OpenVDB 13.0.0

Loading...
Searching...
No Matches
Stream Class Reference

Grid archive associated with arbitrary input and output streams (not necessarily files). More...

`#include <openvdb/io/Stream.h>`

Inheritance diagram for Stream:

## Public Types
using | Ptr = SharedPtr<Archive>
using | ConstPtr = SharedPtr<const Archive>

## Public Member Functions
| Stream (std::istream &, bool delayLoad=true)
| Read grids from an input stream.
| Stream ()
| Construct an archive for stream output.
| Stream (std::ostream &)
| Construct an archive for output to the given stream.
| Stream (const Stream &)
Stream & | operator= (const Stream &)
| ~Stream () override
Archive::Ptr | copy () const override
| Return a copy of this archive.
MetaMap::Ptr | getMetadata () const
| Return the file-level metadata in a newly created MetaMap.
GridPtrVecPtr | getGrids ()
| Return pointers to the grids that were read from the input stream.
void | write (const GridCPtrVec &, const MetaMap &=MetaMap()) const override
| Write the grids in the given container to this archive's output stream.
template<typename GridPtrContainerT>
void | write (const GridPtrContainerT &, const MetaMap &=MetaMap()) const
| Write the grids in the given container to this archive's output stream.
std::string | getUniqueTag () const
| Return the UUID that was most recently written (or read, if no UUID has been written yet).
bool | isIdentical (const std::string &uuidStr) const
| Return `true` if the given UUID matches this archive's UUID.
uint32_t | fileVersion () const
| Return the file format version number of the input stream.
VersionId | libraryVersion () const
| Return the (major, minor) version number of the library that was used to write the input stream.
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.
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.
void | setInstancingEnabled (bool b)
| Specify whether trees shared by multiple grids should be written out only once (`true`) or once per grid (`false`).
uint32_t | compression () const
| Return a bit mask specifying compression options for the data stream.
void | setCompression (uint32_t c)
| Specify whether and how the data stream should be compressed.
bool | isGridStatsMetadataEnabled () const
| Return `true` if grid statistics (active voxel count and bounding box, etc.) are computed and written as grid metadata.
void | setGridStatsMetadataEnabled (bool b)
| Specify whether grid statistics (active voxel count and bounding box, etc.) should be computed and written as grid metadata.

## Static Public Member Functions
static bool | hasBloscCompression ()
| Return `true` if the OpenVDB library includes support for the Blosc compressor.
static bool | hasZLibCompression ()
| Return `true` if the OpenVDB library includes support for the ZLib compressor.
static bool | isDelayedLoadingEnabled ()
| Return `true` if delayed loading is enabled.

## Static Public Attributes
static const uint32_t | DEFAULT_COMPRESSION_FLAGS

## Protected Types
using | NamedGridMap = std::map<Name , GridBase::Ptr>

## Protected Member Functions
void | write (std::ostream &, const GridPtrVec &, bool seekable, const MetaMap &=MetaMap()) const
| Write the given grids to an output stream.
void | write (std::ostream &, const GridCPtrVec &, bool seekable, const MetaMap &=MetaMap()) const
bool | inputHasGridOffsets () const
| Return `true` if the input stream contains grid offsets that allow for random access or partial reading.
void | setInputHasGridOffsets (bool b)
void | setFormatVersion (std::istream &)
| Tag the given input stream with the input file format version number.
void | setLibraryVersion (std::istream &)
| Tag the given input stream with the version number of the library with which the input stream was created.
void | setDataCompression (std::istream &)
| Tag the given input stream with flags indicating whether the input stream contains compressed data and how it is compressed.
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.
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.
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.
void | writeHeader (std::ostream &, bool seekable) const
| Write the magic number, version numbers, UUID, etc. to the given output stream.

## 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.
static int32_t | readGridCount (std::istream &)
| Read in and return the number of grids on the input stream.
static void | readGrid (GridBase::Ptr, const GridDescriptor &, std::istream &)
| Populate the given grid from the input stream.
static void | readGrid (GridBase::Ptr, const GridDescriptor &, std::istream &, const BBoxd &)
| Populate the given grid from the input stream, but only where it intersects the given world-space bounding box.
static void | readGrid (GridBase::Ptr, const GridDescriptor &, std::istream &, const CoordBBox &)
| Populate the given grid from the input stream, but only where it intersects the given index-space bounding box.

