41 #ifndef OPENVDB_TREE_NODEMANAGER_HAS_BEEN_INCLUDED 42 #define OPENVDB_TREE_NODEMANAGER_HAS_BEEN_INCLUDED 44 #include <tbb/parallel_for.h> 45 #include <tbb/parallel_reduce.h> 46 #include <openvdb/Types.h> 56 template<
typename TreeOrLeafManagerT, Index LEVELS = TreeOrLeafManagerT::RootNodeType::LEVEL>
66 template<
typename NodeT>
71 typedef std::deque<value_type>
ListT;
75 void push_back(NodeT* node) { mList.push_back(node); }
77 NodeT&
operator()(
size_t n)
const { assert(n<mList.size());
return *(mList[n]); }
79 NodeT*&
operator[](
size_t n) { assert(n<mList.size());
return mList[n]; }
85 void resize(
size_t n) { mList.resize(n); }
92 mEnd(end), mBegin(begin), mGrainSize(grainSize), mNodeList(nodeList) {}
95 mEnd(r.mEnd), mBegin(doSplit(r)), mGrainSize(r.mGrainSize),
96 mNodeList(r.mNodeList) {}
98 size_t size()
const {
return mEnd - mBegin; }
104 bool empty()
const {
return !(mBegin < mEnd);}
113 assert(this->isValid());
117 mRange = other.mRange; mPos = other.mPos;
return *
this;
122 NodeT&
operator*()
const {
return mRange.mNodeList(mPos); }
126 size_t pos()
const {
return mPos; }
127 bool isValid()
const {
return mPos>=mRange.mBegin && mPos<=mRange.mEnd; }
129 bool test()
const {
return mPos < mRange.mEnd; }
131 operator bool()
const {
return this->test(); }
133 bool empty()
const {
return !this->test(); }
136 return (mPos != other.mPos) || (&mRange != &other.mRange);
151 size_t mEnd, mBegin, mGrainSize;
157 size_t middle = r.mBegin + (r.mEnd - r.mBegin) / 2u;
166 return NodeRange(0, this->nodeCount(), *
this, grainsize);
169 template<
typename NodeOp>
170 void foreach(
const NodeOp& op,
bool threaded =
true,
size_t grainSize=1)
172 NodeTransformer<NodeOp> transform(op);
173 transform.run(this->nodeRange(grainSize), threaded);
176 template<
typename NodeOp>
177 void reduce(NodeOp& op,
bool threaded =
true,
size_t grainSize=1)
179 NodeReducer<NodeOp> transform(op);
180 transform.run(this->nodeRange(grainSize), threaded);
186 template<
typename NodeOp>
187 struct NodeTransformer
189 NodeTransformer(
const NodeOp& nodeOp) : mNodeOp(nodeOp)
192 void run(
const NodeRange& range,
bool threaded =
true)
194 threaded ? tbb::parallel_for(range, *
this) : (*this)(range);
196 void operator()(
const NodeRange& range)
const 198 for (
typename NodeRange::Iterator it = range.begin(); it; ++it) mNodeOp(*it);
200 const NodeOp mNodeOp;
204 template<
typename NodeOp>
207 NodeReducer(NodeOp& nodeOp) : mNodeOp(&nodeOp), mOwnsOp(
false)
210 NodeReducer(
const NodeReducer& other, tbb::split) :
211 mNodeOp(
new NodeOp(*(other.mNodeOp), tbb::split())), mOwnsOp(
true)
214 ~NodeReducer() {
if (mOwnsOp)
delete mNodeOp; }
215 void run(
const NodeRange& range,
bool threaded =
true)
217 threaded ? tbb::parallel_reduce(range, *
this) : (*this)(range);
219 void operator()(
const NodeRange& range)
221 NodeOp &op = *mNodeOp;
222 for (
typename NodeRange::Iterator it = range.begin(); it; ++it) op(*it);
224 void join(
const NodeReducer& other)
226 mNodeOp->join(*(other.mNodeOp));
245 template<
typename NodeT, Index LEVEL>
253 void clear() { mList.clear(); mNext.clear(); }
255 template<
typename ParentT,
typename TreeOrLeafManagerT>
256 void init(ParentT& parent, TreeOrLeafManagerT& tree)
258 parent.getNodes(mList);
259 for (
size_t i=0, n=mList.nodeCount(); i<n; ++i) mNext.init(mList(i), tree);
262 template<
typename ParentT>
266 parent.getNodes(mList);
267 for (
size_t i=0, n=mList.nodeCount(); i<n; ++i) mNext.rebuild(mList(i));
274 return i==NodeT::LEVEL ? mList.nodeCount() : mNext.nodeCount(i);
277 template<
typename NodeOp>
280 mNext.foreachBottomUp(op, threaded, grainSize);
281 mList.foreach(op, threaded, grainSize);
284 template<
typename NodeOp>
287 mList.foreach(op, threaded, grainSize);
288 mNext.foreachTopDown(op, threaded, grainSize);
291 template<
typename NodeOp>
294 this->foreachBottomUp<NodeOp>(op, threaded, grainSize);
297 template<
typename NodeOp>
300 this->foreachTopDown<NodeOp>(op, threaded, grainSize);
303 template<
typename NodeOp>
306 mNext.reduceBottomUp(op, threaded, grainSize);
307 mList.reduce(op, threaded, grainSize);
310 template<
typename NodeOp>
313 mList.reduce(op, threaded, grainSize);
314 mNext.reduceTopDown(op, threaded, grainSize);
329 template<
typename NodeT>
340 template<
typename ParentT>
341 void rebuild(ParentT& parent) { mList.clear(); parent.getNodes(mList); }
347 template<
typename NodeOp>
350 mList.foreach(op, threaded, grainSize);
353 template<
typename NodeOp>
356 mList.foreach(op, threaded, grainSize);
359 template<
typename NodeOp>
362 this->foreachBottomUp<NodeOp>(op, threaded, grainSize);
365 template<
typename NodeOp>
368 this->foreachTopDown<NodeOp>(op, threaded, grainSize);
371 template<
typename NodeOp>
374 mList.reduce(op, threaded, grainSize);
377 template<
typename NodeOp>
380 mList.reduce(op, threaded, grainSize);
383 template<
typename ParentT,
typename TreeOrLeafManagerT>
384 void init(ParentT& parent, TreeOrLeafManagerT& tree)
387 if (TreeOrLeafManagerT::DEPTH == 2 && NodeT::LEVEL == 0) {
388 tree.getNodes(mList);
390 parent.getNodes(mList);
407 template<
typename TreeOrLeafManagerT, Index _LEVELS>
411 static const Index LEVELS = _LEVELS;
412 BOOST_STATIC_ASSERT(LEVELS > 0);
414 BOOST_STATIC_ASSERT(RootNodeType::LEVEL >= LEVELS);
416 NodeManager(TreeOrLeafManagerT& tree) : mRoot(tree.root()) { mChain.init(mRoot, tree); }
428 const RootNodeType&
root()
const {
return mRoot; }
438 template<
typename NodeOp>
496 mChain.foreachBottomUp(op, threaded, grainSize);
499 template<
typename NodeOp>
503 mChain.foreachTopDown(op, threaded, grainSize);
505 template<
typename NodeOp>
508 this->foreachBottomUp<NodeOp>(op, threaded, grainSize);
510 template<
typename NodeOp>
513 this->foreachTopDown<NodeOp>(op, threaded, grainSize);
518 template<
typename NodeOp>
578 mChain.reduceBottomUp(op, threaded, grainSize);
582 template<
typename NodeOp>
586 mChain.reduceTopDown(op, threaded, grainSize);
603 template<
typename TreeOrLeafManagerT>
622 const RootNodeType&
root()
const {
return mRoot; }
629 template<
typename NodeOp>
632 template<
typename NodeOp>
635 template<
typename NodeOp>
638 template<
typename NodeOp>
641 template<
typename NodeOp>
644 template<
typename NodeOp>
659 template<
typename TreeOrLeafManagerT>
664 BOOST_STATIC_ASSERT(RootNodeType::LEVEL > 0);
670 if (TreeOrLeafManagerT::DEPTH == 2 && NodeT0::LEVEL == 0) {
671 tree.getNodes(mList0);
673 mRoot.getNodes(mList0);
685 void rebuild() { mList0.clear(); mRoot.getNodes(mList0); }
688 const RootNodeType&
root()
const {
return mRoot; }
697 template<
typename NodeOp>
700 mList0.foreach(op, threaded, grainSize);
704 template<
typename NodeOp>
708 mList0.foreach(op, threaded, grainSize);
710 template<
typename NodeOp>
713 this->foreachBottomUp<NodeOp>(op, threaded, grainSize);
716 template<
typename NodeOp>
719 this->foreachTopDown<NodeOp>(op, threaded, grainSize);
722 template<
typename NodeOp>
725 mList0.reduce(op, threaded, grainSize);
729 template<
typename NodeOp>
733 mList0.reduce(op, threaded, grainSize);
738 typedef typename NodeT1::ChildNodeType
NodeT0;
753 template<
typename TreeOrLeafManagerT>
758 BOOST_STATIC_ASSERT(RootNodeType::LEVEL > 1);
763 mRoot.getNodes(mList1);
766 if (TreeOrLeafManagerT::DEPTH == 2 && NodeT0::LEVEL == 0) {
767 tree.getNodes(mList0);
769 for (
size_t i=0, n=mList1.nodeCount(); i<n; ++i) mList1(i).getNodes(mList0);
777 void clear() { mList0.clear(); mList1.clear(); }
784 mRoot.getNodes(mList1);
785 for (
size_t i=0, n=mList1.nodeCount(); i<n; ++i) mList1(i).getNodes(mList0);
789 const RootNodeType&
root()
const {
return mRoot; }
798 return i==0 ? mList0.nodeCount() : i==1 ? mList1.nodeCount() : 0;
801 template<
typename NodeOp>
804 mList0.foreach(op, threaded, grainSize);
805 mList1.foreach(op, threaded, grainSize);
809 template<
typename NodeOp>
813 mList1.foreach(op, threaded, grainSize);
814 mList0.foreach(op, threaded, grainSize);
817 template<
typename NodeOp>
820 this->foreachBottomUp<NodeOp>(op, threaded, grainSize);
823 template<
typename NodeOp>
826 this->foreachTopDown<NodeOp>(op, threaded, grainSize);
829 template<
typename NodeOp>
832 mList0.reduce(op, threaded, grainSize);
833 mList1.reduce(op, threaded, grainSize);
837 template<
typename NodeOp>
841 mList1.reduce(op, threaded, grainSize);
842 mList0.reduce(op, threaded, grainSize);
847 typedef typename NodeT2::ChildNodeType
NodeT1;
848 typedef typename NodeT1::ChildNodeType
NodeT0;
866 template<
typename TreeOrLeafManagerT>
871 BOOST_STATIC_ASSERT(RootNodeType::LEVEL > 2);
876 mRoot.getNodes(mList2);
877 for (
size_t i=0, n=mList2.nodeCount(); i<n; ++i) mList2(i).getNodes(mList1);
880 if (TreeOrLeafManagerT::DEPTH == 2 && NodeT0::LEVEL == 0) {
881 tree.getNodes(mList0);
883 for (
size_t i=0, n=mList1.nodeCount(); i<n; ++i) mList1(i).getNodes(mList0);
891 void clear() { mList0.clear(); mList1.clear(); mList2.clear(); }
898 mRoot.getNodes(mList2);
899 for (
size_t i=0, n=mList2.nodeCount(); i<n; ++i) mList2(i).getNodes(mList1);
900 for (
size_t i=0, n=mList1.nodeCount(); i<n; ++i) mList1(i).getNodes(mList0);
904 const RootNodeType&
root()
const {
return mRoot; }
907 Index64 nodeCount()
const {
return mList0.nodeCount()+mList1.nodeCount()+mList2.nodeCount(); }
913 return i==0 ? mList0.nodeCount() : i==1 ? mList1.nodeCount()
914 : i==2 ? mList2.nodeCount() : 0;
917 template<
typename NodeOp>
920 mList0.foreach(op, threaded, grainSize);
921 mList1.foreach(op, threaded, grainSize);
922 mList2.foreach(op, threaded, grainSize);
926 template<
typename NodeOp>
930 mList2.foreach(op, threaded, grainSize);
931 mList1.foreach(op, threaded, grainSize);
932 mList0.foreach(op, threaded, grainSize);
935 template<
typename NodeOp>
938 this->foreachBottomUp<NodeOp>(op, threaded, grainSize);
941 template<
typename NodeOp>
944 this->foreachTopDown<NodeOp>(op, threaded, grainSize);
947 template<
typename NodeOp>
950 mList0.reduce(op, threaded, grainSize);
951 mList1.reduce(op, threaded, grainSize);
952 mList2.reduce(op, threaded, grainSize);
956 template<
typename NodeOp>
960 mList2.reduce(op, threaded, grainSize);
961 mList1.reduce(op, threaded, grainSize);
962 mList0.reduce(op, threaded, grainSize);
967 typedef typename NodeT3::ChildNodeType
NodeT2;
968 typedef typename NodeT2::ChildNodeType
NodeT1;
969 typedef typename NodeT1::ChildNodeType
NodeT0;
989 template<
typename TreeOrLeafManagerT>
994 BOOST_STATIC_ASSERT(RootNodeType::LEVEL > 3);
999 mRoot.getNodes(mList3);
1000 for (
size_t i=0, n=mList3.nodeCount(); i<n; ++i) mList3(i).getNodes(mList2);
1001 for (
size_t i=0, n=mList2.nodeCount(); i<n; ++i) mList2(i).getNodes(mList1);
1004 if (TreeOrLeafManagerT::DEPTH == 2 && NodeT0::LEVEL == 0) {
1005 tree.getNodes(mList0);
1007 for (
size_t i=0, n=mList1.nodeCount(); i<n; ++i) mList1(i).getNodes(mList0);
1015 void clear() { mList0.clear(); mList1.clear(); mList2.clear(); mList3.clear; }
1022 mRoot.getNodes(mList3);
1023 for (
size_t i=0, n=mList3.nodeCount(); i<n; ++i) mList3(i).getNodes(mList2);
1024 for (
size_t i=0, n=mList2.nodeCount(); i<n; ++i) mList2(i).getNodes(mList1);
1025 for (
size_t i=0, n=mList1.nodeCount(); i<n; ++i) mList1(i).getNodes(mList0);
1029 const RootNodeType&
root()
const {
return mRoot; }
1034 return mList0.nodeCount() + mList1.nodeCount()
1035 + mList2.nodeCount() + mList3.nodeCount();
1042 return i==0 ? mList0.nodeCount() : i==1 ? mList1.nodeCount() :
1043 i==2 ? mList2.nodeCount() : i==3 ? mList3.nodeCount() : 0;
1046 template<
typename NodeOp>
1049 mList0.foreach(op, threaded, grainSize);
1050 mList1.foreach(op, threaded, grainSize);
1051 mList2.foreach(op, threaded, grainSize);
1052 mList3.foreach(op, threaded, grainSize);
1056 template<
typename NodeOp>
1060 mList3.foreach(op, threaded, grainSize);
1061 mList2.foreach(op, threaded, grainSize);
1062 mList1.foreach(op, threaded, grainSize);
1063 mList0.foreach(op, threaded, grainSize);
1066 template<
typename NodeOp>
1069 this->foreachBottomUp<NodeOp>(op, threaded, grainSize);
1072 template<
typename NodeOp>
1075 this->foreachTopDown<NodeOp>(op, threaded, grainSize);
1078 template<
typename NodeOp>
1081 mList0.reduce(op, threaded, grainSize);
1082 mList1.reduce(op, threaded, grainSize);
1083 mList2.reduce(op, threaded, grainSize);
1084 mList3.reduce(op, threaded, grainSize);
1088 template<
typename NodeOp>
1092 mList3.reduce(op, threaded, grainSize);
1093 mList2.reduce(op, threaded, grainSize);
1094 mList1.reduce(op, threaded, grainSize);
1095 mList0.reduce(op, threaded, grainSize);
1100 typedef typename NodeT4::ChildNodeType
NodeT3;
1101 typedef typename NodeT3::ChildNodeType
NodeT2;
1102 typedef typename NodeT2::ChildNodeType
NodeT1;
1103 typedef typename NodeT1::ChildNodeType
NodeT0;
1124 #endif // OPENVDB_TREE_NODEMANAGER_HAS_BEEN_INCLUDED void clear()
Clear all the cached tree nodes.
Definition: NodeManager.h:421
void rebuild()
Clear and recache all the tree nodes from the tree. This is required if tree nodes have been added or...
Definition: NodeManager.h:895
TreeOrLeafManagerT::RootNodeType RootNodeType
Definition: NodeManager.h:870
NodeList< NodeT1 > ListT1
Definition: NodeManager.h:972
void reduceBottomUp(NodeOp &op, bool, size_t)
Definition: NodeManager.h:642
OPENVDB_DEPRECATED void processTopDown(const NodeOp &op, bool threaded=true, size_t grainSize=1)
Definition: NodeManager.h:942
Iterator end() const
Definition: NodeManager.h:148
TreeOrLeafManagerT::RootNodeType RootNodeType
Definition: NodeManager.h:607
void rebuild(ParentT &parent)
Definition: NodeManager.h:341
OPENVDB_DEPRECATED void processTopDown(const NodeOp &op, bool threaded, size_t grainSize)
Definition: NodeManager.h:366
NodeT1 & mRoot
Definition: NodeManager.h:741
TreeOrLeafManagerT::RootNodeType RootNodeType
Definition: NodeManager.h:663
RootNodeType NodeT1
Definition: NodeManager.h:737
NodeT2::ChildNodeType NodeT1
Definition: NodeManager.h:968
const NodeRange & nodeRange() const
Definition: NodeManager.h:139
void rebuild()
Clear and recache all the tree nodes from the tree. This is required if tree nodes have been added or...
Definition: NodeManager.h:1019
NodeList< NodeT1 > ListT1
Definition: NodeManager.h:850
OPENVDB_DEPRECATED void processTopDown(const NodeOp &op, bool threaded=true, size_t grainSize=1)
Definition: NodeManager.h:824
RootNodeType NodeT4
Definition: NodeManager.h:1099
OPENVDB_DEPRECATED void processTopDown(const NodeOp &op, bool threaded=true, size_t grainSize=1)
Definition: NodeManager.h:1073
This class caches tree nodes of a specific type in a linear array.
Definition: NodeManager.h:67
const RootNodeType & root() const
Return a reference to the root node.
Definition: NodeManager.h:428
Index64 nodeCount() const
Return the total number of cached nodes (excluding the root node)
Definition: NodeManager.h:1032
Iterator(const NodeRange &range, size_t pos)
Definition: NodeManager.h:111
NodeT *& operator[](size_t n)
Definition: NodeManager.h:79
RootNodeType NodeT3
Definition: NodeManager.h:966
NodeT2::ChildNodeType NodeT1
Definition: NodeManager.h:1102
bool operator!=(const Iterator &other) const
Definition: NodeManager.h:134
void foreachBottomUp(const NodeOp &op, bool threaded=true, size_t grainSize=1)
Definition: NodeManager.h:802
void reduce(NodeOp &op, bool threaded=true, size_t grainSize=1)
Definition: NodeManager.h:177
NodeList< NodeT > mList
Definition: NodeManager.h:395
NodeT3::ChildNodeType NodeT2
Definition: NodeManager.h:1101
OPENVDB_DEPRECATED void processBottomUp(const NodeOp &op, bool threaded=true, size_t grainSize=1)
Definition: NodeManager.h:818
Index64 nodeCount(Index i) const
Return the number of cached nodes at level i, where 0 corresponds to the lowest level.
Definition: NodeManager.h:796
Index64 nodeCount() const
Return the total number of cached nodes (excluding the root node)
Definition: NodeManager.h:907
ListT3 mList3
Definition: NodeManager.h:1111
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.
Definition: NodeManager.h:511
void reduceBottomUp(NodeOp &op, bool threaded=true, size_t grainSize=1)
Definition: NodeManager.h:1079
void reduceBottomUp(NodeOp &op, bool threaded, size_t grainSize)
Definition: NodeManager.h:304
const RootNodeType & root() const
Return a reference to the root node.
Definition: NodeManager.h:789
void reduceBottomUp(NodeOp &op, bool threaded=true, size_t grainSize=1)
Definition: NodeManager.h:948
Mat3< typename promote< T0, T1 >::type > operator*(const Mat3< T0 > &m0, const Mat3< T1 > &m1)
Matrix multiplication.
Definition: Mat3.h:658
bool test() const
Return true if this iterator is not yet exhausted.
Definition: NodeManager.h:129
void foreachBottomUp(const NodeOp &op, bool threaded, size_t grainSize)
Definition: NodeManager.h:278
This class is a link in a chain that each caches tree nodes of a specific type in a linear array...
Definition: NodeManager.h:246
bool operator==(const Iterator &other) const
Definition: NodeManager.h:138
NodeT3::ChildNodeType NodeT2
Definition: NodeManager.h:967
void foreachTopDown(const NodeOp &op, bool threaded, size_t grainSize)
Definition: NodeManager.h:285
NodeRange(NodeRange &r, tbb::split)
Definition: NodeManager.h:94
NodeT & operator()(size_t n) const
Definition: NodeManager.h:77
TreeOrLeafManagerT::RootNodeType RootNodeType
Definition: NodeManager.h:413
virtual ~NodeManagerLink()
Definition: NodeManager.h:251
ListT1 mList1
Definition: NodeManager.h:854
void reduceBottomUp(NodeOp &op, bool threaded=true, size_t grainSize=1)
Definition: NodeManager.h:723
NodeT & operator*() const
Return a reference to the node to which this iterator is pointing.
Definition: NodeManager.h:122
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.
Definition: NodeManager.h:500
NodeT4 & mRoot
Definition: NodeManager.h:1110
void rebuild(ParentT &parent)
Definition: NodeManager.h:263
void reduceTopDown(NodeOp &op, bool threaded=true, size_t grainSize=1)
Threaded method that processes nodes with a user supplied functor.
Definition: NodeManager.h:583
OPENVDB_DEPRECATED void processBottomUp(const NodeOp &op, bool threaded=true, size_t grainSize=1)
Definition: NodeManager.h:711
void foreachTopDown(const NodeOp &op, bool, size_t)
Definition: NodeManager.h:639
void foreachTopDown(const NodeOp &op, bool threaded=true, size_t grainSize=1)
Definition: NodeManager.h:927
Iterator begin() const
Definition: NodeManager.h:146
void rebuild()
Clear and recache all the tree nodes from the tree. This is required if tree nodes have been added or...
Definition: NodeManager.h:781
Index64 nodeCount(Index i) const
Definition: NodeManager.h:272
ListT2 mList2
Definition: NodeManager.h:1112
void rebuild()
Clear and recache all the tree nodes from the tree. This is required if tree nodes have been added or...
Definition: NodeManager.h:425
void foreachTopDown(const NodeOp &op, bool threaded=true, size_t grainSize=1)
Definition: NodeManager.h:1057
NodeRange nodeRange(size_t grainsize=1) const
Return a TBB-compatible NodeRange.
Definition: NodeManager.h:164
RootNodeType & mRoot
Definition: NodeManager.h:591
const RootNodeType & root() const
Return a reference to the root node.
Definition: NodeManager.h:622
NodeList< NodeT0 > ListT0
Definition: NodeManager.h:739
Index32 Index
Definition: Types.h:58
ListT2 mList2
Definition: NodeManager.h:976
const RootNodeType & root() const
Return a reference to the root node.
Definition: NodeManager.h:688
Index64 nodeCount() const
Return the total number of cached nodes (excluding the root node)
Definition: NodeManager.h:792
NodeT * operator->() const
Return a pointer to the node to which this iterator is pointing.
Definition: NodeManager.h:124
ListT0 mList0
Definition: NodeManager.h:855
uint64_t Index64
Definition: Types.h:57
Index64 nodeCount() const
Return the total number of cached nodes (excluding the root node)
Definition: NodeManager.h:625
RootNodeType NodeT2
Definition: NodeManager.h:846
#define OPENVDB_VERSION_NAME
Definition: version.h:43
Index64 nodeCount() const
Return the total number of cached nodes (excluding the root node)
Definition: NodeManager.h:691
OPENVDB_DEPRECATED void processBottomUp(const NodeOp &op, bool threaded=true, size_t grainSize=1)
Definition: NodeManager.h:1067
void reduceBottomUp(NodeOp &op, bool threaded=true, size_t grainSize=1)
Threaded method that processes nodes with a user supplied functor.
Definition: NodeManager.h:576
Index64 nodeCount(Index i) const
Return the number of cached nodes at level i, where 0 corresponds to the lowest level.
Definition: NodeManager.h:1040
OPENVDB_DEPRECATED void processBottomUp(const NodeOp &op, bool threaded=true, size_t grainSize=1)
Definition: NodeManager.h:936
void init(ParentT &parent, TreeOrLeafManagerT &tree)
Definition: NodeManager.h:256
void foreachTopDown(const NodeOp &op, bool threaded=true, size_t grainSize=1)
Definition: NodeManager.h:705
ListT0 mList0
Definition: NodeManager.h:978
OPENVDB_DEPRECATED void processTopDown(const NodeOp &op, bool, size_t)
Definition: NodeManager.h:633
void clear()
Clear all the cached tree nodes.
Definition: NodeManager.h:681
NodeT1::ChildNodeType NodeT0
Definition: NodeManager.h:848
ListT0 mList0
Definition: NodeManager.h:1114
void clear()
Clear all the cached tree nodes.
Definition: NodeManager.h:615
virtual ~NodeManagerLink()
Definition: NodeManager.h:335
NodeManagerLink()
Definition: NodeManager.h:249
Index64 nodeCount(Index i) const
Return the number of cached nodes at level i, where 0 corresponds to the lowest level.
Definition: NodeManager.h:911
Definition: Exceptions.h:39
void reduceTopDown(NodeOp &op, bool threaded, size_t grainSize)
Definition: NodeManager.h:311
NodeList< NodeT3 > ListT3
Definition: NodeManager.h:1105
NodeList< NodeT > mList
Definition: NodeManager.h:318
void foreachBottomUp(const NodeOp &op, bool, size_t)
Definition: NodeManager.h:636
NodeT2::ChildNodeType NodeT1
Definition: NodeManager.h:847
void init(ParentT &parent, TreeOrLeafManagerT &tree)
Definition: NodeManager.h:384
void reduceTopDown(NodeOp &op, bool threaded=true, size_t grainSize=1)
Definition: NodeManager.h:730
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.
Definition: NodeManager.h:494
void clear()
Clear all the cached tree nodes.
Definition: NodeManager.h:338
virtual ~NodeManager()
Definition: NodeManager.h:418
bool empty() const
Definition: NodeManager.h:104
bool isValid() const
Definition: NodeManager.h:127
NodeList< NodeT0 > ListT0
Definition: NodeManager.h:973
OPENVDB_DEPRECATED void processTopDown(const NodeOp &op, bool threaded, size_t grainSize)
Definition: NodeManager.h:298
NodeList()
Definition: NodeManager.h:73
ListT1 mList1
Definition: NodeManager.h:977
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.
Definition: NodeManager.h:506
NodeList< NodeT0 > ListT0
Definition: NodeManager.h:851
NodeList< NodeT0 > ListT0
Definition: NodeManager.h:1108
ListT1 mList1
Definition: NodeManager.h:1113
TreeOrLeafManagerT::RootNodeType RootNodeType
Definition: NodeManager.h:757
Index64 nodeCount(Index) const
Definition: NodeManager.h:627
size_t size() const
Definition: NodeManager.h:98
const RootNodeType & root() const
Return a reference to the root node.
Definition: NodeManager.h:1029
Index64 nodeCount() const
Definition: NodeManager.h:81
Index64 nodeCount() const
Definition: NodeManager.h:343
bool is_divisible() const
Definition: NodeManager.h:106
size_t grainsize() const
Definition: NodeManager.h:100
NodeManagerLink()
Definition: NodeManager.h:333
NodeManager(TreeOrLeafManagerT &tree)
Definition: NodeManager.h:874
void reduceTopDown(NodeOp &op, bool threaded, size_t grainSize)
Definition: NodeManager.h:378
NodeManagerLink< typename RootNodeType::ChildNodeType, LEVELS-1 > mChain
Definition: NodeManager.h:592
NodeManager(TreeOrLeafManagerT &tree)
Definition: NodeManager.h:416
Index64 nodeCount() const
Definition: NodeManager.h:270
void clear()
Definition: NodeManager.h:253
To facilitate threading over the nodes of a tree, cache node pointers in linear arrays, one for each level of the tree.
Definition: NodeManager.h:57
NodeList< NodeT2 > ListT2
Definition: NodeManager.h:971
NodeT * value_type
Definition: NodeManager.h:70
void rebuild()
Clear and recache all the tree nodes from the tree. This is required if tree nodes have been added or...
Definition: NodeManager.h:685
virtual ~NodeManager()
Definition: NodeManager.h:612
const RootNodeType & root() const
Return a reference to the root node.
Definition: NodeManager.h:904
NodeList< NodeT2 > ListT2
Definition: NodeManager.h:1106
void reduceBottomUp(NodeOp &op, bool threaded=true, size_t grainSize=1)
Definition: NodeManager.h:830
const NodeList & nodeList() const
Definition: NodeManager.h:102
OPENVDB_DEPRECATED void processBottomUp(const NodeOp &op, bool threaded, size_t grainSize)
Definition: NodeManager.h:292
void rebuild()
Clear and recache all the tree nodes from the tree. This is required if tree nodes have been added or...
Definition: NodeManager.h:619
virtual ~NodeManager()
Definition: NodeManager.h:678
NodeManager(TreeOrLeafManagerT &tree)
Definition: NodeManager.h:997
void foreachTopDown(const NodeOp &op, bool threaded, size_t grainSize)
Definition: NodeManager.h:354
NodeT1::ChildNodeType NodeT0
Definition: NodeManager.h:738
Index64 nodeCount(Index i) const
Return the number of cached nodes at level i, where 0 corresponds to the lowest level.
Definition: NodeManager.h:695
RootNodeType & mRoot
Definition: NodeManager.h:648
Iterator & operator=(const Iterator &other)
Definition: NodeManager.h:115
void foreachBottomUp(const NodeOp &op, bool threaded=true, size_t grainSize=1)
Definition: NodeManager.h:698
void foreachTopDown(const NodeOp &op, bool threaded=true, size_t grainSize=1)
Definition: NodeManager.h:810
NodeT2 & mRoot
Definition: NodeManager.h:853
void push_back(NodeT *node)
Definition: NodeManager.h:75
void clear()
Clear all the cached tree nodes.
Definition: NodeManager.h:1015
NodeT3 & mRoot
Definition: NodeManager.h:975
ListT0 mList0
Definition: NodeManager.h:742
virtual ~NodeManager()
Definition: NodeManager.h:1012
NodeT1::ChildNodeType NodeT0
Definition: NodeManager.h:969
NodeManager(TreeOrLeafManagerT &tree)
Definition: NodeManager.h:667
bool empty() const
Return true if this iterator is exhausted.
Definition: NodeManager.h:133
OPENVDB_DEPRECATED void processBottomUp(const NodeOp &op, bool, size_t)
Definition: NodeManager.h:630
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h:71
void clear()
Clear all the cached tree nodes.
Definition: NodeManager.h:891
void clear()
Definition: NodeManager.h:83
void foreachBottomUp(const NodeOp &op, bool threaded, size_t grainSize)
Definition: NodeManager.h:348
NodeManagerLink< typename NodeT::ChildNodeType, LEVEL-1 > mNext
Definition: NodeManager.h:319
Definition: NodeManager.h:87
NodeT1::ChildNodeType NodeT0
Definition: NodeManager.h:1103
NodeManager(TreeOrLeafManagerT &tree)
Definition: NodeManager.h:610
NodeT4::ChildNodeType NodeT3
Definition: NodeManager.h:1100
void reduceTopDown(NodeOp &op, bool threaded=true, size_t grainSize=1)
Definition: NodeManager.h:1089
void foreachBottomUp(const NodeOp &op, bool threaded=true, size_t grainSize=1)
Definition: NodeManager.h:1047
void reduceBottomUp(NodeOp &op, bool threaded, size_t grainSize)
Definition: NodeManager.h:372
Definition: NodeManager.h:108
size_t pos() const
Return the index into the list of the current node.
Definition: NodeManager.h:126
OPENVDB_DEPRECATED void processBottomUp(const NodeOp &op, bool threaded, size_t grainSize)
Definition: NodeManager.h:360
Index64 nodeCount(Index) const
Definition: NodeManager.h:345
virtual ~NodeManager()
Definition: NodeManager.h:888
ListT mList
Definition: NodeManager.h:234
void clear()
Clear all the cached tree nodes.
Definition: NodeManager.h:777
Iterator & operator++()
Advance to the next node.
Definition: NodeManager.h:120
TreeOrLeafManagerT::RootNodeType RootNodeType
Definition: NodeManager.h:993
NodeRange(size_t begin, size_t end, const NodeList &nodeList, size_t grainSize=1)
Definition: NodeManager.h:91
void reduceTopDown(NodeOp &op, bool, size_t)
Definition: NodeManager.h:645
virtual ~NodeManager()
Definition: NodeManager.h:774
NodeManager(TreeOrLeafManagerT &tree)
Definition: NodeManager.h:761
void reduceTopDown(NodeOp &op, bool threaded=true, size_t grainSize=1)
Definition: NodeManager.h:957
std::deque< value_type > ListT
Definition: NodeManager.h:71
Index64 nodeCount(Index i) const
Return the number of cached nodes at level i, where 0 corresponds to the lowest level.
Definition: NodeManager.h:435
void foreachBottomUp(const NodeOp &op, bool threaded=true, size_t grainSize=1)
Definition: NodeManager.h:918
OPENVDB_DEPRECATED void processTopDown(const NodeOp &op, bool threaded=true, size_t grainSize=1)
Definition: NodeManager.h:717
void resize(size_t n)
Definition: NodeManager.h:85
void reduceTopDown(NodeOp &op, bool threaded=true, size_t grainSize=1)
Definition: NodeManager.h:838
Index64 nodeCount() const
Return the total number of cached nodes (excluding the root node)
Definition: NodeManager.h:431
NodeList< NodeT1 > ListT1
Definition: NodeManager.h:1107