OpenVDB  12.0.0
Classes | Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Friends | List of all members
LeafNode< BuildT, CoordT, MaskT, Log2Dim > Class Template Reference

Leaf nodes of the VDB tree. (defaults to 8x8x8 = 512 voxels) More...

#include <nanovdb/NanoVDB.h>

Inherits LeafData< BuildT, CoordT, MaskT, Log2Dim >.

Classes

struct  ChildNodeType
 
class  ValueIterator
 Visits all values in a leaf node, i.e. both active and inactive values. More...
 
class  ValueOffIterator
 Visits all inactive values in a leaf node. More...
 
class  ValueOnIterator
 Visits all active values in a leaf node. More...
 

Public Types

using LeafNodeType = LeafNode< BuildT, CoordT, MaskT, Log2Dim >
 
using DataType = LeafData< BuildT, CoordT, MaskT, Log2Dim >
 
using ValueType = typename DataType::ValueType
 
using FloatType = typename DataType::FloatType
 
using BuildType = typename DataType::BuildType
 
using CoordType = CoordT
 
template<uint32_t LOG2>
using MaskType = MaskT< LOG2 >
 
template<bool ON>
using MaskIterT = typename Mask< Log2Dim >::template Iterator< ON >
 
using ArrayType = BuildT
 

Public Member Functions

__hostdev__ ValueOnIterator beginValueOn () const
 
__hostdev__ ValueOnIterator cbeginValueOn () const
 
__hostdev__ ValueOffIterator beginValueOff () const
 
__hostdev__ ValueOffIterator cbeginValueOff () const
 
__hostdev__ ValueIterator beginValue () const
 
__hostdev__ ValueIterator cbeginValueAll () const
 
__hostdev__ DataTypedata ()
 
__hostdev__ const DataTypedata () const
 
__hostdev__ const MaskType< LOG2DIM > & valueMask () const
 Return a const reference to the bit mask of active voxels in this leaf node. More...
 
__hostdev__ const MaskType< LOG2DIM > & getValueMask () const
 
__hostdev__ ValueType minimum () const
 Return a const reference to the minimum active value encoded in this leaf node. More...
 
__hostdev__ ValueType maximum () const
 Return a const reference to the maximum active value encoded in this leaf node. More...
 
__hostdev__ FloatType average () const
 Return a const reference to the average of all the active values encoded in this leaf node. More...
 
__hostdev__ FloatType variance () const
 Return the variance of all the active values encoded in this leaf node. More...
 
__hostdev__ FloatType stdDeviation () const
 Return a const reference to the standard deviation of all the active values encoded in this leaf node. More...
 
__hostdev__ uint8_t flags () const
 
__hostdev__ CoordT origin () const
 Return the origin in index space of this leaf node. More...
 
__hostdev__ void localToGlobalCoord (Coord &ijk) const
 Converts (in place) a local index coordinate to a global index coordinate. More...
 
__hostdev__ CoordT offsetToGlobalCoord (uint32_t n) const
 
__hostdev__ math::BBox< CoordT > bbox () const
 Return the bounding box in index space of active values in this leaf node. More...
 
__hostdev__ uint64_t memUsage () const
 return memory usage in bytes for the leaf node More...
 
 LeafNode ()=delete
 This class cannot be constructed or deleted. More...
 
 LeafNode (const LeafNode &)=delete
 
LeafNodeoperator= (const LeafNode &)=delete
 
 ~LeafNode ()=delete
 
__hostdev__ ValueType getValue (uint32_t offset) const
 Return the voxel value at the given offset. More...
 
__hostdev__ ValueType getValue (const CoordT &ijk) const
 Return the voxel value at the given coordinate. More...
 
__hostdev__ ValueType getFirstValue () const
 Return the first value in this leaf node. More...
 
__hostdev__ ValueType getLastValue () const
 Return the last value in this leaf node. More...
 
__hostdev__ void setValue (const CoordT &ijk, const ValueType &v)
 Sets the value at the specified location and activate its state. More...
 
__hostdev__ void setValueOnly (uint32_t offset, const ValueType &v)
 Sets the value at the specified location but leaves its state unchanged. More...
 
__hostdev__ void setValueOnly (const CoordT &ijk, const ValueType &v)
 