## Detailed Description

Grid archive associated with arbitrary input and output streams (not necessarily files).

## Member Typedef Documentation

## ◆ ConstPtr

using ConstPtr = SharedPtr<const Archive>
| inherited

## ◆ NamedGridMap

using NamedGridMap = std::map<Name , GridBase::Ptr>
| protected inherited

## ◆ Ptr

using Ptr = SharedPtr<Archive>
| inherited

## Constructor & Destructor Documentation

## ◆ Stream() [1/4]

Stream | ( | std::istream & | ,
|  | bool | delayLoad = true )
| explicit

Read grids from an input stream.

If delayLoad is true, map the contents of the input stream into memory and enable delayed loading of grids.

Note
  Define the environment variable `OPENVDB_DISABLE_DELAYED_LOAD` to disable delayed loading unconditionally.

## ◆ Stream() [2/4]

Stream | ( |  | ) |

Construct an archive for stream output.

## ◆ Stream() [3/4]

Stream | ( | std::ostream & |  | ) |
| explicit

Construct an archive for output to the given stream.

## ◆ Stream() [4/4]

Stream | ( | const Stream & |  | ) |

## ◆ ~Stream()

~Stream | ( |  | ) |
| override

## Member Function Documentation

## ◆ compression()

uint32_t compression | ( |  | ) | const
| inline inherited

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

## ◆ connectInstance()

void connectInstance | ( | const GridDescriptor & | ,
|  | const NamedGridMap & | ) const
| protected inherited

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

## ◆ copy()

Archive::Ptr copy | ( |  | ) | const
| override virtual

Return a copy of this archive.

Reimplemented from Archive.

## ◆ fileVersion()

uint32_t fileVersion | ( |  | ) | const
| inline inherited

Return the file format version number of the input stream.

## ◆ getGrids()

GridPtrVecPtr getGrids | ( |  | ) |

Return pointers to the grids that were read from the input stream.

## ◆ getMetadata()

MetaMap::Ptr getMetadata | ( |  | ) | const

Return the file-level metadata in a newly created MetaMap.

## ◆ getUniqueTag()

std::string getUniqueTag | ( |  | ) | const
| inherited

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

## ◆ hasBloscCompression()

bool hasBloscCompression | ( |  | ) |
| static inherited

Return `true` if the OpenVDB library includes support for the Blosc compressor.

## ◆ hasZLibCompression()

bool hasZLibCompression | ( |  | ) |
| static inherited

Return `true` if the OpenVDB library includes support for the ZLib compressor.

## ◆ inputHasGridOffsets()

bool inputHasGridOffsets | ( |  | ) | const
| inline protected inherited

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

## ◆ isDelayedLoadingEnabled()

bool isDelayedLoadingEnabled | ( |  | ) |
| static inherited

Return `true` if delayed loading is enabled.

If enabled, delayed loading can be disabled for individual files, but not vice-versa.

Note
  Define the environment variable `OPENVDB_DISABLE_DELAYED_LOAD` to disable delayed loading unconditionally.

## ◆ isGridStatsMetadataEnabled()

bool isGridStatsMetadataEnabled | ( |  | ) | const
| inline inherited

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

## ◆ isIdentical()

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

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

## ◆ isInstancingEnabled()

bool isInstancingEnabled | ( |  | ) | const
| inline inherited

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

## ◆ libraryVersion()

VersionId libraryVersion | ( |  | ) | const
| inline inherited

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

## ◆ operator=()

Stream & operator= | ( | const Stream & |  | ) |

## ◆ readGrid() [1/3]

void readGrid | ( | GridBase::Ptr | ,
|  | const GridDescriptor & | ,
|  | std::istream & | )
| static protected inherited

Populate the given grid from the input stream.

## ◆ readGrid() [2/3]

