OpenVDB  2.1.0
Classes | Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Types | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Friends | List of all members
LeafNode< T, Log2Dim > Class Template Reference

Templated block class to hold specific data types and a fixed number of values determined by Log2Dim. The actual coordinate dimension of the block is 2^Log2Dim, i.e. Log2Dim=3 corresponds to a LeafNode that spans a 8^3 block. More...

#include <LeafNode.h>

Classes

class  Buffer
 Stores the actual values in the LeafNode. Its dimension it fixed to 2^(3*Log2Dim) More...
 
struct  ChildAll
 
struct  ChildIter
 Leaf nodes have no children, so their child iterators have no get/set accessors. More...
 
struct  ChildOff
 
struct  ChildOn
 
struct  DenseIter
 
struct  ValueAll
 
struct  ValueConverter
 ValueConverter<T>::Type is the type of a LeafNode having the same child hierarchy and dimensions as this node but a different value type, T. More...
 
struct  ValueIter
 
struct  ValueOff
 
struct  ValueOn
 

Public Types

typedef T ValueType
 
typedef LeafNode< ValueType,
Log2Dim > 
LeafNodeType
 
typedef boost::shared_ptr
< LeafNode
Ptr
 
typedef util::NodeMask< Log2Dim > NodeMaskType
 
typedef ValueIter
< MaskOnIterator, LeafNode,
const ValueType, ValueOn
ValueOnIter
 
typedef ValueIter
< MaskOnIterator, const
LeafNode, const ValueType,
ValueOn
ValueOnCIter
 
typedef ValueIter
< MaskOffIterator, LeafNode,
const ValueType, ValueOff
ValueOffIter
 
typedef ValueIter
< MaskOffIterator, const
LeafNode, const ValueType,
ValueOff
ValueOffCIter
 
typedef ValueIter
< MaskDenseIterator, LeafNode,
const ValueType, ValueAll
ValueAllIter
 
typedef ValueIter
< MaskDenseIterator, const
LeafNode, const ValueType,
ValueAll
ValueAllCIter
 
typedef ChildIter
< MaskOnIterator, LeafNode,
ChildOn
ChildOnIter
 
typedef ChildIter
< MaskOnIterator, const
LeafNode, ChildOn
ChildOnCIter
 
typedef ChildIter
< MaskOffIterator, LeafNode,
ChildOff
ChildOffIter
 
typedef ChildIter
< MaskOffIterator, const
LeafNode, ChildOff
ChildOffCIter
 
typedef DenseIter< LeafNode,
ValueType, ChildAll
ChildAllIter
 
typedef DenseIter< const
LeafNode, const ValueType,
ChildAll
ChildAllCIter
 

Public Member Functions

 LeafNode ()
 Default constructor. More...
 
 LeafNode (const Coord &coords, const ValueType &value=zeroVal< ValueType >(), bool active=false)
 Constructor. More...
 
 LeafNode (const LeafNode &)
 Deep copy constructor. More...
 
template<typename OtherValueType >
 LeafNode (const LeafNode< OtherValueType, Log2Dim > &other, const ValueType &offValue, const ValueType &onValue, TopologyCopy)
 Topology copy constructor. More...
 
template<typename OtherValueType >
 LeafNode (const LeafNode< OtherValueType, Log2Dim > &other, const ValueType &background, TopologyCopy)
 Topology copy constructor. More...
 
 ~LeafNode ()
 Destructor. More...
 
Index64 onVoxelCount () const
 Return the number of voxels marked On. More...
 
Index64 offVoxelCount () const
 Return the number of voxels marked Off. More...
 
Index64 onLeafVoxelCount () const
 
Index64 offLeafVoxelCount () const
 
bool isEmpty () const
 Return true if this node has no active voxels. More...
 
bool isDense () const
 Return true if this node contains only active voxels. More...
 
Index64 memUsage () const
 Return the memory in bytes occupied by this node. More...
 
void evalActiveBoundingBox (CoordBBox &, bool visitVoxels=true) const
 
OPENVDB_DEPRECATED void evalActiveVoxelBoundingBox (CoordBBox &) const
 
CoordBBox getNodeBoundingBox () const
 Return the bounding box of this node, i.e., the full index space spanned by this leaf node. More...
 
void setOrigin (const Coord &origin)
 Set the grid index coordinates of this node's local origin. More...
 
OPENVDB_DEPRECATED const Coord & getOrigin () const
 Return the grid index coordinates of this node's local origin. More...
 
Coord offsetToGlobalCoord (Index n) const
 Return the global coordinates for a linear table offset. More...
 
std::string str () const
 Return a string representation of this node. More...
 
template<typename OtherType , Index OtherLog2Dim>
bool hasSameTopology (const LeafNode< OtherType, OtherLog2Dim > *other) const
 Return true if the given node (which may have a different ValueType than this node) has the same active value topology as this node. More...
 
bool operator== (const LeafNode &other) const
 Check for buffer, state and origin equivalence. More...
 
bool operator!= (const LeafNode &other) const
 
ValueOnCIter cbeginValueOn () const
 
ValueOnCIter beginValueOn () const
 
ValueOnIter beginValueOn ()
 
ValueOffCIter cbeginValueOff () const
 
ValueOffCIter beginValueOff () const
 
ValueOffIter beginValueOff ()
 
ValueAllCIter cbeginValueAll () const
 
ValueAllCIter beginValueAll () const
 
ValueAllIter beginValueAll ()
 
ValueOnCIter cendValueOn () const
 
ValueOnCIter endValueOn () const
 
ValueOnIter endValueOn ()
 
ValueOffCIter cendValueOff () const
 
ValueOffCIter endValueOff () const
 
ValueOffIter endValueOff ()
 
ValueAllCIter cendValueAll () const
 
ValueAllCIter endValueAll () const
 
ValueAllIter endValueAll ()
 
ChildOnCIter cbeginChildOn () const
 
ChildOnCIter beginChildOn () const
 
ChildOnIter beginChildOn ()
 
ChildOffCIter cbeginChildOff () const
 
ChildOffCIter beginChildOff () const
 
ChildOffIter beginChildOff ()
 
ChildAllCIter cbeginChildAll () const
 
ChildAllCIter beginChildAll () const
 
