OpenVDB  11.0.0
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | List of all members
Grid< TreeT > Class Template Reference

Highest level of the data structure. Contains a tree and a world->index transform (that currently only supports uniform scaling and translation). More...

#include <nanovdb/NanoVDB.h>

Inherits GridData.

Public Types

using TreeType = TreeT
 
using RootType = typename TreeT::RootType
 
using RootNodeType = RootType
 
using UpperNodeType = typename RootNodeType::ChildNodeType
 
using LowerNodeType = typename UpperNodeType::ChildNodeType
 
using LeafNodeType = typename RootType::LeafNodeType
 
using DataType = GridData
 
using ValueType = typename TreeT::ValueType
 
using BuildType = typename TreeT::BuildType
 
using CoordType = typename TreeT::CoordType
 
using AccessorType = DefaultReadAccessor< BuildType >
 

Public Member Functions

 Grid (const Grid &)=delete
 Disallow constructions, copy and assignment. More...
 
Gridoperator= (const Grid &)=delete
 
 ~Grid ()=delete
 
Version version () const
 
DataTypedata ()
 
const DataTypedata () const
 
uint64_t gridSize () const
 Return memory usage in bytes for this class only. More...
 
uint32_t gridIndex () const
 Return index of this grid in the buffer. More...
 
uint32_t gridCount () const
 Return total number of grids in the buffer. More...
 
template<typename T = BuildType>
enable_if< BuildTraits< T >::is_index, const uint64_t & >::type valueCount () const
 Return the total number of values indexed by this IndexGrid. More...
 
template<typename T = BuildType>
enable_if< is_same< T, Point >::value, const uint64_t & >::type pointCount () const
 Return the total number of points indexed by this PointGrid. More...
 
const TreeT & tree () const
 Return a const reference to the tree. More...
 
TreeT & tree ()
 Return a non-const reference to the tree. More...
 
AccessorType getAccessor () const
 Return a new instance of a ReadAccessor used to access values in this grid. More...
 
const Vec3dvoxelSize () const
 Return a const reference to the size of a voxel in world units. More...
 
const Mapmap () const
 Return a const reference to the Map for this grid. More...
 
template<typename Vec3T >
Vec3T worldToIndex (const Vec3T &xyz) const
 world to index space transformation More...
 
template<typename Vec3T >
Vec3T indexToWorld (const Vec3T &xyz) const
 index to world space transformation More...
 
template<typename Vec3T >
Vec3T indexToWorldDir (const Vec3T &dir) const
 transformation from index space direction to world space direction More...
 
template<typename Vec3T >
Vec3T worldToIndexDir (const Vec3T &dir) const
 transformation from world space direction to index space direction More...
 
template<typename Vec3T >
Vec3T indexToWorldGrad (const Vec3T &grad) const
 transform the gradient from index space to world space. More...
 
template<typename Vec3T >
Vec3T worldToIndexF (const Vec3T &xyz) const
 world to index space transformation More...
 
template<typename Vec3T >
Vec3T indexToWorldF (const Vec3T &xyz) const
 index to world space transformation More...
 
template<typename Vec3T >
Vec3T indexToWorldDirF (const Vec3T &dir) const
 transformation from index space direction to world space direction More...
 
template<typename Vec3T >
Vec3T worldToIndexDirF (const Vec3T &dir) const
 transformation from world space direction to index space direction More...
 
template<typename Vec3T >
Vec3T indexToWorldGradF (const Vec3T &grad) const
 Transforms the gradient from index space to world space. More...
 
uint64_t activeVoxelCount () const
 Computes a AABB of active values in world space. More...
 
bool isValid () const
 Methods related to the classification of this grid. More...
 
const GridTypegridType () const
 
const GridClassgridClass () const
 
bool isLevelSet () const
 
bool isFogVolume () const
 
bool isStaggered () const
 
bool isPointIndex () const
 
bool isGridIndex () const
 
bool isPointData () const
 
bool isMask () const
 
bool isUnknown () const
 
bool hasMinMax () const
 
bool hasBBox () const
 
bool hasLongGridName () const
 
bool hasAverage () const
 
bool hasStdDeviation () const
 
bool isBreadthFirst () const
 
template<typename NodeT >
bool isSequential () const
 return true if the specified node type is layed out breadth-first in memory and has a fixed size. This allows for sequential access to the nodes. More...
 
template<int LEVEL>
bool isSequential () const
 return true if the specified node level is layed out breadth-first in memory and has a fixed size. This allows for sequential access to the nodes. More...
 
bool isSequential () const
 return true if nodes at all levels can safely be accessed with simple linear offsets More...
 
