OpenVDB
11.0.0
|
This class serves to manage a buffer containing one or more NanoVDB Grids. More...
#include <nanovdb/util/GridHandle.h>
Public Types | |
using | BufferType = BufferT |
Public Member Functions | |
template<typename T = BufferT, typename enable_if< BufferTraits< T >::hasDeviceDual, int >::type = 0> | |
GridHandle (T &&buffer) | |
Move constructor from a host buffer. More... | |
template<typename T = BufferT, typename disable_if< BufferTraits< T >::hasDeviceDual, int >::type = 0> | |
GridHandle (T &&buffer) | |
Move constructor from a dual host-device buffer. More... | |
GridHandle ()=default | |
Constructs an empty GridHandle. More... | |
GridHandle (const GridHandle &)=delete | |
Disallow copy-construction. More... | |
GridHandle (GridHandle &&other) noexcept | |
Move copy-constructor. More... | |
void | reset () |
clear this GridHandle to an empty handle More... | |
GridHandle & | operator= (const GridHandle &)=delete |
Disallow copy assignment operation. More... | |
GridHandle & | operator= (GridHandle &&other) noexcept |
Move copy assignment operation. More... | |
template<typename OtherBufferT = HostBuffer> | |
GridHandle< OtherBufferT > | copy (const OtherBufferT &buffer=OtherBufferT()) const |
Performs a deep copy of the GridHandle, possibly templated on a different buffer type. More... | |
BufferT & | buffer () |
Return a reference to the buffer. More... | |
const BufferT & | buffer () const |
Return a const reference to the buffer. More... | |
uint8_t * | data () |
Returns a non-const pointer to the data. More... | |
const uint8_t * | data () const |
Returns a const pointer to the data. More... | |
template<typename U = BufferT> | |
enable_if< BufferTraits< U >::hasDeviceDual, const uint8_t * >::type | deviceData () const |
template<typename U = BufferT> | |
enable_if< BufferTraits< U >::hasDeviceDual, uint8_t * >::type | deviceData () |
uint64_t | size () const |
Returns the size in bytes of the raw memory buffer managed by this GridHandle. More... | |
operator bool () const | |
Return true if this handle contains any grids. More... | |
template<typename ValueT > | |
const NanoGrid< ValueT > * | grid (uint32_t n=0) const |
Returns a const host pointer to the n'th NanoVDB grid encoded in this GridHandle. More... | |
template<typename ValueT > | |
NanoGrid< ValueT > * | grid (uint32_t n=0) |
Returns a host pointer to the n'th NanoVDB grid encoded in this GridHandle. More... | |
template<typename ValueT , typename U = BufferT> | |
enable_if< BufferTraits< U >::hasDeviceDual, const NanoGrid< ValueT > * >::type | deviceGrid (uint32_t n=0) const |
Return a const pointer to the n'th grid encoded in this GridHandle on the device, e.g. GPU. More... | |
template<typename ValueT , typename U = BufferT> | |
enable_if< BufferTraits< U >::hasDeviceDual, NanoGrid< ValueT > * >::type | deviceGrid (uint32_t n=0) |
Return a const pointer to the n'th grid encoded in this GridHandle on the device, e.g. GPU. More... | |
template<typename U = BufferT> | |
enable_if< BufferTraits< U >::hasDeviceDual, void >::type | deviceUpload (void *stream=nullptr, bool sync=true) |
Upload the grid to the device, e.g. from CPU to GPU. More... | |
template<typename U = BufferT> | |
enable_if< BufferTraits< U >::hasDeviceDual, void >::type | deviceDownload (void *stream=nullptr, bool sync=true) |
Download the grid to from the device, e.g. from GPU to CPU. More... | |
bool | isPadded () const |
Check if the buffer is this handle has any padding, i.e. if the buffer is larger than the combined size of all its grids. More... | |
uint32_t | gridCount () const |
Return the total number of grids contained in this buffer. More... | |
uint64_t | gridSize (uint32_t n=0) const |
Return the grid size of the n'th grid in this GridHandle. More... | |
GridType | gridType (uint32_t n=0) const |
Return the GridType of the n'th grid in this GridHandle. More... | |
const GridData * | gridData (uint32_t n=0) const |
Access to the GridData of the n'th grid in the current handle. More... | |
const GridMetaData * | gridMetaData (uint32_t n=0) const |
Returns a const point to the n'th grid meta data. More... | |
void | write (std::ostream &os, uint32_t n) const |
Write a specific grid in this buffer to an output stream. More... | |
void | write (std::ostream &os) const |
Write the entire grid buffer to an output stream. More... | |
void | write (const std::string &fileName) const |
Write this entire grid buffer to a file. More... | |
void | write (const std::string &fileName, uint32_t n) const |
Write a specific grid to file. More... | |
void | read (std::istream &is, const BufferT &pool=BufferT()) |
Read an entire raw grid buffer from an input stream. More... | |
void | read (std::istream &is, uint32_t n, const BufferT &pool=BufferT()) |
Read a specific grid from an input stream containing a raw grid buffer. More... | |
void | read (std::istream &is, const std::string &gridName, const BufferT &pool=BufferT()) |
Read a specific grid from an input stream containing a raw grid buffer. More... | |
void | read (const std::string &fileName, const BufferT &pool=BufferT()) |
Read a raw grid buffer from a file. More... | |
void | read (const std::string &fileName, uint32_t n, const BufferT &pool=BufferT()) |
Read a specific grid from a file containing a raw grid buffer. More... | |
void | read (const std::string &fileName, const std::string &gridName, const BufferT &pool=BufferT()) |
Read a specific grid from a file containing a raw grid buffer. More... | |
bool | empty () const |
Return true if this handle is empty, i.e. has no allocated memory. More... | |
bool | isEmpty () const |
Return true if this handle is empty, i.e. has no allocated memory. More... | |
This class serves to manage a buffer containing one or more NanoVDB Grids.
using BufferType = BufferT |
GridHandle | ( | T && | buffer | ) |
Move constructor from a host buffer.
buffer | buffer containing one or more NanoGrids that will be moved into this GridHandle |
Will | throw and error with the buffer does not contain a valid NanoGrid! |
GridHandle | ( | T && | buffer | ) |
Move constructor from a dual host-device buffer.
buffer | buffer containing one or more NanoGrids that will be moved into this GridHandle |
Will | throw and error with the buffer does not contain a valid NanoGrid! |
|
default |
Constructs an empty GridHandle.
|
delete |
Disallow copy-construction.
|
inlinenoexcept |
Move copy-constructor.
|
inline |
Return a reference to the buffer.
|
inline |
Return a const reference to the buffer.
|
inline |
Performs a deep copy of the GridHandle, possibly templated on a different buffer type.
OtherBufferT | Buffer type of the deep copy |
buffer | optional buffer used for allocation |
|
inline |
Returns a non-const pointer to the data.
|
inline |
Returns a const pointer to the data.
|
inline |
|
inline |
|
inline |
Download the grid to from the device, e.g. from GPU to CPU.
|
inline |
Return a const pointer to the n'th grid encoded in this GridHandle on the device, e.g. GPU.
ValueT | Value type of the grid point to be returned |
n | Index of the (device) grid pointer to be returned |
|
inline |
Return a const pointer to the n'th grid encoded in this GridHandle on the device, e.g. GPU.
ValueT | Value type of the grid point to be returned |
n | Index if of the grid pointer to be returned |
verbose | if non-zero error messages will be printed in case something failed |
|
inline |
Upload the grid to the device, e.g. from CPU to GPU.
|
inline |
Return true if this handle is empty, i.e. has no allocated memory.
|
inline |
Returns a const host pointer to the n'th NanoVDB grid encoded in this GridHandle.
ValueT | Value type of the grid point to be returned |
n | Index of the (host) grid pointer to be returned |
|
inline |
Returns a host pointer to the n'th NanoVDB grid encoded in this GridHandle.
ValueT | Value type of the grid point to be returned |
n | Index of the (host) grid pointer to be returned |
|
inline |
Return the total number of grids contained in this buffer.
|
inline |
|
inline |
Returns a const point to the n'th grid meta data.
n | zero-based ID of the grid |
|
inline |
Return the grid size of the n'th grid in this GridHandle.
n | index of the grid (assumed to be less than gridCount()) |
|
inline |
Return the GridType of the n'th grid in this GridHandle.
n | index of the grid (assumed to be less than gridCount()) |
|
inline |
Return true if this handle is empty, i.e. has no allocated memory.
|
inline |
Check if the buffer is this handle has any padding, i.e. if the buffer is larger than the combined size of all its grids.
|
inline |
Return true if this handle contains any grids.
|
delete |
Disallow copy assignment operation.
|
inlinenoexcept |
Move copy assignment operation.
void read | ( | std::istream & | is, |
const BufferT & | pool = BufferT() |
||
) |
Read an entire raw grid buffer from an input stream.
is | input stream containing a raw grid buffer |
pool | optional pool from which to allocate the new grid buffer |
Will | throw a std::logic_error if the stream does not contain a valid raw grid |
void read | ( | std::istream & | is, |
uint32_t | n, | ||
const BufferT & | pool = BufferT() |
||
) |
Read a specific grid from an input stream containing a raw grid buffer.
is | input stream containing a raw grid buffer |
n | zero-based index of the grid to be read |
pool | optional pool from which to allocate the new grid buffer |
Will | throw a std::logic_error if the stream does not contain a valid raw grid |
void read | ( | std::istream & | is, |
const std::string & | gridName, | ||
const BufferT & | pool = BufferT() |
||
) |
Read a specific grid from an input stream containing a raw grid buffer.
is | input stream containing a raw grid buffer |
gridName | string name of the grid to be read |
pool | optional pool from which to allocate the new grid buffer |
Will | throw a std::logic_error if the stream does not contain a valid raw grid with the speficied name |
|
inline |
Read a raw grid buffer from a file.
filename | string name of the input file containing a raw grid buffer |
pool | optional pool from which to allocate the new grid buffe |
|
inline |
Read a specific grid from a file containing a raw grid buffer.
filename | string name of the input file containing a raw grid buffer |
n | zero-based index of the grid to be read |
pool | optional pool from which to allocate the new grid buffer |
Will | throw a std::ios_base::failure if the file does not exist and a std::logic_error if the files does not contain a valid raw grid |
|
inline |
Read a specific grid from a file containing a raw grid buffer.
filename | string name of the input file containing a raw grid buffer |
gridName | string name of the grid to be read |
pool | optional pool from which to allocate the new grid buffer |
Will | throw a std::ios_base::failure if the file does not exist and a std::logic_error if the files does not contain a valid raw grid withe the specified name |
|
inline |
clear this GridHandle to an empty handle
|
inline |
Returns the size in bytes of the raw memory buffer managed by this GridHandle.
|
inline |
Write a specific grid in this buffer to an output stream.
os | output stream that the buffer will be written to |
n | zero-based index of the grid to be written to stream |
|
inline |
Write the entire grid buffer to an output stream.
os | output stream that the buffer will be written to |
|
inline |
Write this entire grid buffer to a file.
fileName | string name of the output file |
|
inline |
Write a specific grid to file.
fileName | string name of the output file |
n | zero-based index of the grid to be written to file |