ChildAllIter beginChildAll ()
 
ChildOnCIter cendChildOn () const
 
ChildOnCIter endChildOn () const
 
ChildOnIter endChildOn ()
 
ChildOffCIter cendChildOff () const
 
ChildOffCIter endChildOff () const
 
ChildOffIter endChildOff ()
 
ChildAllCIter cendChildAll () const
 
ChildAllCIter endChildAll () const
 
ChildAllIter endChildAll ()
 
void swap (Buffer &other)
 Exchange this node's data buffer with the given data buffer without changing the active states of the values. More...
 
const Bufferbuffer () const
 
Bufferbuffer ()
 
void readTopology (std::istream &is, bool fromHalf=false)
 Read in just the topology. More...
 
void writeTopology (std::ostream &os, bool toHalf=false) const
 Write out just the topology. More...
 
void readBuffers (std::istream &is, bool fromHalf=false)
 Read buffers from a stream. More...
 
void writeBuffers (std::ostream &os, bool toHalf=false) const
 Write buffers to a stream. More...
 
size_t streamingSize (bool toHalf=false) const
 
const ValueTypegetValue (const Coord &xyz) const
 Return the value of the voxel at the given coordinates. More...
 
const ValueTypegetValue (Index offset) const
 Return the value of the voxel at the given linear offset. More...
 
bool probeValue (const Coord &xyz, ValueType &val) const
 Return true if the voxel at the given coordinates is active. More...
 
bool probeValue (Index offset, ValueType &val) const
 Return true if the voxel at the given offset is active. More...
 
void setActiveState (const Coord &xyz, bool on)
 Set the active state of the voxel at the given coordinates but don't change its value. More...
 
void setActiveState (Index offset, bool on)
 Set the active state of the voxel at the given offset but don't change its value. More...
 
void setValueOnly (const Coord &xyz, const ValueType &val)
 Set the value of the voxel at the given coordinates but don't change its active state. More...
 
void setValueOnly (Index offset, const ValueType &val)
 Set the value of the voxel at the given offset but don't change its active state. More...
 
void setValueOff (const Coord &xyz)
 Mark the voxel at the given coordinates as inactive but don't change its value. More...
 
void setValueOff (Index offset)
 Mark the voxel at the given offset as inactive but don't change its value. More...
 
void setValueOff (const Coord &xyz, const ValueType &val)
 Set the value of the voxel at the given coordinates and mark the voxel as inactive. More...
 
void setValueOff (Index offset, const ValueType &val)
 Set the value of the voxel at the given offset and mark the voxel as inactive. More...
 
void setValueOn (const Coord &xyz)
 Mark the voxel at the given coordinates as active but don't change its value. More...
 
void setValueOn (Index offset)
 Mark the voxel at the given offset as active but don't change its value. More...
 
void setValueOn (const Coord &xyz, const ValueType &val)
 Set the value of the voxel at the given coordinates and mark the voxel as active. More...
 
void setValue (const Coord &xyz, const ValueType &val)
 Set the value of the voxel at the given coordinates and mark the voxel as active. More...
 
void setValueOn (Index offset, const ValueType &val)
 Set the value of the voxel at the given offset and mark the voxel as active. More...
 
template<typename ModifyOp >
void modifyValue (Index offset, const ModifyOp &op)
 Apply a functor to the value of the voxel at the given offset and mark the voxel as active. More...
 
template<typename ModifyOp >
void modifyValue (const Coord &xyz, const ModifyOp &op)
 Apply a functor to the value of the voxel at the given coordinates and mark the voxel as active. More...
 
template<typename ModifyOp >
void modifyValueAndActiveState (const Coord &xyz, const ModifyOp &op)
 Apply a functor to the voxel at the given coordinates. More...
 
void setValuesOn ()
 Mark all voxels as active but don't change their values. More...
 
void setValuesOff ()
 Mark all voxels as inactive but don't change their values. More...
 
bool isValueOn (const Coord &xyz) const
 Return true if the voxel at the given coordinates is active. More...
 
bool isValueOn (Index offset) const
 Return true if the voxel at the given offset is active. More...
 
void fill (const CoordBBox &bbox, const ValueType &, bool active=true)
 Set all voxels within an axis-aligned box to the specified value and active state. More...
 
void fill (const ValueType &value)
 Set all voxels to the specified value but don't change their active states. More...
 
void fill (const ValueType &value, bool active)
 Set all voxels to the specified value and active state. More...
 
template<typename DenseT >
void copyToDense (const CoordBBox &bbox, DenseT &dense) const
 Copy into a dense grid the values of the voxels that lie within a given bounding box. More...
 
template<typename DenseT >
void copyFromDense (const CoordBBox &bbox, const DenseT &dense, const ValueType &background, const ValueType &tolerance)
 Copy from a dense grid into this node the values of the voxels that lie within a given bounding box. More...
 
template<typename AccessorT >
const ValueTypegetValueAndCache (const Coord &xyz, AccessorT &) const
 Return the value of the voxel at the given coordinates. More...
 
template<typename AccessorT >
bool isValueOnAndCache (const Coord &xyz, AccessorT &) const
 Return true if the voxel at the given coordinates is active. More...
 
template<typename AccessorT >
void setValueAndCache (const Coord &xyz, const ValueType &val, AccessorT &)
 Change the value of the voxel at the given coordinates and mark it as active. More...
 
template<typename AccessorT >
void setValueOnlyAndCache (const Coord &xyz, const ValueType &val, AccessorT &)
 Change the value of the voxel at the given coordinates but preserve its state. More...
 
template<typename ModifyOp , typename AccessorT >
void modifyValueAndCache (const Coord &xyz, const ModifyOp &op, AccessorT &)
 Apply a functor to the value of the voxel at the given coordinates and mark the voxel as active. More...
 
template<typename ModifyOp , typename AccessorT >
void modifyValueAndActiveStateAndCache (const Coord &xyz, const ModifyOp &op, AccessorT &)
 
template<typename AccessorT >
void setValueOffAndCache (const Coord &xyz, const ValueType &value, AccessorT &)
 Change the value of the voxel at the given coordinates and mark it as inactive. More...
 
