Open Inventor Release 2024.1.3
 
Loading...
Searching...
No Matches
SoVolumeReader Class Referenceabstract

Large Data Management Abstract base class for volume data set readers. More...

#include <LDM/readers/SoVolumeReader.h>

+ Inheritance diagram for SoVolumeReader:

Public Types

enum  ReadError {
  RD_NO_ERROR ,
  RD_FILE_NOT_FOUND_ERROR ,
  RD_INVALID_DATA_ERROR ,
  RD_UNSUPPORTED_DATA_TYPE_ERROR ,
  RD_FILE_FORMAT_NOT_VALID_ERROR ,
  RD_UNKNOWN_ERROR
}
 Read error. More...
 
enum  Axis {
  X ,
  Y ,
  Z
}
 Which axis to handle. More...
 
enum  ReaderType {
  NO_READER ,
  AM ,
  AVS ,
  DICOM ,
  GENERIC ,
  LDM ,
  MEMORY ,
  RASTERSTACK ,
  SEGY ,
  VOL ,
  VOX ,
  TIFF ,
  MRC
}
 Available reader type. More...
 
enum  CoordinateType {
  COORDINATES_UNIFORM = 0 ,
  COORDINATES_RECTILINEAR
}
 Coordinate type used by this data set. More...
 

Public Member Functions

virtual SoType getTypeId () const
 Returns the type identifier for this specific instance.
 
 SoVolumeReader ()
 Constructor.
 
virtual ReadError getDataChar (SbBox3f &size, SoDataSet::DataType &type, SbVec3i32 &dim)=0
 Gets the characteristics (file header) of the data volume.
 
virtual SbBool setOutputDataType (SbBool doChange, SoDataSet::DataType outputType)
 Sets the output data type.
 
virtual SbBool setInputDataRange (SbBool doChange, double min, double max)
 Requests that the input be converted from the specified range to the range depending on the output data type.
 
virtual int getNumSignificantBits ()
 This method is optional.
 
virtual void getSubSlice (const SbBox2i32 &subSlice, int sliceNumber, void *data)
 Must copy the rectangular part defined by subSlice of the XY slice sliceNumber to the memory referenced by data.
 
virtual void getSubSlice (const SbBox2i32 &subSlice, int sliceNumber, SoBufferObject *dataBuffer)
 Same as getSubSlice( const SbBox2i32& subSlice, int sliceNumber, void * data ) but using an SoBufferObject as the target of the data.
 
SbVec3i32 getNumVoxels (const SbVec3i32 &realSize, const SbVec3i32 &subsamplingLevel)
 Utility function provided by SoVolumeReader for subclass readers to call.
 
SbVec3i32 getSizeToAllocate (const SbVec3i32 &realSize, const SbVec3i32 &subsamplingLevel)
 Utility function provided by SoVolumeReader for subclass readers to call.
 
virtual int setFilename (const SbString &filename)
 Specifies the path of the file.
 
SbString getFilename () const
 Returns the path of the file.
 
virtual SbBool isDataConverted () const
 Returns TRUE if the data is already organized in tiles for the LDM module.
 
virtual void reloadTileMinMax ()
 
virtual SbBool getTileSize (SbVec3i32 &size)
 Returns tile dimensions in voxels when using data stored in tiles.
 
virtual SoBufferObjectreadTile (int index, const SbBox3i32 &tilePosition)
 Given an index, reads a tile if the data is organized in tiles (for LDM).
 
virtual SbBool readXTraceInTile (int index, unsigned char *&buffer, const SbBox3i32 &tilePosition, const SbVec2i32 &tracePosition)
 Read directly from the data source, a trace inside a tile.
 
virtual SbBool readYSliceInTile (int index, unsigned char *&buffer, const SbBox3i32 &tilePosition, const uint32_t &slicePosition)
 Read directly from the data source, an orthoslice on the Y axis (Zaxis == 1) inside a tile.
 
virtual SbBool readZSliceInTile (int index, unsigned char *&buffer, const SbBox3i32 &tilePosition, const uint32_t &slicePosition)
 Read directly from the data source, an orthoslice on the Z axis (Zaxis == 2) inside a tile.
 
virtual SbBool readXSliceInTile (int index, unsigned char *&buffer, const SbBox3i32 &tilePosition, const uint32_t &slicePosition)
 Read directly from the data source, an orthoslice on the X axis (Zaxis == 0) inside a tile.
 
virtual SbBool isThreadSafe () const
 Should return TRUE if the reader is thread safe.
 
virtual SbBool isIgnoredFile () const
 Should return TRUE if at least one file has been ignored during reading.
 
virtual SbString getOriginalFilename () const
 Returns original file name from which the data has been converted to LDM format if stored in file.
 
virtual SbBool getMinMax (int64_t &min, int64_t &max)
 Returns min and max for integer data type, if available.
 
virtual SbBool getMinMax (double &min, double &max)
 Returns min max for float data type, if available.
 
virtual SbBool getHistogram (std::vector< int64_t > &numVox)
 Returns histogram if available.
 
virtual SbBool setDirectCoordSysAutoDetection (SbBool autoValue)
 Sets whether or not the reader should automatically try to detect if the coordinate system used is direct or not.
 
virtual SbBool getDirectCoordSysAutoDetection ()
 Return automatic detection value.
 
virtual SbBool setDirectCoorSys (SbBool directCoord)
 Specify if the coordinate system used is direct or not.
 
virtual SbBool getDirectCoordSys ()
 Return whether the coordinate system used is direct or not.
 
virtual SbVec2d getTileMinMax (int index) const
 Returns the minimum and maximum data values for the given tile.
 
virtual SoVolumeReader::ReaderType getReaderType ()
 Returns the reader type.
 
virtual SoVolumeWritergetConfiguredWriter ()
 Returns a volume writer that corresponds to this reader
(same format, parameters, etc).
 
CoordinateType getCoordinateType ()
 Returns coordinate type used by the data set.
 
const float * getRectilinearCoordinates (Axis axis) const
 Returns the coordinates for the specified axis.
 
void setRectilinearCoordinates (const float *x, const float *y, const float *z)
 Sets rectilinear coordinates for the data set.
 
