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 
23 ML_START_NAMESPACE
24 
25 //-------------------------------------------------------------------------------------------
28 //-------------------------------------------------------------------------------------------
30 {
31 
32 public:
33 
36 
39 
42 
44  MLEXPORT void setup(PagedImage& image, const SubImageBox& box);
45 
47  inline MLint getNextPageID() {
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 
99 private:
100  ImageVector _pageStride;
101  ImageVector _currentPosition;
102  ImageVector _pageBoxExtent;
103  MLint _currentPageId;
104  MLint _lastPageId;
105  MLint _numberOfPages;
106 
107 };
108 
109 ML_END_NAMESPACE
110 
111 #endif //of __mlPageIDIterator_H
112 
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 which 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.
Class which represents an image, which manages properties of an image and image data which is located...
Definition: mlPagedImage.h:70
#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:578