13#ifndef ML_VIRTUAL_VOLUME_H
14#define ML_VIRTUAL_VOLUME_H
53 template<
class DATATYPE>
class TVirtualVolume;
55 class VirtualVolumeMemoryTracker;
135 inline bool isValid()
const {
return _valid; }
138 inline void invalidate() { _valid =
false; _cleanUpMemory(); }
395 bool _areExceptionsOn;
420 MLuint _numPageArrayEntries;
459 VirtualVolumeMemoryTracker* _currentlyUsedMemoryTracker;
461 friend class VirtualVolumeMemoryTracker;
The strong handle of a MLMemoryBlock.
Class to manage a binary image.
Base class for an image processing module of the ML.
Class which represents an image, which manages properties of an image and image data which is located...
This class manages/represents a rectangular 6d image region which is organized linearly in memory.
The TVirtualVolume class implements random access to a paged input image or a pure virtual image with...
This class manages a virtual volume organizing efficient voxel access to the output image of an input...
const ImageVector & getPageExtent() const
Returns the extent of any written/read page used by the virtual volume.
void * _loadPage(PageBuffer *pageBuffer)
This function really loads the page into the memory and updates the corresponding page buffer so that...
MLuint getNumWrittenPages()
Returns number of written (and therefore locked) pages.
void _cleanUpMemory()
Cleans up all allocated memory areas.
VirtualVolume(PagedImage *image, MLDataType dType, MLint maxNumKB=-1, bool areExceptionsOnFlag=false)
Constructor to map a pagedImg.
MLint getDim() const
Return dimension of specified volume.
PageBuffer * _getPageBuffer6D(const ImageVector &pos)
Returns the pageBuffer containing the voxel passed as position.
void copyTileFromInputImage(const SubImageBox &box, PagedImage &image, const ImageVector &shift, const ScaleShiftData &scaleShift=ScaleShiftData())
Copy an image region box from the image and write to the position resulting from box + shift into the...
void resize(const ImageVector &newExt)
This method resizes the virtual volume to the extents given by ext.
MLuint getNumBytes()
Returns number of bytes currently allocated as pages in the virtual volume.
void * getWrittenPageData(MLuint32 wp)
Returns untyped pointer to data of written page with page id wp.
MLDataType getDataType() const
Return data type enum.
void _init(PagedImage *img, const ImageVector &ext, const ImageVector &pageExtent, MLdouble fillVal, MLDataType dType, MLint maxNumKB=-1, bool areExceptionsOnFlag=false)
Constructor-like initialization of the instance.
VirtualVolume(const ImageVector &ext=ImageVector(0), MLdouble fillVal=0, MLDataType dType=MLuint8Type, MLint maxNumKB=-1, bool areExceptionsOnFlag=false)
Constructor to map an image of extents ext (default is 256) filled with fillVal (default is 0).
bool isValid() const
Returns true if instance is valid, otherwise false.
MLuint getNumMappedPages() const
Returns number of currently mapped (volatile) pages. Written pages are counted only temporarily here.
const SubImageBox & getBox() const
Get box extents of input volume.
Module * getModule() const
Returns the pointer to the module which contains the paged image the virtual volume is associated wit...
BitImage * getUsedPagesMask(bool enableMappedPages=true, bool enableWrittenPages=true) const
Returns a pointer BitImage containing a bit for each page of the virtual volume.
void _reset()
Cleans up all allocated memory and resets instance to state after _default().
MLint getInputIndex() const
Returns the output index of the input baseOp or -1 if there is no input baseOp.
const SubImageBox & getWrittenPageBox(MLuint32 wp)
Returns box of written page no.
MLuint getNumPages()
Returns number of all (mapped and written) pages.
void _default()
Set all members to default values without freeing anything.
void unMapAndClearWrittenPages()
This function throws away all written pages.
void copyToSubImage(SubImage &outSubImg)
Copy area from virtual volume into outSubImg.
VirtualVolume(const ImageVector &extent, const ImageVector &pageExtent, MLdouble fillVal=0, MLDataType dType=MLuint8Type, MLint maxNumKB=-1, bool areExceptionsOnFlag=false)
Constructor that allows to pass the pageExtent.
void * createTypedVirtualVolume()
Creates and returns a typed version of this virtual volume as void pointer or NULL on failure.
static void destroyTypedVirtualVolume(void *tVV, MLDataType dt)
Destroys a typed version of a virtual volume given by a void pointer tVV of data type dt.
const ImageVector & getPageArrayExtent() const
Returns the extent of the array of page buffers.
void registerPageFunction(PageFunc pFunc, void *userData)
Register a function to be called when a page is mapped or unmapped.
static void * _loadPageCB(PageBuffer *pageBuffer)
This function calls the page loading method of Virtual volume.
PagedImage * getInputImage() const
Returns the pointer to the paged image the virtual volume is associated with.
virtual ~VirtualVolume()
Destructor.
PageMapped
Enum which describes whether a page is mapped into the currently used page list or unmapped from used...
ImageVector getExtent() const
Get extents of input volume.
void _updateWrittenPages()
This function moves all written pages to _writtenPages to have a valid base to work on all written pa...
bool areExceptionsOn() const
Returns true if exception handling is enabled otherwise false.
void invalidate()
Invalidates state of virtual volume, e.g. after an error.
MLint32 MLDataType
MLDataType.
@ MLuint8Type
Enumerator for the unsigned 8 bit ML integer type.
Target mlrange_cast(Source arg)
Generic version of checked ML casts.
MLuint64 MLuint
An unsigned ML integer type with at least 64 bits used for index calculations on very large images ev...
MLint64 MLint
A signed ML integer type with at least 64 bits used for index calculations on very large images even ...
PageBuffer is a helper structure to manage one page of input data of the VirtualVolume class and it a...
SubImageBox _box
Box of original image mapped in this page.
VirtualVolume * _virtVol
Pointer to the virtual volume object.
ReturnPageFunc _getPageFkt
Pointer to function to return the page managed by the PageBuffer.
MLMemoryBlockHandle _memoryBlockHandle
The memory block handle for holding the page data locked.
bool _locked
If true this page contains written data and must not be removed.
PageBuffer()
Initialize the structure.
void * _page
Pointer to the page data reduced by the offset to the page origin.