virtual SbBool isRGBA () const
 Returns TRUE if the data set contains RGBA color values.
 
void setRGBA (const SbBool flag)
 Specifies if data must be considered as RGBA.
 
virtual void closeAllHandles ()
 Close all resources that are locked by the reader.
 
virtual void restoreAllHandles ()
 Restore resources that were closed by closeAllHandles().
 
- Public Member Functions inherited from SoFieldContainer
void setToDefaults ()
 Sets all fields in this object to their default values.
 
SbBool hasDefaultValues () const
 Returns TRUE if all of the object's fields have their default values.
 
SbBool fieldsAreEqual (const SoFieldContainer *fc) const
 Returns TRUE if this object's fields are exactly equal to fc's fields.
 
void copyFieldValues (const SoFieldContainer *fc, SbBool copyConnections=FALSE)
 Copies the contents of fc's fields into this object's fields.
 
SoNONUNICODE SbBool set (const char *fieldDataString)
 Sets one or more fields in this object to the values specified in the given string, which should be a string in the Open Inventor file format.
 
SbBool set (const SbString &fieldDataString)
 Sets one or more fields in this object to the values specified in the given string, which should be a string in the Open Inventor file format.
 
void get (SbString &fieldDataString)
 Returns the values of the fields of this object in the Open Inventor ASCII file format in the given string.
 
virtual int getFields (SoFieldList &list) const
 Appends references to all of this object's fields to resultList, and returns the number of fields appended.
 
virtual int getAllFields (SoFieldList &list) const
 Returns a list of fields, including the eventIn's and eventOut's.
 
virtual SoFieldgetField (const SbName &fieldName) const
 Returns a the field of this object whose name is fieldName.
 
virtual SoFieldgetEventIn (const SbName &fieldName) const
 Returns a the eventIn with the given name.
 
virtual SoFieldgetEventOut (const SbName &fieldName) const
 Returns the eventOut with the given name.
 
SbBool getFieldName (const SoField *field, SbName &fieldName) const
 Returns the name of the given field in the fieldName argument.
 
SbBool enableNotify (SbBool flag)
 Notification at this Field Container is enabled (if flag == TRUE) or disabled (if flag == FALSE).
 
SbBool isNotifyEnabled () const
 Notification is the process of telling interested objects that this object has changed.
 
virtual void setUserData (void *data)
 Sets application data.
 
void * getUserData (void) const
 Gets user application data.
 
- Public Member Functions inherited from SoBase
virtual void touch ()
 Marks an instance as modified, simulating a change to it.
 
virtual SbName getName () const
 Returns the name of an instance.
 
virtual void setName (const SbName &name)
 Sets the name of an instance.
 
void setSynchronizable (const bool b)
 Sets this to be a ScaleViz synchronizable object.
 
bool isSynchronizable () const
 Gets the ScaleViz synchronizable state of this object.
 
- Public Member Functions inherited from SoRefCounter
void ref () const
 Adds a reference to an instance.
 
void unref () const
 Removes a reference from an instance.
 
void unrefNoDelete () const
 unrefNoDelete() should be called when it is desired to decrement the reference count, but not delete the instance if this brings the reference count to zero.
 
int getRefCount () const
 Returns current reference count.
 
void lock () const
 lock this instance.
 
void unlock () const
 unlock this instance.
 
- Public Member Functions inherited from SoTypedObject
SbBool isOfType (const SoType &type) const
 Returns TRUE if this object is of the type specified in type or is derived from that type.
 
template<typename TypedObjectClass >
SbBool isOfType () const
 Returns TRUE if this object is of the type of class TypedObjectClass or is derived from that class.
 

Static Public Member Functions

static SoType getClassTypeId ()
 Returns the type identifier for this class.
 
static SoVolumeReadergetAppropriateReader (const SbString &filename)
 Returns a preconfigured SoVolumeReader instance that can be used to load the given file (based on the filename extension).
 
- Static Public Member Functions inherited from SoFieldContainer
static SoType getClassTypeId ()
 Returns the type of this class.
 
- Static Public Member Functions inherited from SoBase
static SoType getClassTypeId ()
 Returns type identifier for this class.
 
- Static Public Member Functions inherited from SoTypedObject
static SoType getClassTypeId ()
 Returns the type identifier for this class.
 

Protected Member Functions

virtual ~SoVolumeReader ()
 Destructor.
 
void * getBuffer (int64_t offset, unsigned int size)
 Returns a pointer to a buffer of size bytes corresponding to a part of the file at offset bytes from the beginning of the file.
 
int64_t fileSize ()
 Returns the size of the file when file I/O is handled by this class.
 

Static Protected Member Functions

static bool registerVolumeReaderExtension (const SbString &fileExtension, const SoType &readerType)
 Register an SoVolumeReader class to handle a file extension.
 
static bool unregisterVolumeReaderExtensions (const SoType &readerType)
 Unregister all filename extensions associated with the specified SoVolumeReader class.
 
static int bytesToInt (const unsigned char *ptr, int sizeBytes)
 Utility method that returns an integer from sizeBytes bytes starting at address ptr.
 
static void swapBytes (int *intPtr, int sizeBytes)
 Utility method to convert an integer into the correct architecture (little/big endian).
 
static void swapBytesN (void *buffer, int numElements, int numBytesPerElement)
 Utility method to swap bytes of each element of an array of numElements elements.
 
static SbBool isValidFloat (const float val)
 Utility method to check if value is a valid IEEE 754 floating point number.
 
static SbBox3f adjustFlatExtent (const SbString &fileName, const SbBox3f &extent, const SbVec3i32 &dim)
 VolumeViz doesn't handles empty extent (for ex.
 

Deprecated

SoDEPRECATED SbBool m_dataConverted
 
virtual SoDEPRECATED SbBool readTile (int index, unsigned char *&buffer, const SbBox3i32 &tilePosition)
 Given an index, reads a tile if the data is organized in tiles (for LDM).
 
virtual SoDEPRECATED SbBool readTile (int index, SoBufferObject *buffer, const SbBox3i32 &tilePosition)
 Same as readTile(int index, unsigned char*& buffer, const SbBox3i32& tilePosition) but using an SoBufferObject (allocated by LDM) as the target of the data.
 