template<typename AccessorT >
void setActiveStateAndCache (const Coord &xyz, bool on, AccessorT &)
 Set the active state of the voxel at the given coordinates without changing its value. More...
 
template<typename AccessorT >
bool probeValueAndCache (const Coord &xyz, ValueType &val, AccessorT &) const
 Return true if the voxel at the given coordinates is active and return the voxel value in val. More...
 
template<typename AccessorT >
const ValueTypegetValue (const Coord &xyz, bool &state, int &level, AccessorT &) const
 Return the value of the voxel at the given coordinates and return its active state and level (i.e., 0) in state and level. More...
 
const ValueTypegetFirstValue () const
 Return a const reference to the first value in the buffer. More...
 
const ValueTypegetLastValue () const
 Return a const reference to the last value in the buffer. More...
 
void resetBackground (const ValueType &oldBackground, const ValueType &newBackground)
 Replace inactive occurrences of oldBackground with newBackground, and inactive occurrences of -oldBackground with -newBackground. More...
 
void signedFloodFill (const ValueType &background)
 Overwrite each inactive value in this node and in any child nodes with a new value whose magnitude is equal to the specified background value and whose sign is consistent with that of the lexicographically closest active value. More...
 
void signedFloodFill (const ValueType &outside, const ValueType &inside)
 Overwrite each inactive value in this node and in any child nodes with either outside or inside, depending on the sign of the lexicographically closest active value. More...
 
void negate ()
 
void voxelizeActiveTiles ()
 
template<MergePolicy Policy>
void merge (const LeafNode &)
 
template<MergePolicy Policy>
void merge (const ValueType &tileValue, bool tileActive)
 
template<MergePolicy Policy>
void merge (const LeafNode &other, const ValueType &, const ValueType &)
 
template<typename OtherType >
void topologyUnion (const LeafNode< OtherType, Log2Dim > &other)
 Union this node's set of active values with the active values of the other node, whose ValueType may be different. So a resulting voxel will be active if either of the original voxels were active. More...
 
template<typename OtherType >
void topologyIntersection (const LeafNode< OtherType, Log2Dim > &other, const ValueType &)
 Intersect this node's set of active values with the active values of the other node, whose ValueType may be different. So a resulting voxel will be active only if both of the original voxels were active. More...
 
template<typename OtherType >
void topologyDifference (const LeafNode< OtherType, Log2Dim > &other, const ValueType &)
 Difference this node's set of active values with the active values of the other node, whose ValueType may be different. So a resulting voxel will be active only if the original voxel is active in this LeafNode and inactive in the other LeafNode. More...
 
template<typename CombineOp >
void combine (const LeafNode &other, CombineOp &op)
 
template<typename CombineOp >
void combine (const ValueType &value, bool valueIsActive, CombineOp &op)
 
template<typename CombineOp >
void combine2 (const LeafNode &other, const ValueType &, bool valueIsActive, CombineOp &)
 
template<typename CombineOp >
void combine2 (const ValueType &, const LeafNode &other, bool valueIsActive, CombineOp &)
 
template<typename CombineOp >
void combine2 (const LeafNode &b0, const LeafNode &b1, CombineOp &)
 
template<typename BBoxOp >
void visitActiveBBox (BBoxOp &) const
 Calls the templated functor BBoxOp with bounding box information. An additional level argument is provided to the callback. More...
 
template<typename VisitorOp >
void visit (VisitorOp &)
 
template<typename VisitorOp >
void visit (VisitorOp &) const
 
template<typename OtherLeafNodeType , typename VisitorOp >
void visit2Node (OtherLeafNodeType &other, VisitorOp &)
 
template<typename OtherLeafNodeType , typename VisitorOp >
void visit2Node (OtherLeafNodeType &other, VisitorOp &) const
 
template<typename IterT , typename VisitorOp >
void visit2 (IterT &otherIter, VisitorOp &, bool otherIsLHS=false)
 
template<typename IterT , typename VisitorOp >
void visit2 (IterT &otherIter, VisitorOp &, bool otherIsLHS=false) const
 
void addTile (Index level, const Coord &, const ValueType &, bool)
 
void addTile (Index offset, const ValueType &, bool)
 
template<typename AccessorT >
void addTileAndCache (Index, const Coord &, const ValueType &, bool, AccessorT &)
 
bool isConstant (ValueType &constValue, bool &state, const ValueType &tolerance=zeroVal< ValueType >()) const
 
bool isInactive () const
 Return true if all of this node's values are inactive. More...
 
bool isValueMaskOn (Index n) const
 
bool isValueMaskOn () const
 
bool isValueMaskOff (Index n) const
 
bool isValueMaskOff () const
 
const NodeMaskTypegetValueMask () const
 
NodeMaskTypegetValueMask ()
 
void setValueMask (const NodeMaskType &mask)
 
bool isChildMaskOn (Index) const
 
bool isChildMaskOff (Index) const
 
bool isChildMaskOff () const
 
const Coord & origin () const
 Return the grid index coordinates of this node's local origin. More...
 
void getOrigin (Coord &origin) const
 Return the grid index coordinates of this node's local origin. More...
 
void getOrigin (Int32 &x, Int32 &y, Int32 &z) const
 Return the grid index coordinates of this node's local origin. More...
 
template<typename PruneOp >
void pruneOp (PruneOp &)
 This function exists only to enable template instantiation. More...
 
void prune (const ValueType &=zeroVal< ValueType >())
 This function exists only to enable template instantiation. More...
 
void pruneInactive (const ValueType &)
 This function exists only to enable template instantiation. More...
 
void addLeaf (LeafNode *)
 This function exists only to enable template instantiation. More...
 
template<typename AccessorT >
void addLeafAndCache (LeafNode *, AccessorT &)
 This function exists only to enable template instantiation. More...
 
template<typename NodeT >
NodeT * stealNode (const Coord &, const ValueType &, bool)
 This function exists only to enable template instantiation. More...
 
template<typename NodeT >
NodeT * probeNode (const Coord &)
 This function exists only to enable template instantiation. More...
 
template<typename NodeT >
const NodeT * probeConstNode (const Coord &) const
 This function exists only to enable template instantiation. More...
 
LeafNodetouchLeaf (const Coord &)
 Return a pointer to this node. More...
 
