OpenVDB: NodeManager.h Source File

OpenVDB 3.2.0

NodeManager.h
Go to the documentation of this file.
1 //
3 // Copyright (c) 2012-2016 DreamWorks Animation LLC
4 //
5 // All rights reserved. This software is distributed under the
6 // Mozilla Public License 2.0 ( http://www.mozilla.org/MPL/2.0/ )
7 //
8 // Redistributions of source code must retain the above copyright
9 // and license notice and the following restrictions and disclaimer.
10 //
11 // * Neither the name of DreamWorks Animation nor the names of
12 // its contributors may be used to endorse or promote products derived
13 // from this software without specific prior written permission.
14 //
15 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
18 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
19 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY INDIRECT, INCIDENTAL,
20 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
21 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 // IN NO EVENT SHALL THE COPYRIGHT HOLDERS' AND CONTRIBUTORS' AGGREGATE
27 // LIABILITY FOR ALL CLAIMS REGARDLESS OF THEIR BASIS EXCEED US$250.00.
28 //
30 //
40
41 #ifndef OPENVDB_TREE_NODEMANAGER_HAS_BEEN_INCLUDED
42 #define OPENVDB_TREE_NODEMANAGER_HAS_BEEN_INCLUDED
43
44 #include <tbb/parallel_for.h>
45 #include <tbb/parallel_reduce.h>
46 #include <openvdb/Types.h>
47 #include <deque>
48
49 namespace openvdb {
50 OPENVDB_USE_VERSION_NAMESPACE
51 namespace OPENVDB_VERSION_NAME {
52 namespace tree {
53
54 // Produce linear arrays of all tree nodes, to facilitate efficient threading
55 // and bottom-up processing.
56 template<typename TreeOrLeafManagerT, Index LEVELS = TreeOrLeafManagerT::RootNodeType::LEVEL>
57 class NodeManager;
58
59
61
62
66 template<typename NodeT>
67 class NodeList
68 {
69 public:
70 typedef NodeT* value_type;
71 typedef std::deque<value_type> ListT;
72
73 NodeList() {}
74
75 void push_back(NodeT* node) { mList.push_back(node); }
76
77 NodeT& operator()(size_t n) const { assert(n<mList.size()); return *(mList[n]); }
78
79 NodeT*& operator[](size_t n) { assert(n<mList.size()); return mList[n]; }
80
81 Index64 nodeCount() const { return mList.size(); }
82
83 void clear() { mList.clear(); }
84
85 void resize(size_t n) { mList.resize(n); }
86
87 class NodeRange
88 {
89 public:
90
91 NodeRange(size_t begin, size_t end, const NodeList& nodeList, size_t grainSize=1):
92 mEnd(end), mBegin(begin), mGrainSize(grainSize), mNodeList(nodeList) {}
93
94 NodeRange(NodeRange& r, tbb::split):
95 mEnd(r.mEnd), mBegin(doSplit(r)), mGrainSize(r.mGrainSize),
96 mNodeList(r.mNodeList) {}
97
98 size_t size() const { return mEnd - mBegin; }
99
100 size_t grainsize() const { return mGrainSize; }
101
102 const NodeList& nodeList() const { return mNodeList; }
103
104 bool empty() const {return !(mBegin < mEnd);}
105
106 bool is_divisible() const {return mGrainSize < this->size();}
107
108 class Iterator
109 {
110 public:
111 Iterator(const NodeRange& range, size_t pos): mRange(range), mPos(pos)
112 {
113 assert(this->isValid());
114 }
115 Iterator& operator=(const Iterator& other)
116 {
117 mRange = other.mRange; mPos = other.mPos; return *this;
118 }
120 Iterator& operator++() { ++mPos; return *this; }
122 NodeT& operator*() const { return mRange.mNodeList(mPos); }
124 NodeT* operator->() const { return &(this->operator*()); }
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(); }
134 bool operator!=(const Iterator& other) const
135 {
136 return (mPos != other.mPos) || (&mRange != &other.mRange);
137 }
138 bool operator==(const Iterator& other) const { return !(*this != other); }
139 const NodeRange& nodeRange() const { return mRange; }
140
141 private:
142 const NodeRange& mRange;
143 size_t mPos;
144 };// NodeList::NodeRange::Iterator
145
146 Iterator begin() const {return Iterator(*this, mBegin);}
147
148 Iterator end() const {return Iterator(*this, mEnd);}
149
150 private:
151 size_t mEnd, mBegin, mGrainSize;
152 const NodeList& mNodeList;
153
154 static size_t doSplit(NodeRange& r)
155 {
156 assert(r.is_divisible());
157 size_t middle = r.mBegin + (r.mEnd - r.mBegin) / 2u;
158 r.mEnd = middle;
159 return middle;
160 }
161 };// NodeList::NodeRange
162
164 NodeRange nodeRange(size_t grainsize = 1) const
165 {
166 return NodeRange(0, this->nodeCount(), *this, grainsize);
167 }
168
169 template<typename NodeOp>
170 void foreach(const NodeOp& op, bool threaded = true, size_t grainSize=1)
171 {
172 NodeTransformer<NodeOp> transform(op);
173 transform.run(this->nodeRange(grainSize), threaded);
174 }
175
176 template<typename NodeOp>
177 void reduce(NodeOp& op, bool threaded = true, size_t grainSize=1)
178 {
179 NodeReducer<NodeOp> transform(op);
180 transform.run(this->nodeRange(grainSize), threaded);
181 }
182
183 private:
184
185 // Private struct of NodeList that performs parallel_for
186 template<typename NodeOp>
187 struct NodeTransformer
188 {
189 NodeTransformer(const NodeOp& nodeOp) : mNodeOp(nodeOp)
190 {
191 }
192 void run(const NodeRange& range, bool threaded = true)
193 {
194 threaded ? tbb::parallel_for(range, *this) : (*this)(range);
195 }
196 void operator()(const NodeRange& range) const
197 {
198 for (typename NodeRange::Iterator it = range.begin(); it; ++it) mNodeOp(*it);
199 }
200 const NodeOp mNodeOp;
201 };// NodeList::NodeTransformer
202
203 // Private struct of NodeList that performs parallel_reduce
204 template<typename NodeOp>
205 struct NodeReducer
206 {
207 NodeReducer(NodeOp& nodeOp) : mNodeOp(&nodeOp), mOwnsOp(false)
208 {
209 }
210 NodeReducer(const NodeReducer& other, tbb::split) :
211 mNodeOp(new NodeOp(*(other.mNodeOp), tbb::split())), mOwnsOp(true)
212 {
213 }
214 ~NodeReducer() { if (mOwnsOp) delete mNodeOp; }
215 void run(const NodeRange& range, bool threaded = true)
216 {
217 threaded ? tbb::parallel_reduce(range, *this) : (*this)(range);
218 }
219 void operator()(const NodeRange& range)
220 {
221 NodeOp &op = *mNodeOp;
222 for (typename NodeRange::Iterator it = range.begin(); it; ++it) op(*it);
223 }
224 void join(const NodeReducer& other)
225 {
226 mNodeOp->join(*(other.mNodeOp));
227 }
228 NodeOp *mNodeOp;
229 const bool mOwnsOp;
230 };// NodeList::NodeReducer
231
232
233 protected:
234 ListT mList;
235 };// NodeList
236
237
239
240
245 template<typename NodeT, Index LEVEL>
246 class NodeManagerLink
247 {
248 public:
249 NodeManagerLink() {}
250
251 virtual ~NodeManagerLink() {}
252
253 void clear() { mList.clear(); mNext.clear(); }
254
255 template<typename ParentT, typename TreeOrLeafManagerT>
256 void init(ParentT& parent, TreeOrLeafManagerT& tree)
257 {
258 parent.getNodes(mList);
259 for (size_t i=0, n=mList.nodeCount(); i<n; ++i) mNext.init(mList(i), tree);
260 }
261
262 template<typename ParentT>
263 void rebuild(ParentT& parent)
264 {
265 mList.clear();
266 parent.getNodes(mList);
267 for (size_t i=0, n=mList.nodeCount(); i<n; ++i) mNext.rebuild(mList(i));
268 }
269
270 Index64 nodeCount() const { return mList.nodeCount() + mNext.nodeCount(); }
271
272 Index64 nodeCount(Index i) const
273 {
274 return i==NodeT::LEVEL ? mList.nodeCount() : mNext.nodeCount(i);
275 }
276
277 template<typename NodeOp>
278 void foreachBottomUp(const NodeOp& op, bool threaded, size_t grainSize)
279 {
280 mNext.foreachBottomUp(op, threaded, grainSize);
281 mList.foreach(op, threaded, grainSize);
282 }
283
284 template<typename NodeOp>
285 void foreachTopDown(const NodeOp& op, bool threaded, size_t grainSize)
286 {
287 mList.foreach(op, threaded, grainSize);
288 mNext.foreachTopDown(op, threaded, grainSize);
289 }
290
291 template<typename NodeOp>
292 OPENVDB_DEPRECATED void processBottomUp(const NodeOp& op, bool threaded, size_t grainSize)
293 {
294 this->foreachBottomUp<NodeOp>(op, threaded, grainSize);
295 }
296
297 template<typename NodeOp>
298 OPENVDB_DEPRECATED void processTopDown(const NodeOp& op, bool threaded, size_t grainSize)
299 {
300 this->foreachTopDown<NodeOp>(op, threaded, grainSize);
301 }
302
303 template<typename NodeOp>
304 void reduceBottomUp(NodeOp& op, bool threaded, size_t grainSize)
305 {
306 mNext.reduceBottomUp(op, threaded, grainSize);
307 mList.reduce(op, threaded, grainSize);
308 }
309
310 template<typename NodeOp>
311 void reduceTopDown(NodeOp& op, bool threaded, size_t grainSize)
312 {
313 mList.reduce(op, threaded, grainSize);
314 mNext.reduceTopDown(op, threaded, grainSize);
315 }
316
317 protected:
318 NodeList<NodeT> mList;
319 NodeManagerLink<typename NodeT::ChildNodeType, LEVEL-1> mNext;
320 };// NodeManagerLink class
321
322
324
325
329 template<typename NodeT>
330 class NodeManagerLink<NodeT, 0>
331 {
332 public:
333 NodeManagerLink() {}
334
335 virtual ~NodeManagerLink() {}
336
338 void clear() { mList.clear(); }
339
340 template<typename ParentT>
341 void rebuild(ParentT& parent) { mList.clear(); parent.getNodes(mList); }
342
343 Index64 nodeCount() const { return mList.nodeCount(); }
344
345 Index64 nodeCount(Index) const { return mList.nodeCount(); }
346
347 template<typename NodeOp>
348 void foreachBottomUp(const NodeOp& op, bool threaded, size_t grainSize)
349 {
350 mList.foreach(op, threaded, grainSize);
351 }
352
353 template<typename NodeOp>
354 void foreachTopDown(const NodeOp& op, bool threaded, size_t grainSize)
355 {
356 mList.foreach(op, threaded, grainSize);
357 }
358
359 template<typename NodeOp>
360 OPENVDB_DEPRECATED void processBottomUp(const NodeOp& op, bool threaded, size_t grainSize)
361 {
362 this->foreachBottomUp<NodeOp>(op, threaded, grainSize);
363 }
364
365 template<typename NodeOp>
366 OPENVDB_DEPRECATED void processTopDown(const NodeOp& op, bool threaded, size_t grainSize)
367 {
368 this->foreachTopDown<NodeOp>(op, threaded, grainSize);
369 }
370
371 template<typename NodeOp>
372 void reduceBottomUp(NodeOp& op, bool threaded, size_t grainSize)
373 {
374 mList.reduce(op, threaded, grainSize);
375 }
376
377 template<typename NodeOp>
378 void reduceTopDown(NodeOp& op, bool threaded, size_t grainSize)
379 {
380 mList.reduce(op, threaded, grainSize);
381 }
382
383 template<typename ParentT, typename TreeOrLeafManagerT>
384 void init(ParentT& parent, TreeOrLeafManagerT& tree)
385 {
386 OPENVDB_NO_UNREACHABLE_CODE_WARNING_BEGIN
387 if (TreeOrLeafManagerT::DEPTH == 2 && NodeT::LEVEL == 0) {
388 tree.getNodes(mList);
389 } else {
390 parent.getNodes(mList);
391 }
392 OPENVDB_NO_UNREACHABLE_CODE_WARNING_END
393 }
394 protected:
395 NodeList<NodeT> mList;
396 };// NodeManagerLink class
397
398
400
401
407 template<typename TreeOrLeafManagerT, Index _LEVELS>
408 class NodeManager
409 {
410 public:
411 static const Index LEVELS = _LEVELS;
412 BOOST_STATIC_ASSERT(LEVELS > 0);//special implementation below
413 typedef typename TreeOrLeafManagerT::RootNodeType RootNodeType;
414 BOOST_STATIC_ASSERT(RootNodeType::LEVEL >= LEVELS);
415
416 NodeManager(TreeOrLeafManagerT& tree) : mRoot(tree.root()) { mChain.init(mRoot, tree); }
417
418 virtual ~NodeManager() {}
419
421 void clear() { mChain.clear(); }
422
425 void rebuild() { mChain.rebuild(mRoot); }
426
428 const RootNodeType& root() const { return mRoot; }
429
431 Index64 nodeCount() const { return mChain.nodeCount(); }
432
435 Index64 nodeCount(Index i) const { return mChain.nodeCount(i); }
436
438 template<typename NodeOp>
494 void foreachBottomUp(const NodeOp& op, bool threaded = true, size_t grainSize=1)
495 {
496 mChain.foreachBottomUp(op, threaded, grainSize);
497 op(mRoot);
498 }
499 template<typename NodeOp>
500 void foreachTopDown(const NodeOp& op, bool threaded = true, size_t grainSize=1)
501 {
502 op(mRoot);
503 mChain.foreachTopDown(op, threaded, grainSize);
504 }
505 template<typename NodeOp>
506 OPENVDB_DEPRECATED void processBottomUp(const NodeOp& op, bool threaded = true, size_t grainSize=1)
507 {
508 this->foreachBottomUp<NodeOp>(op, threaded, grainSize);
509 }
510 template<typename NodeOp>
511 OPENVDB_DEPRECATED void processTopDown(const NodeOp& op, bool threaded = true, size_t grainSize=1)
512 {
513 this->foreachTopDown<NodeOp>(op, threaded, grainSize);
514 }
516
518 template<typename NodeOp>
576 void reduceBottomUp(NodeOp& op, bool threaded = true, size_t grainSize=1)
577 {
578 mChain.reduceBottomUp(op, threaded, grainSize);
579 op(mRoot);
580 }
581
582 template<typename NodeOp>
583 void reduceTopDown(NodeOp& op, bool threaded = true, size_t grainSize=1)
584 {
585 op(mRoot);
586 mChain.reduceTopDown(op, threaded, grainSize);
587 }
589
590 protected:
591 RootNodeType& mRoot;
592 NodeManagerLink<typename RootNodeType::ChildNodeType, LEVELS-1> mChain;
593
594 private:
595 NodeManager(const NodeManager&) {}//disallow copy-construction
596 };// NodeManager class
597
598
600
601
603 template<typename TreeOrLeafManagerT>
604 class NodeManager<TreeOrLeafManagerT, 0>
605 {
606 public:
607 typedef typename TreeOrLeafManagerT::RootNodeType RootNodeType;
608 static const Index LEVELS = 0;
609
610 NodeManager(TreeOrLeafManagerT& tree) : mRoot(tree.root()) {}
611
612 virtual ~NodeManager() {}
613
615 void clear() {}
616
619 void rebuild() {}
620
622 const RootNodeType& root() const { return mRoot; }
623
625 Index64 nodeCount() const { return 0; }
626
627 Index64 nodeCount(Index) const { return 0; }
628
629 template<typename NodeOp>
630 OPENVDB_DEPRECATED void processBottomUp(const NodeOp& op, bool, size_t) { op(mRoot); }
631
632 template<typename NodeOp>
633 OPENVDB_DEPRECATED void processTopDown(const NodeOp& op, bool, size_t) { op(mRoot); }
634
635 template<typename NodeOp>
636 void foreachBottomUp(const NodeOp& op, bool, size_t) { op(mRoot); }
637
638 template<typename NodeOp>
639 void foreachTopDown(const NodeOp& op, bool, size_t) { op(mRoot); }
640
641 template<typename NodeOp>
642 void reduceBottomUp(NodeOp& op, bool, size_t) { op(mRoot); }
643
644 template<typename NodeOp>
645 void reduceTopDown(NodeOp& op, bool, size_t) { op(mRoot); }
646
647 protected:
648 RootNodeType& mRoot;
649
650 private:
651 NodeManager(const NodeManager&) {} // disallow copy-construction
652 }; // NodeManager<0>
653
654
656
657
659 template<typename TreeOrLeafManagerT>
660 class NodeManager<TreeOrLeafManagerT, 1>
661 {
662 public:
663 typedef typename TreeOrLeafManagerT::RootNodeType RootNodeType;
664 BOOST_STATIC_ASSERT(RootNodeType::LEVEL > 0);
665 static const Index LEVELS = 1;
666
667 NodeManager(TreeOrLeafManagerT& tree) : mRoot(tree.root())
668 {
669 OPENVDB_NO_UNREACHABLE_CODE_WARNING_BEGIN
670 if (TreeOrLeafManagerT::DEPTH == 2 && NodeT0::LEVEL == 0) {
671 tree.getNodes(mList0);
672 } else {
673 mRoot.getNodes(mList0);
674 }
675 OPENVDB_NO_UNREACHABLE_CODE_WARNING_END
676 }
677
678 virtual ~NodeManager() {}
679
681 void clear() { mList0.clear(); }
682
685 void rebuild() { mList0.clear(); mRoot.getNodes(mList0); }
686
688 const RootNodeType& root() const { return mRoot; }
689
691 Index64 nodeCount() const { return mList0.nodeCount(); }
692
695 Index64 nodeCount(Index i) const { return i==0 ? mList0.nodeCount() : 0; }
696
697 template<typename NodeOp>
698 void foreachBottomUp(const NodeOp& op, bool threaded = true, size_t grainSize=1)
699 {
700 mList0.foreach(op, threaded, grainSize);
701 op(mRoot);
702 }
703
704 template<typename NodeOp>
705 void foreachTopDown(const NodeOp& op, bool threaded = true, size_t grainSize=1)
706 {
707 op(mRoot);
708 mList0.foreach(op, threaded, grainSize);
709 }
710 template<typename NodeOp>
711 OPENVDB_DEPRECATED void processBottomUp(const NodeOp& op, bool threaded = true, size_t grainSize=1)
712 {
713 this->foreachBottomUp<NodeOp>(op, threaded, grainSize);
714 }
715
716 template<typename NodeOp>
717 OPENVDB_DEPRECATED void processTopDown(const NodeOp& op, bool threaded = true, size_t grainSize=1)
718 {
719 this->foreachTopDown<NodeOp>(op, threaded, grainSize);
720 }
721
722 template<typename NodeOp>
723 void reduceBottomUp(NodeOp& op, bool threaded = true, size_t grainSize=1)
724 {
725 mList0.reduce(op, threaded, grainSize);
726 op(mRoot);
727 }
728
729 template<typename NodeOp>
730 void reduceTopDown(NodeOp& op, bool threaded = true, size_t grainSize=1)
731 {
732 op(mRoot);
733 mList0.reduce(op, threaded, grainSize);
734 }
735
736 protected:
737 typedef RootNodeType NodeT1;
738 typedef typename NodeT1::ChildNodeType NodeT0;
739 typedef NodeList<NodeT0> ListT0;
740
741 NodeT1& mRoot;
742 ListT0 mList0;
743
744 private:
745 NodeManager(const NodeManager&) {} // disallow copy-construction
746 }; // NodeManager<1>
747
748
750
751
753 template<typename TreeOrLeafManagerT>
754 class NodeManager<TreeOrLeafManagerT, 2>
755 {
756 public:
757 typedef typename TreeOrLeafManagerT::RootNodeType RootNodeType;
758 BOOST_STATIC_ASSERT(RootNodeType::LEVEL > 1);
759 static const Index LEVELS = 2;
760
761 NodeManager(TreeOrLeafManagerT& tree) : mRoot(tree.root())
762 {
763 mRoot.getNodes(mList1);
764
765 OPENVDB_NO_UNREACHABLE_CODE_WARNING_BEGIN
766 if (TreeOrLeafManagerT::DEPTH == 2 && NodeT0::LEVEL == 0) {
767 tree.getNodes(mList0);
768 } else {
769 for (size_t i=0, n=mList1.nodeCount(); i<n; ++i) mList1(i).getNodes(mList0);
770 }
771 OPENVDB_NO_UNREACHABLE_CODE_WARNING_END
772 }
773
774 virtual ~NodeManager() {}
775
777 void clear() { mList0.clear(); mList1.clear(); }
778
781 void rebuild()
782 {
783 this->clear();
784 mRoot.getNodes(mList1);
785 for (size_t i=0, n=mList1.nodeCount(); i<n; ++i) mList1(i).getNodes(mList0);
786 }
787
789 const RootNodeType& root() const { return mRoot; }
790
792 Index64 nodeCount() const { return mList0.nodeCount() + mList1.nodeCount(); }
793
796 Index64 nodeCount(Index i) const
797 {
798 return i==0 ? mList0.nodeCount() : i==1 ? mList1.nodeCount() : 0;
799 }
800
801 template<typename NodeOp>
802 void foreachBottomUp(const NodeOp& op, bool threaded = true, size_t grainSize=1)
803 {
804 mList0.foreach(op, threaded, grainSize);
805 mList1.foreach(op, threaded, grainSize);
806 op(mRoot);
807 }
808
809 template<typename NodeOp>
810 void foreachTopDown(const NodeOp& op, bool threaded = true, size_t grainSize=1)
811 {
812 op(mRoot);
813 mList1.foreach(op, threaded, grainSize);
814 mList0.foreach(op, threaded, grainSize);
815 }
816
817 template<typename NodeOp>
818 OPENVDB_DEPRECATED void processBottomUp(const NodeOp& op, bool threaded = true, size_t grainSize=1)
819 {
820 this->foreachBottomUp<NodeOp>(op, threaded, grainSize);
821 }
822
823 template<typename NodeOp>
824 OPENVDB_DEPRECATED void processTopDown(const NodeOp& op, bool threaded = true, size_t grainSize=1)
825 {
826 this->foreachTopDown<NodeOp>(op, threaded, grainSize);
827 }
828
829 template<typename NodeOp>
830 void reduceBottomUp(NodeOp& op, bool threaded = true, size_t grainSize=1)
831 {
832 mList0.reduce(op, threaded, grainSize);
833 mList1.reduce(op, threaded, grainSize);
834 op(mRoot);
835 }
836
837 template<typename NodeOp>
838 void reduceTopDown(NodeOp& op, bool threaded = true, size_t grainSize=1)
839 {
840 op(mRoot);
841 mList1.reduce(op, threaded, grainSize);
842 mList0.reduce(op, threaded, grainSize);
843 }
844
845 protected:
846 typedef RootNodeType NodeT2;
847 typedef typename NodeT2::ChildNodeType NodeT1;//upper level
848 typedef typename NodeT1::ChildNodeType NodeT0;//lower level
849
850 typedef NodeList<NodeT1> ListT1;//upper level
851 typedef NodeList<NodeT0> ListT0;//lower level
852
853 NodeT2& mRoot;
854 ListT1 mList1;
855 ListT0 mList0;
856
857 private:
858 NodeManager(const NodeManager&) {} // disallow copy-construction
859 }; // NodeManager<2>
860
861
863
864
866 template<typename TreeOrLeafManagerT>
867 class NodeManager<TreeOrLeafManagerT, 3>
868 {
869 public:
870 typedef typename TreeOrLeafManagerT::RootNodeType RootNodeType;
871 BOOST_STATIC_ASSERT(RootNodeType::LEVEL > 2);
872 static const Index LEVELS = 3;
873
874 NodeManager(TreeOrLeafManagerT& tree) : mRoot(tree.root())
875 {
876 mRoot.getNodes(mList2);
877 for (size_t i=0, n=mList2.nodeCount(); i<n; ++i) mList2(i).getNodes(mList1);
878
879 OPENVDB_NO_UNREACHABLE_CODE_WARNING_BEGIN
880 if (TreeOrLeafManagerT::DEPTH == 2 && NodeT0::LEVEL == 0) {
881 tree.getNodes(mList0);
882 } else {
883 for (size_t i=0, n=mList1.nodeCount(); i<n; ++i) mList1(i).getNodes(mList0);
884 }
885 OPENVDB_NO_UNREACHABLE_CODE_WARNING_END
886 }
887
888 virtual ~NodeManager() {}
889
891 void clear() { mList0.clear(); mList1.clear(); mList2.clear(); }
892
895 void rebuild()
896 {
897 this->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);
901 }
902
904 const RootNodeType& root() const { return mRoot; }
905
907 Index64 nodeCount() const { return mList0.nodeCount()+mList1.nodeCount()+mList2.nodeCount(); }
908
911 Index64 nodeCount(Index i) const
912 {
913 return i==0 ? mList0.nodeCount() : i==1 ? mList1.nodeCount()
914 : i==2 ? mList2.nodeCount() : 0;
915 }
916
917 template<typename NodeOp>
918 void foreachBottomUp(const NodeOp& op, bool threaded = true, size_t grainSize=1)
919 {
920 mList0.foreach(op, threaded, grainSize);
921 mList1.foreach(op, threaded, grainSize);
922 mList2.foreach(op, threaded, grainSize);
923 op(mRoot);
924 }
925
926 template<typename NodeOp>
927 void foreachTopDown(const NodeOp& op, bool threaded = true, size_t grainSize=1)
928 {
929 op(mRoot);
930 mList2.foreach(op, threaded, grainSize);
931 mList1.foreach(op, threaded, grainSize);
932 mList0.foreach(op, threaded, grainSize);
933 }
934
935 template<typename NodeOp>
936 OPENVDB_DEPRECATED void processBottomUp(const NodeOp& op, bool threaded = true, size_t grainSize=1)
937 {
938 this->foreachBottomUp<NodeOp>(op, threaded, grainSize);
939 }
940
941 template<typename NodeOp>
942 OPENVDB_DEPRECATED void processTopDown(const NodeOp& op, bool threaded = true, size_t grainSize=1)
943 {
944 this->foreachTopDown<NodeOp>(op, threaded, grainSize);
945 }
946
947 template<typename NodeOp>
948 void reduceBottomUp(NodeOp& op, bool threaded = true, size_t grainSize=1)
949 {
950 mList0.reduce(op, threaded, grainSize);
951 mList1.reduce(op, threaded, grainSize);
952 mList2.reduce(op, threaded, grainSize);
953 op(mRoot);
954 }
955
956 template<typename NodeOp>
957 void reduceTopDown(NodeOp& op, bool threaded = true, size_t grainSize=1)
958 {
959 op(mRoot);
960 mList2.reduce(op, threaded, grainSize);
961 mList1.reduce(op, threaded, grainSize);
962 mList0.reduce(op, threaded, grainSize);
963 }
964
965 protected:
966 typedef RootNodeType NodeT3;
967 typedef typename NodeT3::ChildNodeType NodeT2;//upper level
968 typedef typename NodeT2::ChildNodeType NodeT1;//mid level
969 typedef typename NodeT1::ChildNodeType NodeT0;//lower level
970
971 typedef NodeList<NodeT2> ListT2;//upper level of internal nodes
972 typedef NodeList<NodeT1> ListT1;//lower level of internal nodes
973 typedef NodeList<NodeT0> ListT0;//lower level of internal nodes or leafs
974
975 NodeT3& mRoot;
976 ListT2 mList2;
977 ListT1 mList1;
978 ListT0 mList0;
979
980 private:
981 NodeManager(const NodeManager&) {} // disallow copy-construction
982 }; // NodeManager<3>
983
984
986
987
989 template<typename TreeOrLeafManagerT>
990 class NodeManager<TreeOrLeafManagerT, 4>
991 {
992 public:
993 typedef typename TreeOrLeafManagerT::RootNodeType RootNodeType;
994 BOOST_STATIC_ASSERT(RootNodeType::LEVEL > 3);
995 static const Index LEVELS = 4;
996
997 NodeManager(TreeOrLeafManagerT& tree) : mRoot(tree.root())
998 {
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);
1002
1003 OPENVDB_NO_UNREACHABLE_CODE_WARNING_BEGIN
1004 if (TreeOrLeafManagerT::DEPTH == 2 && NodeT0::LEVEL == 0) {
1005 tree.getNodes(mList0);
1006 } else {
1007 for (size_t i=0, n=mList1.nodeCount(); i<n; ++i) mList1(i).getNodes(mList0);
1008 }
1009 OPENVDB_NO_UNREACHABLE_CODE_WARNING_END
1010 }
1011
1012 virtual ~NodeManager() {}
1013
1015 void clear() { mList0.clear(); mList1.clear(); mList2.clear(); mList3.clear; }
1016
1019 void rebuild()
1020 {
1021 this->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);
1026 }
1027
1029 const RootNodeType& root() const { return mRoot; }
1030
1032 Index64 nodeCount() const
1033 {
1034 return mList0.nodeCount() + mList1.nodeCount()
1035 + mList2.nodeCount() + mList3.nodeCount();
1036 }
1037
1040 Index64 nodeCount(Index i) const
1041 {
1042 return i==0 ? mList0.nodeCount() : i==1 ? mList1.nodeCount() :
1043 i==2 ? mList2.nodeCount() : i==3 ? mList3.nodeCount() : 0;
1044 }
1045
1046 template<typename NodeOp>
1047 void foreachBottomUp(const NodeOp& op, bool threaded = true, size_t grainSize=1)
1048 {
1049 mList0.foreach(op, threaded, grainSize);
1050 mList1.foreach(op, threaded, grainSize);
1051 mList2.foreach(op, threaded, grainSize);
1052 mList3.foreach(op, threaded, grainSize);
1053 op(mRoot);
1054 }
1055
1056 template<typename NodeOp>
1057 void foreachTopDown(const NodeOp& op, bool threaded = true, size_t grainSize=1)
1058 {
1059 op(mRoot);
1060 mList3.foreach(op, threaded, grainSize);
1061 mList2.foreach(op, threaded, grainSize);
1062 mList1.foreach(op, threaded, grainSize);
1063 mList0.foreach(op, threaded, grainSize);
1064 }
1065
1066 template<typename NodeOp>
1067 OPENVDB_DEPRECATED void processBottomUp(const NodeOp& op, bool threaded = true, size_t grainSize=1)
1068 {
1069 this->foreachBottomUp<NodeOp>(op, threaded, grainSize);
1070 }
1071
1072 template<typename NodeOp>
1073 OPENVDB_DEPRECATED void processTopDown(const NodeOp& op, bool threaded = true, size_t grainSize=1)
1074 {
1075 this->foreachTopDown<NodeOp>(op, threaded, grainSize);
1076 }
1077
1078 template<typename NodeOp>
1079 void reduceBottomUp(NodeOp& op, bool threaded = true, size_t grainSize=1)
1080 {
1081 mList0.reduce(op, threaded, grainSize);
1082 mList1.reduce(op, threaded, grainSize);
1083 mList2.reduce(op, threaded, grainSize);
1084 mList3.reduce(op, threaded, grainSize);
1085 op(mRoot);
1086 }
1087
1088 template<typename NodeOp>
1089 void reduceTopDown(NodeOp& op, bool threaded = true, size_t grainSize=1)
1090 {
1091 op(mRoot);
1092 mList3.reduce(op, threaded, grainSize);
1093 mList2.reduce(op, threaded, grainSize);
1094 mList1.reduce(op, threaded, grainSize);
1095 mList0.reduce(op, threaded, grainSize);
1096 }
1097
1098 protected:
1099 typedef RootNodeType NodeT4;
1100 typedef typename NodeT4::ChildNodeType NodeT3;//upper level
1101 typedef typename NodeT3::ChildNodeType NodeT2;//upper mid level
1102 typedef typename NodeT2::ChildNodeType NodeT1;//lower mid level
1103 typedef typename NodeT1::ChildNodeType NodeT0;//lower level
1104
1105 typedef NodeList<NodeT3> ListT3;//upper level of internal nodes
1106 typedef NodeList<NodeT2> ListT2;//upper mid level of internal nodes
1107 typedef NodeList<NodeT1> ListT1;//lower mid level of internal nodes
1108 typedef NodeList<NodeT0> ListT0;//lower level of internal nodes or leafs
1109
1110 NodeT4& mRoot;
1111 ListT3 mList3;
1112 ListT2 mList2;
1113 ListT1 mList1;
1114 ListT0 mList0;
1115
1116 private:
1117 NodeManager(const NodeManager&) {} // disallow copy-construction
1118 }; // NodeManager<4>
1119
1120 } // namespace tree
1121 } // namespace OPENVDB_VERSION_NAME
1122 } // namespace openvdb
1123
1124 #endif // OPENVDB_TREE_NODEMANAGER_HAS_BEEN_INCLUDED
1125
1126 // Copyright (c) 2012-2016 DreamWorks Animation LLC
1127 // All rights reserved. This software is distributed under the
1128 // Mozilla Public License 2.0 ( http://www.mozilla.org/MPL/2.0/ )
openvdb::v3_2_0::tree::NodeManagerLink::nodeCount
Index64 nodeCount() const
Definition: NodeManager.h:270
openvdb::v3_2_0::tree::NodeManager::clear
void clear()
Clear all the cached tree nodes.
Definition: NodeManager.h:421
openvdb::v3_2_0::tree::NodeManager< TreeOrLeafManagerT, 3 >::rebuild
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
openvdb::v3_2_0::tree::NodeManager< TreeOrLeafManagerT, 3 >::RootNodeType
TreeOrLeafManagerT::RootNodeType RootNodeType
Definition: NodeManager.h:870
openvdb::v3_2_0::tree::NodeManager< TreeOrLeafManagerT, 3 >::ListT1
NodeList< NodeT1 > ListT1
Definition: NodeManager.h:972
openvdb::v3_2_0::tree::NodeManager< TreeOrLeafManagerT, 0 >::reduceBottomUp
void reduceBottomUp(NodeOp &op, bool, size_t)
Definition: NodeManager.h:642
openvdb::v3_2_0::tree::NodeManager< TreeOrLeafManagerT, 3 >::processTopDown
OPENVDB_DEPRECATED void processTopDown(const NodeOp &op, bool threaded=true, size_t grainSize=1)
Definition: NodeManager.h:942
openvdb::v3_2_0::tree::NodeManager< TreeOrLeafManagerT, 0 >::RootNodeType
TreeOrLeafManagerT::RootNodeType RootNodeType
Definition: NodeManager.h:607
openvdb::v3_2_0::tree::NodeManagerLink< NodeT, 0 >::rebuild
void rebuild(ParentT &parent)
Definition: NodeManager.h:341
openvdb::v3_2_0::tree::NodeList::NodeRange::end
Iterator end() const
Definition: NodeManager.h:148
openvdb::v3_2_0::tree::NodeManagerLink< NodeT, 0 >::processTopDown
OPENVDB_DEPRECATED void processTopDown(const NodeOp &op, bool threaded, size_t grainSize)
Definition: NodeManager.h:366
openvdb::v3_2_0::tree::NodeManager< TreeOrLeafManagerT, 1 >::nodeCount
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
Types.h
openvdb::v3_2_0::tree::NodeManager< TreeOrLeafManagerT, 1 >::mRoot
NodeT1 & mRoot
Definition: NodeManager.h:741
OPENVDB_DEPRECATED
#define OPENVDB_DEPRECATED
Definition: Platform.h:49
openvdb::v3_2_0::tree::NodeManager< TreeOrLeafManagerT, 1 >::RootNodeType
TreeOrLeafManagerT::RootNodeType RootNodeType
Definition: NodeManager.h:663
openvdb::v3_2_0::tree::NodeManager< TreeOrLeafManagerT, 1 >::NodeT1
RootNodeType NodeT1
Definition: NodeManager.h:737
openvdb::v3_2_0::tree::NodeManager< TreeOrLeafManagerT, 3 >::NodeT1
NodeT2::ChildNodeType NodeT1
Definition: NodeManager.h:968
openvdb::v3_2_0::tree::NodeManager< TreeOrLeafManagerT, 4 >::rebuild
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
openvdb::v3_2_0::tree::NodeManager< TreeOrLeafManagerT, 2 >::ListT1
NodeList< NodeT1 > ListT1
Definition: NodeManager.h:850
openvdb::v3_2_0::tree::NodeManager< TreeOrLeafManagerT, 2 >::nodeCount
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
openvdb::v3_2_0::tree::NodeManager< TreeOrLeafManagerT, 2 >::processTopDown
OPENVDB_DEPRECATED void processTopDown(const NodeOp &op, bool threaded=true, size_t grainSize=1)
Definition: NodeManager.h:824
openvdb::v3_2_0::tree::NodeManager< TreeOrLeafManagerT, 4 >::NodeT4
RootNodeType NodeT4
Definition: NodeManager.h:1099
openvdb::v3_2_0::tree::NodeManager< TreeOrLeafManagerT, 0 >::nodeCount
Index64 nodeCount() const
Return the total number of cached nodes (excluding the root node)
Definition: NodeManager.h:625
openvdb::v3_2_0::tree::NodeManager< TreeOrLeafManagerT, 4 >::processTopDown
OPENVDB_DEPRECATED void processTopDown(const NodeOp &op, bool threaded=true, size_t grainSize=1)
Definition: NodeManager.h:1073
openvdb::v3_2_0::tree::NodeList::NodeRange::begin
Iterator begin() const
Definition: NodeManager.h:146
openvdb::v3_2_0::tree::NodeList
This class caches tree nodes of a specific type in a linear array.
Definition: NodeManager.h:67
openvdb::v3_2_0::tree::NodeManager< TreeOrLeafManagerT, 1 >::nodeCount
Index64 nodeCount() const
Return the total number of cached nodes (excluding the root node)
Definition: NodeManager.h:691
openvdb::v3_2_0::tree::NodeList::NodeRange::Iterator::Iterator
Iterator(const NodeRange &range, size_t pos)
Definition: NodeManager.h:111
openvdb::v3_2_0::tree::NodeList::operator[]
NodeT *& operator[](size_t n)
Definition: NodeManager.h:79
openvdb::v3_2_0::tree::NodeList::NodeRange::is_divisible
bool is_divisible() const
Definition: NodeManager.h:106
openvdb::v3_2_0::tree::NodeManager< TreeOrLeafManagerT, 3 >::NodeT3
RootNodeType NodeT3
Definition: NodeManager.h:966
openvdb::v3_2_0::tree::NodeManager::nodeCount
Index64 nodeCount() const
Return the total number of cached nodes (excluding the root node)
Definition: NodeManager.h:431
openvdb::v3_2_0::tree::NodeManager< TreeOrLeafManagerT, 4 >::NodeT1
NodeT2::ChildNodeType NodeT1
Definition: NodeManager.h:1102
openvdb::v3_2_0::tree::NodeList::NodeRange::Iterator::operator!=
bool operator!=(const Iterator &other) const
Definition: NodeManager.h:134
openvdb::v3_2_0::tree::NodeManager< TreeOrLeafManagerT, 2 >::foreachBottomUp
void foreachBottomUp(const NodeOp &op, bool threaded=true, size_t grainSize=1)
Definition: NodeManager.h:802
openvdb::v3_2_0::tree::NodeList::reduce
void reduce(NodeOp &op, bool threaded=true, size_t grainSize=1)
Definition: NodeManager.h:177
openvdb::v3_2_0::tree::NodeManager< TreeOrLeafManagerT, 3 >::nodeCount
Index64 nodeCount() const
Return the total number of cached nodes (excluding the root node)
Definition: NodeManager.h:907
openvdb::v3_2_0::tree::NodeManagerLink< NodeT, 0 >::mList
NodeList< NodeT > mList
Definition: NodeManager.h:395
openvdb::v3_2_0::tree::NodeManager< TreeOrLeafManagerT, 4 >::NodeT2
NodeT3::ChildNodeType NodeT2
Definition: NodeManager.h:1101
openvdb::v3_2_0::tree::NodeManager< TreeOrLeafManagerT, 2 >::processBottomUp
OPENVDB_DEPRECATED void processBottomUp(const NodeOp &op, bool threaded=true, size_t grainSize=1)
Definition: NodeManager.h:818
openvdb::v3_2_0::tree::NodeManager< TreeOrLeafManagerT, 4 >::nodeCount
Index64 nodeCount() const
Return the total number of cached nodes (excluding the root node)
Definition: NodeManager.h:1032
openvdb::v3_2_0::tree::NodeManager< TreeOrLeafManagerT, 4 >::mList3
ListT3 mList3
Definition: NodeManager.h:1111
openvdb::v3_2_0::tree::NodeManager::processTopDown
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
openvdb::v3_2_0::tree::NodeManager< TreeOrLeafManagerT, 4 >::reduceBottomUp
void reduceBottomUp(NodeOp &op, bool threaded=true, size_t grainSize=1)
Definition: NodeManager.h:1079
openvdb::v3_2_0::tree::NodeManagerLink::reduceBottomUp
void reduceBottomUp(NodeOp &op, bool threaded, size_t grainSize)
Definition: NodeManager.h:304
openvdb::v3_2_0::tree::NodeManager< TreeOrLeafManagerT, 3 >::reduceBottomUp
void reduceBottomUp(NodeOp &op, bool threaded=true, size_t grainSize=1)
Definition: NodeManager.h:948
openvdb::v3_2_0::math::operator*
Mat3< typename promote< T0, T1 >::type > operator*(const Mat3< T0 > &m0, const Mat3< T1 > &m1)
Matrix multiplication.
Definition: Mat3.h:658
openvdb::v3_2_0::tree::NodeManagerLink::foreachBottomUp
void foreachBottomUp(const NodeOp &op, bool threaded, size_t grainSize)
Definition: NodeManager.h:278
openvdb::v3_2_0::tree::NodeManagerLink
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
openvdb::v3_2_0::tree::NodeManager< TreeOrLeafManagerT, 3 >::NodeT2
NodeT3::ChildNodeType NodeT2
Definition: NodeManager.h:967
openvdb::v3_2_0::tree::NodeManagerLink::foreachTopDown
void foreachTopDown(const NodeOp &op, bool threaded, size_t grainSize)
Definition: NodeManager.h:285
openvdb::v3_2_0::tree::NodeList::NodeRange::NodeRange
NodeRange(NodeRange &r, tbb::split)
Definition: NodeManager.h:94
openvdb::v3_2_0::tree::NodeManager::RootNodeType
TreeOrLeafManagerT::RootNodeType RootNodeType
Definition: NodeManager.h:413
openvdb::v3_2_0::tree::NodeManagerLink::~NodeManagerLink
virtual ~NodeManagerLink()
Definition: NodeManager.h:251
openvdb::v3_2_0::tree::NodeManager< TreeOrLeafManagerT, 2 >::mList1
ListT1 mList1
Definition: NodeManager.h:854
openvdb::v3_2_0::tree::NodeManager< TreeOrLeafManagerT, 1 >::reduceBottomUp
void reduceBottomUp(NodeOp &op, bool threaded=true, size_t grainSize=1)
Definition: NodeManager.h:723
openvdb::v3_2_0::tree::NodeManager::foreachTopDown
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
openvdb::v3_2_0::tree::NodeManager< TreeOrLeafManagerT, 4 >::mRoot
NodeT4 & mRoot
Definition: NodeManager.h:1110
openvdb::v3_2_0::tree::NodeManagerLink::rebuild
void rebuild(ParentT &parent)
Definition: NodeManager.h:263
openvdb::v3_2_0::tree::NodeManager::reduceTopDown
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::v3_2_0::tree::NodeManager< TreeOrLeafManagerT, 1 >::processBottomUp
OPENVDB_DEPRECATED void processBottomUp(const NodeOp &op, bool threaded=true, size_t grainSize=1)
Definition: NodeManager.h:711
openvdb::v3_2_0::tree::NodeList::NodeRange::size
size_t size() const
Definition: NodeManager.h:98
openvdb::v3_2_0::tree::NodeManager< TreeOrLeafManagerT, 0 >::foreachTopDown
void foreachTopDown(const NodeOp &op, bool, size_t)
Definition: NodeManager.h:639
openvdb::v3_2_0::tree::NodeManager< TreeOrLeafManagerT, 3 >::foreachTopDown
void foreachTopDown(const NodeOp &op, bool threaded=true, size_t grainSize=1)
Definition: NodeManager.h:927
openvdb::v3_2_0::tree::NodeManager< TreeOrLeafManagerT, 2 >::rebuild
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
openvdb::v3_2_0::tree::NodeManager< TreeOrLeafManagerT, 4 >::mList2
ListT2 mList2
Definition: NodeManager.h:1112
openvdb::v3_2_0::tree::NodeManager::rebuild
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
openvdb::v3_2_0::tree::NodeManager< TreeOrLeafManagerT, 4 >::foreachTopDown
void foreachTopDown(const NodeOp &op, bool threaded=true, size_t grainSize=1)
Definition: NodeManager.h:1057
openvdb::v3_2_0::tree::NodeManager::mRoot
RootNodeType & mRoot
Definition: NodeManager.h:591
openvdb::v3_2_0::tree::NodeManager::nodeCount
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
openvdb::v3_2_0::tree::NodeManager< TreeOrLeafManagerT, 1 >::ListT0
NodeList< NodeT0 > ListT0
Definition: NodeManager.h:739
openvdb::v3_2_0::Index
Index32 Index
Definition: Types.h:58
openvdb::v3_2_0::tree::NodeManager< TreeOrLeafManagerT, 3 >::mList2
ListT2 mList2
Definition: NodeManager.h:976
openvdb::v3_2_0::tree::NodeList::NodeRange::Iterator::operator->
NodeT * operator->() const
Return a pointer to the node to which this iterator is pointing.
Definition: NodeManager.h:124
openvdb::v3_2_0::tree::NodeManager< TreeOrLeafManagerT, 2 >::mList0
ListT0 mList0
Definition: NodeManager.h:855
openvdb::v3_2_0::Index64
uint64_t Index64
Definition: Types.h:57
openvdb::v3_2_0::tree::NodeManager< TreeOrLeafManagerT, 2 >::NodeT2
RootNodeType NodeT2
Definition: NodeManager.h:846
OPENVDB_VERSION_NAME
#define OPENVDB_VERSION_NAME
Definition: version.h:43
openvdb::v3_2_0::tree::NodeManager< TreeOrLeafManagerT, 4 >::processBottomUp
OPENVDB_DEPRECATED void processBottomUp(const NodeOp &op, bool threaded=true, size_t grainSize=1)
Definition: NodeManager.h:1067
openvdb::v3_2_0::tree::NodeManager::reduceBottomUp
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
openvdb::v3_2_0::tree::NodeManager< TreeOrLeafManagerT, 2 >::root
const RootNodeType & root() const
Return a reference to the root node.
Definition: NodeManager.h:789
openvdb::v3_2_0::tree::NodeManager< TreeOrLeafManagerT, 0 >::nodeCount
Index64 nodeCount(Index) const
Definition: NodeManager.h:627
openvdb::v3_2_0::tree::NodeManager< TreeOrLeafManagerT, 3 >::processBottomUp
OPENVDB_DEPRECATED void processBottomUp(const NodeOp &op, bool threaded=true, size_t grainSize=1)
Definition: NodeManager.h:936
openvdb::v3_2_0::tree::NodeManagerLink::init
void init(ParentT &parent, TreeOrLeafManagerT &tree)
Definition: NodeManager.h:256
openvdb::v3_2_0::tree::NodeManager< TreeOrLeafManagerT, 1 >::foreachTopDown
void foreachTopDown(const NodeOp &op, bool threaded=true, size_t grainSize=1)
Definition: NodeManager.h:705
openvdb::v3_2_0::tree::NodeManager< TreeOrLeafManagerT, 3 >::mList0
ListT0 mList0
Definition: NodeManager.h:978
openvdb::v3_2_0::tree::NodeManager< TreeOrLeafManagerT, 0 >::processTopDown
OPENVDB_DEPRECATED void processTopDown(const NodeOp &op, bool, size_t)
Definition: NodeManager.h:633
openvdb::v3_2_0::tree::NodeManager< TreeOrLeafManagerT, 1 >::clear
void clear()
Clear all the cached tree nodes.
Definition: NodeManager.h:681
openvdb::v3_2_0::tree::NodeManager< TreeOrLeafManagerT, 2 >::NodeT0
NodeT1::ChildNodeType NodeT0
Definition: NodeManager.h:848
openvdb::v3_2_0::tree::NodeManager< TreeOrLeafManagerT, 4 >::mList0
ListT0 mList0
Definition: NodeManager.h:1114
openvdb::v3_2_0::tree::NodeManager< TreeOrLeafManagerT, 0 >::clear
void clear()
Clear all the cached tree nodes.
Definition: NodeManager.h:615
openvdb::v3_2_0::tree::NodeManagerLink::nodeCount
Index64 nodeCount(Index i) const
Definition: NodeManager.h:272
openvdb::v3_2_0::tree::NodeManagerLink< NodeT, 0 >::~NodeManagerLink
virtual ~NodeManagerLink()
Definition: NodeManager.h:335
openvdb::v3_2_0::tree::NodeManagerLink::NodeManagerLink
NodeManagerLink()
Definition: NodeManager.h:249
openvdb
Definition: Exceptions.h:39
OPENVDB_NO_UNREACHABLE_CODE_WARNING_BEGIN
#define OPENVDB_NO_UNREACHABLE_CODE_WARNING_BEGIN
Definition: Platform.h:129
openvdb::v3_2_0::tree::NodeManagerLink::reduceTopDown
void reduceTopDown(NodeOp &op, bool threaded, size_t grainSize)
Definition: NodeManager.h:311
openvdb::v3_2_0::tree::NodeManager< TreeOrLeafManagerT, 4 >::ListT3
NodeList< NodeT3 > ListT3
Definition: NodeManager.h:1105
openvdb::v3_2_0::tree::NodeList::nodeRange
NodeRange nodeRange(size_t grainsize=1) const
Return a TBB-compatible NodeRange.
Definition: NodeManager.h:164
openvdb::v3_2_0::tree::NodeManager< TreeOrLeafManagerT, 1 >::root
const RootNodeType & root() const
Return a reference to the root node.
Definition: NodeManager.h:688
openvdb::v3_2_0::tree::NodeManagerLink::mList
NodeList< NodeT > mList
Definition: NodeManager.h:318
openvdb::v3_2_0::tree::NodeList::NodeRange::Iterator::operator==
bool operator==(const Iterator &other) const
Definition: NodeManager.h:138
openvdb::v3_2_0::tree::NodeManager< TreeOrLeafManagerT, 0 >::foreachBottomUp
void foreachBottomUp(const NodeOp &op, bool, size_t)
Definition: NodeManager.h:636
openvdb::v3_2_0::tree::NodeManager< TreeOrLeafManagerT, 2 >::NodeT1
NodeT2::ChildNodeType NodeT1
Definition: NodeManager.h:847
openvdb::v3_2_0::tree::NodeManagerLink< NodeT, 0 >::init
void init(ParentT &parent, TreeOrLeafManagerT &tree)
Definition: NodeManager.h:384
openvdb::v3_2_0::tree::NodeManager< TreeOrLeafManagerT, 1 >::reduceTopDown
void reduceTopDown(NodeOp &op, bool threaded=true, size_t grainSize=1)
Definition: NodeManager.h:730
openvdb::v3_2_0::tree::NodeManager::foreachBottomUp
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
openvdb::v3_2_0::tree::NodeList::NodeRange::Iterator::operator*
NodeT & operator*() const
Return a reference to the node to which this iterator is pointing.
Definition: NodeManager.h:122
openvdb::v3_2_0::tree::NodeManager< TreeOrLeafManagerT, 0 >::root
const RootNodeType & root() const
Return a reference to the root node.
Definition: NodeManager.h:622
openvdb::v3_2_0::tree::NodeManagerLink< NodeT, 0 >::clear
void clear()
Clear all the cached tree nodes.
Definition: NodeManager.h:338
openvdb::v3_2_0::tree::NodeManager::~NodeManager
virtual ~NodeManager()
Definition: NodeManager.h:418
openvdb::v3_2_0::tree::NodeList::NodeRange::Iterator::nodeRange
const NodeRange & nodeRange() const
Definition: NodeManager.h:139
openvdb::v3_2_0::tree::NodeList::NodeRange::grainsize
size_t grainsize() const
Definition: NodeManager.h:100
openvdb::v3_2_0::tree::NodeManagerLink< NodeT, 0 >::nodeCount
Index64 nodeCount() const
Definition: NodeManager.h:343
openvdb::v3_2_0::tree::NodeManager< TreeOrLeafManagerT, 3 >::ListT0
NodeList< NodeT0 > ListT0
Definition: NodeManager.h:973
openvdb::v3_2_0::tree::NodeManagerLink< NodeT, 0 >::nodeCount
Index64 nodeCount(Index) const
Definition: NodeManager.h:345
openvdb::v3_2_0::tree::NodeManagerLink::processTopDown
OPENVDB_DEPRECATED void processTopDown(const NodeOp &op, bool threaded, size_t grainSize)
Definition: NodeManager.h:298
openvdb::v3_2_0::tree::NodeList::NodeList
NodeList()
Definition: NodeManager.h:73
openvdb::v3_2_0::tree::NodeManager< TreeOrLeafManagerT, 3 >::mList1
ListT1 mList1
Definition: NodeManager.h:977
openvdb::v3_2_0::tree::NodeList::nodeCount
Index64 nodeCount() const
Definition: NodeManager.h:81
openvdb::v3_2_0::tree::NodeManager::processBottomUp
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
openvdb::v3_2_0::tree::NodeManager< TreeOrLeafManagerT, 2 >::ListT0
NodeList< NodeT0 > ListT0
Definition: NodeManager.h:851
openvdb::v3_2_0::tree::NodeManager< TreeOrLeafManagerT, 2 >::nodeCount
Index64 nodeCount() const
Return the total number of cached nodes (excluding the root node)
Definition: NodeManager.h:792
openvdb::v3_2_0::tree::NodeManager< TreeOrLeafManagerT, 4 >::ListT0
NodeList< NodeT0 > ListT0
Definition: NodeManager.h:1108
openvdb::v3_2_0::tree::NodeManager< TreeOrLeafManagerT, 4 >::mList1
ListT1 mList1
Definition: NodeManager.h:1113
openvdb::v3_2_0::tree::NodeManager< TreeOrLeafManagerT, 2 >::RootNodeType
TreeOrLeafManagerT::RootNodeType RootNodeType
Definition: NodeManager.h:757
openvdb::v3_2_0::tree::NodeManagerLink< NodeT, 0 >::NodeManagerLink
NodeManagerLink()
Definition: NodeManager.h:333
openvdb::v3_2_0::tree::NodeManager< TreeOrLeafManagerT, 3 >::NodeManager
NodeManager(TreeOrLeafManagerT &tree)
Definition: NodeManager.h:874
openvdb::v3_2_0::tree::NodeManagerLink< NodeT, 0 >::reduceTopDown
void reduceTopDown(NodeOp &op, bool threaded, size_t grainSize)
Definition: NodeManager.h:378
openvdb::v3_2_0::tree::NodeManager::mChain
NodeManagerLink< typename RootNodeType::ChildNodeType, LEVELS-1 > mChain
Definition: NodeManager.h:592
openvdb::v3_2_0::tree::NodeManager::NodeManager
NodeManager(TreeOrLeafManagerT &tree)
Definition: NodeManager.h:416
OPENVDB_NO_UNREACHABLE_CODE_WARNING_END
#define OPENVDB_NO_UNREACHABLE_CODE_WARNING_END
Definition: Platform.h:130
openvdb::v3_2_0::tree::NodeManagerLink::clear
void clear()
Definition: NodeManager.h:253
openvdb::v3_2_0::tree::NodeManager
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
openvdb::v3_2_0::tree::NodeManager< TreeOrLeafManagerT, 3 >::ListT2
NodeList< NodeT2 > ListT2
Definition: NodeManager.h:971
openvdb::v3_2_0::tree::NodeList::NodeRange::empty
bool empty() const
Definition: NodeManager.h:104
openvdb::v3_2_0::tree::NodeList::value_type
NodeT * value_type
Definition: NodeManager.h:70
openvdb::v3_2_0::tree::NodeManager< TreeOrLeafManagerT, 1 >::rebuild
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
openvdb::v3_2_0::tree::NodeManager< TreeOrLeafManagerT, 0 >::~NodeManager
virtual ~NodeManager()
Definition: NodeManager.h:612
openvdb::v3_2_0::tree::NodeList::NodeRange::Iterator::isValid
bool isValid() const
Definition: NodeManager.h:127
openvdb::v3_2_0::tree::NodeList::NodeRange::nodeList
const NodeList & nodeList() const
Definition: NodeManager.h:102
openvdb::v3_2_0::tree::NodeManager< TreeOrLeafManagerT, 4 >::ListT2
NodeList< NodeT2 > ListT2
Definition: NodeManager.h:1106
openvdb::v3_2_0::tree::NodeManager< TreeOrLeafManagerT, 2 >::reduceBottomUp
void reduceBottomUp(NodeOp &op, bool threaded=true, size_t grainSize=1)
Definition: NodeManager.h:830
openvdb::v3_2_0::tree::NodeManagerLink::processBottomUp
OPENVDB_DEPRECATED void processBottomUp(const NodeOp &op, bool threaded, size_t grainSize)
Definition: NodeManager.h:292
openvdb::v3_2_0::tree::NodeManager< TreeOrLeafManagerT, 0 >::rebuild
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
openvdb::v3_2_0::tree::NodeManager< TreeOrLeafManagerT, 1 >::~NodeManager
virtual ~NodeManager()
Definition: NodeManager.h:678
openvdb::v3_2_0::tree::NodeManager< TreeOrLeafManagerT, 4 >::NodeManager
NodeManager(TreeOrLeafManagerT &tree)
Definition: NodeManager.h:997
openvdb::v3_2_0::tree::NodeManagerLink< NodeT, 0 >::foreachTopDown
void foreachTopDown(const NodeOp &op, bool threaded, size_t grainSize)
Definition: NodeManager.h:354
openvdb::v3_2_0::tree::NodeManager< TreeOrLeafManagerT, 1 >::NodeT0
NodeT1::ChildNodeType NodeT0
Definition: NodeManager.h:738
openvdb::v3_2_0::tree::NodeManager< TreeOrLeafManagerT, 0 >::mRoot
RootNodeType & mRoot
Definition: NodeManager.h:648
openvdb::v3_2_0::tree::NodeList::NodeRange::Iterator::operator=
Iterator & operator=(const Iterator &other)
Definition: NodeManager.h:115
openvdb::v3_2_0::tree::NodeManager< TreeOrLeafManagerT, 1 >::foreachBottomUp
void foreachBottomUp(const NodeOp &op, bool threaded=true, size_t grainSize=1)
Definition: NodeManager.h:698
openvdb::v3_2_0::tree::NodeManager< TreeOrLeafManagerT, 2 >::foreachTopDown
void foreachTopDown(const NodeOp &op, bool threaded=true, size_t grainSize=1)
Definition: NodeManager.h:810
openvdb::v3_2_0::tree::NodeManager< TreeOrLeafManagerT, 2 >::mRoot
NodeT2 & mRoot
Definition: NodeManager.h:853
openvdb::v3_2_0::tree::NodeList::push_back
void push_back(NodeT *node)
Definition: NodeManager.h:75
openvdb::v3_2_0::tree::NodeList::NodeRange::Iterator::test
bool test() const
Return true if this iterator is not yet exhausted.
Definition: NodeManager.h:129
openvdb::v3_2_0::tree::NodeManager< TreeOrLeafManagerT, 4 >::clear
void clear()
Clear all the cached tree nodes.
Definition: NodeManager.h:1015
openvdb::v3_2_0::tree::NodeList::NodeRange::Iterator::pos
size_t pos() const
Return the index into the list of the current node.
Definition: NodeManager.h:126
openvdb::v3_2_0::tree::NodeManager< TreeOrLeafManagerT, 3 >::mRoot
NodeT3 & mRoot
Definition: NodeManager.h:975
openvdb::v3_2_0::tree::NodeManager< TreeOrLeafManagerT, 1 >::mList0
ListT0 mList0
Definition: NodeManager.h:742
openvdb::v3_2_0::tree::NodeManager< TreeOrLeafManagerT, 4 >::~NodeManager
virtual ~NodeManager()
Definition: NodeManager.h:1012
openvdb::v3_2_0::tree::NodeManager< TreeOrLeafManagerT, 3 >::NodeT0
NodeT1::ChildNodeType NodeT0
Definition: NodeManager.h:969
openvdb::v3_2_0::tree::NodeManager< TreeOrLeafManagerT, 1 >::NodeManager
NodeManager(TreeOrLeafManagerT &tree)
Definition: NodeManager.h:667
openvdb::v3_2_0::tree::NodeManager< TreeOrLeafManagerT, 0 >::processBottomUp
OPENVDB_DEPRECATED void processBottomUp(const NodeOp &op, bool, size_t)
Definition: NodeManager.h:630
OPENVDB_USE_VERSION_NAMESPACE
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h:71
openvdb::v3_2_0::tree::NodeManager< TreeOrLeafManagerT, 3 >::clear
void clear()
Clear all the cached tree nodes.
Definition: NodeManager.h:891
openvdb::v3_2_0::tree::NodeList::clear
void clear()
Definition: NodeManager.h:83
openvdb::v3_2_0::tree::NodeManagerLink< NodeT, 0 >::foreachBottomUp
void foreachBottomUp(const NodeOp &op, bool threaded, size_t grainSize)
Definition: NodeManager.h:348
openvdb::v3_2_0::tree::NodeManagerLink::mNext
NodeManagerLink< typename NodeT::ChildNodeType, LEVEL-1 > mNext
Definition: NodeManager.h:319
openvdb::v3_2_0::tree::NodeManager::root
const RootNodeType & root() const
Return a reference to the root node.
Definition: NodeManager.h:428
openvdb::v3_2_0::tree::NodeList::NodeRange
Definition: NodeManager.h:87
openvdb::v3_2_0::tree::NodeManager< TreeOrLeafManagerT, 4 >::NodeT0
NodeT1::ChildNodeType NodeT0
Definition: NodeManager.h:1103
openvdb::v3_2_0::tree::NodeManager< TreeOrLeafManagerT, 0 >::NodeManager
NodeManager(TreeOrLeafManagerT &tree)
Definition: NodeManager.h:610
openvdb::v3_2_0::tree::NodeManager< TreeOrLeafManagerT, 4 >::NodeT3
NodeT4::ChildNodeType NodeT3
Definition: NodeManager.h:1100
openvdb::v3_2_0::tree::NodeManager< TreeOrLeafManagerT, 4 >::reduceTopDown
void reduceTopDown(NodeOp &op, bool threaded=true, size_t grainSize=1)
Definition: NodeManager.h:1089
openvdb::v3_2_0::tree::NodeManager< TreeOrLeafManagerT, 3 >::nodeCount
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
openvdb::v3_2_0::tree::NodeManager< TreeOrLeafManagerT, 4 >::foreachBottomUp
void foreachBottomUp(const NodeOp &op, bool threaded=true, size_t grainSize=1)
Definition: NodeManager.h:1047
openvdb::v3_2_0::tree::NodeManagerLink< NodeT, 0 >::reduceBottomUp
void reduceBottomUp(NodeOp &op, bool threaded, size_t grainSize)
Definition: NodeManager.h:372
openvdb::v3_2_0::tree::NodeList::NodeRange::Iterator
Definition: NodeManager.h:108
openvdb::v3_2_0::tree::NodeManagerLink< NodeT, 0 >::processBottomUp
OPENVDB_DEPRECATED void processBottomUp(const NodeOp &op, bool threaded, size_t grainSize)
Definition: NodeManager.h:360
openvdb::v3_2_0::tree::NodeManager< TreeOrLeafManagerT, 4 >::nodeCount
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::v3_2_0::tree::NodeManager< TreeOrLeafManagerT, 4 >::root
const RootNodeType & root() const
Return a reference to the root node.
Definition: NodeManager.h:1029
openvdb::v3_2_0::tree::NodeManager< TreeOrLeafManagerT, 3 >::~NodeManager
virtual ~NodeManager()
Definition: NodeManager.h:888
openvdb::v3_2_0::tree::NodeList::mList
ListT mList
Definition: NodeManager.h:234
openvdb::v3_2_0::tree::NodeList::operator()
NodeT & operator()(size_t n) const
Definition: NodeManager.h:77
openvdb::v3_2_0::tree::NodeManager< TreeOrLeafManagerT, 2 >::clear
void clear()
Clear all the cached tree nodes.
Definition: NodeManager.h:777
openvdb::v3_2_0::tree::NodeList::NodeRange::Iterator::operator++
Iterator & operator++()
Advance to the next node.
Definition: NodeManager.h:120
openvdb::v3_2_0::tree::NodeManager< TreeOrLeafManagerT, 4 >::RootNodeType
TreeOrLeafManagerT::RootNodeType RootNodeType
Definition: NodeManager.h:993
openvdb::v3_2_0::tree::NodeList::NodeRange::NodeRange
NodeRange(size_t begin, size_t end, const NodeList &nodeList, size_t grainSize=1)
Definition: NodeManager.h:91
openvdb::v3_2_0::tree::NodeManager< TreeOrLeafManagerT, 0 >::reduceTopDown
void reduceTopDown(NodeOp &op, bool, size_t)
Definition: NodeManager.h:645
openvdb::v3_2_0::tree::NodeManager< TreeOrLeafManagerT, 3 >::root
const RootNodeType & root() const
Return a reference to the root node.
Definition: NodeManager.h:904
openvdb::v3_2_0::tree::NodeManager< TreeOrLeafManagerT, 2 >::~NodeManager
virtual ~NodeManager()
Definition: NodeManager.h:774
openvdb::v3_2_0::tree::NodeManager< TreeOrLeafManagerT, 2 >::NodeManager
NodeManager(TreeOrLeafManagerT &tree)
Definition: NodeManager.h:761
openvdb::v3_2_0::tree::NodeManager< TreeOrLeafManagerT, 3 >::reduceTopDown
void reduceTopDown(NodeOp &op, bool threaded=true, size_t grainSize=1)
Definition: NodeManager.h:957
openvdb::v3_2_0::tree::NodeList::ListT
std::deque< value_type > ListT
Definition: NodeManager.h:71
openvdb::v3_2_0::tree::NodeManager< TreeOrLeafManagerT, 3 >::foreachBottomUp
void foreachBottomUp(const NodeOp &op, bool threaded=true, size_t grainSize=1)
Definition: NodeManager.h:918
openvdb::v3_2_0::tree::NodeList::NodeRange::Iterator::empty
bool empty() const
Return true if this iterator is exhausted.
Definition: NodeManager.h:133
openvdb::v3_2_0::tree::NodeManager< TreeOrLeafManagerT, 1 >::processTopDown
OPENVDB_DEPRECATED void processTopDown(const NodeOp &op, bool threaded=true, size_t grainSize=1)
Definition: NodeManager.h:717
openvdb::v3_2_0::tree::NodeList::resize
void resize(size_t n)
Definition: NodeManager.h:85
openvdb::v3_2_0::tree::NodeManager< TreeOrLeafManagerT, 2 >::reduceTopDown
void reduceTopDown(NodeOp &op, bool threaded=true, size_t grainSize=1)
Definition: NodeManager.h:838
openvdb::v3_2_0::tree::NodeManager< TreeOrLeafManagerT, 4 >::ListT1
NodeList< NodeT1 > ListT1
Definition: NodeManager.h:1107