virtual SoDEPRECATED int getBorderFlag ()
 Returns border (overlap) value if stored in file.
 
virtual SoDEPRECATED SbBool getMinMax (int &min, int &max)
 Returns min max if stored in file.
 

Detailed Description

Large Data Management Abstract base class for volume data set readers.

This virtual class provides the interface through which VolumeViz accesses volume data that is not already in memory. Predefined reader classes are provided for many common formats like DICOM and SEGY. See the list of supported file formats and class names below.

Application developers may implement custom reader classes. Custom reader classes allow VolumeViz to access data stored in other file formats. This is particularly useful for converting data to LDM format. A custom reader class could also allow VolumeViz to access data through a proprietary data manager or data stored in application memory.

Minimum implementation:

The application must implement a class derived from SoVolumeReader, and must implement the method getDataChar(). In addition, the optional methods getNumSignificantBits() and getMinMax() can be implemented. If getNumSignificantBits() is not implemented (or returns 0), then the number of significant bits depends on the data type. If getMinMax() is not implemented (or returns false), then VolumeViz will find the min and max voxel values. Note that this requires loading all the data and could take a lot of time for a large volume.

VolumeViz always calls getDataChar() and getNumSignificantBits() before requesting any data from the reader.

If the isDataConverted() method is not implemented (or returns false), then VolumeViz will only call getSubSlice() to request data and will build the LDM tile hierarchy in memory, using the slice data. In this case, note that:

  • VolumeViz always caches data in memory using an LDM multi-resolution, tiled hierarchy. Therefore getSubSlice() may be called multiple times with the same slice number as tiles are constructed in memory.
  • The tile dimensions used to cache data in memory are determined by the tileDimension field of the SoLDMResourceParameters object associated with the SoVolumeData node. This field can be set by the application, but VolumeViz will not automatically set it (as it does in the case of an LDM reader). Of course a custom reader could implement the getTileSize() method for the application to call, even though VolumeViz doesn't use it.
  • VolumeViz will not call the getHistogram() method. So if the application calls getHistogram() on the SoVolumeData node, VolumeViz will build the histogram. This requires loading all the data and could take a lot of time for a large volume. However if VolumeViz builds the histogram, it also finds the min and max values, so there is no extra time required for that query.

LDM (tiled) volume reader:

In addition to the usual requirements for an application-defined reader, e.g., implementing the getDataChar() method, an application-defined reader for LDM data is required to:

  • Implement the isDataConverted() method and return TRUE.
    The method must return TRUE when the reader is passed to SoVolumeData to ensure that LDM manager classes are correctly initialized.
  • Implement the readTile() method.
    • When implementing the readTile method, be aware that how the SoCpuBuffer object is created affects how its memory will be managed.
      In general you should create the object using the constructor with no parameters, then allocate memory inside the object using the setSize() method. In this case the buffer object owns the memory and the memory will be freed when LDM no longer needs this tile. This implies for example that to avoid data copying when reading tile data from a file, you should create and allocate the buffer object, map the buffer object, then read the data into the buffer object. If you create the buffer object "wrapping" an existing block of memory, that memory will not be freed when LDM releases the buffer object. The application owns that memory and is responsible for freeing it.
    • Note that readTile can return one of the specialized sub-classes of SoCpuBufferObject that use less system memory:
      • SoCpuBufferUniform: This buffer contains a "uniform" tile in which all the voxels have the same value. It is stored efficiently as a single value until needed.
      • SoCpuBufferCompressed: This buffer contains a compressed tile. It is stored efficiently in its compressed form until needed.
      • SoCpuBufferBasicProperty: This buffer contains a standard tile, but can also store the tile's min and max data values for use in various optimizations.
      • SoCpuBufferBitset: This contains a bitset tile in which each voxel is a boolean value. It is stored efficiently in a packed form until needed.
    • Also note that readTile can return an undefined tile by returning either NULL or an empty buffer. See readTile() for detail.
  • Implement the getTileSize() method

An application-defined LDM reader may optionally:

  • Implement the getMinMax() method
    Return TRUE and the requested values if the min and max data values for the volume are known to the reader, e.g., are in the file header. The reader should implement this method if possible, because applications typically query these values to setup their SoDataRange node. If this method is not implemented, and the application calls SoVolumeData::getMinMax() is called, then VolumeViz must load every tile to compute the volume min and max. This can cause a long delay.
  • Implement the getTileMinMax() method
    Return the min and max values for the specified data tile. This information benefits optimizations such as SoLDMGlobalResourceParameters::setIgnoreFullyTransparentTiles. If this method is not implemented, VolumeViz will automatically compute the min and max values for each tile when it is loaded. Automatic computation works fine for volume data, but we strongly recommend implementing this method for height field data.
  • Implement the getHistogram() method
    Return TRUE and the requested values if the min and max data values are known to the reader, e.g., are in the file header.

General information:

Starting with Open Inventor 7.0, general rectilinear grids are supported. This feature allows non-uniform voxel spacing along each axis of the volume. The AmiraMesh reader (.am file), the in-memory reader, and the LDM reader support rectilinear coordinates. Call the method setRectilinearCoordinates to specify rectilinear coordinates (if they are not already stored in the data file and set by the reader).

Starting with Open Inventor 7.0, SoVolumeReader is derived from SoFieldContainer. This allows client classes like SoVolumeData to be automatically notified when the reader's state changes, and update their own state appropriately. Any reader method that changes the volume properties (dimension, size, data type, etc) should trigger notification by calling the reader's touch() method. If this notification is not done, client node fields, for example SoDataSet::extent, won't be updated correctly. For example, a reader with a method setData(SbVec3i32 size, void* data) that loads a new data set should call touch() at its end. This reader could also be implemented using an SoSFArray3D field instead of the setData method. Modifying this field will automatically trigger notification.

Applications should subclass from SoVolumeReader when creating any type of custom volume reader, including an LDM (tiled) volume reader. The classes SoLDMReader and SoVRLdmFileReader are internal classes which are specific to the VSG defined LDM file format.

This class cannot be instantiated directly.

