ImFusion SDK 4.3
ImFusionFilePlugin Class Referenceabstract

#include <ImFusion/Base/ImFusionFilePlugin.h>

Allow loading and saving of custom classes and data within the ImFusion file format. More...

+ Inheritance diagram for ImFusionFilePlugin:

Detailed Description

Allow loading and saving of custom classes and data within the ImFusion file format.

Multiple data type IDs may be supported by a plugin. The load and save methods do not have to be implemented, for example if a custom image class shall be created for a type but the standard loader for image data is sufficient.

Public Member Functions

virtual ~ImFusionFilePlugin ()=default
 Destructor.
 
virtual DataloadInstance (unsigned int type, unsigned int headerSize=0)=0
 Create specialized instance for a given data type or return null if not supported.
 
virtual unsigned int saveType (const Data *data)=0
 Return type for saving a given data instance or null if not supported.
 
virtual bool load (unsigned int, Data *, std::istream &, Progress *=0)
 Load data into given class instance, return true if data is complete (otherwise ImFusionImage loader will be run)
 
virtual bool save (Data *, std::ostream &, Progress *=0)
 Save a data instance to file, return true if complete (otherwise ImFusionImage writer will be run afterwards) To keep the consistency between the description in data block header and the actual stored block body, use the m_blockType in save method and avoid checking data description directly from the data.
 
virtual std::unique_ptr< PropertiescustomPropertiesToSave (Data *)
 Lets plugin save custom properties as part of the global file metadata.
 
virtual bool loadCustomProperties (Data *, Properties *)
 Load custom properties as returned previously by customPropertiesToSave()
 
virtual void applyFlipToEnsureConsistency (Data *)
 Is called after the image content had to be flipped to ensure a consistent coordinate system.
 
virtual bool beginBlockWrite (std::iostream &)
 Initialize plugin with current file pointer.
 
virtual unsigned long long endBlockWrite ()
 Indicate to plugin that the block it is writing needs to be finished.
 
virtual bool beginBlockRead (std::iostream &, unsigned long long)
 Initialize plugin with current file pointer.
 
virtual bool endBlockRead ()
 Indicate to plugin that it will lose read access to the file pointer after this call.
 
virtual void setBlockType (unsigned int type)
 Set the type of current data block which is being loaded/saved.
 

Protected Attributes

unsigned int m_blockType = 0
 Keeps the type of currently saving/loading data block.
 

Member Function Documentation

◆ loadInstance()

virtual Data * loadInstance ( unsigned int type,
unsigned int headerSize = 0 )
pure virtual

Create specialized instance for a given data type or return null if not supported.

Implemented in GenericASCImFusionFilePlugin, ImFusionImage, SpineDataImFusionFilePlugin, StereoImageImFusionFilePlugin, and TrackedImageSetImFusionFilePlugin.

◆ saveType()

virtual unsigned int saveType ( const Data * data)
pure virtual

Return type for saving a given data instance or null if not supported.

Implemented in GenericASCImFusionFilePlugin, ImFusionImage, SpineDataImFusionFilePlugin, StereoImageImFusionFilePlugin, and TrackedImageSetImFusionFilePlugin.

◆ load()

virtual bool load ( unsigned int ,
Data * ,
std::istream & ,
Progress * = 0 )
virtual

Load data into given class instance, return true if data is complete (otherwise ImFusionImage loader will be run)

Reimplemented in GenericASCImFusionFilePlugin, ImFusionImage, SpineDataImFusionFilePlugin, StereoImageImFusionFilePlugin, and TrackedImageSetImFusionFilePlugin.

◆ save()

virtual bool save ( Data * ,
std::ostream & ,
Progress * = 0 )
virtual

Save a data instance to file, return true if complete (otherwise ImFusionImage writer will be run afterwards) To keep the consistency between the description in data block header and the actual stored block body, use the m_blockType in save method and avoid checking data description directly from the data.

Reimplemented in GenericASCImFusionFilePlugin, ImFusionImage, SpineDataImFusionFilePlugin, StereoImageImFusionFilePlugin, and TrackedImageSetImFusionFilePlugin.

◆ customPropertiesToSave()

virtual std::unique_ptr< Properties > customPropertiesToSave ( Data * )
virtual

Lets plugin save custom properties as part of the global file metadata.

Reimplemented in StereoImageImFusionFilePlugin.

◆ loadCustomProperties()

virtual bool loadCustomProperties ( Data * ,
Properties *  )
virtual

Load custom properties as returned previously by customPropertiesToSave()

Returns
true if successful, false otherwise

Reimplemented in GenericASCImFusionFilePlugin, SpineDataImFusionFilePlugin, StereoImageImFusionFilePlugin, and TrackedImageSetImFusionFilePlugin.

◆ applyFlipToEnsureConsistency()

virtual void applyFlipToEnsureConsistency ( Data * )
inlinevirtual

Is called after the image content had to be flipped to ensure a consistent coordinate system.

This method needs to take care that data consistency is maintained, for instance by also updating all relevant data components and other meta data, e.g. calibration matrices. Background: Previously, mixed image coordinate conventions (origin is either top-left or bottom-left corner) were allowed in the entire framework. The bottom- left (=OpenGL) convention is now being phased out, so for several applications, including ultrasound, and X-ray/CBCT images, images stored with the bottom-left convention are hard-flipped on loading.

Reimplemented in TrackedImageSetImFusionFilePlugin.

◆ beginBlockWrite()

virtual bool beginBlockWrite ( std::iostream & )
virtual

Initialize plugin with current file pointer.

The pointer points to the position directly after the block header. Until end() is called the plugin can freely append to the file. It may not seek to a position before the position of the stream upon the begin() call.

Parameters
iofile stream which you can write to
Returns
true if successful, false otherwise

Reimplemented in ImFusionImage.

◆ endBlockWrite()

virtual unsigned long long endBlockWrite ( )
virtual

Indicate to plugin that the block it is writing needs to be finished.

The plugin must finalize the data it is writting.

Returns
number of bytes written to the block

Reimplemented in ImFusionImage.

◆ beginBlockRead()

virtual bool beginBlockRead ( std::iostream & ,
unsigned long long  )
virtual

Initialize plugin with current file pointer.

The pointer points to the position directly after the block header. Until end() is called the plugin can freely read from the file. It may not seek to a position before the position of the stream upon the begin() call.

Parameters
iofile stream which can be read
blockSizenumber of bytes in block starting from current get file pointer
Returns
true if successful, false otherwise

◆ endBlockRead()

virtual bool endBlockRead ( )
virtual

Indicate to plugin that it will lose read access to the file pointer after this call.

Returns
true if successful, false otherwise

◆ setBlockType()

virtual void setBlockType ( unsigned int type)
virtual

Set the type of current data block which is being loaded/saved.

Must be set if the header of the current block is chosen by another plug-in

Member Data Documentation

◆ m_blockType

unsigned int m_blockType = 0
protected

Keeps the type of currently saving/loading data block.

When a plug-in chooses the type, the same must be set for the ImFusionImage to keep the header and body consistent.


The documentation for this class was generated from the following file:
Search Tab / S to search, Esc to close