OpenVDB  0.104.0
Public Member Functions | Static Public Attributes | Protected Types | Protected Member Functions | Static Protected Member Functions | Friends | List of all members
Archive Class Reference

Grid serializer/unserializer. More...

#include <Archive.h>

Inherited by File, and Stream.

Public Member Functions

 Archive ()
 
virtual ~Archive ()
 
std::string getUniqueTag () const
 Return the UUID that was most recently written (or read, if no UUID has been written yet). More...
 
bool isIdentical (const std::string &uuidStr) const
 Return true if the given UUID matches this archive's UUID. More...
 
uint32_t fileVersion () const
 Return the file format version number of the input stream. More...
 
VersionId libraryVersion () const
 Return the (major, minor) version number of the library that was used to write the input stream. More...
 
std::string version () const
 Return a string of the form "<major>.<minor>/<format>", giving the library and file format version numbers associated with the input stream. More...
 
bool isInstancingEnabled () const
 Return true if trees shared by multiple grids are written out only once, false if they are written out once per grid. More...
 
void setInstancingEnabled (bool b)
 Specify whether trees shared by multiple grids should be written out only once (true) or once per grid (false). More...
 
bool isCompressionEnabled () const
 Return true if the data stream is Zip-compressed. More...
 
void setCompressionEnabled (bool)
 Specify whether the data stream should be Zip-compressed. More...
 
uint32_t compressionFlags () const
 Return a bit mask specifying compression options for the data stream. More...
 
void setCompressionFlags (uint32_t c)
 Specify whether and how the data stream should be compressed. [Mainly for internal use]. More...
 
bool isGridStatsMetadataEnabled () const
 Return true if grid statistics (active voxel count and bounding box, etc.) are computed and written as grid metadata. More...
 
void setGridStatsMetadataEnabled (bool b)
 Specify whether grid statistics (active voxel count and bounding box, etc.) should be computed and written as grid metadata. More...
 

Static Public Attributes

static const int sFormatVersionIndex = std::ios_base::xalloc()
 
static const int sLibraryMajorVersionIndex = std::ios_base::xalloc()
 
static const int sLibraryMinorVersionIndex = std::ios_base::xalloc()
 
static const int sDataCompressionIndex = std::ios_base::xalloc()
 
static const int sWriteGridStatsMetadataIndex = std::ios_base::xalloc()
 
static const int sGridBackgroundIndex = std::ios_base::xalloc()
 
static const int sGridClassIndex = std::ios_base::xalloc()
 
static const uint32_t DEFAULT_COMPRESSION_FLAGS = (COMPRESS_ZIP | COMPRESS_ACTIVE_MASK)
 

Protected Types

typedef std::map< Name,
GridBase::Ptr
NamedGridMap
 

Protected Member Functions

bool inputHasGridOffsets () const
 Return true if the input stream contains grid offsets that allow for random access or partial reading. More...
 
void setInputHasGridOffsets (bool b)
 
void setFormatVersion (std::istream &)
 Tag the given input stream with the input file format version number. More...
 
void setLibraryVersion (std::istream &)
 Tag the given input stream with the version number of the library with which the input stream was created. More...
 
void setDataCompression (std::istream &)
 Tag the given input stream with flags indicating whether the input stream contains compressed data and how it is compressed. More...
 
void setGridCompression (std::ostream &, const GridBase &) const
 Tag an output stream with flags specifying only those compression options that are applicable to the given grid. More...
 
void setWriteGridStatsMetadata (std::ostream &)
 Tag the given output stream with a flag indicating whether to compute and write grid statistics metadata. More...
 
void connectInstance (const GridDescriptor &, const NamedGridMap &) const
 If the grid represented by the given grid descriptor is an instance, connect it with its instance parent. More...
 
void writeGrid (GridDescriptor &, GridBase::ConstPtr, std::ostream &, bool seekable) const
 
void writeGridInstance (GridDescriptor &, GridBase::ConstPtr, std::ostream &, bool seekable) const
 
bool readHeader (std::istream &)
 Read the magic number, version numbers, UUID, etc. from the given input stream. More...
 
void writeHeader (std::ostream &, bool seekable) const
 Write the magic number, version numbers, UUID, etc. to the given output stream. More...
 
void write (std::ostream &, const GridPtrVec &, bool seekable, const MetaMap &=MetaMap()) const
 Write the given grids to an output stream. More...
 
void write (std::ostream &, const GridCPtrVec &, bool seekable, const MetaMap &=MetaMap()) const
 Write the given grids to an output stream. More...
 

Static Protected Member Functions

static void readGridCompression (std::istream &)
 Read in the compression flags for a grid and tag the given input stream with those flags. More...
 
static int readGridCount (std::istream &)
 Read in and return the number of grids on the input stream. More...
 
static void readGrid (GridBase::Ptr, const GridDescriptor &, std::istream &)
 Populate the given grid from the input stream. More...
 

Friends

class ::TestFile
 

Detailed Description

Grid serializer/unserializer.

Member Typedef Documentation

typedef std::map<Name , GridBase::Ptr> NamedGridMap
protected

Constructor & Destructor Documentation

Archive ( )
~Archive ( )
virtual

Member Function Documentation

uint32_t compressionFlags ( ) const
inline

Return a bit mask specifying compression options for the data stream.

void connectInstance ( const GridDescriptor gd,
const NamedGridMap grids 
) const
protected

If the grid represented by the given grid descriptor is an instance, connect it with its instance parent.