Supported file formats:

    File extension Reader class Description
    .am SoVRAmFileReader Avizo Mesh file format
    .dc3, .dic, .dicom SoVRDicomFileReader DICOM file format
    .fld SoVRAvsFileReader AVS field file format
    .lda or .ldm SoVRLdmFileReader LDM file format
    .mrc SoVRMrcFileReader MRC file format
    .sgy or .segy SoVRSegyFileReader SEG Y rev 1 file format
    .vol SoVRVolFileReader Vol file format
    .vox SoVRVoxFileReader Vox file format
    .lst SoVRRasterStackReader Lst file format (stack of images)

    File format notes:

    • Avizo mesh
      Avizo mesh is a general purpose file format that can contain many different kinds of data. The VolumeViz file reader can load Avizo mesh files containing a 3-dimensional "Lattice" data object with uniform coordinates and any data type. See SoVRAmFileReader for limitations.
    • AVS field
      AVS field is a general purpose file format that can contain many different kinds of data. The VolumeViz file reader can load AVS field files containing 3-dimensional, uniform data of type "byte". See SoVRAvsFileReader.
    • DICOM
      A widely used format for storing medical image data (CT, MRI, etc), defined by the National Electrical Manufacturers Association (NEMA) (medical.nema.org). See SoVRDicomFileReader
    • LDM
      LDM is a format defined by VSG for storing hierarchical multi-resolution volume data. VolumeViz includes a utility program that can convert any other format supported by VolumeViz into this format (see SoVolumeConverter). Preprocessing volume data into this format provides the maximum benefits from the VolumeViz large data management (LDM) features. See SoVRLdmFileReader.
    • MRC
      MRC is a file format that has become an industry standard for cryo-electron microscopy (cryoEM) and electron tomography (ET) (http://www.ccpem.ac.uk/mrc_format/mrc2014.php). See SoVRMrcFileReader.
    • SEGY
      A widely used format for storing seismic trace data, defined by the Society of Exploration Geophysicists publication "Digital Tape Standards" (www.seg.org). The VolumeViz reader supports all sizes of integer and float data, and can correctly determine the number of samples per trace in many cases. However the reader also has many options to adapt to differences in SEGY file headers. See SoVRSegyFileReader.
    • VOL
      A simple volume interchange format (see "Introduction to Volume Rendering", Lichtenbelt, Crane, Naqvi, 1998). The VolumeViz reader can load files containing 8- or 16-bit voxels. See SoVRVolFileReader.
    • VOX
      A volume interchange format defined by TeraRecon Inc. (www.terarecon.com). The VolumeViz reader can load "Vox1999a" files containing 8- or 16-bit voxels (first volume only). See SOVRVoxFileReader.
    • LST (stack of images)
      A simple format for loading a stack of images (one image per file). Specify the names of the image files in a .lst file. VolumeViz can load image data in most common image formats including BMP, DDS, GIF, JPEG, JPEG2000, PNG and TIFF. See SoVRRasterStackReader for details and limitations.

    Note: '3D TIFF' files (multiple images in one file) are not currently supported.

SEE ALSO

SoDataSet, SoVolumeData, SoConverter

Definition at line 252 of file SoVolumeReader.h.

Member Enumeration Documentation

◆ Axis

Which axis to handle.

See also
getRectilinearCoordinates
Enumerator

Definition at line 293 of file SoVolumeReader.h.

◆ CoordinateType

Coordinate type used by this data set.

Enumerator
COORDINATES_UNIFORM 

Uniform grid spacing along each axis.

COORDINATES_RECTILINEAR 

Grid spacing defined by x, y, z values.

Definition at line 766 of file SoVolumeReader.h.

◆ ReadError

Read error.

Enumerator
RD_NO_ERROR 

No error.

RD_FILE_NOT_FOUND_ERROR 

The data file is not found.

RD_INVALID_DATA_ERROR 

Invalid data.

RD_UNSUPPORTED_DATA_TYPE_ERROR 

Unsupported data type (but the data is valid).

RD_FILE_FORMAT_NOT_VALID_ERROR 

Some error were detected in the file making it impossible to read.

RD_UNKNOWN_ERROR 

Unknown error.

Definition at line 261 of file SoVolumeReader.h.

◆ ReaderType

Available reader type.

Enumerator
NO_READER 

Unknown.

AM 

Amira .am.

AVS 

AVS.

DICOM 

Dicom.

GENERIC 

Generic.

LDM 

Open Inventor LDM.

MEMORY 

In memory.

RASTERSTACK 

Raster Stack.

SEGY 

Segy.

VOL 

Vol.

VOX 

Vox.

TIFF 

Tiff.

MRC 

Mrc.

Definition at line 662 of file SoVolumeReader.h.

Constructor & Destructor Documentation

◆ SoVolumeReader()

SoVolumeReader::SoVolumeReader ( )

Constructor.

◆ ~SoVolumeReader()

virtual SoVolumeReader::~SoVolumeReader ( )
protectedvirtual

Destructor.

Member Function Documentation

◆ adjustFlatExtent()

static SbBox3f SoVolumeReader::adjustFlatExtent ( const SbString fileName,
const SbBox3f extent,
const SbVec3i32 dim 
)
staticprotected

VolumeViz doesn't handles empty extent (for ex.

flat extent). But this case may happen some time. For ex. Avizo generally specify a flat extent for single slice volume. In that case, we try to compute a thickness based on other dimension voxel size. This method will return an extent that correspond to given input extent, but with a non null thickness which is equal to smallest non null voxel size.

◆ bytesToInt()

static int SoVolumeReader::bytesToInt ( const unsigned char *  ptr,
int  sizeBytes 
)
staticprotected

Utility method that returns an integer from sizeBytes bytes starting at address ptr.

Also takes into account the machine architecture (little/big endian).

◆ closeAllHandles()

virtual void SoVolumeReader::closeAllHandles ( )
inlinevirtual

Close all resources that are locked by the reader.

Allows other classes to use the same resources. For example, if the reader reads from a file, this method closes the file so that an SoVolumeWriter associated with the same file can re-open it in write mode. The reader remembers the resources that were closed, so they can re-opened by calling restoreAllHandles().

Reimplemented in SoVRDicomFileReader.

Definition at line 818 of file SoVolumeReader.h.

◆ fileSize()

