31 #ifndef OPENVDB_TREE_LEAFNODE_HAS_BEEN_INCLUDED
32 #define OPENVDB_TREE_LEAFNODE_HAS_BEEN_INCLUDED
37 #include <boost/shared_ptr.hpp>
38 #include <boost/static_assert.hpp>
39 #include <boost/bind.hpp>
40 #include <tbb/blocked_range.h>
41 #include <tbb/parallel_for.h>
42 #include <openvdb/Types.h>
43 #include <openvdb/util/NodeMasks.h>
44 #include <openvdb/io/Compression.h>
61 template<
typename T, Index Log2Dim>
67 typedef boost::shared_ptr<LeafNode>
Ptr;
74 NUM_VALUES = 1 << 3 * Log2Dim,
75 NUM_VOXELS = NUM_VALUES,
81 template<
typename OtherValueType>
104 while (n--) *target++ = val;
118 while (n--) *target++ = *source++;
149 ValueType& operator[](
Index i) { assert(i < SIZE);
return mData[i]; }
151 friend class ::TestLeaf;
166 explicit LeafNode(
const Coord& coords,
167 const ValueType& value = zeroVal<ValueType>(),
168 bool active =
false);
174 template<
typename OtherValueType>
179 template<
typename OtherValueType>
217 bool isEmpty()
const {
return mValueMask.isOff(); }
219 bool isDense()
const {
return mValueMask.isOn(); }
227 void evalActiveBoundingBox(CoordBBox&,
bool visitVoxels =
true)
const;
235 void setOrigin(
const Coord& origin) { mOrigin = origin; }
240 const Coord& origin()
const {
return mOrigin; }
242 void getOrigin(Coord& origin)
const { origin = mOrigin; }
247 static Index coordToOffset(
const Coord& xyz);
250 static Coord offsetToLocalCoord(
Index n);
253 Coord offsetToGlobalCoord(
Index n)
const;
256 std::string str()
const;
260 template<
typename OtherType, Index OtherLog2Dim>
276 template<
typename MaskIterT,
typename NodeT,
typename ValueT,
typename TagT>
281 MaskIterT, ValueIter<MaskIterT, NodeT, ValueT, TagT>, NodeT, ValueT>
288 ValueT&
getItem(
Index pos)
const {
return this->parent().getValue(pos); }
289 ValueT&
getValue()
const {
return this->parent().getValue(this->pos()); }
294 this->parent().setValueOnly(pos, value);
299 this->parent().setValueOnly(this->pos(), value);
303 template<
typename ModifyOp>
304 void modifyItem(
Index n,
const ModifyOp& op)
const { this->parent().modifyValue(n, op); }
306 template<
typename ModifyOp>
307 void modifyValue(
const ModifyOp& op)
const { this->parent().modifyValue(this->pos(), op); }
311 template<
typename MaskIterT,
typename NodeT,
typename TagT>
313 public SparseIteratorBase<MaskIterT, ChildIter<MaskIterT, NodeT, TagT>, NodeT, ValueType>
320 template<
typename NodeT,
typename ValueT,
typename TagT>
322 MaskDenseIterator, DenseIter<NodeT, ValueT, TagT>, NodeT, void, ValueT>
332 value = this->parent().getValue(pos);
343 this->parent().setValueOnly(pos, value);
418 void readTopology(std::istream& is,
bool fromHalf =
false);
422 void writeTopology(std::ostream& os,
bool toHalf =
false)
const;
427 void readBuffers(std::istream& is,
bool fromHalf =
false);
431 void writeBuffers(std::ostream& os,
bool toHalf =
false)
const;
433 size_t streamingSize(
bool toHalf =
false)
const;
439 const ValueType& getValue(
const Coord& xyz)
const;
441 const ValueType& getValue(
Index offset)
const;
446 bool probeValue(
const Coord& xyz, ValueType& val)
const;
450 bool probeValue(
Index offset, ValueType& val)
const;
456 void setActiveState(
const Coord& xyz,
bool on);
461 void setValueOnly(
const Coord& xyz,
const ValueType& val);
463 void setValueOnly(
Index offset,
const ValueType& val);
466 void setValueOff(
const Coord& xyz) { mValueMask.setOff(LeafNode::coordToOffset(xyz)); }
471 void setValueOff(
const Coord& xyz,
const ValueType& val);
473 void setValueOff(
Index offset,
const ValueType& val);
476 void setValueOn(
const Coord& xyz) { mValueMask.setOn(LeafNode::coordToOffset(xyz)); }
481 this->setValueOn(LeafNode::coordToOffset(xyz), val);
487 mBuffer[offset] = val;
488 mValueMask.setOn(offset);
493 template<
typename ModifyOp>
497 mValueMask.setOn(offset);
501 template<
typename ModifyOp>
504 this->modifyValue(this->coordToOffset(xyz), op);
508 template<
typename ModifyOp>
511 const Index offset = this->coordToOffset(xyz);
512 bool state = mValueMask.isOn(offset);
513 op(mBuffer[offset], state);
514 mValueMask.set(offset, state);
531 void fill(
const CoordBBox& bbox,
const ValueType&,
bool active =
true);
534 void fill(
const ValueType& value);
536 void fill(
const ValueType& value,
bool active);
549 template<
typename DenseT>
550 void copyToDense(
const CoordBBox& bbox, DenseT& dense)
const;
568 template<
typename DenseT>
569 void copyFromDense(
const CoordBBox& bbox,
const DenseT& dense,
570 const ValueType& background,
const ValueType& tolerance);
574 template<
typename AccessorT>
577 return this->getValue(xyz);
582 template<
typename AccessorT>
587 template<
typename AccessorT>
590 this->setValueOn(xyz, val);
596 template<
typename AccessorT>
599 this->setValueOnly(xyz, val);
605 template<
typename ModifyOp,
typename AccessorT>
608 this->modifyValue(xyz, op);
613 template<
typename ModifyOp,
typename AccessorT>
616 this->modifyValueAndActiveState(xyz, op);
621 template<
typename AccessorT>
624 this->setValueOff(xyz, value);
630 template<
typename AccessorT>
633 this->setActiveState(xyz, on);
639 template<
typename AccessorT>
642 return this->probeValue(xyz, val);
648 template<
typename AccessorT>
651 const Index offset = this->coordToOffset(xyz);
652 state = mValueMask.isOn(offset);
654 return mBuffer[offset];
659 template<
typename AccessorT>
671 void resetBackground(
const ValueType& oldBackground,
const ValueType& newBackground);
678 void signedFloodFill(
const ValueType& background);
685 void signedFloodFill(
const ValueType& outside,
const ValueType& inside);
691 template<MergePolicy Policy>
void merge(
const LeafNode&);
692 template<MergePolicy Policy>
void merge(
const ValueType& tileValue,
bool tileActive);
693 template<MergePolicy Policy>
694 void merge(
const LeafNode& other,
const ValueType& ,
const ValueType& );
702 template<
typename OtherType>
716 template<
typename OtherType>
730 template<
typename OtherType>
733 template<
typename CombineOp>
735 template<
typename CombineOp>
736 void combine(
const ValueType& value,
bool valueIsActive, CombineOp& op);
738 template<
typename CombineOp>
739 void combine2(
const LeafNode& other,
const ValueType&,
bool valueIsActive, CombineOp&);
740 template<
typename CombineOp>
741 void combine2(
const ValueType&,
const LeafNode& other,
bool valueIsActive, CombineOp&);
742 template<
typename CombineOp>
750 template<
typename BBoxOp>
void visitActiveBBox(BBoxOp&)
const;
752 template<
typename VisitorOp>
void visit(VisitorOp&);
753 template<
typename VisitorOp>
void visit(VisitorOp&)
const;
755 template<
typename OtherLeafNodeType,
typename VisitorOp>
756 void visit2Node(OtherLeafNodeType& other, VisitorOp&);
757 template<
typename OtherLeafNodeType,
typename VisitorOp>
758 void visit2Node(OtherLeafNodeType& other, VisitorOp&)
const;
759 template<
typename IterT,
typename VisitorOp>
760 void visit2(IterT& otherIter, VisitorOp&,
bool otherIsLHS =
false);
761 template<
typename IterT,
typename VisitorOp>
762 void visit2(IterT& otherIter, VisitorOp&,
bool otherIsLHS =
false)
const;
765 template<
typename PruneOp>
void pruneOp(PruneOp&) {}
770 template<
typename AccessorT>
772 template<
typename NodeT>
774 template<
typename NodeT>
776 template<
typename NodeT>
780 void addTile(
Index level,
const Coord&,
const ValueType&,
bool);
781 void addTile(
Index offset,
const ValueType&,
bool);
782 template<
typename AccessorT>
783 void addTileAndCache(
Index,
const Coord&,
const ValueType&,
bool, AccessorT&);
786 LeafNode* touchLeaf(
const Coord&) {
return this; }
788 template<
typename AccessorT>
790 template<
typename NodeT,
typename AccessorT>
794 if (!(boost::is_same<NodeT,LeafNode>::value))
return NULL;
795 return reinterpret_cast<NodeT*
>(
this);
799 template<
typename AccessorT>
803 const LeafNode* probeConstLeaf(
const Coord&)
const {
return this; }
805 template<
typename AccessorT>
807 template<
typename AccessorT>
810 template<
typename NodeT,
typename AccessorT>
814 if (!(boost::is_same<NodeT,LeafNode>::value))
return NULL;
815 return reinterpret_cast<const NodeT*
>(
this);
823 bool isConstant(ValueType& constValue,
bool& state,
824 const ValueType& tolerance = zeroVal<ValueType>())
const;
829 friend class ::TestLeaf;
830 template<
typename>
friend class ::TestLeafIO;
876 template<
typename NodeT,
typename VisitorOp,
typename ChildAllIterT>
877 static inline void doVisit(NodeT&, VisitorOp&);
879 template<
typename NodeT,
typename OtherNodeT,
typename VisitorOp,
880 typename ChildAllIterT,
typename OtherChildAllIterT>
881 static inline void doVisit2Node(NodeT&
self, OtherNodeT& other, VisitorOp&);
883 template<
typename NodeT,
typename VisitorOp,
884 typename ChildAllIterT,
typename OtherChildAllIterT>
885 static inline void doVisit2(NodeT&
self, OtherChildAllIterT&, VisitorOp&,
bool otherIsLHS);
892 template<
typename T, Index Log2Dim>
901 template<
typename T, Index Log2Dim>
906 mOrigin(xyz & (~(DIM - 1)))
910 template<
typename T, Index Log2Dim>
911 template<
typename OtherValueType>
916 mValueMask(other.mValueMask),
917 mOrigin(other.mOrigin)
921 template<
typename T, Index Log2Dim>
922 template<
typename OtherValueType>
926 mValueMask(other.mValueMask),
927 mOrigin(other.mOrigin)
934 template<
typename T, Index Log2Dim>
937 mBuffer(other.mBuffer),
938 mValueMask(other.mValueMask),
939 mOrigin(other.mOrigin)
944 template<
typename T, Index Log2Dim>
950 template<
typename T, Index Log2Dim>
954 std::ostringstream ostr;
955 ostr <<
"LeafNode @" << mOrigin <<
": " << mBuffer;
963 template<
typename T, Index Log2Dim>
967 assert ((xyz[0] & (DIM-1u)) < DIM && (xyz[1] & (DIM-1u)) < DIM && (xyz[2] & (DIM-1u)) < DIM);
968 return ((xyz[0] & (DIM-1u)) << 2*Log2Dim)
969 + ((xyz[1] & (DIM-1u)) << Log2Dim)
970 + (xyz[2] & (DIM-1u));
973 template<
typename T, Index Log2Dim>
977 assert(n<(1<< 3*Log2Dim));
979 xyz.setX(n >> 2*Log2Dim);
980 n &= ((1<<2*Log2Dim)-1);
981 xyz.setY(n >> Log2Dim);
982 xyz.setZ(n & ((1<<Log2Dim)-1));
987 template<
typename T, Index Log2Dim>
991 assert(n<(1<< 3*Log2Dim));
992 xyz.setX(n >> 2*Log2Dim);
993 n &= ((1<<2*Log2Dim)-1);
994 xyz.setY(n >> Log2Dim);
995 xyz.setZ(n & ((1<<Log2Dim)-1));
999 template<
typename T, Index Log2Dim>
1003 return (this->offsetToLocalCoord(n) + this->origin());
1010 template<
typename ValueT, Index Log2Dim>
1011 inline const ValueT&
1017 template<
typename ValueT, Index Log2Dim>
1018 inline const ValueT&
1021 assert(offset < SIZE);
1022 return mBuffer[offset];
1026 template<
typename T, Index Log2Dim>
1033 template<
typename T, Index Log2Dim>
1037 assert(offset < SIZE);
1038 val = mBuffer[offset];
1039 return mValueMask.isOn(offset);
1043 template<
typename T, Index Log2Dim>
1050 template<
typename T, Index Log2Dim>
1054 assert(offset < SIZE);
1055 mBuffer[offset] = val;
1056 mValueMask.setOff(offset);
1060 template<
typename T, Index Log2Dim>
1064 mValueMask.set(this->coordToOffset(xyz), on);
1068 template<
typename T, Index Log2Dim>
1075 template<
typename T, Index Log2Dim>
1079 assert(offset<SIZE); mBuffer[offset] = val;
1086 template<
typename T, Index Log2Dim>
1090 for (
Int32 x = bbox.min().x(); x <= bbox.max().x(); ++x) {
1091 const Index offsetX = (x & (DIM-1u)) << 2*Log2Dim;
1092 for (
Int32 y = bbox.min().y(); y <= bbox.max().y(); ++y) {
1093 const Index offsetXY = offsetX + ((y & (DIM-1u)) << Log2Dim);
1094 for (
Int32 z = bbox.min().z(); z <= bbox.max().z(); ++z) {
1095 const Index offset = offsetXY + (z & (DIM-1u));
1096 mBuffer[offset] = value;
1097 mValueMask.set(offset, active);
1103 template<
typename T, Index Log2Dim>
1107 mBuffer.fill(value);
1110 template<
typename T, Index Log2Dim>
1114 mBuffer.fill(value);
1115 mValueMask.set(active);
1122 template<
typename T, Index Log2Dim>
1123 template<
typename DenseT>
1127 typedef typename DenseT::ValueType DenseValueType;
1129 const size_t xStride = dense.xStride(), yStride = dense.yStride(), zStride = dense.zStride();
1130 const Coord&
min = dense.bbox().min();
1131 DenseValueType* t0 = dense.data() + zStride * (bbox.min()[2] - min[2]);
1132 const T* s0 = &mBuffer[bbox.min()[2] & (DIM-1u)];
1133 for (
Int32 x = bbox.min()[0], ex = bbox.max()[0] + 1; x < ex; ++x) {
1134 DenseValueType* t1 = t0 + xStride * (x - min[0]);
1135 const T* s1 = s0 + ((x & (DIM-1u)) << 2*Log2Dim);
1136 for (
Int32 y = bbox.min()[1], ey = bbox.max()[1] + 1; y < ey; ++y) {
1137 DenseValueType* t2 = t1 + yStride * (y - min[1]);
1138 const T* s2 = s1 + ((y & (DIM-1u)) << Log2Dim);
1139 for (
Int32 z = bbox.min()[2], ez = bbox.max()[2] + 1; z < ez; ++z, t2 += zStride) {
1140 *t2 = DenseValueType(*s2++);
1147 template<
typename T, Index Log2Dim>
1148 template<
typename DenseT>
1153 typedef typename DenseT::ValueType DenseValueType;
1155 const size_t xStride = dense.xStride(), yStride = dense.yStride(), zStride = dense.zStride();
1156 const Coord&
min = dense.bbox().min();
1158 const DenseValueType* s0 = dense.data() + zStride * (bbox.min()[2] - min[2]);
1159 const Int32 n0 = bbox.min()[2] & (DIM-1u);
1160 for (
Int32 x = bbox.min()[0], ex = bbox.max()[0]+1; x < ex; ++x) {
1161 const DenseValueType* s1 = s0 + xStride * (x - min[0]);
1162 const Int32 n1 = n0 + ((x & (DIM-1u)) << 2*LOG2DIM);
1163 for (
Int32 y = bbox.min()[1], ey = bbox.max()[1]+1; y < ey; ++y) {
1164 const DenseValueType* s2 = s1 + yStride * (y - min[1]);
1165 Int32 n2 = n1 + ((y & (DIM-1u)) << LOG2DIM);
1166 for (
Int32 z = bbox.min()[2], ez = bbox.max()[2]+1; z < ez; ++z, ++n2, s2 += zStride) {
1168 mValueMask.setOff(n2);
1169 mBuffer[n2] = background;
1171 mValueMask.setOn(n2);
1183 template<
typename T, Index Log2Dim>
1187 mValueMask.load(is);
1191 template<
typename T, Index Log2Dim>
1195 mValueMask.save(os);
1202 template<
typename T, Index Log2Dim>
1207 mValueMask.load(is);
1209 int8_t numBuffers = 1;
1212 is.read(reinterpret_cast<char*>(&mOrigin),
sizeof(Coord::ValueType) * 3);
1215 is.read(reinterpret_cast<char*>(&numBuffers),
sizeof(int8_t));
1220 if (numBuffers > 1) {
1225 for (
int i = 1; i < numBuffers; ++i) {
1229 io::readData<T>(is, temp.mData, SIZE, zipped);
1236 template<
typename T, Index Log2Dim>
1241 mValueMask.save(os);
1251 template<
typename T, Index Log2Dim>
1255 return mOrigin == other.
mOrigin &&
1261 template<
typename T, Index Log2Dim>
1265 return mBuffer.memUsage() +
sizeof(mOrigin) + mValueMask.memUsage();
1269 template<
typename T, Index Log2Dim>
1273 CoordBBox this_bbox = this->getNodeBoundingBox();
1274 if (bbox.isInside(this_bbox))
return;
1277 for(; iter; ++iter) this_bbox.expand(this->offsetToLocalCoord(iter.pos()));
1278 this_bbox.translate(this->origin());
1279 bbox.expand(this_bbox);
1283 template<
typename T, Index Log2Dim>
1287 CoordBBox this_bbox = this->getNodeBoundingBox();
1288 if (bbox.isInside(this_bbox))
return;
1292 for(; iter; ++iter) this_bbox.expand(this->offsetToLocalCoord(iter.pos()));
1293 this_bbox.translate(this->origin());
1295 bbox.expand(this_bbox);
1300 template<
typename T, Index Log2Dim>
1301 template<
typename OtherType, Index OtherLog2Dim>
1306 return (Log2Dim == OtherLog2Dim && mValueMask == other->
getValueMask());
1310 template<
typename T, Index Log2Dim>
1313 bool& state,
const ValueType& tolerance)
const
1315 state = mValueMask.isOn();
1317 if (!(state || mValueMask.isOff()))
return false;
1319 bool allEqual =
true;
1320 const T value = mBuffer[0];
1321 for (
Index i = 1; allEqual && i < SIZE; ++i) {
1325 if (allEqual) constValue = value;
1333 template<
typename T, Index Log2Dim>
1338 this->addTile(this->coordToOffset(xyz), val, active);
1341 template<
typename T, Index Log2Dim>
1345 assert(offset < SIZE);
1346 setValueOnly(offset, val);
1347 setActiveState(offset, active);
1350 template<
typename T, Index Log2Dim>
1351 template<
typename AccessorT>
1354 const ValueType& val,
bool active, AccessorT&)
1356 this->addTile(level, xyz, val, active);
1363 template<
typename T, Index Log2Dim>
1370 template<
typename T, Index Log2Dim>
1375 const Index first = mValueMask.findFirstOn();
1377 bool xInside =
math::isNegative(mBuffer[first]), yInside = xInside, zInside = xInside;
1378 for (
Index x = 0; x != (1 << Log2Dim); ++x) {
1379 const Index x00 = x << (2 * Log2Dim);
1380 if (mValueMask.isOn(x00)) {
1384 for (
Index y = 0; y != (1 << Log2Dim); ++y) {
1385 const Index xy0 = x00 + (y << Log2Dim);
1386 if (mValueMask.isOn(xy0)) {
1390 for (
Index z = 0; z != (1 << Log2Dim); ++z) {
1391 const Index xyz = xy0 + z;
1392 if (mValueMask.isOn(xyz)) {
1395 mBuffer[xyz] = zInside ? insideValue : outsideValue;
1406 template<
typename T, Index Log2Dim>
1413 for (iter = this->mValueMask.beginOff(); iter; ++iter) {
1416 inactiveValue = newBackground;
1424 template<
typename T, Index Log2Dim>
1425 template<MergePolicy Policy>
1432 for (; iter; ++iter) {
1434 if (mValueMask.isOff(n)) {
1435 mBuffer[n] = other.
mBuffer[n];
1436 mValueMask.setOn(n);
1442 template<
typename T, Index Log2Dim>
1443 template<MergePolicy Policy>
1448 this->
template merge<Policy>(other);
1451 template<
typename T, Index Log2Dim>
1452 template<MergePolicy Policy>
1458 if (!tileActive)
return;
1461 const Index n = iter.pos();
1462 mBuffer[n] = tileValue;
1463 mValueMask.setOn(n);
1469 template<
typename T, Index Log2Dim>
1470 template<
typename OtherType>
1477 template<
typename T, Index Log2Dim>
1478 template<
typename OtherType>
1486 template<
typename T, Index Log2Dim>
1487 template<
typename OtherType>
1495 template<
typename T, Index Log2Dim>
1499 for (
Index i = 0; i < SIZE; ++i) {
1500 mBuffer[i] = -mBuffer[i];
1508 template<
typename T, Index Log2Dim>
1509 template<
typename CombineOp>
1514 for (
Index i = 0; i < SIZE; ++i) {
1516 .setAIsActive(mValueMask.isOn(i))
1519 .setResultRef(mBuffer[i]));
1525 template<
typename T, Index Log2Dim>
1526 template<
typename CombineOp>
1531 args.
setBRef(value).setBIsActive(valueIsActive);
1532 for (
Index i = 0; i < SIZE; ++i) {
1534 .setAIsActive(mValueMask.isOn(i))
1535 .setResultRef(mBuffer[i]));
1544 template<
typename T, Index Log2Dim>
1545 template<
typename CombineOp>
1548 bool valueIsActive, CombineOp& op)
1551 args.
setBRef(value).setBIsActive(valueIsActive);
1552 for (
Index i = 0; i < SIZE; ++i) {
1555 .setResultRef(mBuffer[i]));
1561 template<
typename T, Index Log2Dim>
1562 template<
typename CombineOp>
1565 bool valueIsActive, CombineOp& op)
1568 args.
setARef(value).setAIsActive(valueIsActive);
1569 for (
Index i = 0; i < SIZE; ++i) {
1572 .setResultRef(mBuffer[i]));
1578 template<
typename T, Index Log2Dim>
1579 template<
typename CombineOp>
1584 for (
Index i = 0; i < SIZE; ++i) {
1590 .setResultRef(mBuffer[i]));
1599 template<
typename T, Index Log2Dim>
1600 template<
typename BBoxOp>
1604 if (op.template descent<LEVEL>()) {
1607 op.operator()<LEVEL>(CoordBBox::createCube(i.getCoord(), 1));
1609 op.template operator()<LEVEL>(CoordBBox::createCube(i.getCoord(), 1));
1614 op.operator()<LEVEL>(this->getNodeBoundingBox());
1616 op.template operator()<LEVEL>(this->getNodeBoundingBox());
1622 template<
typename T, Index Log2Dim>
1623 template<
typename VisitorOp>
1627 doVisit<LeafNode, VisitorOp, ChildAllIter>(*
this, op);
1631 template<
typename T, Index Log2Dim>
1632 template<
typename VisitorOp>
1636 doVisit<const LeafNode, VisitorOp, ChildAllCIter>(*
this, op);
1640 template<
typename T, Index Log2Dim>
1641 template<
typename NodeT,
typename VisitorOp,
typename ChildAllIterT>
1645 for (ChildAllIterT iter =
self.beginChildAll(); iter; ++iter) {
1654 template<
typename T, Index Log2Dim>
1655 template<
typename OtherLeafNodeType,
typename VisitorOp>
1660 typename OtherLeafNodeType::ChildAllIter>(*
this, other, op);
1664 template<
typename T, Index Log2Dim>
1665 template<
typename OtherLeafNodeType,
typename VisitorOp>
1670 typename OtherLeafNodeType::ChildAllCIter>(*
this, other, op);
1674 template<
typename T, Index Log2Dim>
1677 typename OtherNodeT,
1679 typename ChildAllIterT,
1680 typename OtherChildAllIterT>
1685 BOOST_STATIC_ASSERT(OtherNodeT::SIZE == NodeT::SIZE);
1686 BOOST_STATIC_ASSERT(OtherNodeT::LEVEL == NodeT::LEVEL);
1688 ChildAllIterT iter =
self.beginChildAll();
1689 OtherChildAllIterT otherIter = other.beginChildAll();
1691 for ( ; iter && otherIter; ++iter, ++otherIter) {
1692 op(iter, otherIter);
1700 template<
typename T, Index Log2Dim>
1701 template<
typename IterT,
typename VisitorOp>
1705 doVisit2<LeafNode, VisitorOp, ChildAllIter, IterT>(
1706 *
this, otherIter, op, otherIsLHS);
1710 template<
typename T, Index Log2Dim>
1711 template<
typename IterT,
typename VisitorOp>
1715 doVisit2<const LeafNode, VisitorOp, ChildAllCIter, IterT>(
1716 *
this, otherIter, op, otherIsLHS);
1720 template<
typename T, Index Log2Dim>
1724 typename ChildAllIterT,
1725 typename OtherChildAllIterT>
1728 VisitorOp& op,
bool otherIsLHS)
1730 if (!otherIter)
return;
1733 for (ChildAllIterT iter =
self.beginChildAll(); iter; ++iter) {
1734 op(otherIter, iter);
1737 for (ChildAllIterT iter =
self.beginChildAll(); iter; ++iter) {
1738 op(iter, otherIter);
1747 template<
typename T, Index Log2Dim>
1748 inline std::ostream&
1749 operator<<(std::ostream& os, const typename LeafNode<T, Log2Dim>::Buffer& buf)
1751 for (
Index32 i = 0, N = buf.size(); i < N; ++i) os << buf.mData[i] <<
", ";
1766 #endif // OPENVDB_TREE_LEAFNODE_HAS_BEEN_INCLUDED
ValueIter()
Definition: LeafNode.h:285
void setValueOff(const Coord &xyz)
Mark the voxel at the given coordinates as inactive but don't change its value.
Definition: LeafNode.h:466
bool isValueOnAndCache(const Coord &xyz, AccessorT &) const
Return true if the voxel at the given coordinates is active.
Definition: LeafNode.h:583
static Index32 leafCount()
Return the leaf count for this node, which is one.
Definition: LeafNode.h:204
bool probeValueAndCache(const Coord &xyz, ValueType &val, AccessorT &) const
Return true if the voxel at the given coordinates is active and return the voxel value in val...
Definition: LeafNode.h:640
bool isValueOn(const Coord &xyz) const
Return true if the voxel at the given coordinates is active.
Definition: LeafNode.h:523
ValueIter< MaskOffIterator, LeafNode, const ValueType, ValueOff > ValueOffIter
Definition: LeafNode.h:350
DenseIter< LeafNode, ValueType, ChildAll > ChildAllIter
Definition: LeafNode.h:358
LeafNode * touchLeafAndCache(const Coord &, AccessorT &)
Return a pointer to this node.
Definition: LeafNode.h:789
LeafNode< ValueType, Log2Dim > LeafNodeType
Definition: LeafNode.h:66
DenseIter(const MaskDenseIterator &iter, NodeT *parent)
Definition: LeafNode.h:328
Buffer mBuffer
Buffer containing the actual data values.
Definition: LeafNode.h:850
const ValueType & getFirstValue() const
Return a const reference to the first value in the buffer.
Definition: LeafNode.h:665
void setActiveState(Index offset, bool on)
Set the active state of the voxel at the given offset but don't change its value. ...
Definition: LeafNode.h:458
OPENVDB_API Hermite min(const Hermite &, const Hermite &)
min and max operations done directly on the compressed data.
Index64 onVoxelCount() const
Return the number of voxels marked On.
Definition: LeafNode.h:209
void prune(const ValueType &=zeroVal< ValueType >())
This function exists only to enable template instantiation.
Definition: LeafNode.h:767
ValueOffCIter cendValueOff() const
Definition: LeafNode.h:374
bool isValueMaskOn(Index n) const
Definition: LeafNode.h:858
Coord offsetToGlobalCoord(Index n) const
Return the global coordinates for a linear table offset.
Definition: LeafNode.h:1001
void evalActiveBoundingBox(CoordBBox &, bool visitVoxels=true) const
Definition: LeafNode.h:1285
ChildOnCIter cbeginChildOn() const
Definition: LeafNode.h:383
ChildOnIter beginChildOn()
Definition: LeafNode.h:385
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:1303
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:1125
Definition: LeafNode.h:50
Index32 pos() const
Definition: NodeMasks.h:177
void signedFloodFill(const ValueType &background)
Overwrite each inactive value in this node and in any child nodes with a new value whose magnitude is...
Definition: LeafNode.h:1365
const ValueType & operator[](Index i) const
Return a const reference to the i'th element of the Buffer.
Definition: LeafNode.h:109
ValueIter< MaskDenseIterator, const LeafNode, const ValueType, ValueAll > ValueAllCIter
Definition: LeafNode.h:353
ChildOffIter beginChildOff()
Definition: LeafNode.h:388
bool operator==(const LeafNode &other) const
Check for buffer, state and origin equivalence.
Definition: LeafNode.h:1253
boost::remove_const< UnsetItemT >::type NonConstValueType
Definition: Iterator.h:217
ValueOnCIter cbeginValueOn() const
Definition: LeafNode.h:361
void writeCompressedValues(std::ostream &os, ValueT *srcBuf, Index srcCount, const MaskT &valueMask, const MaskT &childMask, bool toHalf)
Definition: Compression.h:378
Definition: NodeMasks.h:189
bool isChildMaskOn(Index) const
Definition: LeafNode.h:865
void swap(Buffer &other)
Exchange this node's data buffer with the given data buffer without changing the active states of the...
Definition: LeafNode.h:408
ChildIter< MaskOnIterator, LeafNode, ChildOn > ChildOnIter
Definition: LeafNode.h:354
void setValue(const Coord &xyz, const ValueType &val)
Set the value of the voxel at the given coordinates and mark the voxel as active. ...
Definition: LeafNode.h:484
static Coord offsetToLocalCoord(Index n)
Return the local coordinates for a linear table offset, where offset 0 has coordinates (0...
Definition: LeafNode.h:975
Index64 offLeafVoxelCount() const
Definition: LeafNode.h:213
ValueT & getItem(Index pos) const
Definition: LeafNode.h:288
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:1480
static Index memUsage()
Return the memory-footprint of this Buffer in units of bytes.
Definition: LeafNode.h:142
Definition: LeafNode.h:273
void visit2Node(OtherLeafNodeType &other, VisitorOp &)
Definition: LeafNode.h:1657
OnIterator beginOn() const
Definition: NodeMasks.h:332
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:1472
util::NodeMask< Log2Dim > NodeMaskType
Definition: LeafNode.h:68
const ValueType & getValue(const Coord &xyz) const
Return the value of the voxel at the given coordinates.
Definition: LeafNode.h:1012
ChildOnIter endChildOn()
Definition: LeafNode.h:395
void voxelizeActiveTiles()
Definition: LeafNode.h:689
void addLeafAndCache(LeafNode *, AccessorT &)
This function exists only to enable template instantiation.
Definition: LeafNode.h:771
ChildIter< MaskOffIterator, const LeafNode, ChildOff > ChildOffCIter
Definition: LeafNode.h:357
static Index coordToOffset(const Coord &xyz)
Return the linear table offset of the given global or local coordinates.
Definition: LeafNode.h:965
void setValueOffAndCache(const Coord &xyz, const ValueType &value, AccessorT &)
Change the value of the voxel at the given coordinates and mark it as inactive.
Definition: LeafNode.h:622
void combine2(const LeafNode &other, const ValueType &, bool valueIsActive, CombineOp &)
Definition: LeafNode.h:1547
Buffer()
Empty default constructor.
Definition: LeafNode.h:92
ValueOnIter beginValueOn()
Definition: LeafNode.h:363
void negate()
Definition: LeafNode.h:1497
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:494
void setOrigin(const Coord &origin)
Set the grid index coordinates of this node's local origin.
Definition: LeafNode.h:235
Definition: LeafNode.h:277
ValueOnCIter endValueOn() const
Definition: LeafNode.h:372
Definition: LeafNode.h:274
ValueAllCIter endValueAll() const
Definition: LeafNode.h:378
ValueOnIter endValueOn()
Definition: LeafNode.h:373
Bit mask for the internal and leaf nodes of VDB. This is a 64-bit implementation. ...
Definition: NodeMasks.h:288
ValueIter< MaskDenseIterator, LeafNode, const ValueType, ValueAll > ValueAllIter
Definition: LeafNode.h:352
Index32 Index
Definition: Types.h:56
ValueAllIter beginValueAll()
Definition: LeafNode.h:369
static const Index SIZE
Definition: LeafNode.h:76
const NodeT * probeConstNode(const Coord &) const
This function exists only to enable template instantiation.
Definition: LeafNode.h:777
static void doVisit2Node(NodeT &self, OtherNodeT &other, VisitorOp &)
Definition: LeafNode.h:1682
ChildAllCIter endChildAll() const
Definition: LeafNode.h:400
ValueOnCIter beginValueOn() const
Definition: LeafNode.h:362
void swap(Buffer &other)
Replace the values in this Buffer with the values in the other Buffer.
Definition: LeafNode.h:135
bool operator==(const Vec3< T0 > &v0, const Vec3< T1 > &v1)
Equality operator, does exact floating point comparisons.
Definition: Vec3.h:430
bool isValueOn(Index offset) const
Return true if the voxel at the given offset is active.
Definition: LeafNode.h:525
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: LeafNode.h:606
void addLeaf(LeafNode *)
This function exists only to enable template instantiation.
Definition: LeafNode.h:769
Definition: Compression.h:70
void setItem(Index pos, const ValueT &value) const
Definition: LeafNode.h:292
static Index getChildDim()
Return the dimension of child nodes of this LeafNode, which is one for voxels.
Definition: LeafNode.h:202
Base class for sparse iterators over internal and leaf nodes.
Definition: Iterator.h:148
ChildOnCIter cendChildOn() const
Definition: LeafNode.h:393
void unsetItem(Index pos, const ValueT &value) const
Definition: LeafNode.h:341
void readBuffers(std::istream &is, bool fromHalf=false)
Read buffers from a stream.
Definition: LeafNode.h:1204
void modifyValue(const ModifyOp &op) const
Definition: LeafNode.h:307
ValueOffCIter cbeginValueOff() const
Definition: LeafNode.h:364
void setValueOn(const Coord &xyz)
Mark the voxel at the given coordinates as active but don't change its value.
Definition: LeafNode.h:476
ChildIter(const MaskIterT &iter, NodeT *parent)
Definition: LeafNode.h:316
LeafNode * probeLeafAndCache(const Coord &, AccessorT &)
Return a pointer to this node.
Definition: LeafNode.h:800
~Buffer()
Destructor.
Definition: LeafNode.h:98
void setValueOn(Index offset)
Mark the voxel at the given offset as active but don't change its value.
Definition: LeafNode.h:478
bool operator!=(const LeafNode &other) const
Definition: LeafNode.h:265
SparseIteratorBase< MaskIterT, ValueIter, NodeT, ValueT > BaseT
Definition: LeafNode.h:283
static Index64 onTileCount()
Definition: LeafNode.h:214
Stores the actual values in the LeafNode. Its dimension it fixed to 2^(3*Log2Dim) ...
Definition: LeafNode.h:88
BaseT::NonConstValueType NonConstValueT
Definition: LeafNode.h:325
ValueIter< MaskOffIterator, const LeafNode, const ValueType, ValueOff > ValueOffCIter
Definition: LeafNode.h:351
CombineArgs & setBRef(const ValueType &b)
Redirect the B value to a new external source.
Definition: Types.h:271
This struct collects both input and output arguments to "grid combiner" functors used with the tree::...
Definition: Types.h:232
Definition: Compression.h:165
static Index64 offTileCount()
Definition: LeafNode.h:215
void setValuesOn()
Mark all voxels as active but don't change their values.
Definition: LeafNode.h:518
ChildAllCIter cbeginChildAll() const
Definition: LeafNode.h:389
#define OPENVDB_VERSION_NAME
Definition: version.h:45
OPENVDB_IMPORT uint32_t getDataCompression(std::ios_base &)
Return a bitwise OR of compression option flags (COMPRESS_ZIP, COMPRESS_ACTIVE_MASK, etc.) specifying whether and how input data is compressed or output data should be compressed.
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:1062
Buffer(const ValueType &val)
Constructs a buffer populated with the specified value.
Definition: LeafNode.h:94
ChildOffCIter cbeginChildOff() const
Definition: LeafNode.h:386
bool isValueMaskOff() const
Definition: LeafNode.h:861
ChildOffIter endChildOff()
Definition: LeafNode.h:398
void fill(const ValueType &val)
Populates the buffer with a constant value.
Definition: LeafNode.h:100
ValueT & getValue() const
Definition: LeafNode.h:289
Base class for iterators over internal and leaf nodes.
Definition: Iterator.h:58
ChildOnCIter endChildOn() const
Definition: LeafNode.h:394
bool isOn(Index32 n) const
Return true if the nth bit is on.
Definition: NodeMasks.h:440
ChildAllCIter beginChildAll() const
Definition: LeafNode.h:390
void visitActiveBBox(BBoxOp &) const
Calls the templated functor BBoxOp with bounding box information. An additional level argument is pro...
Definition: LeafNode.h:1602
void visit(VisitorOp &)
Definition: LeafNode.h:1625
bool isChildMaskOff(Index) const
Definition: LeafNode.h:866
bool isConstant(ValueType &constValue, bool &state, const ValueType &tolerance=zeroVal< ValueType >()) const
Definition: LeafNode.h:1312
static void doVisit(NodeT &, VisitorOp &)
Definition: LeafNode.h:1643
bool isExactlyEqual(const T0 &a, const T1 &b)
Return true if a is exactly equal to b.
Definition: Math.h:360
Definition: LeafNode.h:274
ValueIter< MaskOnIterator, LeafNode, const ValueType, ValueOn > ValueOnIter
Definition: LeafNode.h:348
NodeMaskType & getValueMask()
Definition: LeafNode.h:863
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:1088
uint32_t Index32
Definition: Types.h:54
void modifyValueAndActiveStateAndCache(const Coord &xyz, const ModifyOp &op, AccessorT &)
Definition: LeafNode.h:614
NodeT * probeNode(const Coord &)
This function exists only to enable template instantiation.
Definition: LeafNode.h:775
void readCompressedValues(std::istream &is, ValueT *destBuf, Index destCount, const MaskT &valueMask, bool fromHalf)
Definition: Compression.h:276
LeafNode * probeLeaf(const Coord &)
Return a pointer to this node.
Definition: LeafNode.h:798
bool isEmpty() const
Return true if this node has no active voxels.
Definition: LeafNode.h:217
uint64_t Index64
Definition: Types.h:55
int32_t Int32
Definition: Types.h:58
bool isValueMaskOff(Index n) const
Definition: LeafNode.h:860
void addTile(Index level, const Coord &, const ValueType &, bool)
Definition: LeafNode.h:1335
Index64 memUsage() const
Return the memory in bytes occupied by this node.
Definition: LeafNode.h:1263
void setValue(const ValueT &value) const
Definition: LeafNode.h:297
Leaf nodes have no children, so their child iterators have no get/set accessors.
Definition: LeafNode.h:312
Buffer(const Buffer &other)
Copy constructor.
Definition: LeafNode.h:96
NodeT * stealNode(const Coord &, const ValueType &, bool)
This function exists only to enable template instantiation.
Definition: LeafNode.h:773
void setValueMask(const NodeMaskType &mask)
Definition: LeafNode.h:864
Base class for dense iterators over internal and leaf nodes.
Definition: Iterator.h:211
void addTileAndCache(Index, const Coord &, const ValueType &, bool, AccessorT &)
Definition: LeafNode.h:1353
CombineArgs & setARef(const ValueType &a)
Redirect the A value to a new external source.
Definition: Types.h:269
const NodeMaskType & getValueMask() const
Definition: LeafNode.h:862
bool getItem(Index pos, void *&child, NonConstValueT &value) const
Definition: LeafNode.h:330
ValueIter(const MaskIterT &iter, NodeT *parent)
Definition: LeafNode.h:286
static Index dim()
Return the number of voxels in each coordinate dimension.
Definition: LeafNode.h:192
void setValue(Index i, const ValueType &val)
Set the i'th value of the Buffer to the specified value.
Definition: LeafNode.h:111
static Index getLevel()
Return the level of this node, which by definition is zero for LeafNodes.
Definition: LeafNode.h:198
NodeMaskType::OffIterator MaskOffIterator
Definition: LeafNode.h:269
ValueIter< MaskOnIterator, const LeafNode, const ValueType, ValueOn > ValueOnCIter
Definition: LeafNode.h:349
LeafNode< OtherValueType, Log2Dim > Type
Definition: LeafNode.h:83
bool isValueMaskOn() const
Definition: LeafNode.h:859
NodeT * probeNodeAndCache(const Coord &, AccessorT &)
Return a pointer to this node.
Definition: LeafNode.h:791
ValueOffCIter beginValueOff() const
Definition: LeafNode.h:365
void setValueOn(Index offset, const ValueType &val)
Set the value of the voxel at the given offset and mark the voxel as active.
Definition: LeafNode.h:486
Index64 onLeafVoxelCount() const
Definition: LeafNode.h:212
static Index size()
Return the total number of voxels represented by this LeafNode.
Definition: LeafNode.h:194
void modifyValue(const Coord &xyz, const ModifyOp &op)
Apply a functor to the value of the voxel at the given coordinates and mark the voxel as active...
Definition: LeafNode.h:502
bool isDense() const
Return true if this node contains only active voxels.
Definition: LeafNode.h:219
Definition: version.h:106
ChildOffCIter cendChildOff() const
Definition: LeafNode.h:396
void readTopology(std::istream &is, bool fromHalf=false)
Read in just the topology.
Definition: LeafNode.h:1185
static void doVisit2(NodeT &self, OtherChildAllIterT &, VisitorOp &, bool otherIsLHS)
Definition: LeafNode.h:1727
ValueOnCIter cendValueOn() const
Definition: LeafNode.h:371
void setValueOn(const Coord &xyz, const ValueType &val)
Set the value of the voxel at the given coordinates and mark the voxel as active. ...
Definition: LeafNode.h:480
void getOrigin(Coord &origin) const
Return the grid index coordinates of this node's local origin.
Definition: LeafNode.h:242
ValueType ValueType
Definition: Iterator.h:151
void visit2(IterT &otherIter, VisitorOp &, bool otherIsLHS=false)
Definition: LeafNode.h:1703
std::string str() const
Return a string representation of this node.
Definition: LeafNode.h:952
Definition: LeafNode.h:273
static void getNodeLog2Dims(std::vector< Index > &dims)
Append the Log2Dim of this LeafNode to the specified vector.
Definition: LeafNode.h:200
bool probeValue(const Coord &xyz, ValueType &val) const
Return true if the voxel at the given coordinates is active.
Definition: LeafNode.h:1028
const ValueType & getValue(Index i) const
Return a const reference to the i'th element of the Buffer.
Definition: LeafNode.h:107
const LeafNode * probeLeafAndCache(const Coord &, AccessorT &) const
Return a const pointer to this node.
Definition: LeafNode.h:808
void resetBackground(const ValueType &oldBackground, const ValueType &newBackground)
Replace inactive occurrences of oldBackground with newBackground, and inactive occurrences of -oldBac...
Definition: LeafNode.h:1408
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:1150
OPENVDB_DEPRECATED void evalActiveVoxelBoundingBox(CoordBBox &) const
Definition: LeafNode.h:1271
Buffer & buffer()
Definition: LeafNode.h:410
void writeBuffers(std::ostream &os, bool toHalf=false) const
Write buffers to a stream.
Definition: LeafNode.h:1238
DenseIter< const LeafNode, const ValueType, ChildAll > ChildAllCIter
Definition: LeafNode.h:359
Coord mOrigin
Global grid index coordinates (x,y,z) of the local origin of this node.
Definition: LeafNode.h:854
bool isInactive() const
Return true if all of this node's values are inactive.
Definition: LeafNode.h:826
ChildOffCIter beginChildOff() const
Definition: LeafNode.h:387
const NodeT * probeConstNodeAndCache(const Coord &, AccessorT &) const
Return a const pointer to this node.
Definition: LeafNode.h:811
void setValueMaskOff(Index n)
Definition: LeafNode.h:871
NodeMaskType::DenseIterator MaskDenseIterator
Definition: LeafNode.h:270
ChildAllIter beginChildAll()
Definition: LeafNode.h:391
ChildIter()
Definition: LeafNode.h:315
bool isApproxEqual(const Hermite &lhs, const Hermite &rhs)
Definition: Hermite.h:470
ValueAllCIter cbeginValueAll() const
Definition: LeafNode.h:367
Buffer & operator=(const Buffer &other)
Assigns the values in the other Buffer to this Buffer.
Definition: LeafNode.h:113
static Index getValueLevel(const Coord &)
Return the level (i.e., 0) at which leaf node values reside.
Definition: LeafNode.h:453
static void evalNodeOrigin(Coord &xyz)
Compute the origin of the leaf node that contains the voxel with the given coordinates.
Definition: LeafNode.h:874
ChildOnCIter beginChildOn() const
Definition: LeafNode.h:384
void setValueOnlyAndCache(const Coord &xyz, const ValueType &val, AccessorT &)
Change the value of the voxel at the given coordinates but preserve its state.
Definition: LeafNode.h:597
void modifyItem(Index n, const ModifyOp &op) const
Definition: LeafNode.h:304
bool operator==(const Buffer &other) const
Definition: LeafNode.h:123
void pruneInactive(const ValueType &)
This function exists only to enable template instantiation.
Definition: LeafNode.h:768
void setValuesOff()
Mark all voxels as inactive but don't change their values.
Definition: LeafNode.h:520
bool isNegative(const Type &x)
Return true if x is less than zero.
Definition: Math.h:313
const LeafNode * probeConstLeafAndCache(const Coord &, AccessorT &) const
Return a const pointer to this node.
Definition: LeafNode.h:806
void setValueAndCache(const Coord &xyz, const ValueType &val, AccessorT &)
Change the value of the voxel at the given coordinates and mark it as active.
Definition: LeafNode.h:588
ValueAllIter endValueAll()
Definition: LeafNode.h:379
Definition: NodeMasks.h:220
bool resultIsActive() const
Definition: Types.h:280
ChildIter< MaskOnIterator, const LeafNode, ChildOn > ChildOnCIter
Definition: LeafNode.h:355
ChildAllCIter cendChildAll() const
Definition: LeafNode.h:399
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:1489
const ValueType & getValueAndCache(const Coord &xyz, AccessorT &) const
Return the value of the voxel at the given coordinates.
Definition: LeafNode.h:575
Templated block class to hold specific data types and a fixed number of values determined by Log2Dim...
Definition: LeafNode.h:62
void getOrigin(Int32 &x, Int32 &y, Int32 &z) const
Return the grid index coordinates of this node's local origin.
Definition: LeafNode.h:243
void modifyValueAndActiveState(const Coord &xyz, const ModifyOp &op)
Apply a functor to the voxel at the given coordinates.
Definition: LeafNode.h:509
LeafNode()
Default constructor.
Definition: LeafNode.h:894
ValueAllCIter cendValueAll() const
Definition: LeafNode.h:377
void setValueMaskOn(Index n)
Definition: LeafNode.h:870
static bool hasActiveTiles()
Return false since leaf nodes never contain tiles.
Definition: LeafNode.h:528
bool operator!=(const Buffer &other) const
Definition: LeafNode.h:133
static Index numValues()
Return the total number of voxels represented by this LeafNode.
Definition: LeafNode.h:196
Definition: NodeMasks.h:251
const ValueType & getValue(const Coord &xyz, bool &state, int &level, AccessorT &) const
Return the value of the voxel at the given coordinates and return its active state and level (i...
Definition: LeafNode.h:649
T ValueType
Definition: LeafNode.h:65
ValueConverter<T>::Type is the type of a LeafNode having the same child hierarchy and dimensions as t...
Definition: LeafNode.h:82
static Index size()
Return the number of values represented in this Buffer.
Definition: LeafNode.h:144
~LeafNode()
Destructor.
Definition: LeafNode.h:946
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h:67
ValueOffIter endValueOff()
Definition: LeafNode.h:376
ValueAllCIter beginValueAll() const
Definition: LeafNode.h:368
NodeMaskType::OnIterator MaskOnIterator
Definition: LeafNode.h:268
T negative(const T &val)
Return the unary negation of the given value.
Definition: Math.h:107
bool isChildMaskOff() const
Definition: LeafNode.h:867
void setActiveStateAndCache(const Coord &xyz, bool on, AccessorT &)
Set the active state of the voxel at the given coordinates without changing its value.
Definition: LeafNode.h:631
static Index getValueLevelAndCache(const Coord &, AccessorT &)
Return the LEVEL (=0) at which leaf node values reside.
Definition: LeafNode.h:660
boost::shared_ptr< LeafNode > Ptr
Definition: LeafNode.h:67
const LeafNode * probeLeaf(const Coord &) const
Return a const pointer to this node.
Definition: LeafNode.h:809
static Index32 nonLeafCount()
Return the non-leaf count for this node, which is zero.
Definition: LeafNode.h:206
OPENVDB_DEPRECATED const Coord & getOrigin() const
Return the grid index coordinates of this node's local origin.
Definition: LeafNode.h:238
NodeMaskType mValueMask
Bitmask that determines which voxels are active.
Definition: LeafNode.h:852
DenseIteratorBase< MaskDenseIterator, DenseIter, NodeT, void, ValueT > BaseT
Definition: LeafNode.h:324
void writeTopology(std::ostream &os, bool toHalf=false) const
Write out just the topology.
Definition: LeafNode.h:1193
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:1070
void setValueOff(Index offset)
Mark the voxel at the given offset as inactive but don't change its value.
Definition: LeafNode.h:468
OPENVDB_IMPORT uint32_t getFormatVersion(std::istream &)
Return the file format version number associated with the given input stream.
Definition: LeafNode.h:273
Definition: LeafNode.h:321
void merge(const LeafNode &)
Definition: LeafNode.h:1427
const ValueType & getLastValue() const
Return a const reference to the last value in the buffer.
Definition: LeafNode.h:667
ValueOffCIter endValueOff() const
Definition: LeafNode.h:375
ChildOffCIter endChildOff() const
Definition: LeafNode.h:397
void setValueMask(Index n, bool on)
Definition: LeafNode.h:869
const Buffer & buffer() const
Definition: LeafNode.h:409
ChildIter< MaskOffIterator, LeafNode, ChildOff > ChildOffIter
Definition: LeafNode.h:356
ChildAllIter endChildAll()
Definition: LeafNode.h:401
ValueOffIter beginValueOff()
Definition: LeafNode.h:366
DenseIter()
Definition: LeafNode.h:327
Index64 offVoxelCount() const
Return the number of voxels marked Off.
Definition: LeafNode.h:211
static Index log2dim()
Return log2 of the dimension of this LeafNode, e.g. 3 if dimensions are 8^3.
Definition: LeafNode.h:190
CoordBBox getNodeBoundingBox() const
Return the bounding box of this node, i.e., the full index space spanned by this leaf node...
Definition: LeafNode.h:232
void combine(const LeafNode &other, CombineOp &op)
Definition: LeafNode.h:1511