MeVisLab Toolbox Reference
|
Base class for a generic file reader plugin with factory interface. More...
#include <mlFileReaderPluginsBase.h>
Public Member Functions | |
FileReaderPluginsBase () | |
Constructor. | |
virtual | ~FileReaderPluginsBase () |
Destructor cleaning up allocated structures and closing a possibly open file. | |
virtual bool | isSupported (const std::string &fileName) const =0 |
Applies a fast check whether the file is probably supported or not, for example via the suffix. | |
virtual double | getPluginPriority () const |
Returns a priority over other loader plugins, low priorities mean that other loader plugins with higher priorities which can also read the file should be preferred if there are any. | |
virtual MLErrorCode | loadFile (const std::string &fileName)=0 |
Opens and loads a file such that getPagedImageProperties() and fillSubImage() can be used to retrieve information from the file. | |
virtual size_t | getNumberOfImagesInFile ()=0 |
Returns the number of images which are accessible in the loaded file; normally one, but some formats can contain more than on image per file. | |
virtual std::string | getCodedImageIndexString (unsigned int imgIdx) |
If getNumberOfImagesInFile() is <=1 then the plugin string id getTypeId()->getName() is returned, otherwise the string getTypeId()->getName() plus "*#" and the imgIdx. | |
virtual unsigned int | extractImageIndexValue (const std::string &codedLoaderPluginString) |
From a string of the format "LoaderPluginName+#IDX" extract "IDX" as unsigned int, check whether it is smaller than the number of images in getNumberOfImagesInFile() and if yes then return it. | |
virtual void | setSelectedImageIndex (size_t idx=0) |
Selects which image from inside the loaded file shall be used. | |
virtual size_t | getSelectedImageIndex () const |
Returns the currently selected image from inside the loaded file. | |
virtual const PagedImage & | getPagedImageProperties ()=0 |
Returns the properties of the currently loaded image. | |
virtual MLErrorCode | fillSubImage (SubImage &dstSubImage)=0 |
Copy overlapping regions in dstSubImage with image data from the loaded file; note that the calculation of the overlapping region depends on whether a PagedImage was set with setReferenceForFillingInReferenceCoordinates or not. | |
virtual std::string | getTagDump (const size_t maxNumBinaryEntries=8, const size_t maxNumStringEntries=20) |
This function returns a tag or meta data dump of the loaded file or an empty string if not possible (default implementation). | |
virtual void | close ()=0 |
Closes the file and cleans up data structures. | |
virtual void | setReferenceForFillingInReferenceCoordinates (const PagedImage *refImg=nullptr) |
If a valid PagedImage pointer is passed then each fillSubImage operation will take into account the difference between the world origin of the given reference PagedImage and ensure that the copySubImage operation fills dstSubImg in world coordinates of refImg; if nullptr is passed then subimage data will be copied from the file assuming that it is located at voxel coordinates (0,0,0,0,0,0) Loaders which do not support world coordinates will silently ignore the given reference image. | |
virtual const PagedImage * | getReferenceForFillingInReferenceCoordinates () const |
Returns the recently set "enabled" state set with setSubImageFillingInReferenceCoordinates(). | |
virtual bool | supportsFillingInReferenceCoordinates () const |
Returns true if the loader instance support SubImage filling in reference coordinates, otherwise false. | |
Static Public Member Functions | |
static FileReaderPluginsBase * | createLoaderInstance (const std::string &fileName) |
Factory functionality: Instantiate a loader for the file name fileName and return a new instance of it or return nullptr if no loader can be created. | |
Protected Member Functions | |
ImageVector | _determineWorldDifferenceAsVoxelShift (const PagedImage &destination) const |
Determines a translation vector for SubImages boxes which represents the world difference between the given two PagedImage. | |
Base class for a generic file reader plugin with factory interface.
Classes deriving from FileReaderPluginsBase must implement all pure virtual functions and register themselves in the Runtime type system normally with ML_CLASS_HEADER(DerivedClassName), ML_CLASS_SOURCE(DerivedClassName, FileReaderPluginsBase), and the corresponding DerivedClassName::initClass() call during library load. It is recommended to load the library with a .def file entry such as
PreloadDLL DerivedPluginClassLibrary {}
to make MeVisLab load the class library on startup time to ensure that classes using the createLoaderInstance() functionality surely can find it.
Definition at line 32 of file mlFileReaderPluginsBase.h.
ml::FileReaderPluginsBase::FileReaderPluginsBase | ( | ) |
Constructor.
|
virtual |
Destructor cleaning up allocated structures and closing a possibly open file.
|
protected |
Determines a translation vector for SubImages boxes which represents the world difference between the given two PagedImage.
Closes the file and cleans up data structures.
Property requests and fillSubImage calls will not operate successfully any more after this call.
Implemented in ml::DMFileReaderPlugin, and ml::XYLibReaderPlugin.
|
static |
Factory functionality: Instantiate a loader for the file name fileName and return a new instance of it or return nullptr if no loader can be created.
|
virtual |
From a string of the format "LoaderPluginName+#IDX" extract "IDX" as unsigned int, check whether it is smaller than the number of images in getNumberOfImagesInFile() and if yes then return it.
If the "*#" code does not exist it is assumed that the index is not coded and 0 is returned. If "*#" is found but the index cannot be parsed after it or if it outside the number of images in the file then ML_UINT32_MAX is returned.
|
pure virtual |
Copy overlapping regions in dstSubImage with image data from the loaded file; note that the calculation of the overlapping region depends on whether a PagedImage was set with setReferenceForFillingInReferenceCoordinates or not.
Loaders which do not support filling in reference coordinates (which return false on supportsFillingInReferenceCoordinates()) will silently ignore the reference image.
dstSubImage | The subimage to be filled with data from the loaded file where the image regions overlap. Non overlapping regions are left unchanged. |
Implemented in ml::DMFileReaderPlugin, and ml::XYLibReaderPlugin.
|
virtual |
If getNumberOfImagesInFile() is <=1 then the plugin string id getTypeId()->getName() is returned, otherwise the string getTypeId()->getName() plus "*#" and the imgIdx.
In case of invalid getTypeId()->getName() "Unknown" is coded as plugin id.
Returns the number of images which are accessible in the loaded file; normally one, but some formats can contain more than on image per file.
Implemented in ml::DMFileReaderPlugin, and ml::XYLibReaderPlugin.
|
pure virtual |
Returns the properties of the currently loaded image.
Validity can be determined with isValid() on returned object.
Implemented in ml::DMFileReaderPlugin, and ml::XYLibReaderPlugin.
Returns a priority over other loader plugins, low priorities mean that other loader plugins with higher priorities which can also read the file should be preferred if there are any.
The order of plugins with equal priorities is left undefined. The returned value defaults to 0.5; values should be from [0,1].
Reimplemented in ml::XYLibReaderPlugin.
|
virtual |
Returns the recently set "enabled" state set with setSubImageFillingInReferenceCoordinates().
Returns the currently selected image from inside the loaded file.
|
virtual |
This function returns a tag or meta data dump of the loaded file or an empty string if not possible (default implementation).
If a binary value information is displayed then the number of shown values is controlled with maxNumBinaryEntries; if there are more then "..." is displayed instead. If a string value is displayed then the number of shown characters is controlled with maxNumStringEntries; if there are more then "..." is displayed instead.
Reimplemented in ml::DMFileReaderPlugin, and ml::XYLibReaderPlugin.
|
pure virtual |
Applies a fast check whether the file is probably supported or not, for
example via the suffix.
If false is returned then file is definitely not loadable; if true then opening with loadFile() is worth a try.
Implemented in ml::DMFileReaderPlugin, and ml::XYLibReaderPlugin.
|
pure virtual |
Opens and loads a file such that getPagedImageProperties() and fillSubImage() can be used to retrieve information from the file.
Corresponding close is performed with close() or the destructor.
fileName | The absolute path to the file to be loaded. |
Implemented in ml::DMFileReaderPlugin, and ml::XYLibReaderPlugin.
|
virtual |
If a valid PagedImage pointer is passed then each fillSubImage operation will take into account the difference between the world origin of the given reference PagedImage and ensure that the copySubImage operation fills dstSubImg in world coordinates of refImg; if nullptr is passed then subimage data will be copied from the file assuming that it is located at voxel coordinates (0,0,0,0,0,0) Loaders which do not support world coordinates will silently ignore the given reference image.
refImg | The image providing the reference coordinate system; it's life time must be longer than the last fillSubImage operation. If it is not valid or the matrix is not of rank 4 then operations will be the same as with refImg = nullptr. |
Selects which image from inside the loaded file shall be used.
Typically 0, but some formats can load more than one image from a file whose number can be determined with getNumberOfImagesInFile().
Returns true if the loader instance support SubImage filling in reference coordinates, otherwise false.
Reimplemented in ml::DMFileReaderPlugin, and ml::XYLibReaderPlugin.