Class SoVolumeWriter

All Implemented Interfaces:
SafeDisposable
Direct Known Subclasses:
SoVRLdmFileWriter, SoVRMemoryWriter

public abstract class SoVolumeWriter extends SoFieldContainer
Abstract base class for volume data writer. Base class used to write volume data. Data are generally organised by tiles (like in LDM) or by slices (like in DICOM).

The isDataConverted() method must be reimplemented in derived classes and return true if the data is organized in tiles. In this case, the writeTile() method MUST be implemented and will be used to write data.

If isDataConverted() returns false, the writeSubSlice() method MUST be implemented and will be used to write data.

EXAMPLE

 SoVRLdmFileWriter writer = new SoVRLdmFileWriter();
 // set parameters
 writer.headerFilename.setValue( "myFile.ldm" );
 writer.dimension.setValue( 128, 128, 128 );
 writer.extent.setValue( -1,-1,-1, 1,1,1  );
 
 // Initialize
 writer.initialize();
 
 // Write data
 if ( writer.isDataConverted() ) {
   SoLDMTileID tileID = new SoLDMTileID( 0 );
   SoCpuBufferObject tileBuffer = new SoCpuBufferObject();
   writer.writeTile( tileID, tileBuffer );
 }
 else {
   int sliceIndex = 0;
   SbBox2i32 subSlice = new SbBox2i32( 0,0, 128,128 );
   SoCpuBufferObject sliceBuffer = new SoCpuBufferObject();
   writer.writeSubSlice( sliceIndex, subSlice, sliceBuffer );
 }
 
 // Finalize
 writer.finish();

See Also:
  • Field Details

    • extent

      public final SoSFBox3f extent
      Extent of dataset. Default is (-1, -1, -1, 1, 1, 1)
    • dimension

      public final SoSFVec3i32 dimension
      Dimension of dataset, in voxels. Default is empty.
    • dataType

      public final SoSFEnum<SoDataSet.DataTypes> dataType
      Type of input data (that will be given in the writeXXX method) . Default is UNSIGNED_BYTE.
    • wordFormat

      public final SoSFEnum<SoVolumeWriter.WordFormats> wordFormat
      Endianess of data. . Default is current machine endianess.
  • Method Details

    • initialize

      public boolean initialize()
      Initialize writer. Allocates memory and other resources depending on the kind of writer. By default do nothing.
    • writeTile

      public boolean writeTile(SoLDMTileID tileId, SoBufferObject buffer)
      Given a tileID, writes a tile if the data is organized in tiles (see SoLDMTileID).
      This function must be called only if isDataConverted() return true.

      Must be reimplemented in children classes.

      Please refer to SoLDMTileID and SoLDMTopoOctree for relation between tileId and tile position.

    • finish

      public boolean finish()
      Finish writing the file, free ressources, ... depending on kind of writer.
    • writeSubSlice

      public boolean writeSubSlice(int sliceIndex, SbBox2i32 subSlice, SoBufferObject buffer)
      Writes the data contained in the specified subslice. This function must be called only if isDataConverted() return false.

      Must be reimplemented in children classes.

    • isDataConverted

      public boolean isDataConverted()
      Returns true if the data is already organized in tiles for the LDM module.
      In other words, all writers that directly support the writeTile() method should return true from isDataConverted.

      If true is returned, VolumeViz will use the writeTile method and will not call writeSubVolume() or writeSubSlice().

      Must be reimplemented in children classes.

    • closeAllHandles

      public boolean closeAllHandles()
      Close all ressources that are locked by the writer so that someone else can read or write to them. For example, if the writer write to a file, this method must close the file so that someone else can re-open it in read mode.
    • restoreAllHandles

      public boolean restoreAllHandles()
      Restore ressources that was closed by closeAllHandles.