HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
nanovdb::GridHandle< BufferT > Class Template Reference

This class serves to manage a buffer containing one or more NanoVDB Grids. More...

#include <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...
 
GridHandleoperator= (const GridHandle &)=delete
 Disallow copy assignment operation. More...
 
GridHandleoperator= (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 GridMetaDatagridMetaData (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...
 

Detailed Description

template<typename BufferT = HostBuffer>
class nanovdb::GridHandle< BufferT >

This class serves to manage a buffer containing one or more NanoVDB Grids.

Note
It is important to note that this class does NOT depend on OpenVDB.

Definition at line 37 of file GridHandle.h.

Member Typedef Documentation

template<typename BufferT = HostBuffer>
using nanovdb::GridHandle< BufferT >::BufferType = BufferT

Definition at line 46 of file GridHandle.h.

Constructor & Destructor Documentation

template<typename BufferT >
template<typename T , typename disable_if< BufferTraits< T >::hasDeviceDual, int >::type >
nanovdb::GridHandle< BufferT >::GridHandle ( T &&  buffer)

Move constructor from a host buffer.

Parameters
bufferbuffer containing one or more NanoGrids that will be moved into this GridHandle
Exceptions
Willthrow and error with the buffer does not contain a valid NanoGrid!

Definition at line 322 of file GridHandle.h.

template<typename BufferT = HostBuffer>
template<typename T = BufferT, typename disable_if< BufferTraits< T >::hasDeviceDual, int >::type = 0>
nanovdb::GridHandle< BufferT >::GridHandle ( T &&  buffer)

Move constructor from a dual host-device buffer.

Parameters
bufferbuffer containing one or more NanoGrids that will be moved into this GridHandle
Exceptions
Willthrow and error with the buffer does not contain a valid NanoGrid!
template<typename BufferT = HostBuffer>
nanovdb::GridHandle< BufferT >::GridHandle ( )
default

Constructs an empty GridHandle.

template<typename BufferT = HostBuffer>
nanovdb::GridHandle< BufferT >::GridHandle ( const GridHandle< BufferT > &  )
delete

Disallow copy-construction.

template<typename BufferT = HostBuffer>
nanovdb::GridHandle< BufferT >::GridHandle ( GridHandle< BufferT > &&  other)
inlinenoexcept

Move copy-constructor.

Definition at line 67 of file GridHandle.h.

Member Function Documentation

template<typename BufferT = HostBuffer>
BufferT& nanovdb::GridHandle< BufferT >::buffer ( )
inline

Return a reference to the buffer.

Definition at line 96 of file GridHandle.h.

template<typename BufferT = HostBuffer>
const BufferT& nanovdb::GridHandle< BufferT >::buffer ( ) const
inline

Return a const reference to the buffer.

Definition at line 99 of file GridHandle.h.

template<typename BufferT >
template<typename OtherBufferT >
GridHandle< OtherBufferT > nanovdb::GridHandle< BufferT >::copy ( const OtherBufferT &  buffer = OtherBufferT()) const
inline

Performs a deep copy of the GridHandle, possibly templated on a different buffer type.

Template Parameters
OtherBufferTBuffer type of the deep copy
Parameters
bufferoptional buffer used for allocation
Returns
A new handle of the specified buffer type that contains a deep copy of the current handle

Definition at line 335 of file GridHandle.h.

template<typename BufferT = HostBuffer>
uint8_t* nanovdb::GridHandle< BufferT >::data ( )
inline

Returns a non-const pointer to the data.

Warning
Note that the return pointer can be NULL if the GridHandle was not initialized

Definition at line 103 of file GridHandle.h.

template<typename BufferT = HostBuffer>
const uint8_t* nanovdb::GridHandle< BufferT >::data ( ) const
inline

Returns a const pointer to the data.

Warning
Note that the return pointer can be NULL if the GridHandle was not initialized

Definition at line 107 of file GridHandle.h.

template<typename BufferT = HostBuffer>
template<typename U = BufferT>
enable_if<BufferTraits<U>::hasDeviceDual, const uint8_t*>::type nanovdb::GridHandle< BufferT >::deviceData ( ) const
inline

Definition at line 111 of file GridHandle.h.

template<typename BufferT = HostBuffer>
template<typename U = BufferT>
enable_if<BufferTraits<U>::hasDeviceDual, uint8_t*>::type nanovdb::GridHandle< BufferT >::deviceData ( )
inline

Definition at line 114 of file GridHandle.h.

template<typename BufferT = HostBuffer>
template<typename U = BufferT>
enable_if<BufferTraits<U>::hasDeviceDual, void>::type nanovdb::GridHandle< BufferT >::deviceDownload ( void stream = nullptr,
bool  sync = true 
)
inline

Download the grid to from the device, e.g. from GPU to CPU.

Note
This method is only available if the buffer supports devices

Definition at line 173 of file GridHandle.h.

template<typename BufferT >
template<typename ValueT , typename U >
enable_if< BufferTraits< U >::hasDeviceDual, const NanoGrid< ValueT > * >::type nanovdb::GridHandle< BufferT >::deviceGrid ( uint32_t  n = 0) const
inline

Return a const pointer to the n'th grid encoded in this GridHandle on the device, e.g. GPU.

Template Parameters
ValueTValue type of the grid point to be returned
Parameters
nIndex of the (device) grid pointer to be returned
Warning
Note that the return pointer can be NULL if the GridHandle has no device grid, n is invalid, or if the template parameter does not match the specified grid.

Definition at line 355 of file GridHandle.h.

template<typename BufferT = HostBuffer>
template<typename ValueT , typename U = BufferT>
enable_if<BufferTraits<U>::hasDeviceDual, NanoGrid<ValueT>*>::type nanovdb::GridHandle< BufferT >::deviceGrid ( uint32_t  n = 0)
inline

Return a const pointer to the n'th grid encoded in this GridHandle on the device, e.g. GPU.

Template Parameters
ValueTValue type of the grid point to be returned
Parameters
nIndex if of the grid pointer to be returned
verboseif non-zero error messages will be printed in case something failed
Warning
Note that the return pointer can be NULL if the GridHandle was not initialized, n is invalid, or if the template parameter does not match the specified grid.

Definition at line 161 of file GridHandle.h.

template<typename BufferT = HostBuffer>
template<typename U = BufferT>
enable_if<BufferTraits<U>::hasDeviceDual, void>::type nanovdb::GridHandle< BufferT >::deviceUpload ( void stream = nullptr,
bool  sync = true 
)
inline

Upload the grid to the device, e.g. from CPU to GPU.

Note
This method is only available if the buffer supports devices

Definition at line 167 of file GridHandle.h.

template<typename BufferT = HostBuffer>
bool nanovdb::GridHandle< BufferT >::empty ( void  ) const
inline

Return true if this handle is empty, i.e. has no allocated memory.

Definition at line 121 of file GridHandle.h.

template<typename BufferT >
template<typename ValueT >
const NanoGrid< ValueT > * nanovdb::GridHandle< BufferT >::grid ( uint32_t  n = 0) const
inline

Returns a const host pointer to the n'th NanoVDB grid encoded in this GridHandle.

Template Parameters
ValueTValue type of the grid point to be returned
Parameters
nIndex of the (host) grid pointer to be returned
Warning
Note that the return pointer can be NULL if the GridHandle no host grid, n is invalid or if the template parameter does not match the specified grid!

Definition at line 345 of file GridHandle.h.

template<typename BufferT = HostBuffer>
template<typename ValueT >
NanoGrid<ValueT>* nanovdb::GridHandle< BufferT >::grid ( uint32_t  n = 0)
inline

Returns a host pointer to the n'th NanoVDB grid encoded in this GridHandle.

Template Parameters
ValueTValue type of the grid point to be returned
Parameters
nIndex of the (host) grid pointer to be returned
Warning
Note that the return pointer can be NULL if the GridHandle no host grid, n is invalid or if the template parameter does not match the specified grid!

Definition at line 142 of file GridHandle.h.

template<typename BufferT = HostBuffer>
uint32_t nanovdb::GridHandle< BufferT >::gridCount ( ) const
inline

Return the total number of grids contained in this buffer.

Definition at line 180 of file GridHandle.h.

template<typename BufferT >
const GridData * nanovdb::GridHandle< BufferT >::gridData ( uint32_t  n = 0) const
inline

Access to the GridData of the n'th grid in the current handle.

Parameters
nzero-based ID of the grid
Returns
Const pointer to the n'th GridData in the current handle

Definition at line 293 of file GridHandle.h.

template<typename BufferT >
const GridMetaData * nanovdb::GridHandle< BufferT >::gridMetaData ( uint32_t  n = 0) const
inline

Returns a const point to the n'th grid meta data.

Parameters
nzero-based ID of the grid
Warning
Note that the return pointer can be NULL if the GridHandle was not initialized

Definition at line 301 of file GridHandle.h.

template<typename BufferT = HostBuffer>
uint64_t nanovdb::GridHandle< BufferT >::gridSize ( uint32_t  n = 0) const
inline

Return the grid size of the n'th grid in this GridHandle.

Parameters
nindex of the grid (assumed to be less than gridCount())
Returns
Return the byte size of the specified grid

Definition at line 185 of file GridHandle.h.

template<typename BufferT = HostBuffer>
GridType nanovdb::GridHandle< BufferT >::gridType ( uint32_t  n = 0) const
inline

Return the GridType of the n'th grid in this GridHandle.

Parameters
nindex of the grid (assumed to be less than gridCount())
Returns
Return the GridType of the specified grid

Definition at line 190 of file GridHandle.h.

template<typename BufferT = HostBuffer>
bool nanovdb::GridHandle< BufferT >::isEmpty ( ) const
inline

Return true if this handle is empty, i.e. has no allocated memory.

Definition at line 122 of file GridHandle.h.

template<typename BufferT = HostBuffer>
bool nanovdb::GridHandle< BufferT >::isPadded ( ) const
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.

Returns
true is the combined size of all grid is smaller than the buffer size

Definition at line 177 of file GridHandle.h.

template<typename BufferT = HostBuffer>
nanovdb::GridHandle< BufferT >::operator bool ( ) const
inline

Return true if this handle contains any grids.

Definition at line 126 of file GridHandle.h.

template<typename BufferT = HostBuffer>
GridHandle& nanovdb::GridHandle< BufferT >::operator= ( const GridHandle< BufferT > &  )
delete

Disallow copy assignment operation.

template<typename BufferT = HostBuffer>
GridHandle& nanovdb::GridHandle< BufferT >::operator= ( GridHandle< BufferT > &&  other)
inlinenoexcept

Move copy assignment operation.

Definition at line 82 of file GridHandle.h.

template<typename BufferT >
void nanovdb::GridHandle< BufferT >::read ( std::istream &  is,
const BufferT &  pool = BufferT() 
)

Read an entire raw grid buffer from an input stream.

Parameters
isinput stream containing a raw grid buffer
pooloptional pool from which to allocate the new grid buffer
Exceptions
Willthrow a std::logic_error if the stream does not contain a valid raw grid

Definition at line 363 of file GridHandle.h.

template<typename BufferT >
void nanovdb::GridHandle< BufferT >::read ( std::istream &  is,
uint32_t  n,
const BufferT &  pool = BufferT() 
)

Read a specific grid from an input stream containing a raw grid buffer.

Parameters
isinput stream containing a raw grid buffer
nzero-based index of the grid to be read
pooloptional pool from which to allocate the new grid buffer
Exceptions
Willthrow a std::logic_error if the stream does not contain a valid raw grid

Definition at line 385 of file GridHandle.h.

template<typename BufferT >
void nanovdb::GridHandle< BufferT >::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.

Parameters
isinput stream containing a raw grid buffer
gridNamestring name of the grid to be read
pooloptional pool from which to allocate the new grid buffer
Exceptions
Willthrow a std::logic_error if the stream does not contain a valid raw grid with the speficied name

Definition at line 407 of file GridHandle.h.

template<typename BufferT = HostBuffer>
void nanovdb::GridHandle< BufferT >::read ( const std::string fileName,
const BufferT &  pool = BufferT() 
)
inline

Read a raw grid buffer from a file.

Parameters
filenamestring name of the input file containing a raw grid buffer
pooloptional pool from which to allocate the new grid buffe

Definition at line 259 of file GridHandle.h.

template<typename BufferT = HostBuffer>
void nanovdb::GridHandle< BufferT >::read ( const std::string fileName,
uint32_t  n,
const BufferT &  pool = BufferT() 
)
inline

Read a specific grid from a file containing a raw grid buffer.

Parameters
filenamestring name of the input file containing a raw grid buffer
nzero-based index of the grid to be read
pooloptional pool from which to allocate the new grid buffer
Exceptions
Willthrow 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

Definition at line 271 of file GridHandle.h.

template<typename BufferT = HostBuffer>
void nanovdb::GridHandle< BufferT >::read ( const std::string fileName,
const std::string gridName,
const BufferT &  pool = BufferT() 
)
inline

Read a specific grid from a file containing a raw grid buffer.

Parameters
filenamestring name of the input file containing a raw grid buffer
gridNamestring name of the grid to be read
pooloptional pool from which to allocate the new grid buffer
Exceptions
Willthrow 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

Definition at line 283 of file GridHandle.h.

template<typename BufferT = HostBuffer>
void nanovdb::GridHandle< BufferT >::reset ( )
inline

clear this GridHandle to an empty handle

Definition at line 73 of file GridHandle.h.

template<typename BufferT = HostBuffer>
uint64_t nanovdb::GridHandle< BufferT >::size ( void  ) const
inline

Returns the size in bytes of the raw memory buffer managed by this GridHandle.

Definition at line 117 of file GridHandle.h.

template<typename BufferT = HostBuffer>
void nanovdb::GridHandle< BufferT >::write ( std::ostream &  os,
uint32_t  n 
) const
inline

Write a specific grid in this buffer to an output stream.

Parameters
osoutput stream that the buffer will be written to
nzero-based index of the grid to be written to stream

Definition at line 205 of file GridHandle.h.

template<typename BufferT = HostBuffer>
void nanovdb::GridHandle< BufferT >::write ( std::ostream &  os) const
inline

Write the entire grid buffer to an output stream.

Parameters
osoutput stream that the buffer will be written to

Definition at line 215 of file GridHandle.h.

template<typename BufferT = HostBuffer>
void nanovdb::GridHandle< BufferT >::write ( const std::string fileName) const
inline

Write this entire grid buffer to a file.

Parameters
fileNamestring name of the output file

Definition at line 221 of file GridHandle.h.

template<typename BufferT = HostBuffer>
void nanovdb::GridHandle< BufferT >::write ( const std::string fileName,
uint32_t  n 
) const
inline

Write a specific grid to file.

Parameters
fileNamestring name of the output file
nzero-based index of the grid to be written to file

Definition at line 230 of file GridHandle.h.


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