MeVisLab Toolbox Reference
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
69 void setDataType(MLDataType dt) { _dataType = dt; }
71 MLDataType getDataType() const { return _dataType; }
72
74 void setInputImageIndex(int index) { _inputImageIndex = index; }
76 int getInputImageIndex() const { return _inputImageIndex; }
77
79 void setAllocationPolicy(TileRequest::AllocationPolicy policy) { _allocationPolicy = policy; }
80
82 void setMaximumQueuedTiles(int size) { _maxQueuedTiles = size; }
83
85
86 //--------------------------------------------------------------------------------------------
87 //
90 //
91 //--------------------------------------------------------------------------------------------
92
95
97
98protected:
100 virtual bool setupProcessing(ModuleBackgroundTask& /*task*/) { return true; }
101
103 virtual bool cleanupProcessing(ModuleBackgroundTask& /*task*/) { return true; }
104
106 void setNumTiles(MLint tiles) { _numTiles = tiles; }
107
108private:
109 int _maxQueuedTiles;
110 std::deque<ImagingBackgroundTask::AsyncTileRequest > _queue;
111
112 int _inputImageIndex;
113 MLDataType _dataType;
114 TileRequest::AllocationPolicy _allocationPolicy;
115
116 MLint _numTiles;
117};
118
119
120//----------------------------------------------------------------------------------------------
121
127{
128public:
130
131 //--------------------------------------------------------------------------------------------
132 //
135 //
136 //--------------------------------------------------------------------------------------------
137
139 void setRegion(const SubImageBox& box) { _box = box; }
140
142 void setTileExtent(const ImageVector& extent) { _tileExtent = extent; }
143
146 void setClipTilesToRegion(bool clip) { _clipTiles = clip; }
147
149
152
155
156private:
157 TileIterator _iterator;
158 SubImageBox _box;
159 ImageVector _tileExtent;
160 bool _clipTiles;
161};
162
164
165#endif
166
167
#define MLBACKGROUNDTASKS_EXPORT
Project global and OS specific declarations.
BackgroundTaskTileProcessorBase is the base class for processors that request an input image tile-by-...
MLDataType getDataType() const
Get the datatype.
virtual bool setupProcessing(ModuleBackgroundTask &)
Needs to be reimplemented to setup things before doProcessing() requests tiles.
void setAllocationPolicy(TileRequest::AllocationPolicy policy)
Set the allocation policy of the tiles that are passed to processTile() (The default is to use the Me...
virtual bool doProcessing(ModuleBackgroundTask &task)
Start the processing, returns true if everything went fine.
void setNumTiles(MLint tiles)
Set the number of tiles that will be processed.
void setInputImageIndex(int index)
Set the input image from which data is requested (the default is 0).
int getInputImageIndex() const
Get the input image index.
virtual SubImageBox getNextTileBox()=0
Reimplement to return the next tile's SubImageBox.
void setDataType(MLDataType dt)
Set the datatype (if it is not set, it will use the input image datatype).
virtual bool cleanupProcessing(ModuleBackgroundTask &)
Needs to be reimplemented to cleanup things after doProcessing() finished processing tiles.
void setMaximumQueuedTiles(int size)
Set 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 ok.
virtual ManagedSubImage * createExternalBuffer(const SubImageBox &box)
Only needs to be reimplemented to allocate the memory for your tiles yourself, is only called if setA...
A BackgroundTaskTileProcessor can be used as a base class for processing an input image tile-by-tile ...
void setTileExtent(const ImageVector &extent)
Set the desired extent of the individual tiles (a component value of -1 means to use the region's ext...
void setRegion(const SubImageBox &box)
Set 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)
Set if the tiles are clipped to the requested region (default is true), which means that the tiles ar...
bool setupProcessing(ModuleBackgroundTask &task) override
Reimplemented to setup things before doProcessing() requests tiles.
ManagedSubImage is derived from SubImage and frees its allocated memory automatically when it is dest...
ModuleBackgroundTask extends the ImagingBackgroundTask with a number of useful methods that allow asy...
Iterator that takes a region and a tile extent and returns subsequent tiles that cover the region,...
AllocationPolicy
Defines how the TileRequest will allocate its memory.
MLint32 MLDataType
MLDataType.
Definition mlTypeDefs.h:596
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:490