To facilitate threading over the nodes of a tree, cache node pointers in linear arrays, one for each level of the tree.
More...
#include <NodeManager.h>
|
| BOOST_STATIC_ASSERT (LEVELS > 0) |
|
| BOOST_STATIC_ASSERT (RootNodeType::LEVEL >=LEVELS) |
|
| NodeManager (TreeOrLeafManagerT &tree) |
|
virtual | ~NodeManager () |
|
void | clear () |
| Clear all the cached tree nodes. More...
|
|
void | rebuild () |
| Clear and recache all the tree nodes from the tree. This is required if tree nodes have been added or removed. More...
|
|
const RootNodeType & | root () const |
| Return a reference to the root node. More...
|
|
Index64 | nodeCount () const |
| Return the total number of cached nodes (excluding the root node) More...
|
|
Index64 | nodeCount (Index i) const |
| Return the number of cached nodes at level i, where 0 corresponds to the lowest level. More...
|
|
|
template<typename NodeOp > |
void | foreachBottomUp (const NodeOp &op, bool threaded=true, size_t grainSize=1) |
| Threaded method that applies a user-supplied functor to all the nodes in the tree. More...
|
|
template<typename NodeOp > |
void | foreachTopDown (const NodeOp &op, bool threaded=true, size_t grainSize=1) |
| Threaded method that applies a user-supplied functor to all the nodes in the tree. More...
|
|
template<typename NodeOp > |
OPENVDB_DEPRECATED void | processBottomUp (const NodeOp &op, bool threaded=true, size_t grainSize=1) |
| Threaded method that applies a user-supplied functor to all the nodes in the tree. More...
|
|
template<typename NodeOp > |
OPENVDB_DEPRECATED void | processTopDown (const NodeOp &op, bool threaded=true, size_t grainSize=1) |
| Threaded method that applies a user-supplied functor to all the nodes in the tree. More...
|
|
|
template<typename NodeOp > |
void | reduceBottomUp (NodeOp &op, bool threaded=true, size_t grainSize=1) |
| Threaded method that processes nodes with a user supplied functor. More...
|
|
template<typename NodeOp > |
void | reduceTopDown (NodeOp &op, bool threaded=true, size_t grainSize=1) |
| Threaded method that processes nodes with a user supplied functor. More...
|
|
template<typename TreeOrLeafManagerT, Index _LEVELS>
class openvdb::v4_0_2::tree::NodeManager< TreeOrLeafManagerT, _LEVELS >
To facilitate threading over the nodes of a tree, cache node pointers in linear arrays, one for each level of the tree.
This implementation works with trees of any depth, but optimized specializations are provided for the most typical tree depths.
◆ RootNodeType
◆ NodeManager()
◆ ~NodeManager()
◆ BOOST_STATIC_ASSERT() [1/2]
BOOST_STATIC_ASSERT |
( |
LEVELS |
, |
|
|
0 |
|
|
) |
| |
◆ BOOST_STATIC_ASSERT() [2/2]
BOOST_STATIC_ASSERT |
( |
RootNodeType::LEVEL >= |
LEVELS | ) |
|
◆ clear()
Clear all the cached tree nodes.
◆ foreachBottomUp()
void foreachBottomUp |
( |
const NodeOp & |
op, |
|
|
bool |
threaded = true , |
|
|
size_t |
grainSize = 1 |
|
) |
| |
|
inline |
Threaded method that applies a user-supplied functor to all the nodes in the tree.
- Parameters
-
op | user-supplied functor, see examples for interface details. |
threaded | optional toggle to disable threading, on by default. |
grainSize | optional parameter to specify the grainsize for threading, one by default. |
- Warning
- The functor object is deep-copied to create TBB tasks.
- Example:
template<typename TreeType>
struct OffsetOp
{
typedef typename TreeT::ValueType ValueT;
typedef typename TreeT::RootNodeType RootT;
typedef typename TreeT::LeafNodeType LeafT;
OffsetOp(const ValueT& v) : mOffset(v) {}
void operator()(RootT&
root)
const {
for (
typename RootT::ValueOffIter
i =
root.beginValueOff();
i; ++
i) *
i += mOffset;
}
void operator()(LeafT& leaf) const
{
for (
typename LeafT::ValueOffIter
i = leaf.beginValueOff();
i; ++
i) *
i += mOffset;
}
template<typename NodeT>
void operator()(NodeT& node) const
{
for (
typename NodeT::ValueOffIter
i = node.beginValueOff();
i; ++
i) *
i += mOffset;
}
private:
const ValueT mOffset;
};
OffsetOp<FloatTree> op(3.0f);
tree::NodeManager<FloatTree> nodes(tree);
nodes.foreachBottomUp(op);
typedef tree::LeafManager<FloatTree> T;
OffsetOp<T> op(3.0f);
tree::NodeManager<T> nodes(leafManager);
nodes.foreachBottomUp(op);
◆ foreachTopDown()
void foreachTopDown |
( |
const NodeOp & |
op, |
|
|
bool |
threaded = true , |
|
|
size_t |
grainSize = 1 |
|
) |
| |
|
inline |
Threaded method that applies a user-supplied functor to all the nodes in the tree.
- Parameters
-
op | user-supplied functor, see examples for interface details. |
threaded | optional toggle to disable threading, on by default. |
grainSize | optional parameter to specify the grainsize for threading, one by default. |
- Warning
- The functor object is deep-copied to create TBB tasks.
- Example:
template<typename TreeType>
struct OffsetOp
{
typedef typename TreeT::ValueType ValueT;
typedef typename TreeT::RootNodeType RootT;
typedef typename TreeT::LeafNodeType LeafT;
OffsetOp(const ValueT& v) : mOffset(v) {}
void operator()(RootT&
root)
const {
for (
typename RootT::ValueOffIter
i =
root.beginValueOff();
i; ++
i) *
i += mOffset;
}
void operator()(LeafT& leaf) const
{
for (
typename LeafT::ValueOffIter
i = leaf.beginValueOff();
i; ++
i) *
i += mOffset;
}
template<typename NodeT>
void operator()(NodeT& node) const
{
for (
typename NodeT::ValueOffIter
i = node.beginValueOff();
i; ++
i) *
i += mOffset;
}
private:
const ValueT mOffset;
};
OffsetOp<FloatTree> op(3.0f);
tree::NodeManager<FloatTree> nodes(tree);
nodes.foreachBottomUp(op);
typedef tree::LeafManager<FloatTree> T;
OffsetOp<T> op(3.0f);
tree::NodeManager<T> nodes(leafManager);
nodes.foreachBottomUp(op);
◆ nodeCount() [1/2]
Return the total number of cached nodes (excluding the root node)
◆ nodeCount() [2/2]
Return the number of cached nodes at level i, where 0 corresponds to the lowest level.
◆ processBottomUp()
OPENVDB_DEPRECATED void processBottomUp |
( |
const NodeOp & |
op, |
|
|
bool |
threaded = true , |
|
|
size_t |
grainSize = 1 |
|
) |
| |
|
inline |
Threaded method that applies a user-supplied functor to all the nodes in the tree.
- Parameters
-
op | user-supplied functor, see examples for interface details. |
threaded | optional toggle to disable threading, on by default. |
grainSize | optional parameter to specify the grainsize for threading, one by default. |
- Warning
- The functor object is deep-copied to create TBB tasks.
- Example:
template<typename TreeType>
struct OffsetOp
{
typedef typename TreeT::ValueType ValueT;
typedef typename TreeT::RootNodeType RootT;
typedef typename TreeT::LeafNodeType LeafT;
OffsetOp(const ValueT& v) : mOffset(v) {}
void operator()(RootT&
root)
const {
for (
typename RootT::ValueOffIter
i =
root.beginValueOff();
i; ++
i) *
i += mOffset;
}
void operator()(LeafT& leaf) const
{
for (
typename LeafT::ValueOffIter
i = leaf.beginValueOff();
i; ++
i) *
i += mOffset;
}
template<typename NodeT>
void operator()(NodeT& node) const
{
for (
typename NodeT::ValueOffIter
i = node.beginValueOff();
i; ++
i) *
i += mOffset;
}
private:
const ValueT mOffset;
};
OffsetOp<FloatTree> op(3.0f);
tree::NodeManager<FloatTree> nodes(tree);
nodes.foreachBottomUp(op);
typedef tree::LeafManager<FloatTree> T;
OffsetOp<T> op(3.0f);
tree::NodeManager<T> nodes(leafManager);
nodes.foreachBottomUp(op);
◆ processTopDown()
OPENVDB_DEPRECATED void processTopDown |
( |
const NodeOp & |
op, |
|
|
bool |
threaded = true , |
|
|
size_t |
grainSize = 1 |
|
) |
| |
|
inline |
Threaded method that applies a user-supplied functor to all the nodes in the tree.
- Parameters
-
op | user-supplied functor, see examples for interface details. |
threaded | optional toggle to disable threading, on by default. |
grainSize | optional parameter to specify the grainsize for threading, one by default. |
- Warning
- The functor object is deep-copied to create TBB tasks.
- Example:
template<typename TreeType>
struct OffsetOp
{
typedef typename TreeT::ValueType ValueT;
typedef typename TreeT::RootNodeType RootT;
typedef typename TreeT::LeafNodeType LeafT;
OffsetOp(const ValueT& v) : mOffset(v) {}
void operator()(RootT&
root)
const {
for (
typename RootT::ValueOffIter
i =
root.beginValueOff();
i; ++
i) *
i += mOffset;
}
void operator()(LeafT& leaf) const
{
for (
typename LeafT::ValueOffIter
i = leaf.beginValueOff();
i; ++
i) *
i += mOffset;
}
template<typename NodeT>
void operator()(NodeT& node) const
{
for (
typename NodeT::ValueOffIter
i = node.beginValueOff();
i; ++
i) *
i += mOffset;
}
private:
const ValueT mOffset;
};
OffsetOp<FloatTree> op(3.0f);
tree::NodeManager<FloatTree> nodes(tree);
nodes.foreachBottomUp(op);
typedef tree::LeafManager<FloatTree> T;
OffsetOp<T> op(3.0f);
tree::NodeManager<T> nodes(leafManager);
nodes.foreachBottomUp(op);
◆ rebuild()
Clear and recache all the tree nodes from the tree. This is required if tree nodes have been added or removed.
◆ reduceBottomUp()
void reduceBottomUp |
( |
NodeOp & |
op, |
|
|
bool |
threaded = true , |
|
|
size_t |
grainSize = 1 |
|
) |
| |
|
inline |
Threaded method that processes nodes with a user supplied functor.
- Parameters
-
op | user-supplied functor, see examples for interface details. |
threaded | optional toggle to disable threading, on by default. |
grainSize | optional parameter to specify the grainsize for threading, one by default. |
- Warning
- The functor object is deep-copied to create TBB tasks.
- Example:
template<typename TreeType>
struct NodeCountOp
{
NodeCountOp() :
nodeCount(TreeType::DEPTH, 0), totalCount(0)
{
}
NodeCountOp(const NodeCountOp& other, tbb::split) :
{
}
void join(const NodeCountOp& other)
{
}
totalCount += other.totalCount;
}
void operator()(const typename TreeT::RootNodeType& node)
{
}
template<typename NodeT>
void operator()(const NodeT& node)
{
++totalCount;
}
};
NodeCountOp<FloatTree> op;
tree::NodeManager<FloatTree> nodes(tree);
nodes.reduceBottomUp(op);
NodeCountOp<FloatTree> op;
typedef tree::LeafManager<FloatTree> T;
T leafManager(tree);
tree::NodeManager<T> nodes(leafManager);
nodes.reduceBottomUp(op);
◆ reduceTopDown()
void reduceTopDown |
( |
NodeOp & |
op, |
|
|
bool |
threaded = true , |
|
|
size_t |
grainSize = 1 |
|
) |
| |
|
inline |
Threaded method that processes nodes with a user supplied functor.
- Parameters
-
op | user-supplied functor, see examples for interface details. |
threaded | optional toggle to disable threading, on by default. |
grainSize | optional parameter to specify the grainsize for threading, one by default. |
- Warning
- The functor object is deep-copied to create TBB tasks.
- Example:
template<typename TreeType>
struct NodeCountOp
{
NodeCountOp() :
nodeCount(TreeType::DEPTH, 0), totalCount(0)
{
}
NodeCountOp(const NodeCountOp& other, tbb::split) :
{
}
void join(const NodeCountOp& other)
{
}
totalCount += other.totalCount;
}
void operator()(const typename TreeT::RootNodeType& node)
{
}
template<typename NodeT>
void operator()(const NodeT& node)
{
++totalCount;
}
};
NodeCountOp<FloatTree> op;
tree::NodeManager<FloatTree> nodes(tree);
nodes.reduceBottomUp(op);
NodeCountOp<FloatTree> op;
typedef tree::LeafManager<FloatTree> T;
T leafManager(tree);
tree::NodeManager<T> nodes(leafManager);
nodes.reduceBottomUp(op);
◆ root()
Return a reference to the root node.
◆ LEVELS
const Index LEVELS = _LEVELS |
|
static |
◆ mChain
◆ mRoot
The documentation for this class was generated from the following file: