31 #ifndef OPENVDB_TREE_LEAF_NODE_MASK_HAS_BEEN_INCLUDED 32 #define OPENVDB_TREE_LEAF_NODE_MASK_HAS_BEEN_INCLUDED 35 #include <boost/shared_ptr.hpp> 36 #include <boost/shared_array.hpp> 37 #include <boost/static_assert.hpp> 54 template<Index Log2Dim>
59 typedef boost::shared_ptr<LeafNodeType>
Ptr;
65 static const Index LOG2DIM = Log2Dim;
66 static const Index TOTAL = Log2Dim;
67 static const Index DIM = 1 << TOTAL;
68 static const Index NUM_VALUES = 1 << 3 * Log2Dim;
69 static const Index NUM_VOXELS = NUM_VALUES;
70 static const Index SIZE = NUM_VALUES;
75 template<
typename OtherValueType>
76 struct ValueConverter {
82 template<
typename OtherNodeType>
83 struct SameConfiguration {
91 static const Index WORD_COUNT = NodeMaskType::WORD_COUNT;
93 explicit Buffer(
bool on) : mData(on) {}
94 Buffer(
const NodeMaskType& other): mData(other) {}
95 Buffer(
const Buffer& other): mData(other.mData) {}
97 void fill(
bool val) { mData.set(val); }
100 if (&b !=
this) mData = b.mData;
109 if (mData.isOn(i))
return LeafNode::sOn;
110 return LeafNode::sOff;
114 bool operator==(
const Buffer& other)
const {
return mData == other.mData; }
115 bool operator!=(
const Buffer& other)
const {
return mData != other.mData; }
119 void swap(Buffer& other) {
if (&other !=
this) std::swap(mData, other.mData); }
129 return &(mData.template getWord<WordType>(0));
137 return const_cast<Buffer*
>(
this)->data();
141 friend class ::TestLeaf;
156 explicit LeafNode(
const Coord& xyz,
bool value =
false,
bool dummy =
false);
158 #ifndef OPENVDB_2_ABI_COMPATIBLE 167 template<
typename OtherValueType>
171 template<
typename ValueType>
175 template<
typename ValueType>
179 template<
typename ValueType>
218 bool isEmpty()
const {
return mBuffer.mData.isOff(); }
220 bool isDense()
const {
return mBuffer.mData.isOn(); }
222 #ifndef OPENVDB_2_ABI_COMPATIBLE 223 bool isAllocated()
const {
return true; }
239 void evalActiveBoundingBox(
CoordBBox& bbox,
bool visitVoxels =
true)
const;
248 const Coord& origin()
const {
return mOrigin; }
263 std::string str()
const;
267 template<
typename OtherType, Index OtherLog2Dim>
279 void swap(Buffer& other) { mBuffer.swap(other); }
280 const Buffer&
buffer()
const {
return mBuffer; }
287 void readTopology(std::istream&,
bool fromHalf =
false);
289 void writeTopology(std::ostream&,
bool toHalf =
false)
const;
292 void readBuffers(std::istream&,
bool fromHalf =
false);
293 void readBuffers(std::istream& is,
const CoordBBox&,
bool fromHalf =
false);
295 void writeBuffers(std::ostream&,
bool toHalf =
false)
const;
301 const bool& getValue(
const Coord& xyz)
const;
303 const bool& getValue(
Index offset)
const;
308 bool probeValue(
const Coord& xyz,
bool& val)
const;
314 void setActiveState(
const Coord& xyz,
bool on);
319 void setValueOnly(
const Coord& xyz,
bool val);
321 void setValueOnly(
Index offset,
bool val) { assert(offset<SIZE); mBuffer.setValue(offset,val); }
329 void setValueOff(
const Coord& xyz,
bool val);
331 void setValueOff(
Index offset,
bool val);
339 void setValueOn(
const Coord& xyz,
bool val);
343 void setValueOn(
Index offset,
bool val);
347 template<
typename ModifyOp>
348 void modifyValue(
Index offset,
const ModifyOp& op);
351 template<
typename ModifyOp>
352 void modifyValue(
const Coord& xyz,
const ModifyOp& op);
355 template<
typename ModifyOp>
356 void modifyValueAndActiveState(
const Coord& xyz,
const ModifyOp& op);
364 bool isValueOn(
const Coord& xyz)
const {
return mBuffer.mData.isOn(this->coordToOffset(xyz)); }
366 bool isValueOn(
Index offset)
const { assert(offset < SIZE);
return mBuffer.mData.isOn(offset); }
375 void fill(
const CoordBBox& bbox,
bool value,
bool dummy =
false);
378 void fill(
const bool& value,
bool dummy =
false);
391 template<
typename DenseT>
410 template<
typename DenseT>
415 template<
typename AccessorT>
420 template<
typename AccessorT>
425 template<
typename AccessorT>
431 template<
typename AccessorT>
436 template<
typename AccessorT>
439 this->setValueOff(xyz, value);
445 template<
typename ModifyOp,
typename AccessorT>
448 this->modifyValue(xyz, op);
453 template<
typename ModifyOp,
typename AccessorT>
456 this->modifyValueAndActiveState(xyz, op);
462 template<
typename AccessorT>
465 this->setActiveState(xyz, on);
471 template<
typename AccessorT>
474 return this->probeValue(xyz, val);
479 template<
typename AccessorT>
485 const bool&
getFirstValue()
const {
if (mBuffer.mData.isOn(0))
return sOn;
else return sOff; }
489 const bool&
getLastValue()
const {
if (mBuffer.mData.isOn(SIZE-1))
return sOn;
else return sOff; }
494 bool isConstant(
bool& constValue,
bool& state,
bool tolerance = 0)
const;
503 void negate() { mBuffer.mData.toggle(); }
505 template<MergePolicy Policy>
506 void merge(
const LeafNode& other,
bool bg =
false,
bool otherBG =
false);
507 template<MergePolicy Policy>
void merge(
bool tileValue,
bool tileActive=
false);
519 template<
typename OtherType>
533 template<
typename OtherType>
547 template<
typename OtherType>
550 template<
typename CombineOp>
551 void combine(
const LeafNode& other, CombineOp& op);
552 template<
typename CombineOp>
553 void combine(
bool,
bool valueIsActive, CombineOp& op);
555 template<
typename CombineOp,
typename OtherType >
556 void combine2(
const LeafNode& other,
const OtherType&,
bool valueIsActive, CombineOp&);
557 template<
typename CombineOp,
typename OtherNodeT >
558 void combine2(
bool,
const OtherNodeT& other,
bool valueIsActive, CombineOp&);
559 template<
typename CombineOp,
typename OtherNodeT >
560 void combine2(
const LeafNode& b0,
const OtherNodeT& b1, CombineOp&);
566 template<
typename BBoxOp>
void visitActiveBBox(BBoxOp&)
const;
568 template<
typename VisitorOp>
void visit(VisitorOp&);
569 template<
typename VisitorOp>
void visit(VisitorOp&)
const;
571 template<
typename OtherLeafNodeType,
typename VisitorOp>
572 void visit2Node(OtherLeafNodeType& other, VisitorOp&);
573 template<
typename OtherLeafNodeType,
typename VisitorOp>
574 void visit2Node(OtherLeafNodeType& other, VisitorOp&)
const;
575 template<
typename IterT,
typename VisitorOp>
576 void visit2(IterT& otherIter, VisitorOp&,
bool otherIsLHS =
false);
577 template<
typename IterT,
typename VisitorOp>
578 void visit2(IterT& otherIter, VisitorOp&,
bool otherIsLHS =
false)
const;
581 void prune(
const ValueType& = zeroVal<ValueType>()) {}
584 template<
typename AccessorT>
586 template<
typename NodeT>
588 template<
typename NodeT>
590 template<
typename NodeT>
592 template<
typename ArrayT>
void getNodes(ArrayT&)
const {}
593 template<
typename ArrayT>
void stealNodes(ArrayT&,
const ValueType&,
bool) {}
596 void addTile(
Index level,
const Coord&,
bool val,
bool active);
597 void addTile(
Index offset,
bool val,
bool active);
598 template<
typename AccessorT>
599 void addTileAndCache(
Index level,
const Coord&,
bool val,
bool active, AccessorT&);
604 template<
typename AccessorT>
607 template<
typename AccessorT>
609 template<
typename NodeT,
typename AccessorT>
613 if (!(boost::is_same<NodeT,LeafNode>::value))
return NULL;
614 return reinterpret_cast<NodeT*
>(
this);
619 const LeafNode* probeLeaf(
const Coord&)
const {
return this; }
621 template<
typename AccessorT>
624 template<
typename AccessorT>
626 template<
typename NodeT,
typename AccessorT>
630 if (!(boost::is_same<NodeT,LeafNode>::value))
return NULL;
631 return reinterpret_cast<const NodeT*
>(
this);
644 template<
typename MaskIterT,
typename NodeT,
typename ValueT>
648 public SparseIteratorBase<MaskIterT, ValueIter<MaskIterT, NodeT, ValueT>, NodeT, ValueT>
653 ValueIter(
const MaskIterT& iter, NodeT* parent): BaseT(iter, parent) {}
655 const bool&
getItem(
Index pos)
const {
return this->parent().getValue(pos); }
656 const bool&
getValue()
const {
return this->getItem(this->pos()); }
659 void setItem(
Index pos,
bool value)
const { this->parent().setValueOnly(pos, value); }
661 void setValue(
bool value)
const { this->setItem(this->pos(), value); }
664 template<
typename ModifyOp>
665 void modifyItem(
Index n,
const ModifyOp& op)
const { this->parent().modifyValue(n, op); }
667 template<
typename ModifyOp>
668 void modifyValue(
const ModifyOp& op)
const { this->modifyItem(this->pos(), op); }
672 template<
typename MaskIterT,
typename NodeT>
678 MaskIterT, ChildIter<MaskIterT, NodeT>, NodeT, bool>(iter, parent) {}
681 template<
typename NodeT,
typename ValueT>
683 MaskDenseIter, DenseIter<NodeT, ValueT>, NodeT, void, ValueT>
689 DenseIter(
const MaskDenseIter& iter, NodeT* parent): BaseT(iter, parent) {}
693 value = this->parent().getValue(pos);
702 void unsetItem(
Index pos,
const ValueT& val)
const {this->parent().setValueOnly(pos, val);}
707 typedef ValueIter<MaskOnIter, const LeafNode, const bool>
ValueOnCIter;
719 ValueOnCIter
cbeginValueOn()
const {
return ValueOnCIter(mBuffer.mData.beginOn(),
this); }
720 ValueOnCIter
beginValueOn()
const {
return ValueOnCIter(mBuffer.mData.beginOn(),
this); }
721 ValueOnIter
beginValueOn() {
return ValueOnIter(mBuffer.mData.beginOn(),
this); }
722 ValueOffCIter
cbeginValueOff()
const {
return ValueOffCIter(mBuffer.mData.beginOff(),
this); }
723 ValueOffCIter
beginValueOff()
const {
return ValueOffCIter(mBuffer.mData.beginOff(),
this); }
724 ValueOffIter
beginValueOff() {
return ValueOffIter(mBuffer.mData.beginOff(),
this); }
725 ValueAllCIter
cbeginValueAll()
const {
return ValueAllCIter(mBuffer.mData.beginDense(),
this); }
726 ValueAllCIter
beginValueAll()
const {
return ValueAllCIter(mBuffer.mData.beginDense(),
this); }
727 ValueAllIter
beginValueAll() {
return ValueAllIter(mBuffer.mData.beginDense(),
this); }
729 ValueOnCIter
cendValueOn()
const {
return ValueOnCIter(mBuffer.mData.endOn(),
this); }
730 ValueOnCIter
endValueOn()
const {
return ValueOnCIter(mBuffer.mData.endOn(),
this); }
731 ValueOnIter
endValueOn() {
return ValueOnIter(mBuffer.mData.endOn(),
this); }
732 ValueOffCIter
cendValueOff()
const {
return ValueOffCIter(mBuffer.mData.endOff(),
this); }
733 ValueOffCIter
endValueOff()
const {
return ValueOffCIter(mBuffer.mData.endOff(),
this); }
734 ValueOffIter
endValueOff() {
return ValueOffIter(mBuffer.mData.endOff(),
this); }
735 ValueAllCIter
cendValueAll()
const {
return ValueAllCIter(mBuffer.mData.endDense(),
this); }
736 ValueAllCIter
endValueAll()
const {
return ValueAllCIter(mBuffer.mData.endDense(),
this); }
737 ValueAllIter
endValueAll() {
return ValueAllIter(mBuffer.mData.endDense(),
this); }
741 ChildOnCIter
cbeginChildOn()
const {
return ChildOnCIter(mBuffer.mData.endOn(),
this); }
742 ChildOnCIter
beginChildOn()
const {
return ChildOnCIter(mBuffer.mData.endOn(),
this); }
743 ChildOnIter
beginChildOn() {
return ChildOnIter(mBuffer.mData.endOn(),
this); }
744 ChildOffCIter
cbeginChildOff()
const {
return ChildOffCIter(mBuffer.mData.endOff(),
this); }
745 ChildOffCIter
beginChildOff()
const {
return ChildOffCIter(mBuffer.mData.endOff(),
this); }
746 ChildOffIter
beginChildOff() {
return ChildOffIter(mBuffer.mData.endOff(),
this); }
747 ChildAllCIter
cbeginChildAll()
const {
return ChildAllCIter(mBuffer.mData.beginDense(),
this); }
748 ChildAllCIter
beginChildAll()
const {
return ChildAllCIter(mBuffer.mData.beginDense(),
this); }
749 ChildAllIter
beginChildAll() {
return ChildAllIter(mBuffer.mData.beginDense(),
this); }
751 ChildOnCIter
cendChildOn()
const {
return ChildOnCIter(mBuffer.mData.endOn(),
this); }
752 ChildOnCIter
endChildOn()
const {
return ChildOnCIter(mBuffer.mData.endOn(),
this); }
753 ChildOnIter
endChildOn() {
return ChildOnIter(mBuffer.mData.endOn(),
this); }
754 ChildOffCIter
cendChildOff()
const {
return ChildOffCIter(mBuffer.mData.endOff(),
this); }
755 ChildOffCIter
endChildOff()
const {
return ChildOffCIter(mBuffer.mData.endOff(),
this); }
756 ChildOffIter
endChildOff() {
return ChildOffIter(mBuffer.mData.endOff(),
this); }
757 ChildAllCIter
cendChildAll()
const {
return ChildAllCIter(mBuffer.mData.endDense(),
this); }
758 ChildAllCIter
endChildAll()
const {
return ChildAllCIter(mBuffer.mData.endDense(),
this); }
759 ChildAllIter
endChildAll() {
return ChildAllIter(mBuffer.mData.endDense(),
this); }
769 const NodeMaskType&
valueMask()
const {
return mBuffer.mData; }
783 template<
typename NodeT,
typename VisitorOp,
typename ChildAllIterT>
784 static inline void doVisit(NodeT&, VisitorOp&);
786 template<
typename NodeT,
typename OtherNodeT,
typename VisitorOp,
787 typename ChildAllIterT,
typename OtherChildAllIterT>
788 static inline void doVisit2Node(NodeT&
self, OtherNodeT& other, VisitorOp&);
790 template<
typename NodeT,
typename VisitorOp,
791 typename ChildAllIterT,
typename OtherChildAllIterT>
792 static inline void doVisit2(NodeT&
self, OtherChildAllIterT&, VisitorOp&,
bool otherIsLHS);
809 friend struct ValueIter<MaskOnIter,
LeafNode, bool>;
810 friend struct ValueIter<MaskOffIter,
LeafNode, bool>;
811 friend struct ValueIter<MaskDenseIter,
LeafNode, bool>;
812 friend struct ValueIter<MaskOnIter, const
LeafNode, bool>;
813 friend struct ValueIter<MaskOffIter, const
LeafNode, bool>;
814 friend struct ValueIter<MaskDenseIter, const
LeafNode, bool>;
838 template<Index Log2Dim>
845 template<Index Log2Dim>
849 , mOrigin(xyz & (~(
DIM - 1)))
854 #ifndef OPENVDB_2_ABI_COMPATIBLE 855 template<Index Log2Dim>
859 , mOrigin(xyz & (~(
DIM - 1)))
865 template<Index Log2Dim>
868 : mBuffer(other.mBuffer)
869 , mOrigin(other.mOrigin)
875 template<Index Log2Dim>
876 template<
typename ValueT>
885 template<Index Log2Dim>
886 template<
typename ValueT>
896 template<Index Log2Dim>
897 template<
typename ValueT>
906 template<Index Log2Dim>
907 template<
typename ValueT>
914 if (offValue==
true) {
915 if (onValue==
false) {
916 mBuffer.
mData.toggle();
918 mBuffer.
mData.setOn();
924 template<Index Log2Dim>
934 template<Index Log2Dim>
939 return sizeof(*this);
943 template<Index Log2Dim>
948 if (bbox.
isInside(this_bbox))
return;
952 for(; iter; ++iter) this_bbox.
expand(this->offsetToLocalCoord(iter.pos()));
960 template<Index Log2Dim>
961 template<
typename OtherType, Index OtherLog2Dim>
970 template<Index Log2Dim>
974 std::ostringstream ostr;
975 ostr <<
"LeafNode @" << mOrigin <<
": ";
976 for (
Index32 n = 0; n <
SIZE; ++n) ostr << (mBuffer.
mData.isOn(n) ?
'#' :
'.');
984 template<Index Log2Dim>
988 assert ((xyz[0] & (
DIM-1u)) <
DIM && (xyz[1] & (
DIM-1u)) <
DIM && (xyz[2] & (
DIM-1u)) <
DIM);
989 return ((xyz[0] & (
DIM-1u)) << 2*Log2Dim)
990 + ((xyz[1] & (
DIM-1u)) << Log2Dim)
991 + (xyz[2] & (
DIM-1u));
995 template<Index Log2Dim>
999 assert(n < (1 << 3*Log2Dim));
1001 xyz.
setX(n >> 2*Log2Dim);
1002 n &= ((1 << 2*Log2Dim) - 1);
1003 xyz.
setY(n >> Log2Dim);
1004 xyz.
setZ(n & ((1 << Log2Dim) - 1));
1009 template<Index Log2Dim>
1020 template<Index Log2Dim>
1024 mBuffer.
mData.load(is);
1028 template<Index Log2Dim>
1032 mBuffer.
mData.save(os);
1036 template<Index Log2Dim>
1046 bool background =
false;
1048 background = *
static_cast<const bool*
>(bgPtr);
1050 this->
clip(clipBBox, background);
1054 template<Index Log2Dim>
1059 mBuffer.
mData.load(is);
1065 template<Index Log2Dim>
1070 mBuffer.
mData.save(os);
1072 os.write(reinterpret_cast<const char*>(&mOrigin),
sizeof(
Coord::ValueType) * 3);
1079 template<Index Log2Dim>
1083 return mOrigin == other.mOrigin && mBuffer == other.mBuffer;
1087 template<Index Log2Dim>
1098 template<Index Log2Dim>
1102 if (!mBuffer.
mData.isConstant(state))
return false;
1112 template<Index Log2Dim>
1119 template<Index Log2Dim>
1123 assert(offset <
SIZE);
1128 template<Index Log2Dim>
1129 template<
typename AccessorT>
1132 bool val,
bool active, AccessorT&)
1134 this->
addTile(level, xyz, val, active);
1141 template<Index Log2Dim>
1146 if (mBuffer.
mData.isOn(this->coordToOffset(xyz)))
return sOn;
else return sOff;
1150 template<Index Log2Dim>
1154 assert(offset <
SIZE);
1156 if (mBuffer.
mData.isOn(offset))
return sOn;
else return sOff;
1160 template<Index Log2Dim>
1165 val = mBuffer.
mData.isOn(offset);
1170 template<Index Log2Dim>
1178 template<Index Log2Dim>
1182 assert(offset <
SIZE);
1183 mBuffer.
mData.set(offset, val);
1187 template<Index Log2Dim>
1195 template<Index Log2Dim>
1203 template<Index Log2Dim>
1211 template<Index Log2Dim>
1215 assert(offset <
SIZE);
1216 mBuffer.
mData.set(offset, val);
1220 template<Index Log2Dim>
1221 template<
typename ModifyOp>
1225 bool val = mBuffer.
mData.isOn(offset);
1227 mBuffer.
mData.set(offset, val);
1231 template<Index Log2Dim>
1232 template<
typename ModifyOp>
1240 template<Index Log2Dim>
1241 template<
typename ModifyOp>
1246 bool val = mBuffer.
mData.isOn(offset), state = val;
1248 mBuffer.
mData.set(offset, val);
1255 template<Index Log2Dim>
1256 template<MergePolicy Policy>
1266 template<Index Log2Dim>
1267 template<MergePolicy Policy>
1273 if (tileValue) mBuffer.
mData.setOn();
1281 template<Index Log2Dim>
1282 template<
typename OtherType>
1290 template<Index Log2Dim>
1291 template<
typename OtherType>
1300 template<Index Log2Dim>
1301 template<
typename OtherType>
1313 template<Index Log2Dim>
1320 this->
fill(nodeBBox, background,
false);
1321 }
else if (clipBBox.
isInside(nodeBBox)) {
1333 int &x = xyz.
x(), &y = xyz.
y(), &z = xyz.
z();
1334 for (x = nodeBBox.
min().
x(); x <= nodeBBox.
max().
x(); ++x) {
1335 for (y = nodeBBox.
min().
y(); y <= nodeBBox.
max().
y(); ++y) {
1336 for (z = nodeBBox.
min().
z(); z <= nodeBBox.
max().
z(); ++z) {
1353 template<Index Log2Dim>
1358 const Index offsetX = (x & (
DIM-1u))<<2*Log2Dim;
1360 const Index offsetXY = offsetX + ((y & (
DIM-1u))<< Log2Dim);
1362 const Index offset = offsetXY + (z & (
DIM-1u));
1363 mBuffer.
mData.set(offset, value);
1369 template<Index Log2Dim>
1373 mBuffer.
fill(value);
1380 template<Index Log2Dim>
1381 template<
typename DenseT>
1385 typedef typename DenseT::ValueType DenseValueType;
1387 const size_t xStride = dense.xStride(), yStride = dense.yStride(), zStride = dense.zStride();
1388 const Coord&
min = dense.bbox().min();
1389 DenseValueType* t0 = dense.data() + zStride * (bbox.
min()[2] - min[2]);
1391 for (
Int32 x = bbox.
min()[0], ex = bbox.
max()[0] + 1; x < ex; ++x) {
1392 DenseValueType* t1 = t0 + xStride * (x - min[0]);
1394 for (
Int32 y = bbox.
min()[1], ey = bbox.
max()[1] + 1; y < ey; ++y) {
1395 DenseValueType* t2 = t1 + yStride * (y - min[1]);
1397 for (
Int32 z = bbox.
min()[2], ez = bbox.
max()[2] + 1; z < ez; ++z, t2 += zStride) {
1398 *t2 = DenseValueType(mBuffer.
mData.isOn(n2++));
1405 template<Index Log2Dim>
1406 template<
typename DenseT>
1409 bool background,
bool tolerance)
1411 typedef typename DenseT::ValueType DenseValueType;
1413 inline static bool toBool(
const DenseValueType& v) {
return !
math::isZero(v); }
1416 const size_t xStride = dense.xStride(), yStride = dense.yStride(), zStride = dense.zStride();
1417 const Coord&
min = dense.bbox().min();
1418 const DenseValueType* s0 = dense.data() + zStride * (bbox.
min()[2] - min[2]);
1420 for (
Int32 x = bbox.
min()[0], ex = bbox.
max()[0] + 1; x < ex; ++x) {
1421 const DenseValueType* s1 = s0 + xStride * (x - min[0]);
1423 for (
Int32 y = bbox.
min()[1], ey = bbox.
max()[1] + 1; y < ey; ++y) {
1424 const DenseValueType* s2 = s1 + yStride * (y - min[1]);
1426 for (
Int32 z = bbox.
min()[2], ez = bbox.
max()[2]+1; z < ez; ++z, ++n2, s2 += zStride) {
1428 if (tolerance || (background == Local::toBool(*s2))) {
1429 mBuffer.mData.set(n2, background);
1431 mBuffer.mData.set(n2, Local::toBool(*s2));
1442 template<Index Log2Dim>
1443 template<
typename CombineOp>
1449 bool result =
false, aVal = mBuffer.mData.isOn(i), bVal = other.mBuffer.
mData.isOn(i);
1454 .setResultRef(result));
1455 mBuffer.mData.set(i, result);
1460 template<Index Log2Dim>
1461 template<
typename CombineOp>
1466 args.
setBRef(value).setBIsActive(valueIsActive);
1468 bool result =
false, aVal = mBuffer.mData.isOn(i);
1471 .setResultRef(result));
1472 mBuffer.mData.set(i, result);
1480 template<Index Log2Dim>
1481 template<
typename CombineOp,
typename OtherType>
1484 bool valueIsActive, CombineOp& op)
1487 args.
setBRef(value).setBIsActive(valueIsActive);
1489 bool result =
false, aVal = other.mBuffer.
mData.isOn(i);
1492 .setResultRef(result));
1493 mBuffer.mData.set(i, result);
1498 template<Index Log2Dim>
1499 template<
typename CombineOp,
typename OtherNodeT>
1502 bool valueIsActive, CombineOp& op)
1505 args.
setARef(value).setAIsActive(valueIsActive);
1507 bool result =
false, bVal = other.mBuffer.mData.isOn(i);
1510 .setResultRef(result));
1511 mBuffer.mData.set(i, result);
1516 template<Index Log2Dim>
1517 template<
typename CombineOp,
typename OtherNodeT>
1523 bool result =
false, b0Val = b0.mBuffer.
mData.isOn(i), b1Val = b1.mBuffer.mData.isOn(i);
1525 .setAIsActive(b0Val)
1527 .setBIsActive(b1Val)
1528 .setResultRef(result));
1529 mBuffer.mData.set(i, result);
1536 template<Index Log2Dim>
1537 template<
typename BBoxOp>
1541 if (op.template descent<LEVEL>()) {
1559 template<Index Log2Dim>
1560 template<
typename VisitorOp>
1564 doVisit<LeafNode, VisitorOp, ChildAllIter>(*
this, op);
1568 template<Index Log2Dim>
1569 template<
typename VisitorOp>
1573 doVisit<const LeafNode, VisitorOp, ChildAllCIter>(*
this, op);
1577 template<Index Log2Dim>
1578 template<
typename NodeT,
typename VisitorOp,
typename ChildAllIterT>
1582 for (ChildAllIterT iter =
self.
beginChildAll(); iter; ++iter) {
1591 template<Index Log2Dim>
1592 template<
typename OtherLeafNodeType,
typename VisitorOp>
1597 typename OtherLeafNodeType::ChildAllIter>(*
this, other, op);
1601 template<Index Log2Dim>
1602 template<
typename OtherLeafNodeType,
typename VisitorOp>
1607 typename OtherLeafNodeType::ChildAllCIter>(*
this, other, op);
1611 template<Index Log2Dim>
1614 typename OtherNodeT,
1616 typename ChildAllIterT,
1617 typename OtherChildAllIterT>
1622 BOOST_STATIC_ASSERT(OtherNodeT::SIZE == NodeT::SIZE);
1623 BOOST_STATIC_ASSERT(OtherNodeT::LEVEL == NodeT::LEVEL);
1625 ChildAllIterT iter =
self.beginChildAll();
1626 OtherChildAllIterT otherIter = other.beginChildAll();
1628 for ( ; iter && otherIter; ++iter, ++otherIter) {
1629 op(iter, otherIter);
1637 template<Index Log2Dim>
1638 template<
typename IterT,
typename VisitorOp>
1642 doVisit2<LeafNode, VisitorOp, ChildAllIter, IterT>(*
this, otherIter, op, otherIsLHS);
1646 template<Index Log2Dim>
1647 template<
typename IterT,
typename VisitorOp>
1651 doVisit2<const LeafNode, VisitorOp, ChildAllCIter, IterT>(*
this, otherIter, op, otherIsLHS);
1655 template<Index Log2Dim>
1659 typename ChildAllIterT,
1660 typename OtherChildAllIterT>
1663 VisitorOp& op,
bool otherIsLHS)
1665 if (!otherIter)
return;
1668 for (ChildAllIterT iter =
self.
beginChildAll(); iter; ++iter) {
1669 op(otherIter, iter);
1672 for (ChildAllIterT iter =
self.
beginChildAll(); iter; ++iter) {
1673 op(iter, otherIter);
1682 #endif // OPENVDB_TREE_LEAF_NODE_MASK_HAS_BEEN_INCLUDED bool isDense() const
Return true if this node only contains active voxels.
Definition: LeafNodeMask.h:220
OffIterator beginOff() const
Definition: NodeMasks.h:351
void setOrigin(const Coord &origin)
Set the grid index coordinates of this node's local origin.
Definition: LeafNodeMask.h:246
const LeafNode * probeLeafAndCache(const Coord &, AccessorT &) const
Return a const pointer to this node.
Definition: LeafNodeMask.h:622
ChildAllCIter beginChildAll() const
Definition: LeafNodeMask.h:748
void evalActiveBoundingBox(CoordBBox &bbox, bool visitVoxels=true) const
Definition: LeafNode.h:1727
LeafNode specialization for values of type ValueMask that encodes both the active states and the bool...
Definition: LeafNodeMask.h:55
bool isValueOn(Index offset) const
Return true if the voxel at the given offset is active.
Definition: LeafNodeMask.h:366
const bool & getValueAndCache(const Coord &xyz, AccessorT &) const
Return the value of the voxel at the given coordinates.
Definition: LeafNodeMask.h:416
NodeMaskType & getValueMask()
Definition: LeafNodeMask.h:770
CoordBBox getNodeBoundingBox() const
Return the bounding box of this node, i.e., the full index space spanned by this leaf node...
Definition: LeafNode.h:469
ValueOffCIter cendValueOff() const
Definition: LeafNodeMask.h:732
ChildIter< MaskOnIter, const LeafNode > ChildOnCIter
Definition: LeafNodeMask.h:713
Index64 offLeafVoxelCount() const
Definition: LeafNodeMask.h:213
static const Index LEVEL
Definition: LeafNode.h:81
const NodeT * probeConstNode(const Coord &) const
This function exists only to enable template instantiation.
Definition: LeafNodeMask.h:591
static Index coordToOffset(const Coord &xyz)
Return the linear table offset of the given global or local coordinates.
Definition: LeafNode.h:1276
ValueIter< MaskOnIter, const LeafNode, const bool > ValueOnCIter
Definition: LeafNodeMask.h:707
static Index32 leafCount()
Return the leaf count for this node, which is one.
Definition: LeafNodeMask.h:204
NodeMaskType::Word WordType
Definition: LeafNodeMask.h:90
ChildAllCIter cbeginChildAll() const
Definition: LeafNodeMask.h:747
WordType * data()
Definition: LeafNodeMask.h:127
static Index getValueLevel(const Coord &)
Return the level (0) at which leaf node values reside.
Definition: LeafNodeMask.h:311
bool hasSameTopology(const LeafNode< OtherType, OtherLog2Dim > *other) const
Return true if the given node (which may have a different ValueType than this node) has the same acti...
Definition: LeafNode.h:1745
Coord & setX(Int32 x)
Definition: Coord.h:101
Index64 memUsage() const
Return the memory in bytes occupied by this node.
Definition: LeafNode.h:1717
General-purpose arithmetic and comparison routines, most of which accept arbitrary value types (or at...
static void getNodeLog2Dims(std::vector< Index > &dims)
Append the Log2Dim of this LeafNode to the specified vector.
Definition: LeafNodeMask.h:200
void addTile(Index level, const Coord &, const ValueType &, bool)
Definition: LeafNode.h:1792
static const bool sOn
Definition: LeafNodeMask.h:801
void setValue(bool value) const
Definition: LeafNodeMask.h:661
void writeTopology(std::ostream &os, bool toHalf=false) const
Write out just the topology.
Definition: LeafNode.h:1544
const bool & getFirstValue() const
Return a const reference to the first entry in the buffer.
Definition: LeafNodeMask.h:485
void reset()
Definition: Coord.h:338
void setValuesOff()
Mark all voxels as inactive but don't change their values.
Definition: LeafNodeMask.h:361
ValueAllIter endValueAll()
Definition: LeafNodeMask.h:737
bool isValueMaskOff() const
Definition: LeafNodeMask.h:767
void resetBackground(bool, bool)
no-op since for this temaplte specialization voxel values and states are indistinguishable.
Definition: LeafNodeMask.h:500
static Index getChildDim()
Return the dimension of child nodes of this LeafNode, which is one for voxels.
Definition: LeafNodeMask.h:202
void setItem(Index pos, bool value) const
Definition: LeafNodeMask.h:659
const NodeT * probeConstNodeAndCache(const Coord &, AccessorT &) const
Return a const pointer to this node.
Definition: LeafNodeMask.h:627
void setValueOn(const Coord &xyz)
Mark the voxel at the given coordinates as active but don't change its value.
Definition: LeafNode.h:714
void visit(VisitorOp &)
Definition: LeafNode.h:2068
static Coord offsetToLocalCoord(Index n)
Return the local coordinates for a linear table offset, where offset 0 has coordinates (0...
Definition: LeafNode.h:1286
ChildOffCIter endChildOff() const
Definition: LeafNodeMask.h:755
bool operator!=(const LeafNode &other) const
Definition: LeafNode.h:498
void setActiveState(Index offset, bool on)
Set the active state of the voxel at the given offset but don't change its value. ...
Definition: LeafNodeMask.h:316
ChildIter()
Definition: LeafNodeMask.h:676
Int32 ValueType
Definition: Coord.h:55
CombineArgs & setARef(const AValueType &a)
Redirect the A value to a new external source.
Definition: Types.h:365
Buffer(const Buffer &other)
Definition: LeafNodeMask.h:95
CoordBBox getNodeBoundingBox() const
Return the bounding box of this node, i.e., the full index space spanned by this leaf node...
Definition: LeafNodeMask.h:243
void setValueOff(Index offset)
Mark the voxel at the given offset as inactive but don't change its value.
Definition: LeafNodeMask.h:326
void topologyDifference(const LeafNode< OtherType, Log2Dim > &other, const ValueType &)
Difference this node's set of active values with the active values of the other node, whose ValueType may be different. So a resulting voxel will be active only if the original voxel is active in this LeafNode and inactive in the other LeafNode.
Definition: LeafNode.h:1914
void modifyValue(const ModifyOp &op) const
Definition: LeafNodeMask.h:668
void copyToDense(const CoordBBox &bbox, DenseT &dense) const
Copy into a dense grid the values of the voxels that lie within a given bounding box.
Definition: LeafNode.h:1468
bool isEmpty() const
Return true if this node has no active voxels.
Definition: LeafNodeMask.h:218
ValueOnCIter endValueOn() const
Definition: LeafNodeMask.h:730
ValueAllCIter beginValueAll() const
Definition: LeafNodeMask.h:726
const NodeMaskType & getValueMask() const
Definition: LeafNodeMask.h:768
ValueOffIter endValueOff()
Definition: LeafNodeMask.h:734
bool isZero(const Type &x)
Return true if x is exactly equal to zero.
Definition: Math.h:324
const bool & getItem(Index pos) const
Definition: LeafNodeMask.h:655
static Index dim()
Return the number of voxels in each dimension.
Definition: LeafNodeMask.h:192
void modifyValue(Index offset, const ModifyOp &op)
Apply a functor to the value of the voxel at the given offset and mark the voxel as active...
Definition: LeafNode.h:732
bool isChildMaskOn(Index) const
Definition: LeafNodeMask.h:772
Signed (x, y, z) 32-bit integer coordinates.
Definition: Coord.h:47
void readBuffers(std::istream &is, bool fromHalf=false)
Read buffers from a stream.
Definition: LeafNode.h:1598
Definition: PointIndexGrid.h:69
void modifyItem(Index n, const ModifyOp &op) const
Definition: LeafNodeMask.h:665
DenseIter< const LeafNode, const ValueType, ChildAll > ChildAllCIter
Definition: LeafNode.h:592
void addLeaf(LeafNode *)
This function exists only to enable template instantiation.
Definition: LeafNodeMask.h:583
ValueOffCIter beginValueOff() const
Definition: LeafNodeMask.h:723
ValueOnCIter beginValueOn() const
Definition: LeafNodeMask.h:720
void setValueOn(Index offset)
Mark the voxel at the given offset as active but don't change its value.
Definition: LeafNodeMask.h:336
boost::shared_ptr< LeafNodeType > Ptr
Definition: LeafNodeMask.h:59
const LeafNode * probeConstLeafAndCache(const Coord &, AccessorT &) const
Return a const pointer to this node.
Definition: LeafNodeMask.h:625
bool isValueMaskOff(Index n) const
Definition: LeafNodeMask.h:766
DenseIteratorBase< MaskDenseIter, DenseIter, NodeT, void, ValueT > BaseT
Definition: LeafNodeMask.h:685
static Index getValueLevelAndCache(const Coord &, AccessorT &)
Return the LEVEL (=0) at which leaf node values reside.
Definition: LeafNodeMask.h:480
void stealNodes(ArrayT &, const ValueType &, bool)
This function exists only to enable template instantiation.
Definition: LeafNodeMask.h:593
Index memUsage() const
Definition: LeafNodeMask.h:121
ValueOnIter endValueOn()
Definition: LeafNodeMask.h:731
Int32 x() const
Definition: Coord.h:146
void modifyValueAndActiveStateAndCache(const Coord &xyz, const ModifyOp &op, AccessorT &)
Definition: LeafNodeMask.h:454
NodeMaskType::DenseIterator MaskDenseIter
Definition: LeafNodeMask.h:642
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...
util::NodeMask< Log2Dim > NodeMaskType
Definition: LeafNodeMask.h:62
DenseIter< LeafNode, bool > ChildAllIter
Definition: LeafNodeMask.h:716
Buffer(bool on)
Definition: LeafNodeMask.h:93
void setValueOn(const Coord &xyz)
Mark the voxel at the given coordinates as active but don't change its value.
Definition: LeafNodeMask.h:334
bool probeValueAndCache(const Coord &xyz, bool &val, AccessorT &) const
Return true if the voxel at the given coordinates is active and return the voxel value in val...
Definition: LeafNodeMask.h:472
std::string str() const
Return a string representation of this node.
Definition: LeafNode.h:1263
ChildOffCIter cbeginChildOff() const
Definition: LeafNodeMask.h:744
ValueType * mData
Definition: LeafNode.h:361
ValueAllCIter cbeginValueAll() const
Definition: LeafNodeMask.h:725
Coord & setY(Int32 y)
Definition: Coord.h:102
const Buffer & buffer() const
Definition: LeafNodeMask.h:280
void getNodes(ArrayT &) const
This function exists only to enable template instantiation.
Definition: LeafNodeMask.h:592
const bool & getLastValue() const
Return a const reference to the last entry in the buffer.
Definition: LeafNodeMask.h:489
Index32 Index
Definition: Types.h:58
bool allocate()
Allocate memory for this node's buffer if it has not already been allocated.
Definition: LeafNodeMask.h:230
ChildOnCIter beginChildOn() const
Definition: LeafNodeMask.h:742
ValueMask BuildType
Definition: LeafNodeMask.h:60
Buffer(const NodeMaskType &other)
Definition: LeafNodeMask.h:94
bool getItem(Index pos, void *&child, NonConstValueT &value) const
Definition: LeafNodeMask.h:691
void unsetItem(Index pos, const ValueT &val) const
Definition: LeafNodeMask.h:702
bool isChildMaskOff(Index) const
Definition: LeafNodeMask.h:773
bool operator==(const Buffer &other) const
Definition: LeafNodeMask.h:114
int32_t Int32
Definition: Types.h:60
ValueOffCIter cbeginValueOff() const
Definition: LeafNodeMask.h:722
void combine2(const LeafNode &other, const OtherType &, bool valueIsActive, CombineOp &)
Definition: LeafNode.h:1981
uint64_t Index64
Definition: Types.h:57
void fill(const ValueType &val)
Populate this buffer with a constant value.
Definition: LeafNode.h:171
void fill(bool val)
Definition: LeafNodeMask.h:97
NodeT * probeNode(const Coord &)
This function exists only to enable template instantiation.
Definition: LeafNodeMask.h:589
ValueOffIter beginValueOff()
Definition: LeafNodeMask.h:724
ValueIter(const MaskIterT &iter, NodeT *parent)
Definition: LeafNodeMask.h:653
#define OPENVDB_VERSION_NAME
Definition: version.h:43
NodeMaskType::OnIterator MaskOnIter
Definition: LeafNodeMask.h:640
ValueOnCIter cbeginValueOn() const
Definition: LeafNodeMask.h:719
const Coord & origin() const
Return the grid index coordinates of this node's local origin.
Definition: LeafNode.h:475
ChildAllCIter endChildAll() const
Definition: LeafNodeMask.h:758
void clip(const CoordBBox &, const ValueType &background)
Set all voxels that lie outside the given axis-aligned box to the background.
Definition: LeafNode.h:1387
Coord & setZ(Int32 z)
Definition: Coord.h:103
void expand(ValueType padding)
Pad this bounding box with the specified padding.
Definition: Coord.h:401
ChildIter< MaskOnIter, LeafNode > ChildOnIter
Definition: LeafNodeMask.h:712
LeafNode< ValueMask, Log2Dim > LeafNodeType
Definition: LeafNodeMask.h:58
DenseIter(const MaskDenseIter &iter, NodeT *parent)
Definition: LeafNodeMask.h:689
ChildOnIter endChildOn()
Definition: LeafNodeMask.h:753
Coord mOrigin
Global grid index coordinates (x,y,z) of the local origin of this node.
Definition: LeafNodeMask.h:798
bool operator==(const LeafNode &other) const
Check for buffer, state and origin equivalence.
Definition: LeafNode.h:1707
static Index64 offTileCount()
Definition: LeafNodeMask.h:215
ValueOnCIter cendValueOn() const
Definition: LeafNodeMask.h:729
const NodeMaskType & valueMask() const
Definition: LeafNodeMask.h:769
void negate()
Invert the bits of the voxels, i.e. states and values.
Definition: LeafNodeMask.h:503
Templated block class to hold specific data types and a fixed number of values determined by Log2Dim...
Definition: LeafNode.h:65
void visit2Node(OtherLeafNodeType &other, VisitorOp &)
Definition: LeafNode.h:2100
NodeT * probeNodeAndCache(const Coord &, AccessorT &)
Return a pointer to this node.
Definition: LeafNodeMask.h:610
void setActiveState(const Coord &xyz, bool on)
Set the active state of the voxel at the given coordinates but don't change its value.
Definition: LeafNode.h:1361
ChildAllCIter beginChildAll() const
Definition: LeafNode.h:623
void setValueMaskOn(Index n)
Definition: LeafNodeMask.h:777
void setValueAndCache(const Coord &xyz, bool val, AccessorT &)
Change the value of the voxel at the given coordinates and mark it as active.
Definition: LeafNodeMask.h:426
Index64 onLeafVoxelCount() const
Definition: LeafNodeMask.h:212
const bool & operator[](Index i) const
Definition: LeafNodeMask.h:112
Bit mask for the internal and leaf nodes of VDB. This is a 64-bit implementation. ...
Definition: NodeMasks.h:304
void addTileAndCache(Index, const Coord &, const ValueType &, bool, AccessorT &)
Definition: LeafNode.h:1809
void translate(const Coord &t)
Translate this bounding box by .
Definition: Coord.h:440
~LeafNode()
Destructor.
Definition: LeafNode.h:1256
const LeafNode * probeConstLeaf(const Coord &) const
Return a const pointer to this node.
Definition: LeafNodeMask.h:623
BaseT::NonConstValueType NonConstValueT
Definition: LeafNodeMask.h:686
ChildOnCIter cbeginChildOn() const
Definition: LeafNodeMask.h:741
void readTopology(std::istream &is, bool fromHalf=false)
Read in just the topology.
Definition: LeafNode.h:1536
ChildOnCIter cendChildOn() const
Definition: LeafNodeMask.h:751
ValueOffCIter endValueOff() const
Definition: LeafNodeMask.h:733
Definition: Exceptions.h:39
LeafNode< OtherValueType, Log2Dim > Type
Definition: LeafNodeMask.h:77
Index64 offVoxelCount() const
Return the number of inactive voxels.
Definition: LeafNodeMask.h:211
static Index log2dim()
Return log2 of the size of the buffer storage.
Definition: LeafNodeMask.h:190
void topologyUnion(const LeafNode< OtherType, Log2Dim > &other)
Union this node's set of active values with the active values of the other node, whose ValueType may ...
Definition: LeafNode.h:1897
static Index32 nonLeafCount()
Return the non-leaf count for this node, which is zero.
Definition: LeafNodeMask.h:206
ChildAllCIter cendChildAll() const
Definition: LeafNodeMask.h:757
static Index getLevel()
Return the level of this node, which by definition is zero for LeafNodes.
Definition: LeafNodeMask.h:198
NodeMaskType::OffIterator MaskOffIter
Definition: LeafNodeMask.h:641
uint32_t Index32
Definition: Types.h:56
const bool & getValue() const
Definition: LeafNodeMask.h:656
bool isValueMaskOn() const
Definition: LeafNodeMask.h:765
ValueAllIter beginValueAll()
Definition: LeafNodeMask.h:727
ChildIter< MaskOffIter, LeafNode > ChildOffIter
Definition: LeafNodeMask.h:714
void setValueMaskOff(Index n)
Definition: LeafNodeMask.h:778
bool isValueOnAndCache(const Coord &xyz, AccessorT &) const
Return true if the voxel at the given coordinates is active.
Definition: LeafNodeMask.h:421
void setValuesOn()
Mark all voxels as active but don't change their values.
Definition: LeafNodeMask.h:359
Index64 Word
Definition: NodeMasks.h:313
const NodeMaskType & valueMask() const
Definition: LeafNode.h:1111
LeafNode * probeLeafAndCache(const Coord &, AccessorT &)
Return a pointer to this node.
Definition: LeafNodeMask.h:608
ValueIter< MaskDenseIter, LeafNode, const bool > ValueAllIter
Definition: LeafNodeMask.h:710
Base class for dense iterators over internal and leaf nodes.
Definition: Iterator.h:211
SparseIteratorBase< MaskIterT, ValueIter, NodeT, ValueT > BaseT
Definition: LeafNodeMask.h:650
Base class for sparse iterators over internal and leaf nodes.
Definition: Iterator.h:148
bool isValueOn(const Coord &xyz) const
Return true if the voxel at the given coordinates is active.
Definition: LeafNodeMask.h:364
boost::remove_const< UnsetItemT >::type NonConstValueType
Definition: Iterator.h:217
const ValueType & getValue(const Coord &xyz) const
Return the value of the voxel at the given coordinates.
Definition: LeafNode.h:1311
static void doVisit2(NodeT &self, OtherChildAllIterT &, VisitorOp &, bool otherIsLHS)
Definition: LeafNode.h:2170
Int32 z() const
Definition: Coord.h:148
void visitActiveBBox(BBoxOp &) const
Calls the templated functor BBoxOp with bounding box information. An additional level argument is pro...
Definition: LeafNode.h:2045
static Index64 onTileCount()
Definition: LeafNodeMask.h:214
Definition: NodeMasks.h:267
ChildAllIter beginChildAll()
Definition: LeafNodeMask.h:749
static const Index SIZE
Definition: LeafNode.h:80
void setValueMask(Index n, bool on)
Definition: LeafNodeMask.h:776
bool operator!=(const Buffer &other) const
Definition: LeafNodeMask.h:115
static const bool sOff
Definition: LeafNodeMask.h:802
ChildOffIter beginChildOff()
Definition: LeafNodeMask.h:746
void setOn(Index32 n)
Set the nth bit on.
Definition: NodeMasks.h:449
void combine(const LeafNode &other, CombineOp &op)
Definition: LeafNode.h:1939
const WordType * data() const
Definition: LeafNodeMask.h:135
const Coord & min() const
Definition: Coord.h:332
ValueIter< MaskOffIter, const LeafNode, const bool > ValueOffCIter
Definition: LeafNodeMask.h:709
bool ValueType
Definition: LeafNodeMask.h:61
static void doVisit2Node(NodeT &self, OtherNodeT &other, VisitorOp &)
Definition: LeafNode.h:2125
bool operator==(const Vec3< T0 > &v0, const Vec3< T1 > &v1)
Equality operator, does exact floating point comparisons.
Definition: Vec3.h:450
ChildOnCIter endChildOn() const
Definition: LeafNodeMask.h:752
LeafNode()
Default constructor.
Definition: LeafNode.h:1170
void setActiveStateAndCache(const Coord &xyz, bool on, AccessorT &)
Set the active state of the voxel at the given coordinates without changing its value.
Definition: LeafNodeMask.h:463
bool hasOverlap(const CoordBBox &b) const
Return true if the given bounding box overlaps with this bounding box.
Definition: Coord.h:395
ChildIter(const MaskIterT &iter, NodeT *parent)
Definition: LeafNodeMask.h:677
const Coord & max() const
Definition: Coord.h:333
void setValueOff(const Coord &xyz)
Mark the voxel at the given coordinates as inactive but don't change its value.
Definition: LeafNodeMask.h:324
Buffer & buffer()
Definition: LeafNodeMask.h:281
CombineArgs & setBRef(const BValueType &b)
Redirect the B value to a new external source.
Definition: Types.h:367
static void evalNodeOrigin(Coord &xyz)
Compute the origin of the leaf node that contains the voxel with the given coordinates.
Definition: LeafNodeMask.h:781
const NodeMaskType & getValueMask() const
Definition: LeafNode.h:1109
static Index size()
Definition: LeafNodeMask.h:122
Axis-aligned bounding box of signed integer coordinates.
Definition: Coord.h:259
ValueOnCIter cbeginValueOn() const
Definition: LeafNode.h:594
void modifyValueAndCache(const Coord &xyz, const ModifyOp &op, AccessorT &)
Apply a functor to the value of the voxel at the given coordinates and mark the voxel as active...
Definition: LeafNodeMask.h:446
void setValueOnly(const Coord &xyz, const ValueType &val)
Set the value of the voxel at the given coordinates but don't change its active state.
Definition: LeafNode.h:1369
DenseIter()
Definition: LeafNodeMask.h:688
void setValueOffAndCache(const Coord &xyz, bool value, AccessorT &)
Change the value of the voxel at the given coordinates and mark it as inactive.
Definition: LeafNodeMask.h:437
static const Index LOG2DIM
Definition: LeafNode.h:75
void swap(Buffer &other)
Exchange this node's data buffer with the given data buffer without changing the active states of the...
Definition: LeafNodeMask.h:279
Index64 onVoxelCount() const
Return the number of active voxels.
Definition: LeafNodeMask.h:209
void writeBuffers(std::ostream &os, bool toHalf=false) const
Write buffers to a stream.
Definition: LeafNode.h:1690
Int32 y() const
Definition: Coord.h:147
void getOrigin(Coord &origin) const
Return the grid index coordinates of this node's local origin.
Definition: LeafNodeMask.h:250
DenseIter< LeafNode, ValueType, ChildAll > ChildAllIter
Definition: LeafNode.h:591
void setValue(const Coord &xyz, bool val)
Set the value of the voxel at the given coordinates and mark the voxel as active. ...
Definition: LeafNodeMask.h:341
ChildIter< MaskOffIter, const LeafNode > ChildOffCIter
Definition: LeafNodeMask.h:715
bool operator!=(const Vec3< T0 > &v0, const Vec3< T1 > &v1)
Inequality operator, does exact floating point comparisons.
Definition: Vec3.h:458
void intersect(const CoordBBox &bbox)
Intersect this bounding box with the given bounding box.
Definition: Coord.h:427
void copyFromDense(const CoordBBox &bbox, const DenseT &dense, const ValueType &background, const ValueType &tolerance)
Copy from a dense grid into this node the values of the voxels that lie within a given bounding box...
Definition: LeafNode.h:1497
ValueIter< MaskOffIter, LeafNode, const bool > ValueOffIter
Definition: LeafNodeMask.h:708
ValueAllCIter endValueAll() const
Definition: LeafNodeMask.h:736
ChildAllIter endChildAll()
Definition: LeafNodeMask.h:759
void setValueMask(const NodeMaskType &mask)
Definition: LeafNodeMask.h:771
ChildOffCIter beginChildOff() const
Definition: LeafNodeMask.h:745
Definition: NodeMasks.h:205
void voxelizeActiveTiles(bool=true)
No-op.
Definition: LeafNodeMask.h:511
ChildOffIter endChildOff()
Definition: LeafNodeMask.h:756
Definition: NodeMasks.h:236
bool isInactive() const
Return true if all of this node's values are inactive.
Definition: LeafNodeMask.h:496
ValueIter< MaskOnIter, LeafNode, const bool > ValueOnIter
Definition: LeafNodeMask.h:706
bool isInside(const Coord &xyz) const
Return true if point (x, y, z) is inside this bounding box.
Definition: Coord.h:383
static void doVisit(NodeT &, VisitorOp &)
Definition: LeafNode.h:2086
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h:71
void swap(Buffer &other)
Definition: LeafNodeMask.h:119
static bool hasActiveTiles()
Return false since leaf nodes never contain tiles.
Definition: LeafNodeMask.h:369
void setValueOnly(Index offset, bool val)
Set the value of the voxel at the given offset but don't change its active state. ...
Definition: LeafNodeMask.h:321
void setValueOnlyAndCache(const Coord &xyz, bool val, AccessorT &)
Change the value of the voxel at the given coordinates but preserve its state.
Definition: LeafNodeMask.h:432
void topologyIntersection(const LeafNode< OtherType, Log2Dim > &other, const ValueType &)
Intersect this node's set of active values with the active values of the other node, whose ValueType may be different. So a resulting voxel will be active only if both of the original voxels were active.
Definition: LeafNode.h:1905
ValueIter< MaskDenseIter, const LeafNode, const bool > ValueAllCIter
Definition: LeafNodeMask.h:711
static Index numValues()
Return the total number of voxels represented by this LeafNode.
Definition: LeafNodeMask.h:196
static Index size()
Return the total number of voxels represented by this LeafNode.
Definition: LeafNodeMask.h:194
bool isConstant(ValueType &firstValue, bool &state, const ValueType &tolerance=zeroVal< ValueType >()) const
Definition: LeafNode.h:1753
void merge(const LeafNode &)
Definition: LeafNode.h:1844
void modifyValueAndActiveState(const Coord &xyz, const ModifyOp &op)
Apply a functor to the voxel at the given coordinates.
Definition: LeafNode.h:749
bool probeValue(const Coord &xyz, ValueType &val) const
Return true if the voxel at the given coordinates is active.
Definition: LeafNode.h:1327
Buffer mBuffer
Bitmask representing the values AND state of voxels.
Definition: LeafNodeMask.h:795
Buffer & operator=(const Buffer &b)
Definition: LeafNodeMask.h:98
bool isValueMaskOn(Index n) const
Definition: LeafNodeMask.h:764
ValueAllCIter cendValueAll() const
Definition: LeafNodeMask.h:735
LeafNode * probeLeaf(const Coord &)
Return a pointer to this node.
Definition: LeafNodeMask.h:606
void visit2(IterT &otherIter, VisitorOp &, bool otherIsLHS=false)
Definition: LeafNode.h:2146
DenseIter< const LeafNode, const bool > ChildAllCIter
Definition: LeafNodeMask.h:717
void fill(const CoordBBox &bbox, const ValueType &, bool active=true)
Set all voxels within an axis-aligned box to the specified value and active state.
Definition: LeafNode.h:1427
ValueOnIter beginValueOn()
Definition: LeafNodeMask.h:721
void setValue(Index i, bool val)
Definition: LeafNodeMask.h:117
void setValueOff(const Coord &xyz)
Mark the voxel at the given coordinates as inactive but don't change its value.
Definition: LeafNode.h:704
void addLeafAndCache(LeafNode *, AccessorT &)
This function exists only to enable template instantiation.
Definition: LeafNodeMask.h:585
~Buffer()
Definition: LeafNodeMask.h:96
bool isChildMaskOff() const
Definition: LeafNodeMask.h:774
Buffer()
Definition: LeafNodeMask.h:92
This struct collects both input and output arguments to "grid combiner" functors used with the tree::...
Definition: Types.h:312
const bool & getValue(Index i) const
Definition: LeafNodeMask.h:104
ChildOnIter beginChildOn()
Definition: LeafNodeMask.h:743
ValueIter()
Definition: LeafNodeMask.h:652
ChildOffCIter cendChildOff() const
Definition: LeafNodeMask.h:754
NodeT * stealNode(const Coord &, const ValueType &, bool)
This function exists only to enable template instantiation.
Definition: LeafNodeMask.h:587
static const Index DIM
Definition: LeafNode.h:77
Coord offsetToGlobalCoord(Index n) const
Return the global coordinates for a linear table offset.
Definition: LeafNode.h:1300
static CoordBBox createCube(const Coord &min, ValueType dim)
Definition: Coord.h:324
void getOrigin(Int32 &x, Int32 &y, Int32 &z) const
Return the grid index coordinates of this node's local origin.
Definition: LeafNodeMask.h:251
Base class for iterators over internal and leaf nodes.
Definition: Iterator.h:58
LeafNode * touchLeafAndCache(const Coord &, AccessorT &)
Return a pointer to this node.
Definition: LeafNodeMask.h:605