MeVisLab Toolbox Reference
Loading...
Searching...
No Matches
mlBackgroundTaskTileProcessor.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_BACKGROUND_TASK_TILE_PROCESSOR_H
14#define ML_BACKGROUND_TASK_TILE_PROCESSOR_H
15
16// Local includes
18
20#include "mlTileIterator.h"
21
22#include <ThirdPartyWarningsDisable.h>
23#include <deque>
24#include <ThirdPartyWarningsRestore.h>
25
27
28//-----------------------------------------------------------------------
29
30class ModuleBackgroundTask;
31
35{
36public:
38
41
42 //--------------------------------------------------------------------------------------------
43 //
46 //
47 //--------------------------------------------------------------------------------------------
48
51
53 virtual bool processTile(ManagedSubImage& image) = 0;
54
58
60
61 //--------------------------------------------------------------------------------------------
62 //
65 //
66 //--------------------------------------------------------------------------------------------
67
70 {
71 _dataType = dt;
72 }
75 {
76 return _dataType;
77 }
78
80 void setInputImageIndex(int index)
81 {
82 _inputImageIndex = index;
83 }
86 {
87 return _inputImageIndex;
88 }
89
93 {
94 _allocationPolicy = policy;
95 }
96
98 void setMaximumQueuedTiles(int size)
99 {
100 _maxQueuedTiles = size;
101 }
102
104
105 //--------------------------------------------------------------------------------------------
106 //
109 //
110 //--------------------------------------------------------------------------------------------
111
114
116
117protected:
119 virtual bool setupProcessing(ModuleBackgroundTask& /*task*/)
120 {
121 return true;
122 }
123
126 {
127 return true;
128 }
129
132 {
133 _numTiles = tiles;
134 }
135
136private:
137 int _maxQueuedTiles;
138 std::deque<ImagingBackgroundTask::AsyncTileRequest> _queue;
139
140 int _inputImageIndex;
141 MLDataType _dataType;
142 TileRequest::AllocationPolicy _allocationPolicy;
143
144 MLint _numTiles;
145};
146
147
148//----------------------------------------------------------------------------------------------
149
155{
156public:
158
159 //--------------------------------------------------------------------------------------------
160 //
163 //
164 //--------------------------------------------------------------------------------------------
165
167 void setRegion(const SubImageBox& box)
168 {
169 _box = box;
170 }
171
174 void setTileExtent(const ImageVector& extent)
175 {
176 _tileExtent = extent;
177 }
178
183 {
184 _clipTiles = clip;
185 }
186
188
191
194
195private:
196 TileIterator _iterator;
197 SubImageBox _box;
198 ImageVector _tileExtent;
199 bool _clipTiles;
200};
201
203
204#endif
#define MLBACKGROUNDTASKS_EXPORT
BackgroundTaskTileProcessorBase is the base class for processors that request an input image tile-by-...
MLDataType getDataType() const
Returns the data type.
virtual bool setupProcessing(ModuleBackgroundTask &)
Needs to be reimplemented to set up necessary elements before doProcessing() is called to requests ti...
void setAllocationPolicy(TileRequest::AllocationPolicy policy)
Sets the allocation policy of the tiles that are passed to processTile().
virtual bool doProcessing(ModuleBackgroundTask &task)
Starts the processing and returns true if everything went fine.
void setNumTiles(MLint tiles)
Sets the number of tiles that will be processed.
void setInputImageIndex(int index)
Sets the input image from which data is requested. The default is 0.
int getInputImageIndex() const
Returns the input image index.
virtual SubImageBox getNextTileBox()=0
Reimplement to return the next tile's SubImageBox.
void setDataType(MLDataType dt)
Sets the data type. If it is not set, it will use the input image data type.
virtual bool cleanupProcessing(ModuleBackgroundTask &)
Needs to be reimplemented to clean up elements after doProcessing() is called to finished processing ...
void setMaximumQueuedTiles(int size)
Sets the number of tiles that are allowed to be requested on the request queue.
virtual bool processTile(ManagedSubImage &image)=0
Reimplement to process the given tile. Return true if everything was okay.
virtual ManagedSubImage * createExternalBuffer(const SubImageBox &box)
Only needs to be reimplemented to allocate the memory for your tiles yourself.
A BackgroundTaskTileProcessor can be used as a base class for processing an input image tile-by-tile ...
void setTileExtent(const ImageVector &extent)
Sets the desired extent of the individual tiles A component value of -1 means to use the region's ext...
void setRegion(const SubImageBox &box)
Sets the box that shall be processed tile-by-tile. Default is the complete input image's box.
SubImageBox getNextTileBox() override
Reimplemented to return the next tile's box as given by the iterator.
void setClipTilesToRegion(bool clip)
Sets whether the tiles are clipped to the requested region, which means that the tiles are smaller on...
bool setupProcessing(ModuleBackgroundTask &task) override
Reimplemented to set up necessary elements before doProcessing() is called to requests tiles.
ManagedSubImage is derived from SubImage and frees its allocated memory automatically when it is dest...
ModuleBackgroundTask extends the ImagingBackgroundTask with several useful methods that allow asynchr...
Iterator that takes a region and a tile extent, and returns subsequent tiles that cover the region st...
AllocationPolicy
Defines how the TileRequest will allocate its memory.
MLint32 MLDataType
MLDataType.
Definition mlTypeDefs.h:592
Target mlrange_cast(Source arg)
Generic version of checked ML casts.
MLint64 MLint
A signed ML integer type with at least 64 bits used for index calculations on very large images even ...
Definition mlTypeDefs.h:489