HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
openvdb::OPENVDB_VERSION_NAME::io::File Class Reference

Grid archive associated with a file on disk. More...

#include <File.h>

+ Inheritance diagram for openvdb::OPENVDB_VERSION_NAME::io::File:

Classes

class  NameIterator
 

Public Types

using NameMap = std::multimap< Name, GridDescriptor >
 
using NameMapCIter = NameMap::const_iterator
 
- Public Types inherited from openvdb::OPENVDB_VERSION_NAME::io::Archive
using Ptr = SharedPtr< Archive >
 
using ConstPtr = SharedPtr< const Archive >
 

Public Member Functions

 File (const std::string &filename)
 
 ~File () override
 
 File (const File &other)
 Copy constructor. More...
 
Fileoperator= (const File &other)
 Assignment. More...
 
SharedPtr< Archivecopy () const override
 Return a copy of this archive. More...
 
const std::stringfilename () const
 Return the name of the file with which this archive is associated. More...
 
bool open (bool=false)
 
bool isOpen () const
 Return true if the file has been opened for reading. More...
 
void close ()
 Close the file once we are done reading from it. More...
 
Index64 getSize () const
 Return this file's current size on disk in bytes. More...
 
bool hasGrid (const Name &) const
 Return true if a grid of the given name exists in this file. More...
 
MetaMap::Ptr getMetadata () const
 Return (in a newly created MetaMap) the file-level metadata. More...
 
GridPtrVecPtr getGrids () const
 Read the entire contents of the file and return a list of grid pointers. More...
 
GridPtrVecPtr readAllGridMetadata ()
 Read just the grid metadata and transforms from the file and return a list of pointers to grids that are empty except for their metadata and transforms. More...
 
GridBase::Ptr readGridMetadata (const Name &)
 Read a grid's metadata and transform only. More...
 
GridBase::Ptr readGrid (const Name &)
 Read an entire grid, including all of its data blocks. More...
 
GridBase::Ptr readGrid (const Name &, const BBoxd &)
 Read a grid, including its data blocks, but only where it intersects the given world-space bounding box. More...
 
void write (const GridCPtrVec &, const MetaMap &=MetaMap()) const override
 Write the grids in the given container to the file whose name was given in the constructor. More...
 
template<typename GridPtrContainerT >
void write (const GridPtrContainerT &, const MetaMap &=MetaMap()) const
 Write the grids in the given container to the file whose name was given in the constructor. More...
 
NameIterator beginName () const
 
NameIterator endName () const
 
- Public Member Functions inherited from openvdb::OPENVDB_VERSION_NAME::io::Archive
 Archive ()
 
 Archive (const Archive &)=default
 
Archiveoperator= (const Archive &)=default
 
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...
 
uint32_t compression () const
 Return a bit mask specifying compression options for the data stream. More...
 
void setCompression (uint32_t c)
 Specify whether and how the data stream should be compressed. 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...
 

Friends

class ::TestFile
 
class ::TestStream
 

Additional Inherited Members

- Static Public Member Functions inherited from openvdb::OPENVDB_VERSION_NAME::io::Archive
static bool hasBloscCompression ()
 Return true if the OpenVDB library includes support for the Blosc compressor. More...
 
static bool hasZLibCompression ()
 Return true if the OpenVDB library includes support for the ZLib compressor. More...
 
static bool isDelayedLoadingEnabled ()
 Return true if delayed loading is enabled. More...
 
- Static Public Attributes inherited from openvdb::OPENVDB_VERSION_NAME::io::Archive
static const uint32_t DEFAULT_COMPRESSION_FLAGS
 
- Protected Types inherited from openvdb::OPENVDB_VERSION_NAME::io::Archive
using NamedGridMap = std::map< Name, GridBase::Ptr >
 
- Protected Member Functions inherited from openvdb::OPENVDB_VERSION_NAME::io::Archive
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 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 inherited from openvdb::OPENVDB_VERSION_NAME::io::Archive
static void readGridCompression (std::istream &)
 Read in the compression flags for a grid and tag the given input stream with those flags. More...
 
static int32_t 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...
 
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. More...
 
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. More...
 

Detailed Description

Grid archive associated with a file on disk.

Definition at line 30 of file File.h.

Member Typedef Documentation

Definition at line 33 of file File.h.

