MeVisLab Toolbox Reference
Loading...
Searching...
No Matches
mlPageIDIterator.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_PAGE_IDITERATOR_H
14#define ML_PAGE_IDITERATOR_H
15
17
18// ML-includes
19#include "mlInitSystemML.h"
20
21#include "mlPagedImage.h"
22
24
25//-------------------------------------------------------------------------------------------
28//-------------------------------------------------------------------------------------------
30{
31
32public:
35
38
41
43 MLEXPORT void setup(PagedImage& image, const SubImageBox& box);
44
47 {
48 MLint result = _currentPageId;
49
50 // in case of being the last pageid, we stop incrementing
51 if (result == _lastPageId) {
52 return result;
53 }
54
55 // increment the page ID in all 6 dimensions if overflow occurs:
56 _currentPageId++;
57 _currentPosition.x++;
58 if (_currentPosition.x >= _pageBoxExtent.x) {
59 _currentPosition.x = 0;
60 _currentPageId -= _pageBoxExtent.x;
61
62 _currentPageId += _pageStride.y;
63 _currentPosition.y++;
64 if (_currentPosition.y >= _pageBoxExtent.y) {
65 _currentPosition.y = 0;
66 _currentPageId -= _pageBoxExtent.y * _pageStride.y;
67
68 _currentPageId += _pageStride.z;
69 _currentPosition.z++;
70 if (_currentPosition.z >= _pageBoxExtent.z) {
71 _currentPosition.z = 0;
72 _currentPageId -= _pageBoxExtent.z * _pageStride.z;
73
74 _currentPageId += _pageStride.c;
75 _currentPosition.c++;
76 if (_currentPosition.c >= _pageBoxExtent.c) {
77 _currentPosition.c = 0;
78 _currentPageId -= _pageBoxExtent.c * _pageStride.c;
79
80 _currentPageId += _pageStride.t;
81 _currentPosition.t++;
82 if (_currentPosition.t >= _pageBoxExtent.t) {
83 _currentPosition.t = 0;
84 _currentPageId -= _pageBoxExtent.t * _pageStride.t;
85
86 _currentPageId += _pageStride.u;
87 _currentPosition.u++;
88 }
89 }
90 }
91 }
92 }
93 return result;
94 }
95
97 inline MLint getNumPages() const
98 {
99 return _numberOfPages;
100 }
101
102private:
103 ImageVector _pageStride;
104 ImageVector _currentPosition;
105 ImageVector _pageBoxExtent;
106 MLint _currentPageId;
107 MLint _lastPageId;
108 MLint _numberOfPages;
109};
110
112
113#endif // of __mlPageIDIterator_H
A class that allows to incrementally iterate over all IDs of pages have an intersection with a given ...
MLint getNumPages() const
Returns the number of pages that are part of the box.
MLint getNextPageID()
Returns the next page ID, may only be called as often as getNumPages() returns.
MLEXPORT PageIDIterator()
Default Constructor.
MLEXPORT PageIDIterator(PagedImage &image, const SubImageBox &box)
Constructor that calls setup() with given parameters.
MLEXPORT ~PageIDIterator()
Destructor.
MLEXPORT void setup(PagedImage &image, const SubImageBox &box)
Sets up the iterator from the given image and box.
The class PagedImage, representing a fragmented image that manages properties and data of an image lo...
#define MLEXPORT
To export symbols from a DLL/shared object, we need to mark them with the MLEXPORT symbol.
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