ML Reference
mlPageIDIterator.h
Go to the documentation of this file.
1 // **InsertLicense** code
2 //-------------------------------------------------------------------------
9 //-------------------------------------------------------------------------
10 #ifndef __mlPageIDIterator_H
11 #define __mlPageIDIterator_H
12 
13 // ML-includes
14 #include "mlInitSystemML.h"
15 
16 #include "mlPagedImage.h"
17 
18 ML_START_NAMESPACE
19 
20 //-------------------------------------------------------------------------------------------
23 //-------------------------------------------------------------------------------------------
25 {
26 
27 public:
28 
31 
33  MLEXPORT PageIDIterator(PagedImage& image, const SubImageBox& box);
34 
36  MLEXPORT ~PageIDIterator();
37 
39  MLEXPORT void setup(PagedImage& image, const SubImageBox& box);
40 
42  inline MLint getNextPageID() {
43  MLint result = _currentPageId;
44 
45  // in case of being the last pageid, we stop incrementing
46  if (result==_lastPageId) {
47  return result;
48  }
49 
50  // increment the page id in all 6 dimensions, if overflow occurs:
51  _currentPageId++;
52  _currentPosition.x++;
53  if (_currentPosition.x >= _pageBoxExtent.x) {
54  _currentPosition.x = 0;
55  _currentPageId -= _pageBoxExtent.x;
56 
57  _currentPageId += _pageStride.y;
58  _currentPosition.y++;
59  if (_currentPosition.y >= _pageBoxExtent.y) {
60  _currentPosition.y = 0;
61  _currentPageId -= _pageBoxExtent.y * _pageStride.y;
62 
63  _currentPageId += _pageStride.z;
64  _currentPosition.z++;
65  if (_currentPosition.z >= _pageBoxExtent.z) {
66  _currentPosition.z = 0;
67  _currentPageId -= _pageBoxExtent.z * _pageStride.z;
68 
69  _currentPageId += _pageStride.c;
70  _currentPosition.c++;
71  if (_currentPosition.c >= _pageBoxExtent.c) {
72  _currentPosition.c = 0;
73  _currentPageId -= _pageBoxExtent.c * _pageStride.c;
74 
75  _currentPageId += _pageStride.t;
76  _currentPosition.t++;
77  if (_currentPosition.t >= _pageBoxExtent.t) {
78  _currentPosition.t = 0;
79  _currentPageId -= _pageBoxExtent.t * _pageStride.t;
80 
81  _currentPageId += _pageStride.u;
82  _currentPosition.u++;
83  }
84  }
85  }
86  }
87  }
88  return result;
89  }
90 
92  inline MLint getNumPages() const { return _numberOfPages; }
93 
94 private:
95  ImageVector _pageStride;
96  ImageVector _currentPosition;
97  ImageVector _pageBoxExtent;
98  MLint _currentPageId;
99  MLint _lastPageId;
100  MLint _numberOfPages;
101 
102 };
103 
104 ML_END_NAMESPACE
105 
106 #endif //of __mlPageIDIterator_H
107 
MLint getNumPages() const
Returns the number of pages that are part of the box.
Class which represents an image, which manages properties of an image and image data which is located...
Definition: mlPagedImage.h:66
MLint64 MLint
A signed ML integer type with at least 64 bits used for index calculations on very large images even ...
Definition: mlTypeDefs.h:576
Defines system-specific macros for this project/DLL.
#define MLEXPORT
To export symbols from a dll/shared object, we need to mark them with the MLEXPORT symbol...
A class that allows to incrementally iterate over all ids of pages have an intersection with a given ...
MLint getNextPageID()
Returns the next page id, may only be called as often as getNumPages() returns.
ML_LINEAR_ALGEBRA_EXPORT typedef TImageVector< MLint > ImageVector
Defines the standard ImageVector type which is used by the ML for indexing and coordinates.
Contains the class PagedImage which represents an fragmented image which manages properties of an ima...