MeVisLabToolboxReference
MeVisLab/Standard/Sources/ML/MLTools/include/mlBitImage.h
Go to the documentation of this file.
00001 // **InsertLicense** code
00002 //----------------------------------------------------------------------------------
00014 
00022 //----------------------------------------------------------------------------------
00023 #ifndef __mlBitImage_H
00024 #define __mlBitImage_H
00025 
00026 // ML-includes
00027 #ifndef __MLToolsSystem_H
00028 #include "MLToolsSystem.h"
00029 #endif
00030 #ifndef __mlModuleIncludes_H
00031 #include "mlModuleIncludes.h"
00032 #endif
00033 #ifndef __mlWrapperMacros_H
00034 #include "mlWrapperMacros.h"
00035 #endif
00036 
00037 ML_START_NAMESPACE
00038 
00040 #define ML_BIT_IMG_SHIFT        5l
00041 
00043 #define ML_BIT_IMG_ALL_BITS     0xffffffffl
00044 
00046 #define ML_BIT_IMG_INDEX_BITS   0x1fl
00047 
00049 #define ML_BIT_IMG_LOW_BIT      0x00000001l
00050 
00052 #define ML_BIT_IMG_HIGH_BIT     0x80000000l
00053 
00055 #define ML_BIT_IMG_DATA_TYPE    MLuint32
00056 
00061 #define ML_BIT_IMG_BIT_IDX_TYPE MLuint64
00062 
00063   //----------------------------------------------------------------------------------
00065   //----------------------------------------------------------------------------------
00066   class ML_UNIX_ONLY_EXPORT(MLTOOLS_EXPORT) BitImage : public Base {
00067 
00068   public:
00069 
00071 
00072     enum OperationModes { SET_MODE = 0, 
00073                           OR_MODE,      
00074                           AND_MODE,     
00075                           XOR_MODE,     
00076                           CLEAR_MODE,   
00077 
00078                           NUM_MODES     
00079                         };
00080 
00081 
00083 
00084 
00085 
00086 
00087 
00088     inline BitImage(bool useExceptions=false)                       { _init(ImageVector(0), useExceptions); }
00089 
00095     inline BitImage(const ImageVector &ext, bool useExceptions=false)    { _init(ext, useExceptions); }
00096 
00102     MLTOOLS_EXPORT BitImage(const BitImage &bitImg);
00103 
00105     MLTOOLS_EXPORT virtual ~BitImage()                              { _reset(); }
00106 
00109     inline void reset()                                             { _reset(); }
00110 
00113     inline bool useExceptionHandling() const                        { return _useExceptions; }
00114 
00117     MLTOOLS_EXPORT void useExceptionHandling(bool useExceptions);
00118 
00123     MLTOOLS_EXPORT const BitImage &operator=(const BitImage &bitImg);
00125 
00126 
00128 
00129 
00130 
00131 
00132 
00133 
00134 
00135 
00136 
00137 
00138 
00139     inline bool                   setExtent(const ImageVector &ext)
00140     {
00141       bool result = _setExt(ext);
00142       
00143       clear(false); //initialize content to zero
00144       
00145       return result;
00146     }
00147 
00149     inline const ImageVector     &getExtent() const                   { return _ext; }
00150 
00152     inline const SubImageBox      getBoxFromImageExtent() const       { return SubImageBox(_ext); }
00153 
00161     inline const SubImageBox     &getSourceBox() const                { return _sourceBox; }
00162 
00170     inline void                 setSourceBox(const SubImageBox &box)  { _sourceBox = box; }
00172 
00173 
00174 
00176 
00177 
00178 
00179     inline const                ImageVector &getStrides() const     { return _strides; }
00180 
00182     inline MLint                getCursorBitIndex() const           { return static_cast<MLint>(_cursorBitIdx); }
00183 
00185     inline bool                 isEmpty() const                     { return _ext.compMul() == 0; }
00186 
00188     inline void                 clear(bool val)                     { if (NULL != _image){ memset(_image, val ? 0xff : 0, _numBytes); } }
00190 
00191 
00193 
00194 
00198     inline bool                 operator[](const ImageVector &pos) const { return isSet(pos); }
00199 
00203     inline void                 setValue(const ImageVector &pos, const bool v) { if (v){ set(pos); } else { clear(pos); } }
00204 
00208     inline void                 set(const ImageVector &pos)              { const MLuint b=_bitIdx(this, pos); _image[b >> ML_BIT_IMG_SHIFT] |= static_cast<ML_BIT_IMG_DATA_TYPE>(ML_BIT_IMG_LOW_BIT << (b & ML_BIT_IMG_INDEX_BITS)); }
00209 
00213     inline void                 clear(const ImageVector &pos)            { const MLuint b = _bitIdx(this, pos); _image[b >> ML_BIT_IMG_SHIFT] &= static_cast<ML_BIT_IMG_DATA_TYPE>(ML_BIT_IMG_ALL_BITS ^ (ML_BIT_IMG_LOW_BIT << (b & ML_BIT_IMG_INDEX_BITS))); }
00214 
00218     inline void                 toggle(const ImageVector &pos)           { const MLuint b=_bitIdx(this, pos); _image[b >> ML_BIT_IMG_SHIFT] ^= static_cast<ML_BIT_IMG_DATA_TYPE>(ML_BIT_IMG_LOW_BIT << (b & ML_BIT_IMG_INDEX_BITS)); }
00219 
00223     inline bool                 isSet(const ImageVector &pos) const      { const MLuint b=_bitIdx(this, pos); return (_image[b >> ML_BIT_IMG_SHIFT] & (ML_BIT_IMG_LOW_BIT << (b & ML_BIT_IMG_INDEX_BITS)))!=0; }
00224 
00227     inline bool                 isInRange(const ImageVector &p) const    { return _isInRangeVector(this, p); }
00228 
00231     inline bool                 isInRange(const Vector6 &p) const        { return _isInRangeVec6(this, p); }
00233 
00234 
00236 
00237 
00238 
00239 
00240     inline void                 setCursorPosition(const ImageVector &pos) { _setCursorPos(pos); }
00241 
00243     inline const ImageVector    &getCursorPosition() const                { return _cursorPos; }
00244 
00246     inline bool                 getCursorValue() const              { return (_image[static_cast<size_t>(_cursorBitIdx >> ML_BIT_IMG_SHIFT)] & (ML_BIT_IMG_LOW_BIT << (_cursorBitIdx & ML_BIT_IMG_INDEX_BITS))) != 0; }
00247 
00249     inline void                 setCursorValue(const bool val)      { if (val){ setCursorValue(); } else{ clearCursorValue(); } }
00250 
00252     inline void                 setCursorValue()                    { _image[static_cast<size_t>(_cursorBitIdx >> ML_BIT_IMG_SHIFT)] |= static_cast<ML_BIT_IMG_DATA_TYPE>((ML_BIT_IMG_LOW_BIT << (_cursorBitIdx & ML_BIT_IMG_INDEX_BITS))); }
00253 
00255     inline void                 toggleCursorValue()                 { _image[static_cast<size_t>(_cursorBitIdx >> ML_BIT_IMG_SHIFT)] ^= static_cast<ML_BIT_IMG_DATA_TYPE>((ML_BIT_IMG_LOW_BIT << (_cursorBitIdx & ML_BIT_IMG_INDEX_BITS))); }
00256 
00258     inline void                 clearCursorValue()                  { _image[static_cast<size_t>(_cursorBitIdx >> ML_BIT_IMG_SHIFT)] &= static_cast<ML_BIT_IMG_DATA_TYPE>((ML_BIT_IMG_ALL_BITS ^ (ML_BIT_IMG_LOW_BIT << (_cursorBitIdx & ML_BIT_IMG_INDEX_BITS)))); }
00259 
00261     inline size_t               getCursorWordIndex() const          { return static_cast<size_t>(_cursorBitIdx >> ML_BIT_IMG_SHIFT); }
00262 
00265     inline ML_BIT_IMG_DATA_TYPE getCursorWord() const               { return _image[static_cast<size_t>(_cursorBitIdx >> ML_BIT_IMG_SHIFT)]; }
00266 
00268     inline ML_BIT_IMG_DATA_TYPE getCursorBitMask() const            { return (static_cast<ML_BIT_IMG_DATA_TYPE>(ML_BIT_IMG_LOW_BIT << (_cursorBitIdx & ML_BIT_IMG_INDEX_BITS))); }
00270 
00272 
00273     inline void moveCursorX()    { _moveCursorF1(this); }
00274     inline void moveCursorY()    { _moveCursorF2(this); }
00275     inline void moveCursorZ()    { _moveCursorF3(this); }
00276     inline void moveCursorC()    { _moveCursorF4(this); }
00277     inline void moveCursorT()    { _moveCursorF5(this); }
00278     inline void moveCursorU()    { _moveCursorF6(this); }
00280 
00282 
00283     inline void  reverseMoveCursorX() { _moveCursorB1(this); }
00284     inline void  reverseMoveCursorY() { _moveCursorB2(this); }
00285     inline void  reverseMoveCursorZ() { _moveCursorB3(this); }
00286     inline void  reverseMoveCursorC() { _moveCursorB4(this); }
00287     inline void  reverseMoveCursorT() { _moveCursorB5(this); }
00288     inline void  reverseMoveCursorU() { _moveCursorB6(this); }
00290 
00292 
00293 
00294 
00295 
00296     MLTOOLS_EXPORT void resetCursor();
00297 
00308     MLTOOLS_EXPORT bool moveCursorXWrapAround();
00310 
00312 
00313 
00314 
00315     MLTOOLS_EXPORT void getStatistics(MLuint64 *numBits, MLuint64 *numSetBits, MLuint64 *numClearedBits);
00316 
00325     MLTOOLS_EXPORT BitImage *getDownScaledBitImage(const ImageVector &scales) const;
00326 
00341     MLTOOLS_EXPORT long updateBitImageFromVolume(const void         *data,
00342                                                  const MLDataType    dType,
00343                                                  const SubImageBox    &origBox,
00344                                                  const double        minVal,
00345                                                  const double        maxVal,
00346                                                  const unsigned char addBorderPixels=0);
00347 
00350     MLTOOLS_EXPORT SubImageBox calculateBoundingBox(bool val=true);
00351 
00360     MLTOOLS_EXPORT void copyToBitImage(BitImage&          dstBitImg,
00361                                        OperationModes     mode   = SET_MODE,
00362                                        const SubImageBox& box    = SubImageBox(),
00363                                        const ImageVector& offset = ImageVector(0));
00364 
00370     MLTOOLS_EXPORT BitImage *getSubBitImageByMask(bool val, 
00371                                                   SubImageBox *maskedBox=NULL);
00373 
00374 
00376 
00377 
00381     MLTOOLS_EXPORT void fill(const SubImageBox &box, const bool value);
00382 
00386     MLTOOLS_EXPORT void invert(const SubImageBox &box);
00387 
00399     MLTOOLS_EXPORT void copyToSubImage(SubImage     &outSubImg,
00400                                        const double bkVal,
00401                                        const double fgVal,
00402                                        const OperationModes mode=SET_MODE) const;
00403 
00404 
00411     MLTOOLS_EXPORT void copyFromSubImage(SubImage          &inImg,
00412                                          const SubImageBox &box,
00413                                          const ImageVector &pos,
00414                                          const double      intMin,
00415                                          const double      intMax);
00417 
00418 
00419 
00421 
00422 
00425     MLTOOLS_EXPORT bool is64BitVersion() const;
00426 
00433     MLTOOLS_EXPORT bool writeToFile(const std::string &path, bool overwrite=true);
00434 
00440     MLTOOLS_EXPORT MLErrorCode save(const std::string &path, bool overwrite=true);
00441 
00442 
00446     MLTOOLS_EXPORT bool readFromFile(const std::string &path);
00447 
00451     MLTOOLS_EXPORT MLErrorCode load(const std::string &path);
00453 
00454 
00455 
00458     MLTOOLS_EXPORT static MLuint32 selfTest();
00459 
00460 #ifdef ML_DEPRECATED
00461 
00463 
00464 
00465   public:
00468     inline ML_DEPRECATED bool setExt(const ImageVector &ext) { return setExtent(ext); }
00469 
00472     inline ML_DEPRECATED const ImageVector &getExt() const { return getExtent(); }
00473 
00476     inline ML_DEPRECATED SubImageBox getBoxFromImgExt() const { return getBoxFromImageExtent(); }
00477 
00480     inline ML_DEPRECATED MLint getCursorBitIdx() const { return getCursorBitIndex(); }
00481 
00484     inline ML_DEPRECATED void copyToSubImg(SubImage      &outSubImg,
00485                                            const double  bkVal,
00486                                            const double  fgVal,
00487                                            const OperationModes mode=SET_MODE) const { copyToSubImage(outSubImg, bkVal, fgVal, mode); }
00488 
00491     inline ML_DEPRECATED void copyFromSubImg(SubImage           &inImg,
00492                                              const SubImageBox  &box,
00493                                              const ImageVector  &pos,
00494                                              const double       intMin,
00495                                              const double       intMax) { copyFromSubImage(inImg, box, pos, intMin, intMax); }
00496 
00499     inline ML_DEPRECATED SubImageBox calcBoundingBox(bool val=true) { return calculateBoundingBox(val); }
00500 
00503     inline ML_DEPRECATED void setCursorPos(const ImageVector &pos) { setCursorPosition(pos); }
00504 
00507     inline ML_DEPRECATED const ImageVector& getCursorPos() const { return getCursorPosition(); }
00508 
00511     inline ML_DEPRECATED void moveFX() { moveCursorX(); }
00512 
00515     inline ML_DEPRECATED void moveFY() { moveCursorY(); }
00516 
00519     inline ML_DEPRECATED void moveFZ() { moveCursorZ(); }
00520 
00523     inline ML_DEPRECATED void moveFC() { moveCursorC(); }
00524 
00527     inline ML_DEPRECATED void moveFT() { moveCursorT(); }
00528 
00531     inline ML_DEPRECATED void moveFU() { moveCursorU(); }
00532 
00535     inline ML_DEPRECATED void moveBX() { reverseMoveCursorX(); }
00536 
00539     inline ML_DEPRECATED void moveBY() { reverseMoveCursorY(); }
00540 
00543     inline ML_DEPRECATED void moveBZ() { reverseMoveCursorZ(); }
00544 
00547     inline ML_DEPRECATED void moveBC() { reverseMoveCursorC(); }
00548 
00551     inline ML_DEPRECATED void moveBT() { reverseMoveCursorT(); }
00552 
00555     inline ML_DEPRECATED void moveBU() { reverseMoveCursorU(); }
00556 
00559     inline ML_DEPRECATED bool moveCursorFXLF() { return moveCursorXWrapAround(); }
00561 
00562 #endif // ML_DEPRECATED
00563 
00564   private:
00565 
00568     IMPLEMENT_DIM_DISPATCHER_P1(_bitIdx, const BitImage, ML_BIT_IMG_BIT_IDX_TYPE, return, const ImageVector &);
00569 
00571 
00572     inline ML_BIT_IMG_BIT_IDX_TYPE _bitIdx1D(const ImageVector &pos) const { return static_cast<ML_BIT_IMG_BIT_IDX_TYPE>(_strides.x*pos.x); }
00573     inline ML_BIT_IMG_BIT_IDX_TYPE _bitIdx2D(const ImageVector &pos) const { return static_cast<ML_BIT_IMG_BIT_IDX_TYPE>(_strides.x*pos.x + _strides.y*pos.y); }
00574     inline ML_BIT_IMG_BIT_IDX_TYPE _bitIdx3D(const ImageVector &pos) const { return static_cast<ML_BIT_IMG_BIT_IDX_TYPE>(_strides.x*pos.x + _strides.y*pos.y + _strides.z*pos.z); }
00575     inline ML_BIT_IMG_BIT_IDX_TYPE _bitIdx4D(const ImageVector &pos) const { return static_cast<ML_BIT_IMG_BIT_IDX_TYPE>(_strides.x*pos.x + _strides.y*pos.y + _strides.z*pos.z + _strides.c*pos.c); }
00576     inline ML_BIT_IMG_BIT_IDX_TYPE _bitIdx5D(const ImageVector &pos) const { return static_cast<ML_BIT_IMG_BIT_IDX_TYPE>(_strides.x*pos.x + _strides.y*pos.y + _strides.z*pos.z + _strides.c*pos.c + _strides.t*pos.t); }
00577     inline ML_BIT_IMG_BIT_IDX_TYPE _bitIdx6D(const ImageVector &pos) const { return static_cast<ML_BIT_IMG_BIT_IDX_TYPE>(_strides.x*pos.x + _strides.y*pos.y + _strides.z*pos.z + _strides.c*pos.c + _strides.t*pos.t + _strides.u*pos.u);  }
00579 
00582     IMPLEMENT_DIM_DISPATCHER_P1(_isInRangeVector, const BitImage, bool, return, const ImageVector &);
00583 
00585 
00586     inline bool _isInRangeVector1D(const ImageVector &p) const { return (p.x<_ext.x) && (p.x>=0); }
00587     inline bool _isInRangeVector2D(const ImageVector &p) const { return (p.x<_ext.x) && (p.y<_ext.y) && (p.x>=0)     && (p.y>=0); }
00588     inline bool _isInRangeVector3D(const ImageVector &p) const { return (p.x<_ext.x) && (p.y<_ext.y) && (p.z<_ext.z) && (p.x>=0)     && (p.y>=0)     && (p.z>=0); }
00589     inline bool _isInRangeVector4D(const ImageVector &p) const { return (p.x<_ext.x) && (p.y<_ext.y) && (p.z<_ext.z) && (p.c<_ext.c) && (p.x>=0)     && (p.y>=0)     && (p.z>=0)     && (p.c>=0); }
00590     inline bool _isInRangeVector5D(const ImageVector &p) const { return (p.x<_ext.x) && (p.y<_ext.y) && (p.z<_ext.z) && (p.c<_ext.c) && (p.t<_ext.t) && (p.x>=0)     && (p.y>=0)     && (p.z>=0)     && (p.c>=0)     && (p.t>=0); }
00591     inline bool _isInRangeVector6D(const ImageVector &p) const { return (p.x<_ext.x) && (p.y<_ext.y) && (p.z<_ext.z) && (p.c<_ext.c) && (p.t<_ext.t) && (p.u<_ext.u) && (p.x>=0)     && (p.y>=0)     && (p.z>=0)     && (p.c>=0)     && (p.t>=0)     && (p.u>=0); }
00593 
00594 
00595 
00598     IMPLEMENT_DIM_DISPATCHER_P1(_isInRangeVec6, const BitImage, bool, return, const Vector6 &);
00599 
00601 
00602     inline bool _isInRangeVec61D(const Vector6 &p) const     { return (p[ML_VX]<_ext.x) && (p[ML_VX]>=0); }
00603     inline bool _isInRangeVec62D(const Vector6 &p) const     { return (p[ML_VX]<_ext.x) && (p[ML_VY]<_ext.y) && (p[ML_VX]>=0)     && (p[ML_VY]>=0); }
00604     inline bool _isInRangeVec63D(const Vector6 &p) const     { return (p[ML_VX]<_ext.x) && (p[ML_VY]<_ext.y) && (p[ML_VZ]<_ext.z) && (p[ML_VX]>=0)     && (p[ML_VY]>=0)     && (p[ML_VZ]>=0); }
00605     inline bool _isInRangeVec64D(const Vector6 &p) const     { return (p[ML_VX]<_ext.x) && (p[ML_VY]<_ext.y) && (p[ML_VZ]<_ext.z) && (p[ML_VC]<_ext.c) && (p[ML_VX]>=0)     && (p[ML_VY]>=0)     && (p[ML_VZ]>=0)     && (p[ML_VC]>=0); }
00606     inline bool _isInRangeVec65D(const Vector6 &p) const     { return (p[ML_VX]<_ext.x) && (p[ML_VY]<_ext.y) && (p[ML_VZ]<_ext.z) && (p[ML_VC]<_ext.c) && (p[ML_VT]<_ext.t) && (p[ML_VX]>=0)     && (p[ML_VY]>=0)     && (p[ML_VZ]>=0)     && (p[ML_VC]>=0)   && (p[ML_VT]>=0); }
00607     inline bool _isInRangeVec66D(const Vector6 &p) const     { return (p[ML_VX]<_ext.x) && (p[ML_VY]<_ext.y) && (p[ML_VZ]<_ext.z) && (p[ML_VC]<_ext.c) && (p[ML_VT]<_ext.t) && (p[ML_VU]<_ext.u) && (p[ML_VX]>=0)     && (p[ML_VY]>=0)     && (p[ML_VZ]>=0)   && (p[ML_VC]>=0)   && (p[ML_VT]>=0)   && (p[ML_VU]>=0); }
00609 
00610 
00611 
00614     IMPLEMENT_DIM_DISPATCHER_P0(_isCursorAtEnd, const BitImage, bool, return);
00615 
00617 
00618     inline bool _isCursorAtEnd1D() const { return (_cursorPos.x == _extM1.x); }
00619     inline bool _isCursorAtEnd2D() const { return (_cursorPos.x == _extM1.x) && (_cursorPos.y == _extM1.y); }
00620     inline bool _isCursorAtEnd3D() const { return (_cursorPos.x == _extM1.x) && (_cursorPos.y == _extM1.y) && (_cursorPos.z == _extM1.z); }
00621     inline bool _isCursorAtEnd4D() const { return (_cursorPos.x == _extM1.x) && (_cursorPos.y == _extM1.y) && (_cursorPos.z == _extM1.z) && (_cursorPos.c == _extM1.c); }
00622     inline bool _isCursorAtEnd5D() const { return (_cursorPos.x == _extM1.x) && (_cursorPos.y == _extM1.y) && (_cursorPos.z == _extM1.z) && (_cursorPos.c == _extM1.c) && (_cursorPos.t == _extM1.t); }
00623     inline bool _isCursorAtEnd6D() const { return (_cursorPos.x == _extM1.x) && (_cursorPos.y == _extM1.y) && (_cursorPos.z == _extM1.z) && (_cursorPos.c == _extM1.c) && (_cursorPos.t == _extM1.t) && (_cursorPos.u == _extM1.u); }
00625 
00626 
00627 
00630     IMPLEMENT_EXC_DISPATCHER_P0(_moveCursorF, BitImage, void, ML_EMPTY_SPACE);
00631 
00633 
00634     inline void _moveCursorF1N() { ++_cursorPos.x; _cursorBitIdx++;             }
00635     inline void _moveCursorF2N() { ++_cursorPos.y; _cursorBitIdx += _strides.y; }
00636     inline void _moveCursorF3N() { ++_cursorPos.z; _cursorBitIdx += _strides.z; }
00637     inline void _moveCursorF4N() { ++_cursorPos.c; _cursorBitIdx += _strides.c; }
00638     inline void _moveCursorF5N() { ++_cursorPos.t; _cursorBitIdx += _strides.t; }
00639     inline void _moveCursorF6N() { ++_cursorPos.u; _cursorBitIdx += _strides.u; }
00641 
00643 
00644     inline void _moveCursorF1E() { if (_cursorPos.x >= _extM1.x){ throw(ML_OUT_OF_RANGE); } _moveCursorF1N(); }
00645     inline void _moveCursorF2E() { if (_cursorPos.y >= _extM1.y){ throw(ML_OUT_OF_RANGE); } _moveCursorF2N(); }
00646     inline void _moveCursorF3E() { if (_cursorPos.z >= _extM1.z){ throw(ML_OUT_OF_RANGE); } _moveCursorF3N(); }
00647     inline void _moveCursorF4E() { if (_cursorPos.c >= _extM1.c){ throw(ML_OUT_OF_RANGE); } _moveCursorF4N(); }
00648     inline void _moveCursorF5E() { if (_cursorPos.t >= _extM1.t){ throw(ML_OUT_OF_RANGE); } _moveCursorF5N(); }
00649     inline void _moveCursorF6E() { if (_cursorPos.u >= _extM1.u){ throw(ML_OUT_OF_RANGE); } _moveCursorF6N(); }
00651 
00652 
00653 
00656     IMPLEMENT_EXC_DISPATCHER_P0(_moveCursorB, BitImage, void, ML_EMPTY_SPACE);
00657 
00659 
00660     inline void _moveCursorB1N() { --_cursorPos.x; _cursorBitIdx--;             }
00661     inline void _moveCursorB2N() { --_cursorPos.y; _cursorBitIdx -= _strides.y; }
00662     inline void _moveCursorB3N() { --_cursorPos.z; _cursorBitIdx -= _strides.z; }
00663     inline void _moveCursorB4N() { --_cursorPos.c; _cursorBitIdx -= _strides.c; }
00664     inline void _moveCursorB5N() { --_cursorPos.t; _cursorBitIdx -= _strides.t; }
00665     inline void _moveCursorB6N() { --_cursorPos.u; _cursorBitIdx -= _strides.u; }
00667 
00669 
00670     inline void _moveCursorB1E() { if (!_cursorPos.x){ throw(ML_OUT_OF_RANGE); } _moveCursorB1N(); }
00671     inline void _moveCursorB2E() { if (!_cursorPos.y){ throw(ML_OUT_OF_RANGE); } _moveCursorB2N(); }
00672     inline void _moveCursorB3E() { if (!_cursorPos.z){ throw(ML_OUT_OF_RANGE); } _moveCursorB3N(); }
00673     inline void _moveCursorB4E() { if (!_cursorPos.c){ throw(ML_OUT_OF_RANGE); } _moveCursorB4N(); }
00674     inline void _moveCursorB5E() { if (!_cursorPos.t){ throw(ML_OUT_OF_RANGE); } _moveCursorB5N(); }
00675     inline void _moveCursorB6E() { if (!_cursorPos.u){ throw(ML_OUT_OF_RANGE); } _moveCursorB6N(); }
00677 
00681     inline void _setCursorPos(const ImageVector &pos)
00682       { if (_useExceptions && !isInRange(pos)){ throw(ML_OUT_OF_RANGE); }
00683         _cursorBitIdx = _bitIdx(this, pos);
00684         _cursorPos    = pos;
00685       }
00686 
00691     MLTOOLS_EXPORT bool _init(const ImageVector &ext, bool useExceptions);
00692 
00694     MLTOOLS_EXPORT void _reset();
00695 
00701     MLTOOLS_EXPORT void _updateFunctionPointers(const ImageVector &ext, bool useExceptions);
00702 
00711     MLTOOLS_EXPORT bool _setExt(const ImageVector &ext);
00712 
00713     //------------------------------------------------------
00714     //  Members
00715     //------------------------------------------------------
00716 
00718     ML_BIT_IMG_DATA_TYPE  *_image;
00719 
00721     bool                   _useExceptions;
00722 
00724     ImageVector            _ext;
00725 
00727     ImageVector            _extM1;
00728 
00735     SubImageBox            _sourceBox;
00736 
00738     ImageVector            _strides;
00739 
00741     size_t                 _numWords;
00742 
00744     size_t                 _numBytes;
00745 
00747     ML_BIT_IMG_BIT_IDX_TYPE _cursorBitIdx;
00748 
00750     ImageVector            _cursorPos;
00751 
00753     ML_CLASS_HEADER_EXPORTED(BitImage, MLTOOLS_EXPORT);
00754 
00755   };  // class mlBitImage
00756 
00757 ML_END_NAMESPACE
00758 
00759 #endif // __mlBitImage_H