OpenVDB  3.1.0
NodeManager.h
Go to the documentation of this file.
1 //
3 // Copyright (c) 2012-2015 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 <openvdb/Types.h>
46 #include <deque>
47 
48 namespace openvdb {
50 namespace OPENVDB_VERSION_NAME {
51 namespace tree {
52 
53 // Produce linear arrays of all tree nodes, to facilitate efficient threading
54 // and bottom-up processing.
55 template<typename TreeOrLeafManagerT, Index LEVELS = TreeOrLeafManagerT::RootNodeType::LEVEL>
57 
58 
60 
61 
65 template<typename NodeT>
66 class NodeList
67 {
68 public:
69  typedef NodeT* value_type;
70  typedef std::deque<value_type> ListT;
71 
72  NodeList() {}
73 
74  void push_back(NodeT* node) { mList.push_back(node); }
75 
76  NodeT& operator()(size_t n) const { assert(n<mList.size()); return *(mList[n]); }
77 
78  NodeT*& operator[](size_t n) { assert(n<mList.size()); return mList[n]; }
79 
80  Index64 nodeCount() const { return mList.size(); }
81 
82  void clear() { mList.clear(); }
83 
84  void resize(size_t n) { mList.resize(n); }
85 
86  class NodeRange
87  {
88  public:
89 
90  NodeRange(size_t begin, size_t end, const NodeList& nodeList, size_t grainSize=1):
91  mEnd(end), mBegin(begin), mGrainSize(grainSize), mNodeList(nodeList) {}
92 
93  NodeRange(NodeRange& r, tbb::split):
94  mEnd(r.mEnd), mBegin(doSplit(r)), mGrainSize(r.mGrainSize),
95  mNodeList(r.mNodeList) {}
96 
97  size_t size() const { return mEnd - mBegin; }
98 
99  size_t grainsize() const { return mGrainSize; }
100 
101  const NodeList& nodeList() const { return mNodeList; }
102 
103  bool empty() const {return !(mBegin < mEnd);}
104 
105  bool is_divisible() const {return mGrainSize < this->size();}
106 
107  class Iterator
108  {
109  public:
110  Iterator(const NodeRange& range, size_t pos): mRange(range), mPos(pos)
111  {
112  assert(this->isValid());
113  }
114  Iterator& operator=(const Iterator& other)
115  {
116  mRange = other.mRange; mPos = other.mPos; return *this;
117  }
119  Iterator& operator++() { ++mPos; return *this; }
121  NodeT& operator*() const { return mRange.mNodeList(mPos); }
123  NodeT* operator->() const { return &(this->operator*()); }
125  size_t pos() const { return mPos; }
126  bool isValid() const { return mPos>=mRange.mBegin && mPos<=mRange.mEnd; }
128  bool test() const { return mPos < mRange.mEnd; }
130  operator bool() const { return this->test(); }
132  bool empty() const { return !this->test(); }
133  bool operator!=(const Iterator& other) const
134  {
135  return (mPos != other.mPos) || (&mRange != &other.mRange);
136  }
137  bool operator==(const Iterator& other) const { return !(*this != other); }
138  const NodeRange& nodeRange() const { return mRange; }
139 
140  private:
141  const NodeRange& mRange;
142  size_t mPos;
143  };// NodeList::NodeRange::Iterator
144 
145  Iterator begin() const {return Iterator(*this, mBegin);}
146 
147  Iterator end() const {return Iterator(*this, mEnd);}
148 
149  private:
150  size_t mEnd, mBegin, mGrainSize;
151  const NodeList& mNodeList;
152 
153  static size_t doSplit(NodeRange& r)
154  {
155  assert(r.is_divisible());
156  size_t middle = r.mBegin + (r.mEnd - r.mBegin) / 2u;
157  r.mEnd = middle;
158  return middle;
159  }
160  };// NodeList::NodeRange
161 
163  NodeRange nodeRange(size_t grainsize = 1) const
164  {
165  return NodeRange(0, this->nodeCount(), *this, grainsize);
166  }
167 
168  template<typename NodeOp>
170  {
171  NodeTransformer(const NodeOp& nodeOp) : mNodeOp(nodeOp) {}
172  void run(const NodeRange& range, bool threaded = true)
173  {
174  threaded ? tbb::parallel_for(range, *this) : (*this)(range);
175  }
176  void operator()(const NodeRange& range) const
177  {
178  for (typename NodeRange::Iterator it = range.begin(); it; ++it) mNodeOp(*it);
179  }
180  const NodeOp mNodeOp;
181  };// NodeRange
182 
183  template<typename NodeOp>
184  void foreach(const NodeOp& op, bool threaded = true, size_t grainSize=1)
185  {
186  NodeTransformer<NodeOp> transform(op);
187  transform.run(this->nodeRange(grainSize), threaded);
188  }
189 
190 protected:
191  ListT mList;
192 };// NodeList
193 
194 
196 
197 
202 template<typename NodeT, Index LEVEL>
204 {
205 public:
207 
208  virtual ~NodeManagerLink() {}
209 
210  void clear() { mList.clear(); mNext.clear(); }
211 
212  template<typename ParentT, typename TreeOrLeafManagerT>
213  void init(ParentT& parent, TreeOrLeafManagerT& tree)
214  {
215  parent.getNodes(mList);
216  for (size_t i=0, n=mList.nodeCount(); i<n; ++i) mNext.init(mList(i), tree);
217  }
218 
219  template<typename ParentT>
220  void rebuild(ParentT& parent)
221  {
222  mList.clear();
223  parent.getNodes(mList);
224  for (size_t i=0, n=mList.nodeCount(); i<n; ++i) mNext.rebuild(mList(i));
225  }
226 
227  Index64 nodeCount() const { return mList.nodeCount() + mNext.nodeCount(); }
228 
230  {
231  return i==NodeT::LEVEL ? mList.nodeCount() : mNext.nodeCount(i);
232  }
233 
234  template<typename NodeOp>
235  void processBottomUp(const NodeOp& op, bool threaded, size_t grainSize)
236  {
237  mNext.processBottomUp(op, threaded, grainSize);
238  mList.foreach(op, threaded, grainSize);
239  }
240 
241  template<typename NodeOp>
242  void processTopDown(const NodeOp& op, bool threaded, size_t grainSize)
243  {
244  mList.foreach(op, threaded, grainSize);
245  mNext.processTopDown(op, threaded, grainSize);
246  }
247 
248 protected:
250  NodeManagerLink<typename NodeT::ChildNodeType, LEVEL-1> mNext;
251 };// NodeManagerLink class
252 
253 
255 
256 
260 template<typename NodeT>
261 class NodeManagerLink<NodeT, 0>
262 {
263 public:
265 
266  virtual ~NodeManagerLink() {}
267 
269  void clear() { mList.clear(); }
270 
271  template<typename ParentT>
272  void rebuild(ParentT& parent) { mList.clear(); parent.getNodes(mList); }
273 
274  Index64 nodeCount() const { return mList.nodeCount(); }
275 
276  Index64 nodeCount(Index) const { return mList.nodeCount(); }
277 
278  template<typename NodeOp>
279  void processBottomUp(const NodeOp& op, bool threaded, size_t grainSize)
280  {
281  mList.foreach(op, threaded, grainSize);
282  }
283 
284  template<typename NodeOp>
285  void processTopDown(const NodeOp& op, bool threaded, size_t grainSize)
286  {
287  mList.foreach(op, threaded, grainSize);
288  }
289 
290  template<typename ParentT, typename TreeOrLeafManagerT>
291  void init(ParentT& parent, TreeOrLeafManagerT& tree)
292  {
294  if (TreeOrLeafManagerT::DEPTH == 2 && NodeT::LEVEL == 0) {
295  tree.getNodes(mList);
296  } else {
297  parent.getNodes(mList);
298  }
300  }
301 protected:
303 };// NodeManagerLink class
304 
305 
307 
308 
314 template<typename TreeOrLeafManagerT, Index _LEVELS>
315 class NodeManager
316 {
317 public:
318  static const Index LEVELS = _LEVELS;
319  BOOST_STATIC_ASSERT(LEVELS > 0);//special implementation below
320  typedef typename TreeOrLeafManagerT::RootNodeType RootNodeType;
321  BOOST_STATIC_ASSERT(RootNodeType::LEVEL >= LEVELS);
322 
323  NodeManager(TreeOrLeafManagerT& tree) : mRoot(tree.root()) { mChain.init(mRoot, tree); }
324 
325  virtual ~NodeManager() {}
326 
328  void clear() { mChain.clear(); }
329 
332  void rebuild() { mChain.rebuild(mRoot); }
333 
335  const RootNodeType& root() const { return mRoot; }
336 
338  Index64 nodeCount() const { return mChain.nodeCount(); }
339 
342  Index64 nodeCount(Index i) const { return mChain.nodeCount(i); }
343 
345  template<typename NodeOp>
401  void processBottomUp(const NodeOp& op, bool threaded = true, size_t grainSize=1)
402  {
403  mChain.processBottomUp(op, threaded, grainSize);
404  op(mRoot);
405  }
406 
407  template<typename NodeOp>
408  void processTopDown(const NodeOp& op, bool threaded = true, size_t grainSize=1)
409  {
410  op(mRoot);
411  mChain.processTopDown(op, threaded, grainSize);
412  }
414 
415 protected:
416  RootNodeType& mRoot;
417  NodeManagerLink<typename RootNodeType::ChildNodeType, LEVELS-1> mChain;
418 
419 private:
420  NodeManager(const NodeManager&) {}//disallow copy-construction
421 };// NodeManager class
422 
423 
425 
426 
428 template<typename TreeOrLeafManagerT>
429 class NodeManager<TreeOrLeafManagerT, 0>
430 {
431 public:
432  typedef typename TreeOrLeafManagerT::RootNodeType RootNodeType;
433  static const Index LEVELS = 0;
434 
435  NodeManager(TreeOrLeafManagerT& tree) : mRoot(tree.root()) {}
436 
437  virtual ~NodeManager() {}
438 
440  void clear() {}
441 
444  void rebuild() {}
445 
447  const RootNodeType& root() const { return mRoot; }
448 
450  Index64 nodeCount() const { return 0; }
451 
452  Index64 nodeCount(Index) const { return 0; }
453 
454  template<typename NodeOp>
455  void processBottomUp(const NodeOp& op, bool, size_t) { op(mRoot); }
456 
457  template<typename NodeOp>
458  void processTopDown(const NodeOp& op, bool, size_t) { op(mRoot); }
459 
460 protected:
461  RootNodeType& mRoot;
462 
463 private:
464  NodeManager(const NodeManager&) {} // disallow copy-construction
465 }; // NodeManager<0>
466 
467 
469 
470 
472 template<typename TreeOrLeafManagerT>
473 class NodeManager<TreeOrLeafManagerT, 1>
474 {
475 public:
476  typedef typename TreeOrLeafManagerT::RootNodeType RootNodeType;
477  BOOST_STATIC_ASSERT(RootNodeType::LEVEL > 0);
478  static const Index LEVELS = 1;
479 
480  NodeManager(TreeOrLeafManagerT& tree) : mRoot(tree.root())
481  {
483  if (TreeOrLeafManagerT::DEPTH == 2 && NodeT0::LEVEL == 0) {
484  tree.getNodes(mList0);
485  } else {
486  mRoot.getNodes(mList0);
487  }
489  }
490 
491  virtual ~NodeManager() {}
492 
494  void clear() { mList0.clear(); }
495 
498  void rebuild() { mList0.clear(); mRoot.getNodes(mList0); }
499 
501  const RootNodeType& root() const { return mRoot; }
502 
504  Index64 nodeCount() const { return mList0.nodeCount(); }
505 
508  Index64 nodeCount(Index i) const { return i==0 ? mList0.nodeCount() : 0; }
509 
510  template<typename NodeOp>
511  void processBottomUp(const NodeOp& op, bool threaded = true, size_t grainSize=1)
512  {
513  mList0.foreach(op, threaded, grainSize);
514  op(mRoot);
515  }
516 
517  template<typename NodeOp>
518  void processTopDown(const NodeOp& op, bool threaded = true, size_t grainSize=1)
519  {
520  op(mRoot);
521  mList0.foreach(op, threaded, grainSize);
522  }
523 
524 protected:
525  typedef RootNodeType NodeT1;
526  typedef typename NodeT1::ChildNodeType NodeT0;
528 
529  NodeT1& mRoot;
530  ListT0 mList0;
531 
532 private:
533  NodeManager(const NodeManager&) {} // disallow copy-construction
534 }; // NodeManager<1>
535 
536 
538 
539 
541 template<typename TreeOrLeafManagerT>
542 class NodeManager<TreeOrLeafManagerT, 2>
543 {
544 public:
545  typedef typename TreeOrLeafManagerT::RootNodeType RootNodeType;
546  BOOST_STATIC_ASSERT(RootNodeType::LEVEL > 1);
547  static const Index LEVELS = 2;
548 
549  NodeManager(TreeOrLeafManagerT& tree) : mRoot(tree.root())
550  {
551  mRoot.getNodes(mList1);
552 
554  if (TreeOrLeafManagerT::DEPTH == 2 && NodeT0::LEVEL == 0) {
555  tree.getNodes(mList0);
556  } else {
557  for (size_t i=0, n=mList1.nodeCount(); i<n; ++i) mList1(i).getNodes(mList0);
558  }
560  }
561 
562  virtual ~NodeManager() {}
563 
565  void clear() { mList0.clear(); mList1.clear(); }
566 
569  void rebuild()
570  {
571  this->clear();
572  mRoot.getNodes(mList1);
573  for (size_t i=0, n=mList1.nodeCount(); i<n; ++i) mList1(i).getNodes(mList0);
574  }
575 
577  const RootNodeType& root() const { return mRoot; }
578 
580  Index64 nodeCount() const { return mList0.nodeCount() + mList1.nodeCount(); }
581 
585  {
586  return i==0 ? mList0.nodeCount() : i==1 ? mList1.nodeCount() : 0;
587  }
588 
589  template<typename NodeOp>
590  void processBottomUp(const NodeOp& op, bool threaded = true, size_t grainSize=1)
591  {
592  mList0.foreach(op, threaded, grainSize);
593  mList1.foreach(op, threaded, grainSize);
594  op(mRoot);
595  }
596 
597  template<typename NodeOp>
598  void processTopDown(const NodeOp& op, bool threaded = true, size_t grainSize=1)
599  {
600  op(mRoot);
601  mList1.foreach(op, threaded, grainSize);
602  mList0.foreach(op, threaded, grainSize);
603  }
604 
605 protected:
606  typedef RootNodeType NodeT2;
607  typedef typename NodeT2::ChildNodeType NodeT1;//upper level
608  typedef typename NodeT1::ChildNodeType NodeT0;//lower level
609 
610  typedef NodeList<NodeT1> ListT1;//upper level
611  typedef NodeList<NodeT0> ListT0;//lower level
612 
613  NodeT2& mRoot;
614  ListT1 mList1;
615  ListT0 mList0;
616 
617 private:
618  NodeManager(const NodeManager&) {} // disallow copy-construction
619 }; // NodeManager<2>
620 
621 
623 
624 
626 template<typename TreeOrLeafManagerT>
627 class NodeManager<TreeOrLeafManagerT, 3>
628 {
629 public:
630  typedef typename TreeOrLeafManagerT::RootNodeType RootNodeType;
631  BOOST_STATIC_ASSERT(RootNodeType::LEVEL > 2);
632  static const Index LEVELS = 3;
633 
634  NodeManager(TreeOrLeafManagerT& tree) : mRoot(tree.root())
635  {
636  mRoot.getNodes(mList2);
637  for (size_t i=0, n=mList2.nodeCount(); i<n; ++i) mList2(i).getNodes(mList1);
638 
640  if (TreeOrLeafManagerT::DEPTH == 2 && NodeT0::LEVEL == 0) {
641  tree.getNodes(mList0);
642  } else {
643  for (size_t i=0, n=mList1.nodeCount(); i<n; ++i) mList1(i).getNodes(mList0);
644  }
646  }
647 
648  virtual ~NodeManager() {}
649 
651  void clear() { mList0.clear(); mList1.clear(); mList2.clear(); }
652 
655  void rebuild()
656  {
657  this->clear();
658  mRoot.getNodes(mList2);
659  for (size_t i=0, n=mList2.nodeCount(); i<n; ++i) mList2(i).getNodes(mList1);
660  for (size_t i=0, n=mList1.nodeCount(); i<n; ++i) mList1(i).getNodes(mList0);
661  }
662 
664  const RootNodeType& root() const { return mRoot; }
665 
667  Index64 nodeCount() const { return mList0.nodeCount()+mList1.nodeCount()+mList2.nodeCount(); }
668 
672  {
673  return i==0 ? mList0.nodeCount() : i==1 ? mList1.nodeCount()
674  : i==2 ? mList2.nodeCount() : 0;
675  }
676 
677  template<typename NodeOp>
678  void processBottomUp(const NodeOp& op, bool threaded = true, size_t grainSize=1)
679  {
680  mList0.foreach(op, threaded, grainSize);
681  mList1.foreach(op, threaded, grainSize);
682  mList2.foreach(op, threaded, grainSize);
683  op(mRoot);
684  }
685 
686  template<typename NodeOp>
687  void processTopDown(const NodeOp& op, bool threaded = true, size_t grainSize=1)
688  {
689  op(mRoot);
690  mList2.foreach(op, threaded, grainSize);
691  mList1.foreach(op, threaded, grainSize);
692  mList0.foreach(op, threaded, grainSize);
693  }
694 
695 protected:
696  typedef RootNodeType NodeT3;
697  typedef typename NodeT3::ChildNodeType NodeT2;//upper level
698  typedef typename NodeT2::ChildNodeType NodeT1;//mid level
699  typedef typename NodeT1::ChildNodeType NodeT0;//lower level
700 
701  typedef NodeList<NodeT2> ListT2;//upper level of internal nodes
702  typedef NodeList<NodeT1> ListT1;//lower level of internal nodes
703  typedef NodeList<NodeT0> ListT0;//lower level of internal nodes or leafs
704 
705  NodeT3& mRoot;
706  ListT2 mList2;
707  ListT1 mList1;
708  ListT0 mList0;
709 
710 private:
711  NodeManager(const NodeManager&) {} // disallow copy-construction
712 }; // NodeManager<3>
713 
714 
716 
717 
719 template<typename TreeOrLeafManagerT>
720 class NodeManager<TreeOrLeafManagerT, 4>
721 {
722 public:
723  typedef typename TreeOrLeafManagerT::RootNodeType RootNodeType;
724  BOOST_STATIC_ASSERT(RootNodeType::LEVEL > 3);
725  static const Index LEVELS = 4;
726 
727  NodeManager(TreeOrLeafManagerT& tree) : mRoot(tree.root())
728  {
729  mRoot.getNodes(mList3);
730  for (size_t i=0, n=mList3.nodeCount(); i<n; ++i) mList3(i).getNodes(mList2);
731  for (size_t i=0, n=mList2.nodeCount(); i<n; ++i) mList2(i).getNodes(mList1);
732 
734  if (TreeOrLeafManagerT::DEPTH == 2 && NodeT0::LEVEL == 0) {
735  tree.getNodes(mList0);
736  } else {
737  for (size_t i=0, n=mList1.nodeCount(); i<n; ++i) mList1(i).getNodes(mList0);
738  }
740  }
741 
742  virtual ~NodeManager() {}
743 
745  void clear() { mList0.clear(); mList1.clear(); mList2.clear(); mList3.clear; }
746 
749  void rebuild()
750  {
751  this->clear();
752  mRoot.getNodes(mList3);
753  for (size_t i=0, n=mList3.nodeCount(); i<n; ++i) mList3(i).getNodes(mList2);
754  for (size_t i=0, n=mList2.nodeCount(); i<n; ++i) mList2(i).getNodes(mList1);
755  for (size_t i=0, n=mList1.nodeCount(); i<n; ++i) mList1(i).getNodes(mList0);
756  }
757 
759  const RootNodeType& root() const { return mRoot; }
760 
763  {
764  return mList0.nodeCount() + mList1.nodeCount()
765  + mList2.nodeCount() + mList3.nodeCount();
766  }
767 
771  {
772  return i==0 ? mList0.nodeCount() : i==1 ? mList1.nodeCount() :
773  i==2 ? mList2.nodeCount() : i==3 ? mList3.nodeCount() : 0;
774  }
775 
776  template<typename NodeOp>
777  void processBottomUp(const NodeOp& op, bool threaded = true, size_t grainSize=1)
778  {
779  mList0.foreach(op, threaded, grainSize);
780  mList1.foreach(op, threaded, grainSize);
781  mList2.foreach(op, threaded, grainSize);
782  mList3.foreach(op, threaded, grainSize);
783  op(mRoot);
784  }
785 
786  template<typename NodeOp>
787  void processTopDown(const NodeOp& op, bool threaded = true, size_t grainSize=1)
788  {
789  op(mRoot);
790  mList3.foreach(op, threaded, grainSize);
791  mList2.foreach(op, threaded, grainSize);
792  mList1.foreach(op, threaded, grainSize);
793  mList0.foreach(op, threaded, grainSize);
794  }
795 
796 protected:
797  typedef RootNodeType NodeT4;
798  typedef typename NodeT4::ChildNodeType NodeT3;//upper level
799  typedef typename NodeT3::ChildNodeType NodeT2;//upper mid level
800  typedef typename NodeT2::ChildNodeType NodeT1;//lower mid level
801  typedef typename NodeT1::ChildNodeType NodeT0;//lower level
802 
803  typedef NodeList<NodeT3> ListT3;//upper level of internal nodes
804  typedef NodeList<NodeT2> ListT2;//upper mid level of internal nodes
805  typedef NodeList<NodeT1> ListT1;//lower mid level of internal nodes
806  typedef NodeList<NodeT0> ListT0;//lower level of internal nodes or leafs
807 
808  NodeT4& mRoot;
809  ListT3 mList3;
810  ListT2 mList2;
811  ListT1 mList1;
812  ListT0 mList0;
813 
814 private:
815  NodeManager(const NodeManager&) {} // disallow copy-construction
816 }; // NodeManager<4>
817 
818 } // namespace tree
819 } // namespace OPENVDB_VERSION_NAME
820 } // namespace openvdb
821 
822 #endif // OPENVDB_TREE_NODEMANAGER_HAS_BEEN_INCLUDED
823 
824 // Copyright (c) 2012-2015 DreamWorks Animation LLC
825 // All rights reserved. This software is distributed under the
826 // Mozilla Public License 2.0 ( http://www.mozilla.org/MPL/2.0/ )
Index64 nodeCount(Index i) const
Return the number of cached nodes at level i, where 0 corresponds to the lowest level.
Definition: NodeManager.h:671
const NodeList & nodeList() const
Definition: NodeManager.h:101
void processTopDown(const NodeOp &op, bool, size_t)
Definition: NodeManager.h:458
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:498
Mat3< typename promote< T0, T1 >::type > operator*(const Mat3< T0 > &m0, const Mat3< T1 > &m1)
Matrix multiplication.
Definition: Mat3.h:608
Index64 nodeCount() const
Return the total number of cached nodes (excluding the root node)
Definition: NodeManager.h:504
NodeT *& operator[](size_t n)
Definition: NodeManager.h:78
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:408
Index32 Index
Definition: Types.h:58
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:444
NodeT3::ChildNodeType NodeT2
Definition: NodeManager.h:799
bool empty() const
Definition: NodeManager.h:103
bool isValid() const
Definition: NodeManager.h:126
std::deque< value_type > ListT
Definition: NodeManager.h:70
NodeT4::ChildNodeType NodeT3
Definition: NodeManager.h:798
NodeT1::ChildNodeType NodeT0
Definition: NodeManager.h:608
void processTopDown(const NodeOp &op, bool threaded=true, size_t grainSize=1)
Definition: NodeManager.h:598
Index64 nodeCount() const
Return the total number of cached nodes (excluding the root node)
Definition: NodeManager.h:338
void processTopDown(const NodeOp &op, bool threaded=true, size_t grainSize=1)
Definition: NodeManager.h:518
void clear()
Clear all the cached tree nodes.
Definition: NodeManager.h:745
bool is_divisible() const
Definition: NodeManager.h:105
virtual ~NodeManager()
Definition: NodeManager.h:437
NodeT3::ChildNodeType NodeT2
Definition: NodeManager.h:697
Iterator begin() const
Definition: NodeManager.h:145
void clear()
Clear all the cached tree nodes.
Definition: NodeManager.h:651
virtual ~NodeManager()
Definition: NodeManager.h:491
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:401
void processTopDown(const NodeOp &op, bool threaded=true, size_t grainSize=1)
Definition: NodeManager.h:687
void processBottomUp(const NodeOp &op, bool threaded=true, size_t grainSize=1)
Definition: NodeManager.h:511
NodeTransformer(const NodeOp &nodeOp)
Definition: NodeManager.h:171
NodeManager(TreeOrLeafManagerT &tree)
Definition: NodeManager.h:634
void processTopDown(const NodeOp &op, bool threaded=true, size_t grainSize=1)
Definition: NodeManager.h:787
void clear()
Clear all the cached tree nodes.
Definition: NodeManager.h:565
void processBottomUp(const NodeOp &op, bool threaded=true, size_t grainSize=1)
Definition: NodeManager.h:678
NodeT & operator()(size_t n) const
Definition: NodeManager.h:76
virtual ~NodeManager()
Definition: NodeManager.h:742
TreeOrLeafManagerT::RootNodeType RootNodeType
Definition: NodeManager.h:545
void processBottomUp(const NodeOp &op, bool threaded=true, size_t grainSize=1)
Definition: NodeManager.h:777
const RootNodeType & root() const
Return a reference to the root node.
Definition: NodeManager.h:759
NodeManager(TreeOrLeafManagerT &tree)
Definition: NodeManager.h:727
NodeT2::ChildNodeType NodeT1
Definition: NodeManager.h:698
Index64 nodeCount(Index i) const
Return the number of cached nodes at level i, where 0 corresponds to the lowest level.
Definition: NodeManager.h:508
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:655
virtual ~NodeManager()
Definition: NodeManager.h:648
NodeList< NodeT2 > ListT2
Definition: NodeManager.h:701
virtual ~NodeManager()
Definition: NodeManager.h:562
const RootNodeType & root() const
Return a reference to the root node.
Definition: NodeManager.h:664
NodeManager(TreeOrLeafManagerT &tree)
Definition: NodeManager.h:480
NodeT2::ChildNodeType NodeT1
Definition: NodeManager.h:800
NodeList< NodeT2 > ListT2
Definition: NodeManager.h:804
void operator()(const NodeRange &range) const
Definition: NodeManager.h:176
NodeManager(TreeOrLeafManagerT &tree)
Definition: NodeManager.h:435
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:749
NodeList< NodeT1 > ListT1
Definition: NodeManager.h:805
Iterator & operator++()
Advance to the next node.
Definition: NodeManager.h:119
NodeT1::ChildNodeType NodeT0
Definition: NodeManager.h:526
RootNodeType & mRoot
Definition: NodeManager.h:461
NodeList< NodeT1 > ListT1
Definition: NodeManager.h:702
const NodeOp mNodeOp
Definition: NodeManager.h:180
NodeT1::ChildNodeType NodeT0
Definition: NodeManager.h:699
Iterator & operator=(const Iterator &other)
Definition: NodeManager.h:114
NodeManager(TreeOrLeafManagerT &tree)
Definition: NodeManager.h:549
NodeList< NodeT3 > ListT3
Definition: NodeManager.h:803
NodeT1::ChildNodeType NodeT0
Definition: NodeManager.h:801
NodeList< NodeT1 > ListT1
Definition: NodeManager.h:610
#define OPENVDB_VERSION_NAME
Definition: version.h:43
bool empty() const
Return true if this iterator is exhausted.
Definition: NodeManager.h:132
size_t size() const
Definition: NodeManager.h:97
size_t grainsize() const
Definition: NodeManager.h:99
TreeOrLeafManagerT::RootNodeType RootNodeType
Definition: NodeManager.h:723
NodeRange nodeRange(size_t grainsize=1) const
Return a TBB-compatible NodeRange.
Definition: NodeManager.h:163
const RootNodeType & root() const
Return a reference to the root node.
Definition: NodeManager.h:335
Index64 nodeCount(Index i) const
Return the number of cached nodes at level i, where 0 corresponds to the lowest level.
Definition: NodeManager.h:342
NodeRange(NodeRange &r, tbb::split)
Definition: NodeManager.h:93
size_t pos() const
Return the index into the list of the current node.
Definition: NodeManager.h:125
Index64 nodeCount(Index) const
Definition: NodeManager.h:452
Definition: NodeManager.h:86
NodeList< NodeT0 > ListT0
Definition: NodeManager.h:527
Iterator(const NodeRange &range, size_t pos)
Definition: NodeManager.h:110
NodeManager(TreeOrLeafManagerT &tree)
Definition: NodeManager.h:323
Definition: Exceptions.h:39
RootNodeType NodeT4
Definition: NodeManager.h:797
virtual ~NodeManager()
Definition: NodeManager.h:325
TreeOrLeafManagerT::RootNodeType RootNodeType
Definition: NodeManager.h:630
#define OPENVDB_NO_UNREACHABLE_CODE_WARNING_BEGIN
Definition: Platform.h:129
TreeOrLeafManagerT::RootNodeType RootNodeType
Definition: NodeManager.h:432
Index64 nodeCount() const
Definition: NodeManager.h:80
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:569
NodeT * value_type
Definition: NodeManager.h:69
TreeOrLeafManagerT::RootNodeType RootNodeType
Definition: NodeManager.h:476
Index64 nodeCount(Index i) const
Return the number of cached nodes at level i, where 0 corresponds to the lowest level.
Definition: NodeManager.h:584
bool test() const
Return true if this iterator is not yet exhausted.
Definition: NodeManager.h:128
const NodeRange & nodeRange() const
Definition: NodeManager.h:138
Index64 nodeCount() const
Return the total number of cached nodes (excluding the root node)
Definition: NodeManager.h:762
TreeOrLeafManagerT::RootNodeType RootNodeType
Definition: NodeManager.h:320
RootNodeType NodeT3
Definition: NodeManager.h:696
NodeRange(size_t begin, size_t end, const NodeList &nodeList, size_t grainSize=1)
Definition: NodeManager.h:90
NodeList()
Definition: NodeManager.h:72
#define OPENVDB_NO_UNREACHABLE_CODE_WARNING_END
Definition: Platform.h:130
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:56
Index64 nodeCount() const
Return the total number of cached nodes (excluding the root node)
Definition: NodeManager.h:667
bool operator!=(const Iterator &other) const
Definition: NodeManager.h:133
NodeManagerLink< typename RootNodeType::ChildNodeType, LEVELS-1 > mChain
Definition: NodeManager.h:417
void clear()
Clear all the cached tree nodes.
Definition: NodeManager.h:494
This class caches tree nodes of a specific type in a linear array.
Definition: NodeManager.h:66
NodeT2::ChildNodeType NodeT1
Definition: NodeManager.h:607
uint64_t Index64
Definition: Types.h:57
const RootNodeType & root() const
Return a reference to the root node.
Definition: NodeManager.h:577
void clear()
Clear all the cached tree nodes.
Definition: NodeManager.h:440
NodeList< NodeT0 > ListT0
Definition: NodeManager.h:703
ListT mList
Definition: NodeManager.h:191
Iterator end() const
Definition: NodeManager.h:147
NodeList< NodeT0 > ListT0
Definition: NodeManager.h:611
NodeList< NodeT0 > ListT0
Definition: NodeManager.h:806
RootNodeType NodeT1
Definition: NodeManager.h:525
NodeT * operator->() const
Return a pointer to the node to which this iterator is pointing.
Definition: NodeManager.h:123
RootNodeType & mRoot
Definition: NodeManager.h:416
void processBottomUp(const NodeOp &op, bool threaded=true, size_t grainSize=1)
Definition: NodeManager.h:590
bool operator==(const Iterator &other) const
Definition: NodeManager.h:137
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h:71
NodeT & operator*() const
Return a reference to the node to which this iterator is pointing.
Definition: NodeManager.h:121
RootNodeType NodeT2
Definition: NodeManager.h:606
void resize(size_t n)
Definition: NodeManager.h:84
void processBottomUp(const NodeOp &op, bool, size_t)
Definition: NodeManager.h:455
const RootNodeType & root() const
Return a reference to the root node.
Definition: NodeManager.h:447
Index64 nodeCount(Index i) const
Return the number of cached nodes at level i, where 0 corresponds to the lowest level.
Definition: NodeManager.h:770
void run(const NodeRange &range, bool threaded=true)
Definition: NodeManager.h:172
void clear()
Definition: NodeManager.h:82
void push_back(NodeT *node)
Definition: NodeManager.h:74
const RootNodeType & root() const
Return a reference to the root node.
Definition: NodeManager.h:501
Index64 nodeCount() const
Return the total number of cached nodes (excluding the root node)
Definition: NodeManager.h:580
void clear()
Clear all the cached tree nodes.
Definition: NodeManager.h:328
Index64 nodeCount() const
Return the total number of cached nodes (excluding the root node)
Definition: NodeManager.h:450
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:332