ML Reference
|
00001 // **InsertLicense** code 00002 //------------------------------------------------------------------------- 00009 //------------------------------------------------------------------------- 00010 #ifndef __mlPageIDIterator_H 00011 #define __mlPageIDIterator_H 00012 00013 // ML-includes 00014 #ifndef __mlInitSystemML_H 00015 #include "mlInitSystemML.h" 00016 #endif 00017 00018 #include "mlPagedImage.h" 00019 00020 ML_START_NAMESPACE 00021 00022 //------------------------------------------------------------------------------------------- 00025 //------------------------------------------------------------------------------------------- 00026 class PageIDIterator 00027 { 00028 00029 public: 00030 00032 MLEXPORT PageIDIterator(); 00033 00035 MLEXPORT PageIDIterator(PagedImage& image, const SubImageBox& box); 00036 00038 MLEXPORT ~PageIDIterator(); 00039 00041 MLEXPORT void setup(PagedImage& image, const SubImageBox& box); 00042 00044 inline MLint getNextPageID() { 00045 MLint result = _currentPageId; 00046 00047 // in case of being the last pageid, we stop incrementing 00048 if (result==_lastPageId) { 00049 return result; 00050 } 00051 00052 // increment the page id in all 6 dimensions, if overflow occurs: 00053 _currentPageId++; 00054 _currentPosition.x++; 00055 if (_currentPosition.x >= _pageBoxExtent.x) { 00056 _currentPosition.x = 0; 00057 _currentPageId -= _pageBoxExtent.x; 00058 00059 _currentPageId += _pageStride.y; 00060 _currentPosition.y++; 00061 if (_currentPosition.y >= _pageBoxExtent.y) { 00062 _currentPosition.y = 0; 00063 _currentPageId -= _pageBoxExtent.y * _pageStride.y; 00064 00065 _currentPageId += _pageStride.z; 00066 _currentPosition.z++; 00067 if (_currentPosition.z >= _pageBoxExtent.z) { 00068 _currentPosition.z = 0; 00069 _currentPageId -= _pageBoxExtent.z * _pageStride.z; 00070 00071 _currentPageId += _pageStride.c; 00072 _currentPosition.c++; 00073 if (_currentPosition.c >= _pageBoxExtent.c) { 00074 _currentPosition.c = 0; 00075 _currentPageId -= _pageBoxExtent.c * _pageStride.c; 00076 00077 _currentPageId += _pageStride.t; 00078 _currentPosition.t++; 00079 if (_currentPosition.t >= _pageBoxExtent.t) { 00080 _currentPosition.t = 0; 00081 _currentPageId -= _pageBoxExtent.t * _pageStride.t; 00082 00083 _currentPageId += _pageStride.u; 00084 _currentPosition.u++; 00085 } 00086 } 00087 } 00088 } 00089 } 00090 return result; 00091 } 00092 00094 inline MLint getNumPages() const { return _numberOfPages; } 00095 00096 private: 00097 ImageVector _pageStride; 00098 ImageVector _currentPosition; 00099 ImageVector _pageBoxExtent; 00100 MLint _currentPageId; 00101 MLint _lastPageId; 00102 MLint _numberOfPages; 00103 00104 }; 00105 00106 ML_END_NAMESPACE 00107 00108 #endif //of __mlPageIDIterator_H 00109