template<typename AccessorT >
LeafNodetouchLeafAndCache (const Coord &, AccessorT &)
 Return a pointer to this node. More...
 
template<typename NodeT , typename AccessorT >
NodeT * probeNodeAndCache (const Coord &, AccessorT &)
 Return a pointer to this node. More...
 
LeafNodeprobeLeaf (const Coord &)
 Return a pointer to this node. More...
 
template<typename AccessorT >
LeafNodeprobeLeafAndCache (const Coord &, AccessorT &)
 Return a pointer to this node. More...
 
const LeafNodeprobeConstLeaf (const Coord &) const
 Return a const pointer to this node. More...
 
template<typename AccessorT >
const LeafNodeprobeConstLeafAndCache (const Coord &, AccessorT &) const
 Return a const pointer to this node. More...
 
template<typename AccessorT >
const LeafNodeprobeLeafAndCache (const Coord &, AccessorT &) const
 Return a const pointer to this node. More...
 
const LeafNodeprobeLeaf (const Coord &) const
 Return a const pointer to this node. More...
 
template<typename NodeT , typename AccessorT >
const NodeT * probeConstNodeAndCache (const Coord &, AccessorT &) const
 Return a const pointer to this node. More...
 

Static Public Member Functions

static Index log2dim ()
 Return log2 of the dimension of this LeafNode, e.g. 3 if dimensions are 8^3. More...
 
static Index dim ()
 Return the number of voxels in each coordinate dimension. More...
 
static Index size ()
 Return the total number of voxels represented by this LeafNode. More...
 
static Index numValues ()
 Return the total number of voxels represented by this LeafNode. More...
 
static Index getLevel ()
 Return the level of this node, which by definition is zero for LeafNodes. More...
 
static void getNodeLog2Dims (std::vector< Index > &dims)
 Append the Log2Dim of this LeafNode to the specified vector. More...
 
static Index getChildDim ()
 Return the dimension of child nodes of this LeafNode, which is one for voxels. More...
 
static Index32 leafCount ()
 Return the leaf count for this node, which is one. More...
 
static Index32 nonLeafCount ()
 Return the non-leaf count for this node, which is zero. More...
 
static Index64 onTileCount ()
 
static Index64 offTileCount ()
 
static Index coordToOffset (const Coord &xyz)
 Return the linear table offset of the given global or local coordinates. More...
 
static Coord offsetToLocalCoord (Index n)
 Return the local coordinates for a linear table offset, where offset 0 has coordinates (0, 0, 0). More...
 
static OPENVDB_DEPRECATED void offsetToLocalCoord (Index n, Coord &xyz)
 
static Index getValueLevel (const Coord &)
 Return the level (i.e., 0) at which leaf node values reside. More...
 
static bool hasActiveTiles ()
 Return false since leaf nodes never contain tiles. More...
 
template<typename AccessorT >
static Index getValueLevelAndCache (const Coord &, AccessorT &)
 Return the LEVEL (=0) at which leaf node values reside. More...
 

Static Public Attributes

static const Index LOG2DIM = Log2Dim
 
static const Index TOTAL = Log2Dim
 
static const Index DIM = 1 << TOTAL
 
static const Index NUM_VALUES = 1 << 3 * Log2Dim
 
static const Index NUM_VOXELS = NUM_VALUES
 
static const Index SIZE = NUM_VALUES
 
static const Index LEVEL = 0
 

Protected Types

typedef NodeMaskType::OnIterator MaskOnIterator
 
typedef NodeMaskType::OffIterator MaskOffIterator
 
typedef NodeMaskType::DenseIterator MaskDenseIterator
 

Protected Member Functions

void setValueMask (Index n, bool on)
 
void setValueMaskOn (Index n)
 
void setValueMaskOff (Index n)
 

Static Protected Member Functions

static void evalNodeOrigin (Coord &xyz)
 Compute the origin of the leaf node that contains the voxel with the given coordinates. More...
 
template<typename NodeT , typename VisitorOp , typename ChildAllIterT >
static void doVisit (NodeT &, VisitorOp &)
 
template<typename NodeT , typename OtherNodeT , typename VisitorOp , typename ChildAllIterT , typename OtherChildAllIterT >
static void doVisit2Node (NodeT &self, OtherNodeT &other, VisitorOp &)
 
template<typename NodeT , typename VisitorOp , typename ChildAllIterT , typename OtherChildAllIterT >
static void doVisit2 (NodeT &self, OtherChildAllIterT &, VisitorOp &, bool otherIsLHS)
 

Protected Attributes

Buffer mBuffer
 Buffer containing the actual data values. More...
 
NodeMaskType mValueMask
 Bitmask that determines which voxels are active. More...
 
Coord mOrigin
 Global grid index coordinates (x,y,z) of the local origin of this node. More...
 

Friends

class ::TestLeaf
 
template<typename >
class ::TestLeafIO
 
template<typename , Index >
class LeafNode
 
struct ValueIter< MaskOnIterator, LeafNode, ValueType, ValueOn >
 
struct ValueIter< MaskOffIterator, LeafNode, ValueType, ValueOff >
 
struct ValueIter< MaskDenseIterator, LeafNode, ValueType, ValueAll >
 
struct ValueIter< MaskOnIterator, const LeafNode, ValueType, ValueOn >
 
struct ValueIter< MaskOffIterator, const LeafNode, ValueType, ValueOff >
 
struct ValueIter< MaskDenseIterator, const LeafNode, ValueType, ValueAll >
 
class IteratorBase< MaskOnIterator, LeafNode >
 
class IteratorBase< MaskOffIterator, LeafNode >
 
class IteratorBase< MaskDenseIterator, LeafNode >
 

Detailed Description

template<typename T, Index Log2Dim>
class openvdb::v2_1_0::tree::LeafNode< T, Log2Dim >

Templated block class to hold specific data types and a fixed number of values determined by Log2Dim. The actual coordinate dimension of the block is 2^Log2Dim, i.e. Log2Dim=3 corresponds to a LeafNode that spans a 8^3 block.

Member Typedef Documentation

typedef LeafNode<ValueType, Log2Dim> LeafNodeType
typedef util::NodeMask<Log2Dim> NodeMaskType
typedef boost::shared_ptr<LeafNode> Ptr
typedef T ValueType

