HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
openvdb::OPENVDB_VERSION_NAME::tree::DynamicNodeManager< TreeOrLeafManagerT, _LEVELS > Class Template Reference

#include <NodeManager.h>

Public Types

using NonConstRootNodeType = typename TreeOrLeafManagerT::RootNodeType
 
using RootNodeType = typename CopyConstness< TreeOrLeafManagerT, NonConstRootNodeType >::Type
 
using NonConstChildNodeType = typename RootNodeType::ChildNodeType
 
using ChildNodeType = typename CopyConstness< TreeOrLeafManagerT, NonConstChildNodeType >::Type
 

Public Member Functions

 DynamicNodeManager (TreeOrLeafManagerT &tree)
 
 DynamicNodeManager (const DynamicNodeManager &)=delete
 
const NonConstRootNodeTyperoot () const
 Return a reference to the root node. More...
 
template<typename NodeOp >
void foreachTopDown (const NodeOp &op, bool threaded=true, size_t leafGrainSize=1, size_t nonLeafGrainSize=1)
 Threaded method that applies a user-supplied functor to all the nodes in the tree. More...
 
template<typename NodeOp >
void reduceTopDown (NodeOp &op, bool threaded=true, size_t leafGrainSize=1, size_t nonLeafGrainSize=1)
 Threaded method that processes nodes with a user supplied functor. More...
 

Static Public Attributes

static const Index LEVELS = _LEVELS
 

Protected Attributes

RootNodeTypemRoot
 
DynamicNodeManagerLink
< ChildNodeType, LEVELS-1 > 
mChain
 

Detailed Description

template<typename TreeOrLeafManagerT, Index _LEVELS = TreeOrLeafManagerT::RootNodeType::LEVEL>
class openvdb::OPENVDB_VERSION_NAME::tree::DynamicNodeManager< TreeOrLeafManagerT, _LEVELS >

Definition at line 36 of file NodeManager.h.

Member Typedef Documentation

template<typename TreeOrLeafManagerT, Index _LEVELS = TreeOrLeafManagerT::RootNodeType::LEVEL>
using openvdb::OPENVDB_VERSION_NAME::tree::DynamicNodeManager< TreeOrLeafManagerT, _LEVELS >::ChildNodeType = typename CopyConstness<TreeOrLeafManagerT, NonConstChildNodeType>::Type

Definition at line 898 of file NodeManager.h.

template<typename TreeOrLeafManagerT, Index _LEVELS = TreeOrLeafManagerT::RootNodeType::LEVEL>
using openvdb::OPENVDB_VERSION_NAME::tree::DynamicNodeManager< TreeOrLeafManagerT, _LEVELS >::NonConstChildNodeType = typename RootNodeType::ChildNodeType

Definition at line 897 of file NodeManager.h.

template<typename TreeOrLeafManagerT, Index _LEVELS = TreeOrLeafManagerT::RootNodeType::LEVEL>
using openvdb::OPENVDB_VERSION_NAME::tree::DynamicNodeManager< TreeOrLeafManagerT, _LEVELS >::NonConstRootNodeType = typename TreeOrLeafManagerT::RootNodeType

Definition at line 895 of file NodeManager.h.

template<typename TreeOrLeafManagerT, Index _LEVELS = TreeOrLeafManagerT::RootNodeType::LEVEL>
using openvdb::OPENVDB_VERSION_NAME::tree::DynamicNodeManager< TreeOrLeafManagerT, _LEVELS >::RootNodeType = typename CopyConstness<TreeOrLeafManagerT, NonConstRootNodeType>::Type

Definition at line 896 of file NodeManager.h.

Constructor & Destructor Documentation

template<typename TreeOrLeafManagerT, Index _LEVELS = TreeOrLeafManagerT::RootNodeType::LEVEL>
openvdb::OPENVDB_VERSION_NAME::tree::DynamicNodeManager< TreeOrLeafManagerT, _LEVELS >::DynamicNodeManager ( TreeOrLeafManagerT &  tree)
inlineexplicit

Definition at line 901 of file NodeManager.h.

template<typename TreeOrLeafManagerT, Index _LEVELS = TreeOrLeafManagerT::RootNodeType::LEVEL>
openvdb::OPENVDB_VERSION_NAME::tree::DynamicNodeManager< TreeOrLeafManagerT, _LEVELS >::DynamicNodeManager ( const DynamicNodeManager< TreeOrLeafManagerT, _LEVELS > &  )
delete

Member Function Documentation

template<typename TreeOrLeafManagerT, Index _LEVELS = TreeOrLeafManagerT::RootNodeType::LEVEL>
template<typename NodeOp >
void openvdb::OPENVDB_VERSION_NAME::tree::DynamicNodeManager< TreeOrLeafManagerT, _LEVELS >::foreachTopDown ( const NodeOp &  op,
bool  threaded = true,
size_t  leafGrainSize = 1,
size_t  nonLeafGrainSize = 1 
)
inline

Threaded method that applies a user-supplied functor to all the nodes in the tree.

