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; };
182 #if ML_DEPRECATED_SINCE(3,5,0)
183 [[nodiscard]][[deprecated]]
char*
getPersistentState()
const override {
return nullptr; }
209 template <
typename DATATYPE>
213 if (_isBGFill) { pSubImg->
fill(ml_cast_from_scalar<DATATYPE>(_bgFillValue)); }
216 const DATATYPE fillVal = ml_cast_from_scalar<DATATYPE>(_fillValue);
220 for (p.
u=box.
v1.
u; p.
u<=box.
v2.
u; p.
u++){
221 for (p.
t=box.
v1.
t; p.
t<=box.
v2.
t; p.
t++){
222 for (p.
c=box.
v1.
c; p.
c<=box.
v2.
c; p.
c++){
226 for (p.
z=box.
v1.
z; p.
z<=box.
v2.
z; p.
z++){
234 switch (_testFuncMode){
240 if (_voxelTestFunction){
241 for (p.
y=box.
v1.
y; p.
y<=box.
v2.
y; p.
y++){
243 if (_useModifierFunction && _modifierFunction){
245 for (p.
x=box.
v1.
x; p.
x<=box.
v2.
x; p.
x++){
246 if (_voxelTestFunction(p, _voxelTestFunctionData)){
247 _modifierFunction(pSubImg, p, _modifierFunctionData);
253 for (p.
x=box.
v1.
x; p.
x<=box.
v2.
x; p.
x++){
254 if (_voxelTestFunction(p, _voxelTestFunctionData)){
267 for (p.
y=box.
v1.
y; p.
y<=box.
v2.
y; p.
y++){
269 if (_useModifierFunction && _modifierFunction){
271 for (p.
x=box.
v1.
x; p.
x<=box.
v2.
x; p.
x++){
272 if (isVoxelInside(p)) _modifierFunction(pSubImg, p, _modifierFunctionData);
277 for (p.
x=box.
v1.
x; p.
x<=box.
v2.
x; p.
x++){
289 if (_worldVoxelTestFunction){
293 for (p.
y=box.
v1.
y; p.
y<=box.
v2.
y; p.
y++){
299 if (_useModifierFunction && _modifierFunction){
301 for (p.
x=box.
v1.
x; p.
x<=box.
v2.
x; p.
x++){
302 if (_worldVoxelTestFunction(moveX, _worldVoxelTestFunctionData)){
303 _modifierFunction(pSubImg, p, _modifierFunctionData);
311 for (p.
x=box.
v1.
x; p.
x<=box.
v2.
x; p.
x++){
312 if (_worldVoxelTestFunction(moveX, _worldVoxelTestFunctionData)){
332 for (p.
y=box.
v1.
y; p.
y<=box.
v2.
y; p.
y++){
338 if (_useModifierFunction && _modifierFunction){
340 for (p.
x=box.
v1.
x; p.
x<=box.
v2.
x; p.
x++){
341 if (isWorldVoxelInside(moveX)){
342 _modifierFunction(pSubImg, p, _modifierFunctionData);
350 for (p.
x=box.
v1.
x; p.
x<=box.
v2.
x; p.
x++){
351 if (isWorldVoxelInside(moveX)){
364 ML_PRINT_WARNING(
"void RasterFunction::_fillRaster(const SubImageBox &box, TSubImage<DATATYPE> *pSubImg, Vector3 tBase[4]) const",
ML_BAD_PARAMETER,
"Not rastering!");
383 void _composeMatrices();
419 void * _voxelTestFunctionData;
425 void * _worldVoxelTestFunctionData;
430 bool _useModifierFunction;
432 void * _modifierFunctionData;
Class representing general ML objects that support import/export via strings (setPersistentState() an...
virtual void setPersistentState(const std::string &state)
Restores the object's internal state from a string that had been previously generated using persisten...
virtual void clearPersistentState(char *) const
Disposes a string previously allocated by getPersistentState().
virtual char * getPersistentState() const
Returns a C string describing the object's internal state.
Base object to handle implicit or explicit functions to draw into subimages.
virtual bool isWorldVoxelInside(const Vector6 &) const
The implicit function used to test whether a point p is inside (result == 1), onto (result == 0) or o...
void enableBGFilling(bool val)
void _fillRaster(const SubImageBox &box, TSubImage< DATATYPE > *pSubImg, Vector3 tBase[4]) const
Test all voxels within pSubImg against the selected function if they are inside box.
void setPersistentState(const std::string &) override
Restores the object's internal state from a string that had been previously generated using persisten...
void setWorldBoundingBox(const SubImageBoxd &box)
void getModifierFunction(ModifierFunction &f, void *&data) 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)
const Matrix4 & getPretransform() const
std::string persistentState() const override
Returns a string describing the object's internal state.
double getFillValue() const
void getVoxelTestFunction(VoxelTestFunction &f, void *&data) const
const SubImageBox & getVoxBoundingBox() const
Set/Get bounding boxes of objects in implicit functions in voxel or in world coordinates.
RasterFunction(const RasterFunction &f)
Copy constructor.
void setBGFillValue(double val)
virtual void _getTransformBase(const ImageVector &p, Vector3 tBase[4]) const
Get world coordinate of p, and world vectors from p to p+(1,0,0), to p+(0,1,0) and p+(0,...
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
Returns the subImgBox whose voxels are going to be tested.
void setVoxBoundingBox(const SubImageBox &box)
virtual bool isVoxelInside(const ImageVector &) const
The implicit function used to test whether a point p is inside (result == 1), onto (result == 0) or o...
RasterFunction()
Constructor.
void setFillValue(double val)
virtual void draw(SubImage *sImg) const
Fill intersecting area of sImg with the currently selected function using the transformation matrices...
void enableModifierFunction(bool flag)
void setPreTransform(const Matrix4 &pre)
virtual const RasterFunction & operator=(const RasterFunction &f)
Copy operator.
void setFunctionMode(TestFuncMode mode)
double getBGFillValue() const
const Matrix4 & getVoxToWorld() const
const SubImageBoxd & getWorldBoundingBox() const
void setModifierFunction(ModifierFunction f, void *data)
virtual RasterFunction * clone() const
Create a clone of the RasterFunction.
SubImageBoxd - SubImageBox with coordinates of float data type.
This class manages/represents a rectangular 6d image region which is organized linearly in memory.
VectorType v1
Corner v1 of the subimage region (included in region).
VectorType v2
Corner v2 of the subimage region (also included in region!).
This template class manages/represents a rectangular 6d image region in memory which is organized lin...
void setImageValue(const ImageVector &position, DATATYPE value)
Sets the 6d voxel at the given position to the given 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_BAD_PARAMETER
A bad/invalid parameter (or even an inappropriate image) has been passed to a module or an algorithm;...
#define ML_PRINT_WARNING(FUNC_NAME, REASON, HANDLING)
Like ML_PRINT_WARNING_DUMP(FUNC_NAME, REASON, HANDLING, RT_OBJ) without a runtime object to be dumped...
#define MLBASEEXPORT
defined Header file mlBaseInit.h
#define ML_CLASS_HEADER(className)
Same like ML_CLASS_HEADER_EXPORTED with a non existing export symbol.
void(* ModifierFunction)(SubImage *tSubImg, const ImageVector &p, void *userData)
Function type which modifies a value in a typed subimage given by tSubImg.
bool(* WorldVoxelTestFunction)(const Vector6 &p, void *userData)
Function type used to decide whether a voxel is within an object or not.
bool(* VoxelTestFunction)(const ImageVector &p, void *userData)
Function type used to decide whether a voxel is within an object or not.
TestFuncMode
The modes how the voxel is tested.