Constructor & Destructor Documentation

LeafNode ( )
inline

Default constructor.

LeafNode ( const Coord &  coords,
const ValueType value = zeroVal<ValueType>(),
bool  active = false 
)
inlineexplicit

Constructor.

Parameters
coordsthe grid index coordinates of a voxel
valuea value with which to fill the buffer
activethe active state to which to initialize all voxels
LeafNode ( const LeafNode< T, Log2Dim > &  other)
inline

Deep copy constructor.

LeafNode ( const LeafNode< OtherValueType, Log2Dim > &  other,
const ValueType offValue,
const ValueType onValue,
TopologyCopy   
)
inline

Topology copy constructor.

LeafNode ( const LeafNode< OtherValueType, Log2Dim > &  other,
const ValueType background,
TopologyCopy   
)
inline

Topology copy constructor.

~LeafNode ( )
inline

Destructor.

Member Function Documentation

void addLeaf ( LeafNode< T, Log2Dim > *  )
inline

This function exists only to enable template instantiation.

void addLeafAndCache ( LeafNode< T, Log2Dim > *  ,
AccessorT &   
)
inline

This function exists only to enable template instantiation.

void addTile ( Index  level,
const Coord &  xyz,
const ValueType val,
bool  active 
)
inline
void addTile ( Index  offset,
const ValueType val,
bool  active 
)
inline
void addTileAndCache ( Index  level,
const Coord &  xyz,
const ValueType val,
bool  active,
AccessorT &   
)
inline
ChildAllCIter beginChildAll ( ) const
inline
ChildAllIter beginChildAll ( )
inline
ChildOffCIter beginChildOff ( ) const
inline
ChildOffIter beginChildOff ( )
inline
ChildOnCIter beginChildOn ( ) const
inline
ChildOnIter beginChildOn ( )
inline
ValueAllCIter beginValueAll ( ) const
inline
ValueAllIter beginValueAll ( )
inline
ValueOffCIter beginValueOff ( ) const
inline
ValueOffIter beginValueOff ( )
inline
ValueOnCIter beginValueOn ( ) const
inline
ValueOnIter beginValueOn ( )
inline
const Buffer& buffer ( ) const
inline
Buffer& buffer ( )
inline
ChildAllCIter cbeginChildAll ( ) const
inline
ChildOffCIter cbeginChildOff ( ) const
inline
ChildOnCIter cbeginChildOn ( ) const
inline
ValueAllCIter cbeginValueAll ( ) const
inline
ValueOffCIter cbeginValueOff ( ) const
inline
ValueOnCIter cbeginValueOn ( ) const
inline
ChildAllCIter cendChildAll ( ) const
inline
ChildOffCIter cendChildOff ( ) const
inline
ChildOnCIter cendChildOn ( ) const
inline
ValueAllCIter cendValueAll ( ) const
inline
ValueOffCIter cendValueOff ( ) const
inline
ValueOnCIter cendValueOn ( ) const
inline
void combine ( const LeafNode< T, Log2Dim > &  other,
CombineOp &  op 
)
inline
void combine ( const ValueType value,
bool  valueIsActive,
CombineOp &  op 
)
inline
void combine2 ( const LeafNode< T, Log2Dim > &  other,
const ValueType value,
bool  valueIsActive,
CombineOp &  op 
)
inline
void combine2 ( const ValueType value,
const LeafNode< T, Log2Dim > &  other,
bool  valueIsActive,
CombineOp &  op 
)
inline
void combine2 ( const LeafNode< T, Log2Dim > &  b0,
const LeafNode< T, Log2Dim > &  b1,
CombineOp &  op 
)
inline
Index coordToOffset ( const Coord &  xyz)
inlinestatic

Return the linear table offset of the given global or local coordinates.

void copyFromDense ( const CoordBBox &  bbox,
const DenseT &  dense,
const ValueType background,
const ValueType tolerance 
)
inline

Copy from a dense grid into this node the values of the voxels that lie within a given bounding box.

Only values that are different (by more than the given tolerance) from the background value will be active. Other values are inactive and truncated to the background value.

Parameters
bboxinclusive bounding box of the voxels to be copied into this node
densedense grid with a stride in z of one (see tools::Dense in tools/Dense.h for the required API)
backgroundbackground value of the tree that this node belongs to
tolerancetolerance within which a value equals the background value
Note
bbox is assumed to be identical to or contained in the coordinate domains of both the dense grid and this node, i.e., no bounds checking is performed.
Consider using tools::CopyFromDense in tools/Dense.h instead of calling this method directly.
void copyToDense ( const CoordBBox &  bbox,
DenseT &  dense 
) const
inline

Copy into a dense grid the values of the voxels that lie within a given bounding box.

Parameters
bboxinclusive bounding box of the voxels to be copied into the dense grid
densedense grid with a stride in z of one (see tools::Dense in tools/Dense.h for the required API)
Note
bbox is assumed to be identical to or contained in the coordinate domains of both the dense grid and this node, i.e., no bounds checking is performed.
Consider using tools::CopyToDense in tools/Dense.h instead of calling this method directly.
static Index dim ( )
inlinestatic

Return the number of voxels in each coordinate dimension.

void doVisit ( NodeT &  self,
VisitorOp &  op 
)
inlinestaticprotected
void doVisit2 ( NodeT &  self,
OtherChildAllIterT &  otherIter,
VisitorOp &  op,
bool  otherIsLHS 
)
inlinestaticprotected
void doVisit2Node ( NodeT &  self,
OtherNodeT &  other,
VisitorOp &  op 
)
inlinestaticprotected
ChildAllCIter endChildAll ( ) const
inline
ChildAllIter endChildAll ( )
inline
ChildOffCIter endChildOff ( ) const
inline
ChildOffIter endChildOff ( )
inline
ChildOnCIter endChildOn ( ) const
inline
ChildOnIter endChildOn ( )
inline
ValueAllCIter endValueAll ( ) const
inline
ValueAllIter endValueAll ( )
inline
ValueOffCIter endValueOff ( ) const
inline
ValueOffIter endValueOff ( )
inline
ValueOnCIter endValueOn ( ) const
inline
ValueOnIter endValueOn ( )
inline
void evalActiveBoundingBox ( CoordBBox &  bbox,
bool  visitVoxels = true 
) const
inline