const char * gridName () const
 Return a c-string with the name of this grid. More...
 
const char * shortGridName () const
 Return a c-string with the name of this grid, truncated to 255 characters. More...
 
uint64_t checksum () const
 Return checksum of the grid buffer. More...
 
uint32_t blindDataCount () const
 Return true if this grid is empty, i.e. contains no values or nodes. More...
 
int findBlindData (const char *name) const
 Return the index of the first blind data with specified name if found, otherwise -1. More...
 
int findBlindDataForSemantic (GridBlindDataSemantic semantic) const
 Return the index of the first blind data with specified semantic if found, otherwise -1. More...
 
const void * blindData (uint32_t n) const
 Returns a const pointer to the blindData at the specified linear offset. More...
 
template<typename BlindDataT >
const BlindDataT * getBlindData (uint32_t n) const
 
template<typename BlindDataT >
BlindDataT * getBlindData (uint32_t n)
 
const GridBlindMetaDatablindMetaData (uint32_t n) const
 
void init (std::initializer_list< GridFlags > list={GridFlags::IsBreadthFirst}, uint64_t gridSize=0u, const Map &map=Map(), GridType gridType=GridType::Unknown, GridClass gridClass=GridClass::Unknown)
 
void setMinMaxOn (bool on=true)
 
void setBBoxOn (bool on=true)
 
void setLongGridNameOn (bool on=true)
 
void setAverageOn (bool on=true)
 
void setStdDeviationOn (bool on=true)
 
bool setGridName (const char *src)
 
template<typename Vec3T >
Vec3T applyMap (const Vec3T &xyz) const
 
template<typename Vec3T >
Vec3T applyInverseMap (const Vec3T &xyz) const
 
template<typename Vec3T >
Vec3T applyJacobian (const Vec3T &xyz) const
 
template<typename Vec3T >
Vec3T applyInverseJacobian (const Vec3T &xyz) const
 
template<typename Vec3T >
Vec3T applyIJT (const Vec3T &xyz) const
 
template<typename Vec3T >
Vec3T applyMapF (const Vec3T &xyz) const
 
template<typename Vec3T >
Vec3T applyInverseMapF (const Vec3T &xyz) const
 
template<typename Vec3T >
Vec3T applyJacobianF (const Vec3T &xyz) const
 
template<typename Vec3T >
Vec3T applyInverseJacobianF (const Vec3T &xyz) const
 
template<typename Vec3T >
Vec3T applyIJTF (const Vec3T &xyz) const
 
uint8_t * treePtr ()
 
const uint8_t * treePtr () const
 
template<uint32_t LEVEL>
const uint8_t * nodePtr () const
 Return a non-const uint8_t pointer to the first node at LEVEL. More...
 
template<uint32_t LEVEL>
uint8_t * nodePtr ()
 Return a non-const uint8_t pointer to the first node at LEVEL. More...
 
const BBox< Vec3d > & worldBBox () const
 return AABB of active values in world space More...
 
const CoordBBoxindexBBox () const
 return AABB of active values in index space More...
 
uint32_t rootTableSize () const
 return the root table has size More...
 
bool isEmpty () const
 test if the grid is empty, e.i the root table has size 0 More...
 
bool isRootConnected () const
 return true if RootData follows TreeData in memory without any extra padding More...
 

Static Public Member Functions

static uint64_t memUsage ()
 Return memory usage in bytes for this class only. More...
 

Public Attributes

uint64_t mMagic
 
uint64_t mChecksum
 
Version mVersion
 
BitFlags< 32 > mFlags
 
uint32_t mGridIndex
 
uint32_t mGridCount
 
uint64_t mGridSize
 
char mGridName [MaxNameSize]
 
Map mMap
 
BBox< Vec3dmWorldBBox
 
Vec3d mVoxelSize
 
GridClass mGridClass
 
GridType mGridType
 
int64_t mBlindMetadataOffset
 
uint32_t mBlindMetadataCount
 
uint32_t mData0
 
uint64_t mData1
 
uint64_t mData2
 

Static Public Attributes

static const int MaxNameSize = 256
 

Detailed Description

template<typename TreeT>
class nanovdb::Grid< TreeT >

Highest level of the data structure. Contains a tree and a world->index transform (that currently only supports uniform scaling and translation).

Note
This the API of this class to interface with client code

Member Typedef Documentation

using BuildType = typename TreeT::BuildType
using CoordType = typename TreeT::CoordType
using DataType = GridData
using LeafNodeType = typename RootType::LeafNodeType
using LowerNodeType = typename UpperNodeType::ChildNodeType
using RootType = typename TreeT::RootType
using TreeType = TreeT
using UpperNodeType = typename RootNodeType::ChildNodeType
using ValueType = typename TreeT::ValueType

