Write data to disk in LDM format. More...
#include <LDM/writers/SoVRLdmFileWriter.h>
Creates an LDM file (in the VSG .ldm format) and allows the application to store data blocks in any order. The most common usage is to store blocks of full resolution data. This class can automatically generate the lower resolution (subsampled) tiles after the full resolution data has been stored (when the finish() method is called and doMultiResolution is set to TRUE). However the writeTile() method also allows the application to directly store lower resolution tiles in case a proprietary subsampling algorithm is being used. The result will normally be a .ldm file (LDM header) and a .dat file (data).
It is not necessary, in all cases, to create the lower resolution tiles or even to create the complete set of full resolution tiles. This class supports partial writing feature. If some tiles are missing when the finish method is called, then in addition to the header and data files there will also be a .fcp file with the same name as the header and data files. The LDM header file will contain a reference to this file in the CompletionFilename tag. The .fcp file stores information about which tiles actually exist. Tiles that do not exist are considered to be filled with a constant default value (see defaultValue). This feature allows us, for example, to compute and visualize a subset of the volume before committing to computation on the whole volume. However note that the writer currently pre-allocates disk space for the ".dat" file assuming that all tiles will exist. So skipping creation of the subsampled tiles or writing only a subset of the tiles can reduce computation time and disk I/O time, but it does not reduce the disk space requirement for the volume.
The first step is to create an SoVRLdmFileWriter object and initialize it with the desired characteristics for the output volume. The initialize methods initialize the writer using its current parameters. It must not be modified once initialized.
The next step is to write data into the LDM file using the writeTile methods.
The final step is to call the finish method. This will optionally generate the lower resolution tiles (see doMultiResolution), cleanup and close the LDM file.
SoVRLdmFileWriter* writer = new SoVRLdmFileWriter(); // set parameters writer->headerFilename = "myFile.ldm"; writer->dimension.setValue( 128, 128, 128 ); writer->extent.setValue( -1,-1,-1, 1,1,1 ); // Initialize writer->initialize(); // Write data SoLDMTileID tileID = 0; SoCpuBufferObject* tileBuffer = new SoCpuBufferObject(); writer->writeTile( tileID, tileBuffer ); // Finalize writer->finish();
SoVRLdmFileWriter::SoVRLdmFileWriter | ( | ) |
Constructor.
virtual SbBool SoVRLdmFileWriter::closeAllHandles | ( | ) | [virtual] |
Close all opened files (ldm, data and completion file) so that someone else can access them for reading or writing.
Reimplemented from SoVolumeWriter.
virtual SbBool SoVRLdmFileWriter::finish | ( | ) | [virtual] |
Finalize creation of files.
If doMultiResolution is set to true, all missing sub-resolutions will be computed. This operation can be very long with big dataset.
Reimplemented from SoVolumeWriter.
static SoType SoVRLdmFileWriter::getClassTypeId | ( | ) | [static] |
Returns the type identifier for this class.
Reimplemented from SoVolumeWriter.
virtual SoType SoVRLdmFileWriter::getTypeId | ( | ) | const [virtual] |
Returns the type identifier for this specific instance.
Reimplemented from SoVolumeWriter.
virtual SbBool SoVRLdmFileWriter::initialize | ( | ) | [virtual] |
Initialize writer from current parameters.
Created and allocated data file on disk. This operation can be quite long with big dataset.
Reimplemented from SoVolumeWriter.
virtual SbBool SoVRLdmFileWriter::isDataConverted | ( | ) | const [virtual] |
Return TRUE, as ldm format is organized in tiles.
Implements SoVolumeWriter.
virtual SbBool SoVRLdmFileWriter::restoreAllHandles | ( | ) | [virtual] |
Re-open ldm, data and completion file that was closed by the closeAllHandles() method.
Reimplemented from SoVolumeWriter.
virtual SbBool SoVRLdmFileWriter::writeTile | ( | const SoLDMTileID & | tileId, | |
SoBufferObject * | buffer | |||
) | [virtual] |
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.
Reimplemented from SoVolumeWriter.
Set the bitset threshold value.
For each value (V) of a dataset, if V > threshold the bitset is set to 1 for this bit, or to 0 otherwise. Default is 0. Used only if saveAsBitSet is TRUE.
Set compression level.
The meaning of this parameter depends on the type of compression used (see compressionName): -For gzip, it must be between 0 and 9: 0 gives no compression, 9 gives best compression but slower speed. Default is 3. -For jpeg, it must be between 0 and 100: 0 gives best compression but most loss of data, 100 gives minimum compression and minimum data alteration. Default is 85.
-1 use default value of specified compressor (3 for gzip, 85 for jpeg). Default is -1.
Compression name.
The following compression types are currently supported: "gzip" and "jpeg". Jpeg is a lossy compression format and should not be used if data degradation is unacceptable. You can set the compressionLevel field to adjust compression quality. If empty, no compression will be used. Default is empty.
Rectilinear coordinates along X.
Used only if coordinateType is COORDINATES_RECTILINEAR.
Rectilinear coordinates along Y.
Used only if coordinateType is COORDINATES_RECTILINEAR.
Rectilinear coordinates along Z.
Used only if coordinateType is COORDINATES_RECTILINEAR.
Use enum CoordinateType.
Default is COORDINATES_UNIFORM.
Set CRC32 check on compression.
When compression is enabled using (see compressionName), adds a data integrity check value to all compressed tiles. If the environment variable LDM_COMPRESS_CHECK_CRC32 is set, data values will be checked each time they are read from disk. Default is FALSE.
Data Filename.
By default, take headerFilename and use ".ldm" extension.
Set the default value.
The given value will be stored in the LDM file. Default is 0. If tiles are missing, LDM will use this value to display missing tiles.
Auto compute sub-resolution tiles when finish writing.
Default is true.
Specify if the histogram must be computed or not.
Default is TRUE.
Disabling histogram generation will greatly speedup the writing process, but some VolumeViz rendering features and optimizations won't be available.
Enabling the histogram enables computation of:
Note also that if RGBA mode is set then no histogram is computed.
Specify if tile min/max should be computed even if enableHistogram is false.
Note that when enableHistogram to true, tile min/max is always computed. Default is false.
Header Filename.
Generate only header file.
Default is FALSE.
Range of input datas ((min, max) of data).
If not specified, range has to be computed, which will increase writing time. Default is an invalid range (1, -1)
true if RGBA mode (output will be unsigned int32 RGBA values).
Default is FALSE.
Specifies the algorithm used to build low resolution tiles.
Available options are :
Filename of original file.
Empty by default. Needed if you want to keep an "history" of file.
Save the data as a bitSet (8 values per byte).
You should specified the bitSetThreashold if you use this feature. Default is FALSE.
Tile dimension.
Default is (64, 64, 64).
Set the undefined value.
The given value will be stored in the LDM file. Default is NaN (Not a Number). This is currently used by SoHeightFieldRender (vertices with undefined values are not rendered).
verbose.
Default is TRUE.