__hostdev__ bool isActive (const CoordT &ijk) const
 Return true if the voxel value at the given coordinate is active. More...
 
__hostdev__ bool isActive (uint32_t n) const
 
__hostdev__ bool isActive () const
 Return true if any of the voxel value are active in this leaf node. More...
 
__hostdev__ bool hasBBox () const
 
__hostdev__ bool probeValue (const CoordT &ijk, ValueType &v) const
 Return true if the voxel value at the given coordinate is active and updates v with the value. More...
 
__hostdev__ const LeafNodeprobeLeaf (const CoordT &) const
 
__hostdev__ bool updateBBox ()
 Updates the local bounding box of active voxels in this node. Return true if bbox was updated. More...
 
template<typename OpT , typename... ArgsT>
__hostdev__ auto get (const CoordType &ijk, ArgsT &&...args) const
 
template<typename OpT , typename... ArgsT>
__hostdev__ auto get (const uint32_t n, ArgsT &&...args) const
 
template<typename OpT , typename... ArgsT>
__hostdev__ auto set (const CoordType &ijk, ArgsT &&...args)
 
template<typename OpT , typename... ArgsT>
__hostdev__ auto set (const uint32_t n, ArgsT &&...args)
 
__hostdev__ void setValueOnly (uint32_t offset, const ValueType &value)
 
__hostdev__ void setValue (uint32_t offset, const ValueType &value)
 
__hostdev__ void setOn (uint32_t offset)
 
__hostdev__ ValueType getMin () const
 
__hostdev__ ValueType getMax () const
 
__hostdev__ FloatType getAvg () const
 
__hostdev__ FloatType getDev () const
 
__hostdev__ void setMin (const ValueType &v)
 
__hostdev__ void setMax (const ValueType &v)
 
__hostdev__ void setAvg (const FloatType &v)
 
__hostdev__ void setDev (const FloatType &v)
 
__hostdev__ void setOrigin (const T &ijk)
 
__hostdev__ void fill (const ValueType &v)
 

Static Public Member Functions

static __hostdev__ CoordT OffsetToLocalCoord (uint32_t n)
 Compute the local coordinates from a linear offset. More...
 
static __hostdev__ uint32_t dim ()
 Return the dimension, in index space, of this leaf node (typically 8 as for openvdb leaf nodes!) More...
 
static __hostdev__ uint32_t voxelCount ()
 Return the total number of voxels (e.g. values) encoded in this leaf node. More...
 
static __hostdev__ uint32_t padding ()
 
static __hostdev__ uint32_t CoordToOffset (const CoordT &ijk)
 Return the linear offset corresponding to the given coordinate. More...
 
static __hostdev__ uint64_t memUsage ()
 
static __hostdev__ bool hasStats ()
 

Public Attributes

CoordT mBBoxMin
 
uint8_t mBBoxDif [3]
 
uint8_t mFlags
 
MaskT< LOG2DIMmValueMask
 
ValueType mMinimum
 
ValueType mMaximum
 
FloatType mAverage
 
FloatType mStdDevi
 
ValueType mValues [1u<< 3 *LOG2DIM]
 

Static Public Attributes

static constexpr bool FIXED_SIZE = DataType::FIXED_SIZE
 
static constexpr uint32_t LOG2DIM = Log2Dim
 
static constexpr uint32_t TOTAL = LOG2DIM
 
static constexpr uint32_t DIM = 1u << TOTAL
 
static constexpr uint32_t SIZE = 1u << 3 * LOG2DIM
 
static constexpr uint32_t MASK = (1u << LOG2DIM) - 1u
 
static constexpr uint32_t LEVEL = 0
 
static constexpr uint64_t NUM_VALUES = uint64_t(1) << (3 * TOTAL)
 

Friends

template<typename , int , int , int >
class ReadAccessor
 
template<typename >
class RootNode
 
template<typename , uint32_t >
class InternalNode
 

Detailed Description

template<typename BuildT, typename CoordT = Coord, template< uint32_t > class MaskT = Mask, uint32_t Log2Dim = 3>
class nanovdb::LeafNode< BuildT, CoordT, MaskT, Log2Dim >

