OpenVDB 5.1.0

LeafNodeBool.h
Go to the documentation of this file.
1 //
3 // Copyright (c) 2012-2018 DreamWorks Animation LLC
4 //
5 // All rights reserved. This software is distributed under the
6 // Mozilla Public License 2.0 ( http://www.mozilla.org/MPL/2.0/ )
7 //
8 // Redistributions of source code must retain the above copyright
9 // and license notice and the following restrictions and disclaimer.
10 //
11 // * Neither the name of DreamWorks Animation nor the names of
12 // its contributors may be used to endorse or promote products derived
13 // from this software without specific prior written permission.
14 //
15 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
18 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
19 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY INDIRECT, INCIDENTAL,
20 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
21 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 // IN NO EVENT SHALL THE COPYRIGHT HOLDERS' AND CONTRIBUTORS' AGGREGATE
27 // LIABILITY FOR ALL CLAIMS REGARDLESS OF THEIR BASIS EXCEED US$250.00.
28 //
30
31 #ifndef OPENVDB_TREE_LEAF_NODE_BOOL_HAS_BEEN_INCLUDED
32 #define OPENVDB_TREE_LEAF_NODE_BOOL_HAS_BEEN_INCLUDED
33
34 #include <openvdb/Types.h>
35 #include <openvdb/io/Compression.h> // for io::readData(), etc.
36 #include <openvdb/math/Math.h> // for math::isZero()
37 #include <openvdb/util/NodeMasks.h>
38 #include "LeafNode.h"
39 #include "Iterator.h"
40 #include <iostream>
41 #include <sstream>
42 #include <string>
43 #include <type_traits>
44 #include <vector>
45
46
47 namespace openvdb {
48 OPENVDB_USE_VERSION_NAMESPACE
49 namespace OPENVDB_VERSION_NAME {
50 namespace tree {
51
54 template<Index Log2Dim>
55 class LeafNode<bool, Log2Dim>
56 {
57 public:
58 using LeafNodeType = LeafNode<bool, Log2Dim>;
59 using BuildType = bool;
60 using ValueType = bool;
61 using Buffer = LeafBuffer<ValueType, Log2Dim>;
62 using NodeMaskType = util::NodeMask<Log2Dim>;
63 using Ptr = SharedPtr<LeafNodeType>;
64
65 // These static declarations must be on separate lines to avoid VC9 compiler errors.
66 static const Index LOG2DIM = Log2Dim; // needed by parent nodes
67 static const Index TOTAL = Log2Dim; // needed by parent nodes
68 static const Index DIM = 1 << TOTAL; // dimension along one coordinate direction
69 static const Index NUM_VALUES = 1 << 3 * Log2Dim;
70 static const Index NUM_VOXELS = NUM_VALUES; // total number of voxels represented by this node
71 static const Index SIZE = NUM_VALUES;
72 static const Index LEVEL = 0; // level 0 = leaf
73
76 template<typename ValueType>
77 struct ValueConverter { using Type = LeafNode<ValueType, Log2Dim>; };
78
81 template<typename OtherNodeType>
82 struct SameConfiguration {
83 static const bool value = SameLeafConfig<LOG2DIM, OtherNodeType>::value;
84 };
85
86
88 LeafNode();
89
94 explicit LeafNode(const Coord& xyz, bool value = false, bool active = false);
95
96 #if OPENVDB_ABI_VERSION_NUMBER >= 3
97 LeafNode(PartialCreate, const Coord& xyz, bool value = false, bool active = false);
99 #endif
100
102 LeafNode(const LeafNode&);
103
105 LeafNode& operator=(const LeafNode&) = default;
106
108 template<typename OtherValueType>
109 explicit LeafNode(const LeafNode<OtherValueType, Log2Dim>& other);
110
112 template<typename ValueType>
113 LeafNode(const LeafNode<ValueType, Log2Dim>& other, TopologyCopy);
114
116 template<typename ValueType>
119 LeafNode(const LeafNode<ValueType, Log2Dim>& other, bool offValue, bool onValue, TopologyCopy);
120 template<typename ValueType>
121 LeafNode(const LeafNode<ValueType, Log2Dim>& other, bool background, TopologyCopy);
123
125 ~LeafNode();
126
127 //
128 // Statistics
129 //
131 static Index log2dim() { return Log2Dim; }
133 static Index dim() { return DIM; }
134 static Index size() { return SIZE; }
135 static Index numValues() { return SIZE; }
136 static Index getLevel() { return LEVEL; }
137 static void getNodeLog2Dims(std::vector<Index>& dims) { dims.push_back(Log2Dim); }
138 static Index getChildDim() { return 1; }
139
140 static Index32 leafCount() { return 1; }
141 static Index32 nonLeafCount() { return 0; }
142
144 Index64 onVoxelCount() const { return mValueMask.countOn(); }
146 Index64 offVoxelCount() const { return mValueMask.countOff(); }
147 Index64 onLeafVoxelCount() const { return onVoxelCount(); }
148 Index64 offLeafVoxelCount() const { return offVoxelCount(); }
149 static Index64 onTileCount() { return 0; }
150 static Index64 offTileCount() { return 0; }
151
153 bool isEmpty() const { return mValueMask.isOff(); }
155 bool isDense() const { return mValueMask.isOn(); }
156
157 #if OPENVDB_ABI_VERSION_NUMBER >= 3
158 bool isAllocated() const { return true; }
165 bool allocate() { return true; }
166 #endif
167
169 Index64 memUsage() const;
170
174 void evalActiveBoundingBox(CoordBBox& bbox, bool visitVoxels = true) const;
175
178 CoordBBox getNodeBoundingBox() const { return CoordBBox::createCube(mOrigin, DIM); }
179
181 void setOrigin(const Coord& origin) { mOrigin = origin; }
183 const Coord& origin() const { return mOrigin; }
185 void getOrigin(Coord& origin) const { origin = mOrigin; }
186 void getOrigin(Int32& x, Int32& y, Int32& z) const { mOrigin.asXYZ(x, y, z); }
188
190 static Index coordToOffset(const Coord& xyz);
193 static Coord offsetToLocalCoord(Index n);
195 Coord offsetToGlobalCoord(Index n) const;
196
198 std::string str() const;
199
202 template<typename OtherType, Index OtherLog2Dim>
203 bool hasSameTopology(const LeafNode<OtherType, OtherLog2Dim>* other) const;
204
206 bool operator==(const LeafNode&) const;
207 bool operator!=(const LeafNode&) const;
208
209 //
210 // Buffer management
211 //
214 void swap(Buffer& other) { mBuffer.swap(other); }
215 const Buffer& buffer() const { return mBuffer; }
216 Buffer& buffer() { return mBuffer; }
217
218 //
219 // I/O methods
220 //
222 void readTopology(std::istream&, bool fromHalf = false);
224 void writeTopology(std::ostream&, bool toHalf = false) const;
225
227 void readBuffers(std::istream&, bool fromHalf = false);
228 void readBuffers(std::istream& is, const CoordBBox&, bool fromHalf = false);
230 void writeBuffers(std::ostream&, bool toHalf = false) const;
231
232 //
233 // Accessor methods
234 //
236 const bool& getValue(const Coord& xyz) const;
238 const bool& getValue(Index offset) const;
239
243 bool probeValue(const Coord& xyz, bool& val) const;
244
246 static Index getValueLevel(const Coord&) { return LEVEL; }
247
249 void setActiveState(const Coord& xyz, bool on);
251 void setActiveState(Index offset, bool on) { assert(offset<SIZE); mValueMask.set(offset, on); }
252
254 void setValueOnly(const Coord& xyz, bool val);
256 void setValueOnly(Index offset, bool val) { assert(offset<SIZE); mBuffer.setValue(offset,val); }
257
259 void setValueOff(const Coord& xyz) { mValueMask.setOff(this->coordToOffset(xyz)); }
261 void setValueOff(Index offset) { assert(offset < SIZE); mValueMask.setOff(offset); }
262
264 void setValueOff(const Coord& xyz, bool val);
266 void setValueOff(Index offset, bool val);
267
269 void setValueOn(const Coord& xyz) { mValueMask.setOn(this->coordToOffset(xyz)); }
271 void setValueOn(Index offset) { assert(offset < SIZE); mValueMask.setOn(offset); }
272
274 void setValueOn(const Coord& xyz, bool val);
276 void setValue(const Coord& xyz, bool val) { this->setValueOn(xyz, val); }
278 void setValueOn(Index offset, bool val);
279
282 template<typename ModifyOp>
283 void modifyValue(Index offset, const ModifyOp& op);
286 template<typename ModifyOp>
287 void modifyValue(const Coord& xyz, const ModifyOp& op);
288
290 template<typename ModifyOp>
291 void modifyValueAndActiveState(const Coord& xyz, const ModifyOp& op);
292
294 void setValuesOn() { mValueMask.setOn(); }
296 void setValuesOff() { mValueMask.setOff(); }
297
299 bool isValueOn(const Coord& xyz) const { return mValueMask.isOn(this->coordToOffset(xyz)); }
301 bool isValueOn(Index offset) const { assert(offset < SIZE); return mValueMask.isOn(offset); }
302
304 static bool hasActiveTiles() { return false; }
305
307 void clip(const CoordBBox&, bool background);
308
310 void fill(const CoordBBox& bbox, bool value, bool active = true);
312 void denseFill(const CoordBBox& bbox, bool val, bool on = true) { this->fill(bbox, val, on); }
313
315 void fill(const bool& value);
317 void fill(const bool& value, bool active);
318
330 template<typename DenseT>
331 void copyToDense(const CoordBBox& bbox, DenseT& dense) const;
332
349 template<typename DenseT>
350 void copyFromDense(const CoordBBox& bbox, const DenseT& dense, bool background, bool tolerance);
351
354 template<typename AccessorT>
355 const bool& getValueAndCache(const Coord& xyz, AccessorT&) const {return this->getValue(xyz);}
356
359 template<typename AccessorT>
360 bool isValueOnAndCache(const Coord& xyz, AccessorT&) const { return this->isValueOn(xyz); }
361
364 template<typename AccessorT>
365 void setValueAndCache(const Coord& xyz, bool val, AccessorT&) { this->setValueOn(xyz, val); }
366
370 template<typename AccessorT>
371 void setValueOnlyAndCache(const Coord& xyz, bool val, AccessorT&) {this->setValueOnly(xyz,val);}
372
375 template<typename AccessorT>
376 void setValueOffAndCache(const Coord& xyz, bool value, AccessorT&)
377 {
378 this->setValueOff(xyz, value);
379 }
380
384 template<typename ModifyOp, typename AccessorT>
385 void modifyValueAndCache(const Coord& xyz, const ModifyOp& op, AccessorT&)
386 {
387 this->modifyValue(xyz, op);
388 }
389
392 template<typename ModifyOp, typename AccessorT>
393 void modifyValueAndActiveStateAndCache(const Coord& xyz, const ModifyOp& op, AccessorT&)
394 {
395 this->modifyValueAndActiveState(xyz, op);
396 }
397
401 template<typename AccessorT>
402 void setActiveStateAndCache(const Coord& xyz, bool on, AccessorT&)
403 {
404 this->setActiveState(xyz, on);
405 }
406
410 template<typename AccessorT>
411 bool probeValueAndCache(const Coord& xyz, bool& val, AccessorT&) const
412 {
413 return this->probeValue(xyz, val);
414 }
415
418 template<typename AccessorT>
419 static Index getValueLevelAndCache(const Coord&, AccessorT&) { return LEVEL; }
420
424 const bool& getFirstValue() const { if (mValueMask.isOn(0)) return Buffer::sOn; else return Buffer::sOff; }
428 const bool& getLastValue() const { if (mValueMask.isOn(SIZE-1)) return Buffer::sOn; else return Buffer::sOff; }
429
433 bool isConstant(bool& constValue, bool& state, bool tolerance = 0) const;
434
440 bool medianAll() const;
441
448 Index medianOn(ValueType &value) const;
449
456 Index medianOff(ValueType &value) const;
457
459 bool isInactive() const { return mValueMask.isOff(); }
460
461 void resetBackground(bool oldBackground, bool newBackground);
462
463 void negate() { mBuffer.mData.toggle(); }
464
465 template<MergePolicy Policy>
466 void merge(const LeafNode& other, bool bg = false, bool otherBG = false);
467 template<MergePolicy Policy> void merge(bool tileValue, bool tileActive);
468
471 void voxelizeActiveTiles(bool = true) {}
472
479 template<typename OtherType>
480 void topologyUnion(const LeafNode<OtherType, Log2Dim>& other);
481
493 template<typename OtherType>
494 void topologyIntersection(const LeafNode<OtherType, Log2Dim>& other, const bool&);
495
507 template<typename OtherType>
508 void topologyDifference(const LeafNode<OtherType, Log2Dim>& other, const bool&);
509
510 template<typename CombineOp>
511 void combine(const LeafNode& other, CombineOp& op);
512 template<typename CombineOp>
513 void combine(bool, bool valueIsActive, CombineOp& op);
514
515 template<typename CombineOp, typename OtherType /*= bool*/>
516 void combine2(const LeafNode& other, const OtherType&, bool valueIsActive, CombineOp&);
517 template<typename CombineOp, typename OtherNodeT /*= LeafNode*/>
518 void combine2(bool, const OtherNodeT& other, bool valueIsActive, CombineOp&);
519 template<typename CombineOp, typename OtherNodeT /*= LeafNode*/>
520 void combine2(const LeafNode& b0, const OtherNodeT& b1, CombineOp&);
521
526 template<typename BBoxOp> void visitActiveBBox(BBoxOp&) const;
527
528 template<typename VisitorOp> void visit(VisitorOp&);
529 template<typename VisitorOp> void visit(VisitorOp&) const;
530
531 template<typename OtherLeafNodeType, typename VisitorOp>
532 void visit2Node(OtherLeafNodeType& other, VisitorOp&);
533 template<typename OtherLeafNodeType, typename VisitorOp>
534 void visit2Node(OtherLeafNodeType& other, VisitorOp&) const;
535 template<typename IterT, typename VisitorOp>
536 void visit2(IterT& otherIter, VisitorOp&, bool otherIsLHS = false);
537 template<typename IterT, typename VisitorOp>
538 void visit2(IterT& otherIter, VisitorOp&, bool otherIsLHS = false) const;
539
541 void prune(const ValueType& /*tolerance*/ = zeroVal<ValueType>()) {}
543 void addLeaf(LeafNode*) {}
544 template<typename AccessorT>
545 void addLeafAndCache(LeafNode*, AccessorT&) {}
546 template<typename NodeT>
547 NodeT* stealNode(const Coord&, const ValueType&, bool) { return nullptr; }
548 template<typename NodeT>
549 NodeT* probeNode(const Coord&) { return nullptr; }
550 template<typename NodeT>
551 const NodeT* probeConstNode(const Coord&) const { return nullptr; }
552 template<typename ArrayT> void getNodes(ArrayT&) const {}
553 template<typename ArrayT> void stealNodes(ArrayT&, const ValueType&, bool) {}
555
556 void addTile(Index level, const Coord&, bool val, bool active);
557 void addTile(Index offset, bool val, bool active);
558 template<typename AccessorT>
559 void addTileAndCache(Index level, const Coord&, bool val, bool active, AccessorT&);
560
562 LeafNode* touchLeaf(const Coord&) { return this; }
564 template<typename AccessorT>
565 LeafNode* touchLeafAndCache(const Coord&, AccessorT&) { return this; }
566 LeafNode* probeLeaf(const Coord&) { return this; }
567 template<typename AccessorT>
568 LeafNode* probeLeafAndCache(const Coord&, AccessorT&) { return this; }
569 template<typename NodeT, typename AccessorT>
570 NodeT* probeNodeAndCache(const Coord&, AccessorT&)
571 {
572 OPENVDB_NO_UNREACHABLE_CODE_WARNING_BEGIN
573 if (!(std::is_same<NodeT, LeafNode>::value)) return nullptr;
574 return reinterpret_cast<NodeT*>(this);
575 OPENVDB_NO_UNREACHABLE_CODE_WARNING_END
576 }
578
579 const LeafNode* probeLeaf(const Coord&) const { return this; }
581 template<typename AccessorT>
582 const LeafNode* probeLeafAndCache(const Coord&, AccessorT&) const { return this; }
583 const LeafNode* probeConstLeaf(const Coord&) const { return this; }
584 template<typename AccessorT>
585 const LeafNode* probeConstLeafAndCache(const Coord&, AccessorT&) const { return this; }
586 template<typename NodeT, typename AccessorT>
587 const NodeT* probeConstNodeAndCache(const Coord&, AccessorT&) const
588 {
589 OPENVDB_NO_UNREACHABLE_CODE_WARNING_BEGIN
590 if (!(std::is_same<NodeT, LeafNode>::value)) return nullptr;
591 return reinterpret_cast<const NodeT*>(this);
592 OPENVDB_NO_UNREACHABLE_CODE_WARNING_END
593 }
595
596 //
597 // Iterators
598 //
599 protected:
600 using MaskOnIter = typename NodeMaskType::OnIterator;
601 using MaskOffIter = typename NodeMaskType::OffIterator;
602 using MaskDenseIter = typename NodeMaskType::DenseIterator;
603
604 template<typename MaskIterT, typename NodeT, typename ValueT>
605 struct ValueIter:
606 // Derives from SparseIteratorBase, but can also be used as a dense iterator,
607 // if MaskIterT is a dense mask iterator type.
608 public SparseIteratorBase<MaskIterT, ValueIter<MaskIterT, NodeT, ValueT>, NodeT, ValueT>
609 {
610 using BaseT = SparseIteratorBase<MaskIterT, ValueIter, NodeT, ValueT>;
611
612 ValueIter() {}
613 ValueIter(const MaskIterT& iter, NodeT* parent): BaseT(iter, parent) {}
614
615 const bool& getItem(Index pos) const { return this->parent().getValue(pos); }
616 const bool& getValue() const { return this->getItem(this->pos()); }
617
618 // Note: setItem() can't be called on const iterators.
619 void setItem(Index pos, bool value) const { this->parent().setValueOnly(pos, value); }
620 // Note: setValue() can't be called on const iterators.
621 void setValue(bool value) const { this->setItem(this->pos(), value); }
622
623 // Note: modifyItem() can't be called on const iterators.
624 template<typename ModifyOp>
625 void modifyItem(Index n, const ModifyOp& op) const { this->parent().modifyValue(n, op); }
626 // Note: modifyValue() can't be called on const iterators.
627 template<typename ModifyOp>
628 void modifyValue(const ModifyOp& op) const { this->modifyItem(this->pos(), op); }
629 };
630
632 template<typename MaskIterT, typename NodeT>
633 struct ChildIter:
634 public SparseIteratorBase<MaskIterT, ChildIter<MaskIterT, NodeT>, NodeT, bool>
635 {
636 ChildIter() {}
637 ChildIter(const MaskIterT& iter, NodeT* parent): SparseIteratorBase<
638 MaskIterT, ChildIter<MaskIterT, NodeT>, NodeT, bool>(iter, parent) {}
639 };
640
641 template<typename NodeT, typename ValueT>
642 struct DenseIter: public DenseIteratorBase<
643 MaskDenseIter, DenseIter<NodeT, ValueT>, NodeT, /*ChildT=*/void, ValueT>
644 {
645 using BaseT = DenseIteratorBase<MaskDenseIter, DenseIter, NodeT, void, ValueT>;
646 using NonConstValueT = typename BaseT::NonConstValueType;
647
648 DenseIter() {}
649 DenseIter(const MaskDenseIter& iter, NodeT* parent): BaseT(iter, parent) {}
650
651 bool getItem(Index pos, void*& child, NonConstValueT& value) const
652 {
653 value = this->parent().getValue(pos);
654 child = nullptr;
655 return false; // no child
656 }
657
658 // Note: setItem() can't be called on const iterators.
659 //void setItem(Index pos, void* child) const {}
660
661 // Note: unsetItem() can't be called on const iterators.
662 void unsetItem(Index pos, const ValueT& val) const {this->parent().setValueOnly(pos, val);}
663 };
664
665 public:
666 using ValueOnIter = ValueIter<MaskOnIter, LeafNode, const bool>;
667 using ValueOnCIter = ValueIter<MaskOnIter, const LeafNode, const bool>;
668 using ValueOffIter = ValueIter<MaskOffIter, LeafNode, const bool>;
669 using ValueOffCIter = ValueIter<MaskOffIter, const LeafNode, const bool>;
670 using ValueAllIter = ValueIter<MaskDenseIter, LeafNode, const bool>;
671 using ValueAllCIter = ValueIter<MaskDenseIter, const LeafNode, const bool>;
672 using ChildOnIter = ChildIter<MaskOnIter, LeafNode>;
673 using ChildOnCIter = ChildIter<MaskOnIter, const LeafNode>;
674 using ChildOffIter = ChildIter<MaskOffIter, LeafNode>;
675 using ChildOffCIter = ChildIter<MaskOffIter, const LeafNode>;
676 using ChildAllIter = DenseIter<LeafNode, bool>;
677 using ChildAllCIter = DenseIter<const LeafNode, const bool>;
678
679 ValueOnCIter cbeginValueOn() const { return ValueOnCIter(mValueMask.beginOn(), this); }
680 ValueOnCIter beginValueOn() const { return ValueOnCIter(mValueMask.beginOn(), this); }
681 ValueOnIter beginValueOn() { return ValueOnIter(mValueMask.beginOn(), this); }
682 ValueOffCIter cbeginValueOff() const { return ValueOffCIter(mValueMask.beginOff(), this); }
683 ValueOffCIter beginValueOff() const { return ValueOffCIter(mValueMask.beginOff(), this); }
684 ValueOffIter beginValueOff() { return ValueOffIter(mValueMask.beginOff(), this); }
685 ValueAllCIter cbeginValueAll() const { return ValueAllCIter(mValueMask.beginDense(), this); }
686 ValueAllCIter beginValueAll() const { return ValueAllCIter(mValueMask.beginDense(), this); }
687 ValueAllIter beginValueAll() { return ValueAllIter(mValueMask.beginDense(), this); }
688
689 ValueOnCIter cendValueOn() const { return ValueOnCIter(mValueMask.endOn(), this); }
690 ValueOnCIter endValueOn() const { return ValueOnCIter(mValueMask.endOn(), this); }
691 ValueOnIter endValueOn() { return ValueOnIter(mValueMask.endOn(), this); }
692 ValueOffCIter cendValueOff() const { return ValueOffCIter(mValueMask.endOff(), this); }
693 ValueOffCIter endValueOff() const { return ValueOffCIter(mValueMask.endOff(), this); }
694 ValueOffIter endValueOff() { return ValueOffIter(mValueMask.endOff(), this); }
695 ValueAllCIter cendValueAll() const { return ValueAllCIter(mValueMask.endDense(), this); }
696 ValueAllCIter endValueAll() const { return ValueAllCIter(mValueMask.endDense(), this); }
697 ValueAllIter endValueAll() { return ValueAllIter(mValueMask.endDense(), this); }
698
699 // Note that [c]beginChildOn() and [c]beginChildOff() actually return end iterators,
700 // because leaf nodes have no children.
701 ChildOnCIter cbeginChildOn() const { return ChildOnCIter(mValueMask.endOn(), this); }
702 ChildOnCIter beginChildOn() const { return ChildOnCIter(mValueMask.endOn(), this); }
703 ChildOnIter beginChildOn() { return ChildOnIter(mValueMask.endOn(), this); }
704 ChildOffCIter cbeginChildOff() const { return ChildOffCIter(mValueMask.endOff(), this); }
705 ChildOffCIter beginChildOff() const { return ChildOffCIter(mValueMask.endOff(), this); }
706 ChildOffIter beginChildOff() { return ChildOffIter(mValueMask.endOff(), this); }
707 ChildAllCIter cbeginChildAll() const { return ChildAllCIter(mValueMask.beginDense(), this); }
708 ChildAllCIter beginChildAll() const { return ChildAllCIter(mValueMask.beginDense(), this); }
709 ChildAllIter beginChildAll() { return ChildAllIter(mValueMask.beginDense(), this); }
710
711 ChildOnCIter cendChildOn() const { return ChildOnCIter(mValueMask.endOn(), this); }
712 ChildOnCIter endChildOn() const { return ChildOnCIter(mValueMask.endOn(), this); }
713 ChildOnIter endChildOn() { return ChildOnIter(mValueMask.endOn(), this); }
714 ChildOffCIter cendChildOff() const { return ChildOffCIter(mValueMask.endOff(), this); }
715 ChildOffCIter endChildOff() const { return ChildOffCIter(mValueMask.endOff(), this); }
716 ChildOffIter endChildOff() { return ChildOffIter(mValueMask.endOff(), this); }
717 ChildAllCIter cendChildAll() const { return ChildAllCIter(mValueMask.endDense(), this); }
718 ChildAllCIter endChildAll() const { return ChildAllCIter(mValueMask.endDense(), this); }
719 ChildAllIter endChildAll() { return ChildAllIter(mValueMask.endDense(), this); }
720
721 //
722 // Mask accessors
723 //
724 bool isValueMaskOn(Index n) const { return mValueMask.isOn(n); }
725 bool isValueMaskOn() const { return mValueMask.isOn(); }
726 bool isValueMaskOff(Index n) const { return mValueMask.isOff(n); }
727 bool isValueMaskOff() const { return mValueMask.isOff(); }
728 const NodeMaskType& getValueMask() const { return mValueMask; }
729 const NodeMaskType& valueMask() const { return mValueMask; }
730 NodeMaskType& getValueMask() { return mValueMask; }
731 void setValueMask(const NodeMaskType& mask) { mValueMask = mask; }
732 bool isChildMaskOn(Index) const { return false; } // leaf nodes have no children
733 bool isChildMaskOff(Index) const { return true; }
734 bool isChildMaskOff() const { return true; }
735 protected:
736 void setValueMask(Index n, bool on) { mValueMask.set(n, on); }
737 void setValueMaskOn(Index n) { mValueMask.setOn(n); }
738 void setValueMaskOff(Index n) { mValueMask.setOff(n); }
739
741 static void evalNodeOrigin(Coord& xyz) { xyz &= ~(DIM - 1); }
742
743 template<typename NodeT, typename VisitorOp, typename ChildAllIterT>
744 static inline void doVisit(NodeT&, VisitorOp&);
745
746 template<typename NodeT, typename OtherNodeT, typename VisitorOp,
747 typename ChildAllIterT, typename OtherChildAllIterT>
748 static inline void doVisit2Node(NodeT& self, OtherNodeT& other, VisitorOp&);
749
750 template<typename NodeT, typename VisitorOp,
751 typename ChildAllIterT, typename OtherChildAllIterT>
752 static inline void doVisit2(NodeT& self, OtherChildAllIterT&, VisitorOp&, bool otherIsLHS);
753
754
756 NodeMaskType mValueMask;
758 Buffer mBuffer;
760 Coord mOrigin;
761
762 private:
765 template<typename, Index> friend class LeafNode;
766
767 friend struct ValueIter<MaskOnIter, LeafNode, bool>;
768 friend struct ValueIter<MaskOffIter, LeafNode, bool>;
769 friend struct ValueIter<MaskDenseIter, LeafNode, bool>;
770 friend struct ValueIter<MaskOnIter, const LeafNode, bool>;
771 friend struct ValueIter<MaskOffIter, const LeafNode, bool>;
772 friend struct ValueIter<MaskDenseIter, const LeafNode, bool>;
773
775 friend class IteratorBase<MaskOnIter, LeafNode>;
778 friend class IteratorBase<MaskOffIter, LeafNode>;
779 friend class IteratorBase<MaskDenseIter, LeafNode>;
781
782 }; // class LeafNode<bool>
783
784
786
787
788 template<Index Log2Dim>
789 inline
790 LeafNode<bool, Log2Dim>::LeafNode()
791 : mOrigin(0, 0, 0)
792 {
793 }
794
795
796 template<Index Log2Dim>
797 inline
798 LeafNode<bool, Log2Dim>::LeafNode(const Coord& xyz, bool value, bool active)
799 : mValueMask(active)
800 , mBuffer(value)
801 , mOrigin(xyz & (~(DIM - 1)))
802 {
803 }
804
805
806 #if OPENVDB_ABI_VERSION_NUMBER >= 3
807 template<Index Log2Dim>
808 inline
809 LeafNode<bool, Log2Dim>::LeafNode(PartialCreate, const Coord& xyz, bool value, bool active)
810 : mValueMask(active)
811 , mBuffer(value)
812 , mOrigin(xyz & (~(DIM - 1)))
813 {
817 }
818 #endif
819
820
821 template<Index Log2Dim>
822 inline
823 LeafNode<bool, Log2Dim>::LeafNode(const LeafNode &other)
824 : mValueMask(other.valueMask())
825 , mBuffer(other.mBuffer)
826 , mOrigin(other.mOrigin)
827 {
828 }
829
830
831 // Copy-construct from a leaf node with the same configuration but a different ValueType.
832 template<Index Log2Dim>
833 template<typename ValueT>
834 inline
835 LeafNode<bool, Log2Dim>::LeafNode(const LeafNode<ValueT, Log2Dim>& other)
836 : mValueMask(other.valueMask())
837 , mOrigin(other.origin())
838 {
839 struct Local {
841 static inline bool convertValue(const ValueT& val) { return bool(val); }
842 };
843
844 for (Index i = 0; i < SIZE; ++i) {
845 mBuffer.setValue(i, Local::convertValue(other.mBuffer[i]));
846 }
847 }
848
849
850 template<Index Log2Dim>
851 template<typename ValueT>
852 inline
853 LeafNode<bool, Log2Dim>::LeafNode(const LeafNode<ValueT, Log2Dim>& other,
854 bool background, TopologyCopy)
855 : mValueMask(other.valueMask())
856 , mBuffer(background)
857 , mOrigin(other.origin())
858 {
859 }
860
861
862 template<Index Log2Dim>
863 template<typename ValueT>
864 inline
865 LeafNode<bool, Log2Dim>::LeafNode(const LeafNode<ValueT, Log2Dim>& other, TopologyCopy)
866 : mValueMask(other.valueMask())
867 , mBuffer(other.valueMask())// value = active state
868 , mOrigin(other.origin())
869 {
870 }
871
872
873 template<Index Log2Dim>
874 template<typename ValueT>
875 inline
876 LeafNode<bool, Log2Dim>::LeafNode(const LeafNode<ValueT, Log2Dim>& other,
877 bool offValue, bool onValue, TopologyCopy)
878 : mValueMask(other.valueMask())
879 , mBuffer(other.valueMask())
880 , mOrigin(other.origin())
881 {
882 if (offValue) { if (!onValue) mBuffer.mData.toggle(); else mBuffer.mData.setOn(); }
883 }
884
885
886 template<Index Log2Dim>
887 inline
888 LeafNode<bool, Log2Dim>::~LeafNode()
889 {
890 }
891
892
894
895
896 template<Index Log2Dim>
897 inline Index64
898 LeafNode<bool, Log2Dim>::memUsage() const
899 {
900 // Use sizeof(*this) to capture alignment-related padding
901 return sizeof(*this);
902 }
903
904
905 template<Index Log2Dim>
906 inline void
907 LeafNode<bool, Log2Dim>::evalActiveBoundingBox(CoordBBox& bbox, bool visitVoxels) const
908 {
909 CoordBBox this_bbox = this->getNodeBoundingBox();
910 if (bbox.isInside(this_bbox)) return;//this LeafNode is already enclosed in the bbox
911 if (ValueOnCIter iter = this->cbeginValueOn()) {//any active values?
912 if (visitVoxels) {//use voxel granularity?
913 this_bbox.reset();
914 for(; iter; ++iter) this_bbox.expand(this->offsetToLocalCoord(iter.pos()));
915 this_bbox.translate(this->origin());
916 }
917 bbox.expand(this_bbox);
918 }
919 }
920
921
922 template<Index Log2Dim>
923 template<typename OtherType, Index OtherLog2Dim>
924 inline bool
925 LeafNode<bool, Log2Dim>::hasSameTopology(const LeafNode<OtherType, OtherLog2Dim>* other) const
926 {
927 assert(other);
928 return (Log2Dim == OtherLog2Dim && mValueMask == other->getValueMask());
929 }
930
931
932 template<Index Log2Dim>
933 inline std::string
934 LeafNode<bool, Log2Dim>::str() const
935 {
936 std::ostringstream ostr;
937 ostr << "LeafNode @" << mOrigin << ": ";
938 for (Index32 n = 0; n < SIZE; ++n) ostr << (mValueMask.isOn(n) ? '#' : '.');
939 return ostr.str();
940 }
941
942
944
945
946 template<Index Log2Dim>
947 inline Index
948 LeafNode<bool, Log2Dim>::coordToOffset(const Coord& xyz)
949 {
950 assert ((xyz[0] & (DIM-1u)) < DIM && (xyz[1] & (DIM-1u)) < DIM && (xyz[2] & (DIM-1u)) < DIM);
951 return ((xyz[0] & (DIM-1u)) << 2*Log2Dim)
952 + ((xyz[1] & (DIM-1u)) << Log2Dim)
953 + (xyz[2] & (DIM-1u));
954 }
955
956
957 template<Index Log2Dim>
958 inline Coord
959 LeafNode<bool, Log2Dim>::offsetToLocalCoord(Index n)
960 {
961 assert(n < (1 << 3*Log2Dim));
962 Coord xyz;
963 xyz.setX(n >> 2*Log2Dim);
964 n &= ((1 << 2*Log2Dim) - 1);
965 xyz.setY(n >> Log2Dim);
966 xyz.setZ(n & ((1 << Log2Dim) - 1));
967 return xyz;
968 }
969
970
971 template<Index Log2Dim>
972 inline Coord
973 LeafNode<bool, Log2Dim>::offsetToGlobalCoord(Index n) const
974 {
975 return (this->offsetToLocalCoord(n) + this->origin());
976 }
977
978
980
981
982 template<Index Log2Dim>
983 inline void
984 LeafNode<bool, Log2Dim>::readTopology(std::istream& is, bool /*fromHalf*/)
985 {
986 mValueMask.load(is);
987 }
988
989
990 template<Index Log2Dim>
991 inline void
992 LeafNode<bool, Log2Dim>::writeTopology(std::ostream& os, bool /*toHalf*/) const
993 {
994 mValueMask.save(os);
995 }
996
997
998 template<Index Log2Dim>
999 inline void
1000 LeafNode<bool, Log2Dim>::readBuffers(std::istream& is, const CoordBBox& clipBBox, bool fromHalf)
1001 {
1002 // Boolean LeafNodes don't currently implement lazy loading.
1003 // Instead, load the full buffer, then clip it.
1004
1005 this->readBuffers(is, fromHalf);
1006
1007 // Get this tree's background value.
1008 bool background = false;
1009 if (const void* bgPtr = io::getGridBackgroundValuePtr(is)) {
1010 background = *static_cast<const bool*>(bgPtr);
1011 }
1012 this->clip(clipBBox, background);
1013 }
1014
1015
1016 template<Index Log2Dim>
1017 inline void
1018 LeafNode<bool, Log2Dim>::readBuffers(std::istream& is, bool /*fromHalf*/)
1019 {
1020 // Read in the value mask.
1021 mValueMask.load(is);
1022 // Read in the origin.
1023 is.read(reinterpret_cast<char*>(&mOrigin), sizeof(Coord::ValueType) * 3);
1024
1025 if (io::getFormatVersion(is) >= OPENVDB_FILE_VERSION_BOOL_LEAF_OPTIMIZATION) {
1026 // Read in the mask for the voxel values.
1027 mBuffer.mData.load(is);
1028 } else {
1029 // Older files stored one or more bool arrays.
1030
1031 // Read in the number of buffers, which should now always be one.
1032 int8_t numBuffers = 0;
1033 is.read(reinterpret_cast<char*>(&numBuffers), sizeof(int8_t));
1034
1035 // Read in the buffer.
1036 // (Note: prior to the bool leaf optimization, buffers were always compressed.)
1037 std::unique_ptr<bool[]> buf{new bool[SIZE]};
1038 io::readData<bool>(is, buf.get(), SIZE, /*isCompressed=*/true);
1039
1040 // Transfer values to mBuffer.
1041 mBuffer.mData.setOff();
1042 for (Index i = 0; i < SIZE; ++i) {
1043 if (buf[i]) mBuffer.mData.setOn(i);
1044 }
1045
1046 if (numBuffers > 1) {
1047 // Read in and discard auxiliary buffers that were created with
1048 // earlier versions of the library.
1049 for (int i = 1; i < numBuffers; ++i) {
1050 io::readData<bool>(is, buf.get(), SIZE, /*isCompressed=*/true);
1051 }
1052 }
1053 }
1054 }
1055
1056
1057 template<Index Log2Dim>
1058 inline void
1059 LeafNode<bool, Log2Dim>::writeBuffers(std::ostream& os, bool /*toHalf*/) const
1060 {
1061 // Write out the value mask.
1062 mValueMask.save(os);
1063 // Write out the origin.
1064 os.write(reinterpret_cast<const char*>(&mOrigin), sizeof(Coord::ValueType) * 3);
1065 // Write out the voxel values.
1066 mBuffer.mData.save(os);
1067 }
1068
1069
1071
1072
1073 template<Index Log2Dim>
1074 inline bool
1075 LeafNode<bool, Log2Dim>::operator==(const LeafNode& other) const
1076 {
1077 return mOrigin == other.mOrigin &&
1078 mValueMask == other.valueMask() &&
1079 mBuffer == other.mBuffer;
1080 }
1081
1082
1083 template<Index Log2Dim>
1084 inline bool
1085 LeafNode<bool, Log2Dim>::operator!=(const LeafNode& other) const
1086 {
1087 return !(this->operator==(other));
1088 }
1089
1090
1092
1093
1094 template<Index Log2Dim>
1095 inline bool
1096 LeafNode<bool, Log2Dim>::isConstant(bool& constValue, bool& state, bool tolerance) const
1097 {
1098 if (!mValueMask.isConstant(state)) return false;
1099
1100 // Note: if tolerance is true (i.e., 1), then all boolean values compare equal.
1101 if (!tolerance && !(mBuffer.mData.isOn() || mBuffer.mData.isOff())) return false;
1102
1103 constValue = mBuffer.mData.isOn();
1104 return true;
1105 }
1106
1108
1109 template<Index Log2Dim>
1110 inline bool
1111 LeafNode<bool, Log2Dim>::medianAll() const
1112 {
1113 const Index countTrue = mBuffer.mData.countOn();
1114 return countTrue > (NUM_VALUES >> 1);
1115 }
1116
1117 template<Index Log2Dim>
1118 inline Index
1119 LeafNode<bool, Log2Dim>::medianOn(bool& state) const
1120 {
1121 const NodeMaskType tmp = mBuffer.mData & mValueMask;//both true and active
1122 const Index countTrueOn = tmp.countOn(), countOn = mValueMask.countOn();
1123 state = countTrueOn > (NUM_VALUES >> 1);
1124 return countOn;
1125 }
1126
1127 template<Index Log2Dim>
1128 inline Index
1129 LeafNode<bool, Log2Dim>::medianOff(bool& state) const
1130 {
1131 const NodeMaskType tmp = mBuffer.mData & (!mValueMask);//both true and inactive
1132 const Index countTrueOff = tmp.countOn(), countOff = mValueMask.countOff();
1133 state = countTrueOff > (NUM_VALUES >> 1);
1134 return countOff;
1135 }
1136
1138
1139
1140 template<Index Log2Dim>
1141 inline void
1142 LeafNode<bool, Log2Dim>::addTile(Index /*level*/, const Coord& xyz, bool val, bool active)
1143 {
1144 this->addTile(this->coordToOffset(xyz), val, active);
1145 }
1146
1147 template<Index Log2Dim>
1148 inline void
1149 LeafNode<bool, Log2Dim>::addTile(Index offset, bool val, bool active)
1150 {
1151 assert(offset < SIZE);
1152 this->setValueOnly(offset, val);
1153 this->setActiveState(offset, active);
1154 }
1155
1156 template<Index Log2Dim>
1157 template<typename AccessorT>
1158 inline void
1159 LeafNode<bool, Log2Dim>::addTileAndCache(Index level, const Coord& xyz,
1160 bool val, bool active, AccessorT&)
1161 {
1162 this->addTile(level, xyz, val, active);
1163 }
1164
1165
1167
1168
1169 template<Index Log2Dim>
1170 inline const bool&
1171 LeafNode<bool, Log2Dim>::getValue(const Coord& xyz) const
1172 {
1173 // This *CANNOT* use operator ? because Visual C++
1174 if (mBuffer.mData.isOn(this->coordToOffset(xyz))) return Buffer::sOn; else return Buffer::sOff;
1175 }
1176
1177
1178 template<Index Log2Dim>
1179 inline const bool&
1180 LeafNode<bool, Log2Dim>::getValue(Index offset) const
1181 {
1182 assert(offset < SIZE);
1183 // This *CANNOT* use operator ? for Windows
1184 if (mBuffer.mData.isOn(offset)) return Buffer::sOn; else return Buffer::sOff;
1185 }
1186
1187
1188 template<Index Log2Dim>
1189 inline bool
1190 LeafNode<bool, Log2Dim>::probeValue(const Coord& xyz, bool& val) const
1191 {
1192 const Index offset = this->coordToOffset(xyz);
1193 val = mBuffer.mData.isOn(offset);
1194 return mValueMask.isOn(offset);
1195 }
1196
1197
1198 template<Index Log2Dim>
1199 inline void
1200 LeafNode<bool, Log2Dim>::setValueOn(const Coord& xyz, bool val)
1201 {
1202 this->setValueOn(this->coordToOffset(xyz), val);
1203 }
1204
1205
1206 template<Index Log2Dim>
1207 inline void
1208 LeafNode<bool, Log2Dim>::setValueOn(Index offset, bool val)
1209 {
1210 assert(offset < SIZE);
1211 mValueMask.setOn(offset);
1212 mBuffer.mData.set(offset, val);
1213 }
1214
1215
1216 template<Index Log2Dim>
1217 inline void
1218 LeafNode<bool, Log2Dim>::setValueOnly(const Coord& xyz, bool val)
1219 {
1220 this->setValueOnly(this->coordToOffset(xyz), val);
1221 }
1222
1223
1224 template<Index Log2Dim>
1225 inline void
1226 LeafNode<bool, Log2Dim>::setActiveState(const Coord& xyz, bool on)
1227 {
1228 mValueMask.set(this->coordToOffset(xyz), on);
1229 }
1230
1231
1232 template<Index Log2Dim>
1233 inline void
1234 LeafNode<bool, Log2Dim>::setValueOff(const Coord& xyz, bool val)
1235 {
1236 this->setValueOff(this->coordToOffset(xyz), val);
1237 }
1238
1239
1240 template<Index Log2Dim>
1241 inline void
1242 LeafNode<bool, Log2Dim>::setValueOff(Index offset, bool val)
1243 {
1244 assert(offset < SIZE);
1245 mValueMask.setOff(offset);
1246 mBuffer.mData.set(offset, val);
1247 }
1248
1249
1250 template<Index Log2Dim>
1251 template<typename ModifyOp>
1252 inline void
1253 LeafNode<bool, Log2Dim>::modifyValue(Index offset, const ModifyOp& op)
1254 {
1255 bool val = mBuffer.mData.isOn(offset);
1256 op(val);
1257 mBuffer.mData.set(offset, val);
1258 mValueMask.setOn(offset);
1259 }
1260
1261
1262 template<Index Log2Dim>
1263 template<typename ModifyOp>
1264 inline void
1265 LeafNode<bool, Log2Dim>::modifyValue(const Coord& xyz, const ModifyOp& op)
1266 {
1267 this->modifyValue(this->coordToOffset(xyz), op);
1268 }
1269
1270
1271 template<Index Log2Dim>
1272 template<typename ModifyOp>
1273 inline void
1274 LeafNode<bool, Log2Dim>::modifyValueAndActiveState(const Coord& xyz, const ModifyOp& op)
1275 {
1276 const Index offset = this->coordToOffset(xyz);
1277 bool val = mBuffer.mData.isOn(offset), state = mValueMask.isOn(offset);
1278 op(val, state);
1279 mBuffer.mData.set(offset, val);
1280 mValueMask.set(offset, state);
1281 }
1282
1283
1285
1286
1287 template<Index Log2Dim>
1288 inline void
1289 LeafNode<bool, Log2Dim>::resetBackground(bool oldBackground, bool newBackground)
1290 {
1291 if (newBackground != oldBackground) {
1292 // Flip mBuffer's background bits and zero its foreground bits.
1293 NodeMaskType bgMask = !(mBuffer.mData | mValueMask);
1294 // Overwrite mBuffer's background bits, leaving its foreground bits intact.
1295 mBuffer.mData = (mBuffer.mData & mValueMask) | bgMask;
1296 }
1297 }
1298
1299
1301
1302
1303 template<Index Log2Dim>
1304 template<MergePolicy Policy>
1305 inline void
1306 LeafNode<bool, Log2Dim>::merge(const LeafNode& other, bool /*bg*/, bool /*otherBG*/)
1307 {
1308 OPENVDB_NO_UNREACHABLE_CODE_WARNING_BEGIN
1309 if (Policy == MERGE_NODES) return;
1310 for (typename NodeMaskType::OnIterator iter = other.valueMask().beginOn(); iter; ++iter) {
1311 const Index n = iter.pos();
1312 if (mValueMask.isOff(n)) {
1313 mBuffer.mData.set(n, other.mBuffer.mData.isOn(n));
1314 mValueMask.setOn(n);
1315 }
1316 }
1317 OPENVDB_NO_UNREACHABLE_CODE_WARNING_END
1318 }
1319
1320 template<Index Log2Dim>
1321 template<MergePolicy Policy>
1322 inline void
1323 LeafNode<bool, Log2Dim>::merge(bool tileValue, bool tileActive)
1324 {
1325 OPENVDB_NO_UNREACHABLE_CODE_WARNING_BEGIN
1326 if (Policy != MERGE_ACTIVE_STATES_AND_NODES) return;
1327 if (!tileActive) return;
1328 // Replace all inactive values with the active tile value.
1329 if (tileValue) mBuffer.mData |= !mValueMask; // -0=>1, +0=>0, -1=>1, +1=>1 (-,+ = off,on)
1330 else mBuffer.mData &= mValueMask; // -0=>0, +0=>0, -1=>0, +1=>1
1331 mValueMask.setOn();
1332 OPENVDB_NO_UNREACHABLE_CODE_WARNING_END
1333 }
1334
1335
1337
1338
1339 template<Index Log2Dim>
1340 template<typename OtherType>
1341 inline void
1342 LeafNode<bool, Log2Dim>::topologyUnion(const LeafNode<OtherType, Log2Dim>& other)
1343 {
1344 mValueMask |= other.valueMask();
1345 }
1346
1347
1348 template<Index Log2Dim>
1349 template<typename OtherType>
1350 inline void
1351 LeafNode<bool, Log2Dim>::topologyIntersection(const LeafNode<OtherType, Log2Dim>& other,
1352 const bool&)
1353 {
1354 mValueMask &= other.valueMask();
1355 }
1356
1357
1358 template<Index Log2Dim>
1359 template<typename OtherType>
1360 inline void
1361 LeafNode<bool, Log2Dim>::topologyDifference(const LeafNode<OtherType, Log2Dim>& other,
1362 const bool&)
1363 {
1364 mValueMask &= !other.valueMask();
1365 }
1366
1367
1369
1370
1371 template<Index Log2Dim>
1372 inline void
1373 LeafNode<bool, Log2Dim>::clip(const CoordBBox& clipBBox, bool background)
1374 {
1375 CoordBBox nodeBBox = this->getNodeBoundingBox();
1376 if (!clipBBox.hasOverlap(nodeBBox)) {
1377 // This node lies completely outside the clipping region. Fill it with background tiles.
1378 this->fill(nodeBBox, background, /*active=*/false);
1379 } else if (clipBBox.isInside(nodeBBox)) {
1380 // This node lies completely inside the clipping region. Leave it intact.
1381 return;
1382 }
1383
1384 // This node isn't completely contained inside the clipping region.
1385 // Set any voxels that lie outside the region to the background value.
1386
1387 // Construct a boolean mask that is on inside the clipping region and off outside it.
1388 NodeMaskType mask;
1389 nodeBBox.intersect(clipBBox);
1390 Coord xyz;
1391 int &x = xyz.x(), &y = xyz.y(), &z = xyz.z();
1392 for (x = nodeBBox.min().x(); x <= nodeBBox.max().x(); ++x) {
1393 for (y = nodeBBox.min().y(); y <= nodeBBox.max().y(); ++y) {
1394 for (z = nodeBBox.min().z(); z <= nodeBBox.max().z(); ++z) {
1395 mask.setOn(static_cast<Index32>(this->coordToOffset(xyz)));
1396 }
1397 }
1398 }
1399
1400 // Set voxels that lie in the inactive region of the mask (i.e., outside
1401 // the clipping region) to the background value.
1402 for (MaskOffIter maskIter = mask.beginOff(); maskIter; ++maskIter) {
1403 this->setValueOff(maskIter.pos(), background);
1404 }
1405 }
1406
1407
1409
1410
1411 template<Index Log2Dim>
1412 inline void
1413 LeafNode<bool, Log2Dim>::fill(const CoordBBox& bbox, bool value, bool active)
1414 {
1415 auto clippedBBox = this->getNodeBoundingBox();
1416 clippedBBox.intersect(bbox);
1417 if (!clippedBBox) return;
1418
1419 for (Int32 x = clippedBBox.min().x(); x <= clippedBBox.max().x(); ++x) {
1420 const Index offsetX = (x & (DIM-1u))<<2*Log2Dim;
1421 for (Int32 y = clippedBBox.min().y(); y <= clippedBBox.max().y(); ++y) {
1422 const Index offsetXY = offsetX + ((y & (DIM-1u))<< Log2Dim);
1423 for (Int32 z = clippedBBox.min().z(); z <= clippedBBox.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 using DenseValueType = typename DenseT::ValueType;
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 using DenseValueType = typename DenseT::ValueType;
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.valueMask().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.valueMask().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.valueMask().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.valueMask().isOn(i) || b1.valueMask().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.valueMask().isOn(i))
1606 .setBRef(b1Val)
1607 .setBIsActive(b1.valueMask().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 static_assert(OtherNodeT::SIZE == NodeT::SIZE,
1704 "can't visit nodes of different sizes simultaneously");
1705 static_assert(OtherNodeT::LEVEL == NodeT::LEVEL,
1706 "can't visit nodes at different tree levels simultaneously");
1707
1708 ChildAllIterT iter = self.beginChildAll();
1709 OtherChildAllIterT otherIter = other.beginChildAll();
1710
1711 for ( ; iter && otherIter; ++iter, ++otherIter) {
1712 op(iter, otherIter);
1713 }
1714 }
1715
1716
1718
1719
1720 template<Index Log2Dim>
1721 template<typename IterT, typename VisitorOp>
1722 inline void
1723 LeafNode<bool, Log2Dim>::visit2(IterT& otherIter, VisitorOp& op, bool otherIsLHS)
1724 {
1725 doVisit2<LeafNode, VisitorOp, ChildAllIter, IterT>(*this, otherIter, op, otherIsLHS);
1726 }
1727
1728
1729 template<Index Log2Dim>
1730 template<typename IterT, typename VisitorOp>
1731 inline void
1732 LeafNode<bool, Log2Dim>::visit2(IterT& otherIter, VisitorOp& op, bool otherIsLHS) const
1733 {
1734 doVisit2<const LeafNode, VisitorOp, ChildAllCIter, IterT>(*this, otherIter, op, otherIsLHS);
1735 }
1736
1737
1738 template<Index Log2Dim>
1739 template<
1740 typename NodeT,
1741 typename VisitorOp,
1742 typename ChildAllIterT,
1743 typename OtherChildAllIterT>
1744 inline void
1745 LeafNode<bool, Log2Dim>::doVisit2(NodeT& self, OtherChildAllIterT& otherIter,
1746 VisitorOp& op, bool otherIsLHS)
1747 {
1748 if (!otherIter) return;
1749
1750 if (otherIsLHS) {
1751 for (ChildAllIterT iter = self.beginChildAll(); iter; ++iter) {
1752 op(otherIter, iter);
1753 }
1754 } else {
1755 for (ChildAllIterT iter = self.beginChildAll(); iter; ++iter) {
1756 op(iter, otherIter);
1757 }
1758 }
1759 }
1760
1761 } // namespace tree
1762 } // namespace OPENVDB_VERSION_NAME
1763 } // namespace openvdb
1764
1765 #endif // OPENVDB_TREE_LEAF_NODE_BOOL_HAS_BEEN_INCLUDED
1766
1767 // Copyright (c) 2012-2018 DreamWorks Animation LLC
1768 // All rights reserved. This software is distributed under the
1769 // Mozilla Public License 2.0 ( http://www.mozilla.org/MPL/2.0/ )
openvdb::v5_1::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:1248
openvdb::v5_1::tree::LeafNode< bool, Log2Dim >::ChildOffIter
ChildIter< MaskOffIter, LeafNode > ChildOffIter
Definition: LeafNodeBool.h:674
openvdb::v5_1::tree::LeafNode< bool, Log2Dim >::isValueOn
bool isValueOn(Index offset) const
Return true if the voxel at the given offset is active.
Definition: LeafNodeBool.h:301
openvdb::v5_1::tree::LeafNode< bool, Log2Dim >::isChildMaskOn
bool isChildMaskOn(Index) const
Definition: LeafNodeBool.h:732
openvdb::v5_1::Index32
uint32_t Index32
Definition: Types.h:59
openvdb::v5_1::tree::LeafNode< bool, Log2Dim >::ChildIter::ChildIter
ChildIter()
Definition: LeafNodeBool.h:636
openvdb::v5_1::tree::LeafNode::DIM
static const Index DIM
Definition: LeafNode.h:77
openvdb::v5_1::util::NodeMask::isOff
bool isOff(Index32 n) const
Return true if the nth bit is off.
Definition: NodeMasks.h:510
openvdb::v5_1::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:1728
openvdb::v5_1::tree::LeafNode< bool, Log2Dim >::probeNode
NodeT * probeNode(const Coord &)
This function exists only to enable template instantiation.
Definition: LeafNodeBool.h:549
openvdb::v5_1::tree::LeafNode::LEVEL
static const Index LEVEL
Definition: LeafNode.h:81
openvdb::v5_1::tree::LeafNode< bool, Log2Dim >::getValueMask
NodeMaskType & getValueMask()
Definition: LeafNodeBool.h:730
openvdb::v5_1::tree::LeafNode< bool, Log2Dim >::setValueMaskOff
void setValueMaskOff(Index n)
Definition: LeafNodeBool.h:738
openvdb::v5_1::tree::LeafNode< bool, Log2Dim >::ChildAllIter
DenseIter< LeafNode, bool > ChildAllIter
Definition: LeafNodeBool.h:676
openvdb::v5_1::tree::LeafNode::operator==
bool operator==(const LeafNode &other) const
Check for buffer, state and origin equivalence.
Definition: LeafNode.h:1464
openvdb::v5_1::tree::LeafNode::combine2
void combine2(const LeafNode &other, const OtherType &, bool valueIsActive, CombineOp &)
Definition: LeafNode.h:1804
openvdb::v5_1::CombineArgs::setARef
CombineArgs & setARef(const AValueType &a)
Redirect the A value to a new external source.
Definition: Types.h:436
Types.h
openvdb::v5_1::tree::LeafNode< bool, Log2Dim >::cendValueOff
ValueOffCIter cendValueOff() const
Definition: LeafNodeBool.h:692
openvdb::v5_1::math::CoordBBox::max
const Coord & max() const
Definition: Coord.h:338
openvdb::v5_1::tree::IteratorBase
Base class for iterators over internal and leaf nodes.
Definition: Iterator.h:56
Compression.h
openvdb::v5_1::tree::LeafNode< bool, Log2Dim >::onVoxelCount
Index64 onVoxelCount() const
Return the number of active voxels.
Definition: LeafNodeBool.h:144
openvdb::v5_1::tree::LeafNode::LOG2DIM
static const Index LOG2DIM
Definition: LeafNode.h:75
openvdb::v5_1::tree::LeafNode< bool, Log2Dim >::voxelizeActiveTiles
void voxelizeActiveTiles(bool=true)
No-op.
Definition: LeafNodeBool.h:471
openvdb::v5_1::tree::LeafNode< bool, Log2Dim >::buffer
const Buffer & buffer() const
Definition: LeafNodeBool.h:215
openvdb::v5_1::tree::LeafNode< bool, Log2Dim >::probeLeaf
LeafNode * probeLeaf(const Coord &)
Return a pointer to this node.
Definition: LeafNodeBool.h:566
openvdb::v5_1::tree::LeafNode< bool, Log2Dim >::beginValueOn
ValueOnCIter beginValueOn() const
Definition: LeafNodeBool.h:680
openvdb::v5_1::tree::LeafNode< bool, Log2Dim >::getValueMask
const NodeMaskType & getValueMask() const
Definition: LeafNodeBool.h:728
openvdb::v5_1::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:1062
openvdb::v5_1::tree::LeafNode< bool, Log2Dim >::endValueOff
ValueOffCIter endValueOff() const
Definition: LeafNodeBool.h:693
openvdb::v5_1::math::CoordBBox
Axis-aligned bounding box of signed integer coordinates.
Definition: Coord.h:264
openvdb::v5_1::tree::LeafNode::medianOn
Index medianOn(ValueType &value, ValueType *tmp=nullptr) const
Computes the median value of all the active voxels in this node.
Definition: LeafNode.h:1564
Math.h
General-purpose arithmetic and comparison routines, most of which accept arbitrary value types (or at...
openvdb::v5_1::tree::LeafNode< bool, Log2Dim >::endValueOff
ValueOffIter endValueOff()
Definition: LeafNodeBool.h:694
openvdb::v5_1::util::NodeMask::countOff
Index32 countOff() const
Return the total number of on bits.
Definition: NodeMasks.h:452
openvdb::v5_1::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:411
openvdb::v5_1::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:385
openvdb::v5_1::tree::LeafNode< bool, Log2Dim >::cbeginValueOn
ValueOnCIter cbeginValueOn() const
Definition: LeafNodeBool.h:679
openvdb::v5_1::math::isZero
bool isZero(const Type &x)
Return true if x is exactly equal to zero.
Definition: Math.h:308
openvdb::v5_1::util::NodeMask::set
void set(Index32 n, bool On)
Set the nth bit to the specified state.
Definition: NodeMasks.h:464
openvdb::v5_1::tree::LeafNode< bool, Log2Dim >::endChildOn
ChildOnIter endChildOn()
Definition: LeafNodeBool.h:713
openvdb::v5_1::tree::LeafNode< bool, Log2Dim >::MaskOffIter
typename NodeMaskType::OffIterator MaskOffIter
Definition: LeafNodeBool.h:601
openvdb::v5_1::tree::LeafNode< bool, Log2Dim >::setValueMask
void setValueMask(const NodeMaskType &mask)
Definition: LeafNodeBool.h:731
openvdb::v5_1::math::CoordBBox::expand
void expand(ValueType padding)
Pad this bounding box with the specified padding.
Definition: Coord.h:422
openvdb::v5_1::tree::LeafBuffer::fill
void fill(const ValueType &)
Populate this buffer with a constant value.
Definition: LeafBuffer.h:343
openvdb::v5_1::tree::LeafNode< bool, Log2Dim >::isValueMaskOn
bool isValueMaskOn() const
Definition: LeafNodeBool.h:725
openvdb::v5_1::tree::LeafNode< bool, Log2Dim >::ChildIter::ChildIter
ChildIter(const MaskIterT &iter, NodeT *parent)
Definition: LeafNodeBool.h:637
openvdb::v5_1::tree::LeafNode< bool, Log2Dim >::beginValueOn
ValueOnIter beginValueOn()
Definition: LeafNodeBool.h:681
openvdb::v5_1::tree::LeafNode::addTile
void addTile(Index level, const Coord &, const ValueType &, bool)
Definition: LeafNode.h:1615
openvdb::v5_1::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:299
openvdb::v5_1::tree::LeafNode< bool, Log2Dim >::Ptr
SharedPtr< LeafNodeType > Ptr
Definition: LeafNodeBool.h:63
openvdb::v5_1::tree::LeafNode< bool, Log2Dim >::cbeginChildOff
ChildOffCIter cbeginChildOff() const
Definition: LeafNodeBool.h:704
openvdb::v5_1::tree::LeafNode< bool, Log2Dim >::BuildType
bool BuildType
Definition: LeafNodeBool.h:59
openvdb::v5_1::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:165
openvdb::v5_1::tree::LeafNode< bool, Log2Dim >::onTileCount
static Index64 onTileCount()
Definition: LeafNodeBool.h:149
openvdb::v5_1::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:271
openvdb::v5_1::tree::LeafNode::getValueMask
const NodeMaskType & getValueMask() const
Definition: LeafNode.h:889
openvdb::v5_1::OPENVDB_FILE_VERSION_BOOL_LEAF_OPTIMIZATION
Definition: version.h:223
openvdb::v5_1::tree::LeafNode< bool, Log2Dim >::ValueIter::modifyItem
void modifyItem(Index n, const ModifyOp &op) const
Definition: LeafNodeBool.h:625
openvdb::v5_1::tree::LeafNode< bool, Log2Dim >::size
static Index size()
Definition: LeafNodeBool.h:134
openvdb::v5_1::tree::LeafNode< bool, Log2Dim >::beginChildAll
ChildAllIter beginChildAll()
Definition: LeafNodeBool.h:709
openvdb::v5_1::tree::LeafNode< bool, Log2Dim >::probeConstLeaf
const LeafNode * probeConstLeaf(const Coord &) const
Return a const pointer to this node.
Definition: LeafNodeBool.h:583
openvdb::v5_1::tree::LeafNode::~LeafNode
~LeafNode()
Destructor.
Definition: LeafNode.h:1032
openvdb::v5_1::math::Coord::ValueType
Int32 ValueType
Definition: Coord.h:59
openvdb::v5_1::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:355
openvdb::v5_1::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:402
openvdb::v5_1::tree::LeafNode< bool, Log2Dim >::ValueOnCIter
ValueIter< MaskOnIter, const LeafNode, const bool > ValueOnCIter
Definition: LeafNodeBool.h:667
openvdb::v5_1::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:261
openvdb::v5_1::tree::LeafNode< bool, Log2Dim >::ValueType
bool ValueType
Definition: LeafNodeBool.h:60
openvdb::v5_1::tree::LeafNode< bool, Log2Dim >::ChildAllCIter
DenseIter< const LeafNode, const bool > ChildAllCIter
Definition: LeafNodeBool.h:677
openvdb::v5_1::tree::LeafNode< bool, Log2Dim >::ValueIter::getItem
const bool & getItem(Index pos) const
Definition: LeafNodeBool.h:615
openvdb::v5_1::tree::LeafNode< bool, Log2Dim >::isValueMaskOff
bool isValueMaskOff(Index n) const
Definition: LeafNodeBool.h:726
openvdb::v5_1::tree::LeafNode< bool, Log2Dim >::stealNodes
void stealNodes(ArrayT &, const ValueType &, bool)
This function exists only to enable template instantiation.
Definition: LeafNodeBool.h:553
openvdb::v5_1::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:595
openvdb::v5_1::tree::LeafNode< bool, Log2Dim >::endValueAll
ValueAllCIter endValueAll() const
Definition: LeafNodeBool.h:696
openvdb::v5_1::tree::LeafNode::visit2Node
void visit2Node(OtherLeafNodeType &other, VisitorOp &)
Definition: LeafNode.h:1923
openvdb::v5_1::SharedPtr
std::shared_ptr< T > SharedPtr
Definition: Types.h:139
openvdb::v5_1::tree::LeafNode::valueMask
const NodeMaskType & valueMask() const
Definition: LeafNode.h:891
openvdb::v5_1::tree::LeafNode< bool, Log2Dim >::offVoxelCount
Index64 offVoxelCount() const
Return the number of inactive voxels.
Definition: LeafNodeBool.h:146
openvdb::v5_1::tree::LeafBuffer< ValueType, Log2Dim >
openvdb::v5_1::tree::LeafNode< bool, Log2Dim >::beginValueAll
ValueAllIter beginValueAll()
Definition: LeafNodeBool.h:687
openvdb::v5_1::tree::LeafNode< bool, Log2Dim >::hasActiveTiles
static bool hasActiveTiles()
Return false since leaf nodes never contain tiles.
Definition: LeafNodeBool.h:304
openvdb::v5_1::tree::LeafNode< bool, Log2Dim >::beginValueOff
ValueOffIter beginValueOff()
Definition: LeafNodeBool.h:684
openvdb::v5_1::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:269
openvdb::v5_1::tree::LeafNode< bool, Log2Dim >::DenseIter::unsetItem
void unsetItem(Index pos, const ValueT &val) const
Definition: LeafNodeBool.h:662
openvdb::v5_1::tree::LeafNode< bool, Log2Dim >::DenseIter::DenseIter
DenseIter(const MaskDenseIter &iter, NodeT *parent)
Definition: LeafNodeBool.h:649
openvdb::v5_1::tree::LeafNode< bool, Log2Dim >::onLeafVoxelCount
Index64 onLeafVoxelCount() const
Definition: LeafNodeBool.h:147
openvdb::v5_1::util::NodeMask::isConstant
bool isConstant(bool &isOn) const
Definition: NodeMasks.h:528
openvdb::v5_1::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:259
openvdb::v5_1::tree::LeafNode< bool, Log2Dim >::ValueAllCIter
ValueIter< MaskDenseIter, const LeafNode, const bool > ValueAllCIter
Definition: LeafNodeBool.h:671
openvdb::v5_1::util::OffMaskIterator
Definition: NodeMasks.h:241
openvdb::v5_1::TopologyCopy
Tag dispatch class that distinguishes topology copy constructors from deep copy constructors.
Definition: Types.h:515
openvdb::v5_1::tree::LeafNode< bool, Log2Dim >::addLeaf
void addLeaf(LeafNode *)
This function exists only to enable template instantiation.
Definition: LeafNodeBool.h:543
openvdb::v5_1::tree::LeafNode< bool, Log2Dim >::cendValueAll
ValueAllCIter cendValueAll() const
Definition: LeafNodeBool.h:695
openvdb::v5_1::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:448
openvdb::v5_1::tree::LeafNode< bool, Log2Dim >::mBuffer
Buffer mBuffer
Bitmask representing the values of voxels.
Definition: LeafNodeBool.h:758
openvdb::v5_1::tree::LeafNode::combine
void combine(const LeafNode &other, CombineOp &op)
Definition: LeafNode.h:1762
openvdb::v5_1::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:195
openvdb::v5_1::tree::LeafNode< bool, Log2Dim >::cbeginChildOn
ChildOnCIter cbeginChildOn() const
Definition: LeafNodeBool.h:701
openvdb::v5_1::tree::LeafNode::memUsage
Index64 memUsage() const
Return the memory in bytes occupied by this node.
Definition: LeafNode.h:1474
openvdb::v5_1::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::v5_1::PartialCreate
Tag dispatch class that distinguishes constructors during file input.
Definition: Types.h:517
openvdb::v5_1::tree::LeafNode< bool, Log2Dim >::cbeginValueOff
ValueOffCIter cbeginValueOff() const
Definition: LeafNodeBool.h:682
openvdb::v5_1::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:251
openvdb::v5_1::tree::LeafNode< bool, Log2Dim >::ChildOffCIter
ChildIter< MaskOffIter, const LeafNode > ChildOffCIter
Definition: LeafNodeBool.h:675
openvdb::v5_1::tree::LeafNode< bool, Log2Dim >::endChildOff
ChildOffIter endChildOff()
Definition: LeafNodeBool.h:716
openvdb::v5_1::tree::LeafNode::visit2
void visit2(IterT &otherIter, VisitorOp &, bool otherIsLHS=false)
Definition: LeafNode.h:1971
openvdb::v5_1::tree::LeafNode< bool, Log2Dim >::cbeginChildAll
ChildAllCIter cbeginChildAll() const
Definition: LeafNodeBool.h:707
openvdb::v5_1::tree::LeafNode::NUM_VALUES
static const Index NUM_VALUES
Definition: LeafNode.h:78
openvdb::v5_1::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:1644
openvdb::v5_1::math::Coord::setY
Coord & setY(Int32 y)
Definition: Coord.h:107
openvdb::v5_1::tree::LeafBuffer::setValue
void setValue(Index i, const ValueType &)
Set the i&#39;th value of this buffer to the specified value.
Definition: LeafBuffer.h:294
openvdb::v5_1::util::NodeMask::beginOn
OnIterator beginOn() const
Definition: NodeMasks.h:354
openvdb::v5_1::util::NodeMask::isOn
bool isOn(Index32 n) const
Return true if the nth bit is on.
Definition: NodeMasks.h:504
openvdb::v5_1::tree::LeafNode::getValue
const ValueType & getValue(const Coord &xyz) const
Return the value of the voxel at the given coordinates.
Definition: LeafNode.h:1087
openvdb::v5_1::tree::LeafNode< bool, Log2Dim >::buffer
Buffer & buffer()
Definition: LeafNodeBool.h:216
openvdb::v5_1::tree::LeafNode< bool, Log2Dim >::beginValueOff
ValueOffCIter beginValueOff() const
Definition: LeafNodeBool.h:683
openvdb::v5_1::tree::LeafNode< bool, Log2Dim >::addLeafAndCache
void addLeafAndCache(LeafNode *, AccessorT &)
This function exists only to enable template instantiation.
Definition: LeafNodeBool.h:545
openvdb::v5_1::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:214
openvdb::v5_1::tree::LeafNode::medianAll
ValueType medianAll(ValueType *tmp=nullptr) const
Computes the median value of all the active AND inactive voxels in this node.
Definition: LeafNode.h:1546
openvdb::v5_1::tree::LeafNode< bool, Log2Dim >::endValueOn
ValueOnCIter endValueOn() const
Definition: LeafNodeBool.h:690
openvdb::v5_1::tree::LeafNode< bool, Log2Dim >::beginValueAll
ValueAllCIter beginValueAll() const
Definition: LeafNodeBool.h:686
openvdb::v5_1::math::CoordBBox::hasOverlap
bool hasOverlap(const CoordBBox &b) const
Return true if the given bounding box overlaps with this bounding box.
Definition: Coord.h:416
openvdb::v5_1::tree::LeafNode::beginChildAll
ChildAllCIter beginChildAll() const
Definition: LeafNode.h:349
OPENVDB_VERSION_NAME
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition: version.h:136
openvdb::v5_1::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:360
openvdb::v5_1::tree::LeafNode::modifyValueAndActiveState
void modifyValueAndActiveState(const Coord &xyz, const ModifyOp &op)
Apply a functor to the voxel at the given coordinates.
Definition: LeafNode.h:475
openvdb::v5_1::math::CoordBBox::min
const Coord & min() const
Definition: Coord.h:337
openvdb::v5_1::tree::LeafNode::origin
const Coord & origin() const
Return the grid index coordinates of this node&#39;s local origin.
Definition: LeafNode.h:201
openvdb::v5_1::math::CoordBBox::intersect
void intersect(const CoordBBox &bbox)
Intersect this bounding box with the given bounding box.
Definition: Coord.h:448
openvdb::v5_1::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:1203
openvdb::v5_1::math::operator!=
bool operator!=(const Vec3< T0 > &v0, const Vec3< T1 > &v1)
Inequality operator, does exact floating point comparisons.
Definition: Vec3.h:496
openvdb::v5_1::tree::LeafNode< bool, Log2Dim >::ValueAllIter
ValueIter< MaskDenseIter, LeafNode, const bool > ValueAllIter
Definition: LeafNodeBool.h:670
openvdb::v5_1::tree::LeafNode::evalActiveBoundingBox
void evalActiveBoundingBox(CoordBBox &bbox, bool visitVoxels=true) const
Definition: LeafNode.h:1484
openvdb::v5_1::tree::LeafNode::addTileAndCache
void addTileAndCache(Index, const Coord &, const ValueType &, bool, AccessorT &)
Definition: LeafNode.h:1632
openvdb::v5_1::tree::LeafNode< bool, Log2Dim >::getFirstValue
const bool & getFirstValue() const
Return a const reference to the first entry in the buffer.
Definition: LeafNodeBool.h:424
openvdb::v5_1::tree::LeafNode< bool, Log2Dim >::touchLeafAndCache
LeafNode * touchLeafAndCache(const Coord &, AccessorT &)
Return a pointer to this node.
Definition: LeafNodeBool.h:565
openvdb::v5_1::tree::LeafNode< bool, Log2Dim >
LeafNode specialization for values of type bool that stores both the active states and the values of ...
Definition: LeafNodeBool.h:55
openvdb::v5_1::tree::LeafNode::visit
void visit(VisitorOp &)
Definition: LeafNode.h:1891
openvdb::v5_1::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:1103
openvdb::v5_1::tree::LeafNode::writeTopology
void writeTopology(std::ostream &os, bool toHalf=false) const
Write out just the topology.
Definition: LeafNode.h:1324
openvdb::v5_1::math::CoordBBox::isInside
bool isInside(const Coord &xyz) const
Return true if point (x, y, z) is inside this bounding box.
Definition: Coord.h:404
openvdb::v5_1::tree::LeafNode::readTopology
void readTopology(std::istream &is, bool fromHalf=false)
Read in just the topology.
Definition: LeafNode.h:1316
openvdb::v5_1::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:1277
openvdb::v5_1::tree::LeafNode< bool, Log2Dim >::endChildOff
ChildOffCIter endChildOff() const
Definition: LeafNodeBool.h:715
openvdb::v5_1::math::Coord::z
Int32 z() const
Definition: Coord.h:159
openvdb::v5_1::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:186
openvdb::v5_1::Index64
uint64_t Index64
Definition: Types.h:60
openvdb::v5_1::tree::LeafNode< bool, Log2Dim >::log2dim
static Index log2dim()
Return log2 of the size of the buffer storage.
Definition: LeafNodeBool.h:131
openvdb::v5_1::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:1720
openvdb::v5_1::tree::LeafNode< bool, Log2Dim >::endChildAll
ChildAllCIter endChildAll() const
Definition: LeafNodeBool.h:718
openvdb::v5_1::tree::LeafNode< bool, Log2Dim >::beginChildAll
ChildAllCIter beginChildAll() const
Definition: LeafNodeBool.h:708
openvdb::v5_1::Int32
int32_t Int32
Definition: Types.h:63
openvdb::v5_1::tree::LeafNode::medianOff
Index medianOff(ValueType &value, ValueType *tmp=nullptr) const
Computes the median value of all the inactive voxels in this node.
Definition: LeafNode.h:1588
openvdb::v5_1::tree::LeafNode< bool, Log2Dim >::negate
void negate()
Definition: LeafNodeBool.h:463
openvdb::v5_1::tree::LeafNode< bool, Log2Dim >::getChildDim
static Index getChildDim()
Definition: LeafNodeBool.h:138
openvdb
Definition: Exceptions.h:40
openvdb::v5_1::tree::LeafNode< bool, Log2Dim >::getValueLevel
static Index getValueLevel(const Coord &)
Return the level (0) at which leaf node values reside.
Definition: LeafNodeBool.h:246
openvdb::v5_1::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:1868
OPENVDB_NO_UNREACHABLE_CODE_WARNING_BEGIN
#define OPENVDB_NO_UNREACHABLE_CODE_WARNING_BEGIN
Definition: Platform.h:129
openvdb::v5_1::tree::LeafNode< bool, Log2Dim >::mOrigin
Coord mOrigin
Global grid index coordinates (x,y,z) of the local origin of this node.
Definition: LeafNodeBool.h:760
openvdb::v5_1::util::NodeMask::load
void load(std::istream &is)
Definition: NodeMasks.h:571
openvdb::v5_1::tree::LeafNode< bool, Log2Dim >::beginChildOn
ChildOnCIter beginChildOn() const
Definition: LeafNodeBool.h:702
openvdb::v5_1::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:1137
openvdb::v5_1::math::operator==
bool operator==(const Vec3< T0 > &v0, const Vec3< T1 > &v1)
Equality operator, does exact floating point comparisons.
Definition: Vec3.h:488
openvdb::v5_1::tree::LeafNode< bool, Log2Dim >::MaskDenseIter
typename NodeMaskType::DenseIterator MaskDenseIter
Definition: LeafNodeBool.h:602
openvdb::v5_1::tree::LeafNode< bool, Log2Dim >::ValueIter::getValue
const bool & getValue() const
Definition: LeafNodeBool.h:616
openvdb::v5_1::tree::LeafNode< bool, Log2Dim >::endChildAll
ChildAllIter endChildAll()
Definition: LeafNodeBool.h:719
openvdb::v5_1::util::DenseMaskIterator
Definition: NodeMasks.h:272
openvdb::v5_1::math::CoordBBox::translate
void translate(const Coord &t)
Definition: Coord.h:462
openvdb::v5_1::tree::LeafNode< bool, Log2Dim >::valueMask
const NodeMaskType & valueMask() const
Definition: LeafNodeBool.h:729
openvdb::v5_1::tree::LeafNode< bool, Log2Dim >::DenseIter::getItem
bool getItem(Index pos, void *&child, NonConstValueT &value) const
Definition: LeafNodeBool.h:651
openvdb::v5_1::CombineArgs
This struct collects both input and output arguments to "grid combiner" functors used with the tree::...
Definition: Types.h:383
openvdb::v5_1::tree::LeafNode::ChildAllIter
DenseIter< LeafNode, ValueType, ChildAll > ChildAllIter
Definition: LeafNode.h:317
openvdb::v5_1::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:185
openvdb::v5_1::math::Coord::y
Int32 y() const
Definition: Coord.h:158
openvdb::v5_1::tree::LeafNode< bool, Log2Dim >::ValueIter::ValueIter
ValueIter(const MaskIterT &iter, NodeT *parent)
Definition: LeafNodeBool.h:613
openvdb::v5_1::tree::LeafNode::str
std::string str() const
Return a string representation of this node.
Definition: LeafNode.h:1039
openvdb::v5_1::tree::LeafNode< bool, Log2Dim >::modifyValueAndActiveStateAndCache
void modifyValueAndActiveStateAndCache(const Coord &xyz, const ModifyOp &op, AccessorT &)
Definition: LeafNodeBool.h:393
openvdb::v5_1::tree::LeafNode::readBuffers
void readBuffers(std::istream &is, bool fromHalf=false)
Read buffers from a stream.
Definition: LeafNode.h:1352
openvdb::v5_1::MERGE_NODES
Definition: Types.h:327
LeafNode.h
openvdb::v5_1::util::OnMaskIterator
Definition: NodeMasks.h:210
openvdb::v5_1::tree::LeafNode< bool, Log2Dim >::ValueOnIter
ValueIter< MaskOnIter, LeafNode, const bool > ValueOnIter
Definition: LeafNodeBool.h:666
openvdb::v5_1::tree::LeafNode::SIZE
static const Index SIZE
Definition: LeafNode.h:80
openvdb::v5_1::tree::SameLeafConfig
Definition: PointDataGrid.h:201
openvdb::v5_1::tree::LeafNode< bool, Log2Dim >::denseFill
void denseFill(const CoordBBox &bbox, bool val, bool on=true)
Set all voxels within an axis-aligned box to the specified value and active state.
Definition: LeafNodeBool.h:312
openvdb::v5_1::tree::LeafNode::doVisit2Node
static void doVisit2Node(NodeT &self, OtherNodeT &other, VisitorOp &)
Definition: LeafNode.h:1948
openvdb::v5_1::tree::LeafNode< bool, Log2Dim >::setValueMask
void setValueMask(Index n, bool on)
Definition: LeafNodeBool.h:736
openvdb::v5_1::tree::SparseIteratorBase
Base class for sparse iterators over internal and leaf nodes.
Definition: Iterator.h:141
openvdb::v5_1::tree::LeafNode::LeafNode
LeafNode()
Default constructor.
Definition: LeafNode.h:946
openvdb::v5_1::tree::LeafNode< bool, Log2Dim >::ChildOnIter
ChildIter< MaskOnIter, LeafNode > ChildOnIter
Definition: LeafNodeBool.h:672
openvdb::v5_1::tree::LeafNode< bool, Log2Dim >::mValueMask
NodeMaskType mValueMask
Bitmask that determines which voxels are active.
Definition: LeafNodeBool.h:756
openvdb::v5_1::tree::LeafNode< bool, Log2Dim >::beginChildOff
ChildOffIter beginChildOff()
Definition: LeafNodeBool.h:706
openvdb::v5_1::tree::LeafNode< bool, Log2Dim >::cendChildOn
ChildOnCIter cendChildOn() const
Definition: LeafNodeBool.h:711
openvdb::v5_1::tree::LeafNode< bool, Log2Dim >::cendValueOn
ValueOnCIter cendValueOn() const
Definition: LeafNodeBool.h:689
openvdb::v5_1::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:741
openvdb::v5_1::math::CoordBBox::reset
void reset()
Definition: Coord.h:343
openvdb::v5_1::tree::DenseIteratorBase
Base class for dense iterators over internal and leaf nodes.
Definition: Iterator.h:205
openvdb::v5_1::tree::LeafNode< bool, Log2Dim >::probeConstNode
const NodeT * probeConstNode(const Coord &) const
This function exists only to enable template instantiation.
Definition: LeafNodeBool.h:551
openvdb::v5_1::math::Coord::setZ
Coord & setZ(Int32 z)
Definition: Coord.h:108
openvdb::v5_1::tree::LeafNode< bool, Log2Dim >::dim
static Index dim()
Return the number of voxels in each dimension.
Definition: LeafNodeBool.h:133
openvdb::v5_1::tree::LeafNode< bool, Log2Dim >::ValueOffIter
ValueIter< MaskOffIter, LeafNode, const bool > ValueOffIter
Definition: LeafNodeBool.h:668
openvdb::v5_1::tree::LeafNode< bool, Log2Dim >::cbeginValueAll
ValueAllCIter cbeginValueAll() const
Definition: LeafNodeBool.h:685
openvdb::v5_1::math::CoordBBox::createCube
static CoordBBox createCube(const Coord &min, ValueType dim)
Definition: Coord.h:329
openvdb::v5_1::tree::LeafNode::merge
void merge(const LeafNode &)
Definition: LeafNode.h:1667
openvdb::v5_1::tree::LeafNode< bool, Log2Dim >::probeNodeAndCache
NodeT * probeNodeAndCache(const Coord &, AccessorT &)
Return a pointer to this node.
Definition: LeafNodeBool.h:570
openvdb::v5_1::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:181
OPENVDB_NO_UNREACHABLE_CODE_WARNING_END
#define OPENVDB_NO_UNREACHABLE_CODE_WARNING_END
Definition: Platform.h:130
openvdb::v5_1::CombineArgs::resultIsActive
bool resultIsActive() const
Definition: Types.h:447
openvdb::v5_1::tools::composite::min
const std::enable_if<!VecTraits< T >::IsVec, T >::type & min(const T &a, const T &b)
Definition: Composite.h:129
openvdb::v5_1::tree::LeafNode::writeBuffers
void writeBuffers(std::ostream &os, bool toHalf=false) const
Write buffers to a stream.
Definition: LeafNode.h:1447
openvdb::v5_1::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:178
openvdb::v5_1::tree::LeafNode< bool, Log2Dim >::leafCount
static Index32 leafCount()
Definition: LeafNodeBool.h:140
openvdb::v5_1::tree::LeafNode< bool, Log2Dim >::endValueOn
ValueOnIter endValueOn()
Definition: LeafNodeBool.h:691
openvdb::v5_1::math::Coord::setX
Coord & setX(Int32 x)
Definition: Coord.h:106
openvdb::v5_1::MERGE_ACTIVE_STATES_AND_NODES
Definition: Types.h:328
openvdb::v5_1::math::Coord
Signed (x, y, z) 32-bit integer coordinates.
Definition: Coord.h:51
openvdb::v5_1::tree::LeafNode< bool, Log2Dim >::isChildMaskOff
bool isChildMaskOff(Index) const
Definition: LeafNodeBool.h:733
openvdb::v5_1::tree::LeafNode< bool, Log2Dim >::isInactive
bool isInactive() const
Return true if all of this node&#39;s values are inactive.
Definition: LeafNodeBool.h:459
openvdb::v5_1::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:1737
openvdb::v5_1::tree::LeafNode::doVisit
static void doVisit(NodeT &, VisitorOp &)
Definition: LeafNode.h:1909
openvdb::v5_1::tree::LeafNode< bool, Log2Dim >::nonLeafCount
static Index32 nonLeafCount()
Definition: LeafNodeBool.h:141
openvdb::v5_1::CombineArgs::setBRef
CombineArgs & setBRef(const BValueType &b)
Redirect the B value to a new external source.
Definition: Types.h:438
openvdb::v5_1::tree::LeafNode< bool, Log2Dim >::isValueMaskOn
bool isValueMaskOn(Index n) const
Definition: LeafNodeBool.h:724
Iterator.h
openvdb::v5_1::tree::LeafNode< bool, Log2Dim >::isDense
bool isDense() const
Return true if this node only contains active voxels.
Definition: LeafNodeBool.h:155
openvdb::v5_1::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:1163
openvdb::v5_1::tree::LeafNode::doVisit2
static void doVisit2(NodeT &self, OtherChildAllIterT &, VisitorOp &, bool otherIsLHS)
Definition: LeafNode.h:1995
openvdb::v5_1::tree::LeafNode< bool, Log2Dim >::endChildOn
ChildOnCIter endChildOn() const
Definition: LeafNodeBool.h:712
openvdb::v5_1::tree::LeafNode< bool, Log2Dim >::MaskOnIter
typename NodeMaskType::OnIterator MaskOnIter
Definition: LeafNodeBool.h:600
openvdb::v5_1::tree::LeafNode< bool, Log2Dim >::isChildMaskOff
bool isChildMaskOff() const
Definition: LeafNodeBool.h:734
openvdb::v5_1::tree::LeafNode< bool, Log2Dim >::beginChildOn
ChildOnIter beginChildOn()
Definition: LeafNodeBool.h:703
openvdb::v5_1::tree::LeafNode< bool, Log2Dim >::setValuesOn
void setValuesOn()
Mark all voxels as active but don&#39;t change their values.
Definition: LeafNodeBool.h:294
openvdb::v5_1::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:376
openvdb::v5_1::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:256
openvdb::v5_1::tree::LeafNode< bool, Log2Dim >::ChildOnCIter
ChildIter< MaskOnIter, const LeafNode > ChildOnCIter
Definition: LeafNodeBool.h:673
openvdb::v5_1::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:430
openvdb::v5_1::util::NodeMask::countOn
Index32 countOn() const
Return the total number of on bits.
Definition: NodeMasks.h:445
openvdb::v5_1::tree::LeafNode::cbeginValueOn
ValueOnCIter cbeginValueOn() const
Definition: LeafNode.h:320
openvdb::v5_1::tree::LeafNode< bool, Log2Dim >::ValueOffCIter
ValueIter< MaskOffIter, const LeafNode, const bool > ValueOffCIter
Definition: LeafNodeBool.h:669
openvdb::v5_1::tree::LeafNode< bool, Log2Dim >::offLeafVoxelCount
Index64 offLeafVoxelCount() const
Definition: LeafNodeBool.h:148
openvdb::v5_1::tree::LeafNode::operator!=
bool operator!=(const LeafNode &other) const
Definition: LeafNode.h:224
NodeMasks.h
openvdb::v5_1::tree::LeafNode< bool, Log2Dim >::ValueIter::setItem
void setItem(Index pos, bool value) const
Definition: LeafNodeBool.h:619
openvdb::v5_1::tree::LeafNode::offsetToGlobalCoord
Coord offsetToGlobalCoord(Index n) const
Return the global coordinates for a linear table offset.
Definition: LeafNode.h:1076
openvdb::v5_1::Index
Index32 Index
Definition: Types.h:61
openvdb::v5_1::tree::LeafNode< bool, Log2Dim >::probeLeafAndCache
const LeafNode * probeLeafAndCache(const Coord &, AccessorT &) const
Return a const pointer to this node.
Definition: LeafNodeBool.h:582
openvdb::v5_1::tree::LeafNode< bool, Log2Dim >::DenseIter::NonConstValueT
typename BaseT::NonConstValueType NonConstValueT
Definition: LeafNodeBool.h:646
openvdb::v5_1::tree::LeafNode< bool, Log2Dim >::cendChildOff
ChildOffCIter cendChildOff() const
Definition: LeafNodeBool.h:714
OPENVDB_USE_VERSION_NAMESPACE
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h:188
openvdb::v5_1::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:276
openvdb::v5_1::util::NodeMask::setOn
void setOn(Index32 n)
Set the nth bit on.
Definition: NodeMasks.h:454
openvdb::v5_1::tree::LeafNode< bool, Log2Dim >::isValueMaskOff
bool isValueMaskOff() const
Definition: LeafNodeBool.h:727
openvdb::v5_1::tree::DenseIteratorBase::NonConstValueType
typename std::remove_const< UnsetItemT >::type NonConstValueType
Definition: Iterator.h:211
openvdb::v5_1::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:371
openvdb::v5_1::tree::LeafNode< bool, Log2Dim >::stealNode
NodeT * stealNode(const Coord &, const ValueType &, bool)
This function exists only to enable template instantiation.
Definition: LeafNodeBool.h:547
openvdb::v5_1::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:365
openvdb::v5_1::tree::LeafNode< bool, Log2Dim >::offTileCount
static Index64 offTileCount()
Definition: LeafNodeBool.h:150
openvdb::v5_1::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:1145
openvdb::v5_1::tree::LeafNode< bool, Log2Dim >::DenseIter::DenseIter
DenseIter()
Definition: LeafNodeBool.h:648
openvdb::v5_1::tree::LeafNode< bool, Log2Dim >::probeLeafAndCache
LeafNode * probeLeafAndCache(const Coord &, AccessorT &)
Return a pointer to this node.
Definition: LeafNodeBool.h:568
openvdb::v5_1::tree::LeafNode< bool, Log2Dim >::getLastValue
const bool & getLastValue() const
Return a const reference to the last entry in the buffer.
Definition: LeafNodeBool.h:428
openvdb::v5_1::tree::LeafNode< bool, Log2Dim >::setValueMaskOn
void setValueMaskOn(Index n)
Definition: LeafNodeBool.h:737
openvdb::v5_1::tree::LeafBuffer::mData
ValueType * mData
Definition: LeafBuffer.h:225
openvdb::v5_1::tree::LeafNode< bool, Log2Dim >::getNodes
void getNodes(ArrayT &) const
This function exists only to enable template instantiation.
Definition: LeafNodeBool.h:552
openvdb::v5_1::tree::LeafNode< bool, Log2Dim >::getValueLevelAndCache
static Index getValueLevelAndCache(const Coord &, AccessorT &)
Return the LEVEL (=0) at which leaf node values reside.
Definition: LeafNodeBool.h:419
openvdb::v5_1::tree::LeafNode< bool, Log2Dim >::ValueIter::setValue
void setValue(bool value) const
Definition: LeafNodeBool.h:621
openvdb::v5_1::tree::LeafNode< bool, Log2Dim >::beginChildOff
ChildOffCIter beginChildOff() const
Definition: LeafNodeBool.h:705
openvdb::v5_1::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:440
openvdb::v5_1::tree::LeafNode::coordToOffset
static Index coordToOffset(const Coord &xyz)
Return the linear table offset of the given global or local coordinates.
Definition: LeafNode.h:1052
openvdb::v5_1::tree::LeafNode::isConstant
bool isConstant(ValueType &firstValue, bool &state, const ValueType &tolerance=zeroVal< ValueType >()) const
Definition: LeafNode.h:1510
openvdb::v5_1::tree::LeafNode< bool, Log2Dim >::setValuesOff
void setValuesOff()
Mark all voxels as inactive but don&#39;t change their values.
Definition: LeafNodeBool.h:296
openvdb::v5_1::tree::LeafNode< bool, Log2Dim >::getNodeLog2Dims
static void getNodeLog2Dims(std::vector< Index > &dims)
Definition: LeafNodeBool.h:137
openvdb::v5_1::io::getFormatVersion
OPENVDB_API uint32_t getFormatVersion(std::ios_base &)
Return the file format version number associated with the given input stream.
openvdb::v5_1::tree::LeafNode< bool, Log2Dim >::ValueIter::modifyValue
void modifyValue(const ModifyOp &op) const
Definition: LeafNodeBool.h:628
openvdb::v5_1::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:458
openvdb::v5_1::util::NodeMask::beginOff
OffIterator beginOff() const
Definition: NodeMasks.h:356
openvdb::v5_1::tree::LeafNode< bool, Log2Dim >::ValueIter::ValueIter
ValueIter()
Definition: LeafNodeBool.h:612
openvdb::v5_1::tree::LeafNode
Templated block class to hold specific data types and a fixed number of values determined by Log2Dim...
Definition: LeafNode.h:64
openvdb::v5_1::tree::LeafNode< bool, Log2Dim >::probeConstLeafAndCache
const LeafNode * probeConstLeafAndCache(const Coord &, AccessorT &) const
Return a const pointer to this node.
Definition: LeafNodeBool.h:585
openvdb::v5_1::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:361
openvdb::v5_1::tree::LeafNode< bool, Log2Dim >::cendChildAll
ChildAllCIter cendChildAll() const
Definition: LeafNodeBool.h:717
openvdb::v5_1::tree::LeafNode< bool, Log2Dim >::isEmpty
bool isEmpty() const
Return true if this node has no active voxels.
Definition: LeafNodeBool.h:153
openvdb::v5_1::tree::LeafNode< bool, Log2Dim >::endValueAll
ValueAllIter endValueAll()
Definition: LeafNodeBool.h:697
openvdb::v5_1::tree::LeafNode::ChildAllCIter
DenseIter< const LeafNode, const ValueType, ChildAll > ChildAllCIter
Definition: LeafNode.h:318
openvdb::v5_1::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:1502
openvdb::v5_1::tree::LeafNode< bool, Log2Dim >::probeConstNodeAndCache
const NodeT * probeConstNodeAndCache(const Coord &, AccessorT &) const
Return a const pointer to this node.
Definition: LeafNodeBool.h:587
openvdb::v5_1::tree::LeafNode< bool, Log2Dim >::getLevel
static Index getLevel()
Definition: LeafNodeBool.h:136
openvdb::v5_1::tools::clip
GridType::Ptr clip(const GridType &grid, const BBoxd &bbox, bool keepInterior=true)
Clip the given grid against a world-space bounding box and return a new grid containing the result...
Definition: Clip.h:375
openvdb::v5_1::tree::LeafNode< bool, Log2Dim >::numValues
static Index numValues()
Definition: LeafNodeBool.h:135
openvdb::v5_1::util::NodeMask::setOff
void setOff(Index32 n)
Set the nth bit off.
Definition: NodeMasks.h:459
openvdb::v5_1::util::NodeMask::save
void save(std::ostream &os) const
Definition: NodeMasks.h:567
openvdb::v5_1::math::Coord::x
Int32 x() const
Definition: Coord.h:157
openvdb::v5_1::util::NodeMask
Bit mask for the internal and leaf nodes of VDB. This is a 64-bit implementation. ...
Definition: NodeMasks.h:309