Package com.openinventor.ldm.writers
Class SoVolumeWriter
- java.lang.Object
-
- com.openinventor.inventor.Inventor
-
- com.openinventor.inventor.misc.SoBase
-
- com.openinventor.inventor.fields.SoFieldContainer
-
- com.openinventor.ldm.writers.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, thewriteTile()
method MUST be implemented and will be used to write data.If
isDataConverted()
returns false, thewriteSubSlice()
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:
SoVRLdmFileWriter
,SoVRMemoryWriter
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
SoVolumeWriter.WordFormats
Endianess.-
Nested classes/interfaces inherited from class com.openinventor.inventor.Inventor
Inventor.ConstructorCommand
-
-
Field Summary
Fields Modifier and Type Field Description SoSFEnum<SoDataSet.DataTypes>
dataType
Type of input data (that will be given in the writeXXX method) .SoSFVec3i32
dimension
Dimension of dataset, in voxels.SoSFBox3f
extent
Extent of dataset.SoSFEnum<SoVolumeWriter.WordFormats>
wordFormat
Endianess of data.-
Fields inherited from class com.openinventor.inventor.Inventor
VERBOSE_LEVEL, ZeroHandle
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
closeAllHandles()
Close all ressources that are locked by the writer so that someone else can read or write to them.boolean
finish()
Finish writing the file, free ressources, ...boolean
initialize()
Initialize writer.boolean
isDataConverted()
Returns true if the data is already organized in tiles for the LDM module.boolean
restoreAllHandles()
Restore ressources that was closed bycloseAllHandles
.boolean
writeSubSlice(int sliceIndex, SbBox2i32 subSlice, SoBufferObject buffer)
Writes the data contained in the specified subslice.boolean
writeTile(SoLDMTileID tileId, SoBufferObject buffer)
Given a tileID, writes a tile if the data is organized in tiles (seeSoLDMTileID
).-
Methods inherited from class com.openinventor.inventor.fields.SoFieldContainer
copyFieldValues, copyFieldValues, enableNotify, fieldsAreEqual, get, getAllFields, getEventIn, getEventOut, getField, getFieldName, hasDefaultValues, isNotifyEnabled, set, setToDefaults
-
Methods inherited from class com.openinventor.inventor.misc.SoBase
dispose, getName, isDisposable, isSynchronizable, setName, setSynchronizable, touch
-
Methods inherited from class com.openinventor.inventor.Inventor
getNativeResourceHandle
-
-
-
-
Field Detail
-
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 Detail
-
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 (seeSoLDMTileID
).
This function must be called only ifisDataConverted()
return true.Must be reimplemented in children classes.
Please refer to
SoLDMTileID
andSoLDMTopoOctree
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 ifisDataConverted()
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 thewriteTile()
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 bycloseAllHandles
.
-
-