Parameters
opuser-supplied functor, see examples for interface details.
threadedoptional toggle to disable threading, on by default.
leafGrainSizeoptional parameter to specify the grainsize for threading over leaf nodes, one by default.
nonLeafGrainSizeoptional parameter to specify the grainsize for threading over non-leaf nodes, one by default.
Note
There are two key differences to the interface of the user-supplied functor to the NodeManager class - (1) the operator() method aligns with the LeafManager class in expecting the index of the node in a linear array of identical node types, (2) the operator() method returns a boolean termination value with true indicating that children of this node should be processed, false indicating the early-exit termination should occur.
Unlike the NodeManager, the foreach() method of the DynamicNodeManager uses copy-by-reference for the user-supplied functor. This can be an issue when using a shared Accessor or shared Sampler in the operator as they are not inherently thread-safe. For these use cases, it is recommended to create the Accessor or Sampler in the operator execution itself.
Example:
// Functor to densify the first child node in a linear array. Note
// this implementation also illustrates how different
// computation can be applied to the different node types.
template<typename TreeT>
struct DensifyOp
{
using RootT = typename TreeT::RootNodeType;
using LeafT = typename TreeT::LeafNodeType;
DensifyOp() = default;
// Processes the root node. Required by the DynamicNodeManager
bool operator()(RootT&, size_t) const { return true; }
// Processes the internal nodes. Required by the DynamicNodeManager
template<typename NodeT>
bool operator()(NodeT& node, size_t idx) const
{
// densify child
for (auto iter = node.cbeginValueAll(); iter; ++iter) {
const openvdb::Coord ijk = iter.getCoord();
node.addChild(new typename NodeT::ChildNodeType(iter.getCoord(), NodeT::LEVEL, true));
}
// early-exit termination for all non-zero index children
return idx == 0;
}
// Processes the leaf nodes. Required by the DynamicNodeManager
bool operator()(LeafT&, size_t) const
{
return true;
}
};// DensifyOp
// usage:
DensifyOp<FloatTree> op;
tree::DynamicNodeManager<FloatTree> nodes(tree);
nodes.foreachTopDown(op);

Definition at line 976 of file NodeManager.h.

template<typename TreeOrLeafManagerT, Index _LEVELS = TreeOrLeafManagerT::RootNodeType::LEVEL>
template<typename NodeOp >
void openvdb::OPENVDB_VERSION_NAME::tree::DynamicNodeManager< TreeOrLeafManagerT, _LEVELS >::reduceTopDown ( NodeOp &  op,
bool  threaded = true,
size_t  leafGrainSize = 1,
size_t  nonLeafGrainSize = 1 
)
inline

Threaded method that processes nodes with a user supplied functor.

Parameters
opuser-supplied functor, see examples for interface details.
threadedoptional toggle to disable threading, on by default.
leafGrainSizeoptional parameter to specify the grainsize for threading over leaf nodes, one by default.
nonLeafGrainSizeoptional parameter to specify the grainsize for threading over non-leaf nodes, one by default.
Note
There are two key differences to the interface of the user-supplied functor to the NodeManager class - (1) the operator() method aligns with the LeafManager class in expecting the index of the node in a linear array of identical node types, (2) the operator() method returns a boolean termination value with true indicating that children of this node should be processed, false indicating the early-exit termination should occur.
Example:
// Functor to count nodes in a tree
template<typename TreeType>
struct NodeCountOp
{
NodeCountOp() : nodeCount(TreeType::DEPTH, 0), totalCount(0)
{
}
NodeCountOp(const NodeCountOp& other, tbb::split) :
nodeCount(TreeType::DEPTH, 0), totalCount(0)
{
}
void join(const NodeCountOp& other)
{
for (size_t i = 0; i < nodeCount.size(); ++i) {
nodeCount[i] += other.nodeCount[i];
}
totalCount += other.totalCount;
}
// do nothing for the root node
bool operator()(const typename TreeT::RootNodeType& node, size_t)
{
return true;
}
// count the internal and leaf nodes
template<typename NodeT>
bool operator()(const NodeT& node, size_t)
{
++(nodeCount[NodeT::LEVEL]);
++totalCount;
return true;
}
std::vector<openvdb::Index64> nodeCount;
openvdb::Index64 totalCount;
};
// usage:
NodeCountOp<FloatTree> op;
tree::DynamicNodeManager<FloatTree> nodes(tree);
nodes.reduceTopDown(op);

Definition at line 1043 of file NodeManager.h.

template<typename TreeOrLeafManagerT, Index _LEVELS = TreeOrLeafManagerT::RootNodeType::LEVEL>
const NonConstRootNodeType& openvdb::OPENVDB_VERSION_NAME::tree::DynamicNodeManager< TreeOrLeafManagerT, _LEVELS >::root ( ) const
inline

Return a reference to the root node.

Definition at line 906 of file NodeManager.h.

Member Data Documentation

template<typename TreeOrLeafManagerT, Index _LEVELS = TreeOrLeafManagerT::RootNodeType::LEVEL>
const Index openvdb::OPENVDB_VERSION_NAME::tree::DynamicNodeManager< TreeOrLeafManagerT, _LEVELS >::LEVELS = _LEVELS
static

Definition at line 892 of file NodeManager.h.

template<typename TreeOrLeafManagerT, Index _LEVELS = TreeOrLeafManagerT::RootNodeType::LEVEL>
DynamicNodeManagerLink<ChildNodeType, LEVELS-1> openvdb::OPENVDB_VERSION_NAME::tree::DynamicNodeManager< TreeOrLeafManagerT, _LEVELS >::mChain
protected

Definition at line 1051 of file NodeManager.h.

template<typename TreeOrLeafManagerT, Index _LEVELS = TreeOrLeafManagerT::RootNodeType::LEVEL>
RootNodeType& openvdb::OPENVDB_VERSION_NAME::tree::DynamicNodeManager< TreeOrLeafManagerT, _LEVELS >::mRoot
protected

Definition at line 1050 of file NodeManager.h.


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