ML Reference
mlProcessAllPagesHandler.h
Go to the documentation of this file.
1 /*************************************************************************************
2 **
3 ** Copyright 2009, 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_PROCESS_ALL_PAGES_HANDLER_H
14 #define ML_PROCESS_ALL_PAGES_HANDLER_H
15 
17 
18 // ML-includes
19 #include "mlInitSystemML.h"
20 
21 #include "mlModuleInterfaces.h"
22 
23 #include <ThirdPartyWarningsDisable.h>
24 #include <boost/unordered_map.hpp>
25 #include <ThirdPartyWarningsRestore.h>
26 
27 ML_START_NAMESPACE
28 
38 {
39 public:
46  virtual void calculateOutputImageProperties(PagedImage* /*outImg*/) {};
47 
49  virtual bool wantsProgressUpdates() { return false; }
50 
54  virtual void updateProgress(double /*progress*/) {}
55 
57  void install(PagedImage* outImg);
58 
61  virtual const char* getName() { return nullptr; }
62 
63 private:
65  static void calcOutImagePropsCB(void* userData, PagedImage* outImg) { static_cast<ProcessAllPagesHandler*>(userData)->calculateOutputImageProperties(outImg); }
66 };
67 
68 
69 //---------------------------------------------------------------
73 {
74 public:
76 
81 
84  virtual MLErrorCode processTile(const SubImage& image) = 0;
85 
88  virtual SubImageBox calculateInputSubImageBox(const SubImageBox& outputSubImageBox) { return outputSubImageBox; }
89 
91  SubImageBox calculateInputSubImageBox(int inputIndex, const SubImageBox& outputSubImageBox) override;
92 
94  void calculateOutputSubImage(SubImage* outputSubImage, SubImage* inputSubImages, UserThreadData* /*userThreadData*/) override;
95 
96 protected:
98 
99 private:
100  int _inputIndex;
101  MLint _nextPageId;
102 
103  boost::unordered_map<MLint, SubImage> _bufferedImages;
104 };
105 
106 //---------------------------------------------------------------
110 {
111 public:
113 
118 
121  virtual MLErrorCode processTiles(SubImage* images) = 0;
122 
125  SubImageBox calculateInputSubImageBox(int /*inputIndex*/, const SubImageBox& outputSubImageBox) override;
126 
128  void calculateOutputSubImage(SubImage* outputSubImage, SubImage* inputSubImages, UserThreadData* /*userThreadData*/) override;
129 
130 protected:
132 
133 private:
134  MLint _nextPageId;
135  int _numInputs;
136 
137  boost::unordered_map<MLint, std::vector<SubImage> > _bufferedImages;
138 };
139 
140 ML_END_NAMESPACE
141 
142 #endif
143 
Base class for the calculation of pages of an output image (PagedImage) of a Module.
A ProcessAllPages handler that offers ordered tile delivery on any number of input images.
void calculateOutputSubImage(SubImage *outputSubImage, SubImage *inputSubImages, UserThreadData *) override
Internal method, do not reimplement!
void calculateOutputImageProperties(PagedImage *image) override
Reimplement this method to specify the virtual output image's data type/size/page extent.
virtual MLErrorCode processTiles(SubImage *images)=0
Reimplement this method to perform the processing, return ML_RESULT_OK if processing should go on; ot...
SubImageBox calculateInputSubImageBox(int, const SubImageBox &outputSubImageBox) override
Reimplement this method to specify the input image box for the input images.
A ProcessAllPages handler that offers ordered tile delivery on a single input image.
virtual MLErrorCode processTile(const SubImage &image)=0
Reimplement this method to perform the processing, return ML_RESULT_OK if processing should go on; ot...
void calculateOutputImageProperties(PagedImage *image) override
Reimplement this method to specify the virtual output image's data type/size/page extent.
virtual SubImageBox calculateInputSubImageBox(const SubImageBox &outputSubImageBox)
Reimplement this method to specify the input image box for the input image with index == _inputIndex.
OrderedSingleInputProcessAllPagesHandler(int inputIndex=0)
SubImageBox calculateInputSubImageBox(int inputIndex, const SubImageBox &outputSubImageBox) override
Internal method, do not reimplement!
void calculateOutputSubImage(SubImage *outputSubImage, SubImage *inputSubImages, UserThreadData *) override
Internal method, do not reimplement!
The class PagedImage, representing a fragmented image that manages properties and data of an image lo...
Definition: mlPagedImage.h:66
Base class for handlers that are used for the Module::processAllPages facility.
virtual void calculateOutputImageProperties(PagedImage *)
Calculates the (temporary and virtual) output image's properties, which by default has the properties...
virtual const char * getName()
Returns the name of the handler.
virtual void updateProgress(double)
Called in regular intervals if wantsProgressUpdates() == true.
void install(PagedImage *outImg)
Installs the handler on the PagedImage, which is typically called by the ML Host; do not call it your...
virtual bool wantsProgressUpdates()
Returns whether the handler wants to receive progress updates via updateProgress().
This class manages/represents a rectangular 6D image region that is organized linearly in memory.
Definition: mlSubImage.h:75
Base class for thread local data that is passed to CalculateOutputImageHandler::calculateOutputSubIma...
MLint32 MLErrorCode
Type of an ML Error code.
Definition: mlTypeDefs.h:716
#define MLEXPORT
To export symbols from a DLL/shared object, we need to mark them with the MLEXPORT symbol.
MLint64 MLint
A signed ML integer type with at least 64 bits used for index calculations on very large images even ...
Definition: mlTypeDefs.h:490