![]() |
OpenVDB 14.0.0
|
This class serves to manage a buffer containing one or more NanoVDB Grids. More...
#include <nanovdb/GridHandle.h>
Public Types | |
| using | BufferType = BufferT |
Public Member Functions | |
| const std::vector< GridHandleMetaData > & | metaData () const |
| The layout of the grids in this handle's buffer: offset, size and grid type of each. Valid input to adopt() over a buffer holding a byte-for-byte copy of the grids. | |
| GridHandle (BufferT &&buffer) | |
| Move constructor from a host or single-space device buffer. | |
| template<typename U> | |
| GridHandle (U &&)=delete | |
| Reject anything other than a BufferT rvalue, e.g. a size or a different buffer type that would otherwise implicitly convert to BufferT. Never instantiated, so it emits no symbol. | |
| GridHandle ()=default | |
| Constructs an empty GridHandle. | |
| GridHandle (const GridHandle &)=delete | |
| Disallow copy-construction. | |
| GridHandle (GridHandle &&other) noexcept | |
| Move copy-constructor. | |
| void | reset () |
| clear this GridHandle to an empty handle | |
| GridHandle & | operator= (const GridHandle &)=delete |
| Disallow copy assignment operation. | |
| GridHandle & | operator= (GridHandle &&other) noexcept |
| Move copy assignment operation. | |
| template<typename OtherBufferT = HostBuffer> | |
| GridHandle< OtherBufferT > | copy (const OtherBufferT &buffer) const |
| Performs a deep copy of the GridHandle, possibly templated on a different buffer type. | |
| template<typename OtherBufferT = HostBuffer> | |
| GridHandle< OtherBufferT > | copy () const |
| Deep copy without a pool argument. The single-space path allocates through the source buffer's resource and never constructs a pool buffer, so it works for buffers that are not default-constructible, e.g. over a ResourceRef. The host path default-constructs the pool argument, so it requires a default-constructible OtherBufferT. | |
| BufferT & | buffer () |
| Return a reference to the buffer. | |
| const BufferT & | buffer () const |
| Return a const reference to the buffer. | |
| template<typename U = BufferT, typename util::disable_if< BufferIsDeviceOnly< U >::value, int >::type = 0> | |
| void * | data () |
| Returns a pointer to the host data; not available for a single-space device buffer, which has no host-readable bytes. | |
| template<typename U = BufferT, typename util::disable_if< BufferIsDeviceOnly< U >::value, int >::type = 0> | |
| const void * | data () const |
| template<typename U = BufferT> | |
| util::enable_if< BufferHasDeviceSingle< U >::value, constvoid * >::type | deviceData () const |
| For a single-space buffer the device data is the buffer itself. | |
| template<typename U = BufferT> | |
| util::enable_if< BufferHasDeviceSingle< U >::value, void * >::type | deviceData () |
| uint64_t | bufferSize () const |
| Returns the size in bytes of the raw memory buffer managed by this GridHandle. | |
| bool | empty () const |
| Return true if this handle is empty, i.e. has no allocated memory. | |
| bool | isEmpty () const |
| operator bool () const | |
| Return true if this handle is not empty, i.e. contains at least one grid. | |
| template<typename ValueT, typename U = BufferT, typename util::disable_if< BufferIsDeviceOnly< U >::value, int >::type = 0> | |
| const NanoGrid< ValueT > * | grid (uint32_t n=0) const |
| Returns a const host pointer to the n'th NanoVDB grid encoded in this GridHandle. | |
| template<typename ValueT, typename U = BufferT, typename util::disable_if< BufferIsDeviceOnly< U >::value, int >::type = 0> | |
| NanoGrid< ValueT > * | grid (uint32_t n=0) |
| Returns a host pointer to the n'th NanoVDB grid encoded in this GridHandle. | |
| template<typename ValueT, typename U = BufferT> | |
| util::enable_if< BufferHasDeviceSingle< U >::value, constNanoGrid< ValueT > * >::type | deviceGrid (uint32_t n=0) const |
| Return a pointer to the n'th grid of a single-space device buffer. | |
| template<typename ValueT, typename U = BufferT> | |
| util::enable_if< BufferHasDeviceSingle< U >::value, NanoGrid< ValueT > * >::type | deviceGrid (uint32_t n=0) |
| 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. | |
| uint32_t | gridCount () const |
| Return the total number of grids contained in this buffer. | |
| uint64_t | gridSize (uint32_t n=0) const |
| Return the grid size of the n'th grid in this GridHandle. | |
| uint64_t | totalGridSize () const |
| compute the total sum of memory footprints of all the grids in this buffer | |
| uint64_t | freeSize () const |
| compute the size of unused storage in this buffer | |
| bool | isFull () const |
| Test if this buffer has any unused storage left, i.e. memory not occupied by grids. | |
| GridType | gridType (uint32_t n=0) const |
| Return the GridType of the n'th grid in this GridHandle. | |
| template<typename U = BufferT, typename util::disable_if< BufferIsDeviceOnly< U >::value, int >::type = 0> | |
| const GridData * | gridData (uint32_t n=0) const |
| Access to the GridData of the n'th grid in the current handle. | |
| template<typename U = BufferT, typename util::disable_if< BufferIsDeviceOnly< U >::value, int >::type = 0> | |
| const GridMetaData * | gridMetaData (uint32_t n=0) const |
| Returns a const point to the n'th grid meta data. | |
| void | write (std::ostream &os, uint32_t n) const |
| Write a specific grid in this buffer to an output stream. | |
| void | write (std::ostream &os) const |
| Write the entire grid buffer to an output stream. | |
| void | write (const std::string &fileName) const |
| Write this entire grid buffer to a file. | |
| void | write (const std::string &fileName, uint32_t n) const |
| Write a specific grid to file. | |
| void | read (std::istream &is, const BufferT &pool=BufferT()) |
| Read an entire raw grid buffer from an input stream. | |
| 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. | |
| 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. | |
| void | read (const std::string &fileName, const BufferT &pool=BufferT()) |
| Read a raw grid buffer from a file. | |
| 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. | |
| 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. | |
Static Public Member Functions | |
| static GridHandle | adopt (BufferT &&buffer, std::vector< GridHandleMetaData > meta) |
| Constructs a handle over buffer from metadata the caller already knows to describe its contents, because the bytes were copied from another handle (see metaData()) or laid out by the caller. No grid header is read, so this wraps device bytes without a parse kernel and works for buffers that are not default-constructible. Only the layout arithmetic is checked: the grids must be contiguous from offset zero, start aligned to NANOVDB_DATA_ALIGNMENT and fit the buffer, and an empty layout is accepted only over an empty buffer. Each grid type is trusted as given, so a wrong type makes grid() reinterpret the grid's values; only GridType::End is rejected. | |
Friends | |
| struct | detail::LayoutCopy |
This class serves to manage a buffer containing one or more NanoVDB Grids.
| using BufferType = BufferT |
|
inline |
Move constructor from a host or single-space 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! |
Reject anything other than a BufferT rvalue, e.g. a size or a different buffer type that would otherwise implicitly convert to BufferT. Never instantiated, so it emits no symbol.
|
default |
Constructs an empty GridHandle.
|
delete |
Disallow copy-construction.
|
inlinenoexcept |
Move copy-constructor.
|
inlinestatic |
Constructs a handle over buffer from metadata the caller already knows to describe its contents, because the bytes were copied from another handle (see metaData()) or laid out by the caller. No grid header is read, so this wraps device bytes without a parse kernel and works for buffers that are not default-constructible. Only the layout arithmetic is checked: the grids must be contiguous from offset zero, start aligned to NANOVDB_DATA_ALIGNMENT and fit the buffer, and an empty layout is accepted only over an empty buffer. Each grid type is trusted as given, so a wrong type makes grid() reinterpret the grid's values; only GridType::End is rejected.
| std::runtime_error | when the layout does not fit buffer |
|
inline |
Return a reference to the buffer.
|
inline |
Return a const reference to the buffer.
|
inline |
Returns the size in bytes of the raw memory buffer managed by this GridHandle.
|
inline |
Deep copy without a pool argument. The single-space path allocates through the source buffer's resource and never constructs a pool buffer, so it works for buffers that are not default-constructible, e.g. over a ResourceRef. The host path default-constructs the pool argument, so it requires a default-constructible OtherBufferT.
|
inline |
Performs a deep copy of the GridHandle, possibly templated on a different buffer type.
| OtherBufferT | Buffer type of the deep copy. A single-space device handle only copies to its own buffer type (device-to-device, ordered on the source's retained stream), so call it as copy<BufferT>() – the default OtherBufferT does not compile. |
| buffer | optional buffer used for allocation; a compile error for single-space handles, which allocate through the source buffer's resource (use the no-argument overload) |
|
inline |
Returns a pointer to the host data; not available for a single-space device buffer, which has no host-readable bytes.
|
inline |
|
inline |
|
inline |
For a single-space buffer the device data is the buffer itself.
|
inline |
|
inline |
Return a pointer to the n'th grid of a single-space device buffer.
|
inline |
Return true if this handle is empty, i.e. has no allocated memory.
|
inline |
compute the size of unused storage in this buffer
|
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 |
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 |
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 |
|
inline |
Test if this buffer has any unused storage left, i.e. memory not occupied by grids.
|
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 |
The layout of the grids in this handle's buffer: offset, size and grid type of each. Valid input to adopt() over a buffer holding a byte-for-byte copy of the grids.
|
inline |
Return true if this handle is not empty, i.e. contains at least one grid.
|
delete |
Disallow copy assignment operation.
|
inlinenoexcept |
Move copy assignment operation.
|
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 buffer |
|
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 |
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 |
| 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, |
| 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 specified name |
| 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 |
|
inline |
clear this GridHandle to an empty handle
|
inline |
compute the total sum of memory footprints of all the grids in this buffer
|
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 |
|
inline |
Write the entire grid buffer to an output stream.
| os | output stream that the buffer will be written to |
|
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 |
|
friend |