MeVisLab Toolbox Reference
mlModule.h
Go to the documentation of this file.
1 /*************************************************************************************
2 **
3 ** Copyright 2007, MeVis Medical Solutions AG
4 **
5 ** The user may use this file in accordance with the license agreement provided with
6 ** the Software or, alternatively, in accordance with the terms contained in a
7 ** written agreement between the user and MeVis Medical Solutions AG.
8 **
9 ** For further information use the contact form at https://www.mevislab.de/contact
10 **
11 **************************************************************************************/
12 
13 #ifndef ML_MODULE_H
14 #define ML_MODULE_H
15 
18 
19 // ML-includes
20 #include "mlInitSystemML.h"
21 #include "mlRuntimeSubClass.h"
22 #include "mlBase.h"
23 #include "mlFields.h"
24 #include "mlFieldContainer.h"
25 
26 #include "mlModuleInterfaces.h"
28 #include "mlPagedImage.h"
29 
30 #include <mlMetaProfilePtr.h>
31 
32 
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)));
37 
38 
40 
41 // Namespace ML. It is recommended that all ML classes and modules are in this
42 // name space to avoid collisions with types of other libraries.
43 ML_START_NAMESPACE
44 
45 // ML-classes
46 class SubImage;
47 class PagedImage;
48 class ProcessAllPagesHandler;
49 #if ML_DEPRECATED_SINCE(3,5,0)
50 class BaseOp;
51 class DummyOp;
52 #endif
53 
54 //-------------------------------------------------------------------------
57 
154 //-------------------------------------------------------------------------
156 {
157 
158  //---------------------------------------------------------------------------
160  //---------------------------------------------------------------------------
161  friend class Host;
162  friend class PagedImage;
163  friend class PageRequest;
164  friend class TileRequest;
165  friend class ModuleCalculateOutputImageHandler;
166  friend class State;
167  friend class ClassicHost;
168 
170 
171 public:
172  //---------------------------------------------------------------------------
175  //---------------------------------------------------------------------------
176 
185 public: Module(int numInputImages, int numOutputImages);
186 
192 public: ~Module() override;
194 
195 
196 
197  //---------------------------------------------------------------------------
200  //---------------------------------------------------------------------------
201 
208 protected: void setOutputImageInplace(MLint outputIndex=0, MLint inputIndex=0);
209 
213 protected: void unsetOutputImageInplace(MLint outputIndex=0);
214 
219 public: MLint getOutputImageInplace(MLint outputIndex=0) const;
220 
221 
222 
228 protected: void setBypass(MLint outputIndex=0, MLint inputIndex=0);
229 
233 public: MLint getBypass(MLint outputIndex=0) const;
234 
238 protected: void setClampPagesToImageExtent(bool flag = true);
239 
243  NO_THREAD_SUPPORT = PagedImage::NO_THREAD_SUPPORT,
244  MULTITHREADED = PagedImage::MULTITHREADED,
245  IO_THREAD = PagedImage::IO_THREAD,
246 
247  ML_CALCULATEOUTPUTSUBIMAGE_ON_STD_TYPES = PagedImage::MULTITHREADED,
248  ML_CALCULATEOUTPUTSUBIMAGE_ON_ALL_TYPES = PagedImage::MULTITHREADED,
249 #if ML_DEPRECATED_SINCE(3,5,0)
250  CALC_OUTSUBIMAGE_ON_STD_TYPES = PagedImage::MULTITHREADED,
251  CALC_OUTSUBIMAGE_ON_ALL_TYPES = PagedImage::MULTITHREADED
252 #endif
253  };
254 
257 protected: void setThreadSupport(THREAD_SUPPORT supportMode);
258 
262 
263 
267 protected: void permitRecursiveHandleNotifications(bool enable);
268 
272 
279 
281 
282 
283  //---------------------------------------------------------------------------
286  //---------------------------------------------------------------------------
288 public: enum PERMITTED_TYPES {
292  ONLY_STANDARD_TYPES = ONLY_SCALAR_TYPES,
293  FULLY_OPERATIONAL = ONLY_DEFAULT_TYPES,
294  MINIMUM_OPERATIONAL = ALL_REGISTERED_TYPES
295 };
296 
312 protected: void setVoxelDataTypeSupport(PERMITTED_TYPES permTypes);
313 
318 
321 public: bool isSupportedVoxelDataType(MLDataType dt) const;
323 
324  //---------------------------------------------------------------------------
327  //---------------------------------------------------------------------------
328 
330 public: enum INPUT_STATE {
331  DISCONNECTED = 0, //<! defines that the input is disconnected. In the case of handleInput, this means that the input image can not be updated to a valid image.
332  CONNECTED_BUT_INVALID = 1, //<! defines that the input is connected but has no valid data.
333  CONNECTED_AND_VALID = 2, //<! defines that the input is connected and valid.
334  CONNECTED_BUT_NEEDS_UPDATE = 3, //<! defines that the input is connected and needs to be updated via updateImageProperties(). After the update it may either become CONNECTED_AND_VALID or CONNECTED_BUT_INVALID.
335 #if ML_DEPRECATED_SINCE(3,5,0)
336  OPEN = DISCONNECTED, //<! \deprecated, use DISCONNECTED
337  UNDEFINED_CLOSED = CONNECTED_BUT_INVALID //<! \deprecated, use CONNECTED_BUT_INVALID
338 #endif
339 };
340 
342 public: enum INPUT_HANDLE {
343  INVALIDATE = 0, //<! Used as return value of handleInput() to indicate that the given input is not allowed to be invalid and the output images of the module should be invalidated without calling calculateOutputImageProperties().
344  ALLOW_INVALID_INPUT = 2, //<! Used as return value of handleInput() to indicate that the given input is allowed to be invalid. calculateOutputImageProperties() will be called and getInputImage() for that input index will return NULL.
345 #if ML_DEPRECATED_SINCE(3,5,0)
346  REDIRECT_TO_DUMMY_OP = 1, //<! Deprecated flag to indicate that an invalid input should be redirected to the DummyOp module.
347 #endif
348 };
349 
377 public: virtual INPUT_HANDLE handleInput(int /*inputIndex*/, INPUT_STATE /*state*/) const { return INVALIDATE; }
378 
387 
394 
395 
396 
397  //---------------------------------------------------------------------------
400  //---------------------------------------------------------------------------
401 
402 public:
407 
410 
413 
415  PagedImage* getOutputImage(MLint outputIndex=0) const;
416 
420  InputConnectorField* addInputImage(const char* name = nullptr);
421 
426  OutputConnectorField* addOutputImage(const char* name = nullptr);
427 
428  //---------------------------------------------------------------------------
443  //---------------------------------------------------------------------------
444 public: PagedImage* getInputImage(MLint inputIndex, bool getReal=false) const;
445 
446  //---------------------------------------------------------------------------
457  //---------------------------------------------------------------------------
458 public: PagedImage *getUpdatedInputImage(MLint inputIndex, bool getReal=false) const;
459 
461 
462 
463 
464  //---------------------------------------------------------------------------
467  // These functions are identical to those from
468  // Host::getDefaultHost() and are
469  // wrapped here for convenience.
470  // See mlHost.h for documentation.
471  //---------------------------------------------------------------------------
472 public:
473 
476  [[nodiscard]]
478  SubImageBox loc,
479  MLDataType datatype,
480  void** data,
481  const ScaleShiftData &scaleShiftData=ScaleShiftData(),
482  MLRequestProgressCB* progressCallback = nullptr,
483  void* progressCallbackUserData = nullptr);
484 
488  [[nodiscard]]
490  SubImage &subimg,
491  const ScaleShiftData &scaleShiftData = ScaleShiftData(),
492  MLRequestProgressCB* progressCallback = nullptr,
493  void* progressCallbackUserData = nullptr);
494 
498 
500  static void freeTile(void* data);
501 
503  static void updateProgress(const char* info1, const char* info2);
504 
506  static bool shouldTerminate();
507 
510 
521  static void adaptPageExtent (ImageVector& pageExtent,
522  MLDataType imageType,
523  const ImageVector& newImgExtent,
524  const ImageVector& oldImgExtent,
525  const ImageVector& pageUnit = ImageVector(0),
526  const ImageVector& minPageExtent = ImageVector(0),
527  const ImageVector& maxPageExtent = ImageVector(0));
528 
530 
531  //---------------------------------------------------------------------------
534  //---------------------------------------------------------------------------
535 
542  static std::string getVoxelValueAsString(PagedImage* image,
543  const ImageVector& position,
544  MLErrorCode* errorCode=nullptr,
545  const std::string& errorResult="");
547 
548 
549 
550  //---------------------------------------------------------------------------
553  //---------------------------------------------------------------------------
554 
584 
600 protected: virtual void calculateOutputImageProperties(int outputIndex, PagedImage* /*outputImage*/) { calculateOutputImageProperties(outputIndex); }
601 
602 #if ML_DEPRECATED_SINCE(3,6,0)
605 protected: virtual void calculateOutputImageProperties(int /*outputIndex*/) {}
606 #else
607 private: virtual void calculateOutputImageProperties(int /*outputIndex*/) {}
608 #endif
609 
616 protected: virtual SubImageBox calculateInputSubImageBox(int /*inputIndex*/,
617  const SubImageBox& outputSubImageBox,
618  int /*outputIndex*/)
619  {
620  return outputSubImageBox;
621  };
622 
637 protected: virtual void calculateOutputSubImage(SubImage *outputSubImage, int outputIndex, SubImage *inputSubImages);
638 
640 
641  //---------------------------------------------------------------------------
644  //---------------------------------------------------------------------------
645 
653 protected: virtual void provideCustomPage(int /*outputIndex*/, const SubImageBox& /*pageBox*/, MLMemoryBlockHandle& /*resultPage*/) {};
654 
656 
657  //---------------------------------------------------------------------------
660  //---------------------------------------------------------------------------
698 public:
699  [[nodiscard]]
700  MLErrorCode processAllPages(int outputIndex = -1,
701  SubImageBox region = SubImageBox(),
702  MLRequestProgressCB* progressCallback = nullptr,
703  void* progressCallbackUserData = nullptr);
704 
710 public:
711  [[nodiscard]]
713  SubImageBox region = SubImageBox(),
714  MLRequestProgressCB* progressCallback = nullptr,
715  void* progressCallbackUserData = nullptr);
716 
721 public:
722  [[nodiscard]]
723  MLErrorCode processMissingPages(int outputIndex = 0,
724  SubImageBox region = SubImageBox(),
725  MLRequestProgressCB* progressCallback = nullptr,
726  void* progressCallbackUserData = nullptr);
728 
729 
730 
731  //---------------------------------------------------------------------------
734  //---------------------------------------------------------------------------
735 
737 public: void clearOutputImage(MLint i=0);
739 
742 
743 
744 
745 public:
746  //---------------------------------------------------------------------------
749  //---------------------------------------------------------------------------
752 protected: void handleNotificationOff();
753 
756 protected: void handleNotificationOn();
757 
759 protected: bool isHandleNotificationOn();
761 
762 
763  //---------------------------------------------------------------------------
766  //---------------------------------------------------------------------------
767 
769 public: bool isInputImageField(Field* field) const;
770 
772 public: void touchOutputImageFields() const;
773 
777 public: inline FieldContainer* getFieldContainer() { return this; }
778 
782 public: inline const FieldContainer* getFieldContainer() const { return this; }
783 
798 protected: virtual void handleNotification(Field* /*field*/) {}
799 
803 public: virtual void beginSaveFields() {}
804 
808 public: virtual void endSaveFields() {}
810 
813 protected: void handleNotificationInternal(Field* field, FieldSensor::Strength strength) override;
814 
815 
816  //---------------------------------------------------------------------------
819  //---------------------------------------------------------------------------
821 public: static size_t getNumModules();
822 
824 public: static Module* getModule(size_t index);
825 
827 public: static MLint findModuleIndex(Module& module);
828 
831 public: static void destroyModule();
833 
836 
838 private: void setWasVisited(bool flag) { _visitedFlag = flag; }
839 
841 private: bool wasVisited() { return _visitedFlag; }
842 
844 
845 private:
846  //-----------Private methods:
850  bool _addBaseOp(Module& module);
851 
855  MLint _removeBaseOp(Module& module);
856 
857 
858  //-----------Private members:
860  std::vector <OutputConnectorField*> _outputConnectorFields;
861 
863  std::vector <InputConnectorField*> _inputConnectorFields;
864 
866  THREAD_SUPPORT _threadSupport;
867 
874  MLint _handleNotificationEntryCounter;
875 
879  bool _permitRecursiveHandleNotifications;
880 
882  bool _visitedFlag;
883 
885  PERMITTED_TYPES _permittedTypes;
886 
891  MLint _handleNotificationBlockCounter;
892 
894  mutable MLMetaProfilePtr _metaProfilePtr;
895 
897  static std::vector<Module*> _instantiatedModules;
898 
905 
906 public:
907 
910  const char* getTypeNameFast() const { return getTypeId() ? getTypeId()->getName() : "<unregistered_module>"; }
911 
917  InputConnectorField* addInputConnector(const char* name, Module* module, MLint i) override;
918 
921  OutputConnectorField* addOutputConnector(const char* name, Module* module, MLint i) override;
922 
924 
925 #if ML_DEPRECATED_SINCE(3,5,0)
926 
929 
930 public:
931 
934 protected: void setMemoryOutputControl(MLint outputIndex, bool manually);
935 
938 public: bool getMemoryOutputControl(MLint outputIndex) const;
939 
940 
943  static inline ML_DEPRECATED std::string getVoxelValueAsString(Module &op,
944  MLint outIdx,
945  const ImageVector &pos,
946  MLErrorCode *errCode=nullptr,
947  const std::string &errResult="")
948  {
949  return getVoxelValueAsString(op.getOutputImage(outIdx), pos, errCode, errResult);
950  }
953  [[nodiscard]]
954  static ML_DEPRECATED MLErrorCode getTile(Module* op,
955  MLint outIndex,
956  SubImageBox loc,
957  MLDataType datatype,
958  void** data,
959  const ScaleShiftData &scaleShiftData=ScaleShiftData());
962  [[nodiscard]]
963  static ML_DEPRECATED MLErrorCode getTile(Module* op,
964  MLint outIndex,
965  SubImage &subimg,
966  const ScaleShiftData &scaleShiftData=ScaleShiftData());
969  [[nodiscard]]
970  static ML_DEPRECATED MLErrorCode updateImageProps(Module* op, MLint outIndex);
973  [[nodiscard]]
974  static ML_DEPRECATED MLErrorCode updateImageProperties(Module* op, MLint outIndex);
977  ML_DEPRECATED BaseOp* getInOp(MLint i, bool getReal=false) const;
980  ML_DEPRECATED MLint getInOpIndex(MLint i, bool getReal=false) const;
983  inline ML_DEPRECATED MLint getOutImgInplace(MLint outIndex=0) const { return getOutputImageInplace(outIndex); }
984 
987  ML_DEPRECATED static void getInInfos(const BaseOp &op,
988  MLint i,
989  bool getReal,
990  bool *isValidInputRet,
991  BaseOp **inOpRet,
992  PagedImage **inImgRet,
993  MLint *inOpIndexRet);
994 
997  inline ML_DEPRECATED MLint getInputNum() const { return getNumInputImages(); }
1000  inline ML_DEPRECATED MLint getOutputNum() const { return getNumOutputImages(); }
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); }
1010 
1020  ML_DEPRECATED PagedImage* getNonDummyUpdatedInImg(int inIndex);
1021 
1024  inline ML_DEPRECATED static void adaptPageExt (ImageVector &pageExt,
1025  MLDataType imgType,
1026  const ImageVector &newImgExt,
1027  const ImageVector &oldImgExt,
1028  const ImageVector &pageUnit = ImageVector(0),
1029  const ImageVector &minPageExt = ImageVector(0),
1030  const ImageVector &maxPageExt = ImageVector(0))
1031  {
1032  adaptPageExtent(pageExt, imgType, newImgExt, oldImgExt, pageUnit, minPageExt, maxPageExt);
1033  }
1036  inline ML_DEPRECATED void clearOutImg(MLint i=0) { clearOutputImage(i); }
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(); }
1051  ML_DEPRECATED static BaseOp* getBaseOp(size_t idx);
1054  inline ML_DEPRECATED static MLint findBaseOpIndex(Module &op) { return findModuleIndex(op); }
1057  inline ML_DEPRECATED static void destroyBaseOp() { destroyModule(); }
1058 
1059 
1060 protected:
1061 
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); }
1068 
1070 
1071 #endif
1072 
1073 };
1074 
1076 {
1077 public:
1078  ModuleDiagnosisStackScope(Module* module) : _module(module) { if (pushModuleForDiagnosis) { pushModuleForDiagnosis(_module); } }
1079  ~ModuleDiagnosisStackScope() { if (popModuleForDiagnosis) { popModuleForDiagnosis(_module); } }
1080 
1081  typedef void (*DiagnosisModuleStackCallback)(void*);
1082 
1083  static void setCallbacksForDiagnosisModuleStack(DiagnosisModuleStackCallback pushCallback, DiagnosisModuleStackCallback popCallback)
1084  {
1085  pushModuleForDiagnosis = pushCallback;
1086  popModuleForDiagnosis = popCallback;
1087  }
1088 
1089 private:
1090  static DiagnosisModuleStackCallback pushModuleForDiagnosis;
1091  static DiagnosisModuleStackCallback popModuleForDiagnosis;
1092 
1093  Module* _module;
1094 };
1095 
1096 #if ML_DEPRECATED_SINCE(3,5,0)
1101 #define calcOutImageProps calculateOutputImageProperties
1104 #define calcInSubImageBox calculateInputSubImageBox
1107 #define calcOutSubImage calculateOutputSubImage
1110 #define typedCalcOutSubImage typedCalculateOutputSubImage
1111 
1112 #if defined(WIN32) && !defined(ML_NO_DEPRECATED_WARNINGS)
1113 #pragma deprecated("calcOutImageProps", "calcInSubImageBox", "calcOutSubImage", "typedCalcOutSubImage")
1114 #endif
1115 
1116 #ifndef DOXYGEN_SHOULD_SKIP_THIS
1117 
1123 template<typename CauseAnErrorIfNotSpecified>
1124 class calcInSubImageProps_has_been_removed_from_the_ML {
1125 };
1126 
1128 #define calcInSubImageProps(a,b,c) calcInSubImageProps() { calcInSubImageProps_has_been_removed_from_the_ML; };
1129 
1130 #endif
1131 
1132 // disable deprecation warnings
1133 #ifdef _MSC_VER
1134 #pragma warning(push)
1135 #pragma warning(disable : 4996 )
1136 #endif
1137 
1140 class MLEXPORT ML_DEPRECATED BaseOp : public Module
1141 {
1142 public:
1143  BaseOp(int numInputImages, int numOutputImages):Module(numInputImages, numOutputImages)
1144  {};
1145 
1146  ML_ABSTRACT_CLASS_HEADER(BaseOp)
1147 };
1148 
1149 // re-enable deprecation warnings
1150 #ifdef _MSC_VER
1151 #pragma warning(pop)
1152 #endif
1153 
1155 
1156 #endif
1157 
1158 
1159 ML_END_NAMESPACE
1160 
1161 #endif
1162 
1163 
#define ML_DEPRECATED
Definition: CSOGroup.h:371
The strong handle of a MLMemoryBlock.
The pointer is automatically reset when the meta profile is destroyed.
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.
Definition: mlClassicHost.h:39
Defines the class FieldContainer to encapsulate a vector of fields for (see class Field).
Strength
Enumeration type describing the strength of notifications.
Definition: mlFieldSensor.h:44
Base class for all fields used in the ML.
Definition: mlField.h:73
The Host is the central image processing class in the ML.
Definition: mlHost.h:115
Field to encapsulate a pointer to an input connector which represents a module input.
Definition: mlFields.h:1140
ModuleDiagnosisStackScope(Module *module)
Definition: mlModule.h:1078
static void setCallbacksForDiagnosisModuleStack(DiagnosisModuleStackCallback pushCallback, DiagnosisModuleStackCallback popCallback)
Definition: mlModule.h:1083
Base class for an image processing module of the ML.
Definition: mlModule.h:156
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.
Definition: mlModule.h:342
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.
Definition: mlModule.h:803
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.
Definition: mlModule.h:600
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.
Definition: mlModule.h:330
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).
Definition: mlModule.h:910
void setVoxelDataTypeSupport(PERMITTED_TYPES permTypes)
Specifies which types this module supports.
PERMITTED_TYPES
See documentation of setVoxelDataTypeSupport.
Definition: mlModule.h:288
@ ALL_REGISTERED_TYPES
Definition: mlModule.h:291
@ ONLY_SCALAR_TYPES
Definition: mlModule.h:289
@ ONLY_DEFAULT_TYPES
Definition: mlModule.h:290
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.
Definition: mlModule.h:242
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.
Definition: mlModule.h:777
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.
Definition: mlModule.h:808
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...
Definition: mlModule.h:616
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.
Definition: mlModule.h:653
virtual void handleNotification(Field *)
Called when any field data in the field container of this module is modified.
Definition: mlModule.h:798
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.
Definition: mlModule.h:782
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.
Definition: mlModule.h:377
Field to encapsulate a pointer to an output connector which represents a module output.
Definition: mlFields.h:1085
A PageRequest represents the request for the calculation of a single page of a PagedImage.
Definition: mlPageRequest.h:32
Class which represents an image, which manages properties of an image and image data which is located...
Definition: mlPagedImage.h:70
@ MULTITHREADED
< The calculation of the image data can be called from multiple threads
Definition: mlPagedImage.h:84
@ IO_THREAD
< The calculation of the image data can be called from a designated IO thread
Definition: mlPagedImage.h:85
@ NO_THREAD_SUPPORT
< The image can only be calculated from the main thread
Definition: mlPagedImage.h:83
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.
Definition: mlSubImage.h:75
A TileRequest either represents the input sub image that is needed by a PageRequest or if it is a roo...
Definition: mlTileRequest.h:50
#define ML_DISALLOW_COPY_AND_ASSIGN(className)
Defines basic macros.
Definition: mlMacros.h:23
#define ML_ABSTRACT_CLASS_HEADER(className)
Same like ML_ABSTRACT_CLASS_HEADER_EXPORTED with a non existing export symbol.
MLint32 MLDataType
MLDataType.
Definition: mlTypeDefs.h:684
MLint32 MLErrorCode
Type of an ML Error code.
Definition: mlTypeDefs.h:818
#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)
Definition: mlTypeDefs.h:1318
MLint64 MLint
A signed ML integer type with at least 64 bits used for index calculations on very large images even ...
Definition: mlTypeDefs.h:578
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.