OpenVDB 5.1.0

LeafNodeMask.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_MASK_HAS_BEEN_INCLUDED
32 #define OPENVDB_TREE_LEAF_NODE_MASK_HAS_BEEN_INCLUDED
33
34 #include <openvdb/version.h>
35 #include <openvdb/Types.h>
36 #include <openvdb/io/Compression.h> // for io::readData(), etc.
37 #include <openvdb/math/Math.h> // for math::isZero()
38 #include <openvdb/util/NodeMasks.h>
39 #include "LeafNode.h"
40 #include "Iterator.h"
41 #include <iostream>
42 #include <sstream>
43 #include <string>
44 #include <type_traits>
45 #include <vector>
46
47
48 namespace openvdb {
49 OPENVDB_USE_VERSION_NAMESPACE
50 namespace OPENVDB_VERSION_NAME {
51 namespace tree {
52
56 template<Index Log2Dim>
57 class LeafNode<ValueMask, Log2Dim>
58 {
59 public:
60 using LeafNodeType = LeafNode<ValueMask, Log2Dim>;
61 using BuildType = ValueMask;// this is a rare case where
62 using ValueType = bool;// value type != build type
63 using Buffer = LeafBuffer<ValueType, Log2Dim>;// buffer uses the bool specialization
64 using NodeMaskType = util::NodeMask<Log2Dim>;
65 using Ptr = SharedPtr<LeafNodeType>;
66
67 // These static declarations must be on separate lines to avoid VC9 compiler errors.
68 static const Index LOG2DIM = Log2Dim; // needed by parent nodes
69 static const Index TOTAL = Log2Dim; // needed by parent nodes
70 static const Index DIM = 1 << TOTAL; // dimension along one coordinate direction
71 static const Index NUM_VALUES = 1 << 3 * Log2Dim;
72 static const Index NUM_VOXELS = NUM_VALUES; // total number of voxels represented by this node
73 static const Index SIZE = NUM_VALUES;
74 static const Index LEVEL = 0; // level 0 = leaf
75
78 template<typename OtherValueType>
79 struct ValueConverter { using Type = LeafNode<OtherValueType, Log2Dim>; };
80
83 template<typename OtherNodeType>
84 struct SameConfiguration {
85 static const bool value = SameLeafConfig<LOG2DIM, OtherNodeType>::value;
86 };
87
89 LeafNode();
90
95 explicit LeafNode(const Coord& xyz, bool value = false, bool dummy = false);
96
97 #if OPENVDB_ABI_VERSION_NUMBER >= 3
98 LeafNode(PartialCreate, const Coord& xyz, bool value = false, bool dummy = false);
100 #endif
101
103 LeafNode(const LeafNode&);
104
106 template<typename OtherValueType>
107 explicit LeafNode(const LeafNode<OtherValueType, Log2Dim>& other);
108
110 template<typename ValueType>
111 LeafNode(const LeafNode<ValueType, Log2Dim>& other, TopologyCopy);
112
114 template<typename ValueType>
117 LeafNode(const LeafNode<ValueType, Log2Dim>& other, bool offValue, bool onValue, TopologyCopy);
118 template<typename ValueType>
119 LeafNode(const LeafNode<ValueType, Log2Dim>& other, bool background, TopologyCopy);
121
123 ~LeafNode();
124
125 //
126 // Statistics
127 //
129 static Index log2dim() { return Log2Dim; }
131 static Index dim() { return DIM; }
133 static Index size() { return SIZE; }
135 static Index numValues() { return SIZE; }
137 static Index getLevel() { return LEVEL; }
139 static void getNodeLog2Dims(std::vector<Index>& dims) { dims.push_back(Log2Dim); }
141 static Index getChildDim() { return 1; }
143 static Index32 leafCount() { return 1; }
145 static Index32 nonLeafCount() { return 0; }
146
148 Index64 onVoxelCount() const { return mBuffer.mData.countOn(); }
150 Index64 offVoxelCount() const { return mBuffer.mData.countOff(); }
151 Index64 onLeafVoxelCount() const { return this->onVoxelCount(); }
152 Index64 offLeafVoxelCount() const { return this->offVoxelCount(); }
153 static Index64 onTileCount() { return 0; }
154 static Index64 offTileCount() { return 0; }
155
157 bool isEmpty() const { return mBuffer.mData.isOff(); }
159 bool isDense() const { return mBuffer.mData.isOn(); }
160
161 #if OPENVDB_ABI_VERSION_NUMBER >= 3
162 bool isAllocated() const { return true; }
169 bool allocate() { return true; }
170 #endif
171
173 Index64 memUsage() const;
174
178 void evalActiveBoundingBox(CoordBBox& bbox, bool visitVoxels = true) const;
179
182 CoordBBox getNodeBoundingBox() const { return CoordBBox::createCube(mOrigin, DIM); }
183
185 void setOrigin(const Coord& origin) { mOrigin = origin; }
187 const Coord& origin() const { return mOrigin; }
189 void getOrigin(Coord& origin) const { origin = mOrigin; }
190 void getOrigin(Int32& x, Int32& y, Int32& z) const { mOrigin.asXYZ(x, y, z); }
192
194 static Index coordToOffset(const Coord& xyz);
197 static Coord offsetToLocalCoord(Index n);
199 Coord offsetToGlobalCoord(Index n) const;
200
202 std::string str() const;
203
206 template<typename OtherType, Index OtherLog2Dim>
207 bool hasSameTopology(const LeafNode<OtherType, OtherLog2Dim>* other) const;
208
210 bool operator==(const LeafNode&) const;
211 bool operator!=(const LeafNode&) const;
212
213 //
214 // Buffer management
215 //
218 void swap(Buffer& other) { mBuffer.swap(other); }
219 const Buffer& buffer() const { return mBuffer; }
220 Buffer& buffer() { return mBuffer; }
221
222 //
223 // I/O methods
224 //
226 void readTopology(std::istream&, bool fromHalf = false);
228 void writeTopology(std::ostream&, bool toHalf = false) const;
229
231 void readBuffers(std::istream&, bool fromHalf = false);
232 void readBuffers(std::istream& is, const CoordBBox&, bool fromHalf = false);
234 void writeBuffers(std::ostream&, bool toHalf = false) const;
235
236 //
237 // Accessor methods
238 //
240 const bool& getValue(const Coord& xyz) const;
242 const bool& getValue(Index offset) const;
243
247 bool probeValue(const Coord& xyz, bool& val) const;
248
250 static Index getValueLevel(const Coord&) { return LEVEL; }
251
253 void setActiveState(const Coord& xyz, bool on);
255 void setActiveState(Index offset, bool on) { assert(offset<SIZE); mBuffer.mData.set(offset, on); }
256
258 void setValueOnly(const Coord& xyz, bool val);
260 void setValueOnly(Index offset, bool val) { assert(offset<SIZE); mBuffer.setValue(offset,val); }
261
263 void setValueOff(const Coord& xyz) { mBuffer.mData.setOff(this->coordToOffset(xyz)); }
265 void setValueOff(Index offset) { assert(offset < SIZE); mBuffer.mData.setOff(offset); }
266
268 void setValueOff(const Coord& xyz, bool val);
270 void setValueOff(Index offset, bool val);
271
273 void setValueOn(const Coord& xyz) { mBuffer.mData.setOn(this->coordToOffset(xyz)); }
275 void setValueOn(Index offset) { assert(offset < SIZE); mBuffer.mData.setOn(offset); }
276
278 void setValueOn(const Coord& xyz, bool val);
280 void setValue(const Coord& xyz, bool val) { this->setValueOn(xyz, val); }
282 void setValueOn(Index offset, bool val);
283
286 template<typename ModifyOp>
287 void modifyValue(Index offset, const ModifyOp& op);
290 template<typename ModifyOp>
291 void modifyValue(const Coord& xyz, const ModifyOp& op);
292
294 template<typename ModifyOp>
295 void modifyValueAndActiveState(const Coord& xyz, const ModifyOp& op);
296
298 void setValuesOn() { mBuffer.mData.setOn(); }
300 void setValuesOff() { mBuffer.mData.setOff(); }
301
303 bool isValueOn(const Coord& xyz) const { return mBuffer.mData.isOn(this->coordToOffset(xyz)); }
305 bool isValueOn(Index offset) const { assert(offset < SIZE); return mBuffer.mData.isOn(offset); }
306
308 static bool hasActiveTiles() { return false; }
309
311 void clip(const CoordBBox&, bool background);
312
314 void fill(const CoordBBox& bbox, bool value, bool = false);
316 void denseFill(const CoordBBox& bbox, bool value, bool = false) { this->fill(bbox, value); }
317
319 void fill(const bool& value, bool dummy = false);
320
332 template<typename DenseT>
333 void copyToDense(const CoordBBox& bbox, DenseT& dense) const;
334
351 template<typename DenseT>
352 void copyFromDense(const CoordBBox& bbox, const DenseT& dense, bool background, bool tolerance);
353
356 template<typename AccessorT>
357 const bool& getValueAndCache(const Coord& xyz, AccessorT&) const {return this->getValue(xyz);}
358
361 template<typename AccessorT>
362 bool isValueOnAndCache(const Coord& xyz, AccessorT&) const { return this->isValueOn(xyz); }
363
366 template<typename AccessorT>
367 void setValueAndCache(const Coord& xyz, bool val, AccessorT&) { this->setValueOn(xyz, val); }
368
372 template<typename AccessorT>
373 void setValueOnlyAndCache(const Coord& xyz, bool val, AccessorT&) {this->setValueOnly(xyz,val);}
374
377 template<typename AccessorT>
378 void setValueOffAndCache(const Coord& xyz, bool value, AccessorT&)
379 {
380 this->setValueOff(xyz, value);
381 }
382
386 template<typename ModifyOp, typename AccessorT>
387 void modifyValueAndCache(const Coord& xyz, const ModifyOp& op, AccessorT&)
388 {
389 this->modifyValue(xyz, op);
390 }
391
394 template<typename ModifyOp, typename AccessorT>
395 void modifyValueAndActiveStateAndCache(const Coord& xyz, const ModifyOp& op, AccessorT&)
396 {
397 this->modifyValueAndActiveState(xyz, op);
398 }
399
403 template<typename AccessorT>
404 void setActiveStateAndCache(const Coord& xyz, bool on, AccessorT&)
405 {
406 this->setActiveState(xyz, on);
407 }
408
412 template<typename AccessorT>
413 bool probeValueAndCache(const Coord& xyz, bool& val, AccessorT&) const
414 {
415 return this->probeValue(xyz, val);
416 }
417
420 template<typename AccessorT>
421 static Index getValueLevelAndCache(const Coord&, AccessorT&) { return LEVEL; }
422
426 const bool& getFirstValue() const { if (mBuffer.mData.isOn(0)) return Buffer::sOn; else return Buffer::sOff; }
430 const bool& getLastValue() const { if (mBuffer.mData.isOn(SIZE-1)) return Buffer::sOn; else return Buffer::sOff; }
431
435 bool isConstant(bool& constValue, bool& state, bool tolerance = 0) const;
436
442 bool medianAll() const;
443
451 Index medianOn(ValueType &value) const;
452
461 Index medianOff(ValueType &value) const;
462
464 bool isInactive() const { return mBuffer.mData.isOff(); }
465
468 void resetBackground(bool, bool) {}
469
471 void negate() { mBuffer.mData.toggle(); }
472
473 template<MergePolicy Policy>
474 void merge(const LeafNode& other, bool bg = false, bool otherBG = false);
475 template<MergePolicy Policy> void merge(bool tileValue, bool tileActive=false);
476
479 void voxelizeActiveTiles(bool = true) {}
480
487 template<typename OtherType>
488 void topologyUnion(const LeafNode<OtherType, Log2Dim>& other);
489
501 template<typename OtherType>
502 void topologyIntersection(const LeafNode<OtherType, Log2Dim>& other, const bool&);
503
515 template<typename OtherType>
516 void topologyDifference(const LeafNode<OtherType, Log2Dim>& other, const bool&);
517
518 template<typename CombineOp>
519 void combine(const LeafNode& other, CombineOp& op);
520 template<typename CombineOp>
521 void combine(bool, bool valueIsActive, CombineOp& op);
522
523 template<typename CombineOp, typename OtherType /*= bool*/>
524 void combine2(const LeafNode& other, const OtherType&, bool valueIsActive, CombineOp&);
525 template<typename CombineOp, typename OtherNodeT /*= LeafNode*/>
526 void combine2(bool, const OtherNodeT& other, bool valueIsActive, CombineOp&);
527 template<typename CombineOp, typename OtherNodeT /*= LeafNode*/>
528 void combine2(const LeafNode& b0, const OtherNodeT& b1, CombineOp&);
529
534 template<typename BBoxOp> void visitActiveBBox(BBoxOp&) const;
535
536 template<typename VisitorOp> void visit(VisitorOp&);
537 template<typename VisitorOp> void visit(VisitorOp&) const;
538
539 template<typename OtherLeafNodeType, typename VisitorOp>
540 void visit2Node(OtherLeafNodeType& other, VisitorOp&);
541 template<typename OtherLeafNodeType, typename VisitorOp>
542 void visit2Node(OtherLeafNodeType& other, VisitorOp&) const;
543 template<typename IterT, typename VisitorOp>
544 void visit2(IterT& otherIter, VisitorOp&, bool otherIsLHS = false);
545 template<typename IterT, typename VisitorOp>
546 void visit2(IterT& otherIter, VisitorOp&, bool otherIsLHS = false) const;
547
549 void prune(const ValueType& /*tolerance*/ = zeroVal<ValueType>()) {}
551 void addLeaf(LeafNode*) {}
552 template<typename AccessorT>
553 void addLeafAndCache(LeafNode*, AccessorT&) {}
554 template<typename NodeT>
555 NodeT* stealNode(const Coord&, const ValueType&, bool) { return nullptr; }
556 template<typename NodeT>
557 NodeT* probeNode(const Coord&) { return nullptr; }
558 template<typename NodeT>
559 const NodeT* probeConstNode(const Coord&) const { return nullptr; }
560 template<typename ArrayT> void getNodes(ArrayT&) const {}
561 template<typename ArrayT> void stealNodes(ArrayT&, const ValueType&, bool) {}
563
564 void addTile(Index level, const Coord&, bool val, bool active);
565 void addTile(Index offset, bool val, bool active);
566 template<typename AccessorT>
567 void addTileAndCache(Index level, const Coord&, bool val, bool active, AccessorT&);
568
570 LeafNode* touchLeaf(const Coord&) { return this; }
572 template<typename AccessorT>
573 LeafNode* touchLeafAndCache(const Coord&, AccessorT&) { return this; }
574 LeafNode* probeLeaf(const Coord&) { return this; }
575 template<typename AccessorT>
576 LeafNode* probeLeafAndCache(const Coord&, AccessorT&) { return this; }
577 template<typename NodeT, typename AccessorT>
578 NodeT* probeNodeAndCache(const Coord&, AccessorT&)
579 {
580 OPENVDB_NO_UNREACHABLE_CODE_WARNING_BEGIN
581 if (!(std::is_same<NodeT, LeafNode>::value)) return nullptr;
582 return reinterpret_cast<NodeT*>(this);
583 OPENVDB_NO_UNREACHABLE_CODE_WARNING_END
584 }
586
587 const LeafNode* probeLeaf(const Coord&) const { return this; }
589 template<typename AccessorT>
590 const LeafNode* probeLeafAndCache(const Coord&, AccessorT&) const { return this; }
591 const LeafNode* probeConstLeaf(const Coord&) const { return this; }
592 template<typename AccessorT>
593 const LeafNode* probeConstLeafAndCache(const Coord&, AccessorT&) const { return this; }
594 template<typename NodeT, typename AccessorT>
595 const NodeT* probeConstNodeAndCache(const Coord&, AccessorT&) const
596 {
597 OPENVDB_NO_UNREACHABLE_CODE_WARNING_BEGIN
598 if (!(std::is_same<NodeT, LeafNode>::value)) return nullptr;
599 return reinterpret_cast<const NodeT*>(this);
600 OPENVDB_NO_UNREACHABLE_CODE_WARNING_END
601 }
603
604 //
605 // Iterators
606 //
607 protected:
608 using MaskOnIter = typename NodeMaskType::OnIterator;
609 using MaskOffIter = typename NodeMaskType::OffIterator;
610 using MaskDenseIter = typename NodeMaskType::DenseIterator;
611
612 template<typename MaskIterT, typename NodeT, typename ValueT>
613 struct ValueIter:
614 // Derives from SparseIteratorBase, but can also be used as a dense iterator,
615 // if MaskIterT is a dense mask iterator type.
616 public SparseIteratorBase<MaskIterT, ValueIter<MaskIterT, NodeT, ValueT>, NodeT, ValueT>
617 {
618 using BaseT = SparseIteratorBase<MaskIterT, ValueIter, NodeT, ValueT>;
619
620 ValueIter() {}
621 ValueIter(const MaskIterT& iter, NodeT* parent): BaseT(iter, parent) {}
622
623 const bool& getItem(Index pos) const { return this->parent().getValue(pos); }
624 const bool& getValue() const { return this->getItem(this->pos()); }
625
626 // Note: setItem() can't be called on const iterators.
627 void setItem(Index pos, bool value) const { this->parent().setValueOnly(pos, value); }
628 // Note: setValue() can't be called on const iterators.
629 void setValue(bool value) const { this->setItem(this->pos(), value); }
630
631 // Note: modifyItem() can't be called on const iterators.
632 template<typename ModifyOp>
633 void modifyItem(Index n, const ModifyOp& op) const { this->parent().modifyValue(n, op); }
634 // Note: modifyValue() can't be called on const iterators.
635 template<typename ModifyOp>
636 void modifyValue(const ModifyOp& op) const { this->modifyItem(this->pos(), op); }
637 };
638
640 template<typename MaskIterT, typename NodeT>
641 struct ChildIter:
642 public SparseIteratorBase<MaskIterT, ChildIter<MaskIterT, NodeT>, NodeT, bool>
643 {
644 ChildIter() {}
645 ChildIter(const MaskIterT& iter, NodeT* parent): SparseIteratorBase<
646 MaskIterT, ChildIter<MaskIterT, NodeT>, NodeT, bool>(iter, parent) {}
647 };
648
649 template<typename NodeT, typename ValueT>
650 struct DenseIter: public DenseIteratorBase<
651 MaskDenseIter, DenseIter<NodeT, ValueT>, NodeT, /*ChildT=*/void, ValueT>
652 {
653 using BaseT = DenseIteratorBase<MaskDenseIter, DenseIter, NodeT, void, ValueT>;
654 using NonConstValueT = typename BaseT::NonConstValueType;
655
656 DenseIter() {}
657 DenseIter(const MaskDenseIter& iter, NodeT* parent): BaseT(iter, parent) {}
658
659 bool getItem(Index pos, void*& child, NonConstValueT& value) const
660 {
661 value = this->parent().getValue(pos);
662 child = nullptr;
663 return false; // no child
664 }
665
666 // Note: setItem() can't be called on const iterators.
667 //void setItem(Index pos, void* child) const {}
668
669 // Note: unsetItem() can't be called on const iterators.
670 void unsetItem(Index pos, const ValueT& val) const {this->parent().setValueOnly(pos, val);}
671 };
672
673 public:
674 using ValueOnIter = ValueIter<MaskOnIter, LeafNode, const bool>;
675 using ValueOnCIter = ValueIter<MaskOnIter, const LeafNode, const bool>;
676 using ValueOffIter = ValueIter<MaskOffIter, LeafNode, const bool>;
677 using ValueOffCIter = ValueIter<MaskOffIter, const LeafNode, const bool>;
678 using ValueAllIter = ValueIter<MaskDenseIter, LeafNode, const bool>;
679 using ValueAllCIter = ValueIter<MaskDenseIter, const LeafNode, const bool>;
680 using ChildOnIter = ChildIter<MaskOnIter, LeafNode>;
681 using ChildOnCIter = ChildIter<MaskOnIter, const LeafNode>;
682 using ChildOffIter = ChildIter<MaskOffIter, LeafNode>;
683 using ChildOffCIter = ChildIter<MaskOffIter, const LeafNode>;
684 using ChildAllIter = DenseIter<LeafNode, bool>;
685 using ChildAllCIter = DenseIter<const LeafNode, const bool>;
686
687 ValueOnCIter cbeginValueOn() const { return ValueOnCIter(mBuffer.mData.beginOn(), this); }
688 ValueOnCIter beginValueOn() const { return ValueOnCIter(mBuffer.mData.beginOn(), this); }
689 ValueOnIter beginValueOn() { return ValueOnIter(mBuffer.mData.beginOn(), this); }
690 ValueOffCIter cbeginValueOff() const { return ValueOffCIter(mBuffer.mData.beginOff(), this); }
691 ValueOffCIter beginValueOff() const { return ValueOffCIter(mBuffer.mData.beginOff(), this); }
692 ValueOffIter beginValueOff() { return ValueOffIter(mBuffer.mData.beginOff(), this); }
693 ValueAllCIter cbeginValueAll() const { return ValueAllCIter(mBuffer.mData.beginDense(), this); }
694 ValueAllCIter beginValueAll() const { return ValueAllCIter(mBuffer.mData.beginDense(), this); }
695 ValueAllIter beginValueAll() { return ValueAllIter(mBuffer.mData.beginDense(), this); }
696
697 ValueOnCIter cendValueOn() const { return ValueOnCIter(mBuffer.mData.endOn(), this); }
698 ValueOnCIter endValueOn() const { return ValueOnCIter(mBuffer.mData.endOn(), this); }
699 ValueOnIter endValueOn() { return ValueOnIter(mBuffer.mData.endOn(), this); }
700 ValueOffCIter cendValueOff() const { return ValueOffCIter(mBuffer.mData.endOff(), this); }
701 ValueOffCIter endValueOff() const { return ValueOffCIter(mBuffer.mData.endOff(), this); }
702 ValueOffIter endValueOff() { return ValueOffIter(mBuffer.mData.endOff(), this); }
703 ValueAllCIter cendValueAll() const { return ValueAllCIter(mBuffer.mData.endDense(), this); }
704 ValueAllCIter endValueAll() const { return ValueAllCIter(mBuffer.mData.endDense(), this); }
705 ValueAllIter endValueAll() { return ValueAllIter(mBuffer.mData.endDense(), this); }
706
707 // Note that [c]beginChildOn() and [c]beginChildOff() actually return end iterators,
708 // because leaf nodes have no children.
709 ChildOnCIter cbeginChildOn() const { return ChildOnCIter(mBuffer.mData.endOn(), this); }
710 ChildOnCIter beginChildOn() const { return ChildOnCIter(mBuffer.mData.endOn(), this); }
711 ChildOnIter beginChildOn() { return ChildOnIter(mBuffer.mData.endOn(), this); }
712 ChildOffCIter cbeginChildOff() const { return ChildOffCIter(mBuffer.mData.endOff(), this); }
713 ChildOffCIter beginChildOff() const { return ChildOffCIter(mBuffer.mData.endOff(), this); }
714 ChildOffIter beginChildOff() { return ChildOffIter(mBuffer.mData.endOff(), this); }
715 ChildAllCIter cbeginChildAll() const { return ChildAllCIter(mBuffer.mData.beginDense(), this); }
716 ChildAllCIter beginChildAll() const { return ChildAllCIter(mBuffer.mData.beginDense(), this); }
717 ChildAllIter beginChildAll() { return ChildAllIter(mBuffer.mData.beginDense(), this); }
718
719 ChildOnCIter cendChildOn() const { return ChildOnCIter(mBuffer.mData.endOn(), this); }
720 ChildOnCIter endChildOn() const { return ChildOnCIter(mBuffer.mData.endOn(), this); }
721 ChildOnIter endChildOn() { return ChildOnIter(mBuffer.mData.endOn(), this); }
722 ChildOffCIter cendChildOff() const { return ChildOffCIter(mBuffer.mData.endOff(), this); }
723 ChildOffCIter endChildOff() const { return ChildOffCIter(mBuffer.mData.endOff(), this); }
724 ChildOffIter endChildOff() { return ChildOffIter(mBuffer.mData.endOff(), this); }
725 ChildAllCIter cendChildAll() const { return ChildAllCIter(mBuffer.mData.endDense(), this); }
726 ChildAllCIter endChildAll() const { return ChildAllCIter(mBuffer.mData.endDense(), this); }
727 ChildAllIter endChildAll() { return ChildAllIter(mBuffer.mData.endDense(), this); }
728
729 //
730 // Mask accessors
731 //
732 bool isValueMaskOn(Index n) const { return mBuffer.mData.isOn(n); }
733 bool isValueMaskOn() const { return mBuffer.mData.isOn(); }
734 bool isValueMaskOff(Index n) const { return mBuffer.mData.isOff(n); }
735 bool isValueMaskOff() const { return mBuffer.mData.isOff(); }
736 const NodeMaskType& getValueMask() const { return mBuffer.mData; }
737 const NodeMaskType& valueMask() const { return mBuffer.mData; }
738 NodeMaskType& getValueMask() { return mBuffer.mData; }
739 void setValueMask(const NodeMaskType& mask) { mBuffer.mData = mask; }
740 bool isChildMaskOn(Index) const { return false; } // leaf nodes have no children
741 bool isChildMaskOff(Index) const { return true; }
742 bool isChildMaskOff() const { return true; }
743 protected:
744 void setValueMask(Index n, bool on) { mBuffer.mData.set(n, on); }
745 void setValueMaskOn(Index n) { mBuffer.mData.setOn(n); }
746 void setValueMaskOff(Index n) { mBuffer.mData.setOff(n); }
747
749 static void evalNodeOrigin(Coord& xyz) { xyz &= ~(DIM - 1); }
750
751 template<typename NodeT, typename VisitorOp, typename ChildAllIterT>
752 static inline void doVisit(NodeT&, VisitorOp&);
753
754 template<typename NodeT, typename OtherNodeT, typename VisitorOp,
755 typename ChildAllIterT, typename OtherChildAllIterT>
756 static inline void doVisit2Node(NodeT& self, OtherNodeT& other, VisitorOp&);
757
758 template<typename NodeT, typename VisitorOp,
759 typename ChildAllIterT, typename OtherChildAllIterT>
760 static inline void doVisit2(NodeT& self, OtherChildAllIterT&, VisitorOp&, bool otherIsLHS);
761
763 Buffer mBuffer;
764
766 Coord mOrigin;
767
768 private:
771 template<typename, Index> friend class LeafNode;
772
773 friend struct ValueIter<MaskOnIter, LeafNode, bool>;
774 friend struct ValueIter<MaskOffIter, LeafNode, bool>;
775 friend struct ValueIter<MaskDenseIter, LeafNode, bool>;
776 friend struct ValueIter<MaskOnIter, const LeafNode, bool>;
777 friend struct ValueIter<MaskOffIter, const LeafNode, bool>;
778 friend struct ValueIter<MaskDenseIter, const LeafNode, bool>;
779
781 friend class IteratorBase<MaskOnIter, LeafNode>;
784 friend class IteratorBase<MaskOffIter, LeafNode>;
785 friend class IteratorBase<MaskDenseIter, LeafNode>;
787
788 template<typename, Index> friend class LeafBuffer;
789
790 }; // class LeafNode<ValueMask>
791
792
794
795
796 template<Index Log2Dim>
797 inline
798 LeafNode<ValueMask, Log2Dim>::LeafNode()
799 : mOrigin(0, 0, 0)
800 {
801 }
802
803 template<Index Log2Dim>
804 inline
805 LeafNode<ValueMask, Log2Dim>::LeafNode(const Coord& xyz, bool value, bool active)
806 : mBuffer(value || active)
807 , mOrigin(xyz & (~(DIM - 1)))
808 {
809 }
810
811
812 #if OPENVDB_ABI_VERSION_NUMBER >= 3
813 template<Index Log2Dim>
814 inline
815 LeafNode<ValueMask, Log2Dim>::LeafNode(PartialCreate, const Coord& xyz, bool value, bool active)
816 : mBuffer(value || active)
817 , mOrigin(xyz & (~(DIM - 1)))
818 {
819 }
820 #endif
821
822
823 template<Index Log2Dim>
824 inline
825 LeafNode<ValueMask, Log2Dim>::LeafNode(const LeafNode &other)
826 : mBuffer(other.mBuffer)
827 , mOrigin(other.mOrigin)
828 {
829 }
830
831
832 // Copy-construct from a leaf node with the same configuration but a different ValueType.
833 template<Index Log2Dim>
834 template<typename ValueT>
835 inline
836 LeafNode<ValueMask, Log2Dim>::LeafNode(const LeafNode<ValueT, Log2Dim>& other)
837 : mBuffer(other.valueMask())
838 , mOrigin(other.origin())
839 {
840 }
841
842
843 template<Index Log2Dim>
844 template<typename ValueT>
845 inline
846 LeafNode<ValueMask, Log2Dim>::LeafNode(const LeafNode<ValueT, Log2Dim>& other,
847 bool, TopologyCopy)
848 : mBuffer(other.valueMask())// value = active state
849 , mOrigin(other.origin())
850 {
851 }
852
853
854 template<Index Log2Dim>
855 template<typename ValueT>
856 inline
857 LeafNode<ValueMask, Log2Dim>::LeafNode(const LeafNode<ValueT, Log2Dim>& other, TopologyCopy)
858 : mBuffer(other.valueMask())// value = active state
859 , mOrigin(other.origin())
860 {
861 }
862
863
864 template<Index Log2Dim>
865 template<typename ValueT>
866 inline
867 LeafNode<ValueMask, Log2Dim>::LeafNode(const LeafNode<ValueT, Log2Dim>& other,
868 bool offValue, bool onValue, TopologyCopy)
869 : mBuffer(other.valueMask())
870 , mOrigin(other.origin())
871 {
872 if (offValue==true) {
873 if (onValue==false) {
874 mBuffer.mData.toggle();
875 } else {
876 mBuffer.mData.setOn();
877 }
878 }
879 }
880
881
882 template<Index Log2Dim>
883 inline
884 LeafNode<ValueMask, Log2Dim>::~LeafNode()
885 {
886 }
887
888
890
891
892 template<Index Log2Dim>
893 inline Index64
894 LeafNode<ValueMask, Log2Dim>::memUsage() const
895 {
896 // Use sizeof(*this) to capture alignment-related padding
897 return sizeof(*this);
898 }
899
900
901 template<Index Log2Dim>
902 inline void
903 LeafNode<ValueMask, Log2Dim>::evalActiveBoundingBox(CoordBBox& bbox, bool visitVoxels) const
904 {
905 CoordBBox this_bbox = this->getNodeBoundingBox();
906 if (bbox.isInside(this_bbox)) return;//this LeafNode is already enclosed in the bbox
907 if (ValueOnCIter iter = this->cbeginValueOn()) {//any active values?
908 if (visitVoxels) {//use voxel granularity?
909 this_bbox.reset();
910 for(; iter; ++iter) this_bbox.expand(this->offsetToLocalCoord(iter.pos()));
911 this_bbox.translate(this->origin());
912 }
913 bbox.expand(this_bbox);
914 }
915 }
916
917
918 template<Index Log2Dim>
919 template<typename OtherType, Index OtherLog2Dim>
920 inline bool
921 LeafNode<ValueMask, Log2Dim>::hasSameTopology(const LeafNode<OtherType, OtherLog2Dim>* other) const
922 {
923 assert(other);
924 return (Log2Dim == OtherLog2Dim && mBuffer.mData == other->getValueMask());
925 }
926
927
928 template<Index Log2Dim>
929 inline std::string
930 LeafNode<ValueMask, Log2Dim>::str() const
931 {
932 std::ostringstream ostr;
933 ostr << "LeafNode @" << mOrigin << ": ";
934 for (Index32 n = 0; n < SIZE; ++n) ostr << (mBuffer.mData.isOn(n) ? '#' : '.');
935 return ostr.str();
936 }
937
938
940
941
942 template<Index Log2Dim>
943 inline Index
944 LeafNode<ValueMask, Log2Dim>::coordToOffset(const Coord& xyz)
945 {
946 assert ((xyz[0] & (DIM-1u)) < DIM && (xyz[1] & (DIM-1u)) < DIM && (xyz[2] & (DIM-1u)) < DIM);
947 return ((xyz[0] & (DIM-1u)) << 2*Log2Dim)
948 + ((xyz[1] & (DIM-1u)) << Log2Dim)
949 + (xyz[2] & (DIM-1u));
950 }
951
952
953 template<Index Log2Dim>
954 inline Coord
955 LeafNode<ValueMask, Log2Dim>::offsetToLocalCoord(Index n)
956 {
957 assert(n < (1 << 3*Log2Dim));
958 Coord xyz;
959 xyz.setX(n >> 2*Log2Dim);
960 n &= ((1 << 2*Log2Dim) - 1);
961 xyz.setY(n >> Log2Dim);
962 xyz.setZ(n & ((1 << Log2Dim) - 1));
963 return xyz;
964 }
965
966
967 template<Index Log2Dim>
968 inline Coord
969 LeafNode<ValueMask, Log2Dim>::offsetToGlobalCoord(Index n) const
970 {
971 return (this->offsetToLocalCoord(n) + this->origin());
972 }
973
974
976
977
978 template<Index Log2Dim>
979 inline void
980 LeafNode<ValueMask, Log2Dim>::readTopology(std::istream& is, bool /*fromHalf*/)
981 {
982 mBuffer.mData.load(is);
983 }
984
985
986 template<Index Log2Dim>
987 inline void
988 LeafNode<ValueMask, Log2Dim>::writeTopology(std::ostream& os, bool /*toHalf*/) const
989 {
990 mBuffer.mData.save(os);
991 }
992
993
994 template<Index Log2Dim>
995 inline void
996 LeafNode<ValueMask, Log2Dim>::readBuffers(std::istream& is, const CoordBBox& clipBBox, bool fromHalf)
997 {
998 // Boolean LeafNodes don't currently implement lazy loading.
999 // Instead, load the full buffer, then clip it.
1000
1001 this->readBuffers(is, fromHalf);
1002
1003 // Get this tree's background value.
1004 bool background = false;
1005 if (const void* bgPtr = io::getGridBackgroundValuePtr(is)) {
1006 background = *static_cast<const bool*>(bgPtr);
1007 }
1008 this->clip(clipBBox, background);
1009 }
1010
1011
1012 template<Index Log2Dim>
1013 inline void
1014 LeafNode<ValueMask, Log2Dim>::readBuffers(std::istream& is, bool /*fromHalf*/)
1015 {
1016 // Read in the value mask = buffer.
1017 mBuffer.mData.load(is);
1018 // Read in the origin.
1019 is.read(reinterpret_cast<char*>(&mOrigin), sizeof(Coord::ValueType) * 3);
1020 }
1021
1022
1023 template<Index Log2Dim>
1024 inline void
1025 LeafNode<ValueMask, Log2Dim>::writeBuffers(std::ostream& os, bool /*toHalf*/) const
1026 {
1027 // Write out the value mask = buffer.
1028 mBuffer.mData.save(os);
1029 // Write out the origin.
1030 os.write(reinterpret_cast<const char*>(&mOrigin), sizeof(Coord::ValueType) * 3);
1031 }
1032
1033
1035
1036
1037 template<Index Log2Dim>
1038 inline bool
1039 LeafNode<ValueMask, Log2Dim>::operator==(const LeafNode& other) const
1040 {
1041 return mOrigin == other.mOrigin && mBuffer == other.mBuffer;
1042 }
1043
1044
1045 template<Index Log2Dim>
1046 inline bool
1047 LeafNode<ValueMask, Log2Dim>::operator!=(const LeafNode& other) const
1048 {
1049 return !(this->operator==(other));
1050 }
1051
1052
1054
1055
1056 template<Index Log2Dim>
1057 inline bool
1058 LeafNode<ValueMask, Log2Dim>::isConstant(bool& constValue, bool& state, bool) const
1059 {
1060 if (!mBuffer.mData.isConstant(state)) return false;
1061
1062 constValue = state;
1063 return true;
1064 }
1065
1066
1068
1069 template<Index Log2Dim>
1070 inline bool
1071 LeafNode<ValueMask, Log2Dim>::medianAll() const
1072 {
1073 const Index countTrue = mBuffer.mData.countOn();
1074 return countTrue > (NUM_VALUES >> 1);
1075 }
1076
1077 template<Index Log2Dim>
1078 inline Index
1079 LeafNode<ValueMask, Log2Dim>::medianOn(bool& state) const
1080 {
1081 const Index countTrueOn = mBuffer.mData.countOn();
1082 state = true;//since value and state are the same for this specialization of the leaf node
1083 return countTrueOn;
1084 }
1085
1086 template<Index Log2Dim>
1087 inline Index
1088 LeafNode<ValueMask, Log2Dim>::medianOff(bool& state) const
1089 {
1090 const Index countFalseOff = mBuffer.mData.countOff();
1091 state = false;//since value and state are the same for this specialization of the leaf node
1092 return countFalseOff;
1093 }
1094
1095
1097
1098
1099 template<Index Log2Dim>
1100 inline void
1101 LeafNode<ValueMask, Log2Dim>::addTile(Index /*level*/, const Coord& xyz, bool val, bool active)
1102 {
1103 this->addTile(this->coordToOffset(xyz), val, active);
1104 }
1105
1106 template<Index Log2Dim>
1107 inline void
1108 LeafNode<ValueMask, Log2Dim>::addTile(Index offset, bool val, bool active)
1109 {
1110 assert(offset < SIZE);
1111 this->setValueOnly(offset, val);
1112 this->setActiveState(offset, active);
1113 }
1114
1115 template<Index Log2Dim>
1116 template<typename AccessorT>
1117 inline void
1118 LeafNode<ValueMask, Log2Dim>::addTileAndCache(Index level, const Coord& xyz,
1119 bool val, bool active, AccessorT&)
1120 {
1121 this->addTile(level, xyz, val, active);
1122 }
1123
1124
1126
1127
1128 template<Index Log2Dim>
1129 inline const bool&
1130 LeafNode<ValueMask, Log2Dim>::getValue(const Coord& xyz) const
1131 {
1132 // This *CANNOT* use operator ? because Visual C++
1133 if (mBuffer.mData.isOn(this->coordToOffset(xyz))) return Buffer::sOn; else return Buffer::sOff;
1134 }
1135
1136
1137 template<Index Log2Dim>
1138 inline const bool&
1139 LeafNode<ValueMask, Log2Dim>::getValue(Index offset) const
1140 {
1141 assert(offset < SIZE);
1142 // This *CANNOT* use operator ? for Windows
1143 if (mBuffer.mData.isOn(offset)) return Buffer::sOn; else return Buffer::sOff;
1144 }
1145
1146
1147 template<Index Log2Dim>
1148 inline bool
1149 LeafNode<ValueMask, Log2Dim>::probeValue(const Coord& xyz, bool& val) const
1150 {
1151 const Index offset = this->coordToOffset(xyz);
1152 val = mBuffer.mData.isOn(offset);
1153 return val;
1154 }
1155
1156
1157 template<Index Log2Dim>
1158 inline void
1159 LeafNode<ValueMask, Log2Dim>::setValueOn(const Coord& xyz, bool val)
1160 {
1161 this->setValueOn(this->coordToOffset(xyz), val);
1162 }
1163
1164
1165 template<Index Log2Dim>
1166 inline void
1167 LeafNode<ValueMask, Log2Dim>::setValueOn(Index offset, bool val)
1168 {
1169 assert(offset < SIZE);
1170 mBuffer.mData.set(offset, val);
1171 }
1172
1173
1174 template<Index Log2Dim>
1175 inline void
1176 LeafNode<ValueMask, Log2Dim>::setValueOnly(const Coord& xyz, bool val)
1177 {
1178 this->setValueOnly(this->coordToOffset(xyz), val);
1179 }
1180
1181
1182 template<Index Log2Dim>
1183 inline void
1184 LeafNode<ValueMask, Log2Dim>::setActiveState(const Coord& xyz, bool on)
1185 {
1186 mBuffer.mData.set(this->coordToOffset(xyz), on);
1187 }
1188
1189
1190 template<Index Log2Dim>
1191 inline void
1192 LeafNode<ValueMask, Log2Dim>::setValueOff(const Coord& xyz, bool val)
1193 {
1194 this->setValueOff(this->coordToOffset(xyz), val);
1195 }
1196
1197
1198 template<Index Log2Dim>
1199 inline void
1200 LeafNode<ValueMask, Log2Dim>::setValueOff(Index offset, bool val)
1201 {
1202 assert(offset < SIZE);
1203 mBuffer.mData.set(offset, val);
1204 }
1205
1206
1207 template<Index Log2Dim>
1208 template<typename ModifyOp>
1209 inline void
1210 LeafNode<ValueMask, Log2Dim>::modifyValue(Index offset, const ModifyOp& op)
1211 {
1212 bool val = mBuffer.mData.isOn(offset);
1213 op(val);
1214 mBuffer.mData.set(offset, val);
1215 }
1216
1217
1218 template<Index Log2Dim>
1219 template<typename ModifyOp>
1220 inline void
1221 LeafNode<ValueMask, Log2Dim>::modifyValue(const Coord& xyz, const ModifyOp& op)
1222 {
1223 this->modifyValue(this->coordToOffset(xyz), op);
1224 }
1225
1226
1227 template<Index Log2Dim>
1228 template<typename ModifyOp>
1229 inline void
1230 LeafNode<ValueMask, Log2Dim>::modifyValueAndActiveState(const Coord& xyz, const ModifyOp& op)
1231 {
1232 const Index offset = this->coordToOffset(xyz);
1233 bool val = mBuffer.mData.isOn(offset), state = val;
1234 op(val, state);
1235 mBuffer.mData.set(offset, val);
1236 }
1237
1238
1240
1241
1242 template<Index Log2Dim>
1243 template<MergePolicy Policy>
1244 inline void
1245 LeafNode<ValueMask, Log2Dim>::merge(const LeafNode& other, bool /*bg*/, bool /*otherBG*/)
1246 {
1247 OPENVDB_NO_UNREACHABLE_CODE_WARNING_BEGIN
1248 if (Policy == MERGE_NODES) return;
1249 mBuffer.mData |= other.mBuffer.mData;
1250 OPENVDB_NO_UNREACHABLE_CODE_WARNING_END
1251 }
1252
1253 template<Index Log2Dim>
1254 template<MergePolicy Policy>
1255 inline void
1256 LeafNode<ValueMask, Log2Dim>::merge(bool tileValue, bool)
1257 {
1258 OPENVDB_NO_UNREACHABLE_CODE_WARNING_BEGIN
1259 if (Policy != MERGE_ACTIVE_STATES_AND_NODES) return;
1260 if (tileValue) mBuffer.mData.setOn();
1261 OPENVDB_NO_UNREACHABLE_CODE_WARNING_END
1262 }
1263
1264
1266
1267
1268 template<Index Log2Dim>
1269 template<typename OtherType>
1270 inline void
1271 LeafNode<ValueMask, Log2Dim>::topologyUnion(const LeafNode<OtherType, Log2Dim>& other)
1272 {
1273 mBuffer.mData |= other.valueMask();
1274 }
1275
1276
1277 template<Index Log2Dim>
1278 template<typename OtherType>
1279 inline void
1280 LeafNode<ValueMask, Log2Dim>::topologyIntersection(const LeafNode<OtherType, Log2Dim>& other,
1281 const bool&)
1282 {
1283 mBuffer.mData &= other.valueMask();
1284 }
1285
1286
1287 template<Index Log2Dim>
1288 template<typename OtherType>
1289 inline void
1290 LeafNode<ValueMask, Log2Dim>::topologyDifference(const LeafNode<OtherType, Log2Dim>& other,
1291 const bool&)
1292 {
1293 mBuffer.mData &= !other.valueMask();
1294 }
1295
1296
1298
1299
1300 template<Index Log2Dim>
1301 inline void
1302 LeafNode<ValueMask, Log2Dim>::clip(const CoordBBox& clipBBox, bool background)
1303 {
1304 CoordBBox nodeBBox = this->getNodeBoundingBox();
1305 if (!clipBBox.hasOverlap(nodeBBox)) {
1306 // This node lies completely outside the clipping region. Fill it with background tiles.
1307 this->fill(nodeBBox, background, /*active=*/false);
1308 } else if (clipBBox.isInside(nodeBBox)) {
1309 // This node lies completely inside the clipping region. Leave it intact.
1310 return;
1311 }
1312
1313 // This node isn't completely contained inside the clipping region.
1314 // Set any voxels that lie outside the region to the background value.
1315
1316 // Construct a boolean mask that is on inside the clipping region and off outside it.
1317 NodeMaskType mask;
1318 nodeBBox.intersect(clipBBox);
1319 Coord xyz;
1320 int &x = xyz.x(), &y = xyz.y(), &z = xyz.z();
1321 for (x = nodeBBox.min().x(); x <= nodeBBox.max().x(); ++x) {
1322 for (y = nodeBBox.min().y(); y <= nodeBBox.max().y(); ++y) {
1323 for (z = nodeBBox.min().z(); z <= nodeBBox.max().z(); ++z) {
1324 mask.setOn(static_cast<Index32>(this->coordToOffset(xyz)));
1325 }
1326 }
1327 }
1328
1329 // Set voxels that lie in the inactive region of the mask (i.e., outside
1330 // the clipping region) to the background value.
1331 for (MaskOffIter maskIter = mask.beginOff(); maskIter; ++maskIter) {
1332 this->setValueOff(maskIter.pos(), background);
1333 }
1334 }
1335
1336
1338
1339
1340 template<Index Log2Dim>
1341 inline void
1342 LeafNode<ValueMask, Log2Dim>::fill(const CoordBBox& bbox, bool value, bool)
1343 {
1344 auto clippedBBox = this->getNodeBoundingBox();
1345 clippedBBox.intersect(bbox);
1346 if (!clippedBBox) return;
1347
1348 for (Int32 x = clippedBBox.min().x(); x <= clippedBBox.max().x(); ++x) {
1349 const Index offsetX = (x & (DIM-1u))<<2*Log2Dim;
1350 for (Int32 y = clippedBBox.min().y(); y <= clippedBBox.max().y(); ++y) {
1351 const Index offsetXY = offsetX + ((y & (DIM-1u))<< Log2Dim);
1352 for (Int32 z = clippedBBox.min().z(); z <= clippedBBox.max().z(); ++z) {
1353 const Index offset = offsetXY + (z & (DIM-1u));
1354 mBuffer.mData.set(offset, value);
1355 }
1356 }
1357 }
1358 }
1359
1360 template<Index Log2Dim>
1361 inline void
1362 LeafNode<ValueMask, Log2Dim>::fill(const bool& value, bool)
1363 {
1364 mBuffer.fill(value);
1365 }
1366
1367
1369
1370
1371 template<Index Log2Dim>
1372 template<typename DenseT>
1373 inline void
1374 LeafNode<ValueMask, Log2Dim>::copyToDense(const CoordBBox& bbox, DenseT& dense) const
1375 {
1376 using DenseValueType = typename DenseT::ValueType;
1377
1378 const size_t xStride = dense.xStride(), yStride = dense.yStride(), zStride = dense.zStride();
1379 const Coord& min = dense.bbox().min();
1380 DenseValueType* t0 = dense.data() + zStride * (bbox.min()[2] - min[2]); // target array
1381 const Int32 n0 = bbox.min()[2] & (DIM-1u);
1382 for (Int32 x = bbox.min()[0], ex = bbox.max()[0] + 1; x < ex; ++x) {
1383 DenseValueType* t1 = t0 + xStride * (x - min[0]);
1384 const Int32 n1 = n0 + ((x & (DIM-1u)) << 2*LOG2DIM);
1385 for (Int32 y = bbox.min()[1], ey = bbox.max()[1] + 1; y < ey; ++y) {
1386 DenseValueType* t2 = t1 + yStride * (y - min[1]);
1387 Int32 n2 = n1 + ((y & (DIM-1u)) << LOG2DIM);
1388 for (Int32 z = bbox.min()[2], ez = bbox.max()[2] + 1; z < ez; ++z, t2 += zStride) {
1389 *t2 = DenseValueType(mBuffer.mData.isOn(n2++));
1390 }
1391 }
1392 }
1393 }
1394
1395
1396 template<Index Log2Dim>
1397 template<typename DenseT>
1398 inline void
1399 LeafNode<ValueMask, Log2Dim>::copyFromDense(const CoordBBox& bbox, const DenseT& dense,
1400 bool background, bool tolerance)
1401 {
1402 using DenseValueType = typename DenseT::ValueType;
1403 struct Local {
1404 inline static bool toBool(const DenseValueType& v) { return !math::isZero(v); }
1405 };
1406
1407 const size_t xStride = dense.xStride(), yStride = dense.yStride(), zStride = dense.zStride();
1408 const Coord& min = dense.bbox().min();
1409 const DenseValueType* s0 = dense.data() + zStride * (bbox.min()[2] - min[2]); // source
1410 const Int32 n0 = bbox.min()[2] & (DIM-1u);
1411 for (Int32 x = bbox.min()[0], ex = bbox.max()[0] + 1; x < ex; ++x) {
1412 const DenseValueType* s1 = s0 + xStride * (x - min[0]);
1413 const Int32 n1 = n0 + ((x & (DIM-1u)) << 2*LOG2DIM);
1414 for (Int32 y = bbox.min()[1], ey = bbox.max()[1] + 1; y < ey; ++y) {
1415 const DenseValueType* s2 = s1 + yStride * (y - min[1]);
1416 Int32 n2 = n1 + ((y & (DIM-1u)) << LOG2DIM);
1417 for (Int32 z = bbox.min()[2], ez = bbox.max()[2]+1; z < ez; ++z, ++n2, s2 += zStride) {
1418 // Note: if tolerance is true (i.e., 1), then all boolean values compare equal.
1419 if (tolerance || (background == Local::toBool(*s2))) {
1420 mBuffer.mData.set(n2, background);
1421 } else {
1422 mBuffer.mData.set(n2, Local::toBool(*s2));
1423 }
1424 }
1425 }
1426 }
1427 }
1428
1429
1431
1432
1433 template<Index Log2Dim>
1434 template<typename CombineOp>
1435 inline void
1436 LeafNode<ValueMask, Log2Dim>::combine(const LeafNode& other, CombineOp& op)
1437 {
1438 CombineArgs<bool> args;
1439 for (Index i = 0; i < SIZE; ++i) {
1440 bool result = false, aVal = mBuffer.mData.isOn(i), bVal = other.mBuffer.mData.isOn(i);
1441 op(args.setARef(aVal)
1442 .setAIsActive(aVal)
1443 .setBRef(bVal)
1444 .setBIsActive(bVal)
1445 .setResultRef(result));
1446 mBuffer.mData.set(i, result);
1447 }
1448 }
1449
1450
1451 template<Index Log2Dim>
1452 template<typename CombineOp>
1453 inline void
1454 LeafNode<ValueMask, Log2Dim>::combine(bool value, bool valueIsActive, CombineOp& op)
1455 {
1456 CombineArgs<bool> args;
1457 args.setBRef(value).setBIsActive(valueIsActive);
1458 for (Index i = 0; i < SIZE; ++i) {
1459 bool result = false, aVal = mBuffer.mData.isOn(i);
1460 op(args.setARef(aVal)
1461 .setAIsActive(aVal)
1462 .setResultRef(result));
1463 mBuffer.mData.set(i, result);
1464 }
1465 }
1466
1467
1469
1470
1471 template<Index Log2Dim>
1472 template<typename CombineOp, typename OtherType>
1473 inline void
1474 LeafNode<ValueMask, Log2Dim>::combine2(const LeafNode& other, const OtherType& value,
1475 bool valueIsActive, CombineOp& op)
1476 {
1477 CombineArgs<bool, OtherType> args;
1478 args.setBRef(value).setBIsActive(valueIsActive);
1479 for (Index i = 0; i < SIZE; ++i) {
1480 bool result = false, aVal = other.mBuffer.mData.isOn(i);
1481 op(args.setARef(aVal)
1482 .setAIsActive(aVal)
1483 .setResultRef(result));
1484 mBuffer.mData.set(i, result);
1485 }
1486 }
1487
1488
1489 template<Index Log2Dim>
1490 template<typename CombineOp, typename OtherNodeT>
1491 inline void
1492 LeafNode<ValueMask, Log2Dim>::combine2(bool value, const OtherNodeT& other,
1493 bool valueIsActive, CombineOp& op)
1494 {
1495 CombineArgs<bool, typename OtherNodeT::ValueType> args;
1496 args.setARef(value).setAIsActive(valueIsActive);
1497 for (Index i = 0; i < SIZE; ++i) {
1498 bool result = false, bVal = other.mBuffer.mData.isOn(i);
1499 op(args.setBRef(bVal)
1500 .setBIsActive(bVal)
1501 .setResultRef(result));
1502 mBuffer.mData.set(i, result);
1503 }
1504 }
1505
1506
1507 template<Index Log2Dim>
1508 template<typename CombineOp, typename OtherNodeT>
1509 inline void
1510 LeafNode<ValueMask, Log2Dim>::combine2(const LeafNode& b0, const OtherNodeT& b1, CombineOp& op)
1511 {
1512 CombineArgs<bool, typename OtherNodeT::ValueType> args;
1513 for (Index i = 0; i < SIZE; ++i) {
1514 bool result = false, b0Val = b0.mBuffer.mData.isOn(i), b1Val = b1.mBuffer.mData.isOn(i);
1515 op(args.setARef(b0Val)
1516 .setAIsActive(b0Val)
1517 .setBRef(b1Val)
1518 .setBIsActive(b1Val)
1519 .setResultRef(result));
1520 mBuffer.mData.set(i, result);
1521 }
1522 }
1523
1524
1526
1527 template<Index Log2Dim>
1528 template<typename BBoxOp>
1529 inline void
1530 LeafNode<ValueMask, Log2Dim>::visitActiveBBox(BBoxOp& op) const
1531 {
1532 if (op.template descent<LEVEL>()) {
1533 for (ValueOnCIter i=this->cbeginValueOn(); i; ++i) {
1534 #ifdef _MSC_VER
1535 op.operator()<LEVEL>(CoordBBox::createCube(i.getCoord(), 1));
1536 #else
1537 op.template operator()<LEVEL>(CoordBBox::createCube(i.getCoord(), 1));
1538 #endif
1539 }
1540 } else {
1541 #ifdef _MSC_VER
1542 op.operator()<LEVEL>(this->getNodeBoundingBox());
1543 #else
1544 op.template operator()<LEVEL>(this->getNodeBoundingBox());
1545 #endif
1546 }
1547 }
1548
1549
1550 template<Index Log2Dim>
1551 template<typename VisitorOp>
1552 inline void
1553 LeafNode<ValueMask, Log2Dim>::visit(VisitorOp& op)
1554 {
1555 doVisit<LeafNode, VisitorOp, ChildAllIter>(*this, op);
1556 }
1557
1558
1559 template<Index Log2Dim>
1560 template<typename VisitorOp>
1561 inline void
1562 LeafNode<ValueMask, Log2Dim>::visit(VisitorOp& op) const
1563 {
1564 doVisit<const LeafNode, VisitorOp, ChildAllCIter>(*this, op);
1565 }
1566
1567
1568 template<Index Log2Dim>
1569 template<typename NodeT, typename VisitorOp, typename ChildAllIterT>
1570 inline void
1571 LeafNode<ValueMask, Log2Dim>::doVisit(NodeT& self, VisitorOp& op)
1572 {
1573 for (ChildAllIterT iter = self.beginChildAll(); iter; ++iter) {
1574 op(iter);
1575 }
1576 }
1577
1578
1580
1581
1582 template<Index Log2Dim>
1583 template<typename OtherLeafNodeType, typename VisitorOp>
1584 inline void
1585 LeafNode<ValueMask, Log2Dim>::visit2Node(OtherLeafNodeType& other, VisitorOp& op)
1586 {
1587 doVisit2Node<LeafNode, OtherLeafNodeType, VisitorOp, ChildAllIter,
1588 typename OtherLeafNodeType::ChildAllIter>(*this, other, op);
1589 }
1590
1591
1592 template<Index Log2Dim>
1593 template<typename OtherLeafNodeType, typename VisitorOp>
1594 inline void
1595 LeafNode<ValueMask, Log2Dim>::visit2Node(OtherLeafNodeType& other, VisitorOp& op) const
1596 {
1597 doVisit2Node<const LeafNode, OtherLeafNodeType, VisitorOp, ChildAllCIter,
1598 typename OtherLeafNodeType::ChildAllCIter>(*this, other, op);
1599 }
1600
1601
1602 template<Index Log2Dim>
1603 template<
1604 typename NodeT,
1605 typename OtherNodeT,
1606 typename VisitorOp,
1607 typename ChildAllIterT,
1608 typename OtherChildAllIterT>
1609 inline void
1610 LeafNode<ValueMask, Log2Dim>::doVisit2Node(NodeT& self, OtherNodeT& other, VisitorOp& op)
1611 {
1612 // Allow the two nodes to have different ValueTypes, but not different dimensions.
1613 static_assert(OtherNodeT::SIZE == NodeT::SIZE,
1614 "can't visit nodes of different sizes simultaneously");
1615 static_assert(OtherNodeT::LEVEL == NodeT::LEVEL,
1616 "can't visit nodes at different tree levels simultaneously");
1617
1618 ChildAllIterT iter = self.beginChildAll();
1619 OtherChildAllIterT otherIter = other.beginChildAll();
1620
1621 for ( ; iter && otherIter; ++iter, ++otherIter) {
1622 op(iter, otherIter);
1623 }
1624 }
1625
1626
1628
1629
1630 template<Index Log2Dim>
1631 template<typename IterT, typename VisitorOp>
1632 inline void
1633 LeafNode<ValueMask, Log2Dim>::visit2(IterT& otherIter, VisitorOp& op, bool otherIsLHS)
1634 {
1635 doVisit2<LeafNode, VisitorOp, ChildAllIter, IterT>(*this, otherIter, op, otherIsLHS);
1636 }
1637
1638
1639 template<Index Log2Dim>
1640 template<typename IterT, typename VisitorOp>
1641 inline void
1642 LeafNode<ValueMask, Log2Dim>::visit2(IterT& otherIter, VisitorOp& op, bool otherIsLHS) const
1643 {
1644 doVisit2<const LeafNode, VisitorOp, ChildAllCIter, IterT>(*this, otherIter, op, otherIsLHS);
1645 }
1646
1647
1648 template<Index Log2Dim>
1649 template<
1650 typename NodeT,
1651 typename VisitorOp,
1652 typename ChildAllIterT,
1653 typename OtherChildAllIterT>
1654 inline void
1655 LeafNode<ValueMask, Log2Dim>::doVisit2(NodeT& self, OtherChildAllIterT& otherIter,
1656 VisitorOp& op, bool otherIsLHS)
1657 {
1658 if (!otherIter) return;
1659
1660 if (otherIsLHS) {
1661 for (ChildAllIterT iter = self.beginChildAll(); iter; ++iter) {
1662 op(otherIter, iter);
1663 }
1664 } else {
1665 for (ChildAllIterT iter = self.beginChildAll(); iter; ++iter) {
1666 op(iter, otherIter);
1667 }
1668 }
1669 }
1670
1671 } // namespace tree
1672 } // namespace OPENVDB_VERSION_NAME
1673 } // namespace openvdb
1674
1675 #endif // OPENVDB_TREE_LEAF_NODE_MASK_HAS_BEEN_INCLUDED
1676
1677 // Copyright (c) 2012-2018 DreamWorks Animation LLC
1678 // All rights reserved. This software is distributed under the
1679 // Mozilla Public License 2.0 ( http://www.mozilla.org/MPL/2.0/ )
openvdb::v5_1::tree::LeafNode< ValueMask, Log2Dim >::setValuesOff
void setValuesOff()
Mark all voxels as inactive but don&#39;t change their values.
Definition: LeafNodeMask.h:300
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< ValueMask, Log2Dim >::ValueType
bool ValueType
Definition: LeafNodeMask.h:62
openvdb::v5_1::Index32
uint32_t Index32
Definition: Types.h:59
openvdb::v5_1::tree::LeafNode::DIM
static const Index DIM
Definition: LeafNode.h:77
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< ValueMask, Log2Dim >::setOrigin
void setOrigin(const Coord &origin)
Set the grid index coordinates of this node&#39;s local origin.
Definition: LeafNodeMask.h:185
openvdb::v5_1::tree::LeafNode< ValueMask, Log2Dim >::touchLeafAndCache
LeafNode * touchLeafAndCache(const Coord &, AccessorT &)
Return a pointer to this node.
Definition: LeafNodeMask.h:573
openvdb::v5_1::tree::LeafNode::LEVEL
static const Index LEVEL
Definition: LeafNode.h:81
openvdb::v5_1::tree::LeafNode< ValueMask, Log2Dim >::ValueIter::setItem
void setItem(Index pos, bool value) const
Definition: LeafNodeMask.h:627
openvdb::v5_1::tree::LeafNode< ValueMask, Log2Dim >::isValueOn
bool isValueOn(Index offset) const
Return true if the voxel at the given offset is active.
Definition: LeafNodeMask.h:305
openvdb::v5_1::tree::LeafNode< ValueMask, Log2Dim >::ValueIter::modifyItem
void modifyItem(Index n, const ModifyOp &op) const
Definition: LeafNodeMask.h:633
openvdb::v5_1::tree::LeafNode< ValueMask, Log2Dim >::ValueIter::getItem
const bool & getItem(Index pos) const
Definition: LeafNodeMask.h:623
openvdb::v5_1::tree::LeafNode< ValueMask, Log2Dim >::cbeginValueOn
ValueOnCIter cbeginValueOn() const
Definition: LeafNodeMask.h:687
openvdb::v5_1::tree::LeafNode< ValueMask, Log2Dim >::probeConstNode
const NodeT * probeConstNode(const Coord &) const
This function exists only to enable template instantiation.
Definition: LeafNodeMask.h:559
openvdb::v5_1::tree::LeafNode< ValueMask, Log2Dim >::beginValueOff
ValueOffCIter beginValueOff() const
Definition: LeafNodeMask.h:691
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::math::CoordBBox::max
const Coord & max() const
Definition: Coord.h:338
openvdb::v5_1::tree::LeafNode< ValueMask, Log2Dim >::getValueMask
NodeMaskType & getValueMask()
Definition: LeafNodeMask.h:738
openvdb::v5_1::tree::IteratorBase
Base class for iterators over internal and leaf nodes.
Definition: Iterator.h:56
openvdb::v5_1::tree::LeafNode< ValueMask, Log2Dim >::ValueIter::getValue
const bool & getValue() const
Definition: LeafNodeMask.h:624
openvdb::v5_1::tree::LeafNode< ValueMask, Log2Dim >::endChildOn
ChildOnCIter endChildOn() const
Definition: LeafNodeMask.h:720
Compression.h
openvdb::v5_1::tree::LeafNode::LOG2DIM
static const Index LOG2DIM
Definition: LeafNode.h:75
openvdb::v5_1::tree::LeafNode< ValueMask, Log2Dim >::beginValueOn
ValueOnIter beginValueOn()
Definition: LeafNodeMask.h:689
openvdb::v5_1::tree::LeafNode< ValueMask, Log2Dim >::addLeafAndCache
void addLeafAndCache(LeafNode *, AccessorT &)
This function exists only to enable template instantiation.
Definition: LeafNodeMask.h:553
openvdb::v5_1::tree::LeafNode< ValueMask, Log2Dim >::isEmpty
bool isEmpty() const
Return true if this node has no active voxels.
Definition: LeafNodeMask.h:157
openvdb::v5_1::tree::LeafNode< ValueMask, Log2Dim >::isValueMaskOff
bool isValueMaskOff(Index n) const
Definition: LeafNodeMask.h:734
openvdb::v5_1::tree::LeafNode< ValueMask, Log2Dim >::stealNodes
void stealNodes(ArrayT &, const ValueType &, bool)
This function exists only to enable template instantiation.
Definition: LeafNodeMask.h:561
openvdb::v5_1::tree::LeafNode< ValueMask, Log2Dim >::probeNode
NodeT * probeNode(const Coord &)
This function exists only to enable template instantiation.
Definition: LeafNodeMask.h:557
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< ValueMask, Log2Dim >::hasActiveTiles
static bool hasActiveTiles()
Return false since leaf nodes never contain tiles.
Definition: LeafNodeMask.h:308
openvdb::v5_1::tree::LeafNode< ValueMask, Log2Dim >::beginValueAll
ValueAllCIter beginValueAll() const
Definition: LeafNodeMask.h:694
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
openvdb::v5_1::tree::LeafNode< ValueMask, Log2Dim >::isChildMaskOff
bool isChildMaskOff() const
Definition: LeafNodeMask.h:742
Math.h
General-purpose arithmetic and comparison routines, most of which accept arbitrary value types (or at...
openvdb::v5_1::tree::LeafNode< ValueMask, Log2Dim >::resetBackground
void resetBackground(bool, bool)
no-op since for this temaplte specialization voxel values and states are indistinguishable.
Definition: LeafNodeMask.h:468
openvdb::v5_1::tree::LeafNode< ValueMask, Log2Dim >::setValueOnlyAndCache
void setValueOnlyAndCache(const Coord &xyz, bool val, AccessorT &)
Change the value of the voxel at the given coordinates but preserve its state.
Definition: LeafNodeMask.h:373
openvdb::v5_1::tree::LeafNode< ValueMask, Log2Dim >::ValueIter::setValue
void setValue(bool value) const
Definition: LeafNodeMask.h:629
openvdb::v5_1::tree::LeafNode< ValueMask, Log2Dim >::endChildOff
ChildOffCIter endChildOff() const
Definition: LeafNodeMask.h:723
openvdb::v5_1::tree::LeafNode< ValueMask, Log2Dim >::setValueOff
void setValueOff(const Coord &xyz)
Mark the voxel at the given coordinates as inactive but don&#39;t change its value.
Definition: LeafNodeMask.h:263
openvdb::v5_1::tree::LeafNode< ValueMask, Log2Dim >::cbeginChildAll
ChildAllCIter cbeginChildAll() const
Definition: LeafNodeMask.h:715
openvdb::v5_1::tree::LeafNode< ValueMask, Log2Dim >::ValueOnIter
ValueIter< MaskOnIter, LeafNode, const bool > ValueOnIter
Definition: LeafNodeMask.h:674
openvdb::v5_1::tree::LeafNode< ValueMask, Log2Dim >::probeConstLeaf
const LeafNode * probeConstLeaf(const Coord &) const
Return a const pointer to this node.
Definition: LeafNodeMask.h:591
openvdb::v5_1::tree::LeafNode< ValueMask, Log2Dim >::cbeginValueAll
ValueAllCIter cbeginValueAll() const
Definition: LeafNodeMask.h:693
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::tree::LeafNode< ValueMask, Log2Dim >::valueMask
const NodeMaskType & valueMask() const
Definition: LeafNodeMask.h:737
openvdb::v5_1::tree::LeafNode< ValueMask, Log2Dim >::ValueIter::ValueIter
ValueIter()
Definition: LeafNodeMask.h:620
openvdb::v5_1::tree::LeafNode< ValueMask, Log2Dim >::DenseIter::unsetItem
void unsetItem(Index pos, const ValueT &val) const
Definition: LeafNodeMask.h:670
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< ValueMask, Log2Dim >::denseFill
void denseFill(const CoordBBox &bbox, bool value, bool=false)
Set all voxels within an axis-aligned box to the specified value.
Definition: LeafNodeMask.h:316
openvdb::v5_1::tree::LeafNode< ValueMask, Log2Dim >::ChildIter::ChildIter
ChildIter(const MaskIterT &iter, NodeT *parent)
Definition: LeafNodeMask.h:645
openvdb::v5_1::tree::LeafNode< ValueMask, Log2Dim >::probeLeafAndCache
const LeafNode * probeLeafAndCache(const Coord &, AccessorT &) const
Return a const pointer to this node.
Definition: LeafNodeMask.h:590
openvdb::v5_1::tree::LeafNode< ValueMask, Log2Dim >::ValueAllIter
ValueIter< MaskDenseIter, LeafNode, const bool > ValueAllIter
Definition: LeafNodeMask.h:678
openvdb::v5_1::tree::LeafNode::addTile
void addTile(Index level, const Coord &, const ValueType &, bool)
Definition: LeafNode.h:1615
openvdb::v5_1::tree::LeafNode< ValueMask, Log2Dim >::ChildAllIter
DenseIter< LeafNode, bool > ChildAllIter
Definition: LeafNodeMask.h:684
openvdb::v5_1::tree::LeafNode< ValueMask, Log2Dim >::allocate
bool allocate()
Allocate memory for this node&#39;s buffer if it has not already been allocated.
Definition: LeafNodeMask.h:169
openvdb::v5_1::tree::LeafNode< ValueMask, Log2Dim >::setActiveStateAndCache
void setActiveStateAndCache(const Coord &xyz, bool on, AccessorT &)
Set the active state of the voxel at the given coordinates without changing its value.
Definition: LeafNodeMask.h:404
openvdb::v5_1::tree::LeafNode< ValueMask, Log2Dim >::MaskDenseIter
typename NodeMaskType::DenseIterator MaskDenseIter
Definition: LeafNodeMask.h:610
openvdb::v5_1::tree::LeafNode< ValueMask, Log2Dim >::cendChildAll
ChildAllCIter cendChildAll() const
Definition: LeafNodeMask.h:725
openvdb::v5_1::tree::LeafNode::getValueMask
const NodeMaskType & getValueMask() const
Definition: LeafNode.h:889
openvdb::v5_1::tree::LeafNode< ValueMask, Log2Dim >::getLevel
static Index getLevel()
Return the level of this node, which by definition is zero for LeafNodes.
Definition: LeafNodeMask.h:137
openvdb::v5_1::tree::LeafNode< ValueMask, Log2Dim >::beginChildOn
ChildOnCIter beginChildOn() const
Definition: LeafNodeMask.h:710
openvdb::v5_1::tree::LeafNode< ValueMask, Log2Dim >::stealNode
NodeT * stealNode(const Coord &, const ValueType &, bool)
This function exists only to enable template instantiation.
Definition: LeafNodeMask.h:555
openvdb::v5_1::tree::LeafNode< ValueMask, Log2Dim >::setActiveState
void setActiveState(Index offset, bool on)
Set the active state of the voxel at the given offset but don&#39;t change its value. ...
Definition: LeafNodeMask.h:255
openvdb::v5_1::tree::LeafNode::~LeafNode
~LeafNode()
Destructor.
Definition: LeafNode.h:1032
openvdb::v5_1::tree::LeafNode< ValueMask, Log2Dim >::onTileCount
static Index64 onTileCount()
Definition: LeafNodeMask.h:153
openvdb::v5_1::tree::LeafNode< ValueMask, Log2Dim >::isValueMaskOn
bool isValueMaskOn() const
Definition: LeafNodeMask.h:733
openvdb::v5_1::math::Coord::ValueType
Int32 ValueType
Definition: Coord.h:59
openvdb::v5_1::tree::LeafNode< ValueMask, Log2Dim >::beginValueOn
ValueOnCIter beginValueOn() const
Definition: LeafNodeMask.h:688
openvdb::v5_1::tree::LeafNode< ValueMask, Log2Dim >::DenseIter::getItem
bool getItem(Index pos, void *&child, NonConstValueT &value) const
Definition: LeafNodeMask.h:659
openvdb::v5_1::tree::LeafNode< ValueMask, Log2Dim >::getValueAndCache
const bool & getValueAndCache(const Coord &xyz, AccessorT &) const
Return the value of the voxel at the given coordinates.
Definition: LeafNodeMask.h:357
openvdb::v5_1::tree::LeafNode< ValueMask, Log2Dim >::probeConstLeafAndCache
const LeafNode * probeConstLeafAndCache(const Coord &, AccessorT &) const
Return a const pointer to this node.
Definition: LeafNodeMask.h:593
openvdb::v5_1::tree::LeafNode< ValueMask, Log2Dim >::probeLeaf
LeafNode * probeLeaf(const Coord &)
Return a pointer to this node.
Definition: LeafNodeMask.h:574
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::visit2Node
void visit2Node(OtherLeafNodeType &other, VisitorOp &)
Definition: LeafNode.h:1923
openvdb::v5_1::tree::LeafNode< ValueMask, Log2Dim >::MaskOffIter
typename NodeMaskType::OffIterator MaskOffIter
Definition: LeafNodeMask.h:609
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::LeafBuffer< ValueType, Log2Dim >
openvdb::v5_1::tree::LeafNode< ValueMask, Log2Dim >::endChildAll
ChildAllCIter endChildAll() const
Definition: LeafNodeMask.h:726
openvdb::v5_1::tree::LeafNode< ValueMask, Log2Dim >::mOrigin
Coord mOrigin
Global grid index coordinates (x,y,z) of the local origin of this node.
Definition: LeafNodeMask.h:766
openvdb::v5_1::tree::LeafNode< ValueMask, Log2Dim >::setValueOn
void setValueOn(Index offset)
Mark the voxel at the given offset as active but don&#39;t change its value.
Definition: LeafNodeMask.h:275
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< ValueMask, Log2Dim >::getFirstValue
const bool & getFirstValue() const
Return a const reference to the first entry in the buffer.
Definition: LeafNodeMask.h:426
openvdb::v5_1::tree::LeafNode< ValueMask, Log2Dim >::ChildOffIter
ChildIter< MaskOffIter, LeafNode > ChildOffIter
Definition: LeafNodeMask.h:682
openvdb::v5_1::tree::LeafNode< ValueMask, Log2Dim >::setValueAndCache
void setValueAndCache(const Coord &xyz, bool val, AccessorT &)
Change the value of the voxel at the given coordinates and mark it as active.
Definition: LeafNodeMask.h:367
openvdb::v5_1::tree::LeafNode< ValueMask, Log2Dim >::buffer
const Buffer & buffer() const
Definition: LeafNodeMask.h:219
openvdb::v5_1::tree::LeafNode< ValueMask, Log2Dim >::probeConstNodeAndCache
const NodeT * probeConstNodeAndCache(const Coord &, AccessorT &) const
Return a const pointer to this node.
Definition: LeafNodeMask.h:595
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::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< ValueMask, Log2Dim >::cendChildOff
ChildOffCIter cendChildOff() const
Definition: LeafNodeMask.h:722
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::tree::LeafNode< ValueMask, Log2Dim >
LeafNode specialization for values of type ValueMask that encodes both the active states and the bool...
Definition: LeafNodeMask.h:57
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< ValueMask, Log2Dim >::nonLeafCount
static Index32 nonLeafCount()
Return the non-leaf count for this node, which is zero.
Definition: LeafNodeMask.h:145
openvdb::v5_1::tree::LeafNode::visit2
void visit2(IterT &otherIter, VisitorOp &, bool otherIsLHS=false)
Definition: LeafNode.h:1971
openvdb::v5_1::tree::LeafNode< ValueMask, Log2Dim >::getLastValue
const bool & getLastValue() const
Return a const reference to the last entry in the buffer.
Definition: LeafNodeMask.h:430
openvdb::v5_1::tree::LeafNode< ValueMask, Log2Dim >::MaskOnIter
typename NodeMaskType::OnIterator MaskOnIter
Definition: LeafNodeMask.h:608
openvdb::v5_1::tree::LeafNode::NUM_VALUES
static const Index NUM_VALUES
Definition: LeafNode.h:78
openvdb::v5_1::tree::LeafNode< ValueMask, Log2Dim >::endValueOff
ValueOffIter endValueOff()
Definition: LeafNodeMask.h:702
openvdb::v5_1::math::Coord::setY
Coord & setY(Int32 y)
Definition: Coord.h:107
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< ValueMask, Log2Dim >::ChildOnIter
ChildIter< MaskOnIter, LeafNode > ChildOnIter
Definition: LeafNodeMask.h:680
openvdb::v5_1::tree::LeafNode< ValueMask, Log2Dim >::isValueOnAndCache
bool isValueOnAndCache(const Coord &xyz, AccessorT &) const
Return true if the voxel at the given coordinates is active.
Definition: LeafNodeMask.h:362
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::ValueMask
Definition: Types.h:118
openvdb::v5_1::tree::LeafNode< ValueMask, Log2Dim >::beginValueAll
ValueAllIter beginValueAll()
Definition: LeafNodeMask.h:695
openvdb::v5_1::tree::LeafNode< ValueMask, Log2Dim >::getNodeBoundingBox
CoordBBox getNodeBoundingBox() const
Return the bounding box of this node, i.e., the full index space spanned by this leaf node...
Definition: LeafNodeMask.h:182
openvdb::v5_1::tree::LeafNode< ValueMask, Log2Dim >::cbeginValueOff
ValueOffCIter cbeginValueOff() const
Definition: LeafNodeMask.h:690
openvdb::v5_1::tree::LeafNode< ValueMask, Log2Dim >::ChildOffCIter
ChildIter< MaskOffIter, const LeafNode > ChildOffCIter
Definition: LeafNodeMask.h:683
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< ValueMask, Log2Dim >::addLeaf
void addLeaf(LeafNode *)
This function exists only to enable template instantiation.
Definition: LeafNodeMask.h:551
openvdb::v5_1::tree::LeafNode< ValueMask, Log2Dim >::Ptr
SharedPtr< LeafNodeType > Ptr
Definition: LeafNodeMask.h:65
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::tree::LeafNode< ValueMask, Log2Dim >::endChildAll
ChildAllIter endChildAll()
Definition: LeafNodeMask.h:727
openvdb::v5_1::tree::LeafNode< ValueMask, Log2Dim >::beginChildOff
ChildOffIter beginChildOff()
Definition: LeafNodeMask.h:714
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< ValueMask, Log2Dim >::getValueLevelAndCache
static Index getValueLevelAndCache(const Coord &, AccessorT &)
Return the LEVEL (=0) at which leaf node values reside.
Definition: LeafNodeMask.h:421
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< ValueMask, Log2Dim >::offTileCount
static Index64 offTileCount()
Definition: LeafNodeMask.h:154
openvdb::v5_1::tree::LeafNode< ValueMask, Log2Dim >::modifyValueAndActiveStateAndCache
void modifyValueAndActiveStateAndCache(const Coord &xyz, const ModifyOp &op, AccessorT &)
Definition: LeafNodeMask.h:395
openvdb::v5_1::tree::LeafNode< ValueMask, Log2Dim >::beginChildAll
ChildAllCIter beginChildAll() const
Definition: LeafNodeMask.h:716
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< ValueMask, Log2Dim >::size
static Index size()
Return the total number of voxels represented by this LeafNode.
Definition: LeafNodeMask.h:133
openvdb::v5_1::tree::LeafNode< ValueMask, Log2Dim >::beginValueOff
ValueOffIter beginValueOff()
Definition: LeafNodeMask.h:692
openvdb::v5_1::tree::LeafNode< ValueMask, Log2Dim >::setValueOn
void setValueOn(const Coord &xyz)
Mark the voxel at the given coordinates as active but don&#39;t change its value.
Definition: LeafNodeMask.h:273
openvdb::v5_1::tree::LeafNode< ValueMask, Log2Dim >::isValueMaskOff
bool isValueMaskOff() const
Definition: LeafNodeMask.h:735
openvdb::v5_1::tree::LeafNode::visit
void visit(VisitorOp &)
Definition: LeafNode.h:1891
openvdb::v5_1::tree::LeafNode< ValueMask, Log2Dim >::isChildMaskOn
bool isChildMaskOn(Index) const
Definition: LeafNodeMask.h:740
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< ValueMask, Log2Dim >::ValueAllCIter
ValueIter< MaskDenseIter, const LeafNode, const bool > ValueAllCIter
Definition: LeafNodeMask.h:679
openvdb::v5_1::tree::LeafNode< ValueMask, Log2Dim >::log2dim
static Index log2dim()
Return log2 of the size of the buffer storage.
Definition: LeafNodeMask.h:129
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::math::Coord::z
Int32 z() const
Definition: Coord.h:159
openvdb::v5_1::tree::LeafNode< ValueMask, Log2Dim >::ValueIter::modifyValue
void modifyValue(const ModifyOp &op) const
Definition: LeafNodeMask.h:636
openvdb::v5_1::tree::LeafNode< ValueMask, Log2Dim >::setValueMaskOn
void setValueMaskOn(Index n)
Definition: LeafNodeMask.h:745
openvdb::v5_1::Index64
uint64_t Index64
Definition: Types.h:60
openvdb::v5_1::tree::LeafNode< ValueMask, Log2Dim >::DenseIter::NonConstValueT
typename BaseT::NonConstValueType NonConstValueT
Definition: LeafNodeMask.h:654
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< ValueMask, Log2Dim >::ChildIter::ChildIter
ChildIter()
Definition: LeafNodeMask.h:644
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< ValueMask, Log2Dim >::setValueMaskOff
void setValueMaskOff(Index n)
Definition: LeafNodeMask.h:746
openvdb::v5_1::tree::LeafNode< ValueMask, Log2Dim >::setValuesOn
void setValuesOn()
Mark all voxels as active but don&#39;t change their values.
Definition: LeafNodeMask.h:298
openvdb
Definition: Exceptions.h:40
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::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< ValueMask, Log2Dim >::dim
static Index dim()
Return the number of voxels in each dimension.
Definition: LeafNodeMask.h:131
openvdb::v5_1::tree::LeafNode< ValueMask, Log2Dim >::getNodes
void getNodes(ArrayT &) const
This function exists only to enable template instantiation.
Definition: LeafNodeMask.h:560
openvdb::v5_1::util::DenseMaskIterator
Definition: NodeMasks.h:272
openvdb::v5_1::tree::LeafNode< ValueMask, Log2Dim >::DenseIter::DenseIter
DenseIter(const MaskDenseIter &iter, NodeT *parent)
Definition: LeafNodeMask.h:657
openvdb::v5_1::math::CoordBBox::translate
void translate(const Coord &t)
Definition: Coord.h:462
openvdb::v5_1::tree::LeafNode< ValueMask, Log2Dim >::setValueOffAndCache
void setValueOffAndCache(const Coord &xyz, bool value, AccessorT &)
Change the value of the voxel at the given coordinates and mark it as inactive.
Definition: LeafNodeMask.h:378
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< ValueMask, Log2Dim >::isDense
bool isDense() const
Return true if this node only contains active voxels.
Definition: LeafNodeMask.h:159
openvdb::v5_1::tree::LeafNode< ValueMask, Log2Dim >::setValue
void setValue(const Coord &xyz, bool val)
Set the value of the voxel at the given coordinates and mark the voxel as active. ...
Definition: LeafNodeMask.h:280
openvdb::v5_1::math::Coord::y
Int32 y() const
Definition: Coord.h:158
openvdb::v5_1::tree::LeafNode< ValueMask, Log2Dim >::ChildAllCIter
DenseIter< const LeafNode, const bool > ChildAllCIter
Definition: LeafNodeMask.h:685
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::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::SIZE
static const Index SIZE
Definition: LeafNode.h:80
openvdb::v5_1::tree::SameLeafConfig
Definition: PointDataGrid.h:201
openvdb::v5_1::tree::LeafNode::doVisit2Node
static void doVisit2Node(NodeT &self, OtherNodeT &other, VisitorOp &)
Definition: LeafNode.h:1948
version.h
Library and file format version numbers.
openvdb::v5_1::tree::LeafNode< ValueMask, Log2Dim >::cendValueAll
ValueAllCIter cendValueAll() const
Definition: LeafNodeMask.h:703
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< ValueMask, Log2Dim >::endValueOn
ValueOnIter endValueOn()
Definition: LeafNodeMask.h:699
openvdb::v5_1::tree::LeafNode< ValueMask, Log2Dim >::endChildOff
ChildOffIter endChildOff()
Definition: LeafNodeMask.h:724
openvdb::v5_1::tree::LeafNode< ValueMask, Log2Dim >::getNodeLog2Dims
static void getNodeLog2Dims(std::vector< Index > &dims)
Append the Log2Dim of this LeafNode to the specified vector.
Definition: LeafNodeMask.h:139
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::math::Coord::setZ
Coord & setZ(Int32 z)
Definition: Coord.h:108
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< ValueMask, Log2Dim >::cendValueOn
ValueOnCIter cendValueOn() const
Definition: LeafNodeMask.h:697
openvdb::v5_1::tree::LeafNode< ValueMask, Log2Dim >::probeValueAndCache
bool probeValueAndCache(const Coord &xyz, bool &val, AccessorT &) const
Return true if the voxel at the given coordinates is active and return the voxel value in val...
Definition: LeafNodeMask.h:413
OPENVDB_NO_UNREACHABLE_CODE_WARNING_END
#define OPENVDB_NO_UNREACHABLE_CODE_WARNING_END
Definition: Platform.h:130
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< ValueMask, Log2Dim >::cbeginChildOff
ChildOffCIter cbeginChildOff() const
Definition: LeafNodeMask.h:712
openvdb::v5_1::tree::LeafNode< ValueMask, Log2Dim >::isChildMaskOff
bool isChildMaskOff(Index) const
Definition: LeafNodeMask.h:741
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::tree::LeafNode< ValueMask, Log2Dim >::setValueOnly
void setValueOnly(Index offset, bool val)
Set the value of the voxel at the given offset but don&#39;t change its active state. ...
Definition: LeafNodeMask.h:260
openvdb::v5_1::tree::LeafNode< ValueMask, Log2Dim >::swap
void swap(Buffer &other)
Exchange this node&#39;s data buffer with the given data buffer without changing the active states of the...
Definition: LeafNodeMask.h:218
openvdb::v5_1::math::Coord
Signed (x, y, z) 32-bit integer coordinates.
Definition: Coord.h:51
openvdb::v5_1::tree::LeafNode< ValueMask, Log2Dim >::mBuffer
Buffer mBuffer
Bitmask representing the values AND state of voxels.
Definition: LeafNodeMask.h:763
openvdb::v5_1::tree::LeafNode< ValueMask, Log2Dim >::getChildDim
static Index getChildDim()
Return the dimension of child nodes of this LeafNode, which is one for voxels.
Definition: LeafNodeMask.h:141
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< ValueMask, Log2Dim >::beginChildOn
ChildOnIter beginChildOn()
Definition: LeafNodeMask.h:711
openvdb::v5_1::tree::LeafNode< ValueMask, Log2Dim >::endValueAll
ValueAllCIter endValueAll() const
Definition: LeafNodeMask.h:704
openvdb::v5_1::tree::LeafNode::doVisit
static void doVisit(NodeT &, VisitorOp &)
Definition: LeafNode.h:1909
openvdb::v5_1::tree::LeafNode< ValueMask, Log2Dim >::offVoxelCount
Index64 offVoxelCount() const
Return the number of inactive voxels.
Definition: LeafNodeMask.h:150
openvdb::v5_1::CombineArgs::setBRef
CombineArgs & setBRef(const BValueType &b)
Redirect the B value to a new external source.
Definition: Types.h:438
Iterator.h
openvdb::v5_1::tree::LeafNode< ValueMask, Log2Dim >::getValueMask
const NodeMaskType & getValueMask() const
Definition: LeafNodeMask.h:736
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< ValueMask, Log2Dim >::DenseIter::DenseIter
DenseIter()
Definition: LeafNodeMask.h:656
openvdb::v5_1::tree::LeafNode< ValueMask, Log2Dim >::ValueIter::ValueIter
ValueIter(const MaskIterT &iter, NodeT *parent)
Definition: LeafNodeMask.h:621
openvdb::v5_1::tree::LeafNode< ValueMask, Log2Dim >::ValueOffCIter
ValueIter< MaskOffIter, const LeafNode, const bool > ValueOffCIter
Definition: LeafNodeMask.h:677
openvdb::v5_1::tree::LeafNode< ValueMask, Log2Dim >::voxelizeActiveTiles
void voxelizeActiveTiles(bool=true)
No-op.
Definition: LeafNodeMask.h:479
openvdb::v5_1::tree::LeafNode< ValueMask, Log2Dim >::probeLeafAndCache
LeafNode * probeLeafAndCache(const Coord &, AccessorT &)
Return a pointer to this node.
Definition: LeafNodeMask.h:576
openvdb::v5_1::tree::LeafNode< ValueMask, Log2Dim >::isValueOn
bool isValueOn(const Coord &xyz) const
Return true if the voxel at the given coordinates is active.
Definition: LeafNodeMask.h:303
openvdb::v5_1::tree::LeafNode< ValueMask, Log2Dim >::setValueMask
void setValueMask(const NodeMaskType &mask)
Definition: LeafNodeMask.h:739
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::tree::LeafNode< ValueMask, Log2Dim >::beginChildOff
ChildOffCIter beginChildOff() const
Definition: LeafNodeMask.h:713
openvdb::v5_1::tree::LeafNode::cbeginValueOn
ValueOnCIter cbeginValueOn() const
Definition: LeafNode.h:320
openvdb::v5_1::tree::LeafNode< ValueMask, Log2Dim >::beginChildAll
ChildAllIter beginChildAll()
Definition: LeafNodeMask.h:717
openvdb::v5_1::tree::LeafNode< ValueMask, Log2Dim >::cendValueOff
ValueOffCIter cendValueOff() const
Definition: LeafNodeMask.h:700
openvdb::v5_1::tree::LeafNode::operator!=
bool operator!=(const LeafNode &other) const
Definition: LeafNode.h:224
NodeMasks.h
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< ValueMask, Log2Dim >::ValueOffIter
ValueIter< MaskOffIter, LeafNode, const bool > ValueOffIter
Definition: LeafNodeMask.h:676
OPENVDB_USE_VERSION_NAMESPACE
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h:188
openvdb::v5_1::util::NodeMask::setOn
void setOn(Index32 n)
Set the nth bit on.
Definition: NodeMasks.h:454
openvdb::v5_1::tree::DenseIteratorBase::NonConstValueType
typename std::remove_const< UnsetItemT >::type NonConstValueType
Definition: Iterator.h:211
openvdb::v5_1::tree::LeafNode< ValueMask, Log2Dim >::endChildOn
ChildOnIter endChildOn()
Definition: LeafNodeMask.h:721
openvdb::v5_1::tree::LeafNode< ValueMask, Log2Dim >::setValueMask
void setValueMask(Index n, bool on)
Definition: LeafNodeMask.h:744
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< ValueMask, Log2Dim >::negate
void negate()
Invert the bits of the voxels, i.e. states and values.
Definition: LeafNodeMask.h:471
openvdb::v5_1::tree::LeafNode< ValueMask, Log2Dim >::offLeafVoxelCount
Index64 offLeafVoxelCount() const
Definition: LeafNodeMask.h:152
openvdb::v5_1::tree::LeafNode< ValueMask, Log2Dim >::isInactive
bool isInactive() const
Return true if all of this node&#39;s values are inactive.
Definition: LeafNodeMask.h:464
openvdb::v5_1::tree::LeafNode< ValueMask, Log2Dim >::probeNodeAndCache
NodeT * probeNodeAndCache(const Coord &, AccessorT &)
Return a pointer to this node.
Definition: LeafNodeMask.h:578
openvdb::v5_1::tree::LeafNode< ValueMask, Log2Dim >::leafCount
static Index32 leafCount()
Return the leaf count for this node, which is one.
Definition: LeafNodeMask.h:143
openvdb::v5_1::tree::LeafNode< ValueMask, Log2Dim >::isValueMaskOn
bool isValueMaskOn(Index n) const
Definition: LeafNodeMask.h:732
openvdb::v5_1::tree::LeafNode< ValueMask, Log2Dim >::modifyValueAndCache
void modifyValueAndCache(const Coord &xyz, const ModifyOp &op, AccessorT &)
Apply a functor to the value of the voxel at the given coordinates and mark the voxel as active...
Definition: LeafNodeMask.h:387
openvdb::v5_1::tree::LeafNode< ValueMask, Log2Dim >::onLeafVoxelCount
Index64 onLeafVoxelCount() const
Definition: LeafNodeMask.h:151
openvdb::v5_1::tree::LeafNode< ValueMask, Log2Dim >::getValueLevel
static Index getValueLevel(const Coord &)
Return the level (0) at which leaf node values reside.
Definition: LeafNodeMask.h:250
openvdb::v5_1::tree::LeafNode< ValueMask, Log2Dim >::evalNodeOrigin
static void evalNodeOrigin(Coord &xyz)
Compute the origin of the leaf node that contains the voxel with the given coordinates.
Definition: LeafNodeMask.h:749
openvdb::v5_1::tree::LeafBuffer::mData
ValueType * mData
Definition: LeafBuffer.h:225
openvdb::v5_1::tree::LeafNode< ValueMask, Log2Dim >::buffer
Buffer & buffer()
Definition: LeafNodeMask.h:220
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< ValueMask, Log2Dim >::onVoxelCount
Index64 onVoxelCount() const
Return the number of active voxels.
Definition: LeafNodeMask.h:148
openvdb::v5_1::tree::LeafNode< ValueMask, Log2Dim >::ValueOnCIter
ValueIter< MaskOnIter, const LeafNode, const bool > ValueOnCIter
Definition: LeafNodeMask.h:675
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::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< ValueMask, Log2Dim >::cendChildOn
ChildOnCIter cendChildOn() const
Definition: LeafNodeMask.h:719
openvdb::v5_1::tree::LeafNode< ValueMask, Log2Dim >::numValues
static Index numValues()
Return the total number of voxels represented by this LeafNode.
Definition: LeafNodeMask.h:135
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::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< ValueMask, Log2Dim >::ChildOnCIter
ChildIter< MaskOnIter, const LeafNode > ChildOnCIter
Definition: LeafNodeMask.h:681
openvdb::v5_1::tree::LeafNode< ValueMask, Log2Dim >::setValueOff
void setValueOff(Index offset)
Mark the voxel at the given offset as inactive but don&#39;t change its value.
Definition: LeafNodeMask.h:265
openvdb::v5_1::tree::LeafNode< ValueMask, Log2Dim >::endValueAll
ValueAllIter endValueAll()
Definition: LeafNodeMask.h:705
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< ValueMask, Log2Dim >::getOrigin
void getOrigin(Coord &origin) const
Return the grid index coordinates of this node&#39;s local origin.
Definition: LeafNodeMask.h:189
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< ValueMask, Log2Dim >::getOrigin
void getOrigin(Int32 &x, Int32 &y, Int32 &z) const
Return the grid index coordinates of this node&#39;s local origin.
Definition: LeafNodeMask.h:190
openvdb::v5_1::tree::LeafNode< ValueMask, Log2Dim >::endValueOn
ValueOnCIter endValueOn() const
Definition: LeafNodeMask.h:698
openvdb::v5_1::tree::LeafNode< ValueMask, Log2Dim >::cbeginChildOn
ChildOnCIter cbeginChildOn() const
Definition: LeafNodeMask.h:709
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
openvdb::v5_1::tree::LeafNode< ValueMask, Log2Dim >::endValueOff
ValueOffCIter endValueOff() const
Definition: LeafNodeMask.h:701