HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
IO.h File Reference

Implements I/O for NanoVDB grids. Features optional BLOSC and ZIP file compression, support for multiple grids per file as well as multiple grid types. More...

#include <nanovdb/NanoVDB.h>
#include "GridHandle.h"
#include "GridChecksum.h"
#include <fstream>
#include <iostream>
#include <string>
#include <sstream>
#include <cstring>
#include <memory>
#include <vector>
+ Include dependency graph for IO.h:

Go to the source code of this file.

Classes

struct  nanovdb::io::FileGridMetaData
 This class defines the meta data stored for each grid in a segment. More...
 
struct  nanovdb::io::Segment
 This class defines all the data stored in segment of a file. More...
 

Namespaces

 nanovdb
 
 nanovdb::io
 
 nanovdb::io::Internal
 Internal functions for compressed read/write of a NanoVDB GridHandle into a stream.
 

Typedefs

using nanovdb::io::fileSize_t = uint64_t
 

Functions

template<typename BufferT >
void nanovdb::io::writeGrid (const std::string &fileName, const GridHandle< BufferT > &handle, io::Codec codec=io::Codec::NONE, int verbose=0)
 Write a single grid to file (over-writing existing content of the file) More...
 
template<typename BufferT = HostBuffer, template< typename...> class VecT = std::vector>
void nanovdb::io::writeGrids (const std::string &fileName, const VecT< GridHandle< BufferT >> &handles, Codec codec=Codec::NONE, int verbose=0)
 Write multiple grids to file (over-writing existing content of the file) More...
 
template<typename BufferT = HostBuffer>
GridHandle< BufferT > nanovdb::io::readGrid (const std::string &fileName, int n=0, int verbose=0, const BufferT &buffer=BufferT())
 Read and return one or all grids from a file into a single GridHandle. More...
 
template<typename BufferT = HostBuffer>
GridHandle< BufferT > nanovdb::io::readGrid (const std::string &fileName, const std::string &gridName, int verbose=0, const BufferT &buffer=BufferT())
 Read and return the first grid with a specific name from a file. More...
 
template<typename BufferT = HostBuffer, template< typename...> class VecT = std::vector>
VecT< GridHandle< BufferT > > nanovdb::io::readGrids (const std::string &fileName, int verbose=0, const BufferT &buffer=BufferT())
 Read all the grids in the file and return them as a vector of multiple GridHandles, each containing all grids encoded in the same segment of the file (i.e. they where written together) More...
 
uint64_t nanovdb::io::stringHash (const char *cstr)
 Standard hash function to use on strings; std::hash may vary by platform/implementation and is know to produce frequent collisions. More...
 
uint64_t nanovdb::io::stringHash (const std::string &str)
 Return a uint64_t hash key of a std::string. More...
 
uint64_t nanovdb::io::reverseEndianness (uint64_t val)
 Return a uint64_t with its bytes reversed so we can check for endianness. More...
 
bool nanovdb::io::hasGrid (const std::string &fileName, const std::string &gridName)
 Return true if the file contains a grid with the specified name. More...
 
bool nanovdb::io::hasGrid (std::istream &is, const std::string &gridName)
 Return true if the stream contains a grid with the specified name. More...
 
std::vector< FileGridMetaData > nanovdb::io::readGridMetaData (const std::string &fileName)
 Reads and returns a vector of meta data for all the grids found in the specified file. More...
 
std::vector< FileGridMetaData > nanovdb::io::readGridMetaData (std::istream &is)
 Reads and returns a vector of meta data for all the grids found in the specified stream. More...
 
 nanovdb::io::Version ()}
 
 nanovdb::io::gridName (grid.gridName())
 
template<typename BufferT >
void nanovdb::io::writeGrid (std::ostream &os, const GridHandle< BufferT > &handle, Codec codec)
 
template<typename BufferT = HostBuffer, template< typename...> class VecT = std::vector>
void nanovdb::io::writeGrids (std::ostream &os, const VecT< GridHandle< BufferT >> &handles, Codec codec=Codec::NONE)
 
template<typename BufferT >
GridHandle< BufferT > nanovdb::io::readGrid (std::istream &is, int n, const BufferT &pool)
 
template<typename BufferT >
GridHandle< BufferT > nanovdb::io::readGrid (std::istream &is, const std::string &gridName, const BufferT &pool)
 Read a specific grid from an input stream given the name of the grid. More...
 
template<typename BufferT = HostBuffer, template< typename...> class VecT = std::vector>
VecT< GridHandle< BufferT > > nanovdb::io::readGrids (std::istream &is, const BufferT &pool=BufferT())
 
template<typename T >
std::ostream & nanovdb::operator<< (std::ostream &os, const BBox< Vec3< T >> &b)
 
std::ostream & nanovdb::operator<< (std::ostream &os, const CoordBBox &b)
 
std::ostream & nanovdb::operator<< (std::ostream &os, const Coord &ijk)
 
template<typename T >
std::ostream & nanovdb::operator<< (std::ostream &os, const Vec3< T > &v)
 
template<typename T >
std::ostream & nanovdb::operator<< (std::ostream &os, const Vec4< T > &v)
 

Variables

 nanovdb::io::c
 

Detailed Description

Implements I/O for NanoVDB grids. Features optional BLOSC and ZIP file compression, support for multiple grids per file as well as multiple grid types.

Author
Ken Museth
Date
May 1, 2020
Note
This file does NOT depend on OpenVDB, but optionally on ZIP and BLOSC

NanoVDB files take on of two formats: 1) multiple segments each with multiple grids (segments have easy to access metadata about its grids) 2) starting with verion 32.6.0 nanovdb files also support a raw buffer with one or more grids (just a dump of a raw grid buffer, so no new metadata).

1: Segment: FileHeader, MetaData0, gridName0...MetaDataN, gridNameN, compress Grid0,...compressed GridN 2: Raw: Grid0,...GridN

Definition in file IO.h.