int64_t SoVolumeReader::fileSize ( )
protected

Returns the size of the file when file I/O is handled by this class.

◆ getAppropriateReader()

static SoVolumeReader * SoVolumeReader::getAppropriateReader ( const SbString filename)
static

Returns a preconfigured SoVolumeReader instance that can be used to load the given file (based on the filename extension).

For example, would return an instance of SoVRDicomFileReader for a file named "data.dic".

If no SoVolumeReader is associated to this extension through registerVolumeReaderExtension() then NULL is returned.

Since Open Inventor 9.4

◆ getBorderFlag()

virtual SoDEPRECATED int SoVolumeReader::getBorderFlag ( )
inlinevirtual

Returns border (overlap) value if stored in file.

Reimplemented in SoLDMReader, and SoVRLdmFileBorderReader.

Definition at line 889 of file SoVolumeReader.h.

◆ getBuffer()

void * SoVolumeReader::getBuffer ( int64_t  offset,
unsigned int  size 
)
protected

Returns a pointer to a buffer of size bytes corresponding to a part of the file at offset bytes from the beginning of the file.

Then you can directly read the memory pointed to by the returned pointer. This method uses the memory paging system mechanism and thus is quite efficient.

◆ getClassTypeId()

static SoType SoVolumeReader::getClassTypeId ( )
static

Returns the type identifier for this class.


◆ getConfiguredWriter()

virtual SoVolumeWriter * SoVolumeReader::getConfiguredWriter ( )
virtual

Returns a volume writer that corresponds to this reader
(same format, parameters, etc).

If no writer can be created, NULL is returned.

Notes:

  • The simplest way to implement this behavior is to return a new writer every time.
  • The returned writer is not synchronized with this reader nor with other writers.
  • The returned writer must be manually refed/unrefed.

For example:

MyVolumeReader* reader = new MyVolumeReader();
reader->setFilename( "someFile.dat" );
MyVolumeWriter* writer1 = (MyVolumeWriter*)reader->getConfiguredWriter();
// This writer will write to "someFile.dat"
reader->setFilename( "someOtherFile.dat" );
// The writer will still write to "someFile.dat"
writer1->setFilename( "stillAnotherFile.dat" );
SoVolumeWriter* writer2 = reader->getConfiguredWriter();
// writer2 will write to "someOtherFile.dat", because the
// reader is configured to read from "someOtherFile.dat"
<a href="IconLegend.html"><img src="extLDM.gif" alt="Large Data Management" border="0"></a> Abstract...

Reimplemented in SoLDMReader, and SoVRMemoryReader.

◆ getCoordinateType()

CoordinateType SoVolumeReader::getCoordinateType ( )

Returns coordinate type used by the data set.

◆ getDataChar()

virtual ReadError SoVolumeReader::getDataChar ( SbBox3f size,
SoDataSet::DataType type,
SbVec3i32 dim 
)
pure virtual

Gets the characteristics (file header) of the data volume.

See SoDataSet::setVolumeData().
You can use the convenience method setFilename() to specify the file location, in which case you will not have to open the file yourself. Then you can use the convenience method getBuffer() to read the header in order to get the requested information.

NOTE: We strongly recommend that readers implement this version of getDataChar, introduced in VolumeViz 5.1, because it uses SbVec3i32 for the volume dimension.

Implemented in SoLDMReader, SoVRLdmFileBorderReader, SoVRLdmFileReader, SoVRAmFileReader, SoVRAvsFileReader, SoVRDicomFileReader, SoVRGenericFileReader, SoVRMemoryReader, SoVRMrcFileReader, SoVRRasterStackReader, SoVRSegyFileReader, SoVRTiffFileReader, SoVRVolFileReader, SoVRVoxFileReader, SoVRXtFileReader, and SoLDMReader.

◆ getDirectCoordSys()

SbBool SoVolumeReader::getDirectCoordSys ( )
inlinevirtual

Return whether the coordinate system used is direct or not.

Definition at line 1211 of file SoVolumeReader.h.

◆ getDirectCoordSysAutoDetection()

SbBool SoVolumeReader::getDirectCoordSysAutoDetection ( )
inlinevirtual

Return automatic detection value.

Definition at line 1199 of file SoVolumeReader.h.

◆ getFilename()

SbString SoVolumeReader::getFilename ( ) const

Returns the path of the file.

◆ getHistogram()

SbBool SoVolumeReader::getHistogram ( std::vector< int64_t > &  numVox)
inlinevirtual

Returns histogram if available.

If not, return false.

Reimplemented in SoLDMReader, and SoVRLdmFileReader.

Definition at line 1187 of file SoVolumeReader.h.

◆ getMinMax() [1/3]

SbBool SoVolumeReader::getMinMax ( double &  min,
double &  max 
)
inlinevirtual

Returns min max for float data type, if available.

If not available, return false. The reader should implement this method if possible, because applications often query these values to setup their SoDataRange node. If this method is not implemented, and the application calls SoVolumeData::getMinMax() is called, then VolumeViz must load every tile to compute the volume min and max. This can cause a long delay.

Reimplemented in SoLDMReader, and SoVRLdmFileReader.

Definition at line 1181 of file SoVolumeReader.h.

◆ getMinMax() [2/3]

SbBool SoVolumeReader::getMinMax ( int &  min,
int &  max 
)
inlinevirtual

Returns min max if stored in file.

Reimplemented in SoLDMReader, and SoVRLdmFileReader.

Definition at line 1163 of file SoVolumeReader.h.

◆ getMinMax() [3/3]

SbBool SoVolumeReader::getMinMax ( int64_t &  min,
int64_t &  max 
)
inlinevirtual

Returns min and max for integer data type, if available.

If not available, return false. The reader should implement this method if possible, because applications often query these values to setup their SoDataRange node. If this method is not implemented, and the application calls SoVolumeData::getMinMax() is called, then VolumeViz must load every tile to compute the volume min and max. This can cause a long delay.

Reimplemented in SoLDMReader, and SoVRLdmFileReader.

Definition at line 1169 of file SoVolumeReader.h.

◆ getNumSignificantBits()

virtual int SoVolumeReader::getNumSignificantBits ( )
inlinevirtual

This method is optional.

