13#ifndef ML_RASTER_FUNCTION_H
14#define ML_RASTER_FUNCTION_H
108 { _voxelTestFunction = f; _voxelTestFunctionData = data; };
110 { f = _voxelTestFunction; data = _voxelTestFunctionData; };
117 { _worldVoxelTestFunction = f; _worldVoxelTestFunctionData = data; };
119 { f = _worldVoxelTestFunction; data = _worldVoxelTestFunctionData; };
128 { _modifierFunction = f; _modifierFunctionData = data; };
130 { f = _modifierFunction; data = _modifierFunctionData; };
202 template <
typename DATATYPE>
213 for (p.
u=box.
v1.
u; p.
u<=box.
v2.
u; p.
u++){
214 for (p.
t=box.
v1.
t; p.
t<=box.
v2.
t; p.
t++){
215 for (p.
c=box.
v1.
c; p.
c<=box.
v2.
c; p.
c++){
219 for (p.
z=box.
v1.
z; p.
z<=box.
v2.
z; p.
z++){
227 switch (_testFuncMode){
233 if (_voxelTestFunction){
234 for (p.
y=box.
v1.
y; p.
y<=box.
v2.
y; p.
y++){
236 if (_useModifierFunction && _modifierFunction){
238 for (p.
x=box.
v1.
x; p.
x<=box.
v2.
x; p.
x++){
239 if (_voxelTestFunction(p, _voxelTestFunctionData)){
240 _modifierFunction(pSubImg, p, _modifierFunctionData);
246 for (p.
x=box.
v1.
x; p.
x<=box.
v2.
x; p.
x++){
247 if (_voxelTestFunction(p, _voxelTestFunctionData)){
260 for (p.
y=box.
v1.
y; p.
y<=box.
v2.
y; p.
y++){
262 if (_useModifierFunction && _modifierFunction){
264 for (p.
x=box.
v1.
x; p.
x<=box.
v2.
x; p.
x++){
265 if (
isVoxelInside(p)) _modifierFunction(pSubImg, p, _modifierFunctionData);
270 for (p.
x=box.
v1.
x; p.
x<=box.
v2.
x; p.
x++){
282 if (_worldVoxelTestFunction){
286 for (p.
y=box.
v1.
y; p.
y<=box.
v2.
y; p.
y++){
292 if (_useModifierFunction && _modifierFunction){
294 for (p.
x=box.
v1.
x; p.
x<=box.
v2.
x; p.
x++){
295 if (_worldVoxelTestFunction(moveX, _worldVoxelTestFunctionData)){
296 _modifierFunction(pSubImg, p, _modifierFunctionData);
304 for (p.
x=box.
v1.
x; p.
x<=box.
v2.
x; p.
x++){
305 if (_worldVoxelTestFunction(moveX, _worldVoxelTestFunctionData)){
325 for (p.
y=box.
v1.
y; p.
y<=box.
v2.
y; p.
y++){
331 if (_useModifierFunction && _modifierFunction){
333 for (p.
x=box.
v1.
x; p.
x<=box.
v2.
x; p.
x++){
335 _modifierFunction(pSubImg, p, _modifierFunctionData);
343 for (p.
x=box.
v1.
x; p.
x<=box.
v2.
x; p.
x++){
357 ML_PRINT_WARNING(
"void RasterFunction::_fillRaster(const SubImageBox &box, TSubImage<DATATYPE> *pSubImg, Vector3 tBase[4]) const",
ML_BAD_PARAMETER,
"Not rastering!");
376 void _composeMatrices();
412 void * _voxelTestFunctionData;
418 void * _worldVoxelTestFunctionData;
423 bool _useModifierFunction;
425 void * _modifierFunctionData;
Base object to handle implicit or explicit functions to draw into subimages.
virtual bool isWorldVoxelInside(const Vector6 &) const
const SubImageBox & getVoxBoundingBox() const
const Matrix4 & getVoxToWorld() const
void enableBGFilling(bool val)
void _fillRaster(const SubImageBox &box, TSubImage< DATATYPE > *pSubImg, Vector3 tBase[4]) const
void setPersistentState(const std::string &) override
void setWorldBoundingBox(const SubImageBoxd &box)
void getModifierFunction(ModifierFunction &f, void *&data) const
const Matrix4 & getPretransform() const
~RasterFunction() override
Destructor.
void setWorldVoxelTestFunction(WorldVoxelTestFunction f, void *data)
void getWorldVoxelTestFunction(WorldVoxelTestFunction &f, void *&data) const
TestFuncMode getFunctionMode() const
void setVoxToWorld(const Matrix4 &v2w)
std::string persistentState() const override
Returns a string describing the object's internal state.
double getFillValue() const
void getVoxelTestFunction(VoxelTestFunction &f, void *&data) const
RasterFunction(const RasterFunction &f)
Copy constructor.
void setBGFillValue(double val)
virtual void _getTransformBase(const ImageVector &p, Vector3 tBase[4]) const
bool isModifierFunctionOn() const
virtual SubImageBox _transformSubImgBox(const SubImageBoxd &box) const
Transforms a subImgBox from world coordinates to a subImgBox in voxel coordinates.
void setVoxelTestFunction(VoxelTestFunction f, void *data)
virtual SubImageBox _getClipBox(const SubImageBox &box) const
void setVoxBoundingBox(const SubImageBox &box)
virtual bool isVoxelInside(const ImageVector &) const
RasterFunction()
Constructor.
virtual RasterFunction * clone() const
Create a clone of the RasterFunction.
void setFillValue(double val)
virtual void draw(SubImage *sImg) const
Fill intersecting area of sImg with the currently selected function using the transformation matrices...
const SubImageBoxd & getWorldBoundingBox() const
void enableModifierFunction(bool flag)
void setPreTransform(const Matrix4 &pre)
void setFunctionMode(TestFuncMode mode)
double getBGFillValue() const
virtual const RasterFunction & operator=(const RasterFunction &f)
Copy operator.
void setModifierFunction(ModifierFunction f, void *data)
void setImageValue(const ImageVector &position, DATATYPE value)
void fill(DATATYPE value)
Sets all voxel values in subimage to value.
ComponentType c
Color component of the vector.
ComponentType t
Time component of the vector.
ComponentType u
Unit/Modality/User component of the vector.
ComponentType z
Z component of the vector.
ComponentType x
X component of the vector.
ComponentType y
Y component of the vector.
#define ML_PRINT_WARNING(FUNC_NAME, REASON, HANDLING)
#define MLBASEEXPORT
defined Header file mlBaseInit.h
#define ML_CLASS_HEADER(className)
T ml_cast_from_scalar(double v)
Casts the (scalar) argument to the type of the template argument.
void(* ModifierFunction)(SubImage *tSubImg, const ImageVector &p, void *userData)
Tmat4< MLdouble > Matrix4
The standard 4x4 matrix of type double.
Tvec3< MLdouble > Vector3
A vector with three components of type double.
Tvec6< MLdouble > Vector6
A vector with six components of type double.
bool(* WorldVoxelTestFunction)(const Vector6 &p, void *userData)
TSubImageBox< MLint > SubImageBox
Defines the standard SubImageBox type used in the ML. Its size varies with the size of the MLint type...
bool(* VoxelTestFunction)(const ImageVector &p, void *userData)
TImageVector< MLint > ImageVector
Defines the standard ImageVector type that is used by the ML for indexing and coordinates.