Leaf nodes of the VDB tree. (defaults to 8x8x8 = 512 voxels)

Member Typedef Documentation

using ArrayType = BuildT
inherited
using BuildType = typename DataType::BuildType
using CoordType = CoordT
using DataType = LeafData<BuildT, CoordT, MaskT, Log2Dim>
using FloatType = typename DataType::FloatType
using LeafNodeType = LeafNode<BuildT, CoordT, MaskT, Log2Dim>
using MaskIterT = typename Mask<Log2Dim>::template Iterator<ON>
using MaskType = MaskT<LOG2>
using ValueType = typename DataType::ValueType

Constructor & Destructor Documentation

LeafNode ( )
delete

This class cannot be constructed or deleted.

LeafNode ( const LeafNode< BuildT, CoordT, MaskT, Log2Dim > &  )
delete
~LeafNode ( )
delete

Member Function Documentation

__hostdev__ FloatType average ( ) const
inline

Return a const reference to the average of all the active values encoded in this leaf node.

__hostdev__ math::BBox<CoordT> bbox ( ) const
inline

Return the bounding box in index space of active values in this leaf node.

__hostdev__ ValueIterator beginValue ( ) const
inline
__hostdev__ ValueOffIterator beginValueOff ( ) const
inline
__hostdev__ ValueOnIterator beginValueOn ( ) const
inline
__hostdev__ ValueIterator cbeginValueAll ( ) const
inline
__hostdev__ ValueOffIterator cbeginValueOff ( ) const
inline
__hostdev__ ValueOnIterator cbeginValueOn ( ) const
inline
static __hostdev__ uint32_t CoordToOffset ( const CoordT &  ijk)
inlinestatic

Return the linear offset corresponding to the given coordinate.

__hostdev__ DataType* data ( )
inline
__hostdev__ const DataType* data ( ) const
inline
static __hostdev__ uint32_t dim ( )
inlinestatic

Return the dimension, in index space, of this leaf node (typically 8 as for openvdb leaf nodes!)

__hostdev__ void fill ( const ValueType v)
inlineinherited
__hostdev__ uint8_t flags ( ) const
inline
__hostdev__ auto get ( const CoordType ijk,
ArgsT &&...  args 
) const
inline
__hostdev__ auto get ( const uint32_t  n,
ArgsT &&...  args 
) const
inline
__hostdev__ FloatType getAvg ( ) const
inlineinherited
__hostdev__ FloatType getDev ( ) const
inlineinherited
__hostdev__ ValueType getFirstValue ( ) const
inline

Return the first value in this leaf node.

__hostdev__ ValueType getLastValue ( ) const
inline

Return the last value in this leaf node.

__hostdev__ ValueType getMax ( ) const
inlineinherited
__hostdev__ ValueType getMin ( ) const
inlineinherited
__hostdev__ ValueType getValue ( uint32_t  offset) const
inline

Return the voxel value at the given offset.

__hostdev__ ValueType getValue ( const CoordT &  ijk) const
inline

Return the voxel value at the given coordinate.

__hostdev__ const MaskType<LOG2DIM>& getValueMask ( ) const
inline
__hostdev__ bool hasBBox ( ) const
inline
static __hostdev__ bool hasStats ( )
inlinestaticinherited
__hostdev__ bool isActive ( const CoordT &  ijk) const
inline

Return true if the voxel value at the given coordinate is active.

__hostdev__ bool isActive ( uint32_t  n) const
inline
__hostdev__ bool isActive ( ) const
inline

Return true if any of the voxel value are active in this leaf node.

__hostdev__ void localToGlobalCoord ( Coord &  ijk) const
inline

Converts (in place) a local index coordinate to a global index coordinate.

__hostdev__ ValueType maximum ( ) const
inline

Return a const reference to the maximum active value encoded in this leaf node.

static __hostdev__ uint64_t memUsage ( )
inlinestaticinherited
__hostdev__ uint64_t memUsage ( ) const
inline

return memory usage in bytes for the leaf node

__hostdev__ ValueType minimum ( ) const
inline

Return a const reference to the minimum active value encoded in this leaf node.

__hostdev__ CoordT offsetToGlobalCoord ( uint32_t  n) const
inline
static __hostdev__ CoordT OffsetToLocalCoord ( uint32_t  n)
inlinestatic