Expand the given bounding box so that it includes this leaf node's active voxels. If visitVoxels is false this LeafNode will be approximated as dense, i.e. with all voxels active. Else the individual active voxels are visited to produce a tight bbox.

void evalActiveVoxelBoundingBox ( CoordBBox &  bbox) const
inline
static void evalNodeOrigin ( Coord &  xyz)
inlinestaticprotected

Compute the origin of the leaf node that contains the voxel with the given coordinates.

void fill ( const CoordBBox &  bbox,
const ValueType value,
bool  active = true 
)
inline

Set all voxels within an axis-aligned box to the specified value and active state.

void fill ( const ValueType value)
inline

Set all voxels to the specified value but don't change their active states.

void fill ( const ValueType value,
bool  active 
)
inline

Set all voxels to the specified value and active state.

static Index getChildDim ( )
inlinestatic

Return the dimension of child nodes of this LeafNode, which is one for voxels.

const ValueType& getFirstValue ( ) const
inline

Return a const reference to the first value in the buffer.

Note
Though it is potentially risky you can convert this to a non-const pointer by means of const_case<ValueType*>&.
const ValueType& getLastValue ( ) const
inline

Return a const reference to the last value in the buffer.

static Index getLevel ( )
inlinestatic

Return the level of this node, which by definition is zero for LeafNodes.

CoordBBox getNodeBoundingBox ( ) const
inline

Return the bounding box of this node, i.e., the full index space spanned by this leaf node.

static void getNodeLog2Dims ( std::vector< Index > &  dims)
inlinestatic

Append the Log2Dim of this LeafNode to the specified vector.

OPENVDB_DEPRECATED const Coord& getOrigin ( ) const
inline

Return the grid index coordinates of this node's local origin.

Deprecated:
Use origin() instead.
void getOrigin ( Coord &  origin) const
inline

Return the grid index coordinates of this node's local origin.

void getOrigin ( Int32 x,
Int32 y,
Int32 z 
) const
inline

Return the grid index coordinates of this node's local origin.

const ValueT & getValue ( const Coord &  xyz) const
inline

Return the value of the voxel at the given coordinates.

const ValueT & getValue ( Index  offset) const
inline

Return the value of the voxel at the given linear offset.

const ValueType& getValue ( const Coord &  xyz,
bool &  state,
int &  level,
AccessorT &   
) const
inline

Return the value of the voxel at the given coordinates and return its active state and level (i.e., 0) in state and level.

Note
Used internally by ValueAccessor.
const ValueType& getValueAndCache ( const Coord &  xyz,
AccessorT &   
) const
inline

Return the value of the voxel at the given coordinates.

Note
Used internally by ValueAccessor.
static Index getValueLevel ( const Coord &  )
inlinestatic

Return the level (i.e., 0) at which leaf node values reside.

static Index getValueLevelAndCache ( const Coord &  ,
AccessorT &   
)
inlinestatic

Return the LEVEL (=0) at which leaf node values reside.

Note
Used internally by ValueAccessor (note last argument is a dummy).
const NodeMaskType& getValueMask ( ) const
inline
NodeMaskType& getValueMask ( )
inline
static bool hasActiveTiles ( )
inlinestatic

Return false since leaf nodes never contain tiles.

bool hasSameTopology ( const LeafNode< OtherType, OtherLog2Dim > *  other) const
inline

Return true if the given node (which may have a different ValueType than this node) has the same active value topology as this node.

bool isChildMaskOff ( Index  ) const
inline
bool isChildMaskOff ( ) const
inline
bool isChildMaskOn ( Index  ) const
inline
bool isConstant ( ValueType constValue,
bool &  state,
const ValueType tolerance = zeroVal<ValueType>() 
) const
inline

Return true if all of this node's values have the same active state and are equal to within the given tolerance, and return the value in constValue and the active state in state.

bool isDense ( ) const
inline

Return true if this node contains only active voxels.

bool isEmpty ( ) const
inline

Return true if this node has no active voxels.

bool isInactive ( ) const
inline

Return true if all of this node's values are inactive.

bool isValueMaskOff ( Index  n) const
inline
bool isValueMaskOff ( ) const
inline
bool isValueMaskOn ( Index  n) const
inline
bool isValueMaskOn ( ) const
inline
bool isValueOn ( const Coord &  xyz) const
inline

Return true if the voxel at the given coordinates is active.

bool isValueOn ( Index  offset) const
inline

Return true if the voxel at the given offset is active.

bool isValueOnAndCache ( const Coord &  xyz,
AccessorT &   
) const
inline

Return true if the voxel at the given coordinates is active.

Note
Used internally by ValueAccessor.
static Index32 leafCount ( )
inlinestatic

Return the leaf count for this node, which is one.

static Index log2dim ( )
inlinestatic

Return log2 of the dimension of this LeafNode, e.g. 3 if dimensions are 8^3.

Index64 memUsage ( ) const
inline

Return the memory in bytes occupied by this node.

void merge ( const LeafNode< T, Log2Dim > &  other)
inline
void merge ( const ValueType tileValue,
bool  tileActive 
)
inline
void merge ( const LeafNode< T, Log2Dim > &  other,
const ValueType ,
const ValueType  
)
inline
void modifyValue ( Index  offset,
const ModifyOp &  op 
)
inline

Apply a functor to the value of the voxel at the given offset and mark the voxel as active.

void modifyValue ( const Coord &  xyz,
const ModifyOp &  op 
)
inline

Apply a functor to the value of the voxel at the given coordinates and mark the voxel as active.

void modifyValueAndActiveState ( const Coord &  xyz,
const ModifyOp &  op 
)
inline

Apply a functor to the voxel at the given coordinates.

void modifyValueAndActiveStateAndCache ( const Coord &  xyz,
const ModifyOp &  op,
AccessorT &   
)
inline

Apply a functor to the voxel at the given coordinates.

Note
Used internally by ValueAccessor.
void modifyValueAndCache ( const Coord &  xyz,
const ModifyOp &  op,
AccessorT &   
)
inline