Definition at line 34 of file File.h.

Constructor & Destructor Documentation

openvdb::OPENVDB_VERSION_NAME::io::File::File ( const std::string filename)
explicit
openvdb::OPENVDB_VERSION_NAME::io::File::~File ( )
override
openvdb::OPENVDB_VERSION_NAME::io::File::File ( const File other)

Copy constructor.

The copy will be closed and will not reference the same file descriptor as the original.

Member Function Documentation

NameIterator openvdb::OPENVDB_VERSION_NAME::io::File::beginName ( ) const
Returns
a NameIterator to iterate over all grid names in the file.
void openvdb::OPENVDB_VERSION_NAME::io::File::close ( )

Close the file once we are done reading from it.

SharedPtr<Archive> openvdb::OPENVDB_VERSION_NAME::io::File::copy ( ) const
overridevirtual

Return a copy of this archive.

The copy will be closed and will not reference the same file descriptor as the original.

Reimplemented from openvdb::OPENVDB_VERSION_NAME::io::Archive.

NameIterator openvdb::OPENVDB_VERSION_NAME::io::File::endName ( ) const
Returns
the ending iterator for all grid names in the file.
const std::string& openvdb::OPENVDB_VERSION_NAME::io::File::filename ( ) const

Return the name of the file with which this archive is associated.

The file does not necessarily exist on disk yet.

GridPtrVecPtr openvdb::OPENVDB_VERSION_NAME::io::File::getGrids ( ) const

Read the entire contents of the file and return a list of grid pointers.

MetaMap::Ptr openvdb::OPENVDB_VERSION_NAME::io::File::getMetadata ( ) const

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

Index64 openvdb::OPENVDB_VERSION_NAME::io::File::getSize ( ) const

Return this file's current size on disk in bytes.

Exceptions
IoErrorif the file size cannot be determined.
bool openvdb::OPENVDB_VERSION_NAME::io::File::hasGrid ( const Name ) const

Return true if a grid of the given name exists in this file.

bool openvdb::OPENVDB_VERSION_NAME::io::File::isOpen ( ) const

Return true if the file has been opened for reading.

bool openvdb::OPENVDB_VERSION_NAME::io::File::open ( bool  = false)
File& openvdb::OPENVDB_VERSION_NAME::io::File::operator= ( const File other)

Assignment.

After assignment, this File will be closed and will not reference the same file descriptor as the source File.

GridPtrVecPtr openvdb::OPENVDB_VERSION_NAME::io::File::readAllGridMetadata ( )

Read just the grid metadata and transforms from the file and return a list of pointers to grids that are empty except for their metadata and transforms.

Exceptions
IoErrorif this file is not open for reading.
GridBase::Ptr openvdb::OPENVDB_VERSION_NAME::io::File::readGrid ( const Name )

Read an entire grid, including all of its data blocks.

GridBase::Ptr openvdb::OPENVDB_VERSION_NAME::io::File::readGrid ( const Name ,
const BBoxd  
)

Read a grid, including its data blocks, but only where it intersects the given world-space bounding box.

GridBase::Ptr openvdb::OPENVDB_VERSION_NAME::io::File::readGridMetadata ( const Name )

Read a grid's metadata and transform only.

Returns
A pointer to a grid that is empty except for its metadata and transform.
Exceptions
IoErrorif this file is not open for reading.
KeyErrorif no grid with the given name exists in this file.
void openvdb::OPENVDB_VERSION_NAME::io::File::write ( const GridCPtrVec grids,
const MetaMap meta = MetaMap() 
) const
inlineoverridevirtual

Write the grids in the given container to the file whose name was given in the constructor.

Todo:
GridPtrVec readAllGrids(const Name&)

Reimplemented from openvdb::OPENVDB_VERSION_NAME::io::Archive.

Definition at line 223 of file File.h.

template<typename GridPtrContainerT >
void openvdb::OPENVDB_VERSION_NAME::io::File::write ( const GridPtrContainerT &  container,
const MetaMap meta = MetaMap() 
) const
inline

Write the grids in the given container to the file whose name was given in the constructor.

Definition at line 231 of file File.h.

Friends And Related Function Documentation

friend class ::TestFile
friend

Definition at line 211 of file File.h.

friend class ::TestStream
friend

Definition at line 212 of file File.h.


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