uint32_t fileVersion ( ) const
inline

Return the file format version number of the input stream.

std::string getUniqueTag ( ) const

Return the UUID that was most recently written (or read, if no UUID has been written yet).

bool inputHasGridOffsets ( ) const
inlineprotected

Return true if the input stream contains grid offsets that allow for random access or partial reading.

bool isCompressionEnabled ( ) const

Return true if the data stream is Zip-compressed.

bool isGridStatsMetadataEnabled ( ) const
inline

Return true if grid statistics (active voxel count and bounding box, etc.) are computed and written as grid metadata.

bool isIdentical ( const std::string &  uuidStr) const

Return true if the given UUID matches this archive's UUID.

bool isInstancingEnabled ( ) const
inline

Return true if trees shared by multiple grids are written out only once, false if they are written out once per grid.

VersionId libraryVersion ( ) const
inline

Return the (major, minor) version number of the library that was used to write the input stream.

void readGrid ( GridBase::Ptr  grid,
const GridDescriptor gd,
std::istream &  is 
)
staticprotected

Populate the given grid from the input stream.

void readGridCompression ( std::istream &  is)
staticprotected

Read in the compression flags for a grid and tag the given input stream with those flags.

int32_t readGridCount ( std::istream &  is)
staticprotected

Read in and return the number of grids on the input stream.

bool readHeader ( std::istream &  is)
protected

Read the magic number, version numbers, UUID, etc. from the given input stream.

Returns
true if the input UUID differs from the previously-read UUID.
void setCompressionEnabled ( bool  b)

Specify whether the data stream should be Zip-compressed.

Enabling Zip compression makes I/O slower, but saves space. Disable it only if raw I/O speed is a concern.

void setCompressionFlags ( uint32_t  c)
inline

Specify whether and how the data stream should be compressed. [Mainly for internal use].

Parameters
cbitwise OR (e.g., COMPRESS_ZIP | COMPRESS_ACTIVE_MASK) of compression option flags (see Compression.h for the available flags)
Note
Not all combinations of compression options are supported.
void setDataCompression ( std::istream &  is)
protected

Tag the given input stream with flags indicating whether the input stream contains compressed data and how it is compressed.

void setFormatVersion ( std::istream &  is)
protected

Tag the given input stream with the input file format version number.

The tag can be retrieved with getFormatVersion().

See Also
getFormatVersion()
void setGridCompression ( std::ostream &  os,
const GridBase grid 
) const
protected

Tag an output stream with flags specifying only those compression options that are applicable to the given grid.

void setGridStatsMetadataEnabled ( bool  b)
inline

Specify whether grid statistics (active voxel count and bounding box, etc.) should be computed and written as grid metadata.

void setInputHasGridOffsets ( bool  b)
inlineprotected
void setInstancingEnabled ( bool  b)
inline

Specify whether trees shared by multiple grids should be written out only once (true) or once per grid (false).

Note
Instancing is enabled by default.
void setLibraryVersion ( std::istream &  is)
protected

Tag the given input stream with the version number of the library with which the input stream was created.

The tag can be retrieved with getLibraryVersion().

See Also
getLibraryVersion()
void setWriteGridStatsMetadata ( std::ostream &  os)
protected

Tag the given output stream with a flag indicating whether to compute and write grid statistics metadata.

std::string version ( ) const

Return a string of the form "<major>.<minor>/<format>", giving the library and file format version numbers associated with the input stream.

void write ( std::ostream &  os,
const GridPtrVec grids,
bool  seekable,
const MetaMap metadata = MetaMap() 
) const
protected

Write the given grids to an output stream.

void write ( std::ostream &  os,
const GridCPtrVec grids,
bool  seekable,
const MetaMap metadata = MetaMap() 
) const
protected

Write the given grids to an output stream.

void writeGrid ( GridDescriptor gd,
GridBase::ConstPtr  grid,
std::ostream &  os,
bool  seekable 
) const
protected

Write the given grid descriptor and grid to an output stream and update the GridDescriptor offsets.

Parameters
seekableif true, the output stream supports seek operations
void writeGridInstance ( GridDescriptor gd,
GridBase::ConstPtr  grid,
std::ostream &  os,
bool  seekable 
) const
protected

Write the given grid descriptor and grid metadata to an output stream and update the GridDescriptor offsets, but don't write the grid's tree, since it is shared with another grid.

Parameters
seekableif true, the output stream supports seek operations
void writeHeader ( std::ostream &  os,
bool  seekable 
) const
protected

Write the magic number, version numbers, UUID, etc. to the given output stream.

Parameters
seekableif true, the output stream supports seek operations

Friends And Related Function Documentation

friend class ::TestFile
friend

Member Data Documentation

const uint32_t DEFAULT_COMPRESSION_FLAGS = (COMPRESS_ZIP | COMPRESS_ACTIVE_MASK)
static
const int sDataCompressionIndex = std::ios_base::xalloc()
static
const int sFormatVersionIndex = std::ios_base::xalloc()
static

Allocate storage for per-stream file format and library version numbers and other values of use to readers and writers.

const int sGridBackgroundIndex = std::ios_base::xalloc()
static
const int sGridClassIndex = std::ios_base::xalloc()
static
const int sLibraryMajorVersionIndex = std::ios_base::xalloc()
static
const int sLibraryMinorVersionIndex = std::ios_base::xalloc()
static
const int sWriteGridStatsMetadataIndex = std::ios_base::xalloc()
static

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