Constructor & Destructor Documentation

Grid ( const Grid< TreeT > &  )
delete

Disallow constructions, copy and assignment.

Note
Only a Serializer, defined elsewhere, can instantiate this class
~Grid ( )
delete

Member Function Documentation

uint64_t activeVoxelCount ( ) const
inline

Computes a AABB of active values in world space.

Computes a AABB of active values in index space

Note
This method is returning a floating point bounding box and not a CoordBBox. This makes it more useful for clipping rays. Return the total number of active voxels in this tree.
Vec3T applyIJT ( const Vec3T &  xyz) const
inlineinherited
Vec3T applyIJTF ( const Vec3T &  xyz) const
inlineinherited
Vec3T applyInverseJacobian ( const Vec3T &  xyz) const
inlineinherited
Vec3T applyInverseJacobianF ( const Vec3T &  xyz) const
inlineinherited
Vec3T applyInverseMap ( const Vec3T &  xyz) const
inlineinherited
Vec3T applyInverseMapF ( const Vec3T &  xyz) const
inlineinherited
Vec3T applyJacobian ( const Vec3T &  xyz) const
inlineinherited
Vec3T applyJacobianF ( const Vec3T &  xyz) const
inlineinherited
Vec3T applyMap ( const Vec3T &  xyz) const
inlineinherited
Vec3T applyMapF ( const Vec3T &  xyz) const
inlineinherited
const void* blindData ( uint32_t  n) const
inline

Returns a const pointer to the blindData at the specified linear offset.

Warning
Pointer might be NULL and the linear offset is assumed to be in the valid range
uint32_t blindDataCount ( ) const
inline

Return true if this grid is empty, i.e. contains no values or nodes.

Return the count of blind-data encoded in this grid

const GridBlindMetaData& blindMetaData ( uint32_t  n) const
inline
uint64_t checksum ( ) const
inline

Return checksum of the grid buffer.

DataType* data ( )
inline
const DataType* data ( ) const
inline
int findBlindData ( const char *  name) const

Return the index of the first blind data with specified name if found, otherwise -1.

int findBlindDataForSemantic ( GridBlindDataSemantic  semantic) const

Return the index of the first blind data with specified semantic if found, otherwise -1.

AccessorType getAccessor ( ) const
inline

Return a new instance of a ReadAccessor used to access values in this grid.

const BlindDataT* getBlindData ( uint32_t  n) const
inline
BlindDataT* getBlindData ( uint32_t  n)
inline
const GridClass& gridClass ( ) const
inline
uint32_t gridCount ( ) const
inline

Return total number of grids in the buffer.

uint32_t gridIndex ( ) const
inline

Return index of this grid in the buffer.

const char* gridName ( ) const
inline

Return a c-string with the name of this grid.

uint64_t gridSize ( ) const
inline

Return memory usage in bytes for this class only.

Return the memory footprint of the entire grid, i.e. including all nodes and blind data

const GridType& gridType ( ) const
inline
bool hasAverage ( ) const
inline
bool hasBBox ( ) const
inline
bool hasLongGridName ( ) const
inline
bool hasMinMax ( ) const
inline
bool hasStdDeviation ( ) const
inline
const CoordBBox& indexBBox ( ) const
inlineinherited

return AABB of active values in index space

Vec3T indexToWorld ( const Vec3T &  xyz) const
inline

index to world space transformation

Vec3T indexToWorldDir ( const Vec3T &  dir) const
inline

transformation from index space direction to world space direction

Warning
assumes dir to be normalized
Vec3T indexToWorldDirF ( const Vec3T &  dir) const
inline

transformation from index space direction to world space direction

Warning
assumes dir to be normalized
Vec3T indexToWorldF ( const Vec3T &  xyz) const
inline

index to world space transformation

Vec3T indexToWorldGrad ( const Vec3T &  grad) const
inline

transform the gradient from index space to world space.

Applies the inverse jacobian transform map.

Vec3T indexToWorldGradF ( const Vec3T &  grad) const
inline

Transforms the gradient from index space to world space.

Applies the inverse jacobian transform map.

void init ( std::initializer_list< GridFlags list = {GridFlags::IsBreadthFirst},
uint64_t  gridSize = 0u,
const Map map = Map(),
GridType  gridType = GridType::Unknown,
GridClass  gridClass = GridClass::Unknown 
)
inlineinherited
bool isBreadthFirst ( ) const
inline
bool isEmpty ( ) const
inlineinherited

test if the grid is empty, e.i the root table has size 0