It returns the number of significant bits of the volume data.

If it is not implemented, the default return value is 0, meaning the number of bits depends on the data type. See the last parameter of SoVolumeData::setVolumeData(). This method is called immediately after getDataChar(). For float data type, number of bits is forced to 32.

Reimplemented in SoVRLdmFileReader, SoVRDicomFileReader, SoVRMemoryReader, and SoVRVoxFileReader.

Definition at line 348 of file SoVolumeReader.h.

◆ getNumVoxels()

SbVec3i32 SoVolumeReader::getNumVoxels ( const SbVec3i32 realSize,
const SbVec3i32 subsamplingLevel 
)

Utility function provided by SoVolumeReader for subclass readers to call.

Returns the size of the brick the reader must use, based on subsamplingLevel and realSize of the brick. If the subsampling level is greater than 0 on an axis, the corresponding size is computed as follows:

  1. realSize is divided by 2** subsamplingLevel
  2. brickSize is the next greater power of 2

For example, if subsamplingLevel[0]=1 and realSize[0]=21, then the returned readerSize[0]=16.

If subsamplingLevel is 0, the corresponding size is the realSize.

◆ getOriginalFilename()

virtual SbString SoVolumeReader::getOriginalFilename ( ) const
inlinevirtual

Returns original file name from which the data has been converted to LDM format if stored in file.

Reimplemented in SoLDMReader.

Definition at line 560 of file SoVolumeReader.h.

◆ getReaderType()

◆ getRectilinearCoordinates()

const float * SoVolumeReader::getRectilinearCoordinates ( Axis  axis) const

Returns the coordinates for the specified axis.

◆ getSizeToAllocate()

SbVec3i32 SoVolumeReader::getSizeToAllocate ( const SbVec3i32 realSize,
const SbVec3i32 subsamplingLevel 
)

Utility function provided by SoVolumeReader for subclass readers to call.

If the reader uses the NO_COPY policy, this method returns the size to allocate for the brick. For each axis of the brick, this size is:

(first power of 2 greater than realSize) / ( 2** subsamplingLevel)

◆ getSubSlice() [1/2]

virtual void SoVolumeReader::getSubSlice ( const SbBox2i32 subSlice,
int  sliceNumber,
SoBufferObject dataBuffer 
)
virtual

Same as getSubSlice( const SbBox2i32& subSlice, int sliceNumber, void * data ) but using an SoBufferObject as the target of the data.

If not reimplemented then the version with "unsigned char*" parameter is called

Parameters
subSlice2D region of the slice to return.
sliceNumberSlice number on the volume Z axis (first slice is 0).
dataBufferThe target buffer to be filled.

Reimplemented in SoLDMReader, SoVRMemoryReader, SoVRTiffFileReader, and SoVRMrcFileReader.

◆ getSubSlice() [2/2]

virtual void SoVolumeReader::getSubSlice ( const SbBox2i32 subSlice,
int  sliceNumber,
void *  data 
)
virtual

Must copy the rectangular part defined by subSlice of the XY slice sliceNumber to the memory referenced by data.

Slices will not always be read sequentially.

Parameters
subSlice2D region of the slice to return.
sliceNumberSlice number on the volume Z axis (first slice is 0).
dataCopy the data into this buffer.

You can use the convenience method getBuffer() to read data from file. Note: setFilename() must have been called previously.

Reimplemented in SoLDMReader, SoLDMReader, SoVRLdmFileReader, SoVRAmFileReader, SoVRAvsFileReader, SoVRDicomFileReader, SoVRGenericFileReader, SoVRMemoryReader, SoVRRasterStackReader, SoVRSegyFileReader, SoVRTiffFileReader, SoVRVolFileReader, SoVRVoxFileReader, SoVRXtFileReader, and SoVRMrcFileReader.

◆ getTileMinMax()

virtual SbVec2d SoVolumeReader::getTileMinMax ( int  index) const
virtual

Returns the minimum and maximum data values for the given tile.

This information benefits optimizations such as SoLDMGlobalResourceParameters::setIgnoreFullyTransparentTiles and custom SoVolumeReader able to return SoCpuBufferUniform.

VolumeViz will only call this method if the data is organized in tiles like the LDM file format. In other words, if isDataConverted() returned true. The LDM Converter program automatically computes this information and stores it in the LDM header file. Custom volume readers that implement tiled data, i.e. return true when isDataConverted is called, should consider implement this method when the min max values are available from their backend API.

NOTES:

  • Automatic computation of tile min/max values works fine for actual volume data. But we strongly recommend implementing this method for height field data (see SoHeightFieldGeometry etc). Because of the way the height field algorithm works, if tile min/max info is not available, VolumeViz must load all height field tiles before the first render. This can cause a long delay before the first rendering appears.
  • When all the voxels in the requested tile (fileId) have the same value, we recommend that the volume reader implement two optimizations. First, the readTile() method should return an SoCpuBufferUniform object (instead of SoCpuBufferObject). This reduces the amount of CPU and GPU memory needed to store the tile, allowing more tiles to be loaded in the same amount of memory. Second, the getTileMinMax() method should return an empty range (min = max) for this tile. This allows VolumeViz to optimize sending tiles to the GPU. However, note that the getTileMinMax() method is called before the readTile() method. So ideally the volume reader should be able to return the tile min/max without actually loading the tile data, for example by using metadata stored with the tiles.

Default implementation returns SbVec2d(numeric_limits<double>::max(),-numeric_limits<double>::max())

Parameters
indexThe fileId of the tile.

Reimplemented in SoLDMReader.

◆ getTileSize()

virtual SbBool SoVolumeReader::getTileSize ( SbVec3i32 size)
virtual

Returns tile dimensions in voxels when using data stored in tiles.


Return FALSE if data is not stored in tiles.

Reimplemented in SoVRLdmFileBorderReader, and SoLDMReader.

◆ getTypeId()

◆ isDataConverted()

virtual SbBool SoVolumeReader::isDataConverted ( ) const
virtual

Returns TRUE if the data is already organized in tiles for the LDM module.


In other words, all drivers that directly support the getTile() method should return TRUE from isDataConverted. If TRUE is returned, VolumeViz will use the readTile method and will NOT call getSubVolume() or getSubSlice().

