31 #ifndef OPENVDB_TREE_LEAF_NODE_BOOL_HAS_BEEN_INCLUDED 32 #define OPENVDB_TREE_LEAF_NODE_BOOL_HAS_BEEN_INCLUDED 34 #include <openvdb/Types.h> 35 #include <openvdb/io/Compression.h> 36 #include <openvdb/math/Math.h> 37 #include <openvdb/util/NodeMasks.h> 43 #include <type_traits> 54 template<Index Log2Dim>
66 static const Index LOG2DIM = Log2Dim;
67 static const Index TOTAL = Log2Dim;
68 static const Index DIM = 1 << TOTAL;
69 static const Index NUM_VALUES = 1 << 3 * Log2Dim;
70 static const Index NUM_VOXELS = NUM_VALUES;
71 static const Index SIZE = NUM_VALUES;
76 template<
typename ValueType>
81 template<
typename OtherNodeType>
82 struct SameConfiguration {
94 explicit LeafNode(
const Coord& xyz,
bool value =
false,
bool active =
false);
96 #if OPENVDB_ABI_VERSION_NUMBER >= 3 108 template<
typename OtherValueType>
112 template<
typename ValueType>
116 template<
typename ValueType>
120 template<
typename ValueType>
153 bool isEmpty()
const {
return mValueMask.isOff(); }
155 bool isDense()
const {
return mValueMask.isOn(); }
157 #if OPENVDB_ABI_VERSION_NUMBER >= 3 158 bool isAllocated()
const {
return true; }
174 void evalActiveBoundingBox(
CoordBBox& bbox,
bool visitVoxels =
true)
const;
183 const Coord& origin()
const {
return mOrigin; }
198 std::string str()
const;
202 template<
typename OtherType, Index OtherLog2Dim>
222 void readTopology(std::istream&,
bool fromHalf =
false);
224 void writeTopology(std::ostream&,
bool toHalf =
false)
const;
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;
236 const bool& getValue(
const Coord& xyz)
const;
238 const bool& getValue(
Index offset)
const;
243 bool probeValue(
const Coord& xyz,
bool& val)
const;
249 void setActiveState(
const Coord& xyz,
bool on);
254 void setValueOnly(
const Coord& xyz,
bool val);
256 void setValueOnly(
Index offset,
bool val) { assert(offset<SIZE); mBuffer.setValue(offset,val); }
264 void setValueOff(
const Coord& xyz,
bool val);
266 void setValueOff(
Index offset,
bool val);
274 void setValueOn(
const Coord& xyz,
bool val);
278 void setValueOn(
Index offset,
bool val);
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);
290 template<
typename ModifyOp>
291 void modifyValueAndActiveState(
const Coord& xyz,
const ModifyOp& op);
299 bool isValueOn(
const Coord& xyz)
const {
return mValueMask.isOn(this->coordToOffset(xyz)); }
301 bool isValueOn(
Index offset)
const { assert(offset < SIZE);
return mValueMask.isOn(offset); }
310 void fill(
const CoordBBox& bbox,
bool value,
bool active =
true);
315 void fill(
const bool& value);
317 void fill(
const bool& value,
bool active);
330 template<
typename DenseT>
349 template<
typename DenseT>
354 template<
typename AccessorT>
359 template<
typename AccessorT>
364 template<
typename AccessorT>
370 template<
typename AccessorT>
375 template<
typename AccessorT>
378 this->setValueOff(xyz, value);
384 template<
typename ModifyOp,
typename AccessorT>
387 this->modifyValue(xyz, op);
392 template<
typename ModifyOp,
typename AccessorT>
395 this->modifyValueAndActiveState(xyz, op);
401 template<
typename AccessorT>
404 this->setActiveState(xyz, on);
410 template<
typename AccessorT>
413 return this->probeValue(xyz, val);
418 template<
typename AccessorT>
424 const bool&
getFirstValue()
const {
if (mValueMask.isOn(0))
return Buffer::sOn;
else return Buffer::sOff; }
428 const bool&
getLastValue()
const {
if (mValueMask.isOn(SIZE-1))
return Buffer::sOn;
else return Buffer::sOff; }
433 bool isConstant(
bool& constValue,
bool& state,
bool tolerance = 0)
const;
440 bool medianAll()
const;
461 void resetBackground(
bool oldBackground,
bool newBackground);
463 void negate() { mBuffer.mData.toggle(); }
465 template<MergePolicy Policy>
466 void merge(
const LeafNode& other,
bool bg =
false,
bool otherBG =
false);
467 template<MergePolicy Policy>
void merge(
bool tileValue,
bool tileActive);
479 template<
typename OtherType>
493 template<
typename OtherType>
507 template<
typename OtherType>
510 template<
typename CombineOp>
511 void combine(
const LeafNode& other, CombineOp& op);
512 template<
typename CombineOp>
513 void combine(
bool,
bool valueIsActive, CombineOp& op);
515 template<
typename CombineOp,
typename OtherType >
516 void combine2(
const LeafNode& other,
const OtherType&,
bool valueIsActive, CombineOp&);
517 template<
typename CombineOp,
typename OtherNodeT >
518 void combine2(
bool,
const OtherNodeT& other,
bool valueIsActive, CombineOp&);
519 template<
typename CombineOp,
typename OtherNodeT >
520 void combine2(
const LeafNode& b0,
const OtherNodeT& b1, CombineOp&);
526 template<
typename BBoxOp>
void visitActiveBBox(BBoxOp&)
const;
528 template<
typename VisitorOp>
void visit(VisitorOp&);
529 template<
typename VisitorOp>
void visit(VisitorOp&)
const;
531 template<
typename OtherLeafNodeType,
typename VisitorOp>
532 void visit2Node(OtherLeafNodeType& other, VisitorOp&);
533 template<
typename OtherLeafNodeType,
typename VisitorOp>
534 void visit2Node(OtherLeafNodeType& other, VisitorOp&)
const;
535 template<
typename IterT,
typename VisitorOp>
536 void visit2(IterT& otherIter, VisitorOp&,
bool otherIsLHS =
false);
537 template<
typename IterT,
typename VisitorOp>
538 void visit2(IterT& otherIter, VisitorOp&,
bool otherIsLHS =
false)
const;
544 template<
typename AccessorT>
546 template<
typename NodeT>
548 template<
typename NodeT>
550 template<
typename NodeT>
552 template<
typename ArrayT>
void getNodes(ArrayT&)
const {}
556 void addTile(
Index level,
const Coord&,
bool val,
bool active);
557 void addTile(
Index offset,
bool val,
bool active);
558 template<
typename AccessorT>
559 void addTileAndCache(
Index level,
const Coord&,
bool val,
bool active, AccessorT&);
564 template<
typename AccessorT>
567 template<
typename AccessorT>
569 template<
typename NodeT,
typename AccessorT>
573 if (!(std::is_same<NodeT, LeafNode>::value))
return nullptr;
574 return reinterpret_cast<NodeT*
>(
this);
579 const LeafNode* probeLeaf(
const Coord&)
const {
return this; }
581 template<
typename AccessorT>
584 template<
typename AccessorT>
586 template<
typename NodeT,
typename AccessorT>
590 if (!(std::is_same<NodeT, LeafNode>::value))
return nullptr;
591 return reinterpret_cast<const NodeT*
>(
this);
604 template<
typename MaskIterT,
typename NodeT,
typename ValueT>
608 public SparseIteratorBase<MaskIterT, ValueIter<MaskIterT, NodeT, ValueT>, NodeT, ValueT>
615 const bool&
getItem(
Index pos)
const {
return this->parent().getValue(pos); }
616 const bool&
getValue()
const {
return this->getItem(this->pos()); }
619 void setItem(
Index pos,
bool value)
const { this->parent().setValueOnly(pos, value); }
621 void setValue(
bool value)
const { this->setItem(this->pos(), value); }
624 template<
typename ModifyOp>
625 void modifyItem(
Index n,
const ModifyOp& op)
const { this->parent().modifyValue(n, op); }
627 template<
typename ModifyOp>
628 void modifyValue(
const ModifyOp& op)
const { this->modifyItem(this->pos(), op); }
632 template<
typename MaskIterT,
typename NodeT>
638 MaskIterT, ChildIter<MaskIterT, NodeT>, NodeT, bool>(iter, parent) {}
641 template<
typename NodeT,
typename ValueT>
643 MaskDenseIter, DenseIter<NodeT, ValueT>, NodeT, void, ValueT>
653 value = this->parent().getValue(pos);
662 void unsetItem(
Index pos,
const ValueT& val)
const {this->parent().setValueOnly(pos, val);}
667 using ValueOnCIter = ValueIter<MaskOnIter, const LeafNode, const bool>;
743 template<
typename NodeT,
typename VisitorOp,
typename ChildAllIterT>
744 static inline void doVisit(NodeT&, VisitorOp&);
746 template<
typename NodeT,
typename OtherNodeT,
typename VisitorOp,
747 typename ChildAllIterT,
typename OtherChildAllIterT>
748 static inline void doVisit2Node(NodeT&
self, OtherNodeT& other, VisitorOp&);
750 template<
typename NodeT,
typename VisitorOp,
751 typename ChildAllIterT,
typename OtherChildAllIterT>
752 static inline void doVisit2(NodeT&
self, OtherChildAllIterT&, VisitorOp&,
bool otherIsLHS);
788 template<Index Log2Dim>
796 template<Index Log2Dim>
801 , mOrigin(xyz & (~(
DIM - 1)))
806 #if OPENVDB_ABI_VERSION_NUMBER >= 3 807 template<Index Log2Dim>
812 , mOrigin(xyz & (~(
DIM - 1)))
821 template<Index Log2Dim>
825 , mBuffer(other.mBuffer)
826 , mOrigin(other.mOrigin)
832 template<Index Log2Dim>
833 template<
typename ValueT>
841 static inline bool convertValue(
const ValueT& val) {
return bool(val); }
845 mBuffer.setValue(i, Local::convertValue(other.mBuffer[i]));
850 template<Index Log2Dim>
851 template<
typename ValueT>
856 , mBuffer(background)
862 template<Index Log2Dim>
863 template<
typename ValueT>
873 template<Index Log2Dim>
874 template<
typename ValueT>
882 if (offValue) {
if (!onValue) mBuffer.
mData.toggle();
else mBuffer.
mData.setOn(); }
886 template<Index Log2Dim>
896 template<Index Log2Dim>
901 return sizeof(*this);
905 template<Index Log2Dim>
910 if (bbox.
isInside(this_bbox))
return;
914 for(; iter; ++iter) this_bbox.
expand(this->offsetToLocalCoord(iter.pos()));
922 template<Index Log2Dim>
923 template<
typename OtherType, Index OtherLog2Dim>
928 return (Log2Dim == OtherLog2Dim && mValueMask == other->
getValueMask());
932 template<Index Log2Dim>
936 std::ostringstream ostr;
937 ostr <<
"LeafNode @" << mOrigin <<
": ";
938 for (
Index32 n = 0; n <
SIZE; ++n) ostr << (mValueMask.
isOn(n) ?
'#' :
'.');
946 template<Index Log2Dim>
950 assert ((xyz[0] & (
DIM-1u)) <
DIM && (xyz[1] & (
DIM-1u)) <
DIM && (xyz[2] & (
DIM-1u)) <
DIM);
951 return ((xyz[0] & (
DIM-1u)) << 2*Log2Dim)
952 + ((xyz[1] & (
DIM-1u)) << Log2Dim)
953 + (xyz[2] & (
DIM-1u));
957 template<Index Log2Dim>
961 assert(n < (1 << 3*Log2Dim));
963 xyz.
setX(n >> 2*Log2Dim);
964 n &= ((1 << 2*Log2Dim) - 1);
965 xyz.
setY(n >> Log2Dim);
966 xyz.
setZ(n & ((1 << Log2Dim) - 1));
971 template<Index Log2Dim>
982 template<Index Log2Dim>
990 template<Index Log2Dim>
998 template<Index Log2Dim>
1008 bool background =
false;
1010 background = *
static_cast<const bool*
>(bgPtr);
1012 this->
clip(clipBBox, background);
1016 template<Index Log2Dim>
1021 mValueMask.
load(is);
1027 mBuffer.
mData.load(is);
1032 int8_t numBuffers = 0;
1033 is.read(reinterpret_cast<char*>(&numBuffers),
sizeof(int8_t));
1037 std::unique_ptr<bool[]> buf{
new bool[
SIZE]};
1038 io::readData<bool>(is, buf.get(),
SIZE,
true);
1041 mBuffer.
mData.setOff();
1043 if (buf[i]) mBuffer.
mData.setOn(i);
1046 if (numBuffers > 1) {
1049 for (
int i = 1; i < numBuffers; ++i) {
1050 io::readData<bool>(is, buf.get(),
SIZE,
true);
1057 template<Index Log2Dim>
1062 mValueMask.
save(os);
1064 os.write(reinterpret_cast<const char*>(&mOrigin),
sizeof(
Coord::ValueType) * 3);
1066 mBuffer.
mData.save(os);
1073 template<Index Log2Dim>
1077 return mOrigin == other.mOrigin &&
1079 mBuffer == other.mBuffer;
1083 template<Index Log2Dim>
1094 template<Index Log2Dim>
1098 if (!mValueMask.
isConstant(state))
return false;
1101 if (!tolerance && !(mBuffer.
mData.isOn() || mBuffer.
mData.isOff()))
return false;
1103 constValue = mBuffer.
mData.isOn();
1109 template<Index Log2Dim>
1113 const Index countTrue = mBuffer.
mData.countOn();
1117 template<Index Log2Dim>
1127 template<Index Log2Dim>
1140 template<Index Log2Dim>
1147 template<Index Log2Dim>
1151 assert(offset <
SIZE);
1156 template<Index Log2Dim>
1157 template<
typename AccessorT>
1160 bool val,
bool active, AccessorT&)
1162 this->
addTile(level, xyz, val, active);
1169 template<Index Log2Dim>
1174 if (mBuffer.
mData.isOn(this->coordToOffset(xyz)))
return Buffer::sOn;
else return Buffer::sOff;
1178 template<Index Log2Dim>
1182 assert(offset <
SIZE);
1184 if (mBuffer.
mData.isOn(offset))
return Buffer::sOn;
else return Buffer::sOff;
1188 template<Index Log2Dim>
1193 val = mBuffer.
mData.isOn(offset);
1194 return mValueMask.
isOn(offset);
1198 template<Index Log2Dim>
1206 template<Index Log2Dim>
1210 assert(offset <
SIZE);
1211 mValueMask.
setOn(offset);
1212 mBuffer.
mData.set(offset, val);
1216 template<Index Log2Dim>
1224 template<Index Log2Dim>
1232 template<Index Log2Dim>
1240 template<Index Log2Dim>
1244 assert(offset <
SIZE);
1245 mValueMask.
setOff(offset);
1246 mBuffer.
mData.set(offset, val);
1250 template<Index Log2Dim>
1251 template<
typename ModifyOp>
1255 bool val = mBuffer.
mData.isOn(offset);
1257 mBuffer.
mData.set(offset, val);
1258 mValueMask.
setOn(offset);
1262 template<Index Log2Dim>
1263 template<
typename ModifyOp>
1271 template<Index Log2Dim>
1272 template<
typename ModifyOp>
1277 bool val = mBuffer.
mData.isOn(offset), state = mValueMask.
isOn(offset);
1279 mBuffer.
mData.set(offset, val);
1280 mValueMask.
set(offset, state);
1287 template<Index Log2Dim>
1291 if (newBackground != oldBackground) {
1295 mBuffer.
mData = (mBuffer.
mData & mValueMask) | bgMask;
1303 template<Index Log2Dim>
1304 template<MergePolicy Policy>
1311 const Index n = iter.pos();
1312 if (mValueMask.
isOff(n)) {
1313 mBuffer.
mData.set(n, other.mBuffer.
mData.isOn(n));
1314 mValueMask.
setOn(n);
1320 template<Index Log2Dim>
1321 template<MergePolicy Policy>
1327 if (!tileActive)
return;
1329 if (tileValue) mBuffer.
mData |= !mValueMask;
1330 else mBuffer.
mData &= mValueMask;
1339 template<Index Log2Dim>
1340 template<
typename OtherType>
1348 template<Index Log2Dim>
1349 template<
typename OtherType>
1358 template<Index Log2Dim>
1359 template<
typename OtherType>
1371 template<Index Log2Dim>
1378 this->
fill(nodeBBox, background,
false);
1379 }
else if (clipBBox.
isInside(nodeBBox)) {
1391 int &x = xyz.
x(), &y = xyz.
y(), &z = xyz.
z();
1392 for (x = nodeBBox.
min().
x(); x <= nodeBBox.
max().
x(); ++x) {
1393 for (y = nodeBBox.
min().
y(); y <= nodeBBox.
max().
y(); ++y) {
1394 for (z = nodeBBox.
min().
z(); z <= nodeBBox.
max().
z(); ++z) {
1411 template<Index Log2Dim>
1416 clippedBBox.intersect(bbox);
1417 if (!clippedBBox)
return;
1419 for (
Int32 x = clippedBBox.min().x(); x <= clippedBBox.max().x(); ++x) {
1420 const Index offsetX = (x & (
DIM-1u))<<2*Log2Dim;
1421 for (
Int32 y = clippedBBox.min().y(); y <= clippedBBox.max().y(); ++y) {
1422 const Index offsetXY = offsetX + ((y & (
DIM-1u))<< Log2Dim);
1423 for (
Int32 z = clippedBBox.min().z(); z <= clippedBBox.max().z(); ++z) {
1424 const Index offset = offsetXY + (z & (
DIM-1u));
1425 mValueMask.
set(offset, active);
1426 mBuffer.
mData.set(offset, value);
1432 template<Index Log2Dim>
1436 mBuffer.
fill(value);
1439 template<Index Log2Dim>
1443 mBuffer.
fill(value);
1444 mValueMask.
set(active);
1451 template<Index Log2Dim>
1452 template<
typename DenseT>
1456 using DenseValueType =
typename DenseT::ValueType;
1458 const size_t xStride = dense.xStride(), yStride = dense.yStride(), zStride = dense.zStride();
1459 const Coord&
min = dense.bbox().min();
1460 DenseValueType* t0 = dense.data() + zStride * (bbox.
min()[2] - min[2]);
1462 for (
Int32 x = bbox.
min()[0], ex = bbox.
max()[0] + 1; x < ex; ++x) {
1463 DenseValueType* t1 = t0 + xStride * (x - min[0]);
1465 for (
Int32 y = bbox.
min()[1], ey = bbox.
max()[1] + 1; y < ey; ++y) {
1466 DenseValueType* t2 = t1 + yStride * (y - min[1]);
1468 for (
Int32 z = bbox.
min()[2], ez = bbox.
max()[2] + 1; z < ez; ++z, t2 += zStride) {
1469 *t2 = DenseValueType(mBuffer.
mData.isOn(n2++));
1476 template<Index Log2Dim>
1477 template<
typename DenseT>
1480 bool background,
bool tolerance)
1482 using DenseValueType =
typename DenseT::ValueType;
1484 inline static bool toBool(
const DenseValueType& v) {
return !
math::isZero(v); }
1487 const size_t xStride = dense.xStride(), yStride = dense.yStride(), zStride = dense.zStride();
1488 const Coord&
min = dense.bbox().min();
1489 const DenseValueType* s0 = dense.data() + zStride * (bbox.
min()[2] - min[2]);
1491 for (
Int32 x = bbox.
min()[0], ex = bbox.
max()[0] + 1; x < ex; ++x) {
1492 const DenseValueType* s1 = s0 + xStride * (x - min[0]);
1494 for (
Int32 y = bbox.
min()[1], ey = bbox.
max()[1] + 1; y < ey; ++y) {
1495 const DenseValueType* s2 = s1 + yStride * (y - min[1]);
1497 for (
Int32 z = bbox.
min()[2], ez = bbox.
max()[2]+1; z < ez; ++z, ++n2, s2 += zStride) {
1499 if (tolerance || (background == Local::toBool(*s2))) {
1500 mValueMask.setOff(n2);
1501 mBuffer.mData.set(n2, background);
1503 mValueMask.setOn(n2);
1504 mBuffer.mData.set(n2, Local::toBool(*s2));
1515 template<Index Log2Dim>
1516 template<
typename CombineOp>
1522 bool result =
false, aVal = mBuffer.mData.isOn(i), bVal = other.mBuffer.
mData.isOn(i);
1524 .setAIsActive(mValueMask.isOn(i))
1527 .setResultRef(result));
1529 mBuffer.mData.set(i, result);
1534 template<Index Log2Dim>
1535 template<
typename CombineOp>
1540 args.
setBRef(value).setBIsActive(valueIsActive);
1542 bool result =
false, aVal = mBuffer.mData.isOn(i);
1544 .setAIsActive(mValueMask.isOn(i))
1545 .setResultRef(result));
1547 mBuffer.mData.set(i, result);
1555 template<Index Log2Dim>
1556 template<
typename CombineOp,
typename OtherType>
1559 bool valueIsActive, CombineOp& op)
1562 args.
setBRef(value).setBIsActive(valueIsActive);
1564 bool result =
false, aVal = other.mBuffer.
mData.isOn(i);
1567 .setResultRef(result));
1569 mBuffer.mData.set(i, result);
1574 template<Index Log2Dim>
1575 template<
typename CombineOp,
typename OtherNodeT>
1578 bool valueIsActive, CombineOp& op)
1581 args.
setARef(value).setAIsActive(valueIsActive);
1583 bool result =
false, bVal = other.mBuffer.mData.isOn(i);
1585 .setBIsActive(other.valueMask().isOn(i))
1586 .setResultRef(result));
1588 mBuffer.mData.set(i, result);
1593 template<Index Log2Dim>
1594 template<
typename CombineOp,
typename OtherNodeT>
1601 mValueMask.set(i, b0.
valueMask().
isOn(i) || b1.valueMask().isOn(i));
1603 bool result =
false, b0Val = b0.mBuffer.
mData.isOn(i), b1Val = b1.mBuffer.mData.isOn(i);
1607 .setBIsActive(b1.valueMask().isOn(i))
1608 .setResultRef(result));
1610 mBuffer.mData.set(i, result);
1617 template<Index Log2Dim>
1618 template<
typename BBoxOp>
1622 if (op.template descent<LEVEL>()) {
1640 template<Index Log2Dim>
1641 template<
typename VisitorOp>
1645 doVisit<LeafNode, VisitorOp, ChildAllIter>(*
this, op);
1649 template<Index Log2Dim>
1650 template<
typename VisitorOp>
1654 doVisit<const LeafNode, VisitorOp, ChildAllCIter>(*
this, op);
1658 template<Index Log2Dim>
1659 template<
typename NodeT,
typename VisitorOp,
typename ChildAllIterT>
1663 for (ChildAllIterT iter =
self.
beginChildAll(); iter; ++iter) {
1672 template<Index Log2Dim>
1673 template<
typename OtherLeafNodeType,
typename VisitorOp>
1678 typename OtherLeafNodeType::ChildAllIter>(*
this, other, op);
1682 template<Index Log2Dim>
1683 template<
typename OtherLeafNodeType,
typename VisitorOp>
1688 typename OtherLeafNodeType::ChildAllCIter>(*
this, other, op);
1692 template<Index Log2Dim>
1695 typename OtherNodeT,
1697 typename ChildAllIterT,
1698 typename OtherChildAllIterT>
1703 static_assert(OtherNodeT::SIZE == NodeT::SIZE,
1704 "can't visit nodes of different sizes simultaneously");
1705 static_assert(OtherNodeT::LEVEL == NodeT::LEVEL,
1706 "can't visit nodes at different tree levels simultaneously");
1708 ChildAllIterT iter =
self.beginChildAll();
1709 OtherChildAllIterT otherIter = other.beginChildAll();
1711 for ( ; iter && otherIter; ++iter, ++otherIter) {
1712 op(iter, otherIter);
1720 template<Index Log2Dim>
1721 template<
typename IterT,
typename VisitorOp>
1725 doVisit2<LeafNode, VisitorOp, ChildAllIter, IterT>(*
this, otherIter, op, otherIsLHS);
1729 template<Index Log2Dim>
1730 template<
typename IterT,
typename VisitorOp>
1734 doVisit2<const LeafNode, VisitorOp, ChildAllCIter, IterT>(*
this, otherIter, op, otherIsLHS);
1738 template<Index Log2Dim>
1742 typename ChildAllIterT,
1743 typename OtherChildAllIterT>
1746 VisitorOp& op,
bool otherIsLHS)
1748 if (!otherIter)
return;
1751 for (ChildAllIterT iter =
self.
beginChildAll(); iter; ++iter) {
1752 op(otherIter, iter);
1755 for (ChildAllIterT iter =
self.
beginChildAll(); iter; ++iter) {
1756 op(iter, otherIter);
1765 #endif // OPENVDB_TREE_LEAF_NODE_BOOL_HAS_BEEN_INCLUDED
void setValueOn(Index offset)
Mark the voxel at the given offset as active but don't change its value.
Definition: LeafNodeBool.h:271
void resetBackground(const ValueType &oldBackground, const ValueType &newBackground)
Replace inactive occurrences of oldBackground with newBackground, and inactive occurrences of -oldBac...
Definition: LeafNode.h:1644
static Index coordToOffset(const Coord &xyz)
Return the linear table offset of the given global or local coordinates.
Definition: LeafNode.h:1052
bool ValueType
Definition: LeafNodeBool.h:60
Axis-aligned bounding box of signed integer coordinates.
Definition: Coord.h:264
Int32 x() const
Definition: Coord.h:157
void visitActiveBBox(BBoxOp &) const
Calls the templated functor BBoxOp with bounding box information. An additional level argument is pro...
Definition: LeafNode.h:1868
static const Index SIZE
Definition: LeafNode.h:80
bool isChildMaskOff() const
Definition: LeafNodeBool.h:734
ChildAllIter beginChildAll()
Definition: LeafNodeBool.h:709
Base class for dense iterators over internal and leaf nodes.
Definition: Iterator.h:205
ChildOffCIter cendChildOff() const
Definition: LeafNodeBool.h:714
void stealNodes(ArrayT &, const ValueType &, bool)
This function exists only to enable template instantiation.
Definition: LeafNodeBool.h:553
const LeafNode * probeConstLeaf(const Coord &) const
Return a const pointer to this node.
Definition: LeafNodeBool.h:583
Coord offsetToGlobalCoord(Index n) const
Return the global coordinates for a linear table offset.
Definition: LeafNode.h:1076
bool isOn(Index32 n) const
Return true if the nth bit is on.
Definition: NodeMasks.h:504
void setValueOnlyAndCache(const Coord &xyz, bool val, AccessorT &)
Change the value of the voxel at the given coordinates but preserve its state.
Definition: LeafNodeBool.h:371
NodeT * stealNode(const Coord &, const ValueType &, bool)
This function exists only to enable template instantiation.
Definition: LeafNodeBool.h:547
static Index64 offTileCount()
Definition: LeafNodeBool.h:150
ChildIter< MaskOnIter, const LeafNode > ChildOnCIter
Definition: LeafNodeBool.h:673
static CoordBBox createCube(const Coord &min, ValueType dim)
Definition: Coord.h:329
ValueIter< MaskOffIter, const LeafNode, const bool > ValueOffCIter
Definition: LeafNodeBool.h:669
Index64 offLeafVoxelCount() const
Definition: LeafNodeBool.h:148
Index64 offVoxelCount() const
Return the number of inactive voxels.
Definition: LeafNodeBool.h:146
ValueIter< MaskOnIter, const LeafNode, const bool > ValueOnCIter
Definition: LeafNodeBool.h:667
ValueAllIter beginValueAll()
Definition: LeafNodeBool.h:687
DenseIter< const LeafNode, const ValueType, ChildAll > ChildAllCIter
Definition: LeafNode.h:318
void setValueOn(const Coord &xyz)
Mark the voxel at the given coordinates as active but don't change its value.
Definition: LeafNodeBool.h:269
void getNodes(ArrayT &) const
This function exists only to enable template instantiation.
Definition: LeafNodeBool.h:552
const NodeMaskType & getValueMask() const
Definition: LeafNode.h:889
void setValue(const Coord &xyz, bool val)
Set the value of the voxel at the given coordinates and mark the voxel as active. ...
Definition: LeafNodeBool.h:276
bool isValueMaskOff() const
Definition: LeafNodeBool.h:727
void setValueOff(const Coord &xyz)
Mark the voxel at the given coordinates as inactive but don't change its value.
Definition: LeafNodeBool.h:259
void setValueOn(const Coord &xyz)
Mark the voxel at the given coordinates as active but don't change its value.
Definition: LeafNode.h:440
Buffer mBuffer
Bitmask representing the values of voxels.
Definition: LeafNodeBool.h:758
static bool hasActiveTiles()
Return false since leaf nodes never contain tiles.
Definition: LeafNodeBool.h:304
ValueOffIter beginValueOff()
Definition: LeafNodeBool.h:684
const LeafNode * probeConstLeafAndCache(const Coord &, AccessorT &) const
Return a const pointer to this node.
Definition: LeafNodeBool.h:585
static const Index LEVEL
Definition: LeafNode.h:81
void fill(const ValueType &)
Populate this buffer with a constant value.
Definition: LeafBuffer.h:343
ValueOffCIter cbeginValueOff() const
Definition: LeafNodeBool.h:682
static Index getValueLevelAndCache(const Coord &, AccessorT &)
Return the LEVEL (=0) at which leaf node values reside.
Definition: LeafNodeBool.h:419
OPENVDB_API uint32_t getFormatVersion(std::ios_base &)
Return the file format version number associated with the given input stream.
static void doVisit(NodeT &, VisitorOp &)
Definition: LeafNode.h:1909
ChildIter()
Definition: LeafNodeBool.h:636
void modifyItem(Index n, const ModifyOp &op) const
Definition: LeafNodeBool.h:625
static void getNodeLog2Dims(std::vector< Index > &dims)
Definition: LeafNodeBool.h:137
void addLeaf(LeafNode *)
This function exists only to enable template instantiation.
Definition: LeafNodeBool.h:543
ValueAllCIter cendValueAll() const
Definition: LeafNodeBool.h:695
Index medianOff(ValueType &value, ValueType *tmp=nullptr) const
Computes the median value of all the inactive voxels in this node.
Definition: LeafNode.h:1588
std::string str() const
Return a string representation of this node.
Definition: LeafNode.h:1039
bool resultIsActive() const
Definition: Types.h:450
void readBuffers(std::istream &is, bool fromHalf=false)
Read buffers from a stream.
Definition: LeafNode.h:1352
void unsetItem(Index pos, const ValueT &val) const
Definition: LeafNodeBool.h:662
bool hasOverlap(const CoordBBox &b) const
Return true if the given bounding box overlaps with this bounding box.
Definition: Coord.h:416
static Coord offsetToLocalCoord(Index n)
Return the local coordinates for a linear table offset, where offset 0 has coordinates (0...
Definition: LeafNode.h:1062
void visit2Node(OtherLeafNodeType &other, VisitorOp &)
Definition: LeafNode.h:1923
ChildIter< MaskOffIter, LeafNode > ChildOffIter
Definition: LeafNodeBool.h:674
ValueAllIter endValueAll()
Definition: LeafNodeBool.h:697
ChildOffIter endChildOff()
Definition: LeafNodeBool.h:716
bool isChildMaskOn(Index) const
Definition: LeafNodeBool.h:732
ValueOnCIter endValueOn() const
Definition: LeafNodeBool.h:690
const Coord & min() const
Definition: Coord.h:337
const NodeT * probeConstNodeAndCache(const Coord &, AccessorT &) const
Return a const pointer to this node.
Definition: LeafNodeBool.h:587
ChildAllCIter cbeginChildAll() const
Definition: LeafNodeBool.h:707
Int32 ValueType
Definition: Coord.h:59
Signed (x, y, z) 32-bit integer coordinates.
Definition: Coord.h:51
void writeBuffers(std::ostream &os, bool toHalf=false) const
Write buffers to a stream.
Definition: LeafNode.h:1447
NodeT * probeNode(const Coord &)
This function exists only to enable template instantiation.
Definition: LeafNodeBool.h:549
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:1137
void save(std::ostream &os) const
Definition: NodeMasks.h:567
NodeMaskType & getValueMask()
Definition: LeafNodeBool.h:730
static Index numValues()
Definition: LeafNodeBool.h:135
static const Index DIM
Definition: LeafNode.h:77
void setValueMaskOff(Index n)
Definition: LeafNodeBool.h:738
ValueOffCIter beginValueOff() const
Definition: LeafNodeBool.h:683
ValueOffCIter cendValueOff() const
Definition: LeafNodeBool.h:692
ValueIter< MaskDenseIter, LeafNode, const bool > ValueAllIter
Definition: LeafNodeBool.h:670
std::shared_ptr< T > SharedPtr
Definition: Types.h:139
const bool & getFirstValue() const
Return a const reference to the first entry in the buffer.
Definition: LeafNodeBool.h:424
Index64 onVoxelCount() const
Return the number of active voxels.
Definition: LeafNodeBool.h:144
CoordBBox getNodeBoundingBox() const
Return the bounding box of this node, i.e., the full index space spanned by this leaf node...
Definition: LeafNode.h:195
LeafNode * probeLeaf(const Coord &)
Return a pointer to this node.
Definition: LeafNodeBool.h:566
void clip(const CoordBBox &, const ValueType &background)
Set all voxels that lie outside the given axis-aligned box to the background.
Definition: LeafNode.h:1163
const NodeMaskType & getValueMask() const
Definition: LeafNodeBool.h:728
DenseIter(const MaskDenseIter &iter, NodeT *parent)
Definition: LeafNodeBool.h:649
ValueOffIter endValueOff()
Definition: LeafNodeBool.h:694
ChildIter(const MaskIterT &iter, NodeT *parent)
Definition: LeafNodeBool.h:637
Base class for sparse iterators over internal and leaf nodes.
Definition: Iterator.h:141
bool getItem(Index pos, void *&child, NonConstValueT &value) const
Definition: LeafNodeBool.h:651
bool probeValueAndCache(const Coord &xyz, bool &val, AccessorT &) const
Return true if the voxel at the given coordinates is active and return the voxel value in val...
Definition: LeafNodeBool.h:411
ValueOnCIter cbeginValueOn() const
Definition: LeafNodeBool.h:679
Base class for iterators over internal and leaf nodes.
Definition: Iterator.h:56
LeafNode * touchLeafAndCache(const Coord &, AccessorT &)
Return a pointer to this node.
Definition: LeafNodeBool.h:565
ChildAllCIter endChildAll() const
Definition: LeafNodeBool.h:718
bool probeValue(const Coord &xyz, ValueType &val) const
Return true if the voxel at the given coordinates is active.
Definition: LeafNode.h:1103
Definition: NodeMasks.h:241
bool operator!=(const Vec3< T0 > &v0, const Vec3< T1 > &v1)
Inequality operator, does exact floating point comparisons.
Definition: Vec3.h:496
Coord & setY(Int32 y)
Definition: Coord.h:107
typename NodeMaskType::OffIterator MaskOffIter
Definition: LeafNodeBool.h:601
void negate()
Definition: LeafNodeBool.h:463
void setValueMask(const NodeMaskType &mask)
Definition: LeafNodeBool.h:731
ValueOffCIter endValueOff() const
Definition: LeafNodeBool.h:693
bool isValueMaskOn() const
Definition: LeafNodeBool.h:725
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:1720
CombineArgs & setBRef(const BValueType &b)
Redirect the B value to a new external source.
Definition: Types.h:441
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...
static Index64 onTileCount()
Definition: LeafNodeBool.h:149
ChildOnIter endChildOn()
Definition: LeafNodeBool.h:713
bool isOff(Index32 n) const
Return true if the nth bit is off.
Definition: NodeMasks.h:510
const NodeMaskType & valueMask() const
Definition: LeafNodeBool.h:729
void addTileAndCache(Index, const Coord &, const ValueType &, bool, AccessorT &)
Definition: LeafNode.h:1632
DenseIter()
Definition: LeafNodeBool.h:648
static Index size()
Definition: LeafNodeBool.h:134
bool isConstant(ValueType &firstValue, bool &state, const ValueType &tolerance=zeroVal< ValueType >()) const
Definition: LeafNode.h:1510
Coord mOrigin
Global grid index coordinates (x,y,z) of the local origin of this node.
Definition: LeafNodeBool.h:760
void visit(VisitorOp &)
Definition: LeafNode.h:1891
ChildOffCIter cbeginChildOff() const
Definition: LeafNodeBool.h:704
const bool & getItem(Index pos) const
Definition: LeafNodeBool.h:615
typename NodeMaskType::DenseIterator MaskDenseIter
Definition: LeafNodeBool.h:602
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:1145
void expand(ValueType padding)
Pad this bounding box with the specified padding.
Definition: Coord.h:422
void modifyValueAndActiveStateAndCache(const Coord &xyz, const ModifyOp &op, AccessorT &)
Definition: LeafNodeBool.h:393
DenseIter< LeafNode, ValueType, ChildAll > ChildAllIter
Definition: LeafNode.h:317
static void doVisit2(NodeT &self, OtherChildAllIterT &, VisitorOp &, bool otherIsLHS)
Definition: LeafNode.h:1995
void setActiveStateAndCache(const Coord &xyz, bool on, AccessorT &)
Set the active state of the voxel at the given coordinates without changing its value.
Definition: LeafNodeBool.h:402
void setValueOff(Index offset)
Mark the voxel at the given offset as inactive but don't change its value.
Definition: LeafNodeBool.h:261
ValueIter< MaskOnIter, LeafNode, const bool > ValueOnIter
Definition: LeafNodeBool.h:666
void setValueMask(Index n, bool on)
Definition: LeafNodeBool.h:736
bool hasSameTopology(const LeafNode< OtherType, OtherLog2Dim > *other) const
Return true if the given node (which may have a different ValueType than this node) has the same acti...
Definition: LeafNode.h:1502
void setItem(Index pos, bool value) const
Definition: LeafNodeBool.h:619
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition: version.h:136
ValueOnCIter cbeginValueOn() const
Definition: LeafNode.h:320
const bool & getValue() const
Definition: LeafNodeBool.h:616
ValueAllCIter endValueAll() const
Definition: LeafNodeBool.h:696
const bool & getValueAndCache(const Coord &xyz, AccessorT &) const
Return the value of the voxel at the given coordinates.
Definition: LeafNodeBool.h:355
void visit2(IterT &otherIter, VisitorOp &, bool otherIsLHS=false)
Definition: LeafNode.h:1971
bool operator!=(const LeafNode &other) const
Definition: LeafNode.h:224
void denseFill(const CoordBBox &bbox, bool val, bool on=true)
Set all voxels within an axis-aligned box to the specified value and active state.
Definition: LeafNodeBool.h:312
DenseIter< const LeafNode, const bool > ChildAllCIter
Definition: LeafNodeBool.h:677
int32_t Int32
Definition: Types.h:63
Int32 z() const
Definition: Coord.h:159
ChildOnCIter cendChildOn() const
Definition: LeafNodeBool.h:711
Index64 onLeafVoxelCount() const
Definition: LeafNodeBool.h:147
bool isValueMaskOff(Index n) const
Definition: LeafNodeBool.h:726
ValueIter< MaskOffIter, LeafNode, const bool > ValueOffIter
Definition: LeafNodeBool.h:668
NodeT * probeNodeAndCache(const Coord &, AccessorT &)
Return a pointer to this node.
Definition: LeafNodeBool.h:570
ChildOnCIter cbeginChildOn() const
Definition: LeafNodeBool.h:701
typename BaseT::NonConstValueType NonConstValueT
Definition: LeafNodeBool.h:646
ChildAllCIter beginChildAll() const
Definition: LeafNode.h:349
void setActiveState(Index offset, bool on)
Set the active state of the voxel at the given offset but don't change its value. ...
Definition: LeafNodeBool.h:251
LeafNode specialization for values of type bool that stores both the active states and the values of ...
Definition: LeafNodeBool.h:55
Definition: Exceptions.h:40
static Index32 leafCount()
Definition: LeafNodeBool.h:140
void modifyValue(Index offset, const ModifyOp &op)
Apply a functor to the value of the voxel at the given offset and mark the voxel as active...
Definition: LeafNode.h:458
ValueOnIter endValueOn()
Definition: LeafNodeBool.h:691
ValueIter< MaskDenseIter, const LeafNode, const bool > ValueAllCIter
Definition: LeafNodeBool.h:671
ChildOnCIter endChildOn() const
Definition: LeafNodeBool.h:712
typename NodeMaskType::OnIterator MaskOnIter
Definition: LeafNodeBool.h:600
bool isChildMaskOff(Index) const
Definition: LeafNodeBool.h:733
void combine2(const LeafNode &other, const OtherType &, bool valueIsActive, CombineOp &)
Definition: LeafNode.h:1804
void setValueOnly(Index offset, bool val)
Set the value of the voxel at the given offset but don't change its active state. ...
Definition: LeafNodeBool.h:256
Buffer & buffer()
Definition: LeafNodeBool.h:216
void addLeafAndCache(LeafNode *, AccessorT &)
This function exists only to enable template instantiation.
Definition: LeafNodeBool.h:545
~LeafNode()
Destructor.
Definition: LeafNode.h:1032
ChildIter< MaskOffIter, const LeafNode > ChildOffCIter
Definition: LeafNodeBool.h:675
void merge(const LeafNode &)
Definition: LeafNode.h:1667
static Index32 nonLeafCount()
Definition: LeafNodeBool.h:141
ValueAllCIter beginValueAll() const
Definition: LeafNodeBool.h:686
Coord & setZ(Int32 z)
Definition: Coord.h:108
Index32 countOn() const
Return the total number of on bits.
Definition: NodeMasks.h:445
This struct collects both input and output arguments to "grid combiner" functors used with the tree::...
Definition: Types.h:386
ChildOnIter beginChildOn()
Definition: LeafNodeBool.h:703
Index32 Index
Definition: Types.h:61
void copyToDense(const CoordBBox &bbox, DenseT &dense) const
Copy into a dense grid the values of the voxels that lie within a given bounding box.
Definition: LeafNode.h:1248
void setValueOff(const Coord &xyz)
Mark the voxel at the given coordinates as inactive but don't change its value.
Definition: LeafNode.h:430
void setOff(Index32 n)
Set the nth bit off.
Definition: NodeMasks.h:459
void setValuesOn()
Mark all voxels as active but don't change their values.
Definition: LeafNodeBool.h:294
void setValueOffAndCache(const Coord &xyz, bool value, AccessorT &)
Change the value of the voxel at the given coordinates and mark it as inactive.
Definition: LeafNodeBool.h:376
Definition: version.h:223
void setOn(Index32 n)
Set the nth bit on.
Definition: NodeMasks.h:454
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:1728
void modifyValueAndActiveState(const Coord &xyz, const ModifyOp &op)
Apply a functor to the voxel at the given coordinates.
Definition: LeafNode.h:475
Int32 y() const
Definition: Coord.h:158
void swap(Buffer &other)
Exchange this node's data buffer with the given data buffer without changing the active states of the...
Definition: LeafNodeBool.h:214
const Coord & origin() const
Return the grid index coordinates of this node's local origin.
Definition: LeafNode.h:201
LeafNode * probeLeafAndCache(const Coord &, AccessorT &)
Return a pointer to this node.
Definition: LeafNodeBool.h:568
const bool & getLastValue() const
Return a const reference to the last entry in the buffer.
Definition: LeafNodeBool.h:428
Definition: NodeMasks.h:210
Definition: PointDataGrid.h:201
uint64_t Index64
Definition: Types.h:60
const LeafNode * probeLeafAndCache(const Coord &, AccessorT &) const
Return a const pointer to this node.
Definition: LeafNodeBool.h:582
bool operator==(const Vec3< T0 > &v0, const Vec3< T1 > &v1)
Equality operator, does exact floating point comparisons.
Definition: Vec3.h:488
bool operator==(const LeafNode &other) const
Check for buffer, state and origin equivalence.
Definition: LeafNode.h:1464
bool isValueOnAndCache(const Coord &xyz, AccessorT &) const
Return true if the voxel at the given coordinates is active.
Definition: LeafNodeBool.h:360
CombineArgs & setARef(const AValueType &a)
Redirect the A value to a new external source.
Definition: Types.h:439
void setValueAndCache(const Coord &xyz, bool val, AccessorT &)
Change the value of the voxel at the given coordinates and mark it as active.
Definition: LeafNodeBool.h:365
void setValuesOff()
Mark all voxels as inactive but don't change their values.
Definition: LeafNodeBool.h:296
void writeTopology(std::ostream &os, bool toHalf=false) const
Write out just the topology.
Definition: LeafNode.h:1324
void setValueMaskOn(Index n)
Definition: LeafNodeBool.h:737
static Index log2dim()
Return log2 of the size of the buffer storage.
Definition: LeafNodeBool.h:131
ValueIter()
Definition: LeafNodeBool.h:612
Coord & setX(Int32 x)
Definition: Coord.h:106
OffIterator beginOff() const
Definition: NodeMasks.h:356
bool isEmpty() const
Return true if this node has no active voxels.
Definition: LeafNodeBool.h:153
void intersect(const CoordBBox &bbox)
Intersect this bounding box with the given bounding box.
Definition: Coord.h:448
void combine(const LeafNode &other, CombineOp &op)
Definition: LeafNode.h:1762
Index64 memUsage() const
Return the memory in bytes occupied by this node.
Definition: LeafNode.h:1474
static Index getValueLevel(const Coord &)
Return the level (0) at which leaf node values reside.
Definition: LeafNodeBool.h:246
ChildOffCIter beginChildOff() const
Definition: LeafNodeBool.h:705
static Index getLevel()
Definition: LeafNodeBool.h:136
ChildOffCIter endChildOff() const
Definition: LeafNodeBool.h:715
OnIterator beginOn() const
Definition: NodeMasks.h:354
void getOrigin(Int32 &x, Int32 &y, Int32 &z) const
Return the grid index coordinates of this node's local origin.
Definition: LeafNodeBool.h:186
ChildOnCIter beginChildOn() const
Definition: LeafNodeBool.h:702
const NodeMaskType & valueMask() const
Definition: LeafNode.h:891
LeafNode()
Default constructor.
Definition: LeafNode.h:946
ChildAllCIter beginChildAll() const
Definition: LeafNodeBool.h:708
void set(Index32 n, bool On)
Set the nth bit to the specified state.
Definition: NodeMasks.h:464
ChildAllCIter cendChildAll() const
Definition: LeafNodeBool.h:717
void addTile(Index level, const Coord &, const ValueType &, bool)
Definition: LeafNode.h:1615
static Index getChildDim()
Definition: LeafNodeBool.h:138
void load(std::istream &is)
Definition: NodeMasks.h:571
typename std::remove_const< UnsetItemT >::type NonConstValueType
Definition: Iterator.h:211
void getOrigin(Coord &origin) const
Return the grid index coordinates of this node's local origin.
Definition: LeafNodeBool.h:185
const Coord & max() const
Definition: Coord.h:338
ChildAllIter endChildAll()
Definition: LeafNodeBool.h:719
bool isValueOn(Index offset) const
Return true if the voxel at the given offset is active.
Definition: LeafNodeBool.h:301
void voxelizeActiveTiles(bool=true)
No-op.
Definition: LeafNodeBool.h:471
void evalActiveBoundingBox(CoordBBox &bbox, bool visitVoxels=true) const
Definition: LeafNode.h:1484
ChildOffIter beginChildOff()
Definition: LeafNodeBool.h:706
static void doVisit2Node(NodeT &self, OtherNodeT &other, VisitorOp &)
Definition: LeafNode.h:1948
bool isInside(const Coord &xyz) const
Return true if point (x, y, z) is inside this bounding box.
Definition: Coord.h:404
static void evalNodeOrigin(Coord &xyz)
Compute the origin of the leaf node that contains the voxel with the given coordinates.
Definition: LeafNodeBool.h:741
ValueIter(const MaskIterT &iter, NodeT *parent)
Definition: LeafNodeBool.h:613
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h:188
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:1737
void translate(const Coord &t)
Definition: Coord.h:462
bool isZero(const Type &x)
Return true if x is exactly equal to zero.
Definition: Math.h:308
DenseIter< LeafNode, bool > ChildAllIter
Definition: LeafNodeBool.h:676
static Index dim()
Return the number of voxels in each dimension.
Definition: LeafNodeBool.h:133
const ValueType & getValue(const Coord &xyz) const
Return the value of the voxel at the given coordinates.
Definition: LeafNode.h:1087
static const Index LOG2DIM
Definition: LeafNode.h:75
void readTopology(std::istream &is, bool fromHalf=false)
Read in just the topology.
Definition: LeafNode.h:1316
void copyFromDense(const CoordBBox &bbox, const DenseT &dense, const ValueType &background, const ValueType &tolerance)
Copy from a dense grid into this node the values of the voxels that lie within a given bounding box...
Definition: LeafNode.h:1277
void modifyValue(const ModifyOp &op) const
Definition: LeafNodeBool.h:628
void modifyValueAndCache(const Coord &xyz, const ModifyOp &op, AccessorT &)
Apply a functor to the value of the voxel at the given coordinates and mark the voxel as active...
Definition: LeafNodeBool.h:385
Index32 countOff() const
Return the total number of on bits.
Definition: NodeMasks.h:452
ChildIter< MaskOnIter, LeafNode > ChildOnIter
Definition: LeafNodeBool.h:672
const Buffer & buffer() const
Definition: LeafNodeBool.h:215
ValueType medianAll(ValueType *tmp=nullptr) const
Computes the median value of all the active AND inactive voxels in this node.
Definition: LeafNode.h:1546
ValueOnCIter beginValueOn() const
Definition: LeafNodeBool.h:680
NodeMaskType mValueMask
Bitmask that determines which voxels are active.
Definition: LeafNodeBool.h:756
void setOrigin(const Coord &origin)
Set the grid index coordinates of this node's local origin.
Definition: LeafNodeBool.h:181
ValueOnCIter cendValueOn() const
Definition: LeafNodeBool.h:689
Index medianOn(ValueType &value, ValueType *tmp=nullptr) const
Computes the median value of all the active voxels in this node.
Definition: LeafNode.h:1564
ValueType * mData
Definition: LeafBuffer.h:225
static const Index NUM_VALUES
Definition: LeafNode.h:78
Tag dispatch class that distinguishes constructors during file input.
Definition: Types.h:520
const NodeT * probeConstNode(const Coord &) const
This function exists only to enable template instantiation.
Definition: LeafNodeBool.h:551
Templated block class to hold specific data types and a fixed number of values determined by Log2Dim...
Definition: LeafNode.h:64
SharedPtr< LeafNodeType > Ptr
Definition: LeafNodeBool.h:63
Tag dispatch class that distinguishes topology copy constructors from deep copy constructors.
Definition: Types.h:518
ValueAllCIter cbeginValueAll() const
Definition: LeafNodeBool.h:685
void fill(const CoordBBox &bbox, const ValueType &, bool active=true)
Set all voxels within an axis-aligned box to the specified value and active state.
Definition: LeafNode.h:1203
void reset()
Definition: Coord.h:343
Definition: NodeMasks.h:272
void setValue(bool value) const
Definition: LeafNodeBool.h:621
bool isValueMaskOn(Index n) const
Definition: LeafNodeBool.h:724
CoordBBox getNodeBoundingBox() const
Return the bounding box of this node, i.e., the full index space spanned by this leaf node...
Definition: LeafNodeBool.h:178
uint32_t Index32
Definition: Types.h:59
bool isConstant(bool &isOn) const
Definition: NodeMasks.h:528
bool isDense() const
Return true if this node only contains active voxels.
Definition: LeafNodeBool.h:155
ValueOnIter beginValueOn()
Definition: LeafNodeBool.h:681
bool isValueOn(const Coord &xyz) const
Return true if the voxel at the given coordinates is active.
Definition: LeafNodeBool.h:299
bool isInactive() const
Return true if all of this node's values are inactive.
Definition: LeafNodeBool.h:459
Bit mask for the internal and leaf nodes of VDB. This is a 64-bit implementation. ...
Definition: NodeMasks.h:309
bool BuildType
Definition: LeafNodeBool.h:59
bool allocate()
Allocate memory for this node's buffer if it has not already been allocated.
Definition: LeafNodeBool.h:165