OpenVDB 3.2.0

LeafNodeMask.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
31 #ifndef OPENVDB_TREE_LEAF_NODE_MASK_HAS_BEEN_INCLUDED
32 #define OPENVDB_TREE_LEAF_NODE_MASK_HAS_BEEN_INCLUDED
33
34 #include <iostream>
35 #include <boost/shared_ptr.hpp>
36 #include <boost/shared_array.hpp>
37 #include <boost/static_assert.hpp>
38 #include <openvdb/Types.h>
39 #include <openvdb/io/Compression.h> // for io::readData(), etc.
40 #include <openvdb/math/Math.h> // for math::isZero()
41 #include <openvdb/util/NodeMasks.h>
42 #include "LeafNode.h"
43 #include "Iterator.h"
44
45
46 namespace openvdb {
47 OPENVDB_USE_VERSION_NAMESPACE
48 namespace OPENVDB_VERSION_NAME {
49 namespace tree {
50
54 template<Index Log2Dim>
55 class LeafNode<ValueMask, Log2Dim>
56 {
57 public:
58 typedef LeafNode<ValueMask, Log2Dim> LeafNodeType;
59 typedef boost::shared_ptr<LeafNodeType> Ptr;
60 typedef ValueMask BuildType;// this is a rare case where
61 typedef bool ValueType;// value type != build type
62 typedef util::NodeMask<Log2Dim> NodeMaskType;
63
64 // These static declarations must be on separate lines to avoid VC9 compiler errors.
65 static const Index LOG2DIM = Log2Dim; // needed by parent nodes
66 static const Index TOTAL = Log2Dim; // needed by parent nodes
67 static const Index DIM = 1 << TOTAL; // dimension along one coordinate direction
68 static const Index NUM_VALUES = 1 << 3 * Log2Dim;
69 static const Index NUM_VOXELS = NUM_VALUES; // total number of voxels represented by this node
70 static const Index SIZE = NUM_VALUES;
71 static const Index LEVEL = 0; // level 0 = leaf
72
75 template<typename OtherValueType>
76 struct ValueConverter {
77 typedef LeafNode<OtherValueType, Log2Dim> Type;
78 };
79
82 template<typename OtherNodeType>
83 struct SameConfiguration {
84 static const bool value = SameLeafConfig<LOG2DIM, OtherNodeType>::value;
85 };
86
87 class Buffer
88 {
89 public:
90 typedef typename NodeMaskType::Word WordType;
91 static const Index WORD_COUNT = NodeMaskType::WORD_COUNT;
92 Buffer() {}
93 explicit Buffer(bool on) : mData(on) {}
94 Buffer(const NodeMaskType& other): mData(other) {}
95 Buffer(const Buffer& other): mData(other.mData) {}
96 ~Buffer() {}
97 void fill(bool val) { mData.set(val); }
98 Buffer& operator=(const Buffer& b)
99 {
100 if (&b != this) mData = b.mData;
101 return *this;
102 }
103
104 const bool& getValue(Index i) const
105 {
106 assert(i < SIZE);
107 // We can't use the ternary operator here, otherwise Visual C++ returns
108 // a reference to a temporary.
109 if (mData.isOn(i)) return LeafNode::sOn;
110 return LeafNode::sOff;
111 }
112 const bool& operator[](Index i) const { return this->getValue(i); }
113
114 bool operator==(const Buffer& other) const { return mData == other.mData; }
115 bool operator!=(const Buffer& other) const { return mData != other.mData; }
116
117 void setValue(Index i, bool val) { assert(i < SIZE); mData.set(i, val); }
118
119 void swap(Buffer& other) { if (&other != this) std::swap(mData, other.mData); }
120
121 Index memUsage() const { return mData.memUsage(); }
122 static Index size() { return SIZE; }
123
127 WordType* data()
128 {
129 return &(mData.template getWord<WordType>(0));
130 }
135 const WordType* data() const
136 {
137 return const_cast<Buffer*>(this)->data();
138 }
139
140 private:
141 friend class ::TestLeaf;
142 // Allow the parent LeafNode to access this Buffer's bit mask.
143 friend class LeafNode;
144
145 NodeMaskType mData;
146 }; // class Buffer
147
148
150 LeafNode();
151
156 explicit LeafNode(const Coord& xyz, bool value = false, bool dummy = false);
157
158 #ifndef OPENVDB_2_ABI_COMPATIBLE
159 LeafNode(PartialCreate, const Coord& xyz, bool value = false, bool dummy = false);
161 #endif
162
164 LeafNode(const LeafNode&);
165
167 template<typename OtherValueType>
168 explicit LeafNode(const LeafNode<OtherValueType, Log2Dim>& other);
169
171 template<typename ValueType>
172 LeafNode(const LeafNode<ValueType, Log2Dim>& other, TopologyCopy);
173
175 template<typename ValueType>
178 LeafNode(const LeafNode<ValueType, Log2Dim>& other, bool offValue, bool onValue, TopologyCopy);
179 template<typename ValueType>
180 LeafNode(const LeafNode<ValueType, Log2Dim>& other, bool background, TopologyCopy);
182
184 ~LeafNode();
185
186 //
187 // Statistics
188 //
190 static Index log2dim() { return Log2Dim; }
192 static Index dim() { return DIM; }
194 static Index size() { return SIZE; }
196 static Index numValues() { return SIZE; }
198 static Index getLevel() { return LEVEL; }
200 static void getNodeLog2Dims(std::vector<Index>& dims) { dims.push_back(Log2Dim); }
202 static Index getChildDim() { return 1; }
204 static Index32 leafCount() { return 1; }
206 static Index32 nonLeafCount() { return 0; }
207
209 Index64 onVoxelCount() const { return mBuffer.mData.countOn(); }
211 Index64 offVoxelCount() const { return mBuffer.mData.countOff(); }
212 Index64 onLeafVoxelCount() const { return this->onVoxelCount(); }
213 Index64 offLeafVoxelCount() const { return this->offVoxelCount(); }
214 static Index64 onTileCount() { return 0; }
215 static Index64 offTileCount() { return 0; }
216
218 bool isEmpty() const { return mBuffer.mData.isOff(); }
220 bool isDense() const { return mBuffer.mData.isOn(); }
221
222 #ifndef OPENVDB_2_ABI_COMPATIBLE
223 bool isAllocated() const { return true; }
230 bool allocate() { return true; }
231 #endif
232
234 Index64 memUsage() const;
235
239 void evalActiveBoundingBox(CoordBBox& bbox, bool visitVoxels = true) const;
240
243 CoordBBox getNodeBoundingBox() const { return CoordBBox::createCube(mOrigin, DIM); }
244
246 void setOrigin(const Coord& origin) { mOrigin = origin; }
248 const Coord& origin() const { return mOrigin; }
250 void getOrigin(Coord& origin) const { origin = mOrigin; }
251 void getOrigin(Int32& x, Int32& y, Int32& z) const { mOrigin.asXYZ(x, y, z); }
253
255 static Index coordToOffset(const Coord& xyz);
258 static Coord offsetToLocalCoord(Index n);
260 Coord offsetToGlobalCoord(Index n) const;
261
263 std::string str() const;
264
267 template<typename OtherType, Index OtherLog2Dim>
268 bool hasSameTopology(const LeafNode<OtherType, OtherLog2Dim>* other) const;
269
271 bool operator==(const LeafNode&) const;
272 bool operator!=(const LeafNode&) const;
273
274 //
275 // Buffer management
276 //
279 void swap(Buffer& other) { mBuffer.swap(other); }
280 const Buffer& buffer() const { return mBuffer; }
281 Buffer& buffer() { return mBuffer; }
282
283 //
284 // I/O methods
285 //
287 void readTopology(std::istream&, bool fromHalf = false);
289 void writeTopology(std::ostream&, bool toHalf = false) const;
290
292 void readBuffers(std::istream&, bool fromHalf = false);
293 void readBuffers(std::istream& is, const CoordBBox&, bool fromHalf = false);
295 void writeBuffers(std::ostream&, bool toHalf = false) const;
296
297 //
298 // Accessor methods
299 //
301 const bool& getValue(const Coord& xyz) const;
303 const bool& getValue(Index offset) const;
304
308 bool probeValue(const Coord& xyz, bool& val) const;
309
311 static Index getValueLevel(const Coord&) { return LEVEL; }
312
314 void setActiveState(const Coord& xyz, bool on);
316 void setActiveState(Index offset, bool on) { assert(offset<SIZE); mBuffer.mData.set(offset, on); }
317
319 void setValueOnly(const Coord& xyz, bool val);
321 void setValueOnly(Index offset, bool val) { assert(offset<SIZE); mBuffer.setValue(offset,val); }
322
324 void setValueOff(const Coord& xyz) { mBuffer.mData.setOff(this->coordToOffset(xyz)); }
326 void setValueOff(Index offset) { assert(offset < SIZE); mBuffer.mData.setOff(offset); }
327
329 void setValueOff(const Coord& xyz, bool val);
331 void setValueOff(Index offset, bool val);
332
334 void setValueOn(const Coord& xyz) { mBuffer.mData.setOn(this->coordToOffset(xyz)); }
336 void setValueOn(Index offset) { assert(offset < SIZE); mBuffer.mData.setOn(offset); }
337
339 void setValueOn(const Coord& xyz, bool val);
341 void setValue(const Coord& xyz, bool val) { this->setValueOn(xyz, val); }
343 void setValueOn(Index offset, bool val);
344
347 template<typename ModifyOp>
348 void modifyValue(Index offset, const ModifyOp& op);
351 template<typename ModifyOp>
352 void modifyValue(const Coord& xyz, const ModifyOp& op);
353
355 template<typename ModifyOp>
356 void modifyValueAndActiveState(const Coord& xyz, const ModifyOp& op);
357
359 void setValuesOn() { mBuffer.mData.setOn(); }
361 void setValuesOff() { mBuffer.mData.setOff(); }
362
364 bool isValueOn(const Coord& xyz) const { return mBuffer.mData.isOn(this->coordToOffset(xyz)); }
366 bool isValueOn(Index offset) const { assert(offset < SIZE); return mBuffer.mData.isOn(offset); }
367
369 static bool hasActiveTiles() { return false; }
370
372 void clip(const CoordBBox&, bool background);
373
375 void fill(const CoordBBox& bbox, bool value, bool dummy = false);
376
378 void fill(const bool& value, bool dummy = false);
379
391 template<typename DenseT>
392 void copyToDense(const CoordBBox& bbox, DenseT& dense) const;
393
410 template<typename DenseT>
411 void copyFromDense(const CoordBBox& bbox, const DenseT& dense, bool background, bool tolerance);
412
415 template<typename AccessorT>
416 const bool& getValueAndCache(const Coord& xyz, AccessorT&) const {return this->getValue(xyz);}
417
420 template<typename AccessorT>
421 bool isValueOnAndCache(const Coord& xyz, AccessorT&) const { return this->isValueOn(xyz); }
422
425 template<typename AccessorT>
426 void setValueAndCache(const Coord& xyz, bool val, AccessorT&) { this->setValueOn(xyz, val); }
427
431 template<typename AccessorT>
432 void setValueOnlyAndCache(const Coord& xyz, bool val, AccessorT&) {this->setValueOnly(xyz,val);}
433
436 template<typename AccessorT>
437 void setValueOffAndCache(const Coord& xyz, bool value, AccessorT&)
438 {
439 this->setValueOff(xyz, value);
440 }
441
445 template<typename ModifyOp, typename AccessorT>
446 void modifyValueAndCache(const Coord& xyz, const ModifyOp& op, AccessorT&)
447 {
448 this->modifyValue(xyz, op);
449 }
450
453 template<typename ModifyOp, typename AccessorT>
454 void modifyValueAndActiveStateAndCache(const Coord& xyz, const ModifyOp& op, AccessorT&)
455 {
456 this->modifyValueAndActiveState(xyz, op);
457 }
458
462 template<typename AccessorT>
463 void setActiveStateAndCache(const Coord& xyz, bool on, AccessorT&)
464 {
465 this->setActiveState(xyz, on);
466 }
467
471 template<typename AccessorT>
472 bool probeValueAndCache(const Coord& xyz, bool& val, AccessorT&) const
473 {
474 return this->probeValue(xyz, val);
475 }
476
479 template<typename AccessorT>
480 static Index getValueLevelAndCache(const Coord&, AccessorT&) { return LEVEL; }
481
485 const bool& getFirstValue() const { if (mBuffer.mData.isOn(0)) return sOn; else return sOff; }
489 const bool& getLastValue() const { if (mBuffer.mData.isOn(SIZE-1)) return sOn; else return sOff; }
490
494 bool isConstant(bool& constValue, bool& state, bool tolerance = 0) const;
496 bool isInactive() const { return mBuffer.mData.isOff(); }
497
500 void resetBackground(bool, bool) {}
501
503 void negate() { mBuffer.mData.toggle(); }
504
505 template<MergePolicy Policy>
506 void merge(const LeafNode& other, bool bg = false, bool otherBG = false);
507 template<MergePolicy Policy> void merge(bool tileValue, bool tileActive=false);
508
511 void voxelizeActiveTiles(bool = true) {}
512
519 template<typename OtherType>
520 void topologyUnion(const LeafNode<OtherType, Log2Dim>& other);
521
533 template<typename OtherType>
534 void topologyIntersection(const LeafNode<OtherType, Log2Dim>& other, const bool&);
535
547 template<typename OtherType>
548 void topologyDifference(const LeafNode<OtherType, Log2Dim>& other, const bool&);
549
550 template<typename CombineOp>
551 void combine(const LeafNode& other, CombineOp& op);
552 template<typename CombineOp>
553 void combine(bool, bool valueIsActive, CombineOp& op);
554
555 template<typename CombineOp, typename OtherType /*= bool*/>
556 void combine2(const LeafNode& other, const OtherType&, bool valueIsActive, CombineOp&);
557 template<typename CombineOp, typename OtherNodeT /*= LeafNode*/>
558 void combine2(bool, const OtherNodeT& other, bool valueIsActive, CombineOp&);
559 template<typename CombineOp, typename OtherNodeT /*= LeafNode*/>
560 void combine2(const LeafNode& b0, const OtherNodeT& b1, CombineOp&);
561
566 template<typename BBoxOp> void visitActiveBBox(BBoxOp&) const;
567
568 template<typename VisitorOp> void visit(VisitorOp&);
569 template<typename VisitorOp> void visit(VisitorOp&) const;
570
571 template<typename OtherLeafNodeType, typename VisitorOp>
572 void visit2Node(OtherLeafNodeType& other, VisitorOp&);
573 template<typename OtherLeafNodeType, typename VisitorOp>
574 void visit2Node(OtherLeafNodeType& other, VisitorOp&) const;
575 template<typename IterT, typename VisitorOp>
576 void visit2(IterT& otherIter, VisitorOp&, bool otherIsLHS = false);
577 template<typename IterT, typename VisitorOp>
578 void visit2(IterT& otherIter, VisitorOp&, bool otherIsLHS = false) const;
579
581 void prune(const ValueType& /*tolerance*/ = zeroVal<ValueType>()) {}
583 void addLeaf(LeafNode*) {}
584 template<typename AccessorT>
585 void addLeafAndCache(LeafNode*, AccessorT&) {}
586 template<typename NodeT>
587 NodeT* stealNode(const Coord&, const ValueType&, bool) { return NULL; }
588 template<typename NodeT>
589 NodeT* probeNode(const Coord&) { return NULL; }
590 template<typename NodeT>
591 const NodeT* probeConstNode(const Coord&) const { return NULL; }
592 template<typename ArrayT> void getNodes(ArrayT&) const {}
593 template<typename ArrayT> void stealNodes(ArrayT&, const ValueType&, bool) {}
595
596 void addTile(Index level, const Coord&, bool val, bool active);
597 void addTile(Index offset, bool val, bool active);
598 template<typename AccessorT>
599 void addTileAndCache(Index level, const Coord&, bool val, bool active, AccessorT&);
600
602 LeafNode* touchLeaf(const Coord&) { return this; }
604 template<typename AccessorT>
605 LeafNode* touchLeafAndCache(const Coord&, AccessorT&) { return this; }
606 LeafNode* probeLeaf(const Coord&) { return this; }
607 template<typename AccessorT>
608 LeafNode* probeLeafAndCache(const Coord&, AccessorT&) { return this; }
609 template<typename NodeT, typename AccessorT>
610 NodeT* probeNodeAndCache(const Coord&, AccessorT&)
611 {
612 OPENVDB_NO_UNREACHABLE_CODE_WARNING_BEGIN
613 if (!(boost::is_same<NodeT,LeafNode>::value)) return NULL;
614 return reinterpret_cast<NodeT*>(this);
615 OPENVDB_NO_UNREACHABLE_CODE_WARNING_END
616 }
618
619 const LeafNode* probeLeaf(const Coord&) const { return this; }
621 template<typename AccessorT>
622 const LeafNode* probeLeafAndCache(const Coord&, AccessorT&) const { return this; }
623 const LeafNode* probeConstLeaf(const Coord&) const { return this; }
624 template<typename AccessorT>
625 const LeafNode* probeConstLeafAndCache(const Coord&, AccessorT&) const { return this; }
626 template<typename NodeT, typename AccessorT>
627 const NodeT* probeConstNodeAndCache(const Coord&, AccessorT&) const
628 {
629 OPENVDB_NO_UNREACHABLE_CODE_WARNING_BEGIN
630 if (!(boost::is_same<NodeT,LeafNode>::value)) return NULL;
631 return reinterpret_cast<const NodeT*>(this);
632 OPENVDB_NO_UNREACHABLE_CODE_WARNING_END
633 }
635
636 //
637 // Iterators
638 //
639 protected:
640 typedef typename NodeMaskType::OnIterator MaskOnIter;
641 typedef typename NodeMaskType::OffIterator MaskOffIter;
642 typedef typename NodeMaskType::DenseIterator MaskDenseIter;
643
644 template<typename MaskIterT, typename NodeT, typename ValueT>
645 struct ValueIter:
646 // Derives from SparseIteratorBase, but can also be used as a dense iterator,
647 // if MaskIterT is a dense mask iterator type.
648 public SparseIteratorBase<MaskIterT, ValueIter<MaskIterT, NodeT, ValueT>, NodeT, ValueT>
649 {
650 typedef SparseIteratorBase<MaskIterT, ValueIter, NodeT, ValueT> BaseT;
651
652 ValueIter() {}
653 ValueIter(const MaskIterT& iter, NodeT* parent): BaseT(iter, parent) {}
654
655 const bool& getItem(Index pos) const { return this->parent().getValue(pos); }
656 const bool& getValue() const { return this->getItem(this->pos()); }
657
658 // Note: setItem() can't be called on const iterators.
659 void setItem(Index pos, bool value) const { this->parent().setValueOnly(pos, value); }
660 // Note: setValue() can't be called on const iterators.
661 void setValue(bool value) const { this->setItem(this->pos(), value); }
662
663 // Note: modifyItem() can't be called on const iterators.
664 template<typename ModifyOp>
665 void modifyItem(Index n, const ModifyOp& op) const { this->parent().modifyValue(n, op); }
666 // Note: modifyValue() can't be called on const iterators.
667 template<typename ModifyOp>
668 void modifyValue(const ModifyOp& op) const { this->modifyItem(this->pos(), op); }
669 };
670
672 template<typename MaskIterT, typename NodeT>
673 struct ChildIter:
674 public SparseIteratorBase<MaskIterT, ChildIter<MaskIterT, NodeT>, NodeT, bool>
675 {
676 ChildIter() {}
677 ChildIter(const MaskIterT& iter, NodeT* parent): SparseIteratorBase<
678 MaskIterT, ChildIter<MaskIterT, NodeT>, NodeT, bool>(iter, parent) {}
679 };
680
681 template<typename NodeT, typename ValueT>
682 struct DenseIter: public DenseIteratorBase<
683 MaskDenseIter, DenseIter<NodeT, ValueT>, NodeT, /*ChildT=*/void, ValueT>
684 {
685 typedef DenseIteratorBase<MaskDenseIter, DenseIter, NodeT, void, ValueT> BaseT;
686 typedef typename BaseT::NonConstValueType NonConstValueT;
687
688 DenseIter() {}
689 DenseIter(const MaskDenseIter& iter, NodeT* parent): BaseT(iter, parent) {}
690
691 bool getItem(Index pos, void*& child, NonConstValueT& value) const
692 {
693 value = this->parent().getValue(pos);
694 child = NULL;
695 return false; // no child
696 }
697
698 // Note: setItem() can't be called on const iterators.
699 //void setItem(Index pos, void* child) const {}
700
701 // Note: unsetItem() can't be called on const iterators.
702 void unsetItem(Index pos, const ValueT& val) const {this->parent().setValueOnly(pos, val);}
703 };
704
705 public:
706 typedef ValueIter<MaskOnIter, LeafNode, const bool> ValueOnIter;
707 typedef ValueIter<MaskOnIter, const LeafNode, const bool> ValueOnCIter;
708 typedef ValueIter<MaskOffIter, LeafNode, const bool> ValueOffIter;
709 typedef ValueIter<MaskOffIter, const LeafNode, const bool> ValueOffCIter;
710 typedef ValueIter<MaskDenseIter, LeafNode, const bool> ValueAllIter;
711 typedef ValueIter<MaskDenseIter, const LeafNode, const bool> ValueAllCIter;
712 typedef ChildIter<MaskOnIter, LeafNode> ChildOnIter;
713 typedef ChildIter<MaskOnIter, const LeafNode> ChildOnCIter;
714 typedef ChildIter<MaskOffIter, LeafNode> ChildOffIter;
715 typedef ChildIter<MaskOffIter, const LeafNode> ChildOffCIter;
716 typedef DenseIter<LeafNode, bool> ChildAllIter;
717 typedef DenseIter<const LeafNode, const bool> ChildAllCIter;
718
719 ValueOnCIter cbeginValueOn() const { return ValueOnCIter(mBuffer.mData.beginOn(), this); }
720 ValueOnCIter beginValueOn() const { return ValueOnCIter(mBuffer.mData.beginOn(), this); }
721 ValueOnIter beginValueOn() { return ValueOnIter(mBuffer.mData.beginOn(), this); }
722 ValueOffCIter cbeginValueOff() const { return ValueOffCIter(mBuffer.mData.beginOff(), this); }
723 ValueOffCIter beginValueOff() const { return ValueOffCIter(mBuffer.mData.beginOff(), this); }
724 ValueOffIter beginValueOff() { return ValueOffIter(mBuffer.mData.beginOff(), this); }
725 ValueAllCIter cbeginValueAll() const { return ValueAllCIter(mBuffer.mData.beginDense(), this); }
726 ValueAllCIter beginValueAll() const { return ValueAllCIter(mBuffer.mData.beginDense(), this); }
727 ValueAllIter beginValueAll() { return ValueAllIter(mBuffer.mData.beginDense(), this); }
728
729 ValueOnCIter cendValueOn() const { return ValueOnCIter(mBuffer.mData.endOn(), this); }
730 ValueOnCIter endValueOn() const { return ValueOnCIter(mBuffer.mData.endOn(), this); }
731 ValueOnIter endValueOn() { return ValueOnIter(mBuffer.mData.endOn(), this); }
732 ValueOffCIter cendValueOff() const { return ValueOffCIter(mBuffer.mData.endOff(), this); }
733 ValueOffCIter endValueOff() const { return ValueOffCIter(mBuffer.mData.endOff(), this); }
734 ValueOffIter endValueOff() { return ValueOffIter(mBuffer.mData.endOff(), this); }
735 ValueAllCIter cendValueAll() const { return ValueAllCIter(mBuffer.mData.endDense(), this); }
736 ValueAllCIter endValueAll() const { return ValueAllCIter(mBuffer.mData.endDense(), this); }
737 ValueAllIter endValueAll() { return ValueAllIter(mBuffer.mData.endDense(), this); }
738
739 // Note that [c]beginChildOn() and [c]beginChildOff() actually return end iterators,
740 // because leaf nodes have no children.
741 ChildOnCIter cbeginChildOn() const { return ChildOnCIter(mBuffer.mData.endOn(), this); }
742 ChildOnCIter beginChildOn() const { return ChildOnCIter(mBuffer.mData.endOn(), this); }
743 ChildOnIter beginChildOn() { return ChildOnIter(mBuffer.mData.endOn(), this); }
744 ChildOffCIter cbeginChildOff() const { return ChildOffCIter(mBuffer.mData.endOff(), this); }
745 ChildOffCIter beginChildOff() const { return ChildOffCIter(mBuffer.mData.endOff(), this); }
746 ChildOffIter beginChildOff() { return ChildOffIter(mBuffer.mData.endOff(), this); }
747 ChildAllCIter cbeginChildAll() const { return ChildAllCIter(mBuffer.mData.beginDense(), this); }
748 ChildAllCIter beginChildAll() const { return ChildAllCIter(mBuffer.mData.beginDense(), this); }
749 ChildAllIter beginChildAll() { return ChildAllIter(mBuffer.mData.beginDense(), this); }
750
751 ChildOnCIter cendChildOn() const { return ChildOnCIter(mBuffer.mData.endOn(), this); }
752 ChildOnCIter endChildOn() const { return ChildOnCIter(mBuffer.mData.endOn(), this); }
753 ChildOnIter endChildOn() { return ChildOnIter(mBuffer.mData.endOn(), this); }
754 ChildOffCIter cendChildOff() const { return ChildOffCIter(mBuffer.mData.endOff(), this); }
755 ChildOffCIter endChildOff() const { return ChildOffCIter(mBuffer.mData.endOff(), this); }
756 ChildOffIter endChildOff() { return ChildOffIter(mBuffer.mData.endOff(), this); }
757 ChildAllCIter cendChildAll() const { return ChildAllCIter(mBuffer.mData.endDense(), this); }
758 ChildAllCIter endChildAll() const { return ChildAllCIter(mBuffer.mData.endDense(), this); }
759 ChildAllIter endChildAll() { return ChildAllIter(mBuffer.mData.endDense(), this); }
760
761 //
762 // Mask accessors
763 //
764 bool isValueMaskOn(Index n) const { return mBuffer.mData.isOn(n); }
765 bool isValueMaskOn() const { return mBuffer.mData.isOn(); }
766 bool isValueMaskOff(Index n) const { return mBuffer.mData.isOff(n); }
767 bool isValueMaskOff() const { return mBuffer.mData.isOff(); }
768 const NodeMaskType& getValueMask() const { return mBuffer.mData; }
769 const NodeMaskType& valueMask() const { return mBuffer.mData; }
770 NodeMaskType& getValueMask() { return mBuffer.mData; }
771 void setValueMask(const NodeMaskType& mask) { mBuffer.mData = mask; }
772 bool isChildMaskOn(Index) const { return false; } // leaf nodes have no children
773 bool isChildMaskOff(Index) const { return true; }
774 bool isChildMaskOff() const { return true; }
775 protected:
776 void setValueMask(Index n, bool on) { mBuffer.mData.set(n, on); }
777 void setValueMaskOn(Index n) { mBuffer.mData.setOn(n); }
778 void setValueMaskOff(Index n) { mBuffer.mData.setOff(n); }
779
781 static void evalNodeOrigin(Coord& xyz) { xyz &= ~(DIM - 1); }
782
783 template<typename NodeT, typename VisitorOp, typename ChildAllIterT>
784 static inline void doVisit(NodeT&, VisitorOp&);
785
786 template<typename NodeT, typename OtherNodeT, typename VisitorOp,
787 typename ChildAllIterT, typename OtherChildAllIterT>
788 static inline void doVisit2Node(NodeT& self, OtherNodeT& other, VisitorOp&);
789
790 template<typename NodeT, typename VisitorOp,
791 typename ChildAllIterT, typename OtherChildAllIterT>
792 static inline void doVisit2(NodeT& self, OtherChildAllIterT&, VisitorOp&, bool otherIsLHS);
793
795 Buffer mBuffer;
796
798 Coord mOrigin;
799
800 // These static declarations must be on separate lines to avoid VC9 compiler errors.
801 static const bool sOn;
802 static const bool sOff;
803
804 private:
807 template<typename, Index> friend class LeafNode;
808
809 friend struct ValueIter<MaskOnIter, LeafNode, bool>;
810 friend struct ValueIter<MaskOffIter, LeafNode, bool>;
811 friend struct ValueIter<MaskDenseIter, LeafNode, bool>;
812 friend struct ValueIter<MaskOnIter, const LeafNode, bool>;
813 friend struct ValueIter<MaskOffIter, const LeafNode, bool>;
814 friend struct ValueIter<MaskDenseIter, const LeafNode, bool>;
815
817 friend class IteratorBase<MaskOnIter, LeafNode>;
820 friend class IteratorBase<MaskOffIter, LeafNode>;
821 friend class IteratorBase<MaskDenseIter, LeafNode>;
823
824 }; // class LeafNode<ValueMask>
825
826
831 template<Index Log2Dim> const bool LeafNode<ValueMask, Log2Dim>::sOn = true;
832 template<Index Log2Dim> const bool LeafNode<ValueMask, Log2Dim>::sOff = false;
833
834
836
837
838 template<Index Log2Dim>
839 inline
840 LeafNode<ValueMask, Log2Dim>::LeafNode()
841 : mOrigin(0, 0, 0)
842 {
843 }
844
845 template<Index Log2Dim>
846 inline
847 LeafNode<ValueMask, Log2Dim>::LeafNode(const Coord& xyz, bool value, bool)
848 : mBuffer(value)
849 , mOrigin(xyz & (~(DIM - 1)))
850 {
851 }
852
853
854 #ifndef OPENVDB_2_ABI_COMPATIBLE
855 template<Index Log2Dim>
856 inline
857 LeafNode<ValueMask, Log2Dim>::LeafNode(PartialCreate, const Coord& xyz, bool value, bool)
858 : mBuffer(value)
859 , mOrigin(xyz & (~(DIM - 1)))
860 {
861 }
862 #endif
863
864
865 template<Index Log2Dim>
866 inline
867 LeafNode<ValueMask, Log2Dim>::LeafNode(const LeafNode &other)
868 : mBuffer(other.mBuffer)
869 , mOrigin(other.mOrigin)
870 {
871 }
872
873
874 // Copy-construct from a leaf node with the same configuration but a different ValueType.
875 template<Index Log2Dim>
876 template<typename ValueT>
877 inline
878 LeafNode<ValueMask, Log2Dim>::LeafNode(const LeafNode<ValueT, Log2Dim>& other)
879 : mBuffer(other.valueMask())
880 , mOrigin(other.origin())
881 {
882 }
883
884
885 template<Index Log2Dim>
886 template<typename ValueT>
887 inline
888 LeafNode<ValueMask, Log2Dim>::LeafNode(const LeafNode<ValueT, Log2Dim>& other,
889 bool, TopologyCopy)
890 : mBuffer(other.valueMask())// value = active state
891 , mOrigin(other.origin())
892 {
893 }
894
895
896 template<Index Log2Dim>
897 template<typename ValueT>
898 inline
899 LeafNode<ValueMask, Log2Dim>::LeafNode(const LeafNode<ValueT, Log2Dim>& other, TopologyCopy)
900 : mBuffer(other.valueMask())// value = active state
901 , mOrigin(other.origin())
902 {
903 }
904
905
906 template<Index Log2Dim>
907 template<typename ValueT>
908 inline
909 LeafNode<ValueMask, Log2Dim>::LeafNode(const LeafNode<ValueT, Log2Dim>& other,
910 bool offValue, bool onValue, TopologyCopy)
911 : mBuffer(other.valueMask())
912 , mOrigin(other.origin())
913 {
914 if (offValue==true) {
915 if (onValue==false) {
916 mBuffer.mData.toggle();
917 } else {
918 mBuffer.mData.setOn();
919 }
920 }
921 }
922
923
924 template<Index Log2Dim>
925 inline
926 LeafNode<ValueMask, Log2Dim>::~LeafNode()
927 {
928 }
929
930
932
933
934 template<Index Log2Dim>
935 inline Index64
936 LeafNode<ValueMask, Log2Dim>::memUsage() const
937 {
938 // Use sizeof(*this) to capture alignment-related padding
939 return sizeof(*this);
940 }
941
942
943 template<Index Log2Dim>
944 inline void
945 LeafNode<ValueMask, Log2Dim>::evalActiveBoundingBox(CoordBBox& bbox, bool visitVoxels) const
946 {
947 CoordBBox this_bbox = this->getNodeBoundingBox();
948 if (bbox.isInside(this_bbox)) return;//this LeafNode is already enclosed in the bbox
949 if (ValueOnCIter iter = this->cbeginValueOn()) {//any active values?
950 if (visitVoxels) {//use voxel granularity?
951 this_bbox.reset();
952 for(; iter; ++iter) this_bbox.expand(this->offsetToLocalCoord(iter.pos()));
953 this_bbox.translate(this->origin());
954 }
955 bbox.expand(this_bbox);
956 }
957 }
958
959
960 template<Index Log2Dim>
961 template<typename OtherType, Index OtherLog2Dim>
962 inline bool
963 LeafNode<ValueMask, Log2Dim>::hasSameTopology(const LeafNode<OtherType, OtherLog2Dim>* other) const
964 {
965 assert(other);
966 return (Log2Dim == OtherLog2Dim && mBuffer.mData == other->getValueMask());
967 }
968
969
970 template<Index Log2Dim>
971 inline std::string
972 LeafNode<ValueMask, Log2Dim>::str() const
973 {
974 std::ostringstream ostr;
975 ostr << "LeafNode @" << mOrigin << ": ";
976 for (Index32 n = 0; n < SIZE; ++n) ostr << (mBuffer.mData.isOn(n) ? '#' : '.');
977 return ostr.str();
978 }
979
980
982
983
984 template<Index Log2Dim>
985 inline Index
986 LeafNode<ValueMask, Log2Dim>::coordToOffset(const Coord& xyz)
987 {
988 assert ((xyz[0] & (DIM-1u)) < DIM && (xyz[1] & (DIM-1u)) < DIM && (xyz[2] & (DIM-1u)) < DIM);
989 return ((xyz[0] & (DIM-1u)) << 2*Log2Dim)
990 + ((xyz[1] & (DIM-1u)) << Log2Dim)
991 + (xyz[2] & (DIM-1u));
992 }
993
994
995 template<Index Log2Dim>
996 inline Coord
997 LeafNode<ValueMask, Log2Dim>::offsetToLocalCoord(Index n)
998 {
999 assert(n < (1 << 3*Log2Dim));
1000 Coord xyz;
1001 xyz.setX(n >> 2*Log2Dim);
1002 n &= ((1 << 2*Log2Dim) - 1);
1003 xyz.setY(n >> Log2Dim);
1004 xyz.setZ(n & ((1 << Log2Dim) - 1));
1005 return xyz;
1006 }
1007
1008
1009 template<Index Log2Dim>
1010 inline Coord
1011 LeafNode<ValueMask, Log2Dim>::offsetToGlobalCoord(Index n) const
1012 {
1013 return (this->offsetToLocalCoord(n) + this->origin());
1014 }
1015
1016
1018
1019
1020 template<Index Log2Dim>
1021 inline void
1022 LeafNode<ValueMask, Log2Dim>::readTopology(std::istream& is, bool /*fromHalf*/)
1023 {
1024 mBuffer.mData.load(is);
1025 }
1026
1027
1028 template<Index Log2Dim>
1029 inline void
1030 LeafNode<ValueMask, Log2Dim>::writeTopology(std::ostream& os, bool /*toHalf*/) const
1031 {
1032 mBuffer.mData.save(os);
1033 }
1034
1035
1036 template<Index Log2Dim>
1037 inline void
1038 LeafNode<ValueMask, Log2Dim>::readBuffers(std::istream& is, const CoordBBox& clipBBox, bool fromHalf)
1039 {
1040 // Boolean LeafNodes don't currently implement lazy loading.
1041 // Instead, load the full buffer, then clip it.
1042
1043 this->readBuffers(is, fromHalf);
1044
1045 // Get this tree's background value.
1046 bool background = false;
1047 if (const void* bgPtr = io::getGridBackgroundValuePtr(is)) {
1048 background = *static_cast<const bool*>(bgPtr);
1049 }
1050 this->clip(clipBBox, background);
1051 }
1052
1053
1054 template<Index Log2Dim>
1055 inline void
1056 LeafNode<ValueMask, Log2Dim>::readBuffers(std::istream& is, bool /*fromHalf*/)
1057 {
1058 // Read in the value mask = buffer.
1059 mBuffer.mData.load(is);
1060 // Read in the origin.
1061 is.read(reinterpret_cast<char*>(&mOrigin), sizeof(Coord::ValueType) * 3);
1062 }
1063
1064
1065 template<Index Log2Dim>
1066 inline void
1067 LeafNode<ValueMask, Log2Dim>::writeBuffers(std::ostream& os, bool /*toHalf*/) const
1068 {
1069 // Write out the value mask = buffer.
1070 mBuffer.mData.save(os);
1071 // Write out the origin.
1072 os.write(reinterpret_cast<const char*>(&mOrigin), sizeof(Coord::ValueType) * 3);
1073 }
1074
1075
1077
1078
1079 template<Index Log2Dim>
1080 inline bool
1081 LeafNode<ValueMask, Log2Dim>::operator==(const LeafNode& other) const
1082 {
1083 return mOrigin == other.mOrigin && mBuffer == other.mBuffer;
1084 }
1085
1086
1087 template<Index Log2Dim>
1088 inline bool
1089 LeafNode<ValueMask, Log2Dim>::operator!=(const LeafNode& other) const
1090 {
1091 return !(this->operator==(other));
1092 }
1093
1094
1096
1097
1098 template<Index Log2Dim>
1099 inline bool
1100 LeafNode<ValueMask, Log2Dim>::isConstant(bool& constValue, bool& state, bool) const
1101 {
1102 if (!mBuffer.mData.isConstant(state)) return false;
1103
1104 constValue = state;
1105 return true;
1106 }
1107
1108
1110
1111
1112 template<Index Log2Dim>
1113 inline void
1114 LeafNode<ValueMask, Log2Dim>::addTile(Index /*level*/, const Coord& xyz, bool val, bool active)
1115 {
1116 this->addTile(this->coordToOffset(xyz), val, active);
1117 }
1118
1119 template<Index Log2Dim>
1120 inline void
1121 LeafNode<ValueMask, Log2Dim>::addTile(Index offset, bool val, bool active)
1122 {
1123 assert(offset < SIZE);
1124 this->setValueOnly(offset, val);
1125 this->setActiveState(offset, active);
1126 }
1127
1128 template<Index Log2Dim>
1129 template<typename AccessorT>
1130 inline void
1131 LeafNode<ValueMask, Log2Dim>::addTileAndCache(Index level, const Coord& xyz,
1132 bool val, bool active, AccessorT&)
1133 {
1134 this->addTile(level, xyz, val, active);
1135 }
1136
1137
1139
1140
1141 template<Index Log2Dim>
1142 inline const bool&
1143 LeafNode<ValueMask, Log2Dim>::getValue(const Coord& xyz) const
1144 {
1145 // This *CANNOT* use operator ? because Visual C++
1146 if (mBuffer.mData.isOn(this->coordToOffset(xyz))) return sOn; else return sOff;
1147 }
1148
1149
1150 template<Index Log2Dim>
1151 inline const bool&
1152 LeafNode<ValueMask, Log2Dim>::getValue(Index offset) const
1153 {
1154 assert(offset < SIZE);
1155 // This *CANNOT* use operator ? for Windows
1156 if (mBuffer.mData.isOn(offset)) return sOn; else return sOff;
1157 }
1158
1159
1160 template<Index Log2Dim>
1161 inline bool
1162 LeafNode<ValueMask, Log2Dim>::probeValue(const Coord& xyz, bool& val) const
1163 {
1164 const Index offset = this->coordToOffset(xyz);
1165 val = mBuffer.mData.isOn(offset);
1166 return val;
1167 }
1168
1169
1170 template<Index Log2Dim>
1171 inline void
1172 LeafNode<ValueMask, Log2Dim>::setValueOn(const Coord& xyz, bool val)
1173 {
1174 this->setValueOn(this->coordToOffset(xyz), val);
1175 }
1176
1177
1178 template<Index Log2Dim>
1179 inline void
1180 LeafNode<ValueMask, Log2Dim>::setValueOn(Index offset, bool val)
1181 {
1182 assert(offset < SIZE);
1183 mBuffer.mData.set(offset, val);
1184 }
1185
1186
1187 template<Index Log2Dim>
1188 inline void
1189 LeafNode<ValueMask, Log2Dim>::setValueOnly(const Coord& xyz, bool val)
1190 {
1191 this->setValueOnly(this->coordToOffset(xyz), val);
1192 }
1193
1194
1195 template<Index Log2Dim>
1196 inline void
1197 LeafNode<ValueMask, Log2Dim>::setActiveState(const Coord& xyz, bool on)
1198 {
1199 mBuffer.mData.set(this->coordToOffset(xyz), on);
1200 }
1201
1202
1203 template<Index Log2Dim>
1204 inline void
1205 LeafNode<ValueMask, Log2Dim>::setValueOff(const Coord& xyz, bool val)
1206 {
1207 this->setValueOff(this->coordToOffset(xyz), val);
1208 }
1209
1210
1211 template<Index Log2Dim>
1212 inline void
1213 LeafNode<ValueMask, Log2Dim>::setValueOff(Index offset, bool val)
1214 {
1215 assert(offset < SIZE);
1216 mBuffer.mData.set(offset, val);
1217 }
1218
1219
1220 template<Index Log2Dim>
1221 template<typename ModifyOp>
1222 inline void
1223 LeafNode<ValueMask, Log2Dim>::modifyValue(Index offset, const ModifyOp& op)
1224 {
1225 bool val = mBuffer.mData.isOn(offset);
1226 op(val);
1227 mBuffer.mData.set(offset, val);
1228 }
1229
1230
1231 template<Index Log2Dim>
1232 template<typename ModifyOp>
1233 inline void
1234 LeafNode<ValueMask, Log2Dim>::modifyValue(const Coord& xyz, const ModifyOp& op)
1235 {
1236 this->modifyValue(this->coordToOffset(xyz), op);
1237 }
1238
1239
1240 template<Index Log2Dim>
1241 template<typename ModifyOp>
1242 inline void
1243 LeafNode<ValueMask, Log2Dim>::modifyValueAndActiveState(const Coord& xyz, const ModifyOp& op)
1244 {
1245 const Index offset = this->coordToOffset(xyz);
1246 bool val = mBuffer.mData.isOn(offset), state = val;
1247 op(val, state);
1248 mBuffer.mData.set(offset, val);
1249 }
1250
1251
1253
1254
1255 template<Index Log2Dim>
1256 template<MergePolicy Policy>
1257 inline void
1258 LeafNode<ValueMask, Log2Dim>::merge(const LeafNode& other, bool /*bg*/, bool /*otherBG*/)
1259 {
1260 OPENVDB_NO_UNREACHABLE_CODE_WARNING_BEGIN
1261 if (Policy == MERGE_NODES) return;
1262 mBuffer.mData |= other.mBuffer.mData;
1263 OPENVDB_NO_UNREACHABLE_CODE_WARNING_END
1264 }
1265
1266 template<Index Log2Dim>
1267 template<MergePolicy Policy>
1268 inline void
1269 LeafNode<ValueMask, Log2Dim>::merge(bool tileValue, bool)
1270 {
1271 OPENVDB_NO_UNREACHABLE_CODE_WARNING_BEGIN
1272 if (Policy != MERGE_ACTIVE_STATES_AND_NODES) return;
1273 if (tileValue) mBuffer.mData.setOn();
1274 OPENVDB_NO_UNREACHABLE_CODE_WARNING_END
1275 }
1276
1277
1279
1280
1281 template<Index Log2Dim>
1282 template<typename OtherType>
1283 inline void
1284 LeafNode<ValueMask, Log2Dim>::topologyUnion(const LeafNode<OtherType, Log2Dim>& other)
1285 {
1286 mBuffer.mData |= other.valueMask();
1287 }
1288
1289
1290 template<Index Log2Dim>
1291 template<typename OtherType>
1292 inline void
1293 LeafNode<ValueMask, Log2Dim>::topologyIntersection(const LeafNode<OtherType, Log2Dim>& other,
1294 const bool&)
1295 {
1296 mBuffer.mData &= other.valueMask();
1297 }
1298
1299
1300 template<Index Log2Dim>
1301 template<typename OtherType>
1302 inline void
1303 LeafNode<ValueMask, Log2Dim>::topologyDifference(const LeafNode<OtherType, Log2Dim>& other,
1304 const bool&)
1305 {
1306 mBuffer.mData &= !other.valueMask();
1307 }
1308
1309
1311
1312
1313 template<Index Log2Dim>
1314 inline void
1315 LeafNode<ValueMask, Log2Dim>::clip(const CoordBBox& clipBBox, bool background)
1316 {
1317 CoordBBox nodeBBox = this->getNodeBoundingBox();
1318 if (!clipBBox.hasOverlap(nodeBBox)) {
1319 // This node lies completely outside the clipping region. Fill it with background tiles.
1320 this->fill(nodeBBox, background, /*active=*/false);
1321 } else if (clipBBox.isInside(nodeBBox)) {
1322 // This node lies completely inside the clipping region. Leave it intact.
1323 return;
1324 }
1325
1326 // This node isn't completely contained inside the clipping region.
1327 // Set any voxels that lie outside the region to the background value.
1328
1329 // Construct a boolean mask that is on inside the clipping region and off outside it.
1330 NodeMaskType mask;
1331 nodeBBox.intersect(clipBBox);
1332 Coord xyz;
1333 int &x = xyz.x(), &y = xyz.y(), &z = xyz.z();
1334 for (x = nodeBBox.min().x(); x <= nodeBBox.max().x(); ++x) {
1335 for (y = nodeBBox.min().y(); y <= nodeBBox.max().y(); ++y) {
1336 for (z = nodeBBox.min().z(); z <= nodeBBox.max().z(); ++z) {
1337 mask.setOn(static_cast<Index32>(this->coordToOffset(xyz)));
1338 }
1339 }
1340 }
1341
1342 // Set voxels that lie in the inactive region of the mask (i.e., outside
1343 // the clipping region) to the background value.
1344 for (MaskOffIter maskIter = mask.beginOff(); maskIter; ++maskIter) {
1345 this->setValueOff(maskIter.pos(), background);
1346 }
1347 }
1348
1349
1351
1352
1353 template<Index Log2Dim>
1354 inline void
1355 LeafNode<ValueMask, Log2Dim>::fill(const CoordBBox& bbox, bool value, bool)
1356 {
1357 for (Int32 x = bbox.min().x(); x <= bbox.max().x(); ++x) {
1358 const Index offsetX = (x & (DIM-1u))<<2*Log2Dim;
1359 for (Int32 y = bbox.min().y(); y <= bbox.max().y(); ++y) {
1360 const Index offsetXY = offsetX + ((y & (DIM-1u))<< Log2Dim);
1361 for (Int32 z = bbox.min().z(); z <= bbox.max().z(); ++z) {
1362 const Index offset = offsetXY + (z & (DIM-1u));
1363 mBuffer.mData.set(offset, value);
1364 }
1365 }
1366 }
1367 }
1368
1369 template<Index Log2Dim>
1370 inline void
1371 LeafNode<ValueMask, Log2Dim>::fill(const bool& value, bool)
1372 {
1373 mBuffer.fill(value);
1374 }
1375
1376
1378
1379
1380 template<Index Log2Dim>
1381 template<typename DenseT>
1382 inline void
1383 LeafNode<ValueMask, Log2Dim>::copyToDense(const CoordBBox& bbox, DenseT& dense) const
1384 {
1385 typedef typename DenseT::ValueType DenseValueType;
1386
1387 const size_t xStride = dense.xStride(), yStride = dense.yStride(), zStride = dense.zStride();
1388 const Coord& min = dense.bbox().min();
1389 DenseValueType* t0 = dense.data() + zStride * (bbox.min()[2] - min[2]); // target array
1390 const Int32 n0 = bbox.min()[2] & (DIM-1u);
1391 for (Int32 x = bbox.min()[0], ex = bbox.max()[0] + 1; x < ex; ++x) {
1392 DenseValueType* t1 = t0 + xStride * (x - min[0]);
1393 const Int32 n1 = n0 + ((x & (DIM-1u)) << 2*LOG2DIM);
1394 for (Int32 y = bbox.min()[1], ey = bbox.max()[1] + 1; y < ey; ++y) {
1395 DenseValueType* t2 = t1 + yStride * (y - min[1]);
1396 Int32 n2 = n1 + ((y & (DIM-1u)) << LOG2DIM);
1397 for (Int32 z = bbox.min()[2], ez = bbox.max()[2] + 1; z < ez; ++z, t2 += zStride) {
1398 *t2 = DenseValueType(mBuffer.mData.isOn(n2++));
1399 }
1400 }
1401 }
1402 }
1403
1404
1405 template<Index Log2Dim>
1406 template<typename DenseT>
1407 inline void
1408 LeafNode<ValueMask, Log2Dim>::copyFromDense(const CoordBBox& bbox, const DenseT& dense,
1409 bool background, bool tolerance)
1410 {
1411 typedef typename DenseT::ValueType DenseValueType;
1412 struct Local {
1413 inline static bool toBool(const DenseValueType& v) { return !math::isZero(v); }
1414 };
1415
1416 const size_t xStride = dense.xStride(), yStride = dense.yStride(), zStride = dense.zStride();
1417 const Coord& min = dense.bbox().min();
1418 const DenseValueType* s0 = dense.data() + zStride * (bbox.min()[2] - min[2]); // source
1419 const Int32 n0 = bbox.min()[2] & (DIM-1u);
1420 for (Int32 x = bbox.min()[0], ex = bbox.max()[0] + 1; x < ex; ++x) {
1421 const DenseValueType* s1 = s0 + xStride * (x - min[0]);
1422 const Int32 n1 = n0 + ((x & (DIM-1u)) << 2*LOG2DIM);
1423 for (Int32 y = bbox.min()[1], ey = bbox.max()[1] + 1; y < ey; ++y) {
1424 const DenseValueType* s2 = s1 + yStride * (y - min[1]);
1425 Int32 n2 = n1 + ((y & (DIM-1u)) << LOG2DIM);
1426 for (Int32 z = bbox.min()[2], ez = bbox.max()[2]+1; z < ez; ++z, ++n2, s2 += zStride) {
1427 // Note: if tolerance is true (i.e., 1), then all boolean values compare equal.
1428 if (tolerance || (background == Local::toBool(*s2))) {
1429 mBuffer.mData.set(n2, background);
1430 } else {
1431 mBuffer.mData.set(n2, Local::toBool(*s2));
1432 }
1433 }
1434 }
1435 }
1436 }
1437
1438
1440
1441
1442 template<Index Log2Dim>
1443 template<typename CombineOp>
1444 inline void
1445 LeafNode<ValueMask, Log2Dim>::combine(const LeafNode& other, CombineOp& op)
1446 {
1447 CombineArgs<bool> args;
1448 for (Index i = 0; i < SIZE; ++i) {
1449 bool result = false, aVal = mBuffer.mData.isOn(i), bVal = other.mBuffer.mData.isOn(i);
1450 op(args.setARef(aVal)
1451 .setAIsActive(aVal)
1452 .setBRef(bVal)
1453 .setBIsActive(bVal)
1454 .setResultRef(result));
1455 mBuffer.mData.set(i, result);
1456 }
1457 }
1458
1459
1460 template<Index Log2Dim>
1461 template<typename CombineOp>
1462 inline void
1463 LeafNode<ValueMask, Log2Dim>::combine(bool value, bool valueIsActive, CombineOp& op)
1464 {
1465 CombineArgs<bool> args;
1466 args.setBRef(value).setBIsActive(valueIsActive);
1467 for (Index i = 0; i < SIZE; ++i) {
1468 bool result = false, aVal = mBuffer.mData.isOn(i);
1469 op(args.setARef(aVal)
1470 .setAIsActive(aVal)
1471 .setResultRef(result));
1472 mBuffer.mData.set(i, result);
1473 }
1474 }
1475
1476
1478
1479
1480 template<Index Log2Dim>
1481 template<typename CombineOp, typename OtherType>
1482 inline void
1483 LeafNode<ValueMask, Log2Dim>::combine2(const LeafNode& other, const OtherType& value,
1484 bool valueIsActive, CombineOp& op)
1485 {
1486 CombineArgs<bool, OtherType> args;
1487 args.setBRef(value).setBIsActive(valueIsActive);
1488 for (Index i = 0; i < SIZE; ++i) {
1489 bool result = false, aVal = other.mBuffer.mData.isOn(i);
1490 op(args.setARef(aVal)
1491 .setAIsActive(aVal)
1492 .setResultRef(result));
1493 mBuffer.mData.set(i, result);
1494 }
1495 }
1496
1497
1498 template<Index Log2Dim>
1499 template<typename CombineOp, typename OtherNodeT>
1500 inline void
1501 LeafNode<ValueMask, Log2Dim>::combine2(bool value, const OtherNodeT& other,
1502 bool valueIsActive, CombineOp& op)
1503 {
1504 CombineArgs<bool, typename OtherNodeT::ValueType> args;
1505 args.setARef(value).setAIsActive(valueIsActive);
1506 for (Index i = 0; i < SIZE; ++i) {
1507 bool result = false, bVal = other.mBuffer.mData.isOn(i);
1508 op(args.setBRef(bVal)
1509 .setBIsActive(bVal)
1510 .setResultRef(result));
1511 mBuffer.mData.set(i, result);
1512 }
1513 }
1514
1515
1516 template<Index Log2Dim>
1517 template<typename CombineOp, typename OtherNodeT>
1518 inline void
1519 LeafNode<ValueMask, Log2Dim>::combine2(const LeafNode& b0, const OtherNodeT& b1, CombineOp& op)
1520 {
1521 CombineArgs<bool, typename OtherNodeT::ValueType> args;
1522 for (Index i = 0; i < SIZE; ++i) {
1523 bool result = false, b0Val = b0.mBuffer.mData.isOn(i), b1Val = b1.mBuffer.mData.isOn(i);
1524 op(args.setARef(b0Val)
1525 .setAIsActive(b0Val)
1526 .setBRef(b1Val)
1527 .setBIsActive(b1Val)
1528 .setResultRef(result));
1529 mBuffer.mData.set(i, result);
1530 }
1531 }
1532
1533
1535
1536 template<Index Log2Dim>
1537 template<typename BBoxOp>
1538 inline void
1539 LeafNode<ValueMask, Log2Dim>::visitActiveBBox(BBoxOp& op) const
1540 {
1541 if (op.template descent<LEVEL>()) {
1542 for (ValueOnCIter i=this->cbeginValueOn(); i; ++i) {
1543 #ifdef _MSC_VER
1544 op.operator()<LEVEL>(CoordBBox::createCube(i.getCoord(), 1));
1545 #else
1546 op.template operator()<LEVEL>(CoordBBox::createCube(i.getCoord(), 1));
1547 #endif
1548 }
1549 } else {
1550 #ifdef _MSC_VER
1551 op.operator()<LEVEL>(this->getNodeBoundingBox());
1552 #else
1553 op.template operator()<LEVEL>(this->getNodeBoundingBox());
1554 #endif
1555 }
1556 }
1557
1558
1559 template<Index Log2Dim>
1560 template<typename VisitorOp>
1561 inline void
1562 LeafNode<ValueMask, Log2Dim>::visit(VisitorOp& op)
1563 {
1564 doVisit<LeafNode, VisitorOp, ChildAllIter>(*this, op);
1565 }
1566
1567
1568 template<Index Log2Dim>
1569 template<typename VisitorOp>
1570 inline void
1571 LeafNode<ValueMask, Log2Dim>::visit(VisitorOp& op) const
1572 {
1573 doVisit<const LeafNode, VisitorOp, ChildAllCIter>(*this, op);
1574 }
1575
1576
1577 template<Index Log2Dim>
1578 template<typename NodeT, typename VisitorOp, typename ChildAllIterT>
1579 inline void
1580 LeafNode<ValueMask, Log2Dim>::doVisit(NodeT& self, VisitorOp& op)
1581 {
1582 for (ChildAllIterT iter = self.beginChildAll(); iter; ++iter) {
1583 op(iter);
1584 }
1585 }
1586
1587
1589
1590
1591 template<Index Log2Dim>
1592 template<typename OtherLeafNodeType, typename VisitorOp>
1593 inline void
1594 LeafNode<ValueMask, Log2Dim>::visit2Node(OtherLeafNodeType& other, VisitorOp& op)
1595 {
1596 doVisit2Node<LeafNode, OtherLeafNodeType, VisitorOp, ChildAllIter,
1597 typename OtherLeafNodeType::ChildAllIter>(*this, other, op);
1598 }
1599
1600
1601 template<Index Log2Dim>
1602 template<typename OtherLeafNodeType, typename VisitorOp>
1603 inline void
1604 LeafNode<ValueMask, Log2Dim>::visit2Node(OtherLeafNodeType& other, VisitorOp& op) const
1605 {
1606 doVisit2Node<const LeafNode, OtherLeafNodeType, VisitorOp, ChildAllCIter,
1607 typename OtherLeafNodeType::ChildAllCIter>(*this, other, op);
1608 }
1609
1610
1611 template<Index Log2Dim>
1612 template<
1613 typename NodeT,
1614 typename OtherNodeT,
1615 typename VisitorOp,
1616 typename ChildAllIterT,
1617 typename OtherChildAllIterT>
1618 inline void
1619 LeafNode<ValueMask, Log2Dim>::doVisit2Node(NodeT& self, OtherNodeT& other, VisitorOp& op)
1620 {
1621 // Allow the two nodes to have different ValueTypes, but not different dimensions.
1622 BOOST_STATIC_ASSERT(OtherNodeT::SIZE == NodeT::SIZE);
1623 BOOST_STATIC_ASSERT(OtherNodeT::LEVEL == NodeT::LEVEL);
1624
1625 ChildAllIterT iter = self.beginChildAll();
1626 OtherChildAllIterT otherIter = other.beginChildAll();
1627
1628 for ( ; iter && otherIter; ++iter, ++otherIter) {
1629 op(iter, otherIter);
1630 }
1631 }
1632
1633
1635
1636
1637 template<Index Log2Dim>
1638 template<typename IterT, typename VisitorOp>
1639 inline void
1640 LeafNode<ValueMask, Log2Dim>::visit2(IterT& otherIter, VisitorOp& op, bool otherIsLHS)
1641 {
1642 doVisit2<LeafNode, VisitorOp, ChildAllIter, IterT>(*this, otherIter, op, otherIsLHS);
1643 }
1644
1645
1646 template<Index Log2Dim>
1647 template<typename IterT, typename VisitorOp>
1648 inline void
1649 LeafNode<ValueMask, Log2Dim>::visit2(IterT& otherIter, VisitorOp& op, bool otherIsLHS) const
1650 {
1651 doVisit2<const LeafNode, VisitorOp, ChildAllCIter, IterT>(*this, otherIter, op, otherIsLHS);
1652 }
1653
1654
1655 template<Index Log2Dim>
1656 template<
1657 typename NodeT,
1658 typename VisitorOp,
1659 typename ChildAllIterT,
1660 typename OtherChildAllIterT>
1661 inline void
1662 LeafNode<ValueMask, Log2Dim>::doVisit2(NodeT& self, OtherChildAllIterT& otherIter,
1663 VisitorOp& op, bool otherIsLHS)
1664 {
1665 if (!otherIter) return;
1666
1667 if (otherIsLHS) {
1668 for (ChildAllIterT iter = self.beginChildAll(); iter; ++iter) {
1669 op(otherIter, iter);
1670 }
1671 } else {
1672 for (ChildAllIterT iter = self.beginChildAll(); iter; ++iter) {
1673 op(iter, otherIter);
1674 }
1675 }
1676 }
1677
1678 } // namespace tree
1679 } // namespace OPENVDB_VERSION_NAME
1680 } // namespace openvdb
1681
1682 #endif // OPENVDB_TREE_LEAF_NODE_MASK_HAS_BEEN_INCLUDED
1683
1684 // Copyright (c) 2012-2016 DreamWorks Animation LLC
1685 // All rights reserved. This software is distributed under the
1686 // Mozilla Public License 2.0 ( http://www.mozilla.org/MPL/2.0/ )
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::isDense
bool isDense() const
Return true if this node only contains active voxels.
Definition: LeafNodeMask.h:220
openvdb::v3_2_0::util::NodeMask::beginOff
OffIterator beginOff() const
Definition: NodeMasks.h:351
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::setOrigin
void setOrigin(const Coord &origin)
Set the grid index coordinates of this node&#39;s local origin.
Definition: LeafNodeMask.h:246
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::probeLeafAndCache
const LeafNode * probeLeafAndCache(const Coord &, AccessorT &) const
Return a const pointer to this node.
Definition: LeafNodeMask.h:622
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::beginChildAll
ChildAllCIter beginChildAll() const
Definition: LeafNodeMask.h:748
openvdb::v3_2_0::tree::LeafNode::evalActiveBoundingBox
void evalActiveBoundingBox(CoordBBox &bbox, bool visitVoxels=true) const
Definition: LeafNode.h:1727
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >
LeafNode specialization for values of type ValueMask that encodes both the active states and the bool...
Definition: LeafNodeMask.h:55
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::isValueOn
bool isValueOn(Index offset) const
Return true if the voxel at the given offset is active.
Definition: LeafNodeMask.h:366
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::getValueAndCache
const bool & getValueAndCache(const Coord &xyz, AccessorT &) const
Return the value of the voxel at the given coordinates.
Definition: LeafNodeMask.h:416
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::getValueMask
NodeMaskType & getValueMask()
Definition: LeafNodeMask.h:770
openvdb::v3_2_0::tree::LeafNode::getNodeBoundingBox
CoordBBox getNodeBoundingBox() const
Return the bounding box of this node, i.e., the full index space spanned by this leaf node...
Definition: LeafNode.h:469
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::cendValueOff
ValueOffCIter cendValueOff() const
Definition: LeafNodeMask.h:732
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::ChildOnCIter
ChildIter< MaskOnIter, const LeafNode > ChildOnCIter
Definition: LeafNodeMask.h:713
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::offLeafVoxelCount
Index64 offLeafVoxelCount() const
Definition: LeafNodeMask.h:213
openvdb::v3_2_0::tree::LeafNode::LEVEL
static const Index LEVEL
Definition: LeafNode.h:81
Types.h
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::probeConstNode
const NodeT * probeConstNode(const Coord &) const
This function exists only to enable template instantiation.
Definition: LeafNodeMask.h:591
openvdb::v3_2_0::tree::LeafNode::coordToOffset
static Index coordToOffset(const Coord &xyz)
Return the linear table offset of the given global or local coordinates.
Definition: LeafNode.h:1276
Compression.h
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::ValueOnCIter
ValueIter< MaskOnIter, const LeafNode, const bool > ValueOnCIter
Definition: LeafNodeMask.h:707
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::leafCount
static Index32 leafCount()
Return the leaf count for this node, which is one.
Definition: LeafNodeMask.h:204
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::Buffer::WordType
NodeMaskType::Word WordType
Definition: LeafNodeMask.h:90
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::cbeginChildAll
ChildAllCIter cbeginChildAll() const
Definition: LeafNodeMask.h:747
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::Buffer::data
WordType * data()
Definition: LeafNodeMask.h:127
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::getValueLevel
static Index getValueLevel(const Coord &)
Return the level (0) at which leaf node values reside.
Definition: LeafNodeMask.h:311
openvdb::v3_2_0::tree::LeafNode::hasSameTopology
bool hasSameTopology(const LeafNode< OtherType, OtherLog2Dim > *other) const
Return true if the given node (which may have a different ValueType than this node) has the same acti...
Definition: LeafNode.h:1745
openvdb::v3_2_0::math::Coord::setX
Coord & setX(Int32 x)
Definition: Coord.h:101
openvdb::v3_2_0::tree::LeafNode::memUsage
Index64 memUsage() const
Return the memory in bytes occupied by this node.
Definition: LeafNode.h:1717
Math.h
General-purpose arithmetic and comparison routines, most of which accept arbitrary value types (or at...
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::getNodeLog2Dims
static void getNodeLog2Dims(std::vector< Index > &dims)
Append the Log2Dim of this LeafNode to the specified vector.
Definition: LeafNodeMask.h:200
openvdb::v3_2_0::tree::LeafNode::addTile
void addTile(Index level, const Coord &, const ValueType &, bool)
Definition: LeafNode.h:1792
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::sOn
static const bool sOn
Definition: LeafNodeMask.h:801
openvdb::v3_2_0::tools::copyToDense
void copyToDense(const GridOrTreeT &sparse, DenseT &dense, bool serial=false)
Populate a dense grid with the values of voxels from a sparse grid, where the sparse grid intersects ...
Definition: Dense.h:443
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::ValueIter::setValue
void setValue(bool value) const
Definition: LeafNodeMask.h:661
openvdb::v3_2_0::tree::LeafNode::writeTopology
void writeTopology(std::ostream &os, bool toHalf=false) const
Write out just the topology.
Definition: LeafNode.h:1544
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::getFirstValue
const bool & getFirstValue() const
Return a const reference to the first entry in the buffer.
Definition: LeafNodeMask.h:485
openvdb::v3_2_0::TopologyCopy
Definition: Types.h:442
openvdb::v3_2_0::math::CoordBBox::reset
void reset()
Definition: Coord.h:338
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::setValuesOff
void setValuesOff()
Mark all voxels as inactive but don&#39;t change their values.
Definition: LeafNodeMask.h:361
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::endValueAll
ValueAllIter endValueAll()
Definition: LeafNodeMask.h:737
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::isValueMaskOff
bool isValueMaskOff() const
Definition: LeafNodeMask.h:767
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::resetBackground
void resetBackground(bool, bool)
no-op since for this temaplte specialization voxel values and states are indistinguishable.
Definition: LeafNodeMask.h:500
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::getChildDim
static Index getChildDim()
Return the dimension of child nodes of this LeafNode, which is one for voxels.
Definition: LeafNodeMask.h:202
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::ValueIter::setItem
void setItem(Index pos, bool value) const
Definition: LeafNodeMask.h:659
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::probeConstNodeAndCache
const NodeT * probeConstNodeAndCache(const Coord &, AccessorT &) const
Return a const pointer to this node.
Definition: LeafNodeMask.h:627
openvdb::v3_2_0::tree::LeafNode::setValueOn
void setValueOn(const Coord &xyz)
Mark the voxel at the given coordinates as active but don&#39;t change its value.
Definition: LeafNode.h:714
openvdb::v3_2_0::tree::LeafNode::visit
void visit(VisitorOp &)
Definition: LeafNode.h:2068
openvdb::v3_2_0::tree::LeafNode::offsetToLocalCoord
static Coord offsetToLocalCoord(Index n)
Return the local coordinates for a linear table offset, where offset 0 has coordinates (0...
Definition: LeafNode.h:1286
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::endChildOff
ChildOffCIter endChildOff() const
Definition: LeafNodeMask.h:755
openvdb::v3_2_0::tree::LeafNode::operator!=
bool operator!=(const LeafNode &other) const
Definition: LeafNode.h:498
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::setActiveState
void setActiveState(Index offset, bool on)
Set the active state of the voxel at the given offset but don&#39;t change its value. ...
Definition: LeafNodeMask.h:316
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::ChildIter::ChildIter
ChildIter()
Definition: LeafNodeMask.h:676
openvdb::v3_2_0::math::Coord::ValueType
Int32 ValueType
Definition: Coord.h:55
openvdb::v3_2_0::CombineArgs::setARef
CombineArgs & setARef(const AValueType &a)
Redirect the A value to a new external source.
Definition: Types.h:365
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::Buffer::Buffer
Buffer(const Buffer &other)
Definition: LeafNodeMask.h:95
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::getNodeBoundingBox
CoordBBox getNodeBoundingBox() const
Return the bounding box of this node, i.e., the full index space spanned by this leaf node...
Definition: LeafNodeMask.h:243
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::setValueOff
void setValueOff(Index offset)
Mark the voxel at the given offset as inactive but don&#39;t change its value.
Definition: LeafNodeMask.h:326
openvdb::v3_2_0::tree::LeafNode::topologyDifference
void topologyDifference(const LeafNode< OtherType, Log2Dim > &other, const ValueType &)
Difference this node&#39;s set of active values with the active values of the other node, whose ValueType may be different. So a resulting voxel will be active only if the original voxel is active in this LeafNode and inactive in the other LeafNode.
Definition: LeafNode.h:1914
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::ValueIter::modifyValue
void modifyValue(const ModifyOp &op) const
Definition: LeafNodeMask.h:668
openvdb::v3_2_0::tree::LeafNode::copyToDense
void copyToDense(const CoordBBox &bbox, DenseT &dense) const
Copy into a dense grid the values of the voxels that lie within a given bounding box.
Definition: LeafNode.h:1468
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::isEmpty
bool isEmpty() const
Return true if this node has no active voxels.
Definition: LeafNodeMask.h:218
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::endValueOn
ValueOnCIter endValueOn() const
Definition: LeafNodeMask.h:730
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::beginValueAll
ValueAllCIter beginValueAll() const
Definition: LeafNodeMask.h:726
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::getValueMask
const NodeMaskType & getValueMask() const
Definition: LeafNodeMask.h:768
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::endValueOff
ValueOffIter endValueOff()
Definition: LeafNodeMask.h:734
openvdb::v3_2_0::math::isZero
bool isZero(const Type &x)
Return true if x is exactly equal to zero.
Definition: Math.h:324
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::ValueIter::getItem
const bool & getItem(Index pos) const
Definition: LeafNodeMask.h:655
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::dim
static Index dim()
Return the number of voxels in each dimension.
Definition: LeafNodeMask.h:192
openvdb::v3_2_0::tree::LeafNode::modifyValue
void modifyValue(Index offset, const ModifyOp &op)
Apply a functor to the value of the voxel at the given offset and mark the voxel as active...
Definition: LeafNode.h:732
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::isChildMaskOn
bool isChildMaskOn(Index) const
Definition: LeafNodeMask.h:772
openvdb::v3_2_0::math::Coord
Signed (x, y, z) 32-bit integer coordinates.
Definition: Coord.h:47
openvdb::v3_2_0::tree::LeafNode::readBuffers
void readBuffers(std::istream &is, bool fromHalf=false)
Read buffers from a stream.
Definition: LeafNode.h:1598
openvdb::v3_2_0::tree::SameLeafConfig
Definition: PointIndexGrid.h:69
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::ValueIter::modifyItem
void modifyItem(Index n, const ModifyOp &op) const
Definition: LeafNodeMask.h:665
openvdb::v3_2_0::tree::LeafNode::ChildAllCIter
DenseIter< const LeafNode, const ValueType, ChildAll > ChildAllCIter
Definition: LeafNode.h:592
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::addLeaf
void addLeaf(LeafNode *)
This function exists only to enable template instantiation.
Definition: LeafNodeMask.h:583
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::beginValueOff
ValueOffCIter beginValueOff() const
Definition: LeafNodeMask.h:723
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::beginValueOn
ValueOnCIter beginValueOn() const
Definition: LeafNodeMask.h:720
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::setValueOn
void setValueOn(Index offset)
Mark the voxel at the given offset as active but don&#39;t change its value.
Definition: LeafNodeMask.h:336
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::Ptr
boost::shared_ptr< LeafNodeType > Ptr
Definition: LeafNodeMask.h:59
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::probeConstLeafAndCache
const LeafNode * probeConstLeafAndCache(const Coord &, AccessorT &) const
Return a const pointer to this node.
Definition: LeafNodeMask.h:625
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::isValueMaskOff
bool isValueMaskOff(Index n) const
Definition: LeafNodeMask.h:766
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::DenseIter::BaseT
DenseIteratorBase< MaskDenseIter, DenseIter, NodeT, void, ValueT > BaseT
Definition: LeafNodeMask.h:685
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::getValueLevelAndCache
static Index getValueLevelAndCache(const Coord &, AccessorT &)
Return the LEVEL (=0) at which leaf node values reside.
Definition: LeafNodeMask.h:480
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::stealNodes
void stealNodes(ArrayT &, const ValueType &, bool)
This function exists only to enable template instantiation.
Definition: LeafNodeMask.h:593
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::Buffer::memUsage
Index memUsage() const
Definition: LeafNodeMask.h:121
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::endValueOn
ValueOnIter endValueOn()
Definition: LeafNodeMask.h:731
openvdb::v3_2_0::math::Coord::x
Int32 x() const
Definition: Coord.h:146
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::modifyValueAndActiveStateAndCache
void modifyValueAndActiveStateAndCache(const Coord &xyz, const ModifyOp &op, AccessorT &)
Definition: LeafNodeMask.h:454
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::MaskDenseIter
NodeMaskType::DenseIterator MaskDenseIter
Definition: LeafNodeMask.h:642
openvdb::v3_2_0::io::getGridBackgroundValuePtr
OPENVDB_API const void * getGridBackgroundValuePtr(std::ios_base &)
Return a pointer to the background value of the grid currently being read from or written to the give...
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::NodeMaskType
util::NodeMask< Log2Dim > NodeMaskType
Definition: LeafNodeMask.h:62
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::ChildAllIter
DenseIter< LeafNode, bool > ChildAllIter
Definition: LeafNodeMask.h:716
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::Buffer::Buffer
Buffer(bool on)
Definition: LeafNodeMask.h:93
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::setValueOn
void setValueOn(const Coord &xyz)
Mark the voxel at the given coordinates as active but don&#39;t change its value.
Definition: LeafNodeMask.h:334
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::probeValueAndCache
bool probeValueAndCache(const Coord &xyz, bool &val, AccessorT &) const
Return true if the voxel at the given coordinates is active and return the voxel value in val...
Definition: LeafNodeMask.h:472
openvdb::v3_2_0::tree::LeafNode::str
std::string str() const
Return a string representation of this node.
Definition: LeafNode.h:1263
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::cbeginChildOff
ChildOffCIter cbeginChildOff() const
Definition: LeafNodeMask.h:744
openvdb::v3_2_0::tools::copyFromDense
void copyFromDense(const DenseT &dense, GridOrTreeT &sparse, const typename GridOrTreeT::ValueType &tolerance, bool serial=false)
Populate a sparse grid with the values of all of the voxels of a dense grid.
Definition: Dense.h:590
openvdb::v3_2_0::tree::LeafNode::Buffer::mData
ValueType * mData
Definition: LeafNode.h:361
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::cbeginValueAll
ValueAllCIter cbeginValueAll() const
Definition: LeafNodeMask.h:725
openvdb::v3_2_0::math::Coord::setY
Coord & setY(Int32 y)
Definition: Coord.h:102
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::buffer
const Buffer & buffer() const
Definition: LeafNodeMask.h:280
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::getNodes
void getNodes(ArrayT &) const
This function exists only to enable template instantiation.
Definition: LeafNodeMask.h:592
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::getLastValue
const bool & getLastValue() const
Return a const reference to the last entry in the buffer.
Definition: LeafNodeMask.h:489
openvdb::v3_2_0::Index
Index32 Index
Definition: Types.h:58
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::allocate
bool allocate()
Allocate memory for this node&#39;s buffer if it has not already been allocated.
Definition: LeafNodeMask.h:230
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::beginChildOn
ChildOnCIter beginChildOn() const
Definition: LeafNodeMask.h:742
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::BuildType
ValueMask BuildType
Definition: LeafNodeMask.h:60
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::Buffer::Buffer
Buffer(const NodeMaskType &other)
Definition: LeafNodeMask.h:94
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::DenseIter::getItem
bool getItem(Index pos, void *&child, NonConstValueT &value) const
Definition: LeafNodeMask.h:691
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::DenseIter::unsetItem
void unsetItem(Index pos, const ValueT &val) const
Definition: LeafNodeMask.h:702
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::isChildMaskOff
bool isChildMaskOff(Index) const
Definition: LeafNodeMask.h:773
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::Buffer::operator==
bool operator==(const Buffer &other) const
Definition: LeafNodeMask.h:114
openvdb::v3_2_0::Int32
int32_t Int32
Definition: Types.h:60
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::cbeginValueOff
ValueOffCIter cbeginValueOff() const
Definition: LeafNodeMask.h:722
openvdb::v3_2_0::tree::LeafNode::combine2
void combine2(const LeafNode &other, const OtherType &, bool valueIsActive, CombineOp &)
Definition: LeafNode.h:1981
openvdb::v3_2_0::Index64
uint64_t Index64
Definition: Types.h:57
openvdb::v3_2_0::tree::LeafNode::Buffer::fill
void fill(const ValueType &val)
Populate this buffer with a constant value.
Definition: LeafNode.h:171
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::Buffer::fill
void fill(bool val)
Definition: LeafNodeMask.h:97
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::probeNode
NodeT * probeNode(const Coord &)
This function exists only to enable template instantiation.
Definition: LeafNodeMask.h:589
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::beginValueOff
ValueOffIter beginValueOff()
Definition: LeafNodeMask.h:724
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::ValueIter::ValueIter
ValueIter(const MaskIterT &iter, NodeT *parent)
Definition: LeafNodeMask.h:653
OPENVDB_VERSION_NAME
#define OPENVDB_VERSION_NAME
Definition: version.h:43
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::MaskOnIter
NodeMaskType::OnIterator MaskOnIter
Definition: LeafNodeMask.h:640
openvdb::v3_2_0::tools::clip
OPENVDB_STATIC_SPECIALIZATION GridType::Ptr clip(const GridType &grid, const BBoxd &)
Clip the given grid against a world-space bounding box and return a new grid containing the result...
Definition: Clip.h:356
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::cbeginValueOn
ValueOnCIter cbeginValueOn() const
Definition: LeafNodeMask.h:719
openvdb::v3_2_0::tree::LeafNode::origin
const Coord & origin() const
Return the grid index coordinates of this node&#39;s local origin.
Definition: LeafNode.h:475
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::endChildAll
ChildAllCIter endChildAll() const
Definition: LeafNodeMask.h:758
openvdb::v3_2_0::tree::LeafNode::clip
void clip(const CoordBBox &, const ValueType &background)
Set all voxels that lie outside the given axis-aligned box to the background.
Definition: LeafNode.h:1387
openvdb::v3_2_0::math::Coord::setZ
Coord & setZ(Int32 z)
Definition: Coord.h:103
openvdb::v3_2_0::math::CoordBBox::expand
void expand(ValueType padding)
Pad this bounding box with the specified padding.
Definition: Coord.h:401
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::ChildOnIter
ChildIter< MaskOnIter, LeafNode > ChildOnIter
Definition: LeafNodeMask.h:712
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::LeafNodeType
LeafNode< ValueMask, Log2Dim > LeafNodeType
Definition: LeafNodeMask.h:58
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::DenseIter::DenseIter
DenseIter(const MaskDenseIter &iter, NodeT *parent)
Definition: LeafNodeMask.h:689
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::endChildOn
ChildOnIter endChildOn()
Definition: LeafNodeMask.h:753
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::mOrigin
Coord mOrigin
Global grid index coordinates (x,y,z) of the local origin of this node.
Definition: LeafNodeMask.h:798
openvdb::v3_2_0::tree::LeafNode::operator==
bool operator==(const LeafNode &other) const
Check for buffer, state and origin equivalence.
Definition: LeafNode.h:1707
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::offTileCount
static Index64 offTileCount()
Definition: LeafNodeMask.h:215
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::cendValueOn
ValueOnCIter cendValueOn() const
Definition: LeafNodeMask.h:729
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::valueMask
const NodeMaskType & valueMask() const
Definition: LeafNodeMask.h:769
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::negate
void negate()
Invert the bits of the voxels, i.e. states and values.
Definition: LeafNodeMask.h:503
openvdb::v3_2_0::tree::LeafNode
Templated block class to hold specific data types and a fixed number of values determined by Log2Dim...
Definition: LeafNode.h:65
openvdb::v3_2_0::tree::LeafNode::visit2Node
void visit2Node(OtherLeafNodeType &other, VisitorOp &)
Definition: LeafNode.h:2100
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::probeNodeAndCache
NodeT * probeNodeAndCache(const Coord &, AccessorT &)
Return a pointer to this node.
Definition: LeafNodeMask.h:610
openvdb::v3_2_0::tree::LeafNode::setActiveState
void setActiveState(const Coord &xyz, bool on)
Set the active state of the voxel at the given coordinates but don&#39;t change its value.
Definition: LeafNode.h:1361
openvdb::v3_2_0::tree::LeafNode::beginChildAll
ChildAllCIter beginChildAll() const
Definition: LeafNode.h:623
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::setValueMaskOn
void setValueMaskOn(Index n)
Definition: LeafNodeMask.h:777
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::setValueAndCache
void setValueAndCache(const Coord &xyz, bool val, AccessorT &)
Change the value of the voxel at the given coordinates and mark it as active.
Definition: LeafNodeMask.h:426
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::onLeafVoxelCount
Index64 onLeafVoxelCount() const
Definition: LeafNodeMask.h:212
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::Buffer::operator[]
const bool & operator[](Index i) const
Definition: LeafNodeMask.h:112
openvdb::v3_2_0::util::NodeMask
Bit mask for the internal and leaf nodes of VDB. This is a 64-bit implementation. ...
Definition: NodeMasks.h:304
openvdb::v3_2_0::tree::LeafNode::addTileAndCache
void addTileAndCache(Index, const Coord &, const ValueType &, bool, AccessorT &)
Definition: LeafNode.h:1809
openvdb::v3_2_0::math::CoordBBox::translate
void translate(const Coord &t)
Translate this bounding box by .
Definition: Coord.h:440
openvdb::v3_2_0::tree::LeafNode::~LeafNode
~LeafNode()
Destructor.
Definition: LeafNode.h:1256
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::probeConstLeaf
const LeafNode * probeConstLeaf(const Coord &) const
Return a const pointer to this node.
Definition: LeafNodeMask.h:623
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::DenseIter::NonConstValueT
BaseT::NonConstValueType NonConstValueT
Definition: LeafNodeMask.h:686
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::cbeginChildOn
ChildOnCIter cbeginChildOn() const
Definition: LeafNodeMask.h:741
openvdb::v3_2_0::tree::LeafNode::readTopology
void readTopology(std::istream &is, bool fromHalf=false)
Read in just the topology.
Definition: LeafNode.h:1536
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::cendChildOn
ChildOnCIter cendChildOn() const
Definition: LeafNodeMask.h:751
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::endValueOff
ValueOffCIter endValueOff() const
Definition: LeafNodeMask.h:733
openvdb
Definition: Exceptions.h:39
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::ValueConverter::Type
LeafNode< OtherValueType, Log2Dim > Type
Definition: LeafNodeMask.h:77
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::offVoxelCount
Index64 offVoxelCount() const
Return the number of inactive voxels.
Definition: LeafNodeMask.h:211
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::log2dim
static Index log2dim()
Return log2 of the size of the buffer storage.
Definition: LeafNodeMask.h:190
openvdb::v3_2_0::tree::LeafNode::topologyUnion
void topologyUnion(const LeafNode< OtherType, Log2Dim > &other)
Union this node&#39;s set of active values with the active values of the other node, whose ValueType may ...
Definition: LeafNode.h:1897
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::nonLeafCount
static Index32 nonLeafCount()
Return the non-leaf count for this node, which is zero.
Definition: LeafNodeMask.h:206
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::cendChildAll
ChildAllCIter cendChildAll() const
Definition: LeafNodeMask.h:757
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::getLevel
static Index getLevel()
Return the level of this node, which by definition is zero for LeafNodes.
Definition: LeafNodeMask.h:198
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::MaskOffIter
NodeMaskType::OffIterator MaskOffIter
Definition: LeafNodeMask.h:641
openvdb::v3_2_0::Index32
uint32_t Index32
Definition: Types.h:56
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::ValueIter::getValue
const bool & getValue() const
Definition: LeafNodeMask.h:656
OPENVDB_NO_UNREACHABLE_CODE_WARNING_BEGIN
#define OPENVDB_NO_UNREACHABLE_CODE_WARNING_BEGIN
Definition: Platform.h:129
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::isValueMaskOn
bool isValueMaskOn() const
Definition: LeafNodeMask.h:765
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::beginValueAll
ValueAllIter beginValueAll()
Definition: LeafNodeMask.h:727
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::ChildOffIter
ChildIter< MaskOffIter, LeafNode > ChildOffIter
Definition: LeafNodeMask.h:714
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::setValueMaskOff
void setValueMaskOff(Index n)
Definition: LeafNodeMask.h:778
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::isValueOnAndCache
bool isValueOnAndCache(const Coord &xyz, AccessorT &) const
Return true if the voxel at the given coordinates is active.
Definition: LeafNodeMask.h:421
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::setValuesOn
void setValuesOn()
Mark all voxels as active but don&#39;t change their values.
Definition: LeafNodeMask.h:359
openvdb::v3_2_0::util::NodeMask::Word
Index64 Word
Definition: NodeMasks.h:313
openvdb::v3_2_0::tree::LeafNode::valueMask
const NodeMaskType & valueMask() const
Definition: LeafNode.h:1111
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::probeLeafAndCache
LeafNode * probeLeafAndCache(const Coord &, AccessorT &)
Return a pointer to this node.
Definition: LeafNodeMask.h:608
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::ValueAllIter
ValueIter< MaskDenseIter, LeafNode, const bool > ValueAllIter
Definition: LeafNodeMask.h:710
openvdb::v3_2_0::tree::DenseIteratorBase
Base class for dense iterators over internal and leaf nodes.
Definition: Iterator.h:211
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::ValueIter::BaseT
SparseIteratorBase< MaskIterT, ValueIter, NodeT, ValueT > BaseT
Definition: LeafNodeMask.h:650
openvdb::v3_2_0::tree::SparseIteratorBase
Base class for sparse iterators over internal and leaf nodes.
Definition: Iterator.h:148
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::isValueOn
bool isValueOn(const Coord &xyz) const
Return true if the voxel at the given coordinates is active.
Definition: LeafNodeMask.h:364
openvdb::v3_2_0::tree::DenseIteratorBase::NonConstValueType
boost::remove_const< UnsetItemT >::type NonConstValueType
Definition: Iterator.h:217
openvdb::v3_2_0::tree::LeafNode::getValue
const ValueType & getValue(const Coord &xyz) const
Return the value of the voxel at the given coordinates.
Definition: LeafNode.h:1311
openvdb::v3_2_0::tree::LeafNode::doVisit2
static void doVisit2(NodeT &self, OtherChildAllIterT &, VisitorOp &, bool otherIsLHS)
Definition: LeafNode.h:2170
openvdb::v3_2_0::math::Coord::z
Int32 z() const
Definition: Coord.h:148
openvdb::v3_2_0::tree::LeafNode::visitActiveBBox
void visitActiveBBox(BBoxOp &) const
Calls the templated functor BBoxOp with bounding box information. An additional level argument is pro...
Definition: LeafNode.h:2045
LeafNode.h
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::onTileCount
static Index64 onTileCount()
Definition: LeafNodeMask.h:214
openvdb::v3_2_0::util::DenseMaskIterator
Definition: NodeMasks.h:267
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::beginChildAll
ChildAllIter beginChildAll()
Definition: LeafNodeMask.h:749
openvdb::v3_2_0::tree::LeafNode::SIZE
static const Index SIZE
Definition: LeafNode.h:80
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::setValueMask
void setValueMask(Index n, bool on)
Definition: LeafNodeMask.h:776
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::Buffer::operator!=
bool operator!=(const Buffer &other) const
Definition: LeafNodeMask.h:115
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::sOff
static const bool sOff
Definition: LeafNodeMask.h:802
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::beginChildOff
ChildOffIter beginChildOff()
Definition: LeafNodeMask.h:746
openvdb::v3_2_0::util::NodeMask::setOn
void setOn(Index32 n)
Set the nth bit on.
Definition: NodeMasks.h:449
openvdb::v3_2_0::tree::LeafNode::combine
void combine(const LeafNode &other, CombineOp &op)
Definition: LeafNode.h:1939
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::Buffer::data
const WordType * data() const
Definition: LeafNodeMask.h:135
openvdb::v3_2_0::math::CoordBBox::min
const Coord & min() const
Definition: Coord.h:332
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::ValueOffCIter
ValueIter< MaskOffIter, const LeafNode, const bool > ValueOffCIter
Definition: LeafNodeMask.h:709
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::ValueType
bool ValueType
Definition: LeafNodeMask.h:61
openvdb::v3_2_0::tree::LeafNode::doVisit2Node
static void doVisit2Node(NodeT &self, OtherNodeT &other, VisitorOp &)
Definition: LeafNode.h:2125
openvdb::v3_2_0::math::operator==
bool operator==(const Vec3< T0 > &v0, const Vec3< T1 > &v1)
Equality operator, does exact floating point comparisons.
Definition: Vec3.h:450
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::endChildOn
ChildOnCIter endChildOn() const
Definition: LeafNodeMask.h:752
openvdb::v3_2_0::tree::LeafNode::LeafNode
LeafNode()
Default constructor.
Definition: LeafNode.h:1170
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::setActiveStateAndCache
void setActiveStateAndCache(const Coord &xyz, bool on, AccessorT &)
Set the active state of the voxel at the given coordinates without changing its value.
Definition: LeafNodeMask.h:463
openvdb::v3_2_0::math::CoordBBox::hasOverlap
bool hasOverlap(const CoordBBox &b) const
Return true if the given bounding box overlaps with this bounding box.
Definition: Coord.h:395
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::ChildIter::ChildIter
ChildIter(const MaskIterT &iter, NodeT *parent)
Definition: LeafNodeMask.h:677
openvdb::v3_2_0::math::CoordBBox::max
const Coord & max() const
Definition: Coord.h:333
OPENVDB_NO_UNREACHABLE_CODE_WARNING_END
#define OPENVDB_NO_UNREACHABLE_CODE_WARNING_END
Definition: Platform.h:130
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::setValueOff
void setValueOff(const Coord &xyz)
Mark the voxel at the given coordinates as inactive but don&#39;t change its value.
Definition: LeafNodeMask.h:324
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::buffer
Buffer & buffer()
Definition: LeafNodeMask.h:281
openvdb::v3_2_0::CombineArgs::setBRef
CombineArgs & setBRef(const BValueType &b)
Redirect the B value to a new external source.
Definition: Types.h:367
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::evalNodeOrigin
static void evalNodeOrigin(Coord &xyz)
Compute the origin of the leaf node that contains the voxel with the given coordinates.
Definition: LeafNodeMask.h:781
openvdb::v3_2_0::tree::LeafNode::getValueMask
const NodeMaskType & getValueMask() const
Definition: LeafNode.h:1109
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::Buffer::size
static Index size()
Definition: LeafNodeMask.h:122
openvdb::v3_2_0::math::CoordBBox
Axis-aligned bounding box of signed integer coordinates.
Definition: Coord.h:259
openvdb::v3_2_0::tree::LeafNode::cbeginValueOn
ValueOnCIter cbeginValueOn() const
Definition: LeafNode.h:594
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::modifyValueAndCache
void modifyValueAndCache(const Coord &xyz, const ModifyOp &op, AccessorT &)
Apply a functor to the value of the voxel at the given coordinates and mark the voxel as active...
Definition: LeafNodeMask.h:446
openvdb::v3_2_0::tree::LeafNode::setValueOnly
void setValueOnly(const Coord &xyz, const ValueType &val)
Set the value of the voxel at the given coordinates but don&#39;t change its active state.
Definition: LeafNode.h:1369
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::DenseIter::DenseIter
DenseIter()
Definition: LeafNodeMask.h:688
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::setValueOffAndCache
void setValueOffAndCache(const Coord &xyz, bool value, AccessorT &)
Change the value of the voxel at the given coordinates and mark it as inactive.
Definition: LeafNodeMask.h:437
openvdb::v3_2_0::tree::LeafNode::LOG2DIM
static const Index LOG2DIM
Definition: LeafNode.h:75
openvdb::v3_2_0::MERGE_ACTIVE_STATES_AND_NODES
Definition: Types.h:267
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::swap
void swap(Buffer &other)
Exchange this node&#39;s data buffer with the given data buffer without changing the active states of the...
Definition: LeafNodeMask.h:279
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::onVoxelCount
Index64 onVoxelCount() const
Return the number of active voxels.
Definition: LeafNodeMask.h:209
openvdb::v3_2_0::tree::LeafNode::writeBuffers
void writeBuffers(std::ostream &os, bool toHalf=false) const
Write buffers to a stream.
Definition: LeafNode.h:1690
openvdb::v3_2_0::math::Coord::y
Int32 y() const
Definition: Coord.h:147
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::getOrigin
void getOrigin(Coord &origin) const
Return the grid index coordinates of this node&#39;s local origin.
Definition: LeafNodeMask.h:250
openvdb::v3_2_0::tree::LeafNode::ChildAllIter
DenseIter< LeafNode, ValueType, ChildAll > ChildAllIter
Definition: LeafNode.h:591
Iterator.h
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::setValue
void setValue(const Coord &xyz, bool val)
Set the value of the voxel at the given coordinates and mark the voxel as active. ...
Definition: LeafNodeMask.h:341
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::ChildOffCIter
ChildIter< MaskOffIter, const LeafNode > ChildOffCIter
Definition: LeafNodeMask.h:715
openvdb::v3_2_0::math::operator!=
bool operator!=(const Vec3< T0 > &v0, const Vec3< T1 > &v1)
Inequality operator, does exact floating point comparisons.
Definition: Vec3.h:458
openvdb::v3_2_0::tools::prune
void prune(TreeT &tree, typename TreeT::ValueType tolerance=zeroVal< typename TreeT::ValueType >(), bool threaded=true, size_t grainSize=1)
Reduce the memory footprint of a tree by replacing with tiles any nodes whose values are all the same...
Definition: Prune.h:374
openvdb::v3_2_0::math::CoordBBox::intersect
void intersect(const CoordBBox &bbox)
Intersect this bounding box with the given bounding box.
Definition: Coord.h:427
openvdb::v3_2_0::tree::LeafNode::copyFromDense
void copyFromDense(const CoordBBox &bbox, const DenseT &dense, const ValueType &background, const ValueType &tolerance)
Copy from a dense grid into this node the values of the voxels that lie within a given bounding box...
Definition: LeafNode.h:1497
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::ValueOffIter
ValueIter< MaskOffIter, LeafNode, const bool > ValueOffIter
Definition: LeafNodeMask.h:708
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::endValueAll
ValueAllCIter endValueAll() const
Definition: LeafNodeMask.h:736
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::endChildAll
ChildAllIter endChildAll()
Definition: LeafNodeMask.h:759
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::setValueMask
void setValueMask(const NodeMaskType &mask)
Definition: LeafNodeMask.h:771
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::beginChildOff
ChildOffCIter beginChildOff() const
Definition: LeafNodeMask.h:745
openvdb::v3_2_0::util::OnMaskIterator
Definition: NodeMasks.h:205
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::voxelizeActiveTiles
void voxelizeActiveTiles(bool=true)
No-op.
Definition: LeafNodeMask.h:511
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::endChildOff
ChildOffIter endChildOff()
Definition: LeafNodeMask.h:756
openvdb::v3_2_0::util::OffMaskIterator
Definition: NodeMasks.h:236
NodeMasks.h
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::isInactive
bool isInactive() const
Return true if all of this node&#39;s values are inactive.
Definition: LeafNodeMask.h:496
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::ValueOnIter
ValueIter< MaskOnIter, LeafNode, const bool > ValueOnIter
Definition: LeafNodeMask.h:706
openvdb::v3_2_0::math::CoordBBox::isInside
bool isInside(const Coord &xyz) const
Return true if point (x, y, z) is inside this bounding box.
Definition: Coord.h:383
openvdb::v3_2_0::PartialCreate
Definition: Types.h:444
openvdb::v3_2_0::tree::LeafNode::doVisit
static void doVisit(NodeT &, VisitorOp &)
Definition: LeafNode.h:2086
OPENVDB_USE_VERSION_NAMESPACE
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h:71
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::Buffer::swap
void swap(Buffer &other)
Definition: LeafNodeMask.h:119
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::hasActiveTiles
static bool hasActiveTiles()
Return false since leaf nodes never contain tiles.
Definition: LeafNodeMask.h:369
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::setValueOnly
void setValueOnly(Index offset, bool val)
Set the value of the voxel at the given offset but don&#39;t change its active state. ...
Definition: LeafNodeMask.h:321
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::setValueOnlyAndCache
void setValueOnlyAndCache(const Coord &xyz, bool val, AccessorT &)
Change the value of the voxel at the given coordinates but preserve its state.
Definition: LeafNodeMask.h:432
openvdb::v3_2_0::tree::LeafNode::topologyIntersection
void topologyIntersection(const LeafNode< OtherType, Log2Dim > &other, const ValueType &)
Intersect this node&#39;s set of active values with the active values of the other node, whose ValueType may be different. So a resulting voxel will be active only if both of the original voxels were active.
Definition: LeafNode.h:1905
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::ValueAllCIter
ValueIter< MaskDenseIter, const LeafNode, const bool > ValueAllCIter
Definition: LeafNodeMask.h:711
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::numValues
static Index numValues()
Return the total number of voxels represented by this LeafNode.
Definition: LeafNodeMask.h:196
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::size
static Index size()
Return the total number of voxels represented by this LeafNode.
Definition: LeafNodeMask.h:194
openvdb::v3_2_0::tree::LeafNode::isConstant
bool isConstant(ValueType &firstValue, bool &state, const ValueType &tolerance=zeroVal< ValueType >()) const
Definition: LeafNode.h:1753
openvdb::v3_2_0::tree::LeafNode::merge
void merge(const LeafNode &)
Definition: LeafNode.h:1844
openvdb::v3_2_0::tree::LeafNode::modifyValueAndActiveState
void modifyValueAndActiveState(const Coord &xyz, const ModifyOp &op)
Apply a functor to the voxel at the given coordinates.
Definition: LeafNode.h:749
openvdb::v3_2_0::tree::LeafNode::probeValue
bool probeValue(const Coord &xyz, ValueType &val) const
Return true if the voxel at the given coordinates is active.
Definition: LeafNode.h:1327
openvdb::v3_2_0::ValueMask
Definition: Types.h:109
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::mBuffer
Buffer mBuffer
Bitmask representing the values AND state of voxels.
Definition: LeafNodeMask.h:795
openvdb::v3_2_0::MERGE_NODES
Definition: Types.h:266
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::Buffer::operator=
Buffer & operator=(const Buffer &b)
Definition: LeafNodeMask.h:98
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::isValueMaskOn
bool isValueMaskOn(Index n) const
Definition: LeafNodeMask.h:764
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::cendValueAll
ValueAllCIter cendValueAll() const
Definition: LeafNodeMask.h:735
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::probeLeaf
LeafNode * probeLeaf(const Coord &)
Return a pointer to this node.
Definition: LeafNodeMask.h:606
openvdb::v3_2_0::tree::LeafNode::visit2
void visit2(IterT &otherIter, VisitorOp &, bool otherIsLHS=false)
Definition: LeafNode.h:2146
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::ChildAllCIter
DenseIter< const LeafNode, const bool > ChildAllCIter
Definition: LeafNodeMask.h:717
openvdb::v3_2_0::tree::LeafNode::fill
void fill(const CoordBBox &bbox, const ValueType &, bool active=true)
Set all voxels within an axis-aligned box to the specified value and active state.
Definition: LeafNode.h:1427
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::beginValueOn
ValueOnIter beginValueOn()
Definition: LeafNodeMask.h:721
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::Buffer::setValue
void setValue(Index i, bool val)
Definition: LeafNodeMask.h:117
openvdb::v3_2_0::tree::LeafNode::setValueOff
void setValueOff(const Coord &xyz)
Mark the voxel at the given coordinates as inactive but don&#39;t change its value.
Definition: LeafNode.h:704
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::addLeafAndCache
void addLeafAndCache(LeafNode *, AccessorT &)
This function exists only to enable template instantiation.
Definition: LeafNodeMask.h:585
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::Buffer::~Buffer
~Buffer()
Definition: LeafNodeMask.h:96
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::isChildMaskOff
bool isChildMaskOff() const
Definition: LeafNodeMask.h:774
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::Buffer::Buffer
Buffer()
Definition: LeafNodeMask.h:92
openvdb::v3_2_0::CombineArgs
This struct collects both input and output arguments to "grid combiner" functors used with the tree::...
Definition: Types.h:312
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::Buffer::getValue
const bool & getValue(Index i) const
Definition: LeafNodeMask.h:104
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::beginChildOn
ChildOnIter beginChildOn()
Definition: LeafNodeMask.h:743
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::ValueIter::ValueIter
ValueIter()
Definition: LeafNodeMask.h:652
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::cendChildOff
ChildOffCIter cendChildOff() const
Definition: LeafNodeMask.h:754
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::stealNode
NodeT * stealNode(const Coord &, const ValueType &, bool)
This function exists only to enable template instantiation.
Definition: LeafNodeMask.h:587
openvdb::v3_2_0::tree::LeafNode::DIM
static const Index DIM
Definition: LeafNode.h:77
openvdb::v3_2_0::tree::LeafNode::offsetToGlobalCoord
Coord offsetToGlobalCoord(Index n) const
Return the global coordinates for a linear table offset.
Definition: LeafNode.h:1300
openvdb::v3_2_0::math::CoordBBox::createCube
static CoordBBox createCube(const Coord &min, ValueType dim)
Definition: Coord.h:324
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::getOrigin
void getOrigin(Int32 &x, Int32 &y, Int32 &z) const
Return the grid index coordinates of this node&#39;s local origin.
Definition: LeafNodeMask.h:251
openvdb::v3_2_0::tree::IteratorBase
Base class for iterators over internal and leaf nodes.
Definition: Iterator.h:58
openvdb::v3_2_0::tree::LeafNode< ValueMask, Log2Dim >::touchLeafAndCache
LeafNode * touchLeafAndCache(const Coord &, AccessorT &)
Return a pointer to this node.
Definition: LeafNodeMask.h:605
openvdb::v3_2_0::tools::composite::min
const boost::disable_if_c< VecTraits< T >::IsVec, T >::type & min(const T &a, const T &b)
Definition: Composite.h:128