◆ isIgnoredFile()

SbBool SoVolumeReader::isIgnoredFile ( ) const
inlinevirtual

Should return TRUE if at least one file has been ignored during reading.

Definition at line 1175 of file SoVolumeReader.h.

◆ isRGBA()

virtual SbBool SoVolumeReader::isRGBA ( ) const
inlinevirtual

Returns TRUE if the data set contains RGBA color values.

Reimplemented in SoVRAmFileReader, and SoVRRasterStackReader.

Definition at line 800 of file SoVolumeReader.h.

◆ isThreadSafe()

virtual SbBool SoVolumeReader::isThreadSafe ( ) const
virtual

Should return TRUE if the reader is thread safe.


This function is called by VolumeViz when using the multiIO mode (LDM only). LDM multi-threaded data loading can only be used if this method returns TRUE.

Reimplemented in SoLDMReader, SoVRLdmFileBorderReader, SoVRLdmFileReader, SoVRDicomFileReader, SoVRMemoryReader, SoVRRasterStackReader, SoVRTiffFileReader, and SoVRMrcFileReader.

◆ isValidFloat()

static SbBool SoVolumeReader::isValidFloat ( const float  val)
staticprotected

Utility method to check if value is a valid IEEE 754 floating point number.

◆ readTile() [1/3]

virtual SoBufferObject * SoVolumeReader::readTile ( int  index,
const SbBox3i32 tilePosition 
)
virtual

Given an index, reads a tile if the data is organized in tiles (for LDM).


In the default LDM architecture, the LDM data is based on an octree topology (see SoLDMFileReader). The index passed is 0 for the tile of lowest resolution representing the entire volume (octree root node). The index increments linearly going down through the octree.

A tile can be undefined or empty which means it is not rendered and it isn't taken into account for the rendering of its adjacent cells. An empty buffer or NULL can be returned by this method to specify an undefined tile.

Parameters
indexspecifies a fileID, the id of an existing tile (fileID=tileID in a cubical volume).
tilePositionspecifies the position of the data in the associated volume data of the tile corresponding to the given index. In the default SoVRLdmFileReader, the tilePosition isn't actually used but it is passed as a convenience for customized readers (can be used for mapping to a different index scheme).
Returns
the buffer containing the data of the tile, or NULL (or an empty buffer) in order to specify an undefined tile.

Reimplemented in SoLDMReader, SoLDMReader, and SoVRLdmFileBorderReader.

◆ readTile() [2/3]

virtual SoDEPRECATED SbBool SoVolumeReader::readTile ( int  index,
SoBufferObject buffer,
const SbBox3i32 tilePosition 
)
virtual

Same as readTile(int index, unsigned char*& buffer, const SbBox3i32& tilePosition) but using an SoBufferObject (allocated by LDM) as the target of the data.

If not reimplemented then the version with "unsigned char*" parameter is called

Reimplemented in SoLDMReader.

◆ readTile() [3/3]

virtual SoDEPRECATED SbBool SoVolumeReader::readTile ( int  index,
unsigned char *&  buffer,
const SbBox3i32 tilePosition 
)
inlinevirtual

Given an index, reads a tile if the data is organized in tiles (for LDM).


In the default LDM architecture, the LDM data is based on an octree topology (see SoVRLdmFileReader). The index passed is 0 for the tile of lowest resolution representing the entire volume (octree root node). The index increments linearly going down through the octree.

Indexing works as follows:

Tile 1 is the lower back left corner of the cube. The index increments on X, then Y, and finally Z. So the back tiles are:

3 4
1 2

And the front tiles are:

7 8
5 6

The tiles of full resolution are the leaf tiles.

In the default SoVRLdmFileReader, the tilePosition isn't actually used by the reader but it is passed as a convenience for customized readers (can be used for mapping to a different index scheme).

Reimplemented in SoLDMReader, and SoLDMReader.

Definition at line 871 of file SoVolumeReader.h.

◆ readXSliceInTile()

SbBool SoVolumeReader::readXSliceInTile ( int  index,
unsigned char *&  buffer,
const SbBox3i32 tilePosition,
const uint32_t &  slicePosition 
)
inlinevirtual

Read directly from the data source, an orthoslice on the X axis (Zaxis == 0) inside a tile.

Parameters
indexThe fileId of the tile.
bufferThe buffer in which the data is returned.
tilePositionSpecifies the position of the tile in the associated volume, in voxel coordinates.
In the default SoVRLdmFileReader, the tilePosition isn't actually used by the reader but it is passed as a convenience for customized readers (can be used for mapping to a different index scheme).
slicePositionThe slice position in the tile.

Reimplemented in SoLDMReader.

Definition at line 1151 of file SoVolumeReader.h.

◆ readXTraceInTile()

SbBool SoVolumeReader::readXTraceInTile ( int  index,
unsigned char *&  buffer,
const SbBox3i32 tilePosition,
const SbVec2i32 tracePosition 
)
inlinevirtual

Read directly from the data source, a trace inside a tile.


Parameters
indexthe fileId of an existing tile.
bufferthe buffer in which the data is returned.
tilePositionSpecifies the position of the tile in the associated volume, in voxel coordinates.
In the default SoVRLdmFileReader, the tilePosition isn't actually used by the reader but it is passed as a convenience for customized readers (can be used for mapping to a different index scheme).
tracePositionrepresents the (i,j) coordinates of the trace.

Reimplemented in SoLDMReader.

Definition at line 1145 of file SoVolumeReader.h.

◆ readYSliceInTile()

SbBool SoVolumeReader::readYSliceInTile ( int  index,
unsigned char *&  buffer,
const SbBox3i32 tilePosition,
const uint32_t &  slicePosition 
)
inlinevirtual

Read directly from the data source, an orthoslice on the Y axis (Zaxis == 1) inside a tile.

Parameters
indexThe fileId of the tile.
bufferThe buffer in which the data is returned.
tilePositionSpecifies the position of the tile in the associated volume, in voxel coordinates.
In the default SoVRLdmFileReader, the tilePosition isn't actually used by the reader but it is passed as a convenience for customized readers (can be used for mapping to a different index scheme).
slicePositionThe slice position in the tile.