void readGrid | ( | GridBase::Ptr | ,
|  | const GridDescriptor & | ,
|  | std::istream & | ,
|  | const BBoxd & | )
| static protected inherited

Populate the given grid from the input stream, but only where it intersects the given world-space bounding box.

## ◆ readGrid() [3/3]

void readGrid | ( | GridBase::Ptr | ,
|  | const GridDescriptor & | ,
|  | std::istream & | ,
|  | const CoordBBox & | )
| static protected inherited

Populate the given grid from the input stream, but only where it intersects the given index-space bounding box.

## ◆ readGridCompression()

void readGridCompression | ( | std::istream & |  | ) |
| static protected inherited

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

## ◆ readGridCount()

int32_t readGridCount | ( | std::istream & |  | ) |
| static protected inherited

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

## ◆ readHeader()

bool readHeader | ( | std::istream & |  | ) |
| protected inherited

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.

## ◆ setCompression()

void setCompression | ( | uint32_t | c | ) |
| inline inherited

Specify whether and how the data stream should be compressed.

Parameters

  c | bitwise 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.

## ◆ setDataCompression()

void setDataCompression | ( | std::istream & |  | ) |
| protected inherited

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

## ◆ setFormatVersion()

void setFormatVersion | ( | std::istream & |  | ) |
| protected inherited

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

The tag can be retrieved with getFormatVersion().

See also
  getFormatVersion()

## ◆ setGridCompression()

void setGridCompression | ( | std::ostream & | ,
|  | const GridBase & | ) const
| protected inherited

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

## ◆ setGridStatsMetadataEnabled()

void setGridStatsMetadataEnabled | ( | bool | b | ) |
| inline inherited

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

## ◆ setInputHasGridOffsets()

void setInputHasGridOffsets | ( | bool | b | ) |
| inline protected inherited

## ◆ setInstancingEnabled()

void setInstancingEnabled | ( | bool | b | ) |
| inline inherited

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.

## ◆ setLibraryVersion()

void setLibraryVersion | ( | std::istream & |  | ) |
| protected inherited

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()

## ◆ version()

std::string version | ( |  | ) | const
| inherited

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

## ◆ write() [1/4]

void write | ( | std::ostream & | ,
|  | const GridCPtrVec & | ,
|  | bool | seekable,
|  | const MetaMap & | = MetaMap() ) const
| protected inherited

## ◆ write() [2/4]

void write | ( | std::ostream & | ,
|  | const GridPtrVec & | ,
|  | bool | seekable,
|  | const MetaMap & | = MetaMap() ) const
| protected inherited

Write the given grids to an output stream.

## ◆ write() [3/4]

void write | ( | const GridCPtrVec & | ,
|  | const MetaMap & | = MetaMap() ) const
| override virtual

Write the grids in the given container to this archive's output stream.

Exceptions

  ValueError | if this archive was constructed without specifying an output stream.

Reimplemented from Archive.

## ◆ write() [4/4]

template<typename GridPtrContainerT>

void write | ( | const GridPtrContainerT & | container,
|  | const MetaMap & | metadata = MetaMap() ) const
| inline

Write the grids in the given container to this archive's output stream.

Exceptions

  ValueError | if this archive was constructed without specifying an output stream.

## ◆ writeGrid()

void writeGrid | ( | GridDescriptor & | ,
|  | GridBase::ConstPtr | ,
|  | std::ostream & | ,
|  | bool | seekable ) const
| protected inherited

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

Parameters

  seekable | if true, the output stream supports seek operations

## ◆ writeGridInstance()

void writeGridInstance | ( | GridDescriptor & | ,
|  | GridBase::ConstPtr | ,
|  | std::ostream & | ,
|  | bool | seekable ) const
| protected inherited

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

  seekable | if true, the output stream supports seek operations

## ◆ writeHeader()

void writeHeader | ( | std::ostream & | ,
|  | bool | seekable ) const
| protected inherited

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

Parameters

  seekable | if true, the output stream supports seek operations

## Member Data Documentation

## ◆ DEFAULT_COMPRESSION_FLAGS

const uint32_t DEFAULT_COMPRESSION_FLAGS
| static inherited