MeVisLab Toolbox Reference
SoVirtualVolume.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 SO_VIRTUAL_VOLUME_H
14#define SO_VIRTUAL_VOLUME_H
15
16
19
21
22// Incomplete types needed for abstract interface creation.
23
25 class Module;
26 template <typename intT> class TVector6DBase;
27 template<class TVectorBase> class TVector;
28 template <typename intT> class TImageVector;
29 typedef TImageVector<MLint> ImageVector;
30 class VirtualVolume;
31 template<typename DATATYPE> class TVirtualVolume;
33
34//---------------------------------------------------------------------------------
37//---------------------------------------------------------------------------------
39{
40public:
60 long maxNumKB = -1,
61 bool useExceptions = false);
62
77 double fillVal = 0,
79 long maxNumKB = -1,
80 bool useExceptions = false);
81
86
89
93
98
100 inline long getMaxNumKB() const { return _constructorMaxNumKB; }
101
103 inline bool areExceptionsOn() const { return _constructorAreExceptionsOn; }
104
105 //---------------------------------------------------------------------------------------
107 //---------------------------------------------------------------------------------------
110
113
116
119
122
125
133
139
152
153
154 //---------------------------------------------------------------------------------------
165 //---------------------------------------------------------------------------------------
166 // DO NOT TRACE: All methods are very time critical!
167 inline const XVImageSize &getCursorPosition() { return reinterpret_cast<const XVImageSize&>(_getCursorPosWFunc(_tVirtualVolume)); }
168 inline MLint getIntValue (const XVImageSize &pos) { return _getIntVoxelWFunc(_tVirtualVolume, reinterpret_cast<const ML_NAMESPACE::ImageVector&>(pos)); }
169 inline MLint64 getInt64Value (const XVImageSize &pos) { return _getInt64VoxelWFunc(_tVirtualVolume, reinterpret_cast<const ML_NAMESPACE::ImageVector&>(pos)); }
170 inline MLdouble getDoubleValue (const XVImageSize &pos) { return _getDoubleVoxelWFunc(_tVirtualVolume, reinterpret_cast<const ML_NAMESPACE::ImageVector&>(pos)); }
171 inline MLldouble getLDoubleValue (const XVImageSize &pos) { return _getLDoubleVoxelWFunc(_tVirtualVolume, reinterpret_cast<const ML_NAMESPACE::ImageVector&>(pos)); }
172 inline MLint getIntCursorValue () { return _getIntCursorVoxelWFunc(_tVirtualVolume); }
173 inline MLint64 getInt64CursorValue () { return _getInt64CursorVoxelWFunc(_tVirtualVolume); }
174 inline MLdouble getDoubleCursorValue () { return _getDoubleCursorVoxelWFunc(_tVirtualVolume); }
175 inline MLldouble getLDoubleCursorValue() { return _getLDoubleCursorVoxelWFunc(_tVirtualVolume); }
176 inline bool isMapped (const XVImageSize &pos) { return _isMappedWFunc(_tVirtualVolume, reinterpret_cast<const ML_NAMESPACE::ImageVector&>(pos)); }
177 inline void setCursorPosition (const XVImageSize &pos) { _setCursorPosWFunc(_tVirtualVolume, reinterpret_cast<const ML_NAMESPACE::ImageVector&>(pos)); }
178 inline void setIntValue (const XVImageSize &pos, MLint v) { _setIntVoxelWFunc(_tVirtualVolume, reinterpret_cast<const ML_NAMESPACE::ImageVector&>(pos), v); }
179 inline void setInt64Value (const XVImageSize &pos, MLint64 v) { _setInt64VoxelWFunc(_tVirtualVolume, reinterpret_cast<const ML_NAMESPACE::ImageVector&>(pos), v); }
180 inline void setDoubleValue (const XVImageSize &pos, MLdouble v) { _setDoubleVoxelWFunc(_tVirtualVolume, reinterpret_cast<const ML_NAMESPACE::ImageVector&>(pos), v); }
181 inline void setLDoubleValue (const XVImageSize &pos, MLldouble v) { _setLDoubleVoxelWFunc(_tVirtualVolume, reinterpret_cast<const ML_NAMESPACE::ImageVector&>(pos), v); }
182 inline void setIntCursorValue (MLint v) { _setIntCursorVoxelWFunc(_tVirtualVolume, v); }
183 inline void setInt64CursorValue (MLint64 v) { _setInt64CursorVoxelWFunc(_tVirtualVolume, v); }
184 inline void setDoubleCursorValue (MLdouble v) { _setDoubleCursorVoxelWFunc(_tVirtualVolume, v); }
185 inline void setLDoubleCursorValue(MLldouble v) { _setLDoubleCursorVoxelWFunc(_tVirtualVolume, v); }
186 inline void fillInt (const XVImageSize &boxV1, const XVImageSize &boxV2, MLint v){ _fillIntWFunc(_tVirtualVolume, reinterpret_cast<const ML_NAMESPACE::ImageVector&>(boxV1), reinterpret_cast<const ML_NAMESPACE::ImageVector&>(boxV2), v); }
187 inline void fillInt64 (const XVImageSize &boxV1, const XVImageSize &boxV2, MLint64 v){ _fillInt64WFunc(_tVirtualVolume, reinterpret_cast<const ML_NAMESPACE::ImageVector&>(boxV1), reinterpret_cast<const ML_NAMESPACE::ImageVector&>(boxV2), v); }
188 inline void fillDouble (const XVImageSize &boxV1, const XVImageSize &boxV2, MLdouble v){ _fillDoubleWFunc(_tVirtualVolume, reinterpret_cast<const ML_NAMESPACE::ImageVector&>(boxV1), reinterpret_cast<const ML_NAMESPACE::ImageVector&>(boxV2), v); }
189 inline void fillLDouble (const XVImageSize &boxV1, const XVImageSize &boxV2, MLldouble v){ _fillLDoubleWFunc(_tVirtualVolume, reinterpret_cast<const ML_NAMESPACE::ImageVector&>(boxV1), reinterpret_cast<const ML_NAMESPACE::ImageVector&>(boxV2), v); }
190 inline void moveCursorX () { _moveFXWFunc(_tVirtualVolume); }
191 inline void moveCursorY () { _moveFYWFunc(_tVirtualVolume); }
192 inline void moveCursorZ () { _moveFZWFunc(_tVirtualVolume); }
193 inline void moveCursorC () { _moveFCWFunc(_tVirtualVolume); }
194 inline void moveCursorT () { _moveFTWFunc(_tVirtualVolume); }
195 inline void moveCursorU () { _moveFUWFunc(_tVirtualVolume); }
196 inline void reverseMoveCursorX () { _moveBXWFunc(_tVirtualVolume); }
197 inline void reverseMoveCursorY () { _moveBYWFunc(_tVirtualVolume); }
198 inline void reverseMoveCursorZ () { _moveBZWFunc(_tVirtualVolume); }
199 inline void reverseMoveCursorC () { _moveBCWFunc(_tVirtualVolume); }
200 inline void reverseMoveCursorT () { _moveBTWFunc(_tVirtualVolume); }
201 inline void reverseMoveCursorU () { _moveBUWFunc(_tVirtualVolume); }
202 inline void moveCursorByOffset (const XVImageSize &off) { _moveOffsetFunc(_tVirtualVolume, reinterpret_cast<const ML_NAMESPACE::ImageVector&>(off)); }
203 inline void resetCursor () { _resetCursorFunc(_tVirtualVolume); }
204 inline bool moveCursorXWrapAround() { return _moveCursorFXLFFunc(_tVirtualVolume); }
206
207
208 //---------------------------------------------------------------------------------------
211 //---------------------------------------------------------------------------------------
214 template <typename DATATYPE>
216
220 template <typename DATATYPE>
222
225 template <typename DATATYPE>
227
230 template <typename DATATYPE>
232
237 template <typename DATATYPE>
239
250 template <typename DATATYPE>
253
254protected:
259
264
291 double fillVal = 0,
293 long maxNumKB = -1,
294 bool useExceptions = false);
299
304
312
315
318
321
324
328
330 ML_NAMESPACE::VirtualVolume *_virtualVolume;
331
334
335private:
340 void _enforceInst();
341
348 void _enforceInst2();
349
350 //---------------------------------------------------------------------------------------
353 //---------------------------------------------------------------------------------------
354 typedef const ML_NAMESPACE::ImageVector &(*GetCursorPosWFuncType )(void *vv) ;
355 typedef MLint (*GetIntVoxelWFuncType )(void *vv, const ML_NAMESPACE::ImageVector &pos) ;
356 typedef MLint64 (*GetInt64VoxelWFuncType )(void *vv, const ML_NAMESPACE::ImageVector &pos) ;
357 typedef MLdouble (*GetDoubleVoxelWFuncType )(void *vv, const ML_NAMESPACE::ImageVector &pos) ;
358 typedef MLldouble (*GetLDoubleVoxelWFuncType )(void *vv, const ML_NAMESPACE::ImageVector &pos) ;
359 typedef MLint (*GetIntCursorVoxelWFuncType )(void *vv) ;
360 typedef MLint64 (*GetInt64CursorVoxelWFuncType )(void *vv) ;
361 typedef MLdouble (*GetDoubleCursorVoxelWFuncType )(void *vv) ;
362 typedef MLldouble (*GetLDoubleCursorVoxelWFuncType)(void *vv) ;
363 typedef bool (*IsMappedWFuncType )(void *vv, const ML_NAMESPACE::ImageVector &pos) ;
364 typedef void (*SetCursorPosWFuncType )(void *vv, const ML_NAMESPACE::ImageVector &pos) ;
365 typedef void (*SetIntVoxelWFuncType )(void *vv, const ML_NAMESPACE::ImageVector &pos, MLint v) ;
366 typedef void (*SetInt64VoxelWFuncType )(void *vv, const ML_NAMESPACE::ImageVector &pos, MLint64 v) ;
367 typedef void (*SetDoubleVoxelWFuncType )(void *vv, const ML_NAMESPACE::ImageVector &pos, MLdouble v) ;
368 typedef void (*SetLDoubleVoxelWFuncType )(void *vv, const ML_NAMESPACE::ImageVector &pos, MLldouble v) ;
369 typedef void (*SetIntCursorVoxelWFuncType )(void *vv, MLint v) ;
370 typedef void (*SetInt64CursorVoxelWFuncType )(void *vv, MLint64 v) ;
371 typedef void (*SetDoubleCursorVoxelWFuncType )(void *vv, MLdouble v) ;
372 typedef void (*SetLDoubleCursorVoxelWFuncType)(void *vv, MLldouble v) ;
373 typedef void (*FillIntWFuncType )(void *vv, const ML_NAMESPACE::ImageVector &boxV1, const ML_NAMESPACE::ImageVector &boxV2, MLint v);
374 typedef void (*FillInt64WFuncType )(void *vv, const ML_NAMESPACE::ImageVector &boxV1, const ML_NAMESPACE::ImageVector &boxV2, MLint64 v);
375 typedef void (*FillDoubleWFuncType )(void *vv, const ML_NAMESPACE::ImageVector &boxV1, const ML_NAMESPACE::ImageVector &boxV2, MLdouble v);
376 typedef void (*FillLDoubleWFuncType )(void *vv, const ML_NAMESPACE::ImageVector &boxV1, const ML_NAMESPACE::ImageVector &boxV2, MLldouble v);
377 typedef void (*MoveWFuncType )(void *vv) ;
378 typedef void (*MoveOffsetWFuncType )(void *vv, const ML_NAMESPACE::ImageVector &off) ;
379 typedef void (*ResetCursorWFuncType )(void *vv) ;
380 typedef bool (*MoveCursorFXLFWFuncType )(void *vv) ;
382
383 //---------------------------------------------------------------------------------------
386 //---------------------------------------------------------------------------------------
387 GetCursorPosWFuncType _getCursorPosWFunc ;
388 GetIntVoxelWFuncType _getIntVoxelWFunc ;
389 GetInt64VoxelWFuncType _getInt64VoxelWFunc ;
390 GetDoubleVoxelWFuncType _getDoubleVoxelWFunc ;
391 GetLDoubleVoxelWFuncType _getLDoubleVoxelWFunc ;
392 GetIntCursorVoxelWFuncType _getIntCursorVoxelWFunc ;
393 GetInt64CursorVoxelWFuncType _getInt64CursorVoxelWFunc ;
394 GetDoubleCursorVoxelWFuncType _getDoubleCursorVoxelWFunc ;
395 GetLDoubleCursorVoxelWFuncType _getLDoubleCursorVoxelWFunc ;
396 IsMappedWFuncType _isMappedWFunc ;
397 SetCursorPosWFuncType _setCursorPosWFunc ;
398 SetIntVoxelWFuncType _setIntVoxelWFunc ;
399 SetInt64VoxelWFuncType _setInt64VoxelWFunc ;
400 SetDoubleVoxelWFuncType _setDoubleVoxelWFunc ;
401 SetLDoubleVoxelWFuncType _setLDoubleVoxelWFunc ;
402 SetIntCursorVoxelWFuncType _setIntCursorVoxelWFunc ;
403 SetInt64CursorVoxelWFuncType _setInt64CursorVoxelWFunc ;
404 SetDoubleCursorVoxelWFuncType _setDoubleCursorVoxelWFunc ;
405 SetLDoubleCursorVoxelWFuncType _setLDoubleCursorVoxelWFunc ;
406 FillIntWFuncType _fillIntWFunc ;
407 FillInt64WFuncType _fillInt64WFunc ;
408 FillDoubleWFuncType _fillDoubleWFunc ;
409 FillLDoubleWFuncType _fillLDoubleWFunc ;
410 MoveWFuncType _moveFXWFunc ;
411 MoveWFuncType _moveFYWFunc ;
412 MoveWFuncType _moveFZWFunc ;
413 MoveWFuncType _moveFCWFunc ;
414 MoveWFuncType _moveFTWFunc ;
415 MoveWFuncType _moveFUWFunc ;
416 MoveWFuncType _moveBXWFunc ;
417 MoveWFuncType _moveBYWFunc ;
418 MoveWFuncType _moveBZWFunc ;
419 MoveWFuncType _moveBCWFunc ;
420 MoveWFuncType _moveBTWFunc ;
421 MoveWFuncType _moveBUWFunc ;
422 MoveOffsetWFuncType _moveOffsetFunc ;
423 ResetCursorWFuncType _resetCursorFunc ;
424 MoveCursorFXLFWFuncType _moveCursorFXLFFunc ;
426
427protected:
429 void _enforceInstPub() { _enforceInst(); }
430
432 void _enforceInstPub2() { _enforceInst2(); }
433
434};
435
436#endif
#define SO_VIRTUALVOLUME_EXPORT
File containing all system dependent settings of the SoVirtualVolume project.
The SoSFMLImage field is the interface used by Inventor Nodes to access image data (in the current im...
Definition SoSFMLImage.h:70
The SoVirtualVolume class for fast voxel based access to paged ML images; see also mlVirtualVolume an...
ml::VirtualVolume * _virtualVolume
Pointer to the current untyped virtual volume or NULL if there is none.
MLdouble getDoubleValue(const XVImageSize &pos)
SO_VIRTUALVOLUME_EXPORT void getValue(const XVImageSize &pos, DATATYPE &retVal)
Get a voxel from the virtual volume.
MLint64 getInt64Value(const XVImageSize &pos)
bool _constructorAreExceptionsOn
useExceptions passed to constructor.
SO_VIRTUALVOLUME_EXPORT void fill(const XVImageSize &boxV1, const XVImageSize &boxV2, DATATYPE value)
Fill the area box in the virtual image with voxel value value.
SO_VIRTUALVOLUME_EXPORT MLDataType getDataType() const
Returns the data type used as internal data type of the virtual volume or - if currently no valid vir...
void setLDoubleCursorValue(MLldouble v)
SO_VIRTUALVOLUME_EXPORT void getWrittenPageData(MLuint32 wp, DATATYPE *&dataPtr) const
Returns typed pointer to voxel data of written page number wp.
virtual SO_VIRTUALVOLUME_EXPORT ~SoVirtualVolume()
Destructor.
SO_VIRTUALVOLUME_EXPORT XVImageSize getPageArrayExtent() const
Returns extents of the array of page buffers.
SO_VIRTUALVOLUME_EXPORT SoVirtualVolume & operator=(const SoVirtualVolume &virtVol)
Assignment operator.
SO_VIRTUALVOLUME_EXPORT void * getWrittenPageData(MLuint32 wp)
Returns untyped pointer to data of written page with page id wp.
MLint getIntValue(const XVImageSize &pos)
void fillInt(const XVImageSize &boxV1, const XVImageSize &boxV2, MLint v)
void setCursorPosition(const XVImageSize &pos)
SO_VIRTUALVOLUME_EXPORT bool isValid() const
Returns true if access methods may be called, otherwise false.
long getMaxNumKB() const
Returns the maxNumKB value passed to the constructor.
void setInt64Value(const XVImageSize &pos, MLint64 v)
void moveCursorByOffset(const XVImageSize &off)
SO_VIRTUALVOLUME_EXPORT SoSFMLImage * getImage() const
Returns the SoSFMLImage the SoVirtualVolume is associated to or NULL if it's a Virtual Volume of user...
SO_VIRTUALVOLUME_EXPORT MLuint getNumMappedPages() const
Access functions to virtual volume. Only to be called if isValid() returns true!
void * _tVirtualVolume
Pointer to the current typed virtual volume or NULL if there is none.
void fillDouble(const XVImageSize &boxV1, const XVImageSize &boxV2, MLdouble v)
bool isMapped(const XVImageSize &pos)
SO_VIRTUALVOLUME_EXPORT void unMapAndClearWrittenPages()
This function throws away all written pages.
void setIntValue(const XVImageSize &pos, MLint v)
SO_VIRTUALVOLUME_EXPORT SoVirtualVolume(const XVImageSize &ext=XVImageSize(0), double fillVal=0, MLDataType dType=MLuint8Type, long maxNumKB=-1, bool useExceptions=false)
Constructor to map an image of extents ext filled with fillVal.
void _enforceInstPub()
Template instantiation helper function. This function must not be called.
SO_VIRTUALVOLUME_EXPORT void setCursorValue(DATATYPE val)
Set value under cursor and lock page.
void setLDoubleValue(const XVImageSize &pos, MLldouble v)
void setIntCursorValue(MLint v)
MLDataType _constructorDataType
Extents passed to constructor.
MLdouble getDoubleCursorValue()
SO_VIRTUALVOLUME_EXPORT SoVirtualVolume(SoSFMLImage &image, MLDataType dType=ML_INVALID_DATA_TYPE, long maxNumKB=-1, bool useExceptions=false)
Constructor which creates a SoVirtualVolume interface to an ML paged image hidden behind image.
SO_VIRTUALVOLUME_EXPORT MLuint getNumPages() const
Returns number of all (mapped and written) pages.
SO_VIRTUALVOLUME_EXPORT void _updateVirtualVolumes(const XVImageSize &ext=XVImageSize(0), double fillVal=0, MLDataType dType=MLuint8Type, long maxNumKB=-1, bool useExceptions=false)
If there is a non NULL SoSFMLImage pointer in _image which contains a valid connection to a valid ML ...
SO_VIRTUALVOLUME_EXPORT void _removeVirtualVolumes(bool removeOnlyTyped=false)
Removes all current virtual volumes.
MLldouble getLDoubleValue(const XVImageSize &pos)
void _enforceInstPub2()
Template instantiation helper function. This function must not be called.
SO_VIRTUALVOLUME_EXPORT void setValue(const XVImageSize &pos, DATATYPE data)
Write a voxel into the virtual volume.
SO_VIRTUALVOLUME_EXPORT MLuint getNumBytes() const
Returns number of bytes currently allocated as pages in the virtual volume.
static SO_VIRTUALVOLUME_EXPORT void _imageChangedCB(void *clientData, SoSensor *sensor)
Static function called if _fieldSensor detects a change of _image; it updates the internal virtual vo...
SO_VIRTUALVOLUME_EXPORT MLuint getNumWrittenPages()
Returns number of written (and therefore locked) pages.
SO_VIRTUALVOLUME_EXPORT SoVirtualVolume(const SoVirtualVolume &virtVol)
Copy constructor.
bool areExceptionsOn() const
Returns the useExceptions value passed to the constructor.
long _constructorMaxNumKB
maxNumKB passed to constructor.
MLint64 getInt64CursorValue()
const XVImageSize & getCursorPosition()
void setInt64CursorValue(MLint64 v)
void fillLDouble(const XVImageSize &boxV1, const XVImageSize &boxV2, MLldouble v)
SoSFMLImage * _image
Reference to the SoSFMLImage passed in the constructor.
SO_VIRTUALVOLUME_EXPORT XVImageSize getPageExtent() const
Returns extents of a written and read pages used by the virtual volume.
void setDoubleValue(const XVImageSize &pos, MLdouble v)
MLldouble getLDoubleCursorValue()
SO_VIRTUALVOLUME_EXPORT void getCursorValue(DATATYPE &retVal)
SO_VIRTUALVOLUME_EXPORT void _createTypedVirtualVolume()
Create the typed version of the virtual volume and set up all function pointers from function wrapper...
SoFieldSensor _fieldSensor
Field sensor attached to the SoSFMLImage passed in the constructor.
void fillInt64(const XVImageSize &boxV1, const XVImageSize &boxV2, MLint64 v)
void setDoubleCursorValue(MLdouble v)
SO_VIRTUALVOLUME_EXPORT void resize(const XVImageSize &newExt)
This method resizes the virtual volume to the extents given by ext.
SoSFMLImage - field interface to ML images and related classes.
Definition SoSFMLImage.h:32
#define ML_INVALID_DATA_TYPE
Defines an invalid MLDataType.
Definition mlTypeDefs.h:613
MLint32 MLDataType
MLDataType.
Definition mlTypeDefs.h:596
@ MLuint8Type
Enumerator for the unsigned 8 bit ML integer type.
Definition mlTypeDefs.h:621
Target mlrange_cast(Source arg)
Generic version of checked ML casts.
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
TImageVector< MLint > ImageVector
Defines the standard ImageVector type which is used by the ML for indexing and coordinates.