MeVisLab Toolbox Reference
mlTVirtualVolume.h
Go to the documentation of this file.
1/*************************************************************************************
2**
3** Copyright 2007, 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_TVIRTUAL_VOLUME_H
14#define ML_TVIRTUAL_VOLUME_H
15
16
19
26
27// Include dll-specific settings.
28#include "MLToolsSystem.h"
29
30// Include most ml specific things.
31#include "mlVirtualVolume.h"
32
33// Include BitImage.
34#include "mlBitImage.h"
35
37
38//---------------------------------------------------------------------------------------------------------
209//---------------------------------------------------------------------------------------------------------
210template<typename DATATYPE> class TVirtualVolume {
211
212protected:
214 inline TVirtualVolume(){}
215
219
220public:
221
224
228 {
229 _convenienceInstance = nullptr;
230 _init(vVol);
231 }
232
241 bool areExceptionsOn=false)
242 {
243 _convenienceInstance = new VirtualVolume(image,
244 MLGetDataTypeFromPtr(static_cast<DATATYPE*>(nullptr)),
245 maxNumKB,
246 areExceptionsOn);
247 _init(*_convenienceInstance);
248 }
249
258 MLdouble fillVal = 0,
259 MLint maxNumKB = -1,
260 bool areExceptionsOn = false)
261 {
262 _convenienceInstance = new VirtualVolume(ext,
263 fillVal,
264 MLGetDataTypeFromPtr(static_cast<DATATYPE*>(nullptr)),
265 maxNumKB,
266 areExceptionsOn);
267 _init(*_convenienceInstance);
268 }
269
274 {
275 _cleanUp();
276 delete _convenienceInstance;
277 _convenienceInstance = nullptr;
278 }
279
281 inline VirtualVolume &getVirtualVolume() { return *_virtVol; }
282
288 inline void getValues(const ImageVector *pos, DATATYPE *results, MLuint num);
289
292 inline DATATYPE getValue(const ImageVector &pos) { return _getVoxelFunc(this, pos); }
293
296 inline void setValue(const ImageVector &pos, DATATYPE data) { _setVoxelFunc(this, pos, data); }
297
299 inline void setCursorPosition(const ImageVector & pos) { _setCursorPosFunc(this, pos); }
300
302 inline const ImageVector &getCursorPosition() const { return _cPos; }
303
305 inline void setCursorValue(DATATYPE val);
306
308 inline DATATYPE getCursorValue();
309
311 inline bool isMapped(const ImageVector &pos) const { return _isMappedFunc(this, pos); }
312
315 inline void moveCursorX() { _moveFXFunc(this); }
316 inline void moveCursorY() { _moveFYFunc(this); }
317 inline void moveCursorZ() { _moveFZFunc(this); }
318 inline void moveCursorC() { _moveFCFunc(this); }
319 inline void moveCursorT() { _moveFTFunc(this); }
320 inline void moveCursorU() { _moveFUFunc(this); }
321
322 inline void reverseMoveCursorX() { _moveBXFunc(this); }
323 inline void reverseMoveCursorY() { _moveBYFunc(this); }
324 inline void reverseMoveCursorZ() { _moveBZFunc(this); }
325 inline void reverseMoveCursorC() { _moveBCFunc(this); }
326 inline void reverseMoveCursorT() { _moveBTFunc(this); }
327 inline void reverseMoveCursorU() { _moveBUFunc(this); }
329
331 inline void moveCursorByOffset(const ImageVector &off) { _moveCursorOffsetFunc(this, off);}
332
336 void resetCursor();
337
347 bool moveCursorXWrapAround();
349
353 void fill(const SubImageBox &box, DATATYPE value);
354
359 void copyToSubImage(TSubImage<DATATYPE> &outSubImg);
360
365 void copyFromSubImage(const TSubImage<DATATYPE> &inImg, const SubImageBox &box, const ImageVector &pos);
366
386 //
387 // It would be desirable to have this function in the implementation part, but I
388 // don't know how to do that syntactically with the second template argument.
389 // (Maybe the VC++6 compiler does not support that?)
390 //
391 template <typename OUTDTYPE>
394 bool maskValue = true,
395 bool writeBK = false,
397 {
398 // Save cursor positions of *this, maskBits and outSubImg.
399 const ImageVector vvCursorPos(getCursorPosition());
400 const ImageVector bitImgCursorPos(maskBits.getCursorPosition());
401
402 // Determine valid overlapping region of virtual volume and output page.
403 SubImageBox box = SubImageBox::intersect(_virtVol->getBox(), outSubImg.getBox());
404
405 // Clamp box against bitImage box.
406 box = box.intersect(SubImageBox(maskBits.getExtent()));
407
408 // Scan all voxels in both input subimages which have identical
409 // extents (as specified in calculateInputSubImageBox).
410 ImageVector p = box.v1;
411 for (p.u = box.v1.u; p.u <= box.v2.u; p.u++){
412 for (p.t = box.v1.t; p.t <= box.v2.t; p.t++){
413 for (p.c = box.v1.c; p.c <= box.v2.c; p.c++){
414 for (p.z = box.v1.z; p.z <= box.v2.z; p.z++){
415 for (p.y = box.v1.y; p.y <= box.v2.y; p.y++){
416
417 // Calculate first voxel position in x row.
418 p.x = box.v1.x;
419
420 // Get pointer to first voxels in x-rows of output subimage.
421 OUTDTYPE* oP = outSubImg.getImagePointer(p);
422
423 // Set cursor position in virtual volume.
424 setCursorPosition(p);
425
426 // Set cursor in bitImage of _drawImage.
427 maskBits.setCursorPosition(p);
428
429 // Iterate over all voxels in voxel rows.
430 for (; p.x <= box.v2.x; p.x++){
431
432 // Copy value from virtual volume if corresponding bit
433 // image flag denotes a modified value.
434 if (maskBits.getCursorValue() == maskValue){
435 *oP = static_cast<OUTDTYPE>(getCursorValue());
436 }
437 else{
438 // No copy desired. Set bkVal if writeBK permits it.
439 if (writeBK){ *oP =bkVal; }
440 }
441
442 // Move all image cursors forward, but do not move them
443 // outside image areas in last column to avoid exceptions.
444 if (p.x < box.v2.x){
445 // Move forward the output data pointer.
446 ++oP;
447
448 // Move forward the virtual volume cursor.
449 moveCursorX();
450
451 // Move forward the bit image cursor.
452 maskBits.moveCursorX();
453 }
454 }
455 }
456 }
457 }
458 }
459 }
460
461 // Restore cursor positions.
462 setCursorPosition(vvCursorPos);
463 maskBits.setCursorPosition(bitImgCursorPos);
464 }
465
466
473 inline DATATYPE *getWrittenPageData(MLuint32 wp) const { return static_cast<DATATYPE*>(_virtVol->getWrittenPageData(wp)); }
474
475
476
485 static MLint getIntValueWrapped (void *vv, const ImageVector &pos) { return static_cast<MLint >((static_cast<TVirtualVolume<DATATYPE>*>(vv))->getValue(pos)); }
486 static MLint64 getInt64ValueWrapped (void *vv, const ImageVector &pos) { return static_cast<MLint64 >((static_cast<TVirtualVolume<DATATYPE>*>(vv))->getValue(pos)); }
487 static MLdouble getDoubleValueWrapped (void *vv, const ImageVector &pos) { return static_cast<MLdouble >((static_cast<TVirtualVolume<DATATYPE>*>(vv))->getValue(pos)); }
488 static MLldouble getLDoubleValueWrapped (void *vv, const ImageVector &pos) { return static_cast<MLldouble>((static_cast<TVirtualVolume<DATATYPE>*>(vv))->getValue(pos)); }
489 static MLint getIntCursorValueWrapped (void *vv) { return static_cast<MLint >((static_cast<TVirtualVolume<DATATYPE>*>(vv))->getCursorValue()); }
490 static MLint64 getInt64CursorValueWrapped (void *vv) { return static_cast<MLint64 >((static_cast<TVirtualVolume<DATATYPE>*>(vv))->getCursorValue()); }
491 static MLdouble getDoubleCursorValueWrapped (void *vv) { return static_cast<MLdouble >((static_cast<TVirtualVolume<DATATYPE>*>(vv))->getCursorValue()); }
492 static MLldouble getLDoubleCursorValueWrapped (void *vv) { return static_cast<MLldouble>((static_cast<TVirtualVolume<DATATYPE>*>(vv))->getCursorValue()); }
493 static const ImageVector &getCursorPositionWrapped(void *vv) { return (static_cast<TVirtualVolume<DATATYPE>*>(vv))->getCursorPosition(); }
494 static bool isMappedWrapped (void *vv, const ImageVector &pos) { return (static_cast<TVirtualVolume<DATATYPE>*>(vv))->isMapped(pos); }
495 static void setCursorPositionWrapped (void *vv, const ImageVector &pos) { (static_cast<TVirtualVolume<DATATYPE>*>(vv))->setCursorPosition(pos); }
496 static void setIntValueWrapped (void *vv, const ImageVector &pos, MLint v) { (static_cast<TVirtualVolume<DATATYPE>*>(vv))->setValue(pos, static_cast<DATATYPE>(v)); }
497 static void setInt64ValueWrapped (void *vv, const ImageVector &pos, MLint64 v) { (static_cast<TVirtualVolume<DATATYPE>*>(vv))->setValue(pos, static_cast<DATATYPE>(v)); }
498 static void setDoubleValueWrapped (void *vv, const ImageVector &pos, MLdouble v) { (static_cast<TVirtualVolume<DATATYPE>*>(vv))->setValue(pos, static_cast<DATATYPE>(v)); }
499 static void setLDoubleValueWrapped (void *vv, const ImageVector &pos, MLldouble v) { (static_cast<TVirtualVolume<DATATYPE>*>(vv))->setValue(pos, static_cast<DATATYPE>(v)); }
500 static void setIntCursorValueWrapped (void *vv, MLint v) { (static_cast<TVirtualVolume<DATATYPE>*>(vv))->setCursorValue(static_cast<DATATYPE>(v)); }
501 static void setInt64CursorValueWrapped (void *vv, MLint64 v) { (static_cast<TVirtualVolume<DATATYPE>*>(vv))->setCursorValue(static_cast<DATATYPE>(v)); }
502 static void setDoubleCursorValueWrapped (void *vv, MLdouble v) { (static_cast<TVirtualVolume<DATATYPE>*>(vv))->setCursorValue(static_cast<DATATYPE>(v)); }
503 static void setLDoubleCursorValueWrapped (void *vv, MLldouble v) { (static_cast<TVirtualVolume<DATATYPE>*>(vv))->setCursorValue(static_cast<DATATYPE>(v)); }
504 static void fillIntWrapped (void *vv, const ImageVector &v1, const ImageVector &v2, MLint v){ (static_cast<TVirtualVolume<DATATYPE>*>(vv))->fill(SubImageBox(v1, v2), static_cast<DATATYPE>(v)); }
505 static void fillInt64Wrapped (void *vv, const ImageVector &v1, const ImageVector &v2, MLint64 v){ (static_cast<TVirtualVolume<DATATYPE>*>(vv))->fill(SubImageBox(v1, v2), static_cast<DATATYPE>(v)); }
506 static void fillDoubleWrapped (void *vv, const ImageVector &v1, const ImageVector &v2, MLdouble v){ (static_cast<TVirtualVolume<DATATYPE>*>(vv))->fill(SubImageBox(v1, v2), static_cast<DATATYPE>(v)); }
507 static void fillLDoubleWrapped (void *vv, const ImageVector &v1, const ImageVector &v2, MLldouble v){ (static_cast<TVirtualVolume<DATATYPE>*>(vv))->fill(SubImageBox(v1, v2), static_cast<DATATYPE>(v)); }
508 static void moveCursorXWrapped (void *vv) { (static_cast<TVirtualVolume<DATATYPE>*>(vv))->moveCursorX(); }
509 static void moveCursorYWrapped (void *vv) { (static_cast<TVirtualVolume<DATATYPE>*>(vv))->moveCursorY(); }
510 static void moveCursorZWrapped (void *vv) { (static_cast<TVirtualVolume<DATATYPE>*>(vv))->moveCursorZ(); }
511 static void moveCursorCWrapped (void *vv) { (static_cast<TVirtualVolume<DATATYPE>*>(vv))->moveCursorC(); }
512 static void moveCursorTWrapped (void *vv) { (static_cast<TVirtualVolume<DATATYPE>*>(vv))->moveCursorT(); }
513 static void moveCursorUWrapped (void *vv) { (static_cast<TVirtualVolume<DATATYPE>*>(vv))->moveCursorU(); }
514 static void reverseMoveCursorXWrapped (void *vv) { (static_cast<TVirtualVolume<DATATYPE>*>(vv))->reverseMoveCursorX(); }
515 static void reverseMoveCursorYWrapped (void *vv) { (static_cast<TVirtualVolume<DATATYPE>*>(vv))->reverseMoveCursorY(); }
516 static void reverseMoveCursorZWrapped (void *vv) { (static_cast<TVirtualVolume<DATATYPE>*>(vv))->reverseMoveCursorZ(); }
517 static void reverseMoveCursorCWrapped (void *vv) { (static_cast<TVirtualVolume<DATATYPE>*>(vv))->reverseMoveCursorC(); }
518 static void reverseMoveCursorTWrapped (void *vv) { (static_cast<TVirtualVolume<DATATYPE>*>(vv))->reverseMoveCursorT(); }
519 static void reverseMoveCursorUWrapped (void *vv) { (static_cast<TVirtualVolume<DATATYPE>*>(vv))->reverseMoveCursorU(); }
520 static void moveCursorByOffsetWrapped (void *vv, const ImageVector &off) { (static_cast<TVirtualVolume<DATATYPE>*>(vv))->moveCursorByOffset(off); }
521 static void resetCursorWrapped (void *vv) { (static_cast<TVirtualVolume<DATATYPE>*>(vv))->resetCursor(); }
522 static bool moveCursorXWrapAroundWrapped (void *vv) { return (static_cast<TVirtualVolume<DATATYPE>*>(vv))->moveCursorXWrapAround(); }
524
525protected:
526
527 //------------------------------------------------------------------------------------------------------
528 //------------------------------------------------------------------------------------------------------
529 //------------------------------------------------------------------------------------------------------
530 //
531 //
532 // NOTHING BELOW FOR NORMAL VIRTUAL VOLUME USAGE.
533 //
534 //
535 //------------------------------------------------------------------------------------------------------
536 //------------------------------------------------------------------------------------------------------
537 //------------------------------------------------------------------------------------------------------
538
539
540 //------------------------------------------------------------------------------------------------------
542 //------------------------------------------------------------------------------------------------------
543 void _init(VirtualVolume &vVol);
544
545 //------------------------------------------------------------------------------------------------------
547 //------------------------------------------------------------------------------------------------------
548 void _cleanUp();
549
550 //------------------------------------------------------------------------------------------------------
551 //------------------------------------------------------------------------------------------------------
552 // GetVoxel, SetVoxel and IsMapped implementations.
553 //------------------------------------------------------------------------------------------------------
554 //------------------------------------------------------------------------------------------------------
555
556 //------------------------------------------------------------------------------------------------------
563 //------------------------------------------------------------------------------------------------------
565 inline DATATYPE _getVoxel1D (const ImageVector &pos);
566 inline DATATYPE _getVoxel2D (const ImageVector &pos);
567 inline DATATYPE _getVoxel3D (const ImageVector &pos);
568 inline DATATYPE _getVoxel4D (const ImageVector &pos);
569 inline DATATYPE _getVoxel5D (const ImageVector &pos);
570 inline DATATYPE _getVoxel6D (const ImageVector &pos);
571
572 inline DATATYPE _getVoxel1DE(const ImageVector &pos);
573 inline DATATYPE _getVoxel2DE(const ImageVector &pos);
574 inline DATATYPE _getVoxel3DE(const ImageVector &pos);
575 inline DATATYPE _getVoxel4DE(const ImageVector &pos);
576 inline DATATYPE _getVoxel5DE(const ImageVector &pos);
577 inline DATATYPE _getVoxel6DE(const ImageVector &pos);
579
580 //----------------------------------------------------------------------------------
587 //----------------------------------------------------------------------------------
589 inline void _setVoxel1D (const ImageVector &pos, DATATYPE voxVal);
590 inline void _setVoxel2D (const ImageVector &pos, DATATYPE voxVal);
591 inline void _setVoxel3D (const ImageVector &pos, DATATYPE voxVal);
592 inline void _setVoxel4D (const ImageVector &pos, DATATYPE voxVal);
593 inline void _setVoxel5D (const ImageVector &pos, DATATYPE voxVal);
594 inline void _setVoxel6D (const ImageVector &pos, DATATYPE voxVal);
595
596 inline void _setVoxel1DE(const ImageVector &pos, DATATYPE voxVal);
597 inline void _setVoxel2DE(const ImageVector &pos, DATATYPE voxVal);
598 inline void _setVoxel3DE(const ImageVector &pos, DATATYPE voxVal);
599 inline void _setVoxel4DE(const ImageVector &pos, DATATYPE voxVal);
600 inline void _setVoxel5DE(const ImageVector &pos, DATATYPE voxVal);
601 inline void _setVoxel6DE(const ImageVector &pos, DATATYPE voxVal);
603
604 //----------------------------------------------------------------------------------
610 //----------------------------------------------------------------------------------
612 inline bool _isMapped1D (const ImageVector &pos) const;
613 inline bool _isMapped2D (const ImageVector &pos) const;
614 inline bool _isMapped3D (const ImageVector &pos) const;
615 inline bool _isMapped4D (const ImageVector &pos) const;
616 inline bool _isMapped5D (const ImageVector &pos) const;
617 inline bool _isMapped6D (const ImageVector &pos) const;
618
619 inline bool _isMapped1DE(const ImageVector &pos) const;
620 inline bool _isMapped2DE(const ImageVector &pos) const;
621 inline bool _isMapped3DE(const ImageVector &pos) const;
622 inline bool _isMapped4DE(const ImageVector &pos) const;
623 inline bool _isMapped5DE(const ImageVector &pos) const;
624 inline bool _isMapped6DE(const ImageVector &pos) const;
626
627
628 //--------------------------------------------------------------------------------------------------------------------------
633 //--------------------------------------------------------------------------------------------------------------------------
635 inline static DATATYPE _getVoxel1DCB (TVirtualVolume *obj, const ImageVector &pos) { return obj->_getVoxel1D(pos); };
636 inline static DATATYPE _getVoxel2DCB (TVirtualVolume *obj, const ImageVector &pos) { return obj->_getVoxel2D(pos); };
637 inline static DATATYPE _getVoxel3DCB (TVirtualVolume *obj, const ImageVector &pos) { return obj->_getVoxel3D(pos); };
638 inline static DATATYPE _getVoxel4DCB (TVirtualVolume *obj, const ImageVector &pos) { return obj->_getVoxel4D(pos); };
639 inline static DATATYPE _getVoxel5DCB (TVirtualVolume *obj, const ImageVector &pos) { return obj->_getVoxel5D(pos); };
640 inline static DATATYPE _getVoxel6DCB (TVirtualVolume *obj, const ImageVector &pos) { return obj->_getVoxel6D(pos); };
641
642 inline static DATATYPE _getVoxel1DCBE (TVirtualVolume *obj, const ImageVector &pos) { return obj->_getVoxel1DE(pos); };
643 inline static DATATYPE _getVoxel2DCBE (TVirtualVolume *obj, const ImageVector &pos) { return obj->_getVoxel2DE(pos); };
644 inline static DATATYPE _getVoxel3DCBE (TVirtualVolume *obj, const ImageVector &pos) { return obj->_getVoxel3DE(pos); };
645 inline static DATATYPE _getVoxel4DCBE (TVirtualVolume *obj, const ImageVector &pos) { return obj->_getVoxel4DE(pos); };
646 inline static DATATYPE _getVoxel5DCBE (TVirtualVolume *obj, const ImageVector &pos) { return obj->_getVoxel5DE(pos); };
647 inline static DATATYPE _getVoxel6DCBE (TVirtualVolume *obj, const ImageVector &pos) { return obj->_getVoxel6DE(pos); };
648
649 inline static void _setVoxel1DCB (TVirtualVolume *obj, const ImageVector &pos, DATATYPE voxVal) { obj->_setVoxel1D(pos, voxVal); };
650 inline static void _setVoxel2DCB (TVirtualVolume *obj, const ImageVector &pos, DATATYPE voxVal) { obj->_setVoxel2D(pos, voxVal); };
651 inline static void _setVoxel3DCB (TVirtualVolume *obj, const ImageVector &pos, DATATYPE voxVal) { obj->_setVoxel3D(pos, voxVal); };
652 inline static void _setVoxel4DCB (TVirtualVolume *obj, const ImageVector &pos, DATATYPE voxVal) { obj->_setVoxel4D(pos, voxVal); };
653 inline static void _setVoxel5DCB (TVirtualVolume *obj, const ImageVector &pos, DATATYPE voxVal) { obj->_setVoxel5D(pos, voxVal); };
654 inline static void _setVoxel6DCB (TVirtualVolume *obj, const ImageVector &pos, DATATYPE voxVal) { obj->_setVoxel6D(pos, voxVal); };
655
656 inline static void _setVoxel1DCBE (TVirtualVolume *obj, const ImageVector &pos, DATATYPE voxVal) { obj->_setVoxel1DE(pos, voxVal); };
657 inline static void _setVoxel2DCBE (TVirtualVolume *obj, const ImageVector &pos, DATATYPE voxVal) { obj->_setVoxel2DE(pos, voxVal); };
658 inline static void _setVoxel3DCBE (TVirtualVolume *obj, const ImageVector &pos, DATATYPE voxVal) { obj->_setVoxel3DE(pos, voxVal); };
659 inline static void _setVoxel4DCBE (TVirtualVolume *obj, const ImageVector &pos, DATATYPE voxVal) { obj->_setVoxel4DE(pos, voxVal); };
660 inline static void _setVoxel5DCBE (TVirtualVolume *obj, const ImageVector &pos, DATATYPE voxVal) { obj->_setVoxel5DE(pos, voxVal); };
661 inline static void _setVoxel6DCBE (TVirtualVolume *obj, const ImageVector &pos, DATATYPE voxVal) { obj->_setVoxel6DE(pos, voxVal); };
662
663 inline static bool _isMapped1DCB (const TVirtualVolume *obj, const ImageVector &pos) { return obj->_isMapped1D (pos); }
664 inline static bool _isMapped2DCB (const TVirtualVolume *obj, const ImageVector &pos) { return obj->_isMapped2D (pos); };
665 inline static bool _isMapped3DCB (const TVirtualVolume *obj, const ImageVector &pos) { return obj->_isMapped3D (pos); };
666 inline static bool _isMapped4DCB (const TVirtualVolume *obj, const ImageVector &pos) { return obj->_isMapped4D (pos); };
667 inline static bool _isMapped5DCB (const TVirtualVolume *obj, const ImageVector &pos) { return obj->_isMapped5D (pos); };
668 inline static bool _isMapped6DCB (const TVirtualVolume *obj, const ImageVector &pos) { return obj->_isMapped6D (pos); };
669
670 inline static bool _isMapped1DCBE (const TVirtualVolume *obj, const ImageVector &pos) { return obj->_isMapped1DE(pos); };
671 inline static bool _isMapped2DCBE (const TVirtualVolume *obj, const ImageVector &pos) { return obj->_isMapped2DE(pos); };
672 inline static bool _isMapped3DCBE (const TVirtualVolume *obj, const ImageVector &pos) { return obj->_isMapped3DE(pos); };
673 inline static bool _isMapped4DCBE (const TVirtualVolume *obj, const ImageVector &pos) { return obj->_isMapped4DE(pos); };
674 inline static bool _isMapped5DCBE (const TVirtualVolume *obj, const ImageVector &pos) { return obj->_isMapped5DE(pos); };
675 inline static bool _isMapped6DCBE (const TVirtualVolume *obj, const ImageVector &pos) { return obj->_isMapped6DE(pos); };
677
678
679
680 //----------------------------------------------------------------------------------
681 //----------------------------------------------------------------------------------
683 //----------------------------------------------------------------------------------
684 //----------------------------------------------------------------------------------
685
686 //----------------------------------------------------------------------------------
688 //----------------------------------------------------------------------------------
690 inline void _setCursorPos1D (const ImageVector & p);
691 inline void _setCursorPos2D (const ImageVector & p);
692 inline void _setCursorPos3D (const ImageVector & p);
693 inline void _setCursorPos4D (const ImageVector & p);
694 inline void _setCursorPos5D (const ImageVector & p);
695 inline void _setCursorPos6D (const ImageVector & p);
696
697 inline void _setCursorPos1DE(const ImageVector & p);
698 inline void _setCursorPos2DE(const ImageVector & p);
699 inline void _setCursorPos3DE(const ImageVector & p);
700 inline void _setCursorPos4DE(const ImageVector & p);
701 inline void _setCursorPos5DE(const ImageVector & p);
702 inline void _setCursorPos6DE(const ImageVector & p);
704
705 //--------------------------------------------------------------------------------------------------------------------------
707 //--------------------------------------------------------------------------------------------------------------------------
709 inline static void _setCursorPos1DCB (TVirtualVolume *obj, const ImageVector &p) { obj->_setCursorPos1D(p); };
710 inline static void _setCursorPos2DCB (TVirtualVolume *obj, const ImageVector &p) { obj->_setCursorPos2D(p); };
711 inline static void _setCursorPos3DCB (TVirtualVolume *obj, const ImageVector &p) { obj->_setCursorPos3D(p); };
712 inline static void _setCursorPos4DCB (TVirtualVolume *obj, const ImageVector &p) { obj->_setCursorPos4D(p); };
713 inline static void _setCursorPos5DCB (TVirtualVolume *obj, const ImageVector &p) { obj->_setCursorPos5D(p); };
714 inline static void _setCursorPos6DCB (TVirtualVolume *obj, const ImageVector &p) { obj->_setCursorPos6D(p); };
715
716 inline static void _setCursorPos1DCBE(TVirtualVolume *obj, const ImageVector &p) { obj->_setCursorPos1DE(p); };
717 inline static void _setCursorPos2DCBE(TVirtualVolume *obj, const ImageVector &p) { obj->_setCursorPos2DE(p); };
718 inline static void _setCursorPos3DCBE(TVirtualVolume *obj, const ImageVector &p) { obj->_setCursorPos3DE(p); };
719 inline static void _setCursorPos4DCBE(TVirtualVolume *obj, const ImageVector &p) { obj->_setCursorPos4DE(p); };
720 inline static void _setCursorPos5DCBE(TVirtualVolume *obj, const ImageVector &p) { obj->_setCursorPos5DE(p); };
721 inline static void _setCursorPos6DCBE(TVirtualVolume *obj, const ImageVector &p) { obj->_setCursorPos6DE(p); };
723
724
725 //----------------------------------------------------------------------------------
726 //----------------------------------------------------------------------------------
728 //----------------------------------------------------------------------------------
729 //----------------------------------------------------------------------------------
730
731 //----------------------------------------------------------------------------------
733 //----------------------------------------------------------------------------------
735 inline void _moveCursorOffset1D (const ImageVector & p);
736 inline void _moveCursorOffset2D (const ImageVector & p);
737 inline void _moveCursorOffset3D (const ImageVector & p);
738 inline void _moveCursorOffset4D (const ImageVector & p);
739 inline void _moveCursorOffset5D (const ImageVector & p);
740 inline void _moveCursorOffset6D (const ImageVector & p);
741
742 inline void _moveCursorOffset1DE(const ImageVector & p);
743 inline void _moveCursorOffset2DE(const ImageVector & p);
744 inline void _moveCursorOffset3DE(const ImageVector & p);
745 inline void _moveCursorOffset4DE(const ImageVector & p);
746 inline void _moveCursorOffset5DE(const ImageVector & p);
747 inline void _moveCursorOffset6DE(const ImageVector & p);
749
750 //--------------------------------------------------------------------------------------------------------------------------
752 //--------------------------------------------------------------------------------------------------------------------------
754 inline static void _moveCursorOffset1DCB (TVirtualVolume *obj, const ImageVector &p) { obj->_moveCursorOffset1D(p); };
755 inline static void _moveCursorOffset2DCB (TVirtualVolume *obj, const ImageVector &p) { obj->_moveCursorOffset2D(p); };
756 inline static void _moveCursorOffset3DCB (TVirtualVolume *obj, const ImageVector &p) { obj->_moveCursorOffset3D(p); };
757 inline static void _moveCursorOffset4DCB (TVirtualVolume *obj, const ImageVector &p) { obj->_moveCursorOffset4D(p); };
758 inline static void _moveCursorOffset5DCB (TVirtualVolume *obj, const ImageVector &p) { obj->_moveCursorOffset5D(p); };
759 inline static void _moveCursorOffset6DCB (TVirtualVolume *obj, const ImageVector &p) { obj->_moveCursorOffset6D(p); };
760
761 inline static void _moveCursorOffset1DCBE(TVirtualVolume *obj, const ImageVector &p) { obj->_moveCursorOffset1DE(p); };
762 inline static void _moveCursorOffset2DCBE(TVirtualVolume *obj, const ImageVector &p) { obj->_moveCursorOffset2DE(p); };
763 inline static void _moveCursorOffset3DCBE(TVirtualVolume *obj, const ImageVector &p) { obj->_moveCursorOffset3DE(p); };
764 inline static void _moveCursorOffset4DCBE(TVirtualVolume *obj, const ImageVector &p) { obj->_moveCursorOffset4DE(p); };
765 inline static void _moveCursorOffset5DCBE(TVirtualVolume *obj, const ImageVector &p) { obj->_moveCursorOffset5DE(p); };
766 inline static void _moveCursorOffset6DCBE(TVirtualVolume *obj, const ImageVector &p) { obj->_moveCursorOffset6DE(p); };
768
769
770 //----------------------------------------------------------------------------------
771 //----------------------------------------------------------------------------------
773 //----------------------------------------------------------------------------------
774 //----------------------------------------------------------------------------------
775
776 // In the following sections multiple expressions such as
777 // _cIdx -= static_cast<MLuint>(_pStrides.x);
778 // are performed with casts to unsigned MLuint64 values, because according to C-standard
779 // the signed values are cast to unsigned int 64 before subtracting anyway; and this
780 // which is warned by compilers.
781 // Therefore the cast is done explicitly, which is okay, when considering that negative
782 // signed values are cast, converted to usually large unsigned values which are added
783 // with overflows resulting to the same value.
784
785
786 //--------------------------------------------------------------------------------------------------------------------------
788 //--------------------------------------------------------------------------------------------------------------------------
790 // See notes about casts at line 1000.
791 inline void _moveFX() { _cPos.x++; _cIdx += static_cast<MLuint>(_pStrides.x); if ((_cPos.x & _idxMask.x) == 0){ _cPageIdx += static_cast<MLuint>(_strides.x); } }
792 inline void _moveFY() { _cPos.y++; _cIdx += static_cast<MLuint>(_pStrides.y); if ((_cPos.y & _idxMask.y) == 0){ _cPageIdx += static_cast<MLuint>(_strides.y); } }
793 inline void _moveFZ() { _cPos.z++; _cIdx += static_cast<MLuint>(_pStrides.z); if ((_cPos.z & _idxMask.z) == 0){ _cPageIdx += static_cast<MLuint>(_strides.z); } }
794 inline void _moveFC() { _cPos.c++; _cIdx += static_cast<MLuint>(_pStrides.c); if ((_cPos.c & _idxMask.c) == 0){ _cPageIdx += static_cast<MLuint>(_strides.c); } }
795 inline void _moveFT() { _cPos.t++; _cIdx += static_cast<MLuint>(_pStrides.t); if ((_cPos.t & _idxMask.t) == 0){ _cPageIdx += static_cast<MLuint>(_strides.t); } }
796 inline void _moveFU() { _cPos.u++; _cIdx += static_cast<MLuint>(_pStrides.u); if ((_cPos.u & _idxMask.u) == 0){ _cPageIdx += static_cast<MLuint>(_strides.u); } }
797
798 inline void _moveFXE() { if (_cPos.x < _extD.x){ _moveFX(); } else{ throw(ML_OUT_OF_RANGE); } }
799 inline void _moveFYE() { if (_cPos.y < _extD.y){ _moveFY(); } else{ throw(ML_OUT_OF_RANGE); } }
800 inline void _moveFZE() { if (_cPos.z < _extD.z){ _moveFZ(); } else{ throw(ML_OUT_OF_RANGE); } }
801 inline void _moveFCE() { if (_cPos.c < _extD.c){ _moveFC(); } else{ throw(ML_OUT_OF_RANGE); } }
802 inline void _moveFTE() { if (_cPos.t < _extD.t){ _moveFT(); } else{ throw(ML_OUT_OF_RANGE); } }
803 inline void _moveFUE() { if (_cPos.u < _extD.u){ _moveFU(); } else{ throw(ML_OUT_OF_RANGE); } }
805
806 //--------------------------------------------------------------------------------------------------------------------------
808 //--------------------------------------------------------------------------------------------------------------------------
810 inline static void _moveFXCB (TVirtualVolume *obj) { obj->_moveFX(); }
811 inline static void _moveFYCB (TVirtualVolume *obj) { obj->_moveFY(); }
812 inline static void _moveFZCB (TVirtualVolume *obj) { obj->_moveFZ(); }
813 inline static void _moveFCCB (TVirtualVolume *obj) { obj->_moveFC(); }
814 inline static void _moveFTCB (TVirtualVolume *obj) { obj->_moveFT(); }
815 inline static void _moveFUCB (TVirtualVolume *obj) { obj->_moveFU(); }
816
817 inline static void _moveFXCBE(TVirtualVolume *obj) { obj->_moveFXE(); }
818 inline static void _moveFYCBE(TVirtualVolume *obj) { obj->_moveFYE(); }
819 inline static void _moveFZCBE(TVirtualVolume *obj) { obj->_moveFZE(); }
820 inline static void _moveFCCBE(TVirtualVolume *obj) { obj->_moveFCE(); }
821 inline static void _moveFTCBE(TVirtualVolume *obj) { obj->_moveFTE(); }
822 inline static void _moveFUCBE(TVirtualVolume *obj) { obj->_moveFUE(); }
824
825 //--------------------------------------------------------------------------------------------------------------------------
827 //--------------------------------------------------------------------------------------------------------------------------
829 // See notes about casts at line 1000.
830 inline void _moveBX() { _cPos.x--; _cIdx -= static_cast<MLuint>(_pStrides.x); if ((_cPos.x & _idxMask.x) == _idxMask.x){ _cPageIdx -= static_cast<MLuint>(_strides.x); } }
831 inline void _moveBY() { _cPos.y--; _cIdx -= static_cast<MLuint>(_pStrides.y); if ((_cPos.y & _idxMask.y) == _idxMask.y){ _cPageIdx -= static_cast<MLuint>(_strides.y); } }
832 inline void _moveBZ() { _cPos.z--; _cIdx -= static_cast<MLuint>(_pStrides.z); if ((_cPos.z & _idxMask.z) == _idxMask.z){ _cPageIdx -= static_cast<MLuint>(_strides.z); } }
833 inline void _moveBC() { _cPos.c--; _cIdx -= static_cast<MLuint>(_pStrides.c); if ((_cPos.c & _idxMask.c) == _idxMask.c){ _cPageIdx -= static_cast<MLuint>(_strides.c); } }
834 inline void _moveBT() { _cPos.t--; _cIdx -= static_cast<MLuint>(_pStrides.t); if ((_cPos.t & _idxMask.t) == _idxMask.t){ _cPageIdx -= static_cast<MLuint>(_strides.t); } }
835 inline void _moveBU() { _cPos.u--; _cIdx -= static_cast<MLuint>(_pStrides.u); if ((_cPos.u & _idxMask.u) == _idxMask.u){ _cPageIdx -= static_cast<MLuint>(_strides.u); } }
836
839#define _VV_MOVEBE_TEST(Q) if (_cPos.Q >= 0){ _cPageIdx -= static_cast<MLuint>(_strides.Q); } \
840 else{ _cPos.Q++; _cIdx += static_cast<MLuint>(_pStrides.Q); throw(ML_OUT_OF_RANGE); }
841
842 // See notes about casts at line 1000.
843 inline void _moveBXE() { _cPos.x--; _cIdx -= static_cast<MLuint>(_pStrides.x); if ((_cPos.x & _idxMask.x) == _idxMask.x){ _VV_MOVEBE_TEST(x); } }
844 inline void _moveBYE() { _cPos.y--; _cIdx -= static_cast<MLuint>(_pStrides.y); if ((_cPos.y & _idxMask.y) == _idxMask.y){ _VV_MOVEBE_TEST(y); } }
845 inline void _moveBZE() { _cPos.z--; _cIdx -= static_cast<MLuint>(_pStrides.z); if ((_cPos.z & _idxMask.z) == _idxMask.z){ _VV_MOVEBE_TEST(z); } }
846 inline void _moveBCE() { _cPos.c--; _cIdx -= static_cast<MLuint>(_pStrides.c); if ((_cPos.c & _idxMask.c) == _idxMask.c){ _VV_MOVEBE_TEST(c); } }
847 inline void _moveBTE() { _cPos.t--; _cIdx -= static_cast<MLuint>(_pStrides.t); if ((_cPos.t & _idxMask.t) == _idxMask.t){ _VV_MOVEBE_TEST(t); } }
848 inline void _moveBUE() { _cPos.u--; _cIdx -= static_cast<MLuint>(_pStrides.u); if ((_cPos.u & _idxMask.u) == _idxMask.u){ _VV_MOVEBE_TEST(u); } }
849#undef _VV_MOVEBE_TEST
851
852
853
854 //--------------------------------------------------------------------------------------------------------------------------
856 //--------------------------------------------------------------------------------------------------------------------------
858 inline static void _moveBXCB (TVirtualVolume *obj) { obj->_moveBX(); }
859 inline static void _moveBYCB (TVirtualVolume *obj) { obj->_moveBY(); }
860 inline static void _moveBZCB (TVirtualVolume *obj) { obj->_moveBZ(); }
861 inline static void _moveBCCB (TVirtualVolume *obj) { obj->_moveBC(); }
862 inline static void _moveBTCB (TVirtualVolume *obj) { obj->_moveBT(); }
863 inline static void _moveBUCB (TVirtualVolume *obj) { obj->_moveBU(); }
864
865 inline static void _moveBXCBE(TVirtualVolume *obj) { obj->_moveBXE(); }
866 inline static void _moveBYCBE(TVirtualVolume *obj) { obj->_moveBYE(); }
867 inline static void _moveBZCBE(TVirtualVolume *obj) { obj->_moveBZE(); }
868 inline static void _moveBCCBE(TVirtualVolume *obj) { obj->_moveBCE(); }
869 inline static void _moveBTCBE(TVirtualVolume *obj) { obj->_moveBTE(); }
870 inline static void _moveBUCBE(TVirtualVolume *obj) { obj->_moveBUE(); }
872
873
874
875private:
876
878 typedef DATATYPE (*GetVoxelFunc) (TVirtualVolume *obj, const ImageVector &p);
879
881 typedef void (*SetVoxelFunc) (TVirtualVolume *obj, const ImageVector &p, DATATYPE voxVal);
882
884 typedef bool (*IsMappedFunc) (const TVirtualVolume *obj, const ImageVector &p);
885
887 typedef void (*SetCursorPosFunc) (TVirtualVolume *obj, const ImageVector &p);
888
890 typedef void (*MoveCursorOffsetFunc)(TVirtualVolume *obj, const ImageVector &p);
891
893 typedef void (*MoveCursorPosFunc) (TVirtualVolume *obj);
894
898 VirtualVolume *_convenienceInstance;
899
901 VirtualVolume *_virtVol;
902
904 ImageVector _ext;
905
907 ImageVector _extD;
908
910 PageBuffer *_pageArray;
911
914 ImageVector _rShift;
915
917 ImageVector _strides;
918
920 ImageVector _pStrides;
921
923 ImageVector _idxMask;
924
926 GetVoxelFunc _getVoxelFunc;
927
929 SetVoxelFunc _setVoxelFunc;
930
932 IsMappedFunc _isMappedFunc;
933
935 SetCursorPosFunc _setCursorPosFunc;
936
938 MoveCursorOffsetFunc _moveCursorOffsetFunc;
939
942 MoveCursorPosFunc _moveFXFunc;
943 MoveCursorPosFunc _moveFYFunc;
944 MoveCursorPosFunc _moveFZFunc;
945 MoveCursorPosFunc _moveFCFunc;
946 MoveCursorPosFunc _moveFTFunc;
947 MoveCursorPosFunc _moveFUFunc;
948
949 MoveCursorPosFunc _moveBXFunc;
950 MoveCursorPosFunc _moveBYFunc;
951 MoveCursorPosFunc _moveBZFunc;
952 MoveCursorPosFunc _moveBCFunc;
953 MoveCursorPosFunc _moveBTFunc;
954 MoveCursorPosFunc _moveBUFunc;
956
958 ImageVector _cPos;
959
961 MLuint _cPageIdx;
962
964 MLuint _cIdx;
965
967 bool _useExc;
968};
969
970//--------------------------------------------------------------------------------------------------------
971// END OF USER INTERFACE
972//--------------------------------------------------------------------------------------------------------
973
974
975
976
977
978//--------------------------------------------------------------------------------------------------------
979//--------------------------------------------------------------------------------------------------------
980// Implementation part of Virtual Volume.
981//--------------------------------------------------------------------------------------------------------
982//--------------------------------------------------------------------------------------------------------
983
984template <typename DATATYPE>
986{
987 for (MLuint c=0; c < num; c++){
988 *results = _getVoxelFunc(this, *pos);
989 results++;
990 pos++;
991 }
992}
993
994template <typename DATATYPE>
996{
997 PageBuffer *page = _pageArray + _cPageIdx;
998 (static_cast<DATATYPE*>(page->_getPageFkt(page)))[_cIdx] = val;
999 page->_locked = true;
1000}
1001
1003template <typename DATATYPE>
1005{
1006 PageBuffer *page = _pageArray + _cPageIdx;
1007 return (static_cast<DATATYPE*>(page->_getPageFkt(page)))[_cIdx];
1008}
1009
1011template <typename DATATYPE>
1013{
1014 static const ImageVector zeroPos(0);
1015 _setCursorPosFunc(this, zeroPos);
1016}
1017
1027template <typename DATATYPE>
1029{
1030 if (_cPos.x < _extD.x){ _moveFXFunc(this); return true; }
1031 else{
1032 if (_cPos.y < _extD.y){ _moveFYFunc(this); }
1033 else{
1034 if (_cPos.z < _extD.z){ _moveFZFunc(this); }
1035 else{
1036 if (_cPos.c < _extD.c){ _moveFCFunc(this); }
1037 else{
1038 if (_cPos.t < _extD.t){ _moveFTFunc(this); }
1039 else{
1040 if (_cPos.u < _extD.u){ _moveFUFunc(this); }
1041 else{
1042 // Just return false but do not move cursor any
1043 // further. This makes loops much easier.
1044 return false;
1045 }
1046 _cPos.t = 0;
1047 }
1048 _cPos.c = 0;
1049 }
1050 _cPos.z = 0;
1051 }
1052 _cPos.y = 0;
1053 }
1054 _cPos.x = 0;
1055
1056 // Cursor position has been reset in any component. Update settings.
1057 _setCursorPosFunc(this, _cPos);
1058 return true;
1059 }
1060}
1061
1063template <typename DATATYPE>
1065{
1066 // Restrict size of filled area to valid image regions.
1067 SubImageBox subImgBox = SubImageBox::intersect(box, _virtVol->getBox());
1068
1069 // Note: Future versions could optimise inner loop significantly
1070 // by filling complete rows in pages with memcpy statements
1071 // from a prefilled row (or even by using subimage copies
1072 // from a prefilled page if many pages are filled).
1073 ImageVector p;
1074 for (p.u=subImgBox.v1.u; p.u<=subImgBox.v2.u; p.u++){
1075 for (p.t=subImgBox.v1.t; p.t<=subImgBox.v2.t; p.t++){
1076 for (p.c=subImgBox.v1.c; p.c<=subImgBox.v2.c; p.c++){
1077 for (p.z=subImgBox.v1.z; p.z<=subImgBox.v2.z; p.z++){
1078 for (p.y=subImgBox.v1.y; p.y<=subImgBox.v2.y; p.y++){
1079 for (p.x=subImgBox.v1.x; p.x<=subImgBox.v2.x; p.x++){
1080 setValue(p, value);
1081 } // x
1082 }
1083 }
1084 }
1085 }
1086 } // u
1087}
1088
1089//-----------------------------------------------------------------------------------------------
1091//-----------------------------------------------------------------------------------------------
1092template <typename DATATYPE>
1094{
1095 _virtVol->copyToSubImage(outSubImg);
1096}
1097
1098//-----------------------------------------------------------------------------------------------
1100//-----------------------------------------------------------------------------------------------
1101template <typename DATATYPE>
1103{
1104 // Get extents of subImg as box.
1105 SubImageBox inBox = inImg.getBoxFromImageExtent();
1106
1107 // Determine valid area in inImg which can be copied (overlap of inBox and box).
1108 // (Source area)
1109 SubImageBox srcBox = SubImageBox::intersect(inBox, box);
1110
1111 // Get extents of virtualVolume as box.
1112 SubImageBox vvBox = _virtVol->getBox();
1113
1114 // Determine the area where srcBox is copied to.
1116 tvvBox.v1 = srcBox.v1 + pos;
1117 tvvBox.v2 = srcBox.v2 + pos;
1118
1119 // Restrict tvvBox to valid virtualVolume extents. (Destination area)
1120 SubImageBox dstBox = SubImageBox::intersect(vvBox, tvvBox);
1121
1122 // Iterate over all voxels of the destination area in the virtual volume.
1124 for (dPos.u=dstBox.v1.u, sPos.u = srcBox.v1.u; dPos.u<=dstBox.v2.u; dPos.u++, sPos.u++){
1125 for (dPos.t=dstBox.v1.t, sPos.t = srcBox.v1.t; dPos.t<=dstBox.v2.t; dPos.t++, sPos.t++){
1126 for (dPos.c=dstBox.v1.c, sPos.c = srcBox.v1.c; dPos.c<=dstBox.v2.c; dPos.c++, sPos.c++){
1127 for (dPos.z=dstBox.v1.z, sPos.z = srcBox.v1.z; dPos.z<=dstBox.v2.z; dPos.z++, sPos.z++){
1128 for (dPos.y=dstBox.v1.y, sPos.y = srcBox.v1.y; dPos.y<=dstBox.v2.y; dPos.y++, sPos.y++){
1129 for (dPos.x=dstBox.v1.x, sPos.x = srcBox.v1.x; dPos.x<=dstBox.v2.x; dPos.x++, sPos.x++){
1130 setValue(dPos, inImg.getSubImageValue(sPos));
1131 } // x
1132 }
1133 }
1134 }
1135 }
1136 } // u
1137}
1138
1142template <typename DATATYPE>
1144{
1145 // To avoid a typical programming error force a fatal error if the template data type
1146 // does not match the virtual volume data type.
1147 if (vVol.getDataType() != MLGetDataTypeFromPtr(static_cast<DATATYPE*>(nullptr))){
1148 ML_PRINT_FATAL_ERROR("TVirtualVolume<DATATYPE>::_init()", ML_BAD_DATA_TYPE,
1149 "Mismatch of data type of virtual volume and template typename");
1150 }
1151
1152 // Get some parameters from virtual volume instance.
1153 // _convenienceInstance = ...; // Must be initialized in all constructors before.
1154 _virtVol = &vVol;
1155 _ext = vVol._origVolumeExt;
1156 _extD = vVol._origVolumeExt-ImageVector(1);
1157 _pageArray = vVol._pageArray;
1158 _rShift = vVol._rShift;
1159 _strides = vVol._strides;
1160 _pStrides = vVol._pStrides;
1161 _idxMask = vVol._idxMask;
1162 _useExc = vVol._areExceptionsOn;
1163
1164 // Set cursor position, cursor index and cursor page.
1165 _cPos = ImageVector(0);
1166 _cIdx = 0;
1167 _cPageIdx = 0;
1168
1169 // Dependent on the dimension of the image we can select different read/write
1170 // functions. We do this to avoid unnecessary calculations of 6d coordinates
1171 // if the volume has only e.g. 2 dimensions.
1172 if (_useExc){
1173
1175 _moveFXFunc = _moveFXCBE;
1176 _moveFYFunc = _moveFYCBE;
1177 _moveFZFunc = _moveFZCBE;
1178 _moveFCFunc = _moveFCCBE;
1179 _moveFTFunc = _moveFTCBE;
1180 _moveFUFunc = _moveFUCBE;
1181
1182 _moveBXFunc = _moveBXCBE;
1183 _moveBYFunc = _moveBYCBE;
1184 _moveBZFunc = _moveBZCBE;
1185 _moveBCFunc = _moveBCCBE;
1186 _moveBTFunc = _moveBTCBE;
1187 _moveBUFunc = _moveBUCBE;
1188
1189 // Set the correct setValue/getValue and setCursorPosition functions.
1190 switch (vVol.getDim()){
1191 case 1:
1192 _getVoxelFunc = _getVoxel1DCBE;
1193 _setVoxelFunc = _setVoxel1DCBE;
1194 _setCursorPosFunc = _setCursorPos1DCBE;
1195 _moveCursorOffsetFunc = _moveCursorOffset1DCBE;
1196 _isMappedFunc = _isMapped1DCBE;
1197 break;
1198 case 2:
1199 _getVoxelFunc = _getVoxel2DCBE;
1200 _setVoxelFunc = _setVoxel2DCBE;
1201 _setCursorPosFunc = _setCursorPos2DCBE;
1202 _moveCursorOffsetFunc = _moveCursorOffset2DCBE;
1203 _isMappedFunc = _isMapped2DCBE;
1204 break;
1205 case 3:
1206 _getVoxelFunc = _getVoxel3DCBE;
1207 _setVoxelFunc = _setVoxel3DCBE;
1208 _setCursorPosFunc = _setCursorPos3DCBE;
1209 _moveCursorOffsetFunc = _moveCursorOffset3DCBE;
1210 _isMappedFunc = _isMapped3DCBE;
1211 break;
1212 case 4:
1213 _getVoxelFunc = _getVoxel4DCBE;
1214 _setVoxelFunc = _setVoxel4DCBE;
1215 _setCursorPosFunc = _setCursorPos4DCBE;
1216 _moveCursorOffsetFunc = _moveCursorOffset4DCBE;
1217 _isMappedFunc = _isMapped4DCBE;
1218 break;
1219 case 5:
1220 _getVoxelFunc = _getVoxel5DCBE;
1221 _setVoxelFunc = _setVoxel5DCBE;
1222 _setCursorPosFunc = _setCursorPos5DCBE;
1223 _moveCursorOffsetFunc = _moveCursorOffset5DCBE;
1224 _isMappedFunc = _isMapped5DCBE;
1225 break;
1226 case 6:
1227 _getVoxelFunc = _getVoxel6DCBE;
1228 _setVoxelFunc = _setVoxel6DCBE;
1229 _setCursorPosFunc = _setCursorPos6DCBE;
1230 _moveCursorOffsetFunc = _moveCursorOffset6DCBE;
1231 _isMappedFunc = _isMapped6DCBE;
1232 break;
1233 default:
1234 _getVoxelFunc = _getVoxel6DCBE;
1235 _setVoxelFunc = _setVoxel6DCBE;
1236 _moveCursorOffsetFunc = _moveCursorOffset6DCBE;
1237 _setCursorPosFunc = _setCursorPos6DCBE;
1238 _isMappedFunc = _isMapped6DCBE;
1239 _virtVol->invalidate();
1240 throw(ML_BAD_DIMENSION);
1241 break;
1242 }
1243 }
1244 else{
1245
1247 _moveFXFunc = _moveFXCB;
1248 _moveFYFunc = _moveFYCB;
1249 _moveFZFunc = _moveFZCB;
1250 _moveFCFunc = _moveFCCB;
1251 _moveFTFunc = _moveFTCB;
1252 _moveFUFunc = _moveFUCB;
1253
1254 _moveBXFunc = _moveBXCB;
1255 _moveBYFunc = _moveBYCB;
1256 _moveBZFunc = _moveBZCB;
1257 _moveBCFunc = _moveBCCB;
1258 _moveBTFunc = _moveBTCB;
1259 _moveBUFunc = _moveBUCB;
1260
1261 // Set the correct setValue/getValue and setCursorPosition functions.
1262 switch (vVol.getDim()){
1263 case 1:
1264 _getVoxelFunc = _getVoxel1DCB;
1265 _setVoxelFunc = _setVoxel1DCB;
1266 _setCursorPosFunc = _setCursorPos1DCB;
1267 _moveCursorOffsetFunc = _moveCursorOffset1DCB;
1268 _isMappedFunc = _isMapped1DCB;
1269 break;
1270 case 2:
1271 _getVoxelFunc = _getVoxel2DCB;
1272 _setVoxelFunc = _setVoxel2DCB;
1273 _setCursorPosFunc = _setCursorPos2DCB;
1274 _moveCursorOffsetFunc = _moveCursorOffset2DCB;
1275 _isMappedFunc = _isMapped2DCB;
1276 break;
1277 case 3:
1278 _getVoxelFunc = _getVoxel3DCB;
1279 _setVoxelFunc = _setVoxel3DCB;
1280 _setCursorPosFunc = _setCursorPos3DCB;
1281 _moveCursorOffsetFunc = _moveCursorOffset3DCB;
1282 _isMappedFunc = _isMapped3DCB;
1283 break;
1284 case 4:
1285 _getVoxelFunc = _getVoxel4DCB;
1286 _setVoxelFunc = _setVoxel4DCB;
1287 _setCursorPosFunc = _setCursorPos4DCB;
1288 _moveCursorOffsetFunc = _moveCursorOffset4DCB;
1289 _isMappedFunc = _isMapped4DCB;
1290 break;
1291 case 5:
1292 _getVoxelFunc = _getVoxel5DCB;
1293 _setVoxelFunc = _setVoxel5DCB;
1294 _setCursorPosFunc = _setCursorPos5DCB;
1295 _moveCursorOffsetFunc = _moveCursorOffset5DCB;
1296 _isMappedFunc = _isMapped5DCB;
1297 break;
1298 case 6:
1299 _getVoxelFunc = _getVoxel6DCB;
1300 _setVoxelFunc = _setVoxel6DCB;
1301 _setCursorPosFunc = _setCursorPos6DCB;
1302 _moveCursorOffsetFunc = _moveCursorOffset6DCB;
1303 _isMappedFunc = _isMapped6DCB;
1304 break;
1305 default:
1306 _getVoxelFunc = _getVoxel6DCB;
1307 _setVoxelFunc = _setVoxel6DCB;
1308 _setCursorPosFunc = _setCursorPos6DCB;
1309 _moveCursorOffsetFunc = _moveCursorOffset6DCB;
1310 _isMappedFunc = _isMapped6DCBE;
1311 _virtVol->invalidate();
1312 ML_PRINT_ERROR("TVirtualVolume::_init()", ML_BAD_DIMENSION, "Invalid image dimension. Using dimension 6. \n");
1313 break;
1314 }
1315 }
1316}
1317
1319template <typename DATATYPE>
1321{
1322 // _convenienceInstance = ...; // Must be handled in destructor explicitly.
1323 _virtVol = nullptr;
1324 _ext = ImageVector(0);
1325 _extD = ImageVector(0);
1326 _pageArray = nullptr;
1327 _rShift = ImageVector(0);
1328 _strides = ImageVector(0);
1329 _pStrides = ImageVector(0);
1330 _getVoxelFunc = nullptr;
1331 _setVoxelFunc = nullptr;
1332 _setCursorPosFunc = nullptr;
1333 _moveCursorOffsetFunc = nullptr;
1334 _isMappedFunc = nullptr;
1335 _moveFXFunc = nullptr;
1336 _moveFYFunc = nullptr;
1337 _moveFZFunc = nullptr;
1338 _moveFCFunc = nullptr;
1339 _moveFTFunc = nullptr;
1340 _moveFUFunc = nullptr;
1341 _moveBXFunc = nullptr;
1342 _moveBYFunc = nullptr;
1343 _moveBZFunc = nullptr;
1344 _moveBCFunc = nullptr;
1345 _moveBTFunc = nullptr;
1346 _moveBUFunc = nullptr;
1347 _idxMask = ImageVector(0);
1348 _cPos = ImageVector(0);
1349 _cIdx = 0;
1350 _cPageIdx = 0;
1351 _useExc = false;
1352}
1353
1354
1355
1356//----------------------------------------------------------------------------------------------------------
1357// GetVoxel
1358//----------------------------------------------------------------------------------------------------------
1359
1361template <typename DATATYPE>
1363{
1364 PageBuffer * const page = _pageArray + (pos.x >> _rShift.x);
1365 return (static_cast<DATATYPE*>(page->_getPageFkt(page)))[pos.x];
1366};
1367
1369template <typename DATATYPE>
1371{
1372 const MLint px = pos.x;
1373 if ((px < 0) || (px >= _ext.x)){ throw(ML_OUT_OF_RANGE); }
1374 PageBuffer * const page = _pageArray + (px >> _rShift.x);
1375 return (static_cast<DATATYPE*>(page->_getPageFkt(page)))[px];
1376};
1377
1378
1380template <typename DATATYPE>
1382{
1383 PageBuffer * const page = _pageArray + ((pos.x >> _rShift.x) + (pos.y >> _rShift.y)*_strides.y);
1384 return (static_cast<DATATYPE*>(page->_getPageFkt(page)))[pos.x+ pos.y*_pStrides.y];
1385};
1386
1388template <typename DATATYPE>
1390{
1391 const MLint px = pos.x;
1392 const MLint py = pos.y;
1393 if ((px < 0) || (px >= _ext.x) || (py < 0) || (py >= _ext.y)){ throw(ML_OUT_OF_RANGE); }
1394 PageBuffer * const page = _pageArray + ((px >> _rShift.x) + (py >> _rShift.y)*_strides.y);
1395 return (static_cast<DATATYPE*>(page->_getPageFkt(page)))[px+ py*_pStrides.y];
1396};
1397
1398
1399
1401template <typename DATATYPE>
1403{
1404 PageBuffer * const page = _pageArray + ((pos.x >> _rShift.x) +
1405 (pos.y >> _rShift.y)*_strides.y +
1406 (pos.z >> _rShift.z)*_strides.z);
1407 return (static_cast<DATATYPE*>(page->_getPageFkt(page)))[pos.x + pos.y*_pStrides.y + pos.z*_pStrides.z];
1408};
1409
1411template <typename DATATYPE>
1413{
1414 const MLint px = pos.x;
1415 const MLint py = pos.y;
1416 const MLint pz = pos.z;
1417 if ((px < 0) || (px >= _ext.x) || (py < 0) || (py >= _ext.y) ||
1418 (pz < 0) || (pz >= _ext.z)){ throw(ML_OUT_OF_RANGE); }
1419 PageBuffer * const page = _pageArray + ((px >> _rShift.x) +
1420 (py >> _rShift.y)*_strides.y +
1421 (pz >> _rShift.z)*_strides.z);
1422 return (static_cast<DATATYPE*>(page->_getPageFkt(page)))[px + py*_pStrides.y + pz*_pStrides.z];
1423};
1424
1425
1426
1428template <typename DATATYPE>
1430{
1431 PageBuffer * const page = _pageArray + ((pos.x >> _rShift.x) +
1432 (pos.y >> _rShift.y)*_strides.y +
1433 (pos.z >> _rShift.z)*_strides.z +
1434 (pos.c >> _rShift.c)*_strides.c);
1435 return (static_cast<DATATYPE*>(page->_getPageFkt(page)))[pos.x +
1436 pos.y*_pStrides.y +
1437 pos.z*_pStrides.z +
1438 pos.c*_pStrides.c];
1439};
1440
1442template <typename DATATYPE>
1444{
1445 const MLint px = pos.x;
1446 const MLint py = pos.y;
1447 const MLint pz = pos.z;
1448 const MLint pc = pos.c;
1449 if ((px < 0) || (px >= _ext.x) || (py < 0) || (py >= _ext.y) ||
1450 (pz < 0) || (pz >= _ext.z) || (pc < 0) || (pc >= _ext.c)){ throw(ML_OUT_OF_RANGE); }
1451 PageBuffer * const page = _pageArray + ((px >> _rShift.x) +
1452 (py >> _rShift.y)*_strides.y +
1453 (pz >> _rShift.z)*_strides.z +
1454 (pc >> _rShift.c)*_strides.c);
1455 return (static_cast<DATATYPE*>(page->_getPageFkt(page)))[px +
1456 py*_pStrides.y +
1457 pz*_pStrides.z +
1458 pc*_pStrides.c];
1459};
1460
1462template <typename DATATYPE>
1464{
1465 PageBuffer * const page = _pageArray + ((pos.x >> _rShift.x) +
1466 (pos.y >> _rShift.y)*_strides.y +
1467 (pos.z >> _rShift.z)*_strides.z +
1468 (pos.c >> _rShift.c)*_strides.c +
1469 (pos.t >> _rShift.t)*_strides.t);
1470 return (static_cast<DATATYPE*>(page->_getPageFkt(page)))[pos.x +
1471 pos.y*_pStrides.y +
1472 pos.z*_pStrides.z +
1473 pos.c*_pStrides.c +
1474 pos.t*_pStrides.t];
1475};
1476
1478template <typename DATATYPE>
1480{
1481 const MLint px = pos.x;
1482 const MLint py = pos.y;
1483 const MLint pz = pos.z;
1484 const MLint pc = pos.c;
1485 const MLint pt = pos.t;
1486 if ((px < 0) || (px >= _ext.x) || (py < 0) || (py >= _ext.y) ||
1487 (pz < 0) || (pz >= _ext.z) || (pc < 0) || (pc >= _ext.c) ||
1488 (pt < 0) || (pt >= _ext.t)){ throw(ML_OUT_OF_RANGE); }
1489 PageBuffer * const page = _pageArray + ((px >> _rShift.x) +
1490 (py >> _rShift.y)*_strides.y +
1491 (pz >> _rShift.z)*_strides.z +
1492 (pc >> _rShift.c)*_strides.c +
1493 (pt >> _rShift.t)*_strides.t);
1494 return (static_cast<DATATYPE*>(page->_getPageFkt(page)))[px +
1495 py*_pStrides.y +
1496 pz*_pStrides.z +
1497 pc*_pStrides.c +
1498 pt*_pStrides.t];
1499};
1500
1502template <typename DATATYPE>
1504{
1505 PageBuffer * const page = _pageArray + ((pos.x >> _rShift.x) +
1506 (pos.y >> _rShift.y)*_strides.y +
1507 (pos.z >> _rShift.z)*_strides.z +
1508 (pos.c >> _rShift.c)*_strides.c +
1509 (pos.t >> _rShift.t)*_strides.t +
1510 (pos.u >> _rShift.u)*_strides.u);
1511 return (static_cast<DATATYPE*>(page->_getPageFkt(page)))[pos.x +
1512 pos.y*_pStrides.y +
1513 pos.z*_pStrides.z +
1514 pos.c*_pStrides.c +
1515 pos.t*_pStrides.t +
1516 pos.u*_pStrides.u];
1517};
1518
1520template <typename DATATYPE>
1522{
1523 const MLint px = pos.x;
1524 const MLint py = pos.y;
1525 const MLint pz = pos.z;
1526 const MLint pc = pos.c;
1527 const MLint pt = pos.t;
1528 const MLint pu = pos.u;
1529 if ((px < 0) || (px >= _ext.x) || (py < 0) || (py >= _ext.y) ||
1530 (pz < 0) || (pz >= _ext.z) || (pc < 0) || (pc >= _ext.c) ||
1531 (pt < 0) || (pt >= _ext.t) || (pu < 0) || (pu >= _ext.u)){ throw(ML_OUT_OF_RANGE); }
1532 PageBuffer * const page = _pageArray + ((px >> _rShift.x) +
1533 (py >> _rShift.y)*_strides.y +
1534 (pz >> _rShift.z)*_strides.z +
1535 (pc >> _rShift.c)*_strides.c +
1536 (pt >> _rShift.t)*_strides.t +
1537 (pu >> _rShift.u)*_strides.u);
1538 return (static_cast<DATATYPE*>(page->_getPageFkt(page)))[px +
1539 py*_pStrides.y +
1540 pz*_pStrides.z +
1541 pc*_pStrides.c +
1542 pt*_pStrides.t +
1543 pu*_pStrides.u];
1544};
1545
1546
1547
1548//----------------------------------------------------------------------------------------------------------
1549// SetVoxel
1550//----------------------------------------------------------------------------------------------------------
1551
1552
1553
1555template <typename DATATYPE>
1557{
1558 PageBuffer * const page = _pageArray + (pos.x >> _rShift.x);
1559 page->_locked = true;
1560 (static_cast<DATATYPE*>(page->_getPageFkt(page)))[pos.x] = voxVal;
1561};
1562
1564template <typename DATATYPE>
1566{
1567 const MLint px = pos.x;
1568 if ((px < 0) || (px >= _ext.x)){ throw(ML_OUT_OF_RANGE); }
1569 PageBuffer * const page = _pageArray + (px >> _rShift.x);
1570 page->_locked = true;
1571 (static_cast<DATATYPE*>(page->_getPageFkt(page)))[px] = voxVal;
1572};
1573
1574
1575
1577template <typename DATATYPE>
1579{
1580 PageBuffer * const page = _pageArray + ((pos.x >> _rShift.x) + (pos.y >> _rShift.y)*_strides.y);
1581 page->_locked = true;
1582 (static_cast<DATATYPE*>(page->_getPageFkt(page)))[pos.x + pos.y*_pStrides.y] = voxVal;
1583};
1584
1586template <typename DATATYPE>
1588{
1589 const MLint px = pos.x;
1590 const MLint py = pos.y;
1591 if ((px < 0) || (px >= _ext.x) || (py < 0) || (py >= _ext.y)){ throw(ML_OUT_OF_RANGE); }
1592 PageBuffer * const page = _pageArray + ((px >> _rShift.x) + (py >> _rShift.y)*_strides.y);
1593 page->_locked = true;
1594 (static_cast<DATATYPE*>(page->_getPageFkt(page)))[px + py*_pStrides.y] = voxVal;
1595};
1596
1597
1598
1600template <typename DATATYPE>
1602{
1603 PageBuffer * const page = _pageArray + ((pos.x >> _rShift.x) +
1604 (pos.y >> _rShift.y)*_strides.y +
1605 (pos.z >> _rShift.z)*_strides.z);
1606 page->_locked = true;
1607 (static_cast<DATATYPE*>(page->_getPageFkt(page)))[pos.x + pos.y*_pStrides.y + pos.z*_pStrides.z] = voxVal;
1608};
1609
1611template <typename DATATYPE>
1613{
1614 const MLint px = pos.x;
1615 const MLint py = pos.y;
1616 const MLint pz = pos.z;
1617 if ((px < 0) || (px >= _ext.x) || (py < 0) || (py >= _ext.y) ||
1618 (pz < 0) || (pz >= _ext.z)){ throw(ML_OUT_OF_RANGE); }
1619 PageBuffer * const page = _pageArray + ((px >> _rShift.x) +
1620 (py >> _rShift.y)*_strides.y +
1621 (pz >> _rShift.z)*_strides.z);
1622 page->_locked = true;
1623 (static_cast<DATATYPE*>(page->_getPageFkt(page)))[px + py*_pStrides.y + pz*_pStrides.z] = voxVal;
1624};
1625
1626
1627
1629template <typename DATATYPE>
1631{
1632 PageBuffer * const page = _pageArray + ((pos.x >> _rShift.x) +
1633 (pos.y >> _rShift.y)*_strides.y +
1634 (pos.z >> _rShift.z)*_strides.z +
1635 (pos.c >> _rShift.c)*_strides.c);
1636 page->_locked = true;
1637 (static_cast<DATATYPE*>(page->_getPageFkt(page)))[pos.x +
1638 pos.y*_pStrides.y +
1639 pos.z*_pStrides.z +
1640 pos.c*_pStrides.c] = voxVal;
1641};
1642
1644template <typename DATATYPE>
1646{
1647 const MLint px = pos.x;
1648 const MLint py = pos.y;
1649 const MLint pz = pos.z;
1650 const MLint pc = pos.c;
1651 if ((px < 0) || (px >= _ext.x) || (py < 0) || (py >= _ext.y) ||
1652 (pz < 0) || (pz >= _ext.z) || (pc < 0) || (pc >= _ext.c)){ throw(ML_OUT_OF_RANGE); }
1653 PageBuffer * const page = _pageArray + ((px >> _rShift.x) +
1654 (py >> _rShift.y)*_strides.y +
1655 (pz >> _rShift.z)*_strides.z +
1656 (pc >> _rShift.c)*_strides.c);
1657 page->_locked = true;
1658 (static_cast<DATATYPE*>(page->_getPageFkt(page)))[px +
1659 py*_pStrides.y +
1660 pz*_pStrides.z +
1661 pc*_pStrides.c] = voxVal;
1662};
1663
1664
1665
1667template <typename DATATYPE>
1669{
1670 PageBuffer * const page = _pageArray + ((pos.x >> _rShift.x) +
1671 (pos.y >> _rShift.y)*_strides.y +
1672 (pos.z >> _rShift.z)*_strides.z +
1673 (pos.c >> _rShift.c)*_strides.c +
1674 (pos.t >> _rShift.t)*_strides.t);
1675 page->_locked = true;
1676 (static_cast<DATATYPE*>(page->_getPageFkt(page)))[pos.x +
1677 pos.y*_pStrides.y +
1678 pos.z*_pStrides.z +
1679 pos.c*_pStrides.c +
1680 pos.t*_pStrides.t] = voxVal;
1681};
1682
1684template <typename DATATYPE>
1686{
1687 const MLint px = pos.x;
1688 const MLint py = pos.y;
1689 const MLint pz = pos.z;
1690 const MLint pc = pos.c;
1691 const MLint pt = pos.t;
1692 if ((px < 0) || (px >= _ext.x) || (py < 0) || (py >= _ext.y) ||
1693 (pz < 0) || (pz >= _ext.z) || (pc < 0) || (pc >= _ext.c) ||
1694 (pt < 0) || (pt >= _ext.t)){ throw(ML_OUT_OF_RANGE); }
1695 PageBuffer * const page = _pageArray + ((px >> _rShift.x) +
1696 (py >> _rShift.y)*_strides.y +
1697 (pz >> _rShift.z)*_strides.z +
1698 (pc >> _rShift.c)*_strides.c +
1699 (pt >> _rShift.t)*_strides.t);
1700 page->_locked = true;
1701 (static_cast<DATATYPE*>(page->_getPageFkt(page)))[px +
1702 py*_pStrides.y +
1703 pz*_pStrides.z +
1704 pc*_pStrides.c +
1705 pt*_pStrides.t] = voxVal;
1706};
1707
1708
1709
1711template <typename DATATYPE>
1713{
1714 PageBuffer * const page = _pageArray + ((pos.x >> _rShift.x) +
1715 (pos.y >> _rShift.y)*_strides.y +
1716 (pos.z >> _rShift.z)*_strides.z +
1717 (pos.c >> _rShift.c)*_strides.c +
1718 (pos.t >> _rShift.t)*_strides.t +
1719 (pos.u >> _rShift.u)*_strides.u);
1720 page->_locked = true;
1721 (static_cast<DATATYPE*>(page->_getPageFkt(page)))[pos.x +
1722 pos.y*_pStrides.y +
1723 pos.z*_pStrides.z +
1724 pos.c*_pStrides.c +
1725 pos.t*_pStrides.t +
1726 pos.u*_pStrides.u] = voxVal;
1727};
1728
1730template <typename DATATYPE>
1732{
1733 const MLint px = pos.x;
1734 const MLint py = pos.y;
1735 const MLint pz = pos.z;
1736 const MLint pc = pos.c;
1737 const MLint pt = pos.t;
1738 const MLint pu = pos.u;
1739 if ((px < 0) || (px >= _ext.x) || (py < 0) || (py >= _ext.y) ||
1740 (pz < 0) || (pz >= _ext.z) || (pc < 0) || (pc >= _ext.c) ||
1741 (pt < 0) || (pt >= _ext.t) || (pu < 0) || (pu >= _ext.u)){ throw(ML_OUT_OF_RANGE); }
1742 PageBuffer * const page = _pageArray + ((px >> _rShift.x) +
1743 (py >> _rShift.y)*_strides.y +
1744 (pz >> _rShift.z)*_strides.z +
1745 (pc >> _rShift.c)*_strides.c +
1746 (pt >> _rShift.t)*_strides.t +
1747 (pu >> _rShift.u)*_strides.u);
1748 page->_locked = true;
1749 (static_cast<DATATYPE*>(page->_getPageFkt(page)))[px +
1750 py*_pStrides.y +
1751 pz*_pStrides.z +
1752 pc*_pStrides.c +
1753 pt*_pStrides.t +
1754 pu*_pStrides.u] = voxVal;
1755};
1756
1757
1758
1759
1760//----------------------------------------------------------------------------------------------------------
1761// SetCursorPos.
1762//----------------------------------------------------------------------------------------------------------
1763
1764
1765
1767template <typename DATATYPE>
1769{
1770 _cPos.x = p.x;
1771 _cIdx = static_cast<MLuint>(p.x);
1772 _cPageIdx = static_cast<MLuint>(p.x >> _rShift.x);
1773}
1774
1776template <typename DATATYPE>
1778{
1779 const MLint px = pos.x;
1780 if ((px < 0) || (px >= _ext.x)){ throw(ML_OUT_OF_RANGE); }
1781 _cPos.x = px;
1782 _cIdx = static_cast<MLuint>(px);
1783 _cPageIdx = static_cast<MLuint>(px >> _rShift.x);
1784}
1785
1786
1787
1789template <typename DATATYPE>
1791{
1792 _cPos.x = p.x;
1793 _cPos.y = p.y;
1794 _cIdx = static_cast<MLuint>(p.x + p.y*_pStrides.y);
1795 _cPageIdx = static_cast<MLuint>((p.x >> _rShift.x) +
1796 (p.y >> _rShift.y)*_strides.y);
1797}
1798
1800template <typename DATATYPE>
1802{
1803 const MLint px = pos.x;
1804 const MLint py = pos.y;
1805 if ((px < 0) || (px >= _ext.x) || (py < 0) || (py >= _ext.y)){ throw(ML_OUT_OF_RANGE); }
1806 _cPos.x = px;
1807 _cPos.y = py;
1808 _cIdx = static_cast<MLuint>(px + py*_pStrides.y);
1809 _cPageIdx = static_cast<MLuint>((px >> _rShift.x) +
1810 (py >> _rShift.y)*_strides.y);
1811}
1812
1813
1814
1816template <typename DATATYPE>
1818{
1819 _cPos.x = p.x;
1820 _cPos.y = p.y;
1821 _cPos.z = p.z;
1822 _cIdx = static_cast<MLuint>(p.x + p.y*_pStrides.y + p.z*_pStrides.z);
1823 _cPageIdx = static_cast<MLuint>((p.x >> _rShift.x) +
1824 (p.y >> _rShift.y)*_strides.y +
1825 (p.z >> _rShift.z)*_strides.z);
1826}
1827
1829template <typename DATATYPE>
1831{
1832 const MLint px = pos.x;
1833 const MLint py = pos.y;
1834 const MLint pz = pos.z;
1835 if ((px < 0) || (px >= _ext.x) || (py < 0) || (py >= _ext.y) ||
1836 (pz < 0) || (pz >= _ext.z)){ throw(ML_OUT_OF_RANGE); }
1837 _cPos.x = px;
1838 _cPos.y = py;
1839 _cPos.z = pz;
1840 _cIdx = static_cast<MLuint>(px + py*_pStrides.y + pz*_pStrides.z);
1841 _cPageIdx = static_cast<MLuint>((px >> _rShift.x) +
1842 (py >> _rShift.y)*_strides.y +
1843 (pz >> _rShift.z)*_strides.z);
1844}
1845
1846
1847
1849template <typename DATATYPE>
1851{
1852 _cPos.x = p.x;
1853 _cPos.y = p.y;
1854 _cPos.z = p.z;
1855 _cPos.c = p.c;
1856 _cIdx = static_cast<MLuint>(p.x + p.y*_pStrides.y + p.z*_pStrides.z + p.c*_pStrides.c);
1857 _cPageIdx = static_cast<MLuint>((p.x >> _rShift.x) +
1858 (p.y >> _rShift.y)*_strides.y +
1859 (p.z >> _rShift.z)*_strides.z +
1860 (p.c >> _rShift.c)*_strides.c);
1861}
1862
1864template <typename DATATYPE>
1866{
1867 const MLint px = pos.x;
1868 const MLint py = pos.y;
1869 const MLint pz = pos.z;
1870 const MLint pc = pos.c;
1871 if ((px < 0) || (px >= _ext.x) || (py < 0) || (py >= _ext.y) ||
1872 (pz < 0) || (pz >= _ext.z) || (pc < 0) || (pc >= _ext.c)){ throw(ML_OUT_OF_RANGE); }
1873 _cPos.x = px;
1874 _cPos.y = py;
1875 _cPos.z = pz;
1876 _cPos.c = pc;
1877 _cIdx = static_cast<MLuint>(px + py*_pStrides.y + pz*_pStrides.z + pc*_pStrides.c);
1878 _cPageIdx = static_cast<MLuint>((px >> _rShift.x) +
1879 (py >> _rShift.y)*_strides.y +
1880 (pz >> _rShift.z)*_strides.z +
1881 (pc >> _rShift.c)*_strides.c);
1882}
1883
1884
1885
1887template <typename DATATYPE>
1889{
1890 // Save cursor position.
1891 _cPos = p;
1892
1893 // Determine the index to the voxel within the page.
1894 _cIdx = static_cast<MLuint>(p.x + p.y*_pStrides.y + p.z*_pStrides.z + p.c*_pStrides.c + p.t*_pStrides.t);
1895
1896 // Determine index of the page under the cursor position.
1897 _cPageIdx = static_cast<MLuint>((p.x >> _rShift.x) +
1898 (p.y >> _rShift.y)*_strides.y +
1899 (p.z >> _rShift.z)*_strides.z +
1900 (p.c >> _rShift.c)*_strides.c +
1901 (p.t >> _rShift.t)*_strides.t);
1902}
1903
1905template <typename DATATYPE>
1907{
1908 const MLint px = pos.x;
1909 const MLint py = pos.y;
1910 const MLint pz = pos.z;
1911 const MLint pc = pos.c;
1912 const MLint pt = pos.t;
1913 if ((px < 0) || (px >= _ext.x) || (py < 0) || (py >= _ext.y) ||
1914 (pz < 0) || (pz >= _ext.z) || (pc < 0) || (pc >= _ext.c) ||
1915 (pt < 0) || (pt >= _ext.t)){ throw(ML_OUT_OF_RANGE); }
1916
1917 // Save cursor position.
1918 _cPos = pos;
1919
1920 // Determine the index to the voxel within the page.
1921 _cIdx = static_cast<MLuint>(px + py*_pStrides.y + pz*_pStrides.z + pc*_pStrides.c + pt*_pStrides.t);
1922
1923 // Determine index of the page under the cursor position.
1924 _cPageIdx = static_cast<MLuint>((px >> _rShift.x) +
1925 (py >> _rShift.y)*_strides.y +
1926 (pz >> _rShift.z)*_strides.z +
1927 (pc >> _rShift.c)*_strides.c +
1928 (pt >> _rShift.t)*_strides.t);
1929}
1930
1931
1932
1934template <typename DATATYPE>
1936{
1937 // Save cursor position.
1938 _cPos = p;
1939
1940 // Determine the index to the voxel within the page.
1941 _cIdx = static_cast<MLuint>(p.x + p.y*_pStrides.y + p.z*_pStrides.z +
1942 p.c*_pStrides.c + p.t*_pStrides.t + p.u*_pStrides.u);
1943
1944 // Determine index of the page under the cursor position.
1945 _cPageIdx = static_cast<MLuint>((p.x >> _rShift.x) +
1946 (p.y >> _rShift.y)*_strides.y +
1947 (p.z >> _rShift.z)*_strides.z +
1948 (p.c >> _rShift.c)*_strides.c +
1949 (p.t >> _rShift.t)*_strides.t +
1950 (p.u >> _rShift.u)*_strides.u);
1951}
1952
1954template <typename DATATYPE>
1956{
1957 const MLint px = pos.x;
1958 const MLint py = pos.y;
1959 const MLint pz = pos.z;
1960 const MLint pc = pos.c;
1961 const MLint pt = pos.t;
1962 const MLint pu = pos.u;
1963 if ((px < 0) || (px >= _ext.x) || (py < 0) || (py >= _ext.y) ||
1964 (pz < 0) || (pz >= _ext.z) || (pc < 0) || (pc >= _ext.c) ||
1965 (pt < 0) || (pt >= _ext.t) || (pu < 0) || (pu >= _ext.u)){ throw(ML_OUT_OF_RANGE); }
1966
1967 // Save cursor position.
1968 _cPos = pos;
1969
1970 // Determine the index to the voxel within the page.
1971 _cIdx = static_cast<MLuint>(px + py*_pStrides.y + pz*_pStrides.z +
1972 pc*_pStrides.c + pt*_pStrides.t + pu*_pStrides.u);
1973
1974 // Determine index of the page under the cursor position.
1975 _cPageIdx = static_cast<MLuint>((px >> _rShift.x) +
1976 (py >> _rShift.y)*_strides.y +
1977 (pz >> _rShift.z)*_strides.z +
1978 (pc >> _rShift.c)*_strides.c +
1979 (pt >> _rShift.t)*_strides.t +
1980 (pu >> _rShift.u)*_strides.u);
1981}
1982
1983
1984
1985
1986//----------------------------------------------------------------------------------------------------------
1987// MoveCursorOffset
1988//----------------------------------------------------------------------------------------------------------
1989
1990
1991
1993template <typename DATATYPE>
1995{
1996 _cPos.x += off.x;
1997 _cIdx = static_cast<MLuint>(_cPos.x);
1998 _cPageIdx = static_cast<MLuint>(_cPos.x >> _rShift.x);
1999}
2000
2002template <typename DATATYPE>
2004{
2005 const MLint px = _cPos.x + off.x;
2006 if ((px < 0) || (px >= _ext.x)){ throw(ML_OUT_OF_RANGE); }
2007 _cPos.x = px;
2008 _cIdx = static_cast<MLuint>(px);
2009 _cPageIdx = static_cast<MLuint>(px >> _rShift.x);
2010}
2011
2012
2013
2015template <typename DATATYPE>
2017{
2018 _cPos.x += off.x;
2019 _cPos.y += off.y;
2020 _cIdx = static_cast<MLuint>(_cPos.x + _cPos.y*_pStrides.y);
2021 _cPageIdx = static_cast<MLuint>((_cPos.x >> _rShift.x) + (_cPos.y >> _rShift.y)*_strides.y);
2022}
2023
2025template <typename DATATYPE>
2027{
2028 const MLint px = _cPos.x + off.x;
2029 const MLint py = _cPos.y + off.y;
2030 if ((px < 0) || (px >= _ext.x) || (py < 0) || (py >= _ext.y)){ throw(ML_OUT_OF_RANGE); }
2031 _cPos.x = px;
2032 _cPos.y = py;
2033 _cIdx = static_cast<MLuint>(px + py*_pStrides.y);
2034 _cPageIdx = static_cast<MLuint>((px >> _rShift.x) + (py >> _rShift.y)*_strides.y);
2035}
2036
2037
2038
2040template <typename DATATYPE>
2042{
2043 _cPos.x += off.x;
2044 _cPos.y += off.y;
2045 _cPos.z += off.z;
2046 _cIdx = static_cast<MLuint>(_cPos.x + _cPos.y*_pStrides.y + _cPos.z*_pStrides.z);
2047 _cPageIdx = static_cast<MLuint>((_cPos.x >> _rShift.x) +
2048 (_cPos.y >> _rShift.y)*_strides.y +
2049 (_cPos.z >> _rShift.z)*_strides.z);
2050}
2051
2053template <typename DATATYPE>
2055{
2056 const MLint px = _cPos.x+off.x;
2057 const MLint py = _cPos.y+off.y;
2058 const MLint pz = _cPos.z+off.z;
2059 if ((px < 0) || (px >= _ext.x) || (py < 0) || (py >= _ext.y) ||
2060 (pz < 0) || (pz >= _ext.z)){ throw(ML_OUT_OF_RANGE); }
2061 _cPos.x = px;
2062 _cPos.y = py;
2063 _cPos.z = pz;
2064 _cIdx = static_cast<MLuint>(px + py*_pStrides.y + pz*_pStrides.z);
2065 _cPageIdx = static_cast<MLuint>((px >> _rShift.x) +
2066 (py >> _rShift.y)*_strides.y +
2067 (pz >> _rShift.z)*_strides.z);
2068}
2069
2070
2071
2073template <typename DATATYPE>
2075{
2076 _cPos.x += off.x;
2077 _cPos.y += off.y;
2078 _cPos.z += off.z;
2079 _cPos.c += off.c;
2080 _cIdx = static_cast<MLuint>(_cPos.x + _cPos.y*_pStrides.y + _cPos.z*_pStrides.z + _cPos.c*_pStrides.c);
2081 _cPageIdx = static_cast<MLuint>((_cPos.x >> _rShift.x) +
2082 (_cPos.y >> _rShift.y)*_strides.y +
2083 (_cPos.z >> _rShift.z)*_strides.z +
2084 (_cPos.c >> _rShift.c)*_strides.c);
2085}
2086
2088template <typename DATATYPE>
2090{
2091 const MLint px = _cPos.x + off.x;
2092 const MLint py = _cPos.y + off.y;
2093 const MLint pz = _cPos.z + off.z;
2094 const MLint pc = _cPos.c + off.c;
2095 if ((px < 0) || (px >= _ext.x) || (py < 0) || (py >= _ext.y) ||
2096 (pz < 0) || (pz >= _ext.z) || (pc < 0) || (pc >= _ext.c)){ throw(ML_OUT_OF_RANGE); }
2097 _cPos.x = px;
2098 _cPos.y = py;
2099 _cPos.z = pz;
2100 _cPos.c = pc;
2101 _cIdx = static_cast<MLuint>(px + py*_pStrides.y + pz*_pStrides.z + pc*_pStrides.c);
2102 _cPageIdx = static_cast<MLuint>((px >> _rShift.x) +
2103 (py >> _rShift.y)*_strides.y +
2104 (pz >> _rShift.z)*_strides.z +
2105 (pc >> _rShift.c)*_strides.c);
2106}
2107
2108
2109
2111template <typename DATATYPE>
2113{
2114 // Calculate new cursor position.
2115 _cPos += off;
2116
2117 // Determine the index to the voxel within the page.
2118 _cIdx = static_cast<MLuint>(_cPos.x +
2119 _cPos.y*_pStrides.y + _cPos.z*_pStrides.z +
2120 _cPos.c*_pStrides.c + _cPos.t*_pStrides.t);
2121
2122 // Determine index of the page under the cursor position.
2123 _cPageIdx = static_cast<MLuint>((_cPos.x >> _rShift.x) +
2124 (_cPos.y >> _rShift.y)*_strides.y +
2125 (_cPos.z >> _rShift.z)*_strides.z +
2126 (_cPos.c >> _rShift.c)*_strides.c +
2127 (_cPos.t >> _rShift.t)*_strides.t);
2128}
2129
2131template <typename DATATYPE>
2133{
2134 const MLint px = _cPos.x + off.x;
2135 const MLint py = _cPos.y + off.y;
2136 const MLint pz = _cPos.z + off.z;
2137 const MLint pc = _cPos.c + off.c;
2138 const MLint pt = _cPos.t + off.t;
2139 if ((px < 0) || (px >= _ext.x) || (py < 0) || (py >= _ext.y) ||
2140 (pz < 0) || (pz >= _ext.z) || (pc < 0) || (pc >= _ext.c) ||
2141 (pt < 0) || (pt >= _ext.t)){ throw(ML_OUT_OF_RANGE); }
2142
2143 // Save cursor position.
2144 _cPos.set(px,py,pz,pc,pt,0);
2145
2146 // Determine the index to the voxel within the page.
2147 _cIdx = static_cast<MLuint>(px + py*_pStrides.y + pz*_pStrides.z + pc*_pStrides.c + pt*_pStrides.t);
2148
2149 // Determine index of the page under the cursor position.
2150 _cPageIdx = static_cast<MLuint>((px >> _rShift.x) +
2151 (py >> _rShift.y)*_strides.y +
2152 (pz >> _rShift.z)*_strides.z +
2153 (pc >> _rShift.c)*_strides.c +
2154 (pt >> _rShift.t)*_strides.t);
2155}
2156
2157
2158
2160template <typename DATATYPE>
2162{
2163 // Save cursor position.
2164 _cPos += off;
2165
2166 // Determine the index to the voxel within the page.
2167 _cIdx = static_cast<MLuint>(_cPos.x + _cPos.y*_pStrides.y + _cPos.z*_pStrides.z +
2168 _cPos.c*_pStrides.c + _cPos.t*_pStrides.t + _cPos.u*_pStrides.u);
2169
2170 // Determine index of the page under the cursor position.
2171 _cPageIdx = static_cast<MLuint>((_cPos.x >> _rShift.x) +
2172 (_cPos.y >> _rShift.y)*_strides.y +
2173 (_cPos.z >> _rShift.z)*_strides.z +
2174 (_cPos.c >> _rShift.c)*_strides.c +
2175 (_cPos.t >> _rShift.t)*_strides.t +
2176 (_cPos.u >> _rShift.u)*_strides.u);
2177}
2178
2180template <typename DATATYPE>
2182{
2183 const MLint px = _cPos.x + off.x;
2184 const MLint py = _cPos.y + off.y;
2185 const MLint pz = _cPos.z + off.z;
2186 const MLint pc = _cPos.c + off.c;
2187 const MLint pt = _cPos.t + off.t;
2188 const MLint pu = _cPos.u + off.u;
2189 if ((px < 0) || (px >= _ext.x) || (py < 0) || (py >= _ext.y) ||
2190 (pz < 0) || (pz >= _ext.z) || (pc < 0) || (pc >= _ext.c) ||
2191 (pt < 0) || (pt >= _ext.t) || (pu < 0) || (pu >= _ext.u)){ throw(ML_OUT_OF_RANGE); }
2192
2193 // Save cursor position.
2194 _cPos.set(px,py,pz,pc,pt,pu);
2195
2196 // Determine the index to the voxel within the page.
2197 _cIdx = static_cast<MLuint>(px + py*_pStrides.y + pz*_pStrides.z +
2198 pc*_pStrides.c + pt*_pStrides.t + pu*_pStrides.u);
2199
2200 // Determine index of the page under the cursor position.
2201 _cPageIdx = static_cast<MLuint>((px >> _rShift.x) + (py >> _rShift.y)*_strides.y +
2202 (pz >> _rShift.z)*_strides.z + (pc >> _rShift.c)*_strides.c +
2203 (pt >> _rShift.t)*_strides.t + (pu >> _rShift.u)*_strides.u);
2204}
2205
2206
2207
2208//----------------------------------------------------------------------------------------------------------
2209// IsMapped.
2210//----------------------------------------------------------------------------------------------------------
2211
2212
2213
2215template <typename DATATYPE>
2217{
2218 const PageBuffer * const page = _pageArray + (pos.x >> _rShift.x);
2219 return page->_getPageFkt != VirtualVolume::_loadPageCB;
2220};
2221
2223template <typename DATATYPE>
2225{
2226 const MLint px = pos.x;
2227 if ((px < 0) || (px >= _ext.x)){ throw(ML_OUT_OF_RANGE); }
2228 const PageBuffer * const page = _pageArray + (px >> _rShift.x);
2229 return page->_getPageFkt != VirtualVolume::_loadPageCB;
2230};
2231
2232
2233
2235template <typename DATATYPE>
2237{
2238 const PageBuffer * const page = _pageArray + ((pos.x >> _rShift.x) + (pos.y >> _rShift.y)*_strides.y);
2239 return page->_getPageFkt != VirtualVolume::_loadPageCB;
2240};
2241
2243template <typename DATATYPE>
2245{
2246 const MLint px = pos.x;
2247 const MLint py = pos.y;
2248 if ((px < 0) || (px >= _ext.x) || (py < 0) || (py >= _ext.y)){ throw(ML_OUT_OF_RANGE); }
2249 const PageBuffer * const page = _pageArray + ((px >> _rShift.x) + (py >> _rShift.y)*_strides.y);
2250 return page->_getPageFkt != VirtualVolume::_loadPageCB;
2251};
2252
2253
2254
2256template <typename DATATYPE>
2258{
2259 const PageBuffer * const page = _pageArray + ((pos.x >> _rShift.x) +
2260 (pos.y >> _rShift.y)*_strides.y +
2261 (pos.z >> _rShift.z)*_strides.z);
2262 return page->_getPageFkt != VirtualVolume::_loadPageCB;
2263};
2264
2266template <typename DATATYPE>
2268{
2269 const MLint px = pos.x;
2270 const MLint py = pos.y;
2271 const MLint pz = pos.z;
2272 if ((px < 0) || (px >= _ext.x) || (py < 0) || (py >= _ext.y) ||
2273 (pz < 0) || (pz >= _ext.z)){ throw(ML_OUT_OF_RANGE); }
2274 const PageBuffer * const page = _pageArray + ((px >> _rShift.x) +
2275 (py >> _rShift.y)*_strides.y +
2276 (pz >> _rShift.z)*_strides.z);
2277 return page->_getPageFkt != VirtualVolume::_loadPageCB;
2278};
2279
2280
2281
2283template <typename DATATYPE>
2285{
2286 const PageBuffer * const page = _pageArray + ((pos.x >> _rShift.x) +
2287 (pos.y >> _rShift.y)*_strides.y +
2288 (pos.z >> _rShift.z)*_strides.z +
2289 (pos.c >> _rShift.c)*_strides.c);
2290 return page->_getPageFkt != VirtualVolume::_loadPageCB;
2291};
2292
2294template <typename DATATYPE>
2296{
2297 const MLint px = pos.x;
2298 const MLint py = pos.y;
2299 const MLint pz = pos.z;
2300 const MLint pc = pos.c;
2301 if ((px < 0) || (px >= _ext.x) || (py < 0) || (py >= _ext.y) ||
2302 (pz < 0) || (pz >= _ext.z) || (pc < 0) || (pc >= _ext.c)){ throw(ML_OUT_OF_RANGE); }
2303 const PageBuffer * const page = _pageArray + ((px >> _rShift.x) +
2304 (py >> _rShift.y)*_strides.y +
2305 (pz >> _rShift.z)*_strides.z +
2306 (pc >> _rShift.c)*_strides.c);
2307 return page->_getPageFkt != VirtualVolume::_loadPageCB;
2308};
2309
2310
2311
2313template <typename DATATYPE>
2315{
2316 const PageBuffer * const page = _pageArray + ((pos.x >> _rShift.x) +
2317 (pos.y >> _rShift.y)*_strides.y +
2318 (pos.z >> _rShift.z)*_strides.z +
2319 (pos.c >> _rShift.c)*_strides.c +
2320 (pos.t >> _rShift.t)*_strides.t);
2321 return page->_getPageFkt != VirtualVolume::_loadPageCB;
2322};
2323
2325template <typename DATATYPE>
2327{
2328 const MLint px = pos.x;
2329 const MLint py = pos.y;
2330 const MLint pz = pos.z;
2331 const MLint pc = pos.c;
2332 const MLint pt = pos.t;
2333 if ((px < 0) || (px >= _ext.x) || (py < 0) || (py >= _ext.y) ||
2334 (pz < 0) || (pz >= _ext.z) || (pc < 0) || (pc >= _ext.c) ||
2335 (pt < 0) || (pt >= _ext.t)){ throw(ML_OUT_OF_RANGE); }
2336 const PageBuffer * const page = _pageArray + ((px >> _rShift.x) +
2337 (py >> _rShift.y)*_strides.y +
2338 (pz >> _rShift.z)*_strides.z +
2339 (pc >> _rShift.c)*_strides.c +
2340 (pt >> _rShift.t)*_strides.t);
2341 return page->_getPageFkt != VirtualVolume::_loadPageCB;
2342};
2343
2344
2345
2347template <typename DATATYPE>
2349{
2350 const PageBuffer * const page = _pageArray + ((pos.x >> _rShift.x) +
2351 (pos.y >> _rShift.y)*_strides.y +
2352 (pos.z >> _rShift.z)*_strides.z +
2353 (pos.c >> _rShift.c)*_strides.c +
2354 (pos.t >> _rShift.t)*_strides.t +
2355 (pos.u >> _rShift.u)*_strides.u);
2356 return page->_getPageFkt != VirtualVolume::_loadPageCB;
2357};
2358
2360template <typename DATATYPE>
2362{
2363 const MLint px = pos.x;
2364 const MLint py = pos.y;
2365 const MLint pz = pos.z;
2366 const MLint pc = pos.c;
2367 const MLint pt = pos.t;
2368 const MLint pu = pos.u;
2369 if ((px < 0) || (px >= _ext.x) || (py < 0) || (py >= _ext.y) ||
2370 (pz < 0) || (pz >= _ext.z) || (pc < 0) || (pc >= _ext.c) ||
2371 (pt < 0) || (pt >= _ext.t) || (pu < 0) || (pu >= _ext.u)){ throw(ML_OUT_OF_RANGE); }
2372 const PageBuffer * const page = _pageArray + ((px >> _rShift.x) +
2373 (py >> _rShift.y)*_strides.y +
2374 (pz >> _rShift.z)*_strides.z +
2375 (pc >> _rShift.c)*_strides.c +
2376 (pt >> _rShift.t)*_strides.t +
2377 (pu >> _rShift.u)*_strides.u);
2378 return page->_getPageFkt != VirtualVolume::_loadPageCB;
2379};
2380
2381
2382
2384
2385#endif // __mlTVirtualVolume_H
Class to manage a binary image.
Definition mlBitImage.h:67
Class which represents an image, which manages properties of an image and image data which is located...
const SubImageBox & getBox() const
Returns the box describing the origin/extent of the subimage.
Definition mlSubImage.h:230
VectorType v1
Corner v1 of the subimage region (included in region).
static TSubImageBox< intT > intersect(const TSubImageBox< intT > &box1, const TSubImageBox< intT > &box2)
Returns the overlapping region of subimage regions box1 and box2.
VectorType v2
Corner v2 of the subimage region (also included in region!).
This template class manages/represents a rectangular 6d image region in memory which is organized lin...
const DATATYPE * getImagePointer(const ImageVector &position) const
Returns a pointer to voxel data of image voxel at 6d position position relative to the begin of the c...
The TVirtualVolume class implements random access to a paged input image or a pure virtual image with...
static void _moveFZCB(TVirtualVolume *obj)
static void _setVoxel4DCBE(TVirtualVolume *obj, const ImageVector &pos, DATATYPE voxVal)
static void setInt64ValueWrapped(void *vv, const ImageVector &pos, MLint64 v)
static void _moveBUCBE(TVirtualVolume *obj)
static MLdouble getDoubleCursorValueWrapped(void *vv)
static void _moveCursorOffset3DCB(TVirtualVolume *obj, const ImageVector &p)
static void _moveFYCBE(TVirtualVolume *obj)
static bool _isMapped5DCB(const TVirtualVolume *obj, const ImageVector &pos)
virtual ~TVirtualVolume()
Destructor.
static void _setVoxel6DCB(TVirtualVolume *obj, const ImageVector &pos, DATATYPE voxVal)
static bool _isMapped4DCBE(const TVirtualVolume *obj, const ImageVector &pos)
void setCursorPosition(const ImageVector &pos)
Set the cursor to a certain position.
static void _moveCursorOffset2DCBE(TVirtualVolume *obj, const ImageVector &p)
static MLint64 getInt64ValueWrapped(void *vv, const ImageVector &pos)
static void reverseMoveCursorUWrapped(void *vv)
static void _setCursorPos4DCB(TVirtualVolume *obj, const ImageVector &p)
static void setIntValueWrapped(void *vv, const ImageVector &pos, MLint v)
static void setDoubleValueWrapped(void *vv, const ImageVector &pos, MLdouble v)
static void _moveBXCB(TVirtualVolume *obj)
static void _setCursorPos3DCB(TVirtualVolume *obj, const ImageVector &p)
static void fillDoubleWrapped(void *vv, const ImageVector &v1, const ImageVector &v2, MLdouble v)
static void _setCursorPos6DCB(TVirtualVolume *obj, const ImageVector &p)
static MLdouble getDoubleValueWrapped(void *vv, const ImageVector &pos)
static void setDoubleCursorValueWrapped(void *vv, MLdouble v)
static void reverseMoveCursorCWrapped(void *vv)
static bool _isMapped2DCBE(const TVirtualVolume *obj, const ImageVector &pos)
static MLint64 getInt64CursorValueWrapped(void *vv)
static void setLDoubleCursorValueWrapped(void *vv, MLldouble v)
static void fillLDoubleWrapped(void *vv, const ImageVector &v1, const ImageVector &v2, MLldouble v)
static DATATYPE _getVoxel3DCBE(TVirtualVolume *obj, const ImageVector &pos)
static void _moveBTCB(TVirtualVolume *obj)
static void _setVoxel3DCBE(TVirtualVolume *obj, const ImageVector &pos, DATATYPE voxVal)
static bool _isMapped1DCB(const TVirtualVolume *obj, const ImageVector &pos)
DATATYPE ComponentType
A typedef to "export" the type of voxels components.
DATATYPE * getWrittenPageData(MLuint32 wp) const
Returns typed pointer to data of written page with page id wp.
static void reverseMoveCursorZWrapped(void *vv)
TVirtualVolume()
Hide the default constructor to avoid incorrect usage due to missing initializations.
static DATATYPE _getVoxel1DCBE(TVirtualVolume *obj, const ImageVector &pos)
static void setIntCursorValueWrapped(void *vv, MLint v)
static void setCursorPositionWrapped(void *vv, const ImageVector &pos)
static void _moveCursorOffset3DCBE(TVirtualVolume *obj, const ImageVector &p)
static MLint getIntCursorValueWrapped(void *vv)
static void _moveFTCB(TVirtualVolume *obj)
static void _setCursorPos5DCBE(TVirtualVolume *obj, const ImageVector &p)
static MLint getIntValueWrapped(void *vv, const ImageVector &pos)
Wrapper functions for non template application interfaces.
static const ImageVector & getCursorPositionWrapped(void *vv)
static void moveCursorByOffsetWrapped(void *vv, const ImageVector &off)
static void _moveCursorOffset1DCB(TVirtualVolume *obj, const ImageVector &p)
static DATATYPE _getVoxel4DCBE(TVirtualVolume *obj, const ImageVector &pos)
static void _moveFYCB(TVirtualVolume *obj)
static void moveCursorUWrapped(void *vv)
static void moveCursorYWrapped(void *vv)
static bool isMappedWrapped(void *vv, const ImageVector &pos)
static void moveCursorTWrapped(void *vv)
static bool _isMapped6DCB(const TVirtualVolume *obj, const ImageVector &pos)
static void _setVoxel5DCBE(TVirtualVolume *obj, const ImageVector &pos, DATATYPE voxVal)
static void _setCursorPos3DCBE(TVirtualVolume *obj, const ImageVector &p)
static void _setCursorPos2DCBE(TVirtualVolume *obj, const ImageVector &p)
static void _setVoxel6DCBE(TVirtualVolume *obj, const ImageVector &pos, DATATYPE voxVal)
static void _moveCursorOffset5DCBE(TVirtualVolume *obj, const ImageVector &p)
static void _moveBXCBE(TVirtualVolume *obj)
static void _moveBCCBE(TVirtualVolume *obj)
static void _moveFXCBE(TVirtualVolume *obj)
static void _moveFUCBE(TVirtualVolume *obj)
void copyMaskToSubImage(TSubImage< OUTDTYPE > &outSubImg, BitImage &maskBits, bool maskValue=true, bool writeBK=false, OUTDTYPE bkVal=ml_cast_from_scalar< OUTDTYPE >(0))
Takes overlapping region from *this, outSubImg and maskBits and copies all voxels from *this to outSu...
static DATATYPE _getVoxel4DCB(TVirtualVolume *obj, const ImageVector &pos)
VirtualVolume & getVirtualVolume()
Returns the pointer to the wrapped untyped virtual volume.
static bool _isMapped3DCBE(const TVirtualVolume *obj, const ImageVector &pos)
static void moveCursorXWrapped(void *vv)
static void _moveCursorOffset5DCB(TVirtualVolume *obj, const ImageVector &p)
TVirtualVolume(const ImageVector &ext, MLdouble fillVal=0, MLint maxNumKB=-1, bool areExceptionsOn=false)
Convenience constructor (3) creating an untyped virtual volume inside the typed one to avoid addition...
static bool _isMapped1DCBE(const TVirtualVolume *obj, const ImageVector &pos)
static void _setVoxel1DCBE(TVirtualVolume *obj, const ImageVector &pos, DATATYPE voxVal)
static void _moveBTCBE(TVirtualVolume *obj)
static bool _isMapped6DCBE(const TVirtualVolume *obj, const ImageVector &pos)
static void _setVoxel2DCB(TVirtualVolume *obj, const ImageVector &pos, DATATYPE voxVal)
static void reverseMoveCursorTWrapped(void *vv)
static bool _isMapped2DCB(const TVirtualVolume *obj, const ImageVector &pos)
static void resetCursorWrapped(void *vv)
static void _moveFZCBE(TVirtualVolume *obj)
DATATYPE getValue(const ImageVector &pos)
Get a voxel value from the virtual volume.
static void fillIntWrapped(void *vv, const ImageVector &v1, const ImageVector &v2, MLint v)
static void _setCursorPos6DCBE(TVirtualVolume *obj, const ImageVector &p)
static void _moveFCCB(TVirtualVolume *obj)
static void _setCursorPos2DCB(TVirtualVolume *obj, const ImageVector &p)
static void _setCursorPos1DCB(TVirtualVolume *obj, const ImageVector &p)
static void _setVoxel4DCB(TVirtualVolume *obj, const ImageVector &pos, DATATYPE voxVal)
static void moveCursorCWrapped(void *vv)
static bool _isMapped5DCBE(const TVirtualVolume *obj, const ImageVector &pos)
static DATATYPE _getVoxel1DCB(TVirtualVolume *obj, const ImageVector &pos)
static void _setCursorPos4DCBE(TVirtualVolume *obj, const ImageVector &p)
static void _moveBYCB(TVirtualVolume *obj)
static DATATYPE _getVoxel6DCBE(TVirtualVolume *obj, const ImageVector &pos)
static DATATYPE _getVoxel2DCB(TVirtualVolume *obj, const ImageVector &pos)
static bool moveCursorXWrapAroundWrapped(void *vv)
static void moveCursorZWrapped(void *vv)
static void setInt64CursorValueWrapped(void *vv, MLint64 v)
static void _moveBUCB(TVirtualVolume *obj)
static bool _isMapped4DCB(const TVirtualVolume *obj, const ImageVector &pos)
const ImageVector & getCursorPosition() const
Return the current cursor coordinates.
TVirtualVolume(PagedImage *image, MLint maxNumKB=-1, bool areExceptionsOn=false)
Convenience constructor (2) creating an untyped virtual volume inside the typed one to avoid addition...
static void _setCursorPos1DCBE(TVirtualVolume *obj, const ImageVector &p)
static DATATYPE _getVoxel2DCBE(TVirtualVolume *obj, const ImageVector &pos)
static DATATYPE _getVoxel5DCBE(TVirtualVolume *obj, const ImageVector &pos)
static void _moveFXCB(TVirtualVolume *obj)
static void _moveBZCBE(TVirtualVolume *obj)
TVirtualVolume(VirtualVolume &vVol)
Constructor 1.
static void fillInt64Wrapped(void *vv, const ImageVector &v1, const ImageVector &v2, MLint64 v)
static DATATYPE _getVoxel6DCB(TVirtualVolume *obj, const ImageVector &pos)
static void _moveCursorOffset1DCBE(TVirtualVolume *obj, const ImageVector &p)
static void _moveBCCB(TVirtualVolume *obj)
static void _setVoxel5DCB(TVirtualVolume *obj, const ImageVector &pos, DATATYPE voxVal)
static void _moveCursorOffset2DCB(TVirtualVolume *obj, const ImageVector &p)
static MLldouble getLDoubleValueWrapped(void *vv, const ImageVector &pos)
static void _moveCursorOffset6DCB(TVirtualVolume *obj, const ImageVector &p)
static void _moveFCCBE(TVirtualVolume *obj)
static void _moveFTCBE(TVirtualVolume *obj)
static void _moveBZCB(TVirtualVolume *obj)
static bool _isMapped3DCB(const TVirtualVolume *obj, const ImageVector &pos)
static void reverseMoveCursorXWrapped(void *vv)
TVirtualVolume & operator=(const TVirtualVolume &)
Hide the default assignment operator to avoid incorrect usage due to missing initializations.
void setValue(const ImageVector &pos, DATATYPE data)
Write a voxel into the virtual volume.
static void _moveCursorOffset6DCBE(TVirtualVolume *obj, const ImageVector &p)
static void _moveFUCB(TVirtualVolume *obj)
static void _moveCursorOffset4DCB(TVirtualVolume *obj, const ImageVector &p)
bool isMapped(const ImageVector &pos) const
Returns true if voxel is mapped into memory, otherwise it returns false.
static void _setVoxel1DCB(TVirtualVolume *obj, const ImageVector &pos, DATATYPE voxVal)
void moveCursorByOffset(const ImageVector &off)
Shift cursor to current position + offset.
static void _moveBYCBE(TVirtualVolume *obj)
void copyToSubImage(TSubImage< DATATYPE > &outSubImg)
Copy area from the virtual volume into the subimage given by outSubImg.
static DATATYPE _getVoxel3DCB(TVirtualVolume *obj, const ImageVector &pos)
static void reverseMoveCursorYWrapped(void *vv)
static void _moveCursorOffset4DCBE(TVirtualVolume *obj, const ImageVector &p)
static void _setVoxel3DCB(TVirtualVolume *obj, const ImageVector &pos, DATATYPE voxVal)
static void _setVoxel2DCBE(TVirtualVolume *obj, const ImageVector &pos, DATATYPE voxVal)
static MLldouble getLDoubleCursorValueWrapped(void *vv)
static DATATYPE _getVoxel5DCB(TVirtualVolume *obj, const ImageVector &pos)
static void _setCursorPos5DCB(TVirtualVolume *obj, const ImageVector &p)
static void setLDoubleValueWrapped(void *vv, const ImageVector &pos, MLldouble v)
This class manages a virtual volume organizing efficient voxel access to the output image of an input...
#define ML_BAD_DATA_TYPE
A wrong or unexpected data type has been passed to an algorithm which often is a programming error; t...
Definition mlTypeDefs.h:782
#define ML_BAD_DIMENSION
The image or data structure has wrong extent or dimensions.
Definition mlTypeDefs.h:835
#define ML_OUT_OF_RANGE
Any coordinate or value is out of range, often a voxel address which is outside of an image or it is ...
Definition mlTypeDefs.h:872
#define ML_PRINT_FATAL_ERROR(FUNC_NAME, REASON, HANDLING)
Like ML_PRINT_FATAL_ERROR_DUMP(FUNC_NAME, REASON, HANDLING, RT_OBJ) without a runtime object to be du...
#define ML_PRINT_ERROR(FUNC_NAME, REASON, HANDLING)
Like ML_PRINT_ERROR_DUMP(FUNC_NAME, REASON, HANDLING, RT_OBJ) without a runtime object to be dumped.
Target mlrange_cast(Source arg)
Generic version of checked ML casts.
#define _VV_MOVEBE_TEST(Q)
Macro to save cursor movement with exception handling if outside image.
MLDataType MLGetDataTypeFromPtr(const T *)
long double MLldouble
Definition mlTypeDefs.h:232
unsigned int MLuint32
Definition mlTypeDefs.h:185
MLuint64 MLuint
An unsigned ML integer type with at least 64 bits used for index calculations on very large images ev...
Definition mlTypeDefs.h:506
double MLdouble
Definition mlTypeDefs.h:217
INT64 MLint64
Include 64 bit integer support for Windows or Unix.
Definition mlTypeDefs.h:412
MLint64 MLint
A signed ML integer type with at least 64 bits used for index calculations on very large images even ...
Definition mlTypeDefs.h:490
PageBuffer is a helper structure to manage one page of input data of the VirtualVolume class and it a...
ReturnPageFunc _getPageFkt
Pointer to function to return the page managed by the PageBuffer.
bool _locked
If true this page contains written data and must not be removed.