Compute the local coordinates from a linear offset.

Parameters
nLinear offset into this nodes dense table
Returns
Local (vs global) 3D coordinates
LeafNode& operator= ( const LeafNode< BuildT, CoordT, MaskT, Log2Dim > &  )
delete
__hostdev__ CoordT origin ( ) const
inline

Return the origin in index space of this leaf node.

static __hostdev__ uint32_t padding ( )
inlinestatic
__hostdev__ const LeafNode* probeLeaf ( const CoordT &  ) const
inline
__hostdev__ bool probeValue ( const CoordT &  ijk,
ValueType v 
) const
inline

Return true if the voxel value at the given coordinate is active and updates v with the value.

__hostdev__ auto set ( const CoordType ijk,
ArgsT &&...  args 
)
inline
__hostdev__ auto set ( const uint32_t  n,
ArgsT &&...  args 
)
inline
__hostdev__ void setAvg ( const FloatType v)
inlineinherited
__hostdev__ void setDev ( const FloatType v)
inlineinherited
__hostdev__ void setMax ( const ValueType v)
inlineinherited
__hostdev__ void setMin ( const ValueType v)
inlineinherited
__hostdev__ void setOn ( uint32_t  offset)
inlineinherited
__hostdev__ void setOrigin ( const T &  ijk)
inlineinherited
__hostdev__ void setValue ( uint32_t  offset,
const ValueType value 
)
inlineinherited
__hostdev__ void setValue ( const CoordT &  ijk,
const ValueType v 
)
inline

Sets the value at the specified location and activate its state.

Note
This is safe since it does not change the topology of the tree (unlike setValue methods on the other nodes)
__hostdev__ void setValueOnly ( uint32_t  offset,
const ValueType value 
)
inlineinherited
__hostdev__ void setValueOnly ( uint32_t  offset,
const ValueType v 
)
inline

Sets the value at the specified location but leaves its state unchanged.

Note
This is safe since it does not change the topology of the tree (unlike setValue methods on the other nodes)
__hostdev__ void setValueOnly ( const CoordT &  ijk,
const ValueType v 
)
inline
__hostdev__ FloatType stdDeviation ( ) const
inline

Return a const reference to the standard deviation of all the active values encoded in this leaf node.

__hostdev__ bool updateBBox ( )
inline

Updates the local bounding box of active voxels in this node. Return true if bbox was updated.

Warning
It assumes that the origin and value mask have already been set.

This method is based on few (intrinsic) bit operations and hence is relatively fast. However, it should only only be called if either the value mask has changed or if the active bounding box is still undefined. e.g. during construction of this node.

__hostdev__ const MaskType<LOG2DIM>& valueMask ( ) const
inline

Return a const reference to the bit mask of active voxels in this leaf node.

__hostdev__ FloatType variance ( ) const
inline

Return the variance of all the active values encoded in this leaf node.

static __hostdev__ uint32_t voxelCount ( )
inlinestatic

Return the total number of voxels (e.g. values) encoded in this leaf node.

Friends And Related Function Documentation

friend class InternalNode
friend
friend class ReadAccessor
friend
friend class RootNode
friend

Member Data Documentation

constexpr uint32_t DIM = 1u << TOTAL
static
constexpr bool FIXED_SIZE = DataType::FIXED_SIZE
static
constexpr uint32_t LEVEL = 0
static
constexpr uint32_t LOG2DIM = Log2Dim
static
constexpr uint32_t MASK = (1u << LOG2DIM) - 1u
static
FloatType mAverage
inherited
uint8_t mBBoxDif[3]
inherited
CoordT mBBoxMin
inherited
uint8_t mFlags
inherited
ValueType mMaximum
inherited
ValueType mMinimum
inherited
FloatType mStdDevi
inherited
MaskT<LOG2DIM> mValueMask
inherited
ValueType mValues[1u<< 3 *LOG2DIM]
inherited
constexpr uint64_t NUM_VALUES = uint64_t(1) << (3 * TOTAL)
static
constexpr uint32_t SIZE = 1u << 3 * LOG2DIM
static
constexpr uint32_t TOTAL = LOG2DIM
static