OpenVDB: LeafManager.h Source File

OpenVDB 3.1.0

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- File List
- File Members

LeafManager.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 //
41
42 #ifndef OPENVDB_TREE_LEAFMANAGER_HAS_BEEN_INCLUDED
43 #define OPENVDB_TREE_LEAFMANAGER_HAS_BEEN_INCLUDED
44
45 #include <boost/shared_ptr.hpp>
46 #include <boost/bind.hpp>
47 #include <boost/function.hpp>
48 #include <boost/mpl/if.hpp>
49 #include <boost/type_traits/is_const.hpp>
50 #include <boost/type_traits/is_pointer.hpp>
51 #include <boost/type_traits/is_same.hpp>
52 #include <boost/type_traits/remove_pointer.hpp>
53 #include <tbb/blocked_range.h>
54 #include <tbb/parallel_for.h>
55 #include <openvdb/Types.h>
56 #include "TreeIterator.h" // for CopyConstness
57
58 namespace openvdb {
59 OPENVDB_USE_VERSION_NAMESPACE
60 namespace OPENVDB_VERSION_NAME {
61 namespace tree {
62
63 namespace leafmgr {
64
66 template<typename TreeT> struct TreeTraits {
68 static const bool IsConstTree = false;
69 typedef typename TreeT::LeafIter LeafIterType;
70 };
71 template<typename TreeT> struct TreeTraits<const TreeT> {
72 static const bool IsConstTree = true;
73 typedef typename TreeT::LeafCIter LeafIterType;
74 };
76
77 } // namespace leafmgr
78
79
82 template<typename ManagerT>
83 struct LeafManagerImpl
84 {
85 typedef typename ManagerT::RangeType RangeT;
86 typedef typename ManagerT::LeafType LeafT;
87 typedef typename ManagerT::BufferType BufT;
88
89 static inline void doSwapLeafBuffer(const RangeT& r, size_t auxBufferIdx,
90 LeafT** leafs, BufT* bufs, size_t bufsPerLeaf)
91 {
92 for (size_t n = r.begin(), m = r.end(), N = bufsPerLeaf; n != m; ++n) {
93 leafs[n]->swap(bufs[n * N + auxBufferIdx]);
94 }
95 }
96 };
97
98
100
101
113 template<typename TreeT>
114 class LeafManager
115 {
116 public:
117 typedef TreeT TreeType;
118 typedef typename TreeT::ValueType ValueType;
119 typedef typename TreeT::RootNodeType RootNodeType;
120 typedef typename TreeType::LeafNodeType NonConstLeafType;
121 typedef typename CopyConstness<TreeType, NonConstLeafType>::Type LeafType;
122 typedef LeafType LeafNodeType;
123 typedef typename leafmgr::TreeTraits<TreeT>::LeafIterType LeafIterType;
124 typedef typename LeafType::Buffer NonConstBufferType;
125 typedef typename CopyConstness<TreeType, NonConstBufferType>::Type BufferType;
126 typedef tbb::blocked_range<size_t> RangeType;//leaf index range
127 static const Index DEPTH = 2;//root + leafs
128
129 static const bool IsConstTree = leafmgr::TreeTraits<TreeT>::IsConstTree;
130
131 class LeafRange
132 {
133 public:
134 class Iterator
135 {
136 public:
137 Iterator(const LeafRange& range, size_t pos): mRange(range), mPos(pos)
138 {
139 assert(this->isValid());
140 }
141 Iterator& operator=(const Iterator& other)
142 {
143 mRange = other.mRange; mPos = other.mPos; return *this;
144 }
146 Iterator& operator++() { ++mPos; return *this; }
148 LeafType& operator*() const { return mRange.mLeafManager.leaf(mPos); }
150 LeafType* operator->() const { return &(this->operator*()); }
153 BufferType& buffer(size_t bufferIdx)
154 {
155 return mRange.mLeafManager.getBuffer(mPos, bufferIdx);
156 }
158 size_t pos() const { return mPos; }
159 bool isValid() const { return mPos>=mRange.mBegin && mPos<=mRange.mEnd; }
161 bool test() const { return mPos < mRange.mEnd; }
163 operator bool() const { return this->test(); }
165 bool empty() const { return !this->test(); }
166 bool operator!=(const Iterator& other) const
167 {
168 return (mPos != other.mPos) || (&mRange != &other.mRange);
169 }
170 bool operator==(const Iterator& other) const { return !(*this != other); }
171 const LeafRange& leafRange() const { return mRange; }
172
173 private:
174 const LeafRange& mRange;
175 size_t mPos;
176 };// end Iterator
177
178 LeafRange(size_t begin, size_t end, const LeafManager& leafManager, size_t grainSize=1):
179 mEnd(end), mBegin(begin), mGrainSize(grainSize), mLeafManager(leafManager) {}
180
181 Iterator begin() const {return Iterator(*this, mBegin);}
182
183 Iterator end() const {return Iterator(*this, mEnd);}
184
185 size_t size() const { return mEnd - mBegin; }
186
187 size_t grainsize() const { return mGrainSize; }
188
189 const LeafManager& leafManager() const { return mLeafManager; }
190
191 bool empty() const {return !(mBegin < mEnd);}
192
193 bool is_divisible() const {return mGrainSize < this->size();}
194
195 LeafRange(LeafRange& r, tbb::split):
196 mEnd(r.mEnd), mBegin(doSplit(r)), mGrainSize(r.mGrainSize),
197 mLeafManager(r.mLeafManager) {}
198
199 private:
200 size_t mEnd, mBegin, mGrainSize;
201 const LeafManager& mLeafManager;
202
203 static size_t doSplit(LeafRange& r)
204 {
205 assert(r.is_divisible());
206 size_t middle = r.mBegin + (r.mEnd - r.mBegin) / 2u;
207 r.mEnd = middle;
208 return middle;
209 }
210 };// end of LeafRange
211
214 LeafManager(TreeType& tree, size_t auxBuffersPerLeaf=0, bool serial=false):
215 mTree(&tree),
216 mLeafCount(0),
217 mAuxBufferCount(0),
218 mAuxBuffersPerLeaf(auxBuffersPerLeaf),
219 mLeafs(NULL),
220 mAuxBuffers(NULL),
221 mTask(0),
222 mIsMaster(true)
223 {
224 this->rebuild(serial);
225 }
226
230 LeafManager(const LeafManager& other):
231 mTree(other.mTree),
232 mLeafCount(other.mLeafCount),
233 mAuxBufferCount(other.mAuxBufferCount),
234 mAuxBuffersPerLeaf(other.mAuxBuffersPerLeaf),
235 mLeafs(other.mLeafs),
236 mAuxBuffers(other.mAuxBuffers),
237 mTask(other.mTask),
238 mIsMaster(false)
239 {
240 }
241
242 virtual ~LeafManager()
243 {
244 if (mIsMaster) {
245 delete [] mLeafs;
246 delete [] mAuxBuffers;
247 }
248 }
249
255 void rebuild(bool serial=false)
256 {
257 this->initLeafArray();
258 this->initAuxBuffers(serial);
259 }
261 void rebuild(size_t auxBuffersPerLeaf, bool serial=false)
263 {
264 mAuxBuffersPerLeaf = auxBuffersPerLeaf;
265 this->rebuild(serial);
266 }
267 void rebuild(TreeType& tree, bool serial=false)
268 {
269 mTree = &tree;
270 this->rebuild(serial);
271 }
272 void rebuild(TreeType& tree, size_t auxBuffersPerLeaf, bool serial=false)
273 {
274 mTree = &tree;
275 mAuxBuffersPerLeaf = auxBuffersPerLeaf;
276 this->rebuild(serial);
277 }
279 void rebuildAuxBuffers(size_t auxBuffersPerLeaf, bool serial=false)
284 {
285 mAuxBuffersPerLeaf = auxBuffersPerLeaf;
286 this->initAuxBuffers(serial);
287 }
289 void removeAuxBuffers() { this->rebuildAuxBuffers(0); }
290
292 void rebuildLeafArray()
293 {
294 this->removeAuxBuffers();
295 this->initLeafArray();
296 }
297
299 size_t auxBufferCount() const { return mAuxBufferCount; }
301 size_t auxBuffersPerLeaf() const { return mAuxBuffersPerLeaf; }
302
304 size_t leafCount() const { return mLeafCount; }
305
307 const TreeType& tree() const { return *mTree; }
308
310 TreeType& tree() { return *mTree; }
311
313 const RootNodeType& root() const { return mTree->root(); }
314
316 RootNodeType& root() { return mTree->root(); }
317
319 bool isConstTree() const { return this->IsConstTree; }
320
323 LeafType& leaf(size_t leafIdx) const { assert(leafIdx<mLeafCount); return *mLeafs[leafIdx]; }
324
335 BufferType& getBuffer(size_t leafIdx, size_t bufferIdx) const
336 {
337 assert(leafIdx < mLeafCount);
338 assert(bufferIdx == 0 || bufferIdx - 1 < mAuxBuffersPerLeaf);
339 return bufferIdx == 0 ? mLeafs[leafIdx]->buffer()
340 : mAuxBuffers[leafIdx * mAuxBuffersPerLeaf + bufferIdx - 1];
341 }
342
347 RangeType getRange(size_t grainsize = 1) const { return RangeType(0, mLeafCount, grainsize); }
348
350 LeafRange leafRange(size_t grainsize = 1) const
351 {
352 return LeafRange(0, mLeafCount, *this, grainsize);
353 }
354
364 bool swapLeafBuffer(size_t bufferIdx, bool serial = false)
365 {
366 if (bufferIdx == 0 || bufferIdx > mAuxBuffersPerLeaf || this->isConstTree()) return false;
367 mTask = boost::bind(&LeafManager::doSwapLeafBuffer, _1, _2, bufferIdx - 1);
368 this->cook(serial ? 0 : 512);
369 return true;//success
370 }
375 bool swapBuffer(size_t bufferIdx1, size_t bufferIdx2, bool serial = false)
376 {
377 const size_t b1 = std::min(bufferIdx1, bufferIdx2);
378 const size_t b2 = std::max(bufferIdx1, bufferIdx2);
379 if (b1 == b2 || b2 > mAuxBuffersPerLeaf) return false;
380 if (b1 == 0) {
381 if (this->isConstTree()) return false;
382 mTask = boost::bind(&LeafManager::doSwapLeafBuffer, _1, _2, b2-1);
383 } else {
384 mTask = boost::bind(&LeafManager::doSwapAuxBuffer, _1, _2, b1-1, b2-1);
385 }
386 this->cook(serial ? 0 : 512);
387 return true;//success
388 }
389
398 bool syncAuxBuffer(size_t bufferIdx, bool serial = false)
399 {
400 if (bufferIdx == 0 || bufferIdx > mAuxBuffersPerLeaf) return false;
401 mTask = boost::bind(&LeafManager::doSyncAuxBuffer, _1, _2, bufferIdx - 1);
402 this->cook(serial ? 0 : 64);
403 return true;//success
404 }
405
409 bool syncAllBuffers(bool serial = false)
410 {
411 switch (mAuxBuffersPerLeaf) {
412 case 0: return false;//nothing to do
413 case 1: mTask = boost::bind(&LeafManager::doSyncAllBuffers1, _1, _2); break;
414 case 2: mTask = boost::bind(&LeafManager::doSyncAllBuffers2, _1, _2); break;
415 default: mTask = boost::bind(&LeafManager::doSyncAllBuffersN, _1, _2); break;
416 }
417 this->cook(serial ? 0 : 64);
418 return true;//success
419 }
420
480 template<typename LeafOp>
481 void foreach(const LeafOp& op, bool threaded = true, size_t grainSize=1)
482 {
483 LeafTransformer<LeafOp> transform(op);
484 transform.run(this->leafRange(grainSize), threaded);
485 }
486
487
488 template<typename ArrayT>
489 void getNodes(ArrayT& array)
490 {
491 typedef typename ArrayT::value_type T;
492 BOOST_STATIC_ASSERT(boost::is_pointer<T>::value);
493 typedef typename boost::mpl::if_<boost::is_const<typename boost::remove_pointer<T>::type>,
494 const LeafType, LeafType>::type LeafT;
495
496 OPENVDB_NO_UNREACHABLE_CODE_WARNING_BEGIN
497 if (boost::is_same<T, LeafT*>::value) {
498 array.resize(mLeafCount);
499 for (size_t i=0; i<mLeafCount; ++i) array[i] = reinterpret_cast<T>(mLeafs[i]);
500 } else {
501 mTree->getNodes(array);
502 }
503 OPENVDB_NO_UNREACHABLE_CODE_WARNING_END
504 }
505
506 template<typename ArrayT>
507 void getNodes(ArrayT& array) const
508 {
509 typedef typename ArrayT::value_type T;
510 BOOST_STATIC_ASSERT(boost::is_pointer<T>::value);
511 BOOST_STATIC_ASSERT(boost::is_const<typename boost::remove_pointer<T>::type>::value);
512
513 OPENVDB_NO_UNREACHABLE_CODE_WARNING_BEGIN
514 if (boost::is_same<T, const LeafType*>::value) {
515 array.resize(mLeafCount);
516 for (size_t i=0; i<mLeafCount; ++i) array[i] = reinterpret_cast<T>(mLeafs[i]);
517 } else {
518 mTree->getNodes(array);
519 }
520 OPENVDB_NO_UNREACHABLE_CODE_WARNING_END
521 }
522
524 // All methods below are for internal use only and should never be called directly
525
527 void operator()(const RangeType& r) const
528 {
529 if (mTask) mTask(const_cast<LeafManager*>(this), r);
530 else OPENVDB_THROW(ValueError, "task is undefined");
531 }
532
533
534
535 private:
536
537 // This a simple wrapper for a c-style array so it mimics the api
538 // of a std container, e.g. std::vector or std::deque, and can be
539 // passed to Tree::getNodes().
540 struct MyArray {
541 typedef LeafType* value_type;//required by Tree::getNodes
542 value_type* ptr;
543 MyArray(value_type* array) : ptr(array) {}
544 void push_back(value_type leaf) { *ptr++ = leaf; }//required by Tree::getNodes
545 };
546
547 void initLeafArray()
548 {
549 const size_t leafCount = mTree->leafCount();
550 if (leafCount != mLeafCount) {
551 delete [] mLeafs;
552 mLeafs = (leafCount == 0) ? NULL : new LeafType*[leafCount];
553 mLeafCount = leafCount;
554 }
555 MyArray a(mLeafs);
556 mTree->getNodes(a);
557 }
558
559 void initAuxBuffers(bool serial)
560 {
561 const size_t auxBufferCount = mLeafCount * mAuxBuffersPerLeaf;
562 if (auxBufferCount != mAuxBufferCount) {
563 delete [] mAuxBuffers;
564 mAuxBuffers = (auxBufferCount == 0) ? NULL : new NonConstBufferType[auxBufferCount];
565 mAuxBufferCount = auxBufferCount;
566 }
567 this->syncAllBuffers(serial);
568 }
569
570 void cook(size_t grainsize)
571 {
572 if (grainsize>0) {
573 tbb::parallel_for(this->getRange(grainsize), *this);
574 } else {
575 (*this)(this->getRange());
576 }
577 }
578
579 void doSwapLeafBuffer(const RangeType& r, size_t auxBufferIdx)
580 {
581 LeafManagerImpl<LeafManager>::doSwapLeafBuffer(
582 r, auxBufferIdx, mLeafs, mAuxBuffers, mAuxBuffersPerLeaf);
583 }
584
585 void doSwapAuxBuffer(const RangeType& r, size_t auxBufferIdx1, size_t auxBufferIdx2)
586 {
587 for (size_t N = mAuxBuffersPerLeaf, n = N*r.begin(), m = N*r.end(); n != m; n+=N) {
588 mAuxBuffers[n + auxBufferIdx1].swap(mAuxBuffers[n + auxBufferIdx2]);
589 }
590 }
591
592 void doSyncAuxBuffer(const RangeType& r, size_t auxBufferIdx)
593 {
594 for (size_t n = r.begin(), m = r.end(), N = mAuxBuffersPerLeaf; n != m; ++n) {
595 mAuxBuffers[n*N + auxBufferIdx] = mLeafs[n]->buffer();
596 }
597 }
598
599 void doSyncAllBuffers1(const RangeType& r)
600 {
601 for (size_t n = r.begin(), m = r.end(); n != m; ++n) {
602 mAuxBuffers[n] = mLeafs[n]->buffer();
603 }
604 }
605
606 void doSyncAllBuffers2(const RangeType& r)
607 {
608 for (size_t n = r.begin(), m = r.end(); n != m; ++n) {
609 const BufferType& leafBuffer = mLeafs[n]->buffer();
610 mAuxBuffers[2*n ] = leafBuffer;
611 mAuxBuffers[2*n+1] = leafBuffer;
612 }
613 }
614
615 void doSyncAllBuffersN(const RangeType& r)
616 {
617 for (size_t n = r.begin(), m = r.end(), N = mAuxBuffersPerLeaf; n != m; ++n) {
618 const BufferType& leafBuffer = mLeafs[n]->buffer();
619 for (size_t i=n*N, j=i+N; i!=j; ++i) mAuxBuffers[i] = leafBuffer;
620 }
621 }
622
625 template<typename LeafOp>
626 struct LeafTransformer
627 {
628 LeafTransformer(const LeafOp& leafOp) : mLeafOp(leafOp) {}
629 void run(const LeafRange& range, bool threaded = true)
630 {
631 threaded ? tbb::parallel_for(range, *this) : (*this)(range);
632 }
633 void operator()(const LeafRange& range) const
634 {
635 for (typename LeafRange::Iterator it = range.begin(); it; ++it) mLeafOp(*it, it.pos());
636 }
637 const LeafOp mLeafOp;
638 };
639
640 typedef typename boost::function<void (LeafManager*, const RangeType&)> FuncType;
641
642 TreeType* mTree;
643 size_t mLeafCount, mAuxBufferCount, mAuxBuffersPerLeaf;
644 LeafType** mLeafs;//array of LeafNode pointers
645 NonConstBufferType* mAuxBuffers;//array of auxiliary buffers
646 FuncType mTask;
647 const bool mIsMaster;
648 };//end of LeafManager class
649
650
651 // Partial specializations of LeafManager methods for const trees
652 template<typename TreeT>
653 struct LeafManagerImpl<LeafManager<const TreeT> >
654 {
655 typedef LeafManager<const TreeT> ManagerT;
656 typedef typename ManagerT::RangeType RangeT;
657 typedef typename ManagerT::LeafType LeafT;
658 typedef typename ManagerT::BufferType BufT;
659
660 static inline void doSwapLeafBuffer(const RangeT&, size_t /*auxBufferIdx*/,
661 LeafT**, BufT*, size_t /*bufsPerLeaf*/)
662 {
663 // Buffers can't be swapped into const trees.
664 }
665 };
666
667 } // namespace tree
668 } // namespace OPENVDB_VERSION_NAME
669 } // namespace openvdb
670
671 #endif // OPENVDB_TREE_LEAFMANAGER_HAS_BEEN_INCLUDED
672
673 // Copyright (c) 2012-2015 DreamWorks Animation LLC
674 // All rights reserved. This software is distributed under the
675 // Mozilla Public License 2.0 ( http://www.mozilla.org/MPL/2.0/ )
openvdb::v3_1_0::math::operator*
Mat3< typename promote< T0, T1 >::type > operator*(const Mat3< T0 > &m0, const Mat3< T1 > &m1)
Matrix multiplication.
Definition: Mat3.h:608
openvdb::v3_1_0::tree::LeafManager::LeafRange::LeafRange
LeafRange(size_t begin, size_t end, const LeafManager &leafManager, size_t grainSize=1)
Definition: LeafManager.h:178
openvdb::v3_1_0::tree::LeafManager::LeafRange::Iterator::operator!=
bool operator!=(const Iterator &other) const
Definition: LeafManager.h:166
openvdb::v3_1_0::Index
Index32 Index
Definition: Types.h:58
openvdb::v3_1_0::tree::LeafManager::auxBuffersPerLeaf
size_t auxBuffersPerLeaf() const
Return the number of auxiliary buffers per leaf node.
Definition: LeafManager.h:301
Types.h
openvdb::v3_1_0::tree::LeafManager::getBuffer
BufferType & getBuffer(size_t leafIdx, size_t bufferIdx) const
Return the leaf or auxiliary buffer for the leaf node at index leafIdx. If bufferIdx is zero...
Definition: LeafManager.h:335
openvdb::v3_1_0::tree::LeafManager::LeafRange::Iterator::buffer
BufferType & buffer(size_t bufferIdx)
Return the nth buffer for the leaf node to which this iterator is pointing, where n = bufferIdx and n...
Definition: LeafManager.h:153
openvdb::v3_1_0::tree::LeafManager::LeafRange::Iterator::test
bool test() const
Return true if this iterator is not yet exhausted.
Definition: LeafManager.h:161
openvdb::v3_1_0::tree::leafmgr::TreeTraits
Useful traits for Tree types.
Definition: LeafManager.h:67
openvdb::v3_1_0::tree::LeafManagerImpl::BufT
ManagerT::BufferType BufT
Definition: LeafManager.h:87
openvdb::v3_1_0::ValueError
Definition: Exceptions.h:88
openvdb::v3_1_0::tree::LeafManager::syncAllBuffers
bool syncAllBuffers(bool serial=false)
Sync up all auxiliary buffers with their corresponding leaf node buffers.
Definition: LeafManager.h:409
openvdb::v3_1_0::tree::LeafManager::LeafRange::empty
bool empty() const
Definition: LeafManager.h:191
openvdb::v3_1_0::tree::LeafManager::LeafRange::Iterator::operator->
LeafType * operator->() const
Return a pointer to the leaf node to which this iterator is pointing.
Definition: LeafManager.h:150
OPENVDB_THROW
#define OPENVDB_THROW(exception, message)
Definition: Exceptions.h:97
openvdb::v3_1_0::tree::LeafManager::leafRange
LeafRange leafRange(size_t grainsize=1) const
Return a TBB-compatible LeafRange.
Definition: LeafManager.h:350
openvdb::v3_1_0::tree::leafmgr::TreeTraits< const TreeT >::LeafIterType
TreeT::LeafCIter LeafIterType
Definition: LeafManager.h:73
openvdb::v3_1_0::tree::LeafManager::rebuildLeafArray
void rebuildLeafArray()
Remove the auxiliary buffers and rebuild the leaf array.
Definition: LeafManager.h:292
openvdb::v3_1_0::tree::LeafManager
This class manages a linear array of pointers to a given tree&#39;s leaf nodes, as well as optional auxil...
Definition: LeafManager.h:114
openvdb::v3_1_0::tree::LeafManager::auxBufferCount
size_t auxBufferCount() const
Return the total number of allocated auxiliary buffers.
Definition: LeafManager.h:299
openvdb::v3_1_0::tree::LeafManager::NonConstBufferType
LeafType::Buffer NonConstBufferType
Definition: LeafManager.h:124
openvdb::v3_1_0::tree::LeafManager::LeafRange::Iterator::operator++
Iterator & operator++()
Advance to the next leaf node.
Definition: LeafManager.h:146
openvdb::v3_1_0::tree::LeafManager::LeafRange::leafManager
const LeafManager & leafManager() const
Definition: LeafManager.h:189
openvdb::v3_1_0::tree::CopyConstness::Type
boost::remove_const< ToType >::type Type
Definition: TreeIterator.h:66
openvdb::v3_1_0::tools::composite::min
const boost::disable_if_c< VecTraits< T >::IsVec, T >::type & min(const T &a, const T &b)
Definition: Composite.h:105
openvdb::v3_1_0::tree::LeafManager::LeafManager
LeafManager(TreeType &tree, size_t auxBuffersPerLeaf=0, bool serial=false)
Constructor from a tree reference and an auxiliary buffer count (default is no auxiliary buffers) ...
Definition: LeafManager.h:214
openvdb::v3_1_0::tree::LeafManagerImpl< LeafManager< const TreeT > >::RangeT
ManagerT::RangeType RangeT
Definition: LeafManager.h:656
openvdb::v3_1_0::tree::LeafManager::swapLeafBuffer
bool swapLeafBuffer(size_t bufferIdx, bool serial=false)
Swap each leaf node&#39;s buffer with the nth corresponding auxiliary buffer, where n = bufferIdx...
Definition: LeafManager.h:364
openvdb::v3_1_0::tree::LeafManager::LeafRange::Iterator::operator=
Iterator & operator=(const Iterator &other)
Definition: LeafManager.h:141
openvdb::v3_1_0::tree::LeafManager::LeafRange::end
Iterator end() const
Definition: LeafManager.h:183
openvdb::v3_1_0::tree::LeafManagerImpl< LeafManager< const TreeT > >::ManagerT
LeafManager< const TreeT > ManagerT
Definition: LeafManager.h:655
openvdb::v3_1_0::tree::LeafManager::LeafRange::Iterator::leafRange
const LeafRange & leafRange() const
Definition: LeafManager.h:171
openvdb::v3_1_0::tree::LeafManager::LeafRange::begin
Iterator begin() const
Definition: LeafManager.h:181
openvdb::v3_1_0::tree::LeafManager::LeafIterType
leafmgr::TreeTraits< TreeT >::LeafIterType LeafIterType
Definition: LeafManager.h:123
openvdb::v3_1_0::tree::LeafManager::getNodes
void getNodes(ArrayT &array) const
Definition: LeafManager.h:507
openvdb::v3_1_0::tree::LeafManager::rebuild
void rebuild(bool serial=false)
(Re)initialize by resizing (if necessary) and repopulating the leaf array and by deleting existing au...
Definition: LeafManager.h:255
openvdb::v3_1_0::tree::LeafManager::leaf
LeafType & leaf(size_t leafIdx) const
Return a pointer to the leaf node at index leafIdx in the array.
Definition: LeafManager.h:323
openvdb::v3_1_0::tree::LeafManager::LeafRange::Iterator::operator*
LeafType & operator*() const
Return a reference to the leaf node to which this iterator is pointing.
Definition: LeafManager.h:148
openvdb::v3_1_0::tree::LeafManagerImpl::RangeT
ManagerT::RangeType RangeT
Definition: LeafManager.h:85
TreeIterator.h
openvdb::v3_1_0::tree::LeafManager::LeafRange::Iterator::pos
size_t pos() const
Return the index into the leaf array of the current leaf node.
Definition: LeafManager.h:158
OPENVDB_VERSION_NAME
#define OPENVDB_VERSION_NAME
Definition: version.h:43
openvdb::v3_1_0::tree::LeafManager::rebuild
void rebuild(TreeType &tree, size_t auxBuffersPerLeaf, bool serial=false)
Repopulate the leaf array and delete and reallocate auxiliary buffers.
Definition: LeafManager.h:272
openvdb::v3_1_0::tree::LeafManager::RangeType
tbb::blocked_range< size_t > RangeType
Definition: LeafManager.h:126
openvdb::v3_1_0::tree::LeafManager::tree
const TreeType & tree() const
Return a const reference to tree associated with this manager.
Definition: LeafManager.h:307
openvdb::v3_1_0::tree::LeafManager::TreeType
TreeT TreeType
Definition: LeafManager.h:117
openvdb::v3_1_0::tree::LeafManagerImpl< LeafManager< const TreeT > >::LeafT
ManagerT::LeafType LeafT
Definition: LeafManager.h:657
openvdb::v3_1_0::tree::LeafManager::root
RootNodeType & root()
Return a reference to the root node associated with this manager.
Definition: LeafManager.h:316
openvdb::v3_1_0::tree::LeafManager::LeafRange::Iterator::isValid
bool isValid() const
Definition: LeafManager.h:159
openvdb::v3_1_0::tree::LeafManager::LeafRange::Iterator::empty
bool empty() const
Return true if this iterator is exhausted.
Definition: LeafManager.h:165
openvdb
Definition: Exceptions.h:39
openvdb::v3_1_0::tree::LeafManager::syncAuxBuffer
bool syncAuxBuffer(size_t bufferIdx, bool serial=false)
Sync up the specified auxiliary buffer with the corresponding leaf node buffer.
Definition: LeafManager.h:398
OPENVDB_NO_UNREACHABLE_CODE_WARNING_BEGIN
#define OPENVDB_NO_UNREACHABLE_CODE_WARNING_BEGIN
Definition: Platform.h:129
openvdb::v3_1_0::tree::LeafManager::rebuild
void rebuild(TreeType &tree, bool serial=false)
Repopulate the leaf array and delete and reallocate auxiliary buffers.
Definition: LeafManager.h:267
openvdb::v3_1_0::tree::LeafManager::LeafRange::grainsize
size_t grainsize() const
Definition: LeafManager.h:187
openvdb::v3_1_0::tree::LeafManager::leafCount
size_t leafCount() const
Return the number of leaf nodes.
Definition: LeafManager.h:304
openvdb::v3_1_0::tree::LeafManager::BufferType
CopyConstness< TreeType, NonConstBufferType >::Type BufferType
Definition: LeafManager.h:125
openvdb::v3_1_0::tree::LeafManager::LeafManager
LeafManager(const LeafManager &other)
Definition: LeafManager.h:230
openvdb::v3_1_0::tree::leafmgr::TreeTraits::LeafIterType
TreeT::LeafIter LeafIterType
Definition: LeafManager.h:69
openvdb::v3_1_0::tree::LeafManager::ValueType
TreeT::ValueType ValueType
Definition: LeafManager.h:118
openvdb::v3_1_0::tree::LeafManager::swapBuffer
bool swapBuffer(size_t bufferIdx1, size_t bufferIdx2, bool serial=false)
Swap any two buffers for each leaf node.
Definition: LeafManager.h:375
OPENVDB_NO_UNREACHABLE_CODE_WARNING_END
#define OPENVDB_NO_UNREACHABLE_CODE_WARNING_END
Definition: Platform.h:130
openvdb::v3_1_0::tree::LeafManager::~LeafManager
virtual ~LeafManager()
Definition: LeafManager.h:242
openvdb::v3_1_0::tree::LeafManager::LeafRange::size
size_t size() const
Definition: LeafManager.h:185
openvdb::v3_1_0::tree::LeafManagerImpl< LeafManager< const TreeT > >::doSwapLeafBuffer
static void doSwapLeafBuffer(const RangeT &, size_t, LeafT **, BufT *, size_t)
Definition: LeafManager.h:660
openvdb::v3_1_0::tools::composite::max
const boost::disable_if_c< VecTraits< T >::IsVec, T >::type & max(const T &a, const T &b)
Definition: Composite.h:109
openvdb::v3_1_0::tree::LeafManagerImpl< LeafManager< const TreeT > >::BufT
ManagerT::BufferType BufT
Definition: LeafManager.h:658
openvdb::v3_1_0::tree::LeafManager::tree
TreeType & tree()
Return a reference to the tree associated with this manager.
Definition: LeafManager.h:310
openvdb::v3_1_0::tree::LeafManager::LeafRange::is_divisible
bool is_divisible() const
Definition: LeafManager.h:193
openvdb::v3_1_0::tree::LeafManager::LeafRange::LeafRange
LeafRange(LeafRange &r, tbb::split)
Definition: LeafManager.h:195
openvdb::v3_1_0::tree::LeafManager::getRange
RangeType getRange(size_t grainsize=1) const
Return a tbb::blocked_range of leaf array indices.
Definition: LeafManager.h:347
openvdb::v3_1_0::tree::LeafManagerImpl::doSwapLeafBuffer
static void doSwapLeafBuffer(const RangeT &r, size_t auxBufferIdx, LeafT **leafs, BufT *bufs, size_t bufsPerLeaf)
Definition: LeafManager.h:89
openvdb::v3_1_0::tree::LeafManager::operator()
void operator()(const RangeType &r) const
Used internally by tbb::parallel_for() - never call it directly!
Definition: LeafManager.h:527
openvdb::v3_1_0::tree::LeafManager::LeafRange::Iterator
Definition: LeafManager.h:134
openvdb::v3_1_0::tree::LeafManager::getNodes
void getNodes(ArrayT &array)
Definition: LeafManager.h:489
openvdb::v3_1_0::tree::LeafManagerImpl
Definition: LeafManager.h:83
openvdb::v3_1_0::tree::LeafManager::LeafRange::Iterator::operator==
bool operator==(const Iterator &other) const
Definition: LeafManager.h:170
OPENVDB_USE_VERSION_NAMESPACE
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h:71
openvdb::v3_1_0::tree::LeafManagerImpl::LeafT
ManagerT::LeafType LeafT
Definition: LeafManager.h:86
openvdb::v3_1_0::tree::LeafManager::LeafType
CopyConstness< TreeType, NonConstLeafType >::Type LeafType
Definition: LeafManager.h:121
openvdb::v3_1_0::tree::LeafManager::LeafNodeType
LeafType LeafNodeType
Definition: LeafManager.h:122
openvdb::v3_1_0::tree::LeafManager::isConstTree
bool isConstTree() const
Return true if the tree associated with this manager is immutable.
Definition: LeafManager.h:319
openvdb::v3_1_0::tree::LeafManager::NonConstLeafType
TreeType::LeafNodeType NonConstLeafType
Definition: LeafManager.h:120
openvdb::v3_1_0::tree::LeafManager::LeafRange::Iterator::Iterator
Iterator(const LeafRange &range, size_t pos)
Definition: LeafManager.h:137
openvdb::v3_1_0::tree::LeafManager::root
const RootNodeType & root() const
Return a const reference to root node associated with this manager.
Definition: LeafManager.h:313
openvdb::v3_1_0::tree::LeafManager::removeAuxBuffers
void removeAuxBuffers()
Remove the auxiliary buffers, but don&#39;t rebuild the leaf array.
Definition: LeafManager.h:289
openvdb::v3_1_0::tree::LeafManager::LeafRange
Definition: LeafManager.h:131
openvdb::v3_1_0::tree::LeafManager::RootNodeType
TreeT::RootNodeType RootNodeType
Definition: LeafManager.h:119