Returns
true if this grid contains not data whatsoever
bool isFogVolume ( ) const
inline
bool isGridIndex ( ) const
inline
bool isLevelSet ( ) const
inline
bool isMask ( ) const
inline
bool isPointData ( ) const
inline
bool isPointIndex ( ) const
inline
bool isRootConnected ( ) const
inlineinherited

return true if RootData follows TreeData in memory without any extra padding

TreeData is always following right after GridData, but the same might not be true for RootData

bool isSequential ( ) const
inline

return true if the specified node type is layed out breadth-first in memory and has a fixed size. This allows for sequential access to the nodes.

bool isSequential ( ) const
inline

return true if the specified node level is layed out breadth-first in memory and has a fixed size. This allows for sequential access to the nodes.

bool isSequential ( ) const
inline

return true if nodes at all levels can safely be accessed with simple linear offsets

bool isStaggered ( ) const
inline
bool isUnknown ( ) const
inline
bool isValid ( ) const
inline

Methods related to the classification of this grid.

const Map& map ( ) const
inline

Return a const reference to the Map for this grid.

static uint64_t memUsage ( )
inlinestaticinherited

Return memory usage in bytes for this class only.

const uint8_t* nodePtr ( ) const
inlineinherited

Return a non-const uint8_t pointer to the first node at LEVEL.

Template Parameters
LEVELof the node. LEVEL 0 means leaf node and LEVEL 3 means root node
Warning
If not nodes exist at LEVEL NULL is returned
uint8_t* nodePtr ( )
inlineinherited

Return a non-const uint8_t pointer to the first node at LEVEL.

Template Parameters
LEVELof the node. LEVEL 0 means leaf node and LEVEL 3 means root node
Warning
If not nodes exist at LEVEL NULL is returned
Grid& operator= ( const Grid< TreeT > &  )
delete
enable_if<is_same<T, Point>::value, const uint64_t&>::type pointCount ( ) const
inline

Return the total number of points indexed by this PointGrid.

Note
This method is only defined for PointGrid = NanoGrid<Point>
uint32_t rootTableSize ( ) const
inlineinherited

return the root table has size

void setAverageOn ( bool  on = true)
inlineinherited
void setBBoxOn ( bool  on = true)
inlineinherited
bool setGridName ( const char *  src)
inlineinherited
void setLongGridNameOn ( bool  on = true)
inlineinherited
void setMinMaxOn ( bool  on = true)
inlineinherited
void setStdDeviationOn ( bool  on = true)
inlineinherited
const char* shortGridName ( ) const
inline

Return a c-string with the name of this grid, truncated to 255 characters.

const TreeT& tree ( ) const
inline

Return a const reference to the tree.

TreeT& tree ( )
inline

Return a non-const reference to the tree.

uint8_t* treePtr ( )
inlineinherited
const uint8_t* treePtr ( ) const
inlineinherited
enable_if<BuildTraits<T>::is_index, const uint64_t&>::type valueCount ( ) const
inline

Return the total number of values indexed by this IndexGrid.

Note
This method is only defined for IndexGrid = NanoGrid<ValueIndex || ValueOnIndex || ValueIndexMask || ValueOnIndexMask>
Version version ( ) const
inline
const Vec3d& voxelSize ( ) const
inline

Return a const reference to the size of a voxel in world units.

const BBox<Vec3d>& worldBBox ( ) const
inlineinherited

return AABB of active values in world space

Vec3T worldToIndex ( const Vec3T &  xyz) const
inline

world to index space transformation

Vec3T worldToIndexDir ( const Vec3T &  dir) const
inline

transformation from world space direction to index space direction

Warning
assumes dir to be normalized
Vec3T worldToIndexDirF ( const Vec3T &  dir) const
inline

transformation from world space direction to index space direction

Warning
assumes dir to be normalized
Vec3T worldToIndexF ( const Vec3T &  xyz) const
inline

world to index space transformation

Member Data Documentation

const int MaxNameSize = 256
staticinherited
uint32_t mBlindMetadataCount
inherited
int64_t mBlindMetadataOffset
inherited
uint64_t mChecksum
inherited
uint32_t mData0
inherited
uint64_t mData1
inherited
uint64_t mData2
inherited
BitFlags<32> mFlags
inherited
GridClass mGridClass
inherited
uint32_t mGridCount
inherited
uint32_t mGridIndex
inherited
char mGridName[MaxNameSize]
inherited
uint64_t mGridSize
inherited
GridType mGridType
inherited
uint64_t mMagic
inherited
Map mMap
inherited
Version mVersion
inherited
Vec3d mVoxelSize
inherited
BBox<Vec3d> mWorldBBox
inherited