MeVisLab Toolbox Reference
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
23ML_START_NAMESPACE
24
25//-------------------------------------------------------------------------------------------
28//-------------------------------------------------------------------------------------------
30{
31
32public:
33
36
39
42
44 MLEXPORT void setup(PagedImage& image, const SubImageBox& box);
45
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 { return _numberOfPages; }
98
99private:
100 ImageVector _pageStride;
101 ImageVector _currentPosition;
102 ImageVector _pageBoxExtent;
103 MLint _currentPageId;
104 MLint _lastPageId;
105 MLint _numberOfPages;
106
107};
108
109ML_END_NAMESPACE
110
111#endif //of __mlPageIDIterator_H
112
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.
#define MLEXPORT
Code it as import symbol if compiled elsewhere.
MLint64 MLint
Definition mlTypeDefs.h:489
TSubImageBox< MLint > SubImageBox
Defines 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 that is used by the ML for indexing and coordinates.