OpenVDB: LeafNodeMask.h Source File

OpenVDB 4.0.2

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