Apply a functor to the value of the voxel at the given coordinates and mark the voxel as active.

Note
Used internally by ValueAccessor.
void negate ( )
inline
static Index32 nonLeafCount ( )
inlinestatic

Return the non-leaf count for this node, which is zero.

static Index numValues ( )
inlinestatic

Return the total number of voxels represented by this LeafNode.

Index64 offLeafVoxelCount ( ) const
inline
Coord offsetToGlobalCoord ( Index  n) const
inline

Return the global coordinates for a linear table offset.

Coord offsetToLocalCoord ( Index  n)
inlinestatic

Return the local coordinates for a linear table offset, where offset 0 has coordinates (0, 0, 0).

void offsetToLocalCoord ( Index  n,
Coord &  xyz 
)
inlinestatic
static Index64 offTileCount ( )
inlinestatic
Index64 offVoxelCount ( ) const
inline

Return the number of voxels marked Off.

Index64 onLeafVoxelCount ( ) const
inline
static Index64 onTileCount ( )
inlinestatic
Index64 onVoxelCount ( ) const
inline

Return the number of voxels marked On.

bool operator!= ( const LeafNode< T, Log2Dim > &  other) const
inline
bool operator== ( const LeafNode< T, Log2Dim > &  other) const
inline

Check for buffer, state and origin equivalence.

const Coord& origin ( ) const
inline

Return the grid index coordinates of this node's local origin.

const LeafNode* probeConstLeaf ( const Coord &  ) const
inline

Return a const pointer to this node.

const LeafNode* probeConstLeafAndCache ( const Coord &  ,
AccessorT &   
) const
inline

Return a const pointer to this node.

const NodeT* probeConstNode ( const Coord &  ) const
inline

This function exists only to enable template instantiation.

const NodeT* probeConstNodeAndCache ( const Coord &  ,
AccessorT &   
) const
inline

Return a const pointer to this node.

LeafNode* probeLeaf ( const Coord &  )
inline

Return a pointer to this node.

const LeafNode* probeLeaf ( const Coord &  ) const
inline

Return a const pointer to this node.

LeafNode* probeLeafAndCache ( const Coord &  ,
AccessorT &   
)
inline

Return a pointer to this node.

const LeafNode* probeLeafAndCache ( const Coord &  ,
AccessorT &   
) const
inline

Return a const pointer to this node.

NodeT* probeNode ( const Coord &  )
inline

This function exists only to enable template instantiation.

NodeT* probeNodeAndCache ( const Coord &  ,
AccessorT &   
)
inline

Return a pointer to this node.

bool probeValue ( const Coord &  xyz,
ValueType val 
) const
inline

Return true if the voxel at the given coordinates is active.

Parameters
xyzthe coordinates of the voxel to be probed
[out]valthe value of the voxel at the given coordinates
bool probeValue ( Index  offset,
ValueType val 
) const
inline

Return true if the voxel at the given offset is active.

Parameters
offsetthe linear offset of the voxel to be probed
[out]valthe value of the voxel at the given coordinates
bool probeValueAndCache ( const Coord &  xyz,
ValueType val,
AccessorT &   
) const
inline

Return true if the voxel at the given coordinates is active and return the voxel value in val.

Note
Used internally by ValueAccessor.
void prune ( const ValueType = zeroVal<ValueType>())
inline

This function exists only to enable template instantiation.

void pruneInactive ( const ValueType )
inline

This function exists only to enable template instantiation.

void pruneOp ( PruneOp &  )
inline

This function exists only to enable template instantiation.

void readBuffers ( std::istream &  is,
bool  fromHalf = false 
)
inline

Read buffers from a stream.

Parameters
isthe stream from which to read
fromHalfif true, floating-point input values are assumed to be 16-bit
void readTopology ( std::istream &  is,
bool  fromHalf = false 
)
inline

Read in just the topology.

Parameters
isthe stream from which to read
fromHalfif true, floating-point input values are assumed to be 16-bit
void resetBackground ( const ValueType oldBackground,
const ValueType newBackground 
)
inline

Replace inactive occurrences of oldBackground with newBackground, and inactive occurrences of -oldBackground with -newBackground.

void setActiveState ( const Coord &  xyz,
bool  on 
)
inline

Set the active state of the voxel at the given coordinates but don't change its value.

void setActiveState ( Index  offset,
bool  on 
)
inline

Set the active state of the voxel at the given offset but don't change its value.

void setActiveStateAndCache ( const Coord &  xyz,
bool  on,
AccessorT &   
)
inline

Set the active state of the voxel at the given coordinates without changing its value.

Note
Used internally by ValueAccessor.
void setOrigin ( const Coord &  origin)
inline

Set the grid index coordinates of this node's local origin.

void setValue ( const Coord &  xyz,
const ValueType val 
)
inline

Set the value of the voxel at the given coordinates and mark the voxel as active.

void setValueAndCache ( const Coord &  xyz,
const ValueType val,
AccessorT &   
)
inline

Change the value of the voxel at the given coordinates and mark it as active.

Note
Used internally by ValueAccessor.
void setValueMask ( const NodeMaskType mask)
inline
void setValueMask ( Index  n,
bool  on 
)
inlineprotected
void setValueMaskOff ( Index  n)
inlineprotected
void setValueMaskOn ( Index  n)
inlineprotected
void setValueOff ( const Coord &  xyz)
inline

Mark the voxel at the given coordinates as inactive but don't change its value.

void setValueOff ( Index  offset)
inline

Mark the voxel at the given offset as inactive but don't change its value.

void setValueOff ( const Coord &  xyz,
const ValueType val 
)
inline

Set the value of the voxel at the given coordinates and mark the voxel as inactive.

void setValueOff ( Index  offset,
const ValueType val 
)
inline

Set the value of the voxel at the given offset and mark the voxel as inactive.

void setValueOffAndCache ( const Coord &  xyz,
const ValueType value,
AccessorT &   
)
inline

Change the value of the voxel at the given coordinates and mark it as inactive.

Note
Used internally by ValueAccessor.
void setValueOn ( const Coord &  xyz)
inline

Mark the voxel at the given coordinates as active but don't change its value.

void setValueOn ( Index  offset)
inline

