OpenVDB: LeafNodeBool.h Source File

OpenVDB 3.1.0

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

- File List
- File Members

LeafNodeBool.h
Go to the documentation of this file.
1 //
3 // Copyright (c) 2012-2015 DreamWorks Animation LLC
4 //
5 // All rights reserved. This software is distributed under the
6 // Mozilla Public License 2.0 ( http://www.mozilla.org/MPL/2.0/ )
7 //
8 // Redistributions of source code must retain the above copyright
9 // and license notice and the following restrictions and disclaimer.
10 //
11 // * Neither the name of DreamWorks Animation nor the names of
12 // its contributors may be used to endorse or promote products derived
13 // from this software without specific prior written permission.
14 //
15 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
18 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
19 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY INDIRECT, INCIDENTAL,
20 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
21 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 // IN NO EVENT SHALL THE COPYRIGHT HOLDERS' AND CONTRIBUTORS' AGGREGATE
27 // LIABILITY FOR ALL CLAIMS REGARDLESS OF THEIR BASIS EXCEED US$250.00.
28 //
30
31 #ifndef OPENVDB_TREE_LEAFNODEBOOL_HAS_BEEN_INCLUDED
32 #define OPENVDB_TREE_LEAFNODEBOOL_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
53 template<Index Log2Dim>
54 class LeafNode<bool, Log2Dim>
55 {
56 public:
57 typedef LeafNode<bool, Log2Dim> LeafNodeType;
58 typedef boost::shared_ptr<LeafNodeType> Ptr;
59 typedef bool ValueType;
60 typedef util::NodeMask<Log2Dim> NodeMaskType;
61
62 // These static declarations must be on separate lines to avoid VC9 compiler errors.
63 static const Index LOG2DIM = Log2Dim; // needed by parent nodes
64 static const Index TOTAL = Log2Dim; // needed by parent nodes
65 static const Index DIM = 1 << TOTAL; // dimension along one coordinate direction
66 static const Index NUM_VALUES = 1 << 3 * Log2Dim;
67 static const Index NUM_VOXELS = NUM_VALUES; // total number of voxels represented by this node
68 static const Index SIZE = NUM_VALUES;
69 static const Index LEVEL = 0; // level 0 = leaf
70
73 template<typename ValueType>
74 struct ValueConverter { typedef LeafNode<ValueType, Log2Dim> Type; };
75
78 template<typename OtherNodeType>
79 struct SameConfiguration {
80 static const bool value = SameLeafConfig<LOG2DIM, OtherNodeType>::value;
81 };
82
83
84 class Buffer
85 {
86 public:
87 typedef typename NodeMaskType::Word WordType;
88 static const Index WORD_COUNT = NodeMaskType::WORD_COUNT;
89 Buffer() {}
90 Buffer(bool on) : mData(on) {}
91 Buffer(const NodeMaskType& other): mData(other) {}
92 Buffer(const Buffer& other): mData(other.mData) {}
93 ~Buffer() {}
94 void fill(bool val) { mData.set(val); }
95 Buffer& operator=(const Buffer& b) { if (&b != this) { mData = b.mData; } return *this; }
96
97 const bool& getValue(Index i) const
98 {
99 assert(i < SIZE);
100 // We can't use the ternary operator here, otherwise Visual C++ returns
101 // a reference to a temporary.
102 if (mData.isOn(i)) return LeafNode::sOn; else return LeafNode::sOff;
103 }
104 const bool& operator[](Index i) const { return this->getValue(i); }
105
106 bool operator==(const Buffer& other) const { return mData == other.mData; }
107 bool operator!=(const Buffer& other) const { return mData != other.mData; }
108
109 void setValue(Index i, bool val) { assert(i < SIZE); mData.set(i, val); }
110
111 void swap(Buffer& other) { if (&other != this) std::swap(mData, other.mData); }
112
113 Index memUsage() const { return mData.memUsage(); }
114 static Index size() { return SIZE; }
115
119 WordType* data()
120 {
121 return &(mData.template getWord<WordType>(0));
122 }
127 const WordType* data() const
128 {
129 return const_cast<Buffer*>(this)->data();
130 }
131
132 private:
133 friend class ::TestLeaf;
134 // Allow the parent LeafNode to access this Buffer's bit mask.
135 friend class LeafNode;
136
137 NodeMaskType mData;
138 }; // class Buffer
139
140
142 LeafNode();
143
148 explicit LeafNode(const Coord& xyz, bool value = false, bool active = false);
149
150 #ifndef OPENVDB_2_ABI_COMPATIBLE
151 LeafNode(PartialCreate, const Coord& xyz, bool value = false, bool active = false);
153 #endif
154
156 LeafNode(const LeafNode&);
157
159 template<typename OtherValueType>
160 explicit LeafNode(const LeafNode<OtherValueType, Log2Dim>& other);
161
163 template<typename ValueType>
164 LeafNode(const LeafNode<ValueType, Log2Dim>& other, TopologyCopy);
165
167 template<typename ValueType>
170 LeafNode(const LeafNode<ValueType, Log2Dim>& other, bool offValue, bool onValue, TopologyCopy);
171 template<typename ValueType>
172 LeafNode(const LeafNode<ValueType, Log2Dim>& other, bool background, TopologyCopy);
174
176 ~LeafNode();
177
178 //
179 // Statistics
180 //
182 static Index log2dim() { return Log2Dim; }
184 static Index dim() { return DIM; }
185 static Index size() { return SIZE; }
186 static Index numValues() { return SIZE; }
187 static Index getLevel() { return LEVEL; }
188 static void getNodeLog2Dims(std::vector<Index>& dims) { dims.push_back(Log2Dim); }
189 static Index getChildDim() { return 1; }
190
191 static Index32 leafCount() { return 1; }
192 static Index32 nonLeafCount() { return 0; }
193
195 Index64 onVoxelCount() const { return mValueMask.countOn(); }
197 Index64 offVoxelCount() const { return mValueMask.countOff(); }
198 Index64 onLeafVoxelCount() const { return onVoxelCount(); }
199 Index64 offLeafVoxelCount() const { return offVoxelCount(); }
200 static Index64 onTileCount() { return 0; }
201 static Index64 offTileCount() { return 0; }
202
204 bool isEmpty() const { return mValueMask.isOff(); }
206 bool isDense() const { return mValueMask.isOn(); }
207
208 #ifndef OPENVDB_2_ABI_COMPATIBLE
209 bool isAllocated() const { return true; }
216 bool allocate() { return true; }
217 #endif
218
220 Index64 memUsage() const;
221
225 void evalActiveBoundingBox(CoordBBox& bbox, bool visitVoxels = true) const;
226
229 CoordBBox getNodeBoundingBox() const { return CoordBBox::createCube(mOrigin, DIM); }
230
232 void setOrigin(const Coord& origin) { mOrigin = origin; }
234 const Coord& origin() const { return mOrigin; }
236 void getOrigin(Coord& origin) const { origin = mOrigin; }
237 void getOrigin(Int32& x, Int32& y, Int32& z) const { mOrigin.asXYZ(x, y, z); }
239
241 static Index coordToOffset(const Coord& xyz);
244 static Coord offsetToLocalCoord(Index n);
246 Coord offsetToGlobalCoord(Index n) const;
247
249 std::string str() const;
250
253 template<typename OtherType, Index OtherLog2Dim>
254 bool hasSameTopology(const LeafNode<OtherType, OtherLog2Dim>* other) const;
255
257 bool operator==(const LeafNode&) const;
258 bool operator!=(const LeafNode&) const;
259
260 //
261 // Buffer management
262 //
265 void swap(Buffer& other) { mBuffer.swap(other); }
266 const Buffer& buffer() const { return mBuffer; }
267 Buffer& buffer() { return mBuffer; }
268
269 //
270 // I/O methods
271 //
273 void readTopology(std::istream&, bool fromHalf = false);
275 void writeTopology(std::ostream&, bool toHalf = false) const;
276
278 void readBuffers(std::istream&, bool fromHalf = false);
279 void readBuffers(std::istream& is, const CoordBBox&, bool fromHalf = false);
281 void writeBuffers(std::ostream&, bool toHalf = false) const;
282
283 //
284 // Accessor methods
285 //
287 const bool& getValue(const Coord& xyz) const;
289 const bool& getValue(Index offset) const;
290
294 bool probeValue(const Coord& xyz, bool& val) const;
295
297 static Index getValueLevel(const Coord&) { return LEVEL; }
298
300 void setActiveState(const Coord& xyz, bool on);
302 void setActiveState(Index offset, bool on) { assert(offset<SIZE); mValueMask.set(offset, on); }
303
305 void setValueOnly(const Coord& xyz, bool val);
307 void setValueOnly(Index offset, bool val) { assert(offset<SIZE); mBuffer.setValue(offset,val); }
308
310 void setValueOff(const Coord& xyz) { mValueMask.setOff(this->coordToOffset(xyz)); }
312 void setValueOff(Index offset) { assert(offset < SIZE); mValueMask.setOff(offset); }
313
315 void setValueOff(const Coord& xyz, bool val);
317 void setValueOff(Index offset, bool val);
318
320 void setValueOn(const Coord& xyz) { mValueMask.setOn(this->coordToOffset(xyz)); }
322 void setValueOn(Index offset) { assert(offset < SIZE); mValueMask.setOn(offset); }
323
325 void setValueOn(const Coord& xyz, bool val);
327 void setValue(const Coord& xyz, bool val) { this->setValueOn(xyz, val); }
329 void setValueOn(Index offset, bool val);
330
333 template<typename ModifyOp>
334 void modifyValue(Index offset, const ModifyOp& op);
337 template<typename ModifyOp>
338 void modifyValue(const Coord& xyz, const ModifyOp& op);
339
341 template<typename ModifyOp>
342 void modifyValueAndActiveState(const Coord& xyz, const ModifyOp& op);
343
345 void setValuesOn() { mValueMask.setOn(); }
347 void setValuesOff() { mValueMask.setOff(); }
348
350 bool isValueOn(const Coord& xyz) const { return mValueMask.isOn(this->coordToOffset(xyz)); }
352 bool isValueOn(Index offset) const { assert(offset < SIZE); return mValueMask.isOn(offset); }
353
355 static bool hasActiveTiles() { return false; }
356
358 void clip(const CoordBBox&, bool background);
359
361 void fill(const CoordBBox& bbox, bool value, bool active = true);
362
364 void fill(const bool& value);
366 void fill(const bool& value, bool active);
367
379 template<typename DenseT>
380 void copyToDense(const CoordBBox& bbox, DenseT& dense) const;
381
398 template<typename DenseT>
399 void copyFromDense(const CoordBBox& bbox, const DenseT& dense, bool background, bool tolerance);
400
403 template<typename AccessorT>
404 const bool& getValueAndCache(const Coord& xyz, AccessorT&) const {return this->getValue(xyz);}
405
408 template<typename AccessorT>
409 bool isValueOnAndCache(const Coord& xyz, AccessorT&) const { return this->isValueOn(xyz); }
410
413 template<typename AccessorT>
414 void setValueAndCache(const Coord& xyz, bool val, AccessorT&) { this->setValueOn(xyz, val); }
415
419 template<typename AccessorT>
420 void setValueOnlyAndCache(const Coord& xyz, bool val, AccessorT&) {this->setValueOnly(xyz,val);}
421
424 template<typename AccessorT>
425 void setValueOffAndCache(const Coord& xyz, bool value, AccessorT&)
426 {
427 this->setValueOff(xyz, value);
428 }
429
433 template<typename ModifyOp, typename AccessorT>
434 void modifyValueAndCache(const Coord& xyz, const ModifyOp& op, AccessorT&)
435 {
436 this->modifyValue(xyz, op);
437 }
438
441 template<typename ModifyOp, typename AccessorT>
442 void modifyValueAndActiveStateAndCache(const Coord& xyz, const ModifyOp& op, AccessorT&)
443 {
444 this->modifyValueAndActiveState(xyz, op);
445 }
446
450 template<typename AccessorT>
451 void setActiveStateAndCache(const Coord& xyz, bool on, AccessorT&)
452 {
453 this->setActiveState(xyz, on);
454 }
455
459 template<typename AccessorT>
460 bool probeValueAndCache(const Coord& xyz, bool& val, AccessorT&) const
461 {
462 return this->probeValue(xyz, val);
463 }
464
467 template<typename AccessorT>
468 static Index getValueLevelAndCache(const Coord&, AccessorT&) { return LEVEL; }
469
473 const bool& getFirstValue() const { if (mValueMask.isOn(0)) return sOn; else return sOff; }
477 const bool& getLastValue() const { if (mValueMask.isOn(SIZE-1)) return sOn; else return sOff; }
478
482 bool isConstant(bool& constValue, bool& state, bool tolerance = 0) const;
484 bool isInactive() const { return mValueMask.isOff(); }
485
486 void resetBackground(bool oldBackground, bool newBackground);
487
488 void negate() { mBuffer.mData.toggle(); }
489
490 template<MergePolicy Policy>
491 void merge(const LeafNode& other, bool bg = false, bool otherBG = false);
492 template<MergePolicy Policy> void merge(bool tileValue, bool tileActive);
493
494 void voxelizeActiveTiles() {}
495
502 template<typename OtherType>
503 void topologyUnion(const LeafNode<OtherType, Log2Dim>& other);
504
516 template<typename OtherType>
517 void topologyIntersection(const LeafNode<OtherType, Log2Dim>& other, const bool&);
518
530 template<typename OtherType>
531 void topologyDifference(const LeafNode<OtherType, Log2Dim>& other, const bool&);
532
533 template<typename CombineOp>
534 void combine(const LeafNode& other, CombineOp& op);
535 template<typename CombineOp>
536 void combine(bool, bool valueIsActive, CombineOp& op);
537
538 template<typename CombineOp, typename OtherType /*= bool*/>
539 void combine2(const LeafNode& other, const OtherType&, bool valueIsActive, CombineOp&);
540 template<typename CombineOp, typename OtherNodeT /*= LeafNode*/>
541 void combine2(bool, const OtherNodeT& other, bool valueIsActive, CombineOp&);
542 template<typename CombineOp, typename OtherNodeT /*= LeafNode*/>
543 void combine2(const LeafNode& b0, const OtherNodeT& b1, CombineOp&);
544
549 template<typename BBoxOp> void visitActiveBBox(BBoxOp&) const;
550
551 template<typename VisitorOp> void visit(VisitorOp&);
552 template<typename VisitorOp> void visit(VisitorOp&) const;
553
554 template<typename OtherLeafNodeType, typename VisitorOp>
555 void visit2Node(OtherLeafNodeType& other, VisitorOp&);
556 template<typename OtherLeafNodeType, typename VisitorOp>
557 void visit2Node(OtherLeafNodeType& other, VisitorOp&) const;
558 template<typename IterT, typename VisitorOp>
559 void visit2(IterT& otherIter, VisitorOp&, bool otherIsLHS = false);
560 template<typename IterT, typename VisitorOp>
561 void visit2(IterT& otherIter, VisitorOp&, bool otherIsLHS = false) const;
562
564 void prune(const ValueType& /*tolerance*/ = zeroVal<ValueType>()) {}
566 void addLeaf(LeafNode*) {}
567 template<typename AccessorT>
568 void addLeafAndCache(LeafNode*, AccessorT&) {}
569 template<typename NodeT>
570 NodeT* stealNode(const Coord&, const ValueType&, bool) { return NULL; }
571 template<typename NodeT>
572 NodeT* probeNode(const Coord&) { return NULL; }
573 template<typename NodeT>
574 const NodeT* probeConstNode(const Coord&) const { return NULL; }
575 template<typename ArrayT> void getNodes(ArrayT&) const {}
576 template<typename ArrayT> void stealNodes(ArrayT&, const ValueType&, bool) {}
578
579 void addTile(Index level, const Coord&, bool val, bool active);
580 void addTile(Index offset, bool val, bool active);
581 template<typename AccessorT>
582 void addTileAndCache(Index level, const Coord&, bool val, bool active, AccessorT&);
583
585 LeafNode* touchLeaf(const Coord&) { return this; }
587 template<typename AccessorT>
588 LeafNode* touchLeafAndCache(const Coord&, AccessorT&) { return this; }
589 LeafNode* probeLeaf(const Coord&) { return this; }
590 template<typename AccessorT>
591 LeafNode* probeLeafAndCache(const Coord&, AccessorT&) { return this; }
592 template<typename NodeT, typename AccessorT>
593 NodeT* probeNodeAndCache(const Coord&, AccessorT&)
594 {
595 OPENVDB_NO_UNREACHABLE_CODE_WARNING_BEGIN
596 if (!(boost::is_same<NodeT,LeafNode>::value)) return NULL;
597 return reinterpret_cast<NodeT*>(this);
598 OPENVDB_NO_UNREACHABLE_CODE_WARNING_END
599 }
601
602 const LeafNode* probeLeaf(const Coord&) const { return this; }
604 template<typename AccessorT>
605 const LeafNode* probeLeafAndCache(const Coord&, AccessorT&) const { return this; }
606 const LeafNode* probeConstLeaf(const Coord&) const { return this; }
607 template<typename AccessorT>
608 const LeafNode* probeConstLeafAndCache(const Coord&, AccessorT&) const { return this; }
609 template<typename NodeT, typename AccessorT>
610 const NodeT* probeConstNodeAndCache(const Coord&, AccessorT&) const
611 {
612 OPENVDB_NO_UNREACHABLE_CODE_WARNING_BEGIN
613 if (!(boost::is_same<NodeT,LeafNode>::value)) return NULL;
614 return reinterpret_cast<const NodeT*>(this);
615 OPENVDB_NO_UNREACHABLE_CODE_WARNING_END
616 }
618
619 //
620 // Iterators
621 //
622 protected:
623 typedef typename NodeMaskType::OnIterator MaskOnIter;
624 typedef typename NodeMaskType::OffIterator MaskOffIter;
625 typedef typename NodeMaskType::DenseIterator MaskDenseIter;
626
627 template<typename MaskIterT, typename NodeT, typename ValueT>
628 struct ValueIter:
629 // Derives from SparseIteratorBase, but can also be used as a dense iterator,
630 // if MaskIterT is a dense mask iterator type.
631 public SparseIteratorBase<MaskIterT, ValueIter<MaskIterT, NodeT, ValueT>, NodeT, ValueT>
632 {
633 typedef SparseIteratorBase<MaskIterT, ValueIter, NodeT, ValueT> BaseT;
634
635 ValueIter() {}
636 ValueIter(const MaskIterT& iter, NodeT* parent): BaseT(iter, parent) {}
637
638 const bool& getItem(Index pos) const { return this->parent().getValue(pos); }
639 const bool& getValue() const { return this->getItem(this->pos()); }
640
641 // Note: setItem() can't be called on const iterators.
642 void setItem(Index pos, bool value) const { this->parent().setValueOnly(pos, value); }
643 // Note: setValue() can't be called on const iterators.
644 void setValue(bool value) const { this->setItem(this->pos(), value); }
645
646 // Note: modifyItem() can't be called on const iterators.
647 template<typename ModifyOp>
648 void modifyItem(Index n, const ModifyOp& op) const { this->parent().modifyValue(n, op); }
649 // Note: modifyValue() can't be called on const iterators.
650 template<typename ModifyOp>
651 void modifyValue(const ModifyOp& op) const { this->modifyItem(this->pos(), op); }
652 };
653
655 template<typename MaskIterT, typename NodeT>
656 struct ChildIter:
657 public SparseIteratorBase<MaskIterT, ChildIter<MaskIterT, NodeT>, NodeT, bool>
658 {
659 ChildIter() {}
660 ChildIter(const MaskIterT& iter, NodeT* parent): SparseIteratorBase<
661 MaskIterT, ChildIter<MaskIterT, NodeT>, NodeT, bool>(iter, parent) {}
662 };
663
664 template<typename NodeT, typename ValueT>
665 struct DenseIter: public DenseIteratorBase<
666 MaskDenseIter, DenseIter<NodeT, ValueT>, NodeT, /*ChildT=*/void, ValueT>
667 {
668 typedef DenseIteratorBase<MaskDenseIter, DenseIter, NodeT, void, ValueT> BaseT;
669 typedef typename BaseT::NonConstValueType NonConstValueT;
670
671 DenseIter() {}
672 DenseIter(const MaskDenseIter& iter, NodeT* parent): BaseT(iter, parent) {}
673
674 bool getItem(Index pos, void*& child, NonConstValueT& value) const
675 {
676 value = this->parent().getValue(pos);
677 child = NULL;
678 return false; // no child
679 }
680
681 // Note: setItem() can't be called on const iterators.
682 //void setItem(Index pos, void* child) const {}
683
684 // Note: unsetItem() can't be called on const iterators.
685 void unsetItem(Index pos, const ValueT& val) const {this->parent().setValueOnly(pos, val);}
686 };
687
688 public:
689 typedef ValueIter<MaskOnIter, LeafNode, const bool> ValueOnIter;
690 typedef ValueIter<MaskOnIter, const LeafNode, const bool> ValueOnCIter;
691 typedef ValueIter<MaskOffIter, LeafNode, const bool> ValueOffIter;
692 typedef ValueIter<MaskOffIter, const LeafNode, const bool> ValueOffCIter;
693 typedef ValueIter<MaskDenseIter, LeafNode, const bool> ValueAllIter;
694 typedef ValueIter<MaskDenseIter, const LeafNode, const bool> ValueAllCIter;
695 typedef ChildIter<MaskOnIter, LeafNode> ChildOnIter;
696 typedef ChildIter<MaskOnIter, const LeafNode> ChildOnCIter;
697 typedef ChildIter<MaskOffIter, LeafNode> ChildOffIter;
698 typedef ChildIter<MaskOffIter, const LeafNode> ChildOffCIter;
699 typedef DenseIter<LeafNode, bool> ChildAllIter;
700 typedef DenseIter<const LeafNode, const bool> ChildAllCIter;
701
702 ValueOnCIter cbeginValueOn() const { return ValueOnCIter(mValueMask.beginOn(), this); }
703 ValueOnCIter beginValueOn() const { return ValueOnCIter(mValueMask.beginOn(), this); }
704 ValueOnIter beginValueOn() { return ValueOnIter(mValueMask.beginOn(), this); }
705 ValueOffCIter cbeginValueOff() const { return ValueOffCIter(mValueMask.beginOff(), this); }
706 ValueOffCIter beginValueOff() const { return ValueOffCIter(mValueMask.beginOff(), this); }
707 ValueOffIter beginValueOff() { return ValueOffIter(mValueMask.beginOff(), this); }
708 ValueAllCIter cbeginValueAll() const { return ValueAllCIter(mValueMask.beginDense(), this); }
709 ValueAllCIter beginValueAll() const { return ValueAllCIter(mValueMask.beginDense(), this); }
710 ValueAllIter beginValueAll() { return ValueAllIter(mValueMask.beginDense(), this); }
711
712 ValueOnCIter cendValueOn() const { return ValueOnCIter(mValueMask.endOn(), this); }
713 ValueOnCIter endValueOn() const { return ValueOnCIter(mValueMask.endOn(), this); }
714 ValueOnIter endValueOn() { return ValueOnIter(mValueMask.endOn(), this); }
715 ValueOffCIter cendValueOff() const { return ValueOffCIter(mValueMask.endOff(), this); }
716 ValueOffCIter endValueOff() const { return ValueOffCIter(mValueMask.endOff(), this); }
717 ValueOffIter endValueOff() { return ValueOffIter(mValueMask.endOff(), this); }
718 ValueAllCIter cendValueAll() const { return ValueAllCIter(mValueMask.endDense(), this); }
719 ValueAllCIter endValueAll() const { return ValueAllCIter(mValueMask.endDense(), this); }
720 ValueAllIter endValueAll() { return ValueAllIter(mValueMask.endDense(), this); }
721
722 // Note that [c]beginChildOn() and [c]beginChildOff() actually return end iterators,
723 // because leaf nodes have no children.
724 ChildOnCIter cbeginChildOn() const { return ChildOnCIter(mValueMask.endOn(), this); }
725 ChildOnCIter beginChildOn() const { return ChildOnCIter(mValueMask.endOn(), this); }
726 ChildOnIter beginChildOn() { return ChildOnIter(mValueMask.endOn(), this); }
727 ChildOffCIter cbeginChildOff() const { return ChildOffCIter(mValueMask.endOff(), this); }
728 ChildOffCIter beginChildOff() const { return ChildOffCIter(mValueMask.endOff(), this); }
729 ChildOffIter beginChildOff() { return ChildOffIter(mValueMask.endOff(), this); }
730 ChildAllCIter cbeginChildAll() const { return ChildAllCIter(mValueMask.beginDense(), this); }
731 ChildAllCIter beginChildAll() const { return ChildAllCIter(mValueMask.beginDense(), this); }
732 ChildAllIter beginChildAll() { return ChildAllIter(mValueMask.beginDense(), this); }
733
734 ChildOnCIter cendChildOn() const { return ChildOnCIter(mValueMask.endOn(), this); }
735 ChildOnCIter endChildOn() const { return ChildOnCIter(mValueMask.endOn(), this); }
736 ChildOnIter endChildOn() { return ChildOnIter(mValueMask.endOn(), this); }
737 ChildOffCIter cendChildOff() const { return ChildOffCIter(mValueMask.endOff(), this); }
738 ChildOffCIter endChildOff() const { return ChildOffCIter(mValueMask.endOff(), this); }
739 ChildOffIter endChildOff() { return ChildOffIter(mValueMask.endOff(), this); }
740 ChildAllCIter cendChildAll() const { return ChildAllCIter(mValueMask.endDense(), this); }
741 ChildAllCIter endChildAll() const { return ChildAllCIter(mValueMask.endDense(), this); }
742 ChildAllIter endChildAll() { return ChildAllIter(mValueMask.endDense(), this); }
743
744 //
745 // Mask accessors
746 //
747 bool isValueMaskOn(Index n) const { return mValueMask.isOn(n); }
748 bool isValueMaskOn() const { return mValueMask.isOn(); }
749 bool isValueMaskOff(Index n) const { return mValueMask.isOff(n); }
750 bool isValueMaskOff() const { return mValueMask.isOff(); }
751 const NodeMaskType& getValueMask() const { return mValueMask; }
752 NodeMaskType& getValueMask() { return mValueMask; }
753 void setValueMask(const NodeMaskType& mask) { mValueMask = mask; }
754 bool isChildMaskOn(Index) const { return false; } // leaf nodes have no children
755 bool isChildMaskOff(Index) const { return true; }
756 bool isChildMaskOff() const { return true; }
757 protected:
758 void setValueMask(Index n, bool on) { mValueMask.set(n, on); }
759 void setValueMaskOn(Index n) { mValueMask.setOn(n); }
760 void setValueMaskOff(Index n) { mValueMask.setOff(n); }
761
763 static void evalNodeOrigin(Coord& xyz) { xyz &= ~(DIM - 1); }
764
765 template<typename NodeT, typename VisitorOp, typename ChildAllIterT>
766 static inline void doVisit(NodeT&, VisitorOp&);
767
768 template<typename NodeT, typename OtherNodeT, typename VisitorOp,
769 typename ChildAllIterT, typename OtherChildAllIterT>
770 static inline void doVisit2Node(NodeT& self, OtherNodeT& other, VisitorOp&);
771
772 template<typename NodeT, typename VisitorOp,
773 typename ChildAllIterT, typename OtherChildAllIterT>
774 static inline void doVisit2(NodeT& self, OtherChildAllIterT&, VisitorOp&, bool otherIsLHS);
775
776
778 NodeMaskType mValueMask;
780 Buffer mBuffer;
782 Coord mOrigin;
783
784 // These static declarations must be on separate lines to avoid VC9 compiler errors.
785 static const bool sOn;
786 static const bool sOff;
787
788 private:
791 template<typename, Index> friend class LeafNode;
792
793 friend struct ValueIter<MaskOnIter, LeafNode, bool>;
794 friend struct ValueIter<MaskOffIter, LeafNode, bool>;
795 friend struct ValueIter<MaskDenseIter, LeafNode, bool>;
796 friend struct ValueIter<MaskOnIter, const LeafNode, bool>;
797 friend struct ValueIter<MaskOffIter, const LeafNode, bool>;
798 friend struct ValueIter<MaskDenseIter, const LeafNode, bool>;
799
801 friend class IteratorBase<MaskOnIter, LeafNode>;
804 friend class IteratorBase<MaskOffIter, LeafNode>;
805 friend class IteratorBase<MaskDenseIter, LeafNode>;
807
808 }; // class LeafNode<bool>
809
810
815 template<Index Log2Dim> const bool LeafNode<bool, Log2Dim>::sOn = true;
816 template<Index Log2Dim> const bool LeafNode<bool, Log2Dim>::sOff = false;
817
818
820
821
822 template<Index Log2Dim>
823 inline
824 LeafNode<bool, Log2Dim>::LeafNode(): mOrigin(0, 0, 0)
825 {
826 }
827
828
829 template<Index Log2Dim>
830 inline
831 LeafNode<bool, Log2Dim>::LeafNode(const Coord& xyz, bool value, bool active):
832 mValueMask(active),
833 mBuffer(value),
834 mOrigin(xyz & (~(DIM - 1)))
835 {
836 }
837
838
839 #ifndef OPENVDB_2_ABI_COMPATIBLE
840 template<Index Log2Dim>
841 inline
842 LeafNode<bool, Log2Dim>::LeafNode(PartialCreate, const Coord& xyz, bool value, bool active):
843 mValueMask(active),
844 mBuffer(value),
845 mOrigin(xyz & (~(DIM - 1)))
846 {
850 }
851 #endif
852
853
854 template<Index Log2Dim>
855 inline
856 LeafNode<bool, Log2Dim>::LeafNode(const LeafNode &other):
857 mValueMask(other.mValueMask),
858 mBuffer(other.mBuffer),
859 mOrigin(other.mOrigin)
860 {
861 }
862
863
864 // Copy-construct from a leaf node with the same configuration but a different ValueType.
865 template<Index Log2Dim>
866 template<typename ValueT>
867 inline
868 LeafNode<bool, Log2Dim>::LeafNode(const LeafNode<ValueT, Log2Dim>& other):
869 mValueMask(other.getValueMask()),
870 mOrigin(other.origin())
871 {
872 struct Local {
874 static inline bool convertValue(const ValueT& val) { return bool(val); }
875 };
876
877 for (Index i = 0; i < SIZE; ++i) {
878 mBuffer.setValue(i, Local::convertValue(other.mBuffer[i]));
879 }
880 }
881
882
883 template<Index Log2Dim>
884 template<typename ValueT>
885 inline
886 LeafNode<bool, Log2Dim>::LeafNode(const LeafNode<ValueT, Log2Dim>& other,
887 bool background, TopologyCopy):
888 mValueMask(other.getValueMask()),
889 mBuffer(background),
890 mOrigin(other.origin())
891 {
892 }
893
894
895 template<Index Log2Dim>
896 template<typename ValueT>
897 inline
898 LeafNode<bool, Log2Dim>::LeafNode(const LeafNode<ValueT, Log2Dim>& other, TopologyCopy):
899 mValueMask(other.getValueMask()),
900 mBuffer(other.getValueMask()), // value = active state
901 mOrigin(other.origin())
902 {
903 }
904
905
906 template<Index Log2Dim>
907 template<typename ValueT>
908 inline
909 LeafNode<bool, Log2Dim>::LeafNode(const LeafNode<ValueT, Log2Dim>& other,
910 bool offValue, bool onValue, TopologyCopy):
911 mValueMask(other.getValueMask()),
912 mBuffer(other.getValueMask()),
913 mOrigin(other.origin())
914 {
915 if (offValue) { if (!onValue) mBuffer.mData.toggle(); else mBuffer.mData.setOn(); }
916 }
917
918
919 template<Index Log2Dim>
920 inline
921 LeafNode<bool, Log2Dim>::~LeafNode()
922 {
923 }
924
925
927
928
929 template<Index Log2Dim>
930 inline Index64
931 LeafNode<bool, Log2Dim>::memUsage() const
932 {
933 return sizeof(mOrigin) + mValueMask.memUsage() + mBuffer.memUsage();
934 }
935
936
937 template<Index Log2Dim>
938 inline void
939 LeafNode<bool, Log2Dim>::evalActiveBoundingBox(CoordBBox& bbox, bool visitVoxels) const
940 {
941 CoordBBox this_bbox = this->getNodeBoundingBox();
942 if (bbox.isInside(this_bbox)) return;//this LeafNode is already enclosed in the bbox
943 if (ValueOnCIter iter = this->cbeginValueOn()) {//any active values?
944 if (visitVoxels) {//use voxel granularity?
945 this_bbox.reset();
946 for(; iter; ++iter) this_bbox.expand(this->offsetToLocalCoord(iter.pos()));
947 this_bbox.translate(this->origin());
948 }
949 bbox.expand(this_bbox);
950 }
951 }
952
953
954 template<Index Log2Dim>
955 template<typename OtherType, Index OtherLog2Dim>
956 inline bool
957 LeafNode<bool, Log2Dim>::hasSameTopology(const LeafNode<OtherType, OtherLog2Dim>* other) const
958 {
959 assert(other);
960 return (Log2Dim == OtherLog2Dim && mValueMask == other->getValueMask());
961 }
962
963
964 template<Index Log2Dim>
965 inline std::string
966 LeafNode<bool, Log2Dim>::str() const
967 {
968 std::ostringstream ostr;
969 ostr << "LeafNode @" << mOrigin << ": ";
970 for (Index32 n = 0; n < SIZE; ++n) ostr << (mValueMask.isOn(n) ? '#' : '.');
971 return ostr.str();
972 }
973
974
976
977
978 template<Index Log2Dim>
979 inline Index
980 LeafNode<bool, Log2Dim>::coordToOffset(const Coord& xyz)
981 {
982 assert ((xyz[0] & (DIM-1u)) < DIM && (xyz[1] & (DIM-1u)) < DIM && (xyz[2] & (DIM-1u)) < DIM);
983 return ((xyz[0] & (DIM-1u)) << 2*Log2Dim)
984 + ((xyz[1] & (DIM-1u)) << Log2Dim)
985 + (xyz[2] & (DIM-1u));
986 }
987
988
989 template<Index Log2Dim>
990 inline Coord
991 LeafNode<bool, Log2Dim>::offsetToLocalCoord(Index n)
992 {
993 assert(n < (1 << 3*Log2Dim));
994 Coord xyz;
995 xyz.setX(n >> 2*Log2Dim);
996 n &= ((1 << 2*Log2Dim) - 1);
997 xyz.setY(n >> Log2Dim);
998 xyz.setZ(n & ((1 << Log2Dim) - 1));
999 return xyz;
1000 }
1001
1002
1003 template<Index Log2Dim>
1004 inline Coord
1005 LeafNode<bool, Log2Dim>::offsetToGlobalCoord(Index n) const
1006 {
1007 return (this->offsetToLocalCoord(n) + this->origin());
1008 }
1009
1010
1012
1013
1014 template<Index Log2Dim>
1015 inline void
1016 LeafNode<bool, Log2Dim>::readTopology(std::istream& is, bool /*fromHalf*/)
1017 {
1018 mValueMask.load(is);
1019 }
1020
1021
1022 template<Index Log2Dim>
1023 inline void
1024 LeafNode<bool, Log2Dim>::writeTopology(std::ostream& os, bool /*toHalf*/) const
1025 {
1026 mValueMask.save(os);
1027 }
1028
1029
1030 template<Index Log2Dim>
1031 inline void
1032 LeafNode<bool, Log2Dim>::readBuffers(std::istream& is, const CoordBBox& clipBBox, bool fromHalf)
1033 {
1034 // Boolean LeafNodes don't currently implement lazy loading.
1035 // Instead, load the full buffer, then clip it.
1036
1037 this->readBuffers(is, fromHalf);
1038
1039 // Get this tree's background value.
1040 bool background = false;
1041 if (const void* bgPtr = io::getGridBackgroundValuePtr(is)) {
1042 background = *static_cast<const bool*>(bgPtr);
1043 }
1044 this->clip(clipBBox, background);
1045 }
1046
1047
1048 template<Index Log2Dim>
1049 inline void
1050 LeafNode<bool, Log2Dim>::readBuffers(std::istream& is, bool /*fromHalf*/)
1051 {
1052 // Read in the value mask.
1053 mValueMask.load(is);
1054 // Read in the origin.
1055 is.read(reinterpret_cast<char*>(&mOrigin), sizeof(Coord::ValueType) * 3);
1056
1057 if (io::getFormatVersion(is) >= OPENVDB_FILE_VERSION_BOOL_LEAF_OPTIMIZATION) {
1058 // Read in the mask for the voxel values.
1059 mBuffer.mData.load(is);
1060 } else {
1061 // Older files stored one or more bool arrays.
1062
1063 // Read in the number of buffers, which should now always be one.
1064 int8_t numBuffers = 0;
1065 is.read(reinterpret_cast<char*>(&numBuffers), sizeof(int8_t));
1066
1067 // Read in the buffer.
1068 // (Note: prior to the bool leaf optimization, buffers were always compressed.)
1069 boost::shared_array<bool> buf(new bool[SIZE]);
1070 io::readData<bool>(is, buf.get(), SIZE, /*isCompressed=*/true);
1071
1072 // Transfer values to mBuffer.
1073 mBuffer.mData.setOff();
1074 for (Index i = 0; i < SIZE; ++i) {
1075 if (buf[i]) mBuffer.mData.setOn(i);
1076 }
1077
1078 if (numBuffers > 1) {
1079 // Read in and discard auxiliary buffers that were created with
1080 // earlier versions of the library.
1081 for (int i = 1; i < numBuffers; ++i) {
1082 io::readData<bool>(is, buf.get(), SIZE, /*isCompressed=*/true);
1083 }
1084 }
1085 }
1086 }
1087
1088
1089 template<Index Log2Dim>
1090 inline void
1091 LeafNode<bool, Log2Dim>::writeBuffers(std::ostream& os, bool /*toHalf*/) const
1092 {
1093 // Write out the value mask.
1094 mValueMask.save(os);
1095 // Write out the origin.
1096 os.write(reinterpret_cast<const char*>(&mOrigin), sizeof(Coord::ValueType) * 3);
1097 // Write out the voxel values.
1098 mBuffer.mData.save(os);
1099 }
1100
1101
1103
1104
1105 template<Index Log2Dim>
1106 inline bool
1107 LeafNode<bool, Log2Dim>::operator==(const LeafNode& other) const
1108 {
1109 return (mValueMask == other.mValueMask && mBuffer.mData == other.mBuffer.mData);
1110 }
1111
1112
1113 template<Index Log2Dim>
1114 inline bool
1115 LeafNode<bool, Log2Dim>::operator!=(const LeafNode& other) const
1116 {
1117 return !(this->operator==(other));
1118 }
1119
1120
1122
1123
1124 template<Index Log2Dim>
1125 inline bool
1126 LeafNode<bool, Log2Dim>::isConstant(bool& constValue, bool& state, bool tolerance) const
1127 {
1128 state = mValueMask.isOn();
1129
1130 if (!(state || mValueMask.isOff())) return false;
1131
1132 // Note: if tolerance is true (i.e., 1), then all boolean values compare equal.
1133 if (!tolerance && !(mBuffer.mData.isOn() || mBuffer.mData.isOff())) return false;
1134
1135 state = mValueMask.isOn();
1136 constValue = mBuffer.mData.isOn();
1137 return true;
1138 }
1139
1140
1142
1143
1144 template<Index Log2Dim>
1145 inline void
1146 LeafNode<bool, Log2Dim>::addTile(Index /*level*/, const Coord& xyz, bool val, bool active)
1147 {
1148 this->addTile(this->coordToOffset(xyz), val, active);
1149 }
1150
1151 template<Index Log2Dim>
1152 inline void
1153 LeafNode<bool, Log2Dim>::addTile(Index offset, bool val, bool active)
1154 {
1155 assert(offset < SIZE);
1156 setValueOnly(offset, val);
1157 setActiveState(offset, active);
1158 }
1159
1160 template<Index Log2Dim>
1161 template<typename AccessorT>
1162 inline void
1163 LeafNode<bool, Log2Dim>::addTileAndCache(Index level, const Coord& xyz,
1164 bool val, bool active, AccessorT&)
1165 {
1166 this->addTile(level, xyz, val, active);
1167 }
1168
1169
1171
1172
1173 template<Index Log2Dim>
1174 inline const bool&
1175 LeafNode<bool, Log2Dim>::getValue(const Coord& xyz) const
1176 {
1177 // This *CANNOT* use operator ? because Visual C++
1178 if (mBuffer.mData.isOn(this->coordToOffset(xyz))) return sOn; else return sOff;
1179 }
1180
1181
1182 template<Index Log2Dim>
1183 inline const bool&
1184 LeafNode<bool, Log2Dim>::getValue(Index offset) const
1185 {
1186 assert(offset < SIZE);
1187 // This *CANNOT* use operator ? for Windows
1188 if (mBuffer.mData.isOn(offset)) return sOn; else return sOff;
1189 }
1190
1191
1192 template<Index Log2Dim>
1193 inline bool
1194 LeafNode<bool, Log2Dim>::probeValue(const Coord& xyz, bool& val) const
1195 {
1196 const Index offset = this->coordToOffset(xyz);
1197 val = mBuffer.mData.isOn(offset);
1198 return mValueMask.isOn(offset);
1199 }
1200
1201
1202 template<Index Log2Dim>
1203 inline void
1204 LeafNode<bool, Log2Dim>::setValueOn(const Coord& xyz, bool val)
1205 {
1206 this->setValueOn(this->coordToOffset(xyz), val);
1207 }
1208
1209
1210 template<Index Log2Dim>
1211 inline void
1212 LeafNode<bool, Log2Dim>::setValueOn(Index offset, bool val)
1213 {
1214 assert(offset < SIZE);
1215 mValueMask.setOn(offset);
1216 mBuffer.mData.set(offset, val);
1217 }
1218
1219
1220 template<Index Log2Dim>
1221 inline void
1222 LeafNode<bool, Log2Dim>::setValueOnly(const Coord& xyz, bool val)
1223 {
1224 this->setValueOnly(this->coordToOffset(xyz), val);
1225 }
1226
1227
1228 template<Index Log2Dim>
1229 inline void
1230 LeafNode<bool, Log2Dim>::setActiveState(const Coord& xyz, bool on)
1231 {
1232 mValueMask.set(this->coordToOffset(xyz), on);
1233 }
1234
1235
1236 template<Index Log2Dim>
1237 inline void
1238 LeafNode<bool, Log2Dim>::setValueOff(const Coord& xyz, bool val)
1239 {
1240 this->setValueOff(this->coordToOffset(xyz), val);
1241 }
1242
1243
1244 template<Index Log2Dim>
1245 inline void
1246 LeafNode<bool, Log2Dim>::setValueOff(Index offset, bool val)
1247 {
1248 assert(offset < SIZE);
1249 mValueMask.setOff(offset);
1250 mBuffer.mData.set(offset, val);
1251 }
1252
1253
1254 template<Index Log2Dim>
1255 template<typename ModifyOp>
1256 inline void
1257 LeafNode<bool, Log2Dim>::modifyValue(Index offset, const ModifyOp& op)
1258 {
1259 bool val = mBuffer.mData.isOn(offset);
1260 op(val);
1261 mBuffer.mData.set(offset, val);
1262 mValueMask.setOn(offset);
1263 }
1264
1265
1266 template<Index Log2Dim>
1267 template<typename ModifyOp>
1268 inline void
1269 LeafNode<bool, Log2Dim>::modifyValue(const Coord& xyz, const ModifyOp& op)
1270 {
1271 this->modifyValue(this->coordToOffset(xyz), op);
1272 }
1273
1274
1275 template<Index Log2Dim>
1276 template<typename ModifyOp>
1277 inline void
1278 LeafNode<bool, Log2Dim>::modifyValueAndActiveState(const Coord& xyz, const ModifyOp& op)
1279 {
1280 const Index offset = this->coordToOffset(xyz);
1281 bool val = mBuffer.mData.isOn(offset), state = mValueMask.isOn(offset);
1282 op(val, state);
1283 mBuffer.mData.set(offset, val);
1284 mValueMask.set(offset, state);
1285 }
1286
1287
1289
1290
1291 template<Index Log2Dim>
1292 inline void
1293 LeafNode<bool, Log2Dim>::resetBackground(bool oldBackground, bool newBackground)
1294 {
1295 if (newBackground != oldBackground) {
1296 // Flip mBuffer's background bits and zero its foreground bits.
1297 NodeMaskType bgMask = !(mBuffer.mData | mValueMask);
1298 // Overwrite mBuffer's background bits, leaving its foreground bits intact.
1299 mBuffer.mData = (mBuffer.mData & mValueMask) | bgMask;
1300 }
1301 }
1302
1303
1305
1306
1307 template<Index Log2Dim>
1308 template<MergePolicy Policy>
1309 inline void
1310 LeafNode<bool, Log2Dim>::merge(const LeafNode& other, bool /*bg*/, bool /*otherBG*/)
1311 {
1312 OPENVDB_NO_UNREACHABLE_CODE_WARNING_BEGIN
1313 if (Policy == MERGE_NODES) return;
1314 for (typename NodeMaskType::OnIterator iter = other.mValueMask.beginOn(); iter; ++iter) {
1315 const Index n = iter.pos();
1316 if (mValueMask.isOff(n)) {
1317 mBuffer.mData.set(n, other.mBuffer.mData.isOn(n));
1318 mValueMask.setOn(n);
1319 }
1320 }
1321 OPENVDB_NO_UNREACHABLE_CODE_WARNING_END
1322 }
1323
1324 template<Index Log2Dim>
1325 template<MergePolicy Policy>
1326 inline void
1327 LeafNode<bool, Log2Dim>::merge(bool tileValue, bool tileActive)
1328 {
1329 OPENVDB_NO_UNREACHABLE_CODE_WARNING_BEGIN
1330 if (Policy != MERGE_ACTIVE_STATES_AND_NODES) return;
1331 if (!tileActive) return;
1332 // Replace all inactive values with the active tile value.
1333 if (tileValue) mBuffer.mData |= !mValueMask; // -0=>1, +0=>0, -1=>1, +1=>1 (-,+ = off,on)
1334 else mBuffer.mData &= mValueMask; // -0=>0, +0=>0, -1=>0, +1=>1
1335 mValueMask.setOn();
1336 OPENVDB_NO_UNREACHABLE_CODE_WARNING_END
1337 }
1338
1339
1341
1342
1343 template<Index Log2Dim>
1344 template<typename OtherType>
1345 inline void
1346 LeafNode<bool, Log2Dim>::topologyUnion(const LeafNode<OtherType, Log2Dim>& other)
1347 {
1348 mValueMask |= other.getValueMask();
1349 }
1350
1351
1352 template<Index Log2Dim>
1353 template<typename OtherType>
1354 inline void
1355 LeafNode<bool, Log2Dim>::topologyIntersection(const LeafNode<OtherType, Log2Dim>& other,
1356 const bool&)
1357 {
1358 mValueMask &= other.getValueMask();
1359 }
1360
1361
1362 template<Index Log2Dim>
1363 template<typename OtherType>
1364 inline void
1365 LeafNode<bool, Log2Dim>::topologyDifference(const LeafNode<OtherType, Log2Dim>& other,
1366 const bool&)
1367 {
1368 mValueMask &= !other.getValueMask();
1369 }
1370
1371
1373
1374
1375 template<Index Log2Dim>
1376 inline void
1377 LeafNode<bool, Log2Dim>::clip(const CoordBBox& clipBBox, bool background)
1378 {
1379 CoordBBox nodeBBox = this->getNodeBoundingBox();
1380 if (!clipBBox.hasOverlap(nodeBBox)) {
1381 // This node lies completely outside the clipping region. Fill it with background tiles.
1382 this->fill(nodeBBox, background, /*active=*/false);
1383 } else if (clipBBox.isInside(nodeBBox)) {
1384 // This node lies completely inside the clipping region. Leave it intact.
1385 return;
1386 }
1387
1388 // This node isn't completely contained inside the clipping region.
1389 // Set any voxels that lie outside the region to the background value.
1390
1391 // Construct a boolean mask that is on inside the clipping region and off outside it.
1392 NodeMaskType mask;
1393 nodeBBox.intersect(clipBBox);
1394 Coord xyz;
1395 int &x = xyz.x(), &y = xyz.y(), &z = xyz.z();
1396 for (x = nodeBBox.min().x(); x <= nodeBBox.max().x(); ++x) {
1397 for (y = nodeBBox.min().y(); y <= nodeBBox.max().y(); ++y) {
1398 for (z = nodeBBox.min().z(); z <= nodeBBox.max().z(); ++z) {
1399 mask.setOn(static_cast<Index32>(this->coordToOffset(xyz)));
1400 }
1401 }
1402 }
1403
1404 // Set voxels that lie in the inactive region of the mask (i.e., outside
1405 // the clipping region) to the background value.
1406 for (MaskOffIter maskIter = mask.beginOff(); maskIter; ++maskIter) {
1407 this->setValueOff(maskIter.pos(), background);
1408 }
1409 }
1410
1411
1413
1414
1415 template<Index Log2Dim>
1416 inline void
1417 LeafNode<bool, Log2Dim>::fill(const CoordBBox& bbox, bool value, bool active)
1418 {
1419 for (Int32 x = bbox.min().x(); x <= bbox.max().x(); ++x) {
1420 const Index offsetX = (x & (DIM-1u))<<2*Log2Dim;
1421 for (Int32 y = bbox.min().y(); y <= bbox.max().y(); ++y) {
1422 const Index offsetXY = offsetX + ((y & (DIM-1u))<< Log2Dim);
1423 for (Int32 z = bbox.min().z(); z <= bbox.max().z(); ++z) {
1424 const Index offset = offsetXY + (z & (DIM-1u));
1425 mValueMask.set(offset, active);
1426 mBuffer.mData.set(offset, value);
1427 }
1428 }
1429 }
1430 }
1431
1432 template<Index Log2Dim>
1433 inline void
1434 LeafNode<bool, Log2Dim>::fill(const bool& value)
1435 {
1436 mBuffer.fill(value);
1437 }
1438
1439 template<Index Log2Dim>
1440 inline void
1441 LeafNode<bool, Log2Dim>::fill(const bool& value, bool active)
1442 {
1443 mBuffer.fill(value);
1444 mValueMask.set(active);
1445 }
1446
1447
1449
1450
1451 template<Index Log2Dim>
1452 template<typename DenseT>
1453 inline void
1454 LeafNode<bool, Log2Dim>::copyToDense(const CoordBBox& bbox, DenseT& dense) const
1455 {
1456 typedef typename DenseT::ValueType DenseValueType;
1457
1458 const size_t xStride = dense.xStride(), yStride = dense.yStride(), zStride = dense.zStride();
1459 const Coord& min = dense.bbox().min();
1460 DenseValueType* t0 = dense.data() + zStride * (bbox.min()[2] - min[2]); // target array
1461 const Int32 n0 = bbox.min()[2] & (DIM-1u);
1462 for (Int32 x = bbox.min()[0], ex = bbox.max()[0] + 1; x < ex; ++x) {
1463 DenseValueType* t1 = t0 + xStride * (x - min[0]);
1464 const Int32 n1 = n0 + ((x & (DIM-1u)) << 2*LOG2DIM);
1465 for (Int32 y = bbox.min()[1], ey = bbox.max()[1] + 1; y < ey; ++y) {
1466 DenseValueType* t2 = t1 + yStride * (y - min[1]);
1467 Int32 n2 = n1 + ((y & (DIM-1u)) << LOG2DIM);
1468 for (Int32 z = bbox.min()[2], ez = bbox.max()[2] + 1; z < ez; ++z, t2 += zStride) {
1469 *t2 = DenseValueType(mBuffer.mData.isOn(n2++));
1470 }
1471 }
1472 }
1473 }
1474
1475
1476 template<Index Log2Dim>
1477 template<typename DenseT>
1478 inline void
1479 LeafNode<bool, Log2Dim>::copyFromDense(const CoordBBox& bbox, const DenseT& dense,
1480 bool background, bool tolerance)
1481 {
1482 typedef typename DenseT::ValueType DenseValueType;
1483 struct Local {
1484 inline static bool toBool(const DenseValueType& v) { return !math::isZero(v); }
1485 };
1486
1487 const size_t xStride = dense.xStride(), yStride = dense.yStride(), zStride = dense.zStride();
1488 const Coord& min = dense.bbox().min();
1489 const DenseValueType* s0 = dense.data() + zStride * (bbox.min()[2] - min[2]); // source
1490 const Int32 n0 = bbox.min()[2] & (DIM-1u);
1491 for (Int32 x = bbox.min()[0], ex = bbox.max()[0] + 1; x < ex; ++x) {
1492 const DenseValueType* s1 = s0 + xStride * (x - min[0]);
1493 const Int32 n1 = n0 + ((x & (DIM-1u)) << 2*LOG2DIM);
1494 for (Int32 y = bbox.min()[1], ey = bbox.max()[1] + 1; y < ey; ++y) {
1495 const DenseValueType* s2 = s1 + yStride * (y - min[1]);
1496 Int32 n2 = n1 + ((y & (DIM-1u)) << LOG2DIM);
1497 for (Int32 z = bbox.min()[2], ez = bbox.max()[2]+1; z < ez; ++z, ++n2, s2 += zStride) {
1498 // Note: if tolerance is true (i.e., 1), then all boolean values compare equal.
1499 if (tolerance || (background == Local::toBool(*s2))) {
1500 mValueMask.setOff(n2);
1501 mBuffer.mData.set(n2, background);
1502 } else {
1503 mValueMask.setOn(n2);
1504 mBuffer.mData.set(n2, Local::toBool(*s2));
1505 }
1506 }
1507 }
1508 }
1509 }
1510
1511
1513
1514
1515 template<Index Log2Dim>
1516 template<typename CombineOp>
1517 inline void
1518 LeafNode<bool, Log2Dim>::combine(const LeafNode& other, CombineOp& op)
1519 {
1520 CombineArgs<bool> args;
1521 for (Index i = 0; i < SIZE; ++i) {
1522 bool result = false, aVal = mBuffer.mData.isOn(i), bVal = other.mBuffer.mData.isOn(i);
1523 op(args.setARef(aVal)
1524 .setAIsActive(mValueMask.isOn(i))
1525 .setBRef(bVal)
1526 .setBIsActive(other.mValueMask.isOn(i))
1527 .setResultRef(result));
1528 mValueMask.set(i, args.resultIsActive());
1529 mBuffer.mData.set(i, result);
1530 }
1531 }
1532
1533
1534 template<Index Log2Dim>
1535 template<typename CombineOp>
1536 inline void
1537 LeafNode<bool, Log2Dim>::combine(bool value, bool valueIsActive, CombineOp& op)
1538 {
1539 CombineArgs<bool> args;
1540 args.setBRef(value).setBIsActive(valueIsActive);
1541 for (Index i = 0; i < SIZE; ++i) {
1542 bool result = false, aVal = mBuffer.mData.isOn(i);
1543 op(args.setARef(aVal)
1544 .setAIsActive(mValueMask.isOn(i))
1545 .setResultRef(result));
1546 mValueMask.set(i, args.resultIsActive());
1547 mBuffer.mData.set(i, result);
1548 }
1549 }
1550
1551
1553
1554
1555 template<Index Log2Dim>
1556 template<typename CombineOp, typename OtherType>
1557 inline void
1558 LeafNode<bool, Log2Dim>::combine2(const LeafNode& other, const OtherType& value,
1559 bool valueIsActive, CombineOp& op)
1560 {
1561 CombineArgs<bool, OtherType> args;
1562 args.setBRef(value).setBIsActive(valueIsActive);
1563 for (Index i = 0; i < SIZE; ++i) {
1564 bool result = false, aVal = other.mBuffer.mData.isOn(i);
1565 op(args.setARef(aVal)
1566 .setAIsActive(other.mValueMask.isOn(i))
1567 .setResultRef(result));
1568 mValueMask.set(i, args.resultIsActive());
1569 mBuffer.mData.set(i, result);
1570 }
1571 }
1572
1573
1574 template<Index Log2Dim>
1575 template<typename CombineOp, typename OtherNodeT>
1576 inline void
1577 LeafNode<bool, Log2Dim>::combine2(bool value, const OtherNodeT& other,
1578 bool valueIsActive, CombineOp& op)
1579 {
1580 CombineArgs<bool, typename OtherNodeT::ValueType> args;
1581 args.setARef(value).setAIsActive(valueIsActive);
1582 for (Index i = 0; i < SIZE; ++i) {
1583 bool result = false, bVal = other.mBuffer.mData.isOn(i);
1584 op(args.setBRef(bVal)
1585 .setBIsActive(other.mValueMask.isOn(i))
1586 .setResultRef(result));
1587 mValueMask.set(i, args.resultIsActive());
1588 mBuffer.mData.set(i, result);
1589 }
1590 }
1591
1592
1593 template<Index Log2Dim>
1594 template<typename CombineOp, typename OtherNodeT>
1595 inline void
1596 LeafNode<bool, Log2Dim>::combine2(const LeafNode& b0, const OtherNodeT& b1, CombineOp& op)
1597 {
1598 CombineArgs<bool, typename OtherNodeT::ValueType> args;
1599 for (Index i = 0; i < SIZE; ++i) {
1600 // Default behavior: output voxel is active if either input voxel is active.
1601 mValueMask.set(i, b0.mValueMask.isOn(i) || b1.mValueMask.isOn(i));
1602
1603 bool result = false, b0Val = b0.mBuffer.mData.isOn(i), b1Val = b1.mBuffer.mData.isOn(i);
1604 op(args.setARef(b0Val)
1605 .setAIsActive(b0.mValueMask.isOn(i))
1606 .setBRef(b1Val)
1607 .setBIsActive(b1.mValueMask.isOn(i))
1608 .setResultRef(result));
1609 mValueMask.set(i, args.resultIsActive());
1610 mBuffer.mData.set(i, result);
1611 }
1612 }
1613
1614
1616
1617 template<Index Log2Dim>
1618 template<typename BBoxOp>
1619 inline void
1620 LeafNode<bool, Log2Dim>::visitActiveBBox(BBoxOp& op) const
1621 {
1622 if (op.template descent<LEVEL>()) {
1623 for (ValueOnCIter i=this->cbeginValueOn(); i; ++i) {
1624 #ifdef _MSC_VER
1625 op.operator()<LEVEL>(CoordBBox::createCube(i.getCoord(), 1));
1626 #else
1627 op.template operator()<LEVEL>(CoordBBox::createCube(i.getCoord(), 1));
1628 #endif
1629 }
1630 } else {
1631 #ifdef _MSC_VER
1632 op.operator()<LEVEL>(this->getNodeBoundingBox());
1633 #else
1634 op.template operator()<LEVEL>(this->getNodeBoundingBox());
1635 #endif
1636 }
1637 }
1638
1639
1640 template<Index Log2Dim>
1641 template<typename VisitorOp>
1642 inline void
1643 LeafNode<bool, Log2Dim>::visit(VisitorOp& op)
1644 {
1645 doVisit<LeafNode, VisitorOp, ChildAllIter>(*this, op);
1646 }
1647
1648
1649 template<Index Log2Dim>
1650 template<typename VisitorOp>
1651 inline void
1652 LeafNode<bool, Log2Dim>::visit(VisitorOp& op) const
1653 {
1654 doVisit<const LeafNode, VisitorOp, ChildAllCIter>(*this, op);
1655 }
1656
1657
1658 template<Index Log2Dim>
1659 template<typename NodeT, typename VisitorOp, typename ChildAllIterT>
1660 inline void
1661 LeafNode<bool, Log2Dim>::doVisit(NodeT& self, VisitorOp& op)
1662 {
1663 for (ChildAllIterT iter = self.beginChildAll(); iter; ++iter) {
1664 op(iter);
1665 }
1666 }
1667
1668
1670
1671
1672 template<Index Log2Dim>
1673 template<typename OtherLeafNodeType, typename VisitorOp>
1674 inline void
1675 LeafNode<bool, Log2Dim>::visit2Node(OtherLeafNodeType& other, VisitorOp& op)
1676 {
1677 doVisit2Node<LeafNode, OtherLeafNodeType, VisitorOp, ChildAllIter,
1678 typename OtherLeafNodeType::ChildAllIter>(*this, other, op);
1679 }
1680
1681
1682 template<Index Log2Dim>
1683 template<typename OtherLeafNodeType, typename VisitorOp>
1684 inline void
1685 LeafNode<bool, Log2Dim>::visit2Node(OtherLeafNodeType& other, VisitorOp& op) const
1686 {
1687 doVisit2Node<const LeafNode, OtherLeafNodeType, VisitorOp, ChildAllCIter,
1688 typename OtherLeafNodeType::ChildAllCIter>(*this, other, op);
1689 }
1690
1691
1692 template<Index Log2Dim>
1693 template<
1694 typename NodeT,
1695 typename OtherNodeT,
1696 typename VisitorOp,
1697 typename ChildAllIterT,
1698 typename OtherChildAllIterT>
1699 inline void
1700 LeafNode<bool, Log2Dim>::doVisit2Node(NodeT& self, OtherNodeT& other, VisitorOp& op)
1701 {
1702 // Allow the two nodes to have different ValueTypes, but not different dimensions.
1703 BOOST_STATIC_ASSERT(OtherNodeT::SIZE == NodeT::SIZE);
1704 BOOST_STATIC_ASSERT(OtherNodeT::LEVEL == NodeT::LEVEL);
1705
1706 ChildAllIterT iter = self.beginChildAll();
1707 OtherChildAllIterT otherIter = other.beginChildAll();
1708
1709 for ( ; iter && otherIter; ++iter, ++otherIter) {
1710 op(iter, otherIter);
1711 }
1712 }
1713
1714
1716
1717
1718 template<Index Log2Dim>
1719 template<typename IterT, typename VisitorOp>
1720 inline void
1721 LeafNode<bool, Log2Dim>::visit2(IterT& otherIter, VisitorOp& op, bool otherIsLHS)
1722 {
1723 doVisit2<LeafNode, VisitorOp, ChildAllIter, IterT>(*this, otherIter, op, otherIsLHS);
1724 }
1725
1726
1727 template<Index Log2Dim>
1728 template<typename IterT, typename VisitorOp>
1729 inline void
1730 LeafNode<bool, Log2Dim>::visit2(IterT& otherIter, VisitorOp& op, bool otherIsLHS) const
1731 {
1732 doVisit2<const LeafNode, VisitorOp, ChildAllCIter, IterT>(*this, otherIter, op, otherIsLHS);
1733 }
1734
1735
1736 template<Index Log2Dim>
1737 template<
1738 typename NodeT,
1739 typename VisitorOp,
1740 typename ChildAllIterT,
1741 typename OtherChildAllIterT>
1742 inline void
1743 LeafNode<bool, Log2Dim>::doVisit2(NodeT& self, OtherChildAllIterT& otherIter,
1744 VisitorOp& op, bool otherIsLHS)
1745 {
1746 if (!otherIter) return;
1747
1748 if (otherIsLHS) {
1749 for (ChildAllIterT iter = self.beginChildAll(); iter; ++iter) {
1750 op(otherIter, iter);
1751 }
1752 } else {
1753 for (ChildAllIterT iter = self.beginChildAll(); iter; ++iter) {
1754 op(iter, otherIter);
1755 }
1756 }
1757 }
1758
1759 } // namespace tree
1760 } // namespace OPENVDB_VERSION_NAME
1761 } // namespace openvdb
1762
1763 #endif // OPENVDB_TREE_LEAFNODEBOOL_HAS_BEEN_INCLUDED
1764
1765 // Copyright (c) 2012-2015 DreamWorks Animation LLC
1766 // All rights reserved. This software is distributed under the
1767 // Mozilla Public License 2.0 ( http://www.mozilla.org/MPL/2.0/ )
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::DenseIter::getItem
bool getItem(Index pos, void *&child, NonConstValueT &value) const
Definition: LeafNodeBool.h:674
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::modifyValueAndActiveStateAndCache
void modifyValueAndActiveStateAndCache(const Coord &xyz, const ModifyOp &op, AccessorT &)
Definition: LeafNodeBool.h:442
openvdb::v3_1_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:1422
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::cendChildOn
ChildOnCIter cendChildOn() const
Definition: LeafNodeBool.h:734
openvdb::v3_1_0::tree::LeafNode< bool, 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: LeafNodeBool.h:420
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::addLeafAndCache
void addLeafAndCache(LeafNode *, AccessorT &)
This function exists only to enable template instantiation.
Definition: LeafNodeBool.h:568
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::endValueOn
ValueOnCIter endValueOn() const
Definition: LeafNodeBool.h:713
openvdb::v3_1_0::tree::LeafNode::writeBuffers
void writeBuffers(std::ostream &os, bool toHalf=false) const
Write buffers to a stream.
Definition: LeafNode.h:1685
openvdb::v3_1_0::util::NodeMask::load
void load(std::istream &is)
Definition: NodeMasks.h:555
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::getValueAndCache
const bool & getValueAndCache(const Coord &xyz, AccessorT &) const
Return the value of the voxel at the given coordinates.
Definition: LeafNodeBool.h:404
openvdb::v3_1_0::Index
Index32 Index
Definition: Types.h:58
openvdb::v3_1_0::tree::LeafNode< bool, 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: LeafNodeBool.h:302
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::ValueIter::getItem
const bool & getItem(Index pos) const
Definition: LeafNodeBool.h:638
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::isChildMaskOn
bool isChildMaskOn(Index) const
Definition: LeafNodeBool.h:754
openvdb::v3_1_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:1271
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::ValueIter::setItem
void setItem(Index pos, bool value) const
Definition: LeafNodeBool.h:642
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::dim
static Index dim()
Return the number of voxels in each dimension.
Definition: LeafNodeBool.h:184
openvdb::v3_1_0::tree::LeafNode::getValueMask
const NodeMaskType & getValueMask() const
Definition: LeafNode.h:1105
openvdb::v3_1_0::CombineArgs::setBRef
CombineArgs & setBRef(const BValueType &b)
Redirect the B value to a new external source.
Definition: Types.h:344
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::beginValueOn
ValueOnCIter beginValueOn() const
Definition: LeafNodeBool.h:703
Types.h
openvdb::v3_1_0::tree::LeafNode::offsetToGlobalCoord
Coord offsetToGlobalCoord(Index n) const
Return the global coordinates for a linear table offset.
Definition: LeafNode.h:1295
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::Buffer::operator!=
bool operator!=(const Buffer &other) const
Definition: LeafNodeBool.h:107
openvdb::v3_1_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:408
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::setValueOn
void setValueOn(const Coord &xyz)
Mark the voxel at the given coordinates as active but don&#39;t change its value.
Definition: LeafNodeBool.h:320
Compression.h
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::ValueOnIter
ValueIter< MaskOnIter, LeafNode, const bool > ValueOnIter
Definition: LeafNodeBool.h:689
openvdb::v3_1_0::tree::LeafNode::addTile
void addTile(Index level, const Coord &, const ValueType &, bool)
Definition: LeafNode.h:1790
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::setValueOff
void setValueOff(Index offset)
Mark the voxel at the given offset as inactive but don&#39;t change its value.
Definition: LeafNodeBool.h:312
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::buffer
Buffer & buffer()
Definition: LeafNodeBool.h:267
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::cbeginChildOn
ChildOnCIter cbeginChildOn() const
Definition: LeafNodeBool.h:724
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::MaskDenseIter
NodeMaskType::DenseIterator MaskDenseIter
Definition: LeafNodeBool.h:625
Math.h
General-purpose arithmetic and comparison routines, most of which accept arbitrary value types (or at...
openvdb::v3_1_0::tree::LeafNode::operator==
bool operator==(const LeafNode &other) const
Check for buffer, state and origin equivalence.
Definition: LeafNode.h:1702
openvdb::v3_1_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_1_0::tree::LeafNode< bool, Log2Dim >::ValueOffCIter
ValueIter< MaskOffIter, const LeafNode, const bool > ValueOffCIter
Definition: LeafNodeBool.h:692
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::probeNode
NodeT * probeNode(const Coord &)
This function exists only to enable template instantiation.
Definition: LeafNodeBool.h:572
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::ValueAllCIter
ValueIter< MaskDenseIter, const LeafNode, const bool > ValueAllCIter
Definition: LeafNodeBool.h:694
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::Buffer::setValue
void setValue(Index i, bool val)
Definition: LeafNodeBool.h:109
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::isValueMaskOn
bool isValueMaskOn() const
Definition: LeafNodeBool.h:748
openvdb::v3_1_0::tree::LeafNode::LEVEL
static const Index LEVEL
Definition: LeafNode.h:80
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::cbeginValueAll
ValueAllCIter cbeginValueAll() const
Definition: LeafNodeBool.h:708
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::buffer
const Buffer & buffer() const
Definition: LeafNodeBool.h:266
openvdb::v3_1_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:1281
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::ValueIter::modifyItem
void modifyItem(Index n, const ModifyOp &op) const
Definition: LeafNodeBool.h:648
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::log2dim
static Index log2dim()
Return log2 of the size of the buffer storage.
Definition: LeafNodeBool.h:182
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::mValueMask
NodeMaskType mValueMask
Bitmask that determines which voxels are active.
Definition: LeafNodeBool.h:778
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::LeafNodeType
LeafNode< bool, Log2Dim > LeafNodeType
Definition: LeafNodeBool.h:57
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::endChildOff
ChildOffCIter endChildOff() const
Definition: LeafNodeBool.h:738
openvdb::v3_1_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:467
openvdb::v3_1_0::CombineArgs::resultIsActive
bool resultIsActive() const
Definition: Types.h:353
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::beginChildOff
ChildOffCIter beginChildOff() const
Definition: LeafNodeBool.h:728
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::beginValueAll
ValueAllIter beginValueAll()
Definition: LeafNodeBool.h:710
openvdb::v3_1_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_1_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:712
openvdb::v3_1_0::util::OnMaskIterator
Definition: NodeMasks.h:205
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::getNodes
void getNodes(ArrayT &) const
This function exists only to enable template instantiation.
Definition: LeafNodeBool.h:575
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::beginChildAll
ChildAllIter beginChildAll()
Definition: LeafNodeBool.h:732
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::isValueOn
bool isValueOn(Index offset) const
Return true if the voxel at the given offset is active.
Definition: LeafNodeBool.h:352
openvdb::v3_1_0::util::OffMaskIterator
Definition: NodeMasks.h:236
openvdb::v3_1_0::Index32
uint32_t Index32
Definition: Types.h:56
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::getValueLevel
static Index getValueLevel(const Coord &)
Return the level (0) at which leaf node values reside.
Definition: LeafNodeBool.h:297
openvdb::v3_1_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:355
openvdb::v3_1_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:730
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::Buffer::data
WordType * data()
Definition: LeafNodeBool.h:119
openvdb::v3_1_0::tree::LeafNode< bool, 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: LeafNodeBool.h:460
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::cendChildOff
ChildOffCIter cendChildOff() const
Definition: LeafNodeBool.h:737
openvdb::v3_1_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:1912
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::isValueOn
bool isValueOn(const Coord &xyz) const
Return true if the voxel at the given coordinates is active.
Definition: LeafNodeBool.h:350
openvdb::v3_1_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_1_0::tree::LeafNode::visit
void visit(VisitorOp &)
Definition: LeafNode.h:2066
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::mBuffer
Buffer mBuffer
Bitmask representing the values of voxels.
Definition: LeafNodeBool.h:780
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::setValuesOff
void setValuesOff()
Mark all voxels as inactive but don&#39;t change their values.
Definition: LeafNodeBool.h:347
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::onVoxelCount
Index64 onVoxelCount() const
Return the number of active voxels.
Definition: LeafNodeBool.h:195
openvdb::v3_1_0::tree::DenseIteratorBase::NonConstValueType
boost::remove_const< UnsetItemT >::type NonConstValueType
Definition: Iterator.h:217
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::DenseIter::NonConstValueT
BaseT::NonConstValueType NonConstValueT
Definition: LeafNodeBool.h:669
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::nonLeafCount
static Index32 nonLeafCount()
Definition: LeafNodeBool.h:192
openvdb::v3_1_0::tree::LeafNode::ChildAllCIter
DenseIter< const LeafNode, const ValueType, ChildAll > ChildAllCIter
Definition: LeafNode.h:590
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::isValueMaskOff
bool isValueMaskOff(Index n) const
Definition: LeafNodeBool.h:749
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::Buffer::getValue
const bool & getValue(Index i) const
Definition: LeafNodeBool.h:97
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::cendValueOff
ValueOffCIter cendValueOff() const
Definition: LeafNodeBool.h:715
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::endValueOff
ValueOffIter endValueOff()
Definition: LeafNodeBool.h:717
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::leafCount
static Index32 leafCount()
Definition: LeafNodeBool.h:191
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::allocate
bool allocate()
Allocate memory for this node&#39;s buffer if it has not already been allocated.
Definition: LeafNodeBool.h:216
openvdb::v3_1_0::tree::LeafNode::resetBackground
void resetBackground(const ValueType &oldBackground, const ValueType &newBackground)
Replace inactive occurrences of oldBackground with newBackground, and inactive occurrences of -oldBac...
Definition: LeafNode.h:1819
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::probeConstNodeAndCache
const NodeT * probeConstNodeAndCache(const Coord &, AccessorT &) const
Return a const pointer to this node.
Definition: LeafNodeBool.h:610
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::Buffer::data
const WordType * data() const
Definition: LeafNodeBool.h:127
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::getNodeBoundingBox
CoordBBox getNodeBoundingBox() const
Return the bounding box of this node, i.e., the full index space spanned by this leaf node...
Definition: LeafNodeBool.h:229
openvdb::v3_1_0::tools::composite::min
const boost::disable_if_c< VecTraits< T >::IsVec, T >::type & min(const T &a, const T &b)
Definition: Composite.h:105
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::sOn
static const bool sOn
Definition: LeafNodeBool.h:785
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::isInactive
bool isInactive() const
Return true if all of this node&#39;s values are inactive.
Definition: LeafNodeBool.h:484
openvdb::v3_1_0::tree::LeafNode::readBuffers
void readBuffers(std::istream &is, bool fromHalf=false)
Read buffers from a stream.
Definition: LeafNode.h:1593
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::DenseIter::DenseIter
DenseIter(const MaskDenseIter &iter, NodeT *parent)
Definition: LeafNodeBool.h:672
openvdb::v3_1_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_1_0::tree::LeafNode::operator!=
bool operator!=(const LeafNode &other) const
Definition: LeafNode.h:496
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::voxelizeActiveTiles
void voxelizeActiveTiles()
Definition: LeafNodeBool.h:494
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::getOrigin
void getOrigin(Coord &origin) const
Return the grid index coordinates of this node&#39;s local origin.
Definition: LeafNodeBool.h:236
openvdb::v3_1_0::tree::LeafNode::beginChildAll
ChildAllCIter beginChildAll() const
Definition: LeafNode.h:621
openvdb::v3_1_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:2043
openvdb::v3_1_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:1740
openvdb::v3_1_0::util::NodeMask::isOn
bool isOn(Index32 n) const
Return true if the nth bit is on.
Definition: NodeMasks.h:499
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::getOrigin
void getOrigin(Int32 &x, Int32 &y, Int32 &z) const
Return the grid index coordinates of this node&#39;s local origin.
Definition: LeafNodeBool.h:237
openvdb::v3_1_0::tree::LeafNode::combine2
void combine2(const LeafNode &other, const OtherType &, bool valueIsActive, CombineOp &)
Definition: LeafNode.h:1979
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::ValueIter::getValue
const bool & getValue() const
Definition: LeafNodeBool.h:639
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::getLevel
static Index getLevel()
Definition: LeafNodeBool.h:187
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::ValueOffIter
ValueIter< MaskOffIter, LeafNode, const bool > ValueOffIter
Definition: LeafNodeBool.h:691
openvdb::v3_1_0::tree::LeafNode< bool, 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: LeafNodeBool.h:307
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::cendValueAll
ValueAllCIter cendValueAll() const
Definition: LeafNodeBool.h:718
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::Buffer::operator=
Buffer & operator=(const Buffer &b)
Definition: LeafNodeBool.h:95
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::addLeaf
void addLeaf(LeafNode *)
This function exists only to enable template instantiation.
Definition: LeafNodeBool.h:566
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::getFirstValue
const bool & getFirstValue() const
Return a const reference to the first entry in the buffer.
Definition: LeafNodeBool.h:473
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::sOff
static const bool sOff
Definition: LeafNodeBool.h:786
openvdb::v3_1_0::tree::SameLeafConfig
Definition: PointIndexGrid.h:68
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::setValuesOn
void setValuesOn()
Mark all voxels as active but don&#39;t change their values.
Definition: LeafNodeBool.h:345
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::negate
void negate()
Definition: LeafNodeBool.h:488
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::cbeginChildOff
ChildOffCIter cbeginChildOff() const
Definition: LeafNodeBool.h:727
OPENVDB_VERSION_NAME
#define OPENVDB_VERSION_NAME
Definition: version.h:43
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::setValueMask
void setValueMask(const NodeMaskType &mask)
Definition: LeafNodeBool.h:753
openvdb::v3_1_0::io::getFormatVersion
OPENVDB_API uint32_t getFormatVersion(std::ios_base &)
Return the file format version number associated with the given input stream.
openvdb::v3_1_0::util::NodeMask::beginOff
OffIterator beginOff() const
Definition: NodeMasks.h:351
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::endChildAll
ChildAllIter endChildAll()
Definition: LeafNodeBool.h:742
openvdb::v3_1_0::tree::LeafNode::~LeafNode
~LeafNode()
Destructor.
Definition: LeafNode.h:1251
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::isValueMaskOff
bool isValueMaskOff() const
Definition: LeafNodeBool.h:750
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::setOrigin
void setOrigin(const Coord &origin)
Set the grid index coordinates of this node&#39;s local origin.
Definition: LeafNodeBool.h:232
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::isEmpty
bool isEmpty() const
Return true if this node has no active voxels.
Definition: LeafNodeBool.h:204
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::cbeginChildAll
ChildAllCIter cbeginChildAll() const
Definition: LeafNodeBool.h:730
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::setValueOff
void setValueOff(const Coord &xyz)
Mark the voxel at the given coordinates as inactive but don&#39;t change its value.
Definition: LeafNodeBool.h:310
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::getValueMask
const NodeMaskType & getValueMask() const
Definition: LeafNodeBool.h:751
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::ChildOffCIter
ChildIter< MaskOffIter, const LeafNode > ChildOffCIter
Definition: LeafNodeBool.h:698
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::endChildOff
ChildOffIter endChildOff()
Definition: LeafNodeBool.h:739
openvdb::v3_1_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:1356
openvdb::v3_1_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:1382
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::endChildAll
ChildAllCIter endChildAll() const
Definition: LeafNodeBool.h:741
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::onTileCount
static Index64 onTileCount()
Definition: LeafNodeBool.h:200
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::ChildIter::ChildIter
ChildIter()
Definition: LeafNodeBool.h:659
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::Buffer::Buffer
Buffer()
Definition: LeafNodeBool.h:89
openvdb::v3_1_0::math::isZero
bool isZero(const Type &x)
Return true if x is exactly equal to zero.
Definition: Math.h:324
openvdb::v3_1_0::tree::LeafNode< bool, 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: LeafNodeBool.h:434
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::NodeMaskType
util::NodeMask< Log2Dim > NodeMaskType
Definition: LeafNodeBool.h:60
openvdb::v3_1_0::tree::LeafNode< bool, 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: LeafNodeBool.h:414
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::endValueOff
ValueOffCIter endValueOff() const
Definition: LeafNodeBool.h:716
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::beginChildAll
ChildAllCIter beginChildAll() const
Definition: LeafNodeBool.h:731
openvdb::v3_1_0::CombineArgs::setARef
CombineArgs & setARef(const AValueType &a)
Redirect the A value to a new external source.
Definition: Types.h:342
openvdb::v3_1_0::util::NodeMask::Word
Index64 Word
Definition: NodeMasks.h:313
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::Buffer::fill
void fill(bool val)
Definition: LeafNodeBool.h:94
openvdb::v3_1_0::util::NodeMask::memUsage
static Index32 memUsage()
Return the byte size of this NodeMask.
Definition: NodeMasks.h:438
openvdb::v3_1_0::tree::LeafNode< bool, 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: LeafNodeBool.h:451
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::getChildDim
static Index getChildDim()
Definition: LeafNodeBool.h:189
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::ValueIter::modifyValue
void modifyValue(const ModifyOp &op) const
Definition: LeafNodeBool.h:651
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::ChildIter::ChildIter
ChildIter(const MaskIterT &iter, NodeT *parent)
Definition: LeafNodeBool.h:660
openvdb::v3_1_0::tree::LeafNode::str
std::string str() const
Return a string representation of this node.
Definition: LeafNode.h:1258
openvdb::v3_1_0::util::NodeMask::set
void set(Index32 n, bool On)
Set the nth bit to the specified state.
Definition: NodeMasks.h:459
openvdb
Definition: Exceptions.h:39
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::offLeafVoxelCount
Index64 offLeafVoxelCount() const
Definition: LeafNodeBool.h:199
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::beginChildOn
ChildOnIter beginChildOn()
Definition: LeafNodeBool.h:726
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::isChildMaskOff
bool isChildMaskOff() const
Definition: LeafNodeBool.h:756
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::endValueAll
ValueAllIter endValueAll()
Definition: LeafNodeBool.h:720
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::Buffer::Buffer
Buffer(const Buffer &other)
Definition: LeafNodeBool.h:92
openvdb::v3_1_0::util::NodeMask::isOff
bool isOff(Index32 n) const
Return true if the nth bit is off.
Definition: NodeMasks.h:505
OPENVDB_NO_UNREACHABLE_CODE_WARNING_BEGIN
#define OPENVDB_NO_UNREACHABLE_CODE_WARNING_BEGIN
Definition: Platform.h:129
openvdb::v3_1_0::TopologyCopy
Definition: Types.h:419
openvdb::v3_1_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:347
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::MaskOffIter
NodeMaskType::OffIterator MaskOffIter
Definition: LeafNodeBool.h:624
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::Ptr
boost::shared_ptr< LeafNodeType > Ptr
Definition: LeafNodeBool.h:58
openvdb::v3_1_0::tree::LeafNode::visit2Node
void visit2Node(OtherLeafNodeType &other, VisitorOp &)
Definition: LeafNode.h:2098
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::DenseIter::DenseIter
DenseIter()
Definition: LeafNodeBool.h:671
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::ChildAllCIter
DenseIter< const LeafNode, const bool > ChildAllCIter
Definition: LeafNodeBool.h:700
openvdb::v3_1_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:1895
openvdb::v3_1_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:555
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::numValues
static Index numValues()
Definition: LeafNodeBool.h:186
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::DenseIter::BaseT
DenseIteratorBase< MaskDenseIter, DenseIter, NodeT, void, ValueT > BaseT
Definition: LeafNodeBool.h:668
openvdb::v3_1_0::tree::LeafNode::getValue
const ValueType & getValue(const Coord &xyz) const
Return the value of the voxel at the given coordinates.
Definition: LeafNode.h:1306
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::ValueAllIter
ValueIter< MaskDenseIter, LeafNode, const bool > ValueAllIter
Definition: LeafNodeBool.h:693
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::ValueIter::setValue
void setValue(bool value) const
Definition: LeafNodeBool.h:644
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::probeNodeAndCache
NodeT * probeNodeAndCache(const Coord &, AccessorT &)
Return a pointer to this node.
Definition: LeafNodeBool.h:593
openvdb::v3_1_0::tree::LeafNode::combine
void combine(const LeafNode &other, CombineOp &op)
Definition: LeafNode.h:1937
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::setValueOn
void setValueOn(Index offset)
Mark the voxel at the given offset as active but don&#39;t change its value.
Definition: LeafNodeBool.h:322
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::Buffer::~Buffer
~Buffer()
Definition: LeafNodeBool.h:93
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::beginValueOn
ValueOnIter beginValueOn()
Definition: LeafNodeBool.h:704
openvdb::v3_1_0::tree::LeafNode::addTileAndCache
void addTileAndCache(Index, const Coord &, const ValueType &, bool, AccessorT &)
Definition: LeafNode.h:1807
openvdb::v3_1_0::tree::DenseIteratorBase
Base class for dense iterators over internal and leaf nodes.
Definition: Iterator.h:211
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::ChildOnCIter
ChildIter< MaskOnIter, const LeafNode > ChildOnCIter
Definition: LeafNodeBool.h:696
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::endValueAll
ValueAllCIter endValueAll() const
Definition: LeafNodeBool.h:719
openvdb::v3_1_0::tree::LeafNode::cbeginValueOn
ValueOnCIter cbeginValueOn() const
Definition: LeafNode.h:592
openvdb::v3_1_0::tree::LeafNode::readTopology
void readTopology(std::istream &is, bool fromHalf=false)
Read in just the topology.
Definition: LeafNode.h:1531
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::Buffer::operator[]
const bool & operator[](Index i) const
Definition: LeafNodeBool.h:104
openvdb::v3_1_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:1463
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::ChildOffIter
ChildIter< MaskOffIter, LeafNode > ChildOffIter
Definition: LeafNodeBool.h:697
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::Buffer::memUsage
Index memUsage() const
Definition: LeafNodeBool.h:113
openvdb::v3_1_0::util::NodeMask::setOff
void setOff(Index32 n)
Set the nth bit off.
Definition: NodeMasks.h:454
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::probeLeaf
LeafNode * probeLeaf(const Coord &)
Return a pointer to this node.
Definition: LeafNodeBool.h:589
LeafNode.h
openvdb::v3_1_0::util::DenseMaskIterator
Definition: NodeMasks.h:267
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::DenseIter::unsetItem
void unsetItem(Index pos, const ValueT &val) const
Definition: LeafNodeBool.h:685
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::cendValueOn
ValueOnCIter cendValueOn() const
Definition: LeafNodeBool.h:712
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::Buffer::Buffer
Buffer(bool on)
Definition: LeafNodeBool.h:90
openvdb::v3_1_0::tree::LeafNode< bool, 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: LeafNodeBool.h:327
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::evalNodeOrigin
static void evalNodeOrigin(Coord &xyz)
Compute the origin of the leaf node that contains the voxel with the given coordinates.
Definition: LeafNodeBool.h:763
openvdb::v3_1_0::tree::LeafNode::SIZE
static const Index SIZE
Definition: LeafNode.h:79
openvdb::v3_1_0::MERGE_NODES
Definition: Types.h:259
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::Buffer::WordType
NodeMaskType::Word WordType
Definition: LeafNodeBool.h:87
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::ValueConverter::Type
LeafNode< ValueType, Log2Dim > Type
Definition: LeafNodeBool.h:74
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::touchLeafAndCache
LeafNode * touchLeafAndCache(const Coord &, AccessorT &)
Return a pointer to this node.
Definition: LeafNodeBool.h:588
openvdb::v3_1_0::tree::SparseIteratorBase
Base class for sparse iterators over internal and leaf nodes.
Definition: Iterator.h:148
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::mOrigin
Coord mOrigin
Global grid index coordinates (x,y,z) of the local origin of this node.
Definition: LeafNodeBool.h:782
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::Buffer::swap
void swap(Buffer &other)
Definition: LeafNodeBool.h:111
openvdb::v3_1_0::tree::LeafNode::doVisit2
static void doVisit2(NodeT &self, OtherChildAllIterT &, VisitorOp &, bool otherIsLHS)
Definition: LeafNode.h:2168
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::beginValueOff
ValueOffCIter beginValueOff() const
Definition: LeafNodeBool.h:706
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::beginChildOff
ChildOffIter beginChildOff()
Definition: LeafNodeBool.h:729
openvdb::v3_1_0::tree::LeafNode< bool, 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: LeafNodeBool.h:265
openvdb::v3_1_0::tree::LeafNode::memUsage
Index64 memUsage() const
Return the memory in bytes occupied by this node.
Definition: LeafNode.h:1712
OPENVDB_NO_UNREACHABLE_CODE_WARNING_END
#define OPENVDB_NO_UNREACHABLE_CODE_WARNING_END
Definition: Platform.h:130
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::probeLeafAndCache
const LeafNode * probeLeafAndCache(const Coord &, AccessorT &) const
Return a const pointer to this node.
Definition: LeafNodeBool.h:605
openvdb::v3_1_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:1322
openvdb::v3_1_0::tree::LeafNode::doVisit2Node
static void doVisit2Node(NodeT &self, OtherNodeT &other, VisitorOp &)
Definition: LeafNode.h:2123
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::setValueMask
void setValueMask(Index n, bool on)
Definition: LeafNodeBool.h:758
openvdb::v3_1_0::CombineArgs
This struct collects both input and output arguments to "grid combiner" functors used with the tree::...
Definition: Types.h:304
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::probeConstLeaf
const LeafNode * probeConstLeaf(const Coord &) const
Return a const pointer to this node.
Definition: LeafNodeBool.h:606
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::beginValueAll
ValueAllCIter beginValueAll() const
Definition: LeafNodeBool.h:709
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::getLastValue
const bool & getLastValue() const
Return a const reference to the last entry in the buffer.
Definition: LeafNodeBool.h:477
openvdb::v3_1_0::util::NodeMask::setOn
void setOn(Index32 n)
Set the nth bit on.
Definition: NodeMasks.h:449
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::probeConstLeafAndCache
const LeafNode * probeConstLeafAndCache(const Coord &, AccessorT &) const
Return a const pointer to this node.
Definition: LeafNodeBool.h:608
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::MaskOnIter
NodeMaskType::OnIterator MaskOnIter
Definition: LeafNodeBool.h:623
openvdb::v3_1_0::Int32
int32_t Int32
Definition: Types.h:60
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >
LeafNode specialization for values of type bool that stores both the active states and the values of ...
Definition: LeafNodeBool.h:54
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::getValueLevelAndCache
static Index getValueLevelAndCache(const Coord &, AccessorT &)
Return the LEVEL (=0) at which leaf node values reside.
Definition: LeafNodeBool.h:468
openvdb::v3_1_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:1364
openvdb::v3_1_0::Index64
uint64_t Index64
Definition: Types.h:57
openvdb::v3_1_0::tree::LeafNode::LOG2DIM
static const Index LOG2DIM
Definition: LeafNode.h:74
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::getValueMask
NodeMaskType & getValueMask()
Definition: LeafNodeBool.h:752
Iterator.h
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::isChildMaskOff
bool isChildMaskOff(Index) const
Definition: LeafNodeBool.h:755
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::ChildOnIter
ChildIter< MaskOnIter, LeafNode > ChildOnIter
Definition: LeafNodeBool.h:695
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::ValueOnCIter
ValueIter< MaskOnIter, const LeafNode, const bool > ValueOnCIter
Definition: LeafNodeBool.h:690
openvdb::v3_1_0::tree::LeafNode::LeafNode
LeafNode()
Default constructor.
Definition: LeafNode.h:1165
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::probeConstNode
const NodeT * probeConstNode(const Coord &) const
This function exists only to enable template instantiation.
Definition: LeafNodeBool.h:574
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::onLeafVoxelCount
Index64 onLeafVoxelCount() const
Definition: LeafNodeBool.h:198
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::Buffer::operator==
bool operator==(const Buffer &other) const
Definition: LeafNodeBool.h:106
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::ValueType
bool ValueType
Definition: LeafNodeBool.h:59
openvdb::v3_1_0::util::NodeMask::beginOn
OnIterator beginOn() const
Definition: NodeMasks.h:349
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::offTileCount
static Index64 offTileCount()
Definition: LeafNodeBool.h:201
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::isDense
bool isDense() const
Return true if this node only contains active voxels.
Definition: LeafNodeBool.h:206
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::hasActiveTiles
static bool hasActiveTiles()
Return false since leaf nodes never contain tiles.
Definition: LeafNodeBool.h:355
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::offVoxelCount
Index64 offVoxelCount() const
Return the number of inactive voxels.
Definition: LeafNodeBool.h:197
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::Buffer::size
static Index size()
Definition: LeafNodeBool.h:114
openvdb::v3_1_0::tree::LeafNode::visit2
void visit2(IterT &otherIter, VisitorOp &, bool otherIsLHS=false)
Definition: LeafNode.h:2144
NodeMasks.h
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::endValueOn
ValueOnIter endValueOn()
Definition: LeafNodeBool.h:714
openvdb::v3_1_0::tree::LeafNode::evalActiveBoundingBox
void evalActiveBoundingBox(CoordBBox &bbox, bool visitVoxels=true) const
Definition: LeafNode.h:1722
openvdb::v3_1_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:702
openvdb::v3_1_0::tree::LeafNode< bool, 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: LeafNodeBool.h:425
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::stealNodes
void stealNodes(ArrayT &, const ValueType &, bool)
This function exists only to enable template instantiation.
Definition: LeafNodeBool.h:576
openvdb::v3_1_0::PartialCreate
Definition: Types.h:421
openvdb::v3_1_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_1_0::tree::LeafNode< bool, Log2Dim >::cendChildAll
ChildAllCIter cendChildAll() const
Definition: LeafNodeBool.h:740
openvdb::v3_1_0::tree::LeafNode::ChildAllIter
DenseIter< LeafNode, ValueType, ChildAll > ChildAllIter
Definition: LeafNode.h:589
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::ChildAllIter
DenseIter< LeafNode, bool > ChildAllIter
Definition: LeafNodeBool.h:699
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::probeLeafAndCache
LeafNode * probeLeafAndCache(const Coord &, AccessorT &)
Return a pointer to this node.
Definition: LeafNodeBool.h:591
OPENVDB_USE_VERSION_NAMESPACE
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h:71
openvdb::v3_1_0::tree::LeafNode::Buffer::memUsage
Index memUsage() const
Return the memory footprint of this buffer in bytes.
Definition: LeafNode.h:250
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::beginChildOn
ChildOnCIter beginChildOn() const
Definition: LeafNodeBool.h:725
openvdb::v3_1_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:1492
openvdb::v3_1_0::tree::LeafNode::DIM
static const Index DIM
Definition: LeafNode.h:76
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::ValueIter::ValueIter
ValueIter()
Definition: LeafNodeBool.h:635
openvdb::v3_1_0::tree::LeafNode::Buffer::fill
void fill(const ValueType &val)
Populate this buffer with a constant value.
Definition: LeafNode.h:170
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::cbeginValueOff
ValueOffCIter cbeginValueOff() const
Definition: LeafNodeBool.h:705
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::ValueIter::ValueIter
ValueIter(const MaskIterT &iter, NodeT *parent)
Definition: LeafNodeBool.h:636
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::stealNode
NodeT * stealNode(const Coord &, const ValueType &, bool)
This function exists only to enable template instantiation.
Definition: LeafNodeBool.h:570
openvdb::v3_1_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:1903
openvdb::v3_1_0::tree::IteratorBase
Base class for iterators over internal and leaf nodes.
Definition: Iterator.h:58
openvdb::v3_1_0::tree::LeafNode::Buffer::mData
ValueType * mData
Definition: LeafNode.h:359
openvdb::v3_1_0::tree::LeafNode::merge
void merge(const LeafNode &)
Definition: LeafNode.h:1842
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::cbeginValueOn
ValueOnCIter cbeginValueOn() const
Definition: LeafNodeBool.h:702
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::size
static Index size()
Definition: LeafNodeBool.h:185
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::beginValueOff
ValueOffIter beginValueOff()
Definition: LeafNodeBool.h:707
openvdb::v3_1_0::tree::LeafNode::isConstant
bool isConstant(ValueType &constValue, bool &state, const ValueType &tolerance=zeroVal< ValueType >()) const
Definition: LeafNode.h:1749
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::setValueMaskOff
void setValueMaskOff(Index n)
Definition: LeafNodeBool.h:760
openvdb::v3_1_0::tree::LeafNode::doVisit
static void doVisit(NodeT &, VisitorOp &)
Definition: LeafNode.h:2084
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::Buffer::Buffer
Buffer(const NodeMaskType &other)
Definition: LeafNodeBool.h:91
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::isValueMaskOn
bool isValueMaskOn(Index n) const
Definition: LeafNodeBool.h:747
openvdb::v3_1_0::tree::LeafNode::writeTopology
void writeTopology(std::ostream &os, bool toHalf=false) const
Write out just the topology.
Definition: LeafNode.h:1539
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::endChildOn
ChildOnIter endChildOn()
Definition: LeafNodeBool.h:736
openvdb::v3_1_0::util::NodeMask::save
void save(std::ostream &os) const
Definition: NodeMasks.h:551
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::endChildOn
ChildOnCIter endChildOn() const
Definition: LeafNodeBool.h:735
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::setValueMaskOn
void setValueMaskOn(Index n)
Definition: LeafNodeBool.h:759
openvdb::v3_1_0::OPENVDB_FILE_VERSION_BOOL_LEAF_OPTIMIZATION
Definition: version.h:104
openvdb::v3_1_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:747
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::isValueOnAndCache
bool isValueOnAndCache(const Coord &xyz, AccessorT &) const
Return true if the voxel at the given coordinates is active.
Definition: LeafNodeBool.h:409
openvdb::v3_1_0::MERGE_ACTIVE_STATES_AND_NODES
Definition: Types.h:260
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::getNodeLog2Dims
static void getNodeLog2Dims(std::vector< Index > &dims)
Definition: LeafNodeBool.h:188
openvdb::v3_1_0::tree::LeafNode::origin
const Coord & origin() const
Return the grid index coordinates of this node&#39;s local origin.
Definition: LeafNode.h:473
openvdb::v3_1_0::tree::LeafNode< bool, Log2Dim >::ValueIter::BaseT
SparseIteratorBase< MaskIterT, ValueIter, NodeT, ValueT > BaseT
Definition: LeafNodeBool.h:633