35 #define ML_ADD_FIELD(NAME_P, TYPE_P, VALUE_P) \
36 (static_cast<TYPE_P##Field*> (this->getFieldContainer()->addField(NAME_P, #TYPE_P, VALUE_P)));
48 class ProcessAllPagesHandler;
49 #if ML_DEPRECATED_SINCE(3,5,0)
165 friend class ModuleCalculateOutputImageHandler;
185 public:
Module(
int numInputImages,
int numOutputImages);
249 #if ML_DEPRECATED_SINCE(3,5,0)
251 CALC_OUTSUBIMAGE_ON_ALL_TYPES = PagedImage::MULTITHREADED
292 ONLY_STANDARD_TYPES = ONLY_SCALAR_TYPES,
293 FULLY_OPERATIONAL = ONLY_DEFAULT_TYPES,
294 MINIMUM_OPERATIONAL = ALL_REGISTERED_TYPES
332 CONNECTED_BUT_INVALID = 1,
333 CONNECTED_AND_VALID = 2,
334 CONNECTED_BUT_NEEDS_UPDATE = 3,
335 #if ML_DEPRECATED_SINCE(3,5,0)
337 UNDEFINED_CLOSED = CONNECTED_BUT_INVALID
344 ALLOW_INVALID_INPUT = 2,
345 #if ML_DEPRECATED_SINCE(3,5,0)
346 REDIRECT_TO_DUMMY_OP = 1,
483 void* progressCallbackUserData =
nullptr);
493 void* progressCallbackUserData =
nullptr);
545 const std::string& errorResult=
"");
602 #if ML_DEPRECATED_SINCE(3,6,0)
605 protected:
virtual void calculateOutputImageProperties(
int ) {}
607 private:
virtual void calculateOutputImageProperties(
int ) {}
620 return outputSubImageBox;
703 void* progressCallbackUserData =
nullptr);
715 void* progressCallbackUserData =
nullptr);
726 void* progressCallbackUserData =
nullptr);
838 private:
void setWasVisited(
bool flag) { _visitedFlag = flag; }
841 private:
bool wasVisited() {
return _visitedFlag; }
850 bool _addBaseOp(Module& module);
855 MLint _removeBaseOp(Module& module);
860 std::vector <OutputConnectorField*> _outputConnectorFields;
863 std::vector <InputConnectorField*> _inputConnectorFields;
866 THREAD_SUPPORT _threadSupport;
874 MLint _handleNotificationEntryCounter;
879 bool _permitRecursiveHandleNotifications;
885 PERMITTED_TYPES _permittedTypes;
891 MLint _handleNotificationBlockCounter;
897 static std::vector<Module*> _instantiatedModules;
910 const char*
getTypeNameFast()
const {
return getTypeId() ? getTypeId()->getName() :
"<unregistered_module>"; }
925 #if ML_DEPRECATED_SINCE(3,5,0)
934 protected:
void setMemoryOutputControl(
MLint outputIndex,
bool manually);
938 public:
bool getMemoryOutputControl(
MLint outputIndex)
const;
947 const std::string &errResult=
"")
949 return getVoxelValueAsString(op.
getOutputImage(outIdx), pos, errCode, errResult);
983 inline ML_DEPRECATED MLint getOutImgInplace(
MLint outIndex=0)
const {
return getOutputImageInplace(outIndex); }
990 bool *isValidInputRet,
992 PagedImage **inImgRet,
993 MLint *inOpIndexRet);
1003 inline ML_DEPRECATED PagedImage* getOutImg(
MLint i=0)
const {
return getOutputImage(i); }
1006 inline ML_DEPRECATED PagedImage* getInImg(
MLint i,
bool getReal=
false)
const {
return getInputImage(i, getReal); }
1009 inline ML_DEPRECATED PagedImage* getUpdatedInImg(
MLint i,
bool getReal=
false) {
return getUpdatedInputImage(i, getReal); }
1020 ML_DEPRECATED PagedImage* getNonDummyUpdatedInImg(
int inIndex);
1032 adaptPageExtent(pageExt, imgType, newImgExt, oldImgExt, pageUnit, minPageExt, maxPageExt);
1039 inline ML_DEPRECATED InputConnectorField* getInField(
MLint i)
const {
return getInputImageField(i); }
1042 inline ML_DEPRECATED OutputConnectorField* getOutField(
MLint i=0)
const {
return getOutputImageField(i); }
1045 inline const FieldContainer* getConstFieldContainer()
const {
return getFieldContainer(); }
1048 inline ML_DEPRECATED static size_t getNumBaseOps() {
return getNumModules(); }
1054 inline ML_DEPRECATED static MLint findBaseOpIndex(Module &op) {
return findModuleIndex(op); }
1057 inline ML_DEPRECATED static void destroyBaseOp() { destroyModule(); }
1064 inline ML_DEPRECATED void setOutImgInplace(
MLint outIndex=0,
MLint inIndex=0) { setOutputImageInplace(outIndex, inIndex); }
1067 inline ML_DEPRECATED void unsetOutImgInplace(
MLint outIndex=0) { unsetOutputImageInplace(outIndex); }
1081 typedef void (*DiagnosisModuleStackCallback)(
void*);
1085 pushModuleForDiagnosis = pushCallback;
1086 popModuleForDiagnosis = popCallback;
1090 static DiagnosisModuleStackCallback pushModuleForDiagnosis;
1091 static DiagnosisModuleStackCallback popModuleForDiagnosis;
1096 #if ML_DEPRECATED_SINCE(3,5,0)
1101 #define calcOutImageProps calculateOutputImageProperties
1104 #define calcInSubImageBox calculateInputSubImageBox
1107 #define calcOutSubImage calculateOutputSubImage
1110 #define typedCalcOutSubImage typedCalculateOutputSubImage
1112 #if defined(WIN32) && !defined(ML_NO_DEPRECATED_WARNINGS)
1113 #pragma deprecated("calcOutImageProps", "calcInSubImageBox", "calcOutSubImage", "typedCalcOutSubImage")
1116 #ifndef DOXYGEN_SHOULD_SKIP_THIS
1123 template<
typename CauseAnErrorIfNotSpecified>
1124 class calcInSubImageProps_has_been_removed_from_the_ML {
1128 #define calcInSubImageProps(a,b,c) calcInSubImageProps() { calcInSubImageProps_has_been_removed_from_the_ML; };
1134 #pragma warning(push)
1135 #pragma warning(disable : 4996 )
1143 BaseOp(
int numInputImages,
int numOutputImages):Module(numInputImages, numOutputImages)
1151 #pragma warning(pop)
The strong handle of a MLMemoryBlock.
Base class for the calculation of pages of an output image (PagedImage) of a Module.
Classic ML host used internally to calculate getTile and processAllPages requests.
Defines the class FieldContainer to encapsulate a vector of fields for (see class Field).
Strength
Enumeration type describing the strength of notifications.
Base class for all fields used in the ML.
The Host is the central image processing class in the ML.
~ModuleDiagnosisStackScope()
ModuleDiagnosisStackScope(Module *module)
static void setCallbacksForDiagnosisModuleStack(DiagnosisModuleStackCallback pushCallback, DiagnosisModuleStackCallback popCallback)
Base class for an image processing module of the ML.
static void adaptPageExtent(ImageVector &pageExtent, MLDataType imageType, const ImageVector &newImgExtent, const ImageVector &oldImgExtent, const ImageVector &pageUnit=ImageVector(0), const ImageVector &minPageExtent=ImageVector(0), const ImageVector &maxPageExtent=ImageVector(0))
Adapt page size.
InputConnectorField * addInputConnector(const char *name, Module *module, MLint i) override
static void updateProgress(const char *info1, const char *info2)
For documentation see Host::updateProgress().
OutputConnectorField * addOutputConnector(const char *name, Module *module, MLint i) override
MLMetaProfilePtr & getMetaProfile() const
Returns the meta profile for the base operator.
void handleNotificationOff()
Decreases lock counter for handleNotification calls.
bool isHandleNotificationOn()
Returns true if handleNotification calls are permitted, otherwise false.
bool isSupportedVoxelDataType(MLDataType dt) const
Check if a given data type is supported on the module as configured with setVoxelDataTypeSupport.
MLint getOutputImageInplace(MLint outputIndex=0) const
Return optimization flag: Return index of input image whose input tile is used also as output page fo...
MLErrorCode processAllPages(ProcessAllPagesHandler &handler, SubImageBox region=SubImageBox(), MLRequestProgressCB *progressCallback=nullptr, void *progressCallbackUserData=nullptr)
Process input images with a ProcessAllPagesHandler handler on a temporary output image (which allocat...
void setOutputImageInplace(MLint outputIndex=0, MLint inputIndex=0)
Set optimization flag: If calculating a page in calculateOutputSubImage(), the output image page of o...
void touchOutputImageFields() const
Touch all output image fields to indicate that the images have changed.
~Module() override
Destructor: Destroys this module.
INPUT_HANDLE
See documentation of handleInput.
Module(int numInputImages, int numOutputImages)
Constructor: Initializes numInputImages input images and numOutputImages output images of the module.
MLErrorCode processMissingPages(int outputIndex=0, SubImageBox region=SubImageBox(), MLRequestProgressCB *progressCallback=nullptr, void *progressCallbackUserData=nullptr)
Processes all missing pages on the given output image.
static Module * getModule(size_t index)
Returns pointer to instantiated module index.
OutputConnectorField * addOutputImage(const char *name=nullptr)
Adds a new output image with name to the module.
virtual void beginSaveFields()
Called before all fields data contents of this modules are saved.
static std::string getVoxelValueAsString(PagedImage *image, const ImageVector &position, MLErrorCode *errorCode=nullptr, const std::string &errorResult="")
Returns the voxel value at position position of the image image.
virtual void calculateOutputImageProperties(int outputIndex, PagedImage *)
Set properties of output image outputImage with output index outputIndex.
void setClampPagesToImageExtent(bool flag=true)
Enables/disables page clamping on all output images.
void permitRecursiveHandleNotifications(bool enable)
If this flag is set to enable =true, recursive entries in handleNotification are permitted.
INPUT_STATE
See documentation of handleInput.
INPUT_STATE getInputState(MLint index)
Returns the current state of the input connection.
void setBypass(MLint outputIndex=0, MLint inputIndex=0)
Sets the input image whose pages can also be used instead of output pages for the output image at out...
void setThreadSupport(THREAD_SUPPORT supportMode)
Pass any THREAD_SUPPORT supportMode to decide whether and what type of multithreading is supported by...
bool isInputImageField(Field *field) const
Returns if the given field is an input image field. This can be used in handleNotification(),...
static bool shouldTerminate()
For documentation see Host::shouldTerminate().
virtual CalculateOutputImageHandler * createCalculateOutputImageHandler(PagedImage *outputImage)
Creates the CalculateOutputImageHandler for the given output image outputImage.
void handleNotificationOn()
Increases lock counter for handleNotification calls.
MLint getHandleNotificationEntryCounter() const
A counter returning the current number of (recursive re)entries in handleNotification.
bool areRecursiveHandleNotificationsPermitted() const
Returns if recursive entries in handleNotification are permitted.
const char * getTypeNameFast() const
Macro to declare methods for the ML runtime type system (see mlRuntimeSubClass.h).
void setVoxelDataTypeSupport(PERMITTED_TYPES permTypes)
Specifies which types this module supports.
PERMITTED_TYPES
See documentation of setVoxelDataTypeSupport.
MLint getNumInputImages() const
Returns number of input images of this module.
PagedImage * getOutputImage(MLint outputIndex=0) const
Returns output image outputIndex. The index needs to be in the range [0, getNumOutputImages()-1].
MLint getNumOutputImages() const
Returns number of output images of this module.
PagedImage * getInputImage(MLint inputIndex, bool getReal=false) const
Returns the output image of the module connected to input inputIndex.
OutputConnectorField * getOutputImageField(MLint i=0) const
Returns field representing output image i. i must be a valid index.
THREAD_SUPPORT
Enumerator deciding whether and which type of multithreading is supported by this module.
InputConnectorField * addInputImage(const char *name=nullptr)
Adds a new input image with name to the module.
FieldContainer * getFieldContainer()
Returns a pointer to the container of all the module's fields.
static MLErrorCode getTile(PagedImage *image, SubImageBox loc, MLDataType datatype, void **data, const ScaleShiftData &scaleShiftData=ScaleShiftData(), MLRequestProgressCB *progressCallback=nullptr, void *progressCallbackUserData=nullptr)
For documentation see Host::getTile() function with same signature.
virtual void endSaveFields()
Called after saving all field contents of this module.
MLint getBypass(MLint outputIndex=0) const
Returns the currently bypass index or -1 if bypassing is disabled (default).
virtual void calculateOutputSubImage(SubImage *outputSubImage, int outputIndex, SubImage *inputSubImages)
Calculate page outputSubImage of output image with index outputIndex given the input image tiles in a...
static void freeTile(void *data)
For documentation see Host::freeTile().
void unsetOutputImageInplace(MLint outputIndex=0)
Clear optimization flag: output page of output at outputIndex and input tile shall use different memo...
static void destroyModule()
Destroys static allocated tables to avoid memory leaks.
PagedImage * getUpdatedInputImage(MLint inputIndex, bool getReal=false) const
Convenience method for safe access to the input image at index inputIndex.
THREAD_SUPPORT getThreadSupport() const
Returns the multithreading mode supported by this module, default is NO_THREAD_SUPPORT.
static MLErrorCode getTile(PagedImage *image, SubImage &subimg, const ScaleShiftData &scaleShiftData=ScaleShiftData(), MLRequestProgressCB *progressCallback=nullptr, void *progressCallbackUserData=nullptr)
For documentation see Host::getTile() function with same signature and Module passed as reference.
InputConnectorField * getInputImageField(MLint i) const
Returns the field representing input image i. i must be a valid index.
static MLint findModuleIndex(Module &module)
Returns index of Module module. If not found -1 is returned.
void clearOutputImage(MLint i=0)
Clear cached output image pages of output image i.
static MLErrorCode updateImageProperties(PagedImage *image)
For documentation see Host::updateImageProperties() function with same signature.
void handleNotificationInternal(Field *field, FieldSensor::Strength strength) override
Called from FieldContainer whenever a field changes.
virtual SubImageBox calculateInputSubImageBox(int, const SubImageBox &outputSubImageBox, int)
Called by the Host to determine which input image region (tile) of input inputIndex is required to ca...
MLErrorCode processAllPages(int outputIndex=-1, SubImageBox region=SubImageBox(), MLRequestProgressCB *progressCallback=nullptr, void *progressCallbackUserData=nullptr)
Processes all pages of a module for easy implementation of page-based image processing of complete im...
static size_t getNumModules()
Returns number of instantiated modules.
virtual void provideCustomPage(int, const SubImageBox &, MLMemoryBlockHandle &)
This method allows a Module to provide its own pages to the Host for the outputIndex output image.
virtual void handleNotification(Field *)
Called when any field data in the field container of this module is modified.
PERMITTED_TYPES getVoxelDataTypeSupport() const
Returns the current state of supported voxel data types.
static Field * getPressedNotifyField()
For documentation see Host::getPressedNotifyField().
const FieldContainer * getFieldContainer() const
Returns a constant pointer to the container of all the module's fields.
INPUT_STATE getUpdatedInputState(MLint index)
Returns the updated state of the input image by calling updateImageProperties(index) and returning ge...
virtual INPUT_HANDLE handleInput(int, INPUT_STATE) const
This method may be reimplemented to enable support for invalid input images on the module.
Field to encapsulate a pointer to an output connector which represents a module output.
Class which represents an image, which manages properties of an image and image data which is located...
@ MULTITHREADED
< The calculation of the image data can be called from multiple threads
@ IO_THREAD
< The calculation of the image data can be called from a designated IO thread
@ NO_THREAD_SUPPORT
< The image can only be calculated from the main thread
Base class for handlers that are used for the Module::processAllPages facility.
This class manages/represents a rectangular 6d image region which is organized linearly in memory.
A TileRequest either represents the input sub image that is needed by a PageRequest or if it is a roo...
#define ML_DISALLOW_COPY_AND_ASSIGN(className)
Defines basic macros.
#define ML_ABSTRACT_CLASS_HEADER(className)
Same like ML_ABSTRACT_CLASS_HEADER_EXPORTED with a non existing export symbol.
MLint32 MLDataType
MLDataType.
MLint32 MLErrorCode
Type of an ML Error code.
#define MLEXPORT
To export symbols from a dll/shared object, we need to mark them with the MLEXPORT symbol.
void MLRequestProgressCB(void *usrData, double progress)
MLint64 MLint
A signed ML integer type with at least 64 bits used for index calculations on very large images even ...
TScaleShiftData< MLdouble > ScaleShiftData
Double version of TScaleShiftData for maximum reasonable precision.
TSubImageBox< MLint > SubImageBox
Define the standard SubImageBox type used in the ML. Its size varies with the size of the MLint type.
TImageVector< MLint > ImageVector
Defines the standard ImageVector type which is used by the ML for indexing and coordinates.