Mark the voxel at the given offset as active but don't change its value.

void setValueOn ( const Coord &  xyz,
const ValueType val 
)
inline

Set the value of the voxel at the given coordinates and mark the voxel as active.

void setValueOn ( Index  offset,
const ValueType val 
)
inline

Set the value of the voxel at the given offset and mark the voxel as active.

void setValueOnly ( const Coord &  xyz,
const ValueType val 
)
inline

Set the value of the voxel at the given coordinates but don't change its active state.

void setValueOnly ( Index  offset,
const ValueType val 
)
inline

Set the value of the voxel at the given offset but don't change its active state.

void setValueOnlyAndCache ( const Coord &  xyz,
const ValueType val,
AccessorT &   
)
inline

Change the value of the voxel at the given coordinates but preserve its state.

Note
Used internally by ValueAccessor.
void setValuesOff ( )
inline

Mark all voxels as inactive but don't change their values.

void setValuesOn ( )
inline

Mark all voxels as active but don't change their values.

void signedFloodFill ( const ValueType background)
inline

Overwrite each inactive value in this node and in any child nodes with a new value whose magnitude is equal to the specified background value and whose sign is consistent with that of the lexicographically closest active value.

This is primarily useful for propagating the sign from the (active) voxels in a narrow-band level set to the inactive voxels outside the narrow band.

void signedFloodFill ( const ValueType outside,
const ValueType inside 
)
inline

Overwrite each inactive value in this node and in any child nodes with either outside or inside, depending on the sign of the lexicographically closest active value.

Specifically, an inactive value is set to outside if the closest active value in the lexicographic direction is positive, otherwise it is set to inside.

static Index size ( )
inlinestatic

Return the total number of voxels represented by this LeafNode.

NodeT* stealNode ( const Coord &  ,
const ValueType ,
bool   
)
inline

This function exists only to enable template instantiation.

std::string str ( ) const
inline

Return a string representation of this node.

size_t streamingSize ( bool  toHalf = false) const
void swap ( Buffer other)
inline

Exchange this node's data buffer with the given data buffer without changing the active states of the values.

void topologyDifference ( const LeafNode< OtherType, Log2Dim > &  other,
const ValueType  
)
inline

Difference this node's set of active values with the active values of the other node, whose ValueType may be different. So a resulting voxel will be active only if the original voxel is active in this LeafNode and inactive in the other LeafNode.

The last dummy argument is required to match the signature for InternalNode::topologyDifference.

Note
This operation modifies only active states, not values. Also note that this operation can result in all voxels being inactive so consider subsequnetly calling prune.
void topologyIntersection ( const LeafNode< OtherType, Log2Dim > &  other,
const ValueType  
)
inline

Intersect this node's set of active values with the active values of the other node, whose ValueType may be different. So a resulting voxel will be active only if both of the original voxels were active.

The last dummy argument is required to match the signature for InternalNode::topologyIntersection.

Note
This operation modifies only active states, not values. Also note that this operation can result in all voxels being inactive so consider subsequnetly calling prune.
void topologyUnion ( const LeafNode< OtherType, Log2Dim > &  other)
inline

Union this node's set of active values with the active values of the other node, whose ValueType may be different. So a resulting voxel will be active if either of the original voxels were active.

Note
This operation modifies only active states, not values.
LeafNode* touchLeaf ( const Coord &  )
inline

Return a pointer to this node.

LeafNode* touchLeafAndCache ( const Coord &  ,
AccessorT &   
)
inline

Return a pointer to this node.

void visit ( VisitorOp &  op)
inline
void visit ( VisitorOp &  op) const
inline
void visit2 ( IterT &  otherIter,
VisitorOp &  op,
bool  otherIsLHS = false 
)
inline
void visit2 ( IterT &  otherIter,
VisitorOp &  op,
bool  otherIsLHS = false 
) const
inline
void visit2Node ( OtherLeafNodeType &  other,
VisitorOp &  op 
)
inline
void visit2Node ( OtherLeafNodeType &  other,
VisitorOp &  op 
) const
inline
void visitActiveBBox ( BBoxOp &  op) const
inline

Calls the templated functor BBoxOp with bounding box information. An additional level argument is provided to the callback.

Note
The bounding boxes are guarenteed to be non-overlapping.
void voxelizeActiveTiles ( )
inline
void writeBuffers ( std::ostream &  os,
bool  toHalf = false 
) const
inline

Write buffers to a stream.

Parameters
osthe stream to which to write
toHalfif true, output floating-point values as 16-bit half floats
void writeTopology ( std::ostream &  os,
bool  toHalf = false 
) const
inline

Write out just the topology.

Parameters
osthe stream to which to write
toHalfif true, output floating-point values as 16-bit half floats

Friends And Related Function Documentation

friend class ::TestLeaf
friend
friend class ::TestLeafIO
friend
friend class IteratorBase< MaskDenseIterator, LeafNode >
friend
friend class IteratorBase< MaskOffIterator, LeafNode >
friend
friend class IteratorBase< MaskOnIterator, LeafNode >
friend
friend class LeafNode
friend
friend struct ValueIter< MaskDenseIterator, const LeafNode, ValueType, ValueAll >
friend
friend struct ValueIter< MaskOffIterator, const LeafNode, ValueType, ValueOff >
friend
friend struct ValueIter< MaskOffIterator, LeafNode, ValueType, ValueOff >
friend
friend struct ValueIter< MaskOnIterator, const LeafNode, ValueType, ValueOn >
friend
friend struct ValueIter< MaskOnIterator, LeafNode, ValueType, ValueOn >
friend

Member Data Documentation

const Index DIM = 1 << TOTAL
static
const Index LEVEL = 0
static
const Index LOG2DIM = Log2Dim
static
Buffer mBuffer
protected

Buffer containing the actual data values.

Coord mOrigin
protected

Global grid index coordinates (x,y,z) of the local origin of this node.

NodeMaskType mValueMask
protected

Bitmask that determines which voxels are active.

const Index NUM_VALUES = 1 << 3 * Log2Dim
static
const Index NUM_VOXELS = NUM_VALUES
static
const Index SIZE = NUM_VALUES
static
const Index TOTAL = Log2Dim
static

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