Reimplemented in SoLDMReader.

Definition at line 1157 of file SoVolumeReader.h.

◆ readZSliceInTile()

virtual SbBool SoVolumeReader::readZSliceInTile ( int  index,
unsigned char *&  buffer,
const SbBox3i32 tilePosition,
const uint32_t &  slicePosition 
)
virtual

Read directly from the data source, an orthoslice on the Z axis (Zaxis == 2) inside a tile.

Parameters
indexThe fileId of the tile.
bufferThe buffer in which the data is returned.
tilePositionSpecifies the position of the tile in the associated volume, in voxel coordinates.
In the default SoVRLdmFileReader, the tilePosition isn't actually used by the reader but it is passed as a convenience for customized readers (can be used for mapping to a different index scheme).
slicePositionThe slice position in the tile.

Reimplemented in SoLDMReader.

◆ registerVolumeReaderExtension()

static bool SoVolumeReader::registerVolumeReaderExtension ( const SbString fileExtension,
const SoType readerType 
)
staticprotected

Register an SoVolumeReader class to handle a file extension.

This method can be called for any class derived from SoVolumeReader in order to allow the getAppropriateReader() method to return an instance of the specified reader for files with the specified extension. VolumeViz automatically associates the built-in volume reader classes with their corresponding file extensions. For example, the extension "dic" is associated with SoVRDicomFileReader. This method can be used to associate a custom volume reader with an application data file extension. When this association exists, the application can simply set the SoVolumeData node's filename field and VolumeViz will create an instance of the associated volume reader to load the data.

This method can be called multiple times with different file extensions. Extension strings are not case sensitive and should not include the '.' character.

This method should normally be called from the volume reader's initClass() method and the unregisterVolumeReaderExtensions() method should be called from the exitClass() method.

If the given filename extension is already associated with another SoVolumeReader class then the call is ignored and false is returned.

Parameters
fileExtensionfile extension to associate with the given readerType (without .)
readerTypereader class type to associate with the given fileExtension
Returns
true on success.

Since Open Inventor 9.4

◆ reloadTileMinMax()

virtual void SoVolumeReader::reloadTileMinMax ( )
inlinevirtual

Definition at line 451 of file SoVolumeReader.h.

◆ restoreAllHandles()

virtual void SoVolumeReader::restoreAllHandles ( )
inlinevirtual

Restore resources that were closed by closeAllHandles().

Reimplemented in SoVRDicomFileReader.

Definition at line 823 of file SoVolumeReader.h.

◆ setDirectCoordSysAutoDetection()

SbBool SoVolumeReader::setDirectCoordSysAutoDetection ( SbBool  autoValue)
inlinevirtual

Sets whether or not the reader should automatically try to detect if the coordinate system used is direct or not.

The function will return FALSE if the feature is not supported by the current reader. Default is false.

Reimplemented in SoVRSegyFileReader.

Definition at line 1193 of file SoVolumeReader.h.

◆ setDirectCoorSys()

SbBool SoVolumeReader::setDirectCoorSys ( SbBool  directCoord)
inlinevirtual

Specify if the coordinate system used is direct or not.

The function will return FALSE if the feature is not supported by the current reader. Default is true.

Reimplemented in SoVRSegyFileReader.

Definition at line 1205 of file SoVolumeReader.h.

◆ setFilename()

virtual int SoVolumeReader::setFilename ( const SbString filename)
virtual

Specifies the path of the file.

Returns 0 for success. Any other return value indicates failure.

Reimplemented in SoVRLdmFileBorderReader, SoVRDicomFileReader, SoVRRasterStackReader, SoVRSegyFileReader, SoVRTiffFileReader, SoVRVoxFileReader, and SoVRMrcFileReader.

◆ setInputDataRange()

virtual SbBool SoVolumeReader::setInputDataRange ( SbBool  doChange,
double  min,
double  max 
)
virtual

Requests that the input be converted from the specified range to the range depending on the output data type.

This allows, for instance, if the output data type is unsigned byte, conversion of float data from range [min,max] to range [0,255]. If doChange is FALSE no range conversion is applied. Always returns TRUE.

Reimplemented in SoVRSegyFileReader.

◆ setOutputDataType()

virtual SbBool SoVolumeReader::setOutputDataType ( SbBool  doChange,
SoDataSet::DataType  outputType 
)
virtual

Sets the output data type.

Returns FALSE if the reader does not support this feature. If the reader does support this feature and doChange is set to TRUE, data is converted before being returned (by getSubSlice() for instance). If doChange is set to FALSE, data is not converted and is returned as is.

Reimplemented in SoVRDicomFileReader, and SoVRSegyFileReader.

◆ setRectilinearCoordinates()

void SoVolumeReader::setRectilinearCoordinates ( const float *  x,
const float *  y,
const float *  z 
)

Sets rectilinear coordinates for the data set.

◆ setRGBA()

void SoVolumeReader::setRGBA ( const SbBool  flag)
inline

Specifies if data must be considered as RGBA.

Definition at line 807 of file SoVolumeReader.h.

◆ swapBytes()

static void SoVolumeReader::swapBytes ( int *  intPtr,
int  sizeBytes 
)
staticprotected

Utility method to convert an integer into the correct architecture (little/big endian).

◆ swapBytesN()

static void SoVolumeReader::swapBytesN ( void *  buffer,
int  numElements,
int  numBytesPerElement 
)
staticprotected

Utility method to swap bytes of each element of an array of numElements elements.

The size of each element is numBytesPerElement.

◆ unregisterVolumeReaderExtensions()

static bool SoVolumeReader::unregisterVolumeReaderExtensions ( const SoType readerType)
staticprotected

Unregister all filename extensions associated with the specified SoVolumeReader class.

This method must be called by any SoVolumeReader derived class that previously called registerVolumeReaderExtension().

This method should normally be called once in the volume reader's exitClass() method. It returns false if no filename extension was registered for the specified class.

Since Open Inventor 9.4

Member Data Documentation

◆ m_dataConverted

SoDEPRECATED SbBool SoVolumeReader::m_dataConverted
protected

Definition at line 1065 of file SoVolumeReader.h.


The documentation for this class was generated from the following file: