OpenVDB  2.0.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
InternalNode< _ChildNodeType, Log2Dim > Class Template Reference

#include <InternalNode.h>

Classes

struct  ChildAll
 
struct  ChildIter
 
struct  ChildOff
 
struct  ChildOn
 
struct  DenseIter
 
struct  ValueAll
 
struct  ValueConverter
 ValueConverter<T>::Type is the type of an InternalNode 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 _ChildNodeType ChildNodeType
 
typedef ChildNodeType::LeafNodeType LeafNodeType
 
typedef ChildNodeType::ValueType ValueType
 
typedef NodeUnion< ValueType,
ChildNodeType
UnionType
 
typedef util::NodeMask< Log2Dim > NodeMaskType
 
typedef ChildIter
< InternalNode, ChildNodeType,
MaskOnIterator, ChildOn
ChildOnIter
 
typedef ChildIter< const
InternalNode, const
ChildNodeType, MaskOnIterator,
ChildOn
ChildOnCIter
 
typedef ValueIter
< InternalNode, const
ValueType, MaskOffIterator,
ChildOff
ChildOffIter
 
typedef ValueIter< const
InternalNode, const ValueType,
MaskOffIterator, ChildOff
ChildOffCIter
 
typedef DenseIter
< InternalNode, ChildNodeType,
ValueType, ChildAll
ChildAllIter
 
typedef DenseIter< const
InternalNode, const
ChildNodeType, ValueType,
ChildAll
ChildAllCIter
 
typedef ValueIter
< InternalNode, const
ValueType, MaskOnIterator,
ValueOn
ValueOnIter
 
typedef ValueIter< const
InternalNode, const ValueType,
MaskOnIterator, ValueOn
ValueOnCIter
 
typedef ValueIter
< InternalNode, const
ValueType, MaskOffIterator,
ValueOff
ValueOffIter
 
typedef ValueIter< const
InternalNode, const ValueType,
MaskOffIterator, ValueOff
ValueOffCIter
 
typedef ValueIter
< InternalNode, const
ValueType, MaskOffIterator,
ValueAll
ValueAllIter
 
typedef ValueIter< const
InternalNode, const ValueType,
MaskOffIterator, ValueAll
ValueAllCIter
 

Public Member Functions

 InternalNode ()
 
 InternalNode (const ValueType &offValue)
 
 InternalNode (const Coord &, const ValueType &value, bool active=false)
 
 InternalNode (const InternalNode &)
 Deep copy constructor. More...
 
template<typename OtherChildNodeType >
 InternalNode (const InternalNode< OtherChildNodeType, Log2Dim > &other, const ValueType &background, TopologyCopy)
 Topology copy constructor. More...
 
template<typename OtherChildNodeType >
 InternalNode (const InternalNode< OtherChildNodeType, Log2Dim > &other, const ValueType &offValue, const ValueType &onValue, TopologyCopy)
 Topology copy constructor. More...
 
virtual ~InternalNode ()
 
ChildOnCIter cbeginChildOn () const
 
ChildOffCIter cbeginChildOff () const
 
ChildAllCIter cbeginChildAll () const
 
ChildOnCIter beginChildOn () const
 
ChildOffCIter beginChildOff () const
 
ChildAllCIter beginChildAll () const
 
ChildOnIter beginChildOn ()
 
ChildOffIter beginChildOff ()
 
ChildAllIter beginChildAll ()
 
ValueOnCIter cbeginValueOn () const
 
ValueOffCIter cbeginValueOff () const
 
ValueAllCIter cbeginValueAll () const
 
ValueOnCIter beginValueOn () const
 
ValueOffCIter beginValueOff () const
 
ValueAllCIter beginValueAll () const
 
ValueOnIter beginValueOn ()
 
ValueOffIter beginValueOff ()
 
ValueAllIter beginValueAll ()
 
Coord offsetToGlobalCoord (Index n) const
 Return the global coordinates for a linear table offset. More...
 
const Coord & origin () const
 Return the grid index coordinates of this node's local origin. More...
 
OPENVDB_DEPRECATED Coord getOrigin () const
 Return the grid index coordinates of this node's local origin. More...
 
void setOrigin (const Coord &origin)
 Set the grid index coordinates of this node's local origin. More...
 
Index32 leafCount () const
 
Index32 nonLeafCount () const
 
Index64 onVoxelCount () const
 
Index64 offVoxelCount () const
 
Index64 onLeafVoxelCount () const
 
Index64 offLeafVoxelCount () const
 
Index64 onTileCount () const
 
Index64 memUsage () const
 Return the total amount of memory in bytes occupied by this node and its children. More...
 
void evalActiveBoundingBox (CoordBBox &bbox, bool visitVoxels=true) const
 Expand the specified bounding box so that it includes the active tiles of this internal node as well as all the active values in its child nodes. If visitVoxels is false LeafNodes will be approximated as dense, i.e. with all voxels active. Else the individual active voxels are visited to produce a tight bbox. More...
 
OPENVDB_DEPRECATED void evalActiveVoxelBoundingBox (CoordBBox &bbox) const
 
CoordBBox getNodeBoundingBox () const
 Return the bounding box of this node, i.e., the full index space spanned by the node regardless of its content. More...
 
bool isEmpty () const
 
bool isConstant (ValueType &constValue, bool &state, const ValueType &tolerance=zeroVal< ValueType >()) const
 
bool isInactive () const
 Return true if this node has no children and only contains inactive 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...
 
bool hasActiveTiles () const
 Return true if this node or any of its child nodes have any active tiles. More...
 
const ValueTypegetValue (const Coord &xyz) const
 
bool probeValue (const Coord &xyz, ValueType &value) const
 
Index getValueLevel (const Coord &xyz) const
 Return the level of the tree (0 = leaf) at which the value at the given coordinates resides. More...
 
const ValueTypegetFirstValue () const
 If the first entry in this node's table is a tile, return the tile's value. Otherwise, return the result of calling getFirstValue() on the child. More...
 
const ValueTypegetLastValue () const
 If the last entry in this node's table is a tile, return the tile's value. Otherwise, return the result of calling getLastValue() on the child. 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 setValueOnly (const Coord &xyz, const ValueType &value)
 Set the value of the voxel at the given coordinates but don't change its active state. More...
 
void setValueOn (const Coord &xyz)
 Mark the voxel at the given coordinates as active but don't change its value. More...
 
void setValueOn (const Coord &xyz, const ValueType &value)
 Set the value of the voxel at the given coordinates and mark the voxel as active. More...
 
void setValueOff (const Coord &xyz)
 Mark the voxel at the given coordinates as inactive but don't change its value. More...
 
void setValueOff (const Coord &xyz, const ValueType &value)
 Set the value of the voxel at the given coordinates and mark the voxel as inactive. 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...
 
template<typename AccessorT >
const ValueTypegetValueAndCache (const Coord &xyz, AccessorT &) const
 
template<typename AccessorT >
bool isValueOnAndCache (const Coord &xyz, AccessorT &) const
 
template<typename AccessorT >
void setValueAndCache (const Coord &xyz, const ValueType &value, AccessorT &)
 
template<typename AccessorT >
void setValueOnlyAndCache (const Coord &xyz, const ValueType &value, AccessorT &)
 
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. If necessary, update the accessor with pointers to the nodes along the path from the root node to the node containing the voxel. 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 &)
 
template<typename AccessorT >
void setActiveStateAndCache (const Coord &xyz, bool on, AccessorT &)
 
template<typename AccessorT >
bool probeValueAndCache (const Coord &xyz, ValueType &value, AccessorT &) const
 
template<typename AccessorT >
Index getValueLevelAndCache (const Coord &xyz, AccessorT &) const
 Return the level of the tree (0 = leaf) at which the value at the given coordinates resides. More...
 
void setValuesOn ()
 Mark all values (both tiles and voxels) as active. More...
 
void writeTopology (std::ostream &, bool toHalf=false) const
 
void readTopology (std::istream &, bool fromHalf=false)
 
void writeBuffers (std::ostream &, bool toHalf=false) const
 
void readBuffers (std::istream &, bool fromHalf=false)
 
void fill (const CoordBBox &bbox, const ValueType &, bool active=true)
 Set all voxels within an axis-aligned box to a constant value. (The min and max coordinates are inclusive.) 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 ()
 Densify active tiles, i.e., replace them with leaf-level active voxels. 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<MergePolicy Policy>
void merge (InternalNode &other, const ValueType &background, const ValueType &otherBackground)
 Efficiently merge another tree into this tree using one of several schemes. More...
 
template<MergePolicy Policy>
void merge (const ValueType &tileValue, bool tileActive)
 Merge, using one of several schemes, this node (and its descendants) with a tile of the same dimensions and the given value and active state. More...
 
template<typename OtherChildNodeType >
void topologyUnion (const InternalNode< OtherChildNodeType, Log2Dim > &other)
 Union this branch's set of active values with the other branch's active values. The value type of the other branch can be different. More...
 
template<typename OtherChildNodeType >
void topologyIntersection (const InternalNode< OtherChildNodeType, Log2Dim > &other, const ValueType &background)
 Intersects this tree's set of active values with the active values of the other tree, whose ValueType may be different. More...
 
template<typename OtherChildNodeType >
void topologyDifference (const InternalNode< OtherChildNodeType, Log2Dim > &other, const ValueType &background)
 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 node and inactive in the other node. More...
 
template<typename CombineOp >
void combine (InternalNode &other, CombineOp &)
 
template<typename CombineOp >
void combine (const ValueType &value, bool valueIsActive, CombineOp &)
 
template<typename CombineOp >
void combine2 (const InternalNode &other0, const InternalNode &other1, CombineOp &)
 
template<typename CombineOp >
void combine2 (const ValueType &value, const InternalNode &other, bool valIsActive, CombineOp &)
 
template<typename CombineOp >
void combine2 (const InternalNode &other, const ValueType &val, bool valIsActive, CombineOp &)
 
template<typename BBoxOp >
void visitActiveBBox (BBoxOp &) const
 Calls the templated functor BBoxOp with bounding box information for all active tiles and leaf nodes in this node. An additional level argument is provided for each callback. More...
 
template<typename VisitorOp >
void visit (VisitorOp &)
 
template<typename VisitorOp >
void visit (VisitorOp &) const
 
template<typename OtherNodeType , typename VisitorOp >
void visit2Node (OtherNodeType &other, VisitorOp &)
 
template<typename OtherNodeType , typename VisitorOp >
void visit2Node (OtherNodeType &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
 
template<typename PruneOp >
void pruneOp (PruneOp &)
 Call the PruneOp functor for each child node and, if the functor returns true, prune the node and replace it with a tile. More...
 
void prune (const ValueType &tolerance=zeroVal< ValueType >())
 Reduce the memory footprint of this tree by replacing with tiles any nodes whose values are all the same (optionally to within a tolerance) and have the same active state. More...
 
void pruneInactive (const ValueType &)
 Reduce the memory footprint of this tree by replacing with tiles of the given value any nodes whose values are all inactive. More...
 
void pruneInactive ()
 Reduce the memory footprint of this tree by replacing with background tiles any nodes whose values are all inactive. More...
 
void addLeaf (LeafNodeType *leaf)
 Add the specified leaf to this node, possibly creating a child branch in the process. If the leaf node already exists, replace it. More...
 
template<typename AccessorT >
void addLeafAndCache (LeafNodeType *leaf, AccessorT &)
 Same as addLeaf() except, if necessary, update the accessor with pointers to the nodes along the path from the root node to the node containing the coordinate. More...
 
template<typename NodeT >
NodeT * stealNode (const Coord &xyz, const ValueType &value, bool state)
 Return a pointer to the node of type NodeT that contains voxel (x, y, z) and replace it with a tile of the specified value and state. If no such node exists, leave the tree unchanged and return NULL. More...
 
void addTile (Index level, const Coord &xyz, const ValueType &value, bool state)
 Add a tile at the specified tree level that contains voxel (x, y, z), possibly creating a parent branch or deleting a child branch in the process. More...
 
void addTile (Index offset, const ValueType &value, bool state)
 Delete any existing child branch at the specified offset and add a tile. More...
 
template<typename AccessorT >
void addTileAndCache (Index level, const Coord &xyz, const ValueType &, bool state, AccessorT &)
 Same as addTile() except, if necessary, update the accessor with pointers to the nodes along the path from the root node to the node containing (x, y, z). More...
 
LeafNodeTypetouchLeaf (const Coord &xyz)
 Return the leaf node that contains voxel (x, y, z). If no such node exists, create one, but preserve the values and active states of all voxels. More...
 
template<typename AccessorT >
LeafNodeTypetouchLeafAndCache (const Coord &xyz, AccessorT &)
 Same as touchLeaf() except, if necessary, update the accessor with pointers to the nodes along the path from the root node to the node containing the coordinate. More...
 
void resetBackground (const ValueType &oldBackground, const ValueType &newBackground)
 Change inactive tiles or voxels with value oldBackground to newBackground or -oldBackground to -newBackground. Active values are unchanged. More...
 
template<typename OtherChildNodeType , Index OtherLog2Dim>
bool hasSameTopology (const InternalNode< OtherChildNodeType, OtherLog2Dim > *other) const
 Return true if the given tree branch has the same node and active value topology as this tree branch (but possibly a different ValueType). More...
 
bool isValueMaskOn (Index n) const
 
bool isValueMaskOn () const
 
bool isValueMaskOff (Index n) const
 
bool isValueMaskOff () const
 
bool isChildMaskOn (Index n) const
 
bool isChildMaskOff (Index n) const
 
bool isChildMaskOff () const
 
template<typename NodeT >
NodeT * probeNode (const Coord &xyz)
 
template<typename NodeT , typename AccessorT >
NodeT * probeNodeAndCache (const Coord &xyz, AccessorT &acc)
 
template<typename NodeT >
const NodeT * probeConstNode (const Coord &xyz) const
 
template<typename NodeT , typename AccessorT >
const NodeT * probeConstNodeAndCache (const Coord &xyz, AccessorT &acc) const
 
template<typename AccessorT >
ChildT::LeafNodeType * probeLeafAndCache (const Coord &xyz, AccessorT &acc)
 
template<typename AccessorT >
const ChildT::LeafNodeType * probeLeafAndCache (const Coord &xyz, AccessorT &acc) const
 
template<typename AccessorT >
const ChildT::LeafNodeType * probeConstLeafAndCache (const Coord &xyz, AccessorT &acc) const
 
template<typename AccessorT >
ChildT::LeafNodeType * touchLeafAndCache (const Coord &xyz, AccessorT &acc)
 
template<typename AccessorT >
const ChildT::ValueType & getValueAndCache (const Coord &xyz, AccessorT &acc) const
 
template<typename OtherChildT >
void topologyUnion (const InternalNode< OtherChildT, Log2Dim > &other)
 
template<typename OtherChildT >
void topologyIntersection (const InternalNode< OtherChildT, Log2Dim > &other, const ValueType &background)
 
template<typename OtherChildT >
void topologyDifference (const InternalNode< OtherChildT, Log2Dim > &other, const ValueType &background)
 
template<typename OtherChildAllIterType , typename VisitorOp >
void visit2 (OtherChildAllIterType &otherIter, VisitorOp &op, bool otherIsLHS)
 
template<typename OtherChildAllIterType , typename VisitorOp >
void visit2 (OtherChildAllIterType &otherIter, VisitorOp &op, bool otherIsLHS) const
 
template<typename NodeType >
NodeType * probeNode (const Coord &xyz)
 Return a pointer to the node that contains voxel (x, y, z). If no such node exists, return NULL. More...
 
template<typename NodeType >
const NodeType * probeConstNode (const Coord &xyz) const
 Return a pointer to the node that contains voxel (x, y, z). If no such node exists, return NULL. More...
 
template<typename NodeType , typename AccessorT >
NodeType * probeNodeAndCache (const Coord &xyz, AccessorT &)
 Same as probeNode() except, if necessary, update the accessor with pointers to the nodes along the path from the root node to the node containing (x, y, z). More...
 
template<typename NodeType , typename AccessorT >
const NodeType * probeConstNodeAndCache (const Coord &xyz, AccessorT &) const
 Same as probeNode() except, if necessary, update the accessor with pointers to the nodes along the path from the root node to the node containing (x, y, z). More...
 
LeafNodeTypeprobeLeaf (const Coord &xyz)
 Return a pointer to the leaf node that contains voxel (x, y, z). If no such node exists, return NULL. More...
 
const LeafNodeTypeprobeConstLeaf (const Coord &xyz) const
 Return a pointer to the leaf node that contains voxel (x, y, z). If no such node exists, return NULL. More...
 
const LeafNodeTypeprobeLeaf (const Coord &xyz) const
 Return a pointer to the leaf node that contains voxel (x, y, z). If no such node exists, return NULL. More...
 
template<typename AccessorT >
LeafNodeTypeprobeLeafAndCache (const Coord &xyz, AccessorT &acc)
 Same as probeLeaf() except, if necessary, update the accessor with pointers to the nodes along the path from the root node to the node containing (x, y, z). More...
 
template<typename AccessorT >
const LeafNodeTypeprobeConstLeafAndCache (const Coord &xyz, AccessorT &acc) const
 Same as probeLeaf() except, if necessary, update the accessor with pointers to the nodes along the path from the root node to the node containing (x, y, z). More...
 
template<typename AccessorT >
const LeafNodeTypeprobeLeafAndCache (const Coord &xyz, AccessorT &acc) const
 Same as probeLeaf() except, if necessary, update the accessor with pointers to the nodes along the path from the root node to the node containing (x, y, z). More...
 

Static Public Member Functions

static Index dim ()
 
static Index getLevel ()
 
static void getNodeLog2Dims (std::vector< Index > &dims)
 
static Index getChildDim ()
 
static Index coordToOffset (const Coord &xyz)
 Return the linear table offset of the given global or local coordinates. More...
 
static void offsetToLocalCoord (Index n, Coord &xyz)
 Return the local coordinates for a linear table offset, where offset 0 has coordinates (0, 0, 0). More...
 

Static Public Attributes

static const Index LOG2DIM = Log2Dim
 
static const Index TOTAL = Log2Dim + ChildNodeType::TOTAL
 
static const Index DIM = 1 << TOTAL
 
static const Index NUM_VALUES = 1 << (3 * Log2Dim)
 
static const Index LEVEL = 1 + ChildNodeType::LEVEL
 
static const Index64 NUM_VOXELS = uint64_t(1) << (3 * TOTAL)
 

Protected Types

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

Protected Member Functions

void makeChildNodeEmpty (Index n, const ValueType &value)
 
void setChildNode (Index i, ChildNodeType *child)
 
void resetChildNode (Index i, ChildNodeType *child)
 
ChildNodeTypeunsetChildNode (Index i, const ValueType &value)
 
ChildNodeTypegetChildNode (Index n)
 
const ChildNodeTypegetChildNode (Index n) const
 
void setValueMask (Index n, bool on)
 

Static Protected Member Functions

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 &, OtherNodeT &, VisitorOp &)
 
template<typename NodeT , typename VisitorOp , typename ChildAllIterT , typename OtherChildAllIterT >
static void doVisit2 (NodeT &, OtherChildAllIterT &, VisitorOp &, bool otherIsLHS)
 

Protected Attributes

UnionType mNodes [NUM_VALUES]
 
NodeMaskType mChildMask
 
NodeMaskType mValueMask
 
Coord mOrigin
 Global grid index coordinates (x,y,z) of the local origin of this node. More...
 

Friends

template<typename , Index >
class InternalNode
 During topology-only construction, access is needed to protected/private members of other template instances. More...
 
class IteratorBase< MaskOnIterator, InternalNode >
 
class IteratorBase< MaskOffIterator, InternalNode >
 
class IteratorBase< MaskDenseIterator, InternalNode >
 

Member Typedef Documentation

typedef _ChildNodeType ChildNodeType
typedef ChildNodeType::LeafNodeType LeafNodeType
typedef util::NodeMask<Log2Dim> NodeMaskType
typedef ChildNodeType::ValueType ValueType

Constructor & Destructor Documentation

InternalNode ( )
inline
InternalNode ( const ValueType offValue)
inlineexplicit
InternalNode ( const Coord &  origin,
const ValueType value,
bool  active = false 
)
inline
InternalNode ( const InternalNode< _ChildNodeType, Log2Dim > &  other)
inline

Deep copy constructor.

InternalNode ( const InternalNode< OtherChildNodeType, Log2Dim > &  other,
const ValueType background,
TopologyCopy   
)
inline

Topology copy constructor.

InternalNode ( const InternalNode< OtherChildNodeType, Log2Dim > &  other,
const ValueType offValue,
const ValueType onValue,
TopologyCopy   
)
inline

Topology copy constructor.

~InternalNode ( )
inlinevirtual

Member Function Documentation

void addLeaf ( LeafNodeType leaf)
inline

Add the specified leaf to this node, possibly creating a child branch in the process. If the leaf node already exists, replace it.

void addLeafAndCache ( LeafNodeType leaf,
AccessorT &  acc 
)
inline

Same as addLeaf() except, if necessary, update the accessor with pointers to the nodes along the path from the root node to the node containing the coordinate.

void addTile ( Index  level,
const Coord &  xyz,
const ValueType value,
bool  state 
)
inline

Add a tile at the specified tree level that contains voxel (x, y, z), possibly creating a parent branch or deleting a child branch in the process.

void addTile ( Index  offset,
const ValueType value,
bool  state 
)
inline

Delete any existing child branch at the specified offset and add a tile.

void addTileAndCache ( Index  level,
const Coord &  xyz,
const ValueType value,
bool  state,
AccessorT &  acc 
)
inline

Same as addTile() except, if necessary, update the accessor with pointers to the nodes along the path from the root node to the node containing (x, y, z).

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
ChildAllCIter cbeginChildAll ( ) const
inline
ChildOffCIter cbeginChildOff ( ) const
inline
ChildOnCIter cbeginChildOn ( ) const
inline
ValueAllCIter cbeginValueAll ( ) const
inline
ValueOffCIter cbeginValueOff ( ) const
inline
ValueOnCIter cbeginValueOn ( ) const
inline
void combine ( InternalNode< _ChildNodeType, Log2Dim > &  other,
CombineOp &  op 
)
inline
void combine ( const ValueType value,
bool  valueIsActive,
CombineOp &  op 
)
inline
void combine2 ( const InternalNode< _ChildNodeType, Log2Dim > &  other0,
const InternalNode< _ChildNodeType, Log2Dim > &  other1,
CombineOp &  op 
)
inline
void combine2 ( const ValueType value,
const InternalNode< _ChildNodeType, Log2Dim > &  other,
bool  valIsActive,
CombineOp &  op 
)
inline
void combine2 ( const InternalNode< _ChildNodeType, Log2Dim > &  other,
const ValueType val,
bool  valIsActive,
CombineOp &  op 
)
inline
Index coordToOffset ( const Coord &  xyz)
inlinestatic

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

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.
static Index dim ( )
inlinestatic
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
void evalActiveBoundingBox ( CoordBBox &  bbox,
bool  visitVoxels = true 
) const
inline

Expand the specified bounding box so that it includes the active tiles of this internal node as well as all the active values in its child nodes. If visitVoxels is false LeafNodes 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
void fill ( const CoordBBox &  bbox,
const ValueType value,
bool  active = true 
)
inline

Set all voxels within an axis-aligned box to a constant value. (The min and max coordinates are inclusive.)

static Index getChildDim ( )
inlinestatic
ChildT * getChildNode ( Index  n)
inlineprotected
const ChildT * getChildNode ( Index  n) const
inlineprotected
const ChildT::ValueType & getFirstValue ( ) const
inline

If the first entry in this node's table is a tile, return the tile's value. Otherwise, return the result of calling getFirstValue() on the child.

const ChildT::ValueType & getLastValue ( ) const
inline

If the last entry in this node's table is a tile, return the tile's value. Otherwise, return the result of calling getLastValue() on the child.

static Index getLevel ( )
inlinestatic
CoordBBox getNodeBoundingBox ( ) const
inline

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

void getNodeLog2Dims ( std::vector< Index > &  dims)
static
OPENVDB_DEPRECATED Coord getOrigin ( ) const
inline

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

Deprecated:
Use origin() instead.
const ChildT::ValueType & getValue ( const Coord &  xyz) const
inline
const ValueType& getValueAndCache ( const Coord &  xyz,
AccessorT &   
) const

Return the value of the voxel at the given coordinates and, if necessary, update the accessor with pointers to the nodes along the path from the root node to the node containing the voxel.

Note
Used internally by ValueAccessor.
const ChildT::ValueType& getValueAndCache ( const Coord &  xyz,
AccessorT &  acc 
) const
inline
Index getValueLevel ( const Coord &  xyz) const
inline

Return the level of the tree (0 = leaf) at which the value at the given coordinates resides.

Index getValueLevelAndCache ( const Coord &  xyz,
AccessorT &  acc 
) const
inline

Return the level of the tree (0 = leaf) at which the value at the given coordinates resides.

If necessary, update the accessor with pointers to the nodes along the path from the root node to the node containing the voxel.

Note
Used internally by ValueAccessor.
bool hasActiveTiles ( ) const
inline

Return true if this node or any of its child nodes have any active tiles.

bool hasSameTopology ( const InternalNode< OtherChildNodeType, OtherLog2Dim > *  other) const
inline

Return true if the given tree branch has the same node and active value topology as this tree branch (but possibly a different ValueType).

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

Return true if all of this node's table entries have the same active state and the same constant value to within the given tolerance, and return that value in constValue and the active state in state.

bool isEmpty ( ) const
inline
bool isInactive ( ) const
inline

Return true if this node has no children and only contains inactive values.

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 &  acc 
) const
inline

Return true if the voxel at the given coordinates is active and, if necessary, update the accessor with pointers to the nodes along the path from the root node to the node containing the voxel.

Note
Used internally by ValueAccessor.
Index32 leafCount ( ) const
inline
void makeChildNodeEmpty ( Index  n,
const ValueType value 
)
inlineprotected
Index64 memUsage ( ) const
inline

Return the total amount of memory in bytes occupied by this node and its children.

void merge ( InternalNode< _ChildNodeType, Log2Dim > &  other,
const ValueType background,
const ValueType otherBackground 
)
inline

Efficiently merge another tree into this tree using one of several schemes.

Warning
This operation cannibalizes the other tree.
void merge ( const ValueType tileValue,
bool  tileActive 
)
inline

Merge, using one of several schemes, this node (and its descendants) with a tile of the same dimensions and the given value and active state.

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 &  acc 
)
inline

Apply a functor to the voxel at the given coordinates. If necessary, update the accessor with pointers to the nodes along the path from the root node to the node containing the voxel.

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

Apply a functor to the value of the voxel at the given coordinates and mark the voxel as active. If necessary, update the accessor with pointers to the nodes along the path from the root node to the node containing the voxel.

Note
Used internally by ValueAccessor.
void negate ( )
inline

Change the sign of all the values represented in this node and its child nodes.

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

Return the global coordinates for a linear table offset.

void offsetToLocalCoord ( Index  n,
Coord &  xyz 
)
inlinestatic

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

Index64 offVoxelCount ( ) const
inline
Index64 onLeafVoxelCount ( ) const
inline
Index64 onTileCount ( ) const
inline
Index64 onVoxelCount ( ) const
inline
const Coord& origin ( ) const
inline

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

const ChildT::LeafNodeType * probeConstLeaf ( const Coord &  xyz) const
inline

Return a pointer to the leaf node that contains voxel (x, y, z). If no such node exists, return NULL.

const LeafNodeType* probeConstLeafAndCache ( const Coord &  xyz,
AccessorT &  acc 
) const

Same as probeLeaf() except, if necessary, update the accessor with pointers to the nodes along the path from the root node to the node containing (x, y, z).

const ChildT::LeafNodeType* probeConstLeafAndCache ( const Coord &  xyz,
AccessorT &  acc 
) const
inline
const NodeType* probeConstNode ( const Coord &  xyz) const

Return a pointer to the node that contains voxel (x, y, z). If no such node exists, return NULL.

const NodeT* probeConstNode ( const Coord &  xyz) const
inline
const NodeType* probeConstNodeAndCache ( const Coord &  xyz,
AccessorT &   
) const

Same as probeNode() except, if necessary, update the accessor with pointers to the nodes along the path from the root node to the node containing (x, y, z).

const NodeT* probeConstNodeAndCache ( const Coord &  xyz,
AccessorT &  acc 
) const
inline
ChildT::LeafNodeType * probeLeaf ( const Coord &  xyz)
inline

Return a pointer to the leaf node that contains voxel (x, y, z). If no such node exists, return NULL.

const LeafNodeType* probeLeaf ( const Coord &  xyz) const

Return a pointer to the leaf node that contains voxel (x, y, z). If no such node exists, return NULL.

LeafNodeType* probeLeafAndCache ( const Coord &  xyz,
AccessorT &  acc 
)

Same as probeLeaf() except, if necessary, update the accessor with pointers to the nodes along the path from the root node to the node containing (x, y, z).

const LeafNodeType* probeLeafAndCache ( const Coord &  xyz,
AccessorT &  acc 
) const

Same as probeLeaf() except, if necessary, update the accessor with pointers to the nodes along the path from the root node to the node containing (x, y, z).

ChildT::LeafNodeType* probeLeafAndCache ( const Coord &  xyz,
AccessorT &  acc 
)
inline
const ChildT::LeafNodeType* probeLeafAndCache ( const Coord &  xyz,
AccessorT &  acc 
) const
inline
NodeType* probeNode ( const Coord &  xyz)

Return a pointer to the node that contains voxel (x, y, z). If no such node exists, return NULL.

NodeT* probeNode ( const Coord &  xyz)
inline
NodeType* probeNodeAndCache ( const Coord &  xyz,
AccessorT &   
)

Same as probeNode() except, if necessary, update the accessor with pointers to the nodes along the path from the root node to the node containing (x, y, z).

NodeT* probeNodeAndCache ( const Coord &  xyz,
AccessorT &  acc 
)
inline
bool probeValue ( const Coord &  xyz,
ValueType value 
) const
inline
bool probeValueAndCache ( const Coord &  xyz,
ValueType value,
AccessorT &  acc 
) const
inline

Return, in value, the value of the voxel at the given coordinates and, if necessary, update the accessor with pointers to the nodes along the path from the root node to the node containing the voxel.

Returns
true if the voxel at the given coordinates is active
Note
Used internally by ValueAccessor.
void prune ( const ValueType tolerance = zeroVal<ValueType>())
inline

Reduce the memory footprint of this tree by replacing with tiles any nodes whose values are all the same (optionally to within a tolerance) and have the same active state.

void pruneInactive ( const ValueType bg)
inline

Reduce the memory footprint of this tree by replacing with tiles of the given value any nodes whose values are all inactive.

void pruneInactive ( )
inline

Reduce the memory footprint of this tree by replacing with background tiles any nodes whose values are all inactive.

void pruneOp ( PruneOp &  op)
inline

Call the PruneOp functor for each child node and, if the functor returns true, prune the node and replace it with a tile.

This method is used to implement all of the various pruning algorithms (prune(), pruneInactive(), etc.). It should rarely be called directly.

See Also
openvdb/tree/Util.h for the definition of the PruneOp functor
void readBuffers ( std::istream &  is,
bool  fromHalf = false 
)
inline
void readTopology ( std::istream &  is,
bool  fromHalf = false 
)
inline
void resetBackground ( const ValueType oldBackground,
const ValueType newBackground 
)
inline

Change inactive tiles or voxels with value oldBackground to newBackground or -oldBackground to -newBackground. Active values are unchanged.

void resetChildNode ( Index  i,
ChildNodeType child 
)
inlineprotected
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 setActiveStateAndCache ( const Coord &  xyz,
bool  on,
AccessorT &  acc 
)
inline

Set the active state of the voxel at the given coordinates without changing its value. If necessary, update the accessor with pointers to the nodes along the path from the root node to the node containing the voxel.

Note
Used internally by ValueAccessor.
void setChildNode ( Index  i,
ChildNodeType child 
)
inlineprotected
void setOrigin ( const Coord &  origin)
inline

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

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

Change the value of the voxel at the given coordinates and mark it as active. If necessary, update the accessor with pointers to the nodes along the path from the root node to the node containing the voxel.

Note
Used internally by ValueAccessor.
void setValueMask ( Index  n,
bool  on 
)
inlineprotected

Use a mask accessor to ensure consistency between the child and value masks; i.e., the value mask should always be off wherever the child mask is on.

void setValueOff ( const Coord &  xyz)
inline

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

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

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

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

Change the value of the voxel at the given coordinates and mark it as inactive. If necessary, update the accessor with pointers to the nodes along the path from the root node to the node containing the voxel.

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 ( const Coord &  xyz,
const ValueType value 
)
inline

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

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

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

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

Set the value of the voxel at the given coordinate but preserves its active state. If necessary, update the accessor with pointers to the nodes along the path from the root node to the node containing the voxel.

Note
Used internally by ValueAccessor.
void setValuesOn ( )
inline

Mark all values (both tiles and voxels) as active.

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.

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

Return a pointer to the node of type NodeT that contains voxel (x, y, z) and replace it with a tile of the specified value and state. If no such node exists, leave the tree unchanged and return NULL.

Note
The caller takes ownership of the node and is responsible for deleting it.
Warning
Since this method potentially removes nodes and branches of the tree, it is important to clear the caches of all ValueAccessors associated with this tree.
void topologyDifference ( const InternalNode< OtherChildNodeType, Log2Dim > &  other,
const ValueType background 
)

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 node and inactive in the other node.

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 topologyDifference ( const InternalNode< OtherChildT, Log2Dim > &  other,
const ValueType background 
)
inline
void topologyIntersection ( const InternalNode< OtherChildNodeType, Log2Dim > &  other,
const ValueType background 
)

Intersects this tree's set of active values with the active values of the other tree, whose ValueType may be different.

The resulting state of a value is active only if the corresponding value was already active AND if it is active in the other tree. Also, a resulting value maps to a voxel if the corresponding value already mapped to an active voxel in either of the two grids and it maps to an active tile or voxel in the other grid.

Note
This operation can delete branches in this grid if they overlap with inactive tiles in the other grid. Likewise active voxels can be turned into unactive voxels resulting in leaf nodes with no active values. Thus, it is recommended to subsequently call prune.
void topologyIntersection ( const InternalNode< OtherChildT, Log2Dim > &  other,
const ValueType background 
)
inline
void topologyUnion ( const InternalNode< OtherChildNodeType, Log2Dim > &  other)

Union this branch's set of active values with the other branch's active values. The value type of the other branch can be different.

The resulting state of a value is active if the corresponding value was already active OR if it is active in the other tree. Also, a resulting value maps to a voxel if the corresponding value already mapped to a voxel OR if it is a voxel in the other tree. Thus, a resulting value can only map to a tile if the corresponding value already mapped to a tile AND if it is a tile value in other tree.

Specifically, active tiles and voxels in this branch are not changed, and tiles or voxels that were inactive in this branch but active in the other branch are marked as active in this branch but left with their original values.

void topologyUnion ( const InternalNode< OtherChildT, Log2Dim > &  other)
inline
ChildT::LeafNodeType * touchLeaf ( const Coord &  xyz)
inline

Return the leaf node that contains voxel (x, y, z). If no such node exists, create one, but preserve the values and active states of all voxels.

Use this method to preallocate a static tree topology over which to safely perform multithreaded processing.

LeafNodeType* touchLeafAndCache ( const Coord &  xyz,
AccessorT &   
)

Same as touchLeaf() except, if necessary, update the accessor with pointers to the nodes along the path from the root node to the node containing the coordinate.

ChildT::LeafNodeType* touchLeafAndCache ( const Coord &  xyz,
AccessorT &  acc 
)
inline
ChildT * unsetChildNode ( Index  i,
const ValueType value 
)
inlineprotected
void visit ( VisitorOp &  op)
inline
void visit ( VisitorOp &  op) const
inline
void visit2 ( IterT &  otherIter,
VisitorOp &  ,
bool  otherIsLHS = false 
)
void visit2 ( IterT &  otherIter,
VisitorOp &  ,
bool  otherIsLHS = false 
) const
void visit2 ( OtherChildAllIterType &  otherIter,
VisitorOp &  op,
bool  otherIsLHS 
)
inline
void visit2 ( OtherChildAllIterType &  otherIter,
VisitorOp &  op,
bool  otherIsLHS 
) const
inline
void visit2Node ( OtherNodeType &  other,
VisitorOp &  op 
)
inline
void visit2Node ( OtherNodeType &  other,
VisitorOp &  op 
) const
inline
void visitActiveBBox ( BBoxOp &  op) const
inline

Calls the templated functor BBoxOp with bounding box information for all active tiles and leaf nodes in this node. An additional level argument is provided for each callback.

Note
The bounding boxes are guarenteed to be non-overlapping.
void voxelizeActiveTiles ( )
inline

Densify active tiles, i.e., replace them with leaf-level active voxels.

void writeBuffers ( std::ostream &  os,
bool  toHalf = false 
) const
inline
void writeTopology ( std::ostream &  os,
bool  toHalf = false 
) const
inline

Friends And Related Function Documentation

friend class InternalNode
friend

During topology-only construction, access is needed to protected/private members of other template instances.

friend class IteratorBase< MaskDenseIterator, InternalNode >
friend

Allow iterators to call mask accessor methods (setValueMask(), setChildMask(), etc.).

friend class IteratorBase< MaskOffIterator, InternalNode >
friend

Allow iterators to call mask accessor methods (setValueMask(), setChildMask(), etc.).

friend class IteratorBase< MaskOnIterator, InternalNode >
friend

Allow iterators to call mask accessor methods (setValueMask(), setChildMask(), etc.).

Member Data Documentation

const Index DIM = 1 << TOTAL
static
const Index LEVEL = 1 + ChildNodeType::LEVEL
static
const Index LOG2DIM = Log2Dim
static
NodeMaskType mChildMask
protected
UnionType mNodes[NUM_VALUES]
protected
Coord mOrigin
protected

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

NodeMaskType mValueMask
protected
const Index NUM_VALUES = 1 << (3 * Log2Dim)
static
const Index64 NUM_VOXELS = uint64_t(1) << (3 * TOTAL)
static
const Index TOTAL = Log2Dim + ChildNodeType::TOTAL
static

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