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>
64 template<
typename T, Index Log2Dim>
70 typedef boost::shared_ptr<LeafNode>
Ptr;
77 NUM_VALUES = 1 << 3 * Log2Dim,
78 NUM_VOXELS = NUM_VALUES,
84 template<
typename OtherValueType>
91 template<
typename OtherNodeType>
115 while (n--) *target++ = val;
129 while (n--) *target++ = *source++;
160 ValueType& operator[](
Index i) { assert(i < SIZE);
return mData[i]; }
162 friend class ::TestLeaf;
177 explicit LeafNode(
const Coord& coords,
178 const ValueType& value = zeroVal<ValueType>(),
179 bool active =
false);
185 template<
typename OtherValueType>
189 template<
typename OtherValueType>
194 template<
typename OtherValueType>
232 bool isEmpty()
const {
return mValueMask.isOff(); }
234 bool isDense()
const {
return mValueMask.isOn(); }
242 void evalActiveBoundingBox(CoordBBox& bbox,
bool visitVoxels =
true)
const;
249 void setOrigin(
const Coord& origin) { mOrigin = origin; }
251 const Coord& origin()
const {
return mOrigin; }
253 void getOrigin(Coord& origin)
const { origin = mOrigin; }
258 static Index coordToOffset(
const Coord& xyz);
261 static Coord offsetToLocalCoord(
Index n);
263 Coord offsetToGlobalCoord(
Index n)
const;
266 std::string str()
const;
270 template<
typename OtherType, Index OtherLog2Dim>
286 template<
typename MaskIterT,
typename NodeT,
typename ValueT,
typename TagT>
291 MaskIterT, ValueIter<MaskIterT, NodeT, ValueT, TagT>, NodeT, ValueT>
298 ValueT&
getItem(
Index pos)
const {
return this->parent().getValue(pos); }
299 ValueT&
getValue()
const {
return this->parent().getValue(this->pos()); }
304 this->parent().setValueOnly(pos, value);
309 this->parent().setValueOnly(this->pos(), value);
313 template<
typename ModifyOp>
314 void modifyItem(
Index n,
const ModifyOp& op)
const { this->parent().modifyValue(n, op); }
316 template<
typename ModifyOp>
317 void modifyValue(
const ModifyOp& op)
const { this->parent().modifyValue(this->pos(), op); }
321 template<
typename MaskIterT,
typename NodeT,
typename TagT>
323 public SparseIteratorBase<MaskIterT, ChildIter<MaskIterT, NodeT, TagT>, NodeT, ValueType>
330 template<
typename NodeT,
typename ValueT,
typename TagT>
332 MaskDenseIterator, DenseIter<NodeT, ValueT, TagT>, NodeT, void, ValueT>
342 value = this->parent().getValue(pos);
353 this->parent().setValueOnly(pos, value);
428 void readTopology(std::istream& is,
bool fromHalf =
false);
432 void writeTopology(std::ostream& os,
bool toHalf =
false)
const;
437 void readBuffers(std::istream& is,
bool fromHalf =
false);
441 void writeBuffers(std::ostream& os,
bool toHalf =
false)
const;
443 size_t streamingSize(
bool toHalf =
false)
const;
449 const ValueType& getValue(
const Coord& xyz)
const;
451 const ValueType& getValue(
Index offset)
const;
456 bool probeValue(
const Coord& xyz, ValueType& val)
const;
460 bool probeValue(
Index offset, ValueType& val)
const;
466 void setActiveState(
const Coord& xyz,
bool on);
471 void setValueOnly(
const Coord& xyz,
const ValueType& val);
473 void setValueOnly(
Index offset,
const ValueType& val);
476 void setValueOff(
const Coord& xyz) { mValueMask.setOff(LeafNode::coordToOffset(xyz)); }
481 void setValueOff(
const Coord& xyz,
const ValueType& val);
483 void setValueOff(
Index offset,
const ValueType& val);
486 void setValueOn(
const Coord& xyz) { mValueMask.setOn(LeafNode::coordToOffset(xyz)); }
491 this->setValueOn(LeafNode::coordToOffset(xyz), val);
497 mBuffer[offset] = val;
498 mValueMask.setOn(offset);
503 template<
typename ModifyOp>
507 mValueMask.setOn(offset);
511 template<
typename ModifyOp>
514 this->modifyValue(this->coordToOffset(xyz), op);
518 template<
typename ModifyOp>
521 const Index offset = this->coordToOffset(xyz);
522 bool state = mValueMask.isOn(offset);
523 op(mBuffer[offset], state);
524 mValueMask.set(offset, state);
541 void fill(
const CoordBBox& bbox,
const ValueType&,
bool active =
true);
544 void fill(
const ValueType& value);
546 void fill(
const ValueType& value,
bool active);
559 template<
typename DenseT>
560 void copyToDense(
const CoordBBox& bbox, DenseT& dense)
const;
578 template<
typename DenseT>
579 void copyFromDense(
const CoordBBox& bbox,
const DenseT& dense,
580 const ValueType& background,
const ValueType& tolerance);
584 template<
typename AccessorT>
587 return this->getValue(xyz);
592 template<
typename AccessorT>
597 template<
typename AccessorT>
600 this->setValueOn(xyz, val);
606 template<
typename AccessorT>
609 this->setValueOnly(xyz, val);
615 template<
typename ModifyOp,
typename AccessorT>
618 this->modifyValue(xyz, op);
623 template<
typename ModifyOp,
typename AccessorT>
626 this->modifyValueAndActiveState(xyz, op);
631 template<
typename AccessorT>
634 this->setValueOff(xyz, value);
640 template<
typename AccessorT>
643 this->setActiveState(xyz, on);
649 template<
typename AccessorT>
652 return this->probeValue(xyz, val);
658 template<
typename AccessorT>
661 const Index offset = this->coordToOffset(xyz);
662 state = mValueMask.isOn(offset);
664 return mBuffer[offset];
669 template<
typename AccessorT>
681 void resetBackground(
const ValueType& oldBackground,
const ValueType& newBackground);
688 void signedFloodFill(
const ValueType& background);
695 void signedFloodFill(
const ValueType& outside,
const ValueType& inside);
701 template<MergePolicy Policy>
void merge(
const LeafNode&);
702 template<MergePolicy Policy>
void merge(
const ValueType& tileValue,
bool tileActive);
703 template<MergePolicy Policy>
704 void merge(
const LeafNode& other,
const ValueType& ,
const ValueType& );
712 template<
typename OtherType>
726 template<
typename OtherType>
740 template<
typename OtherType>
743 template<
typename CombineOp>
745 template<
typename CombineOp>
746 void combine(
const ValueType& value,
bool valueIsActive, CombineOp& op);
748 template<
typename CombineOp,
typename OtherType >
749 void combine2(
const LeafNode& other,
const OtherType&,
bool valueIsActive, CombineOp&);
750 template<
typename CombineOp,
typename OtherNodeT >
751 void combine2(
const ValueType&,
const OtherNodeT& other,
bool valueIsActive, CombineOp&);
752 template<
typename CombineOp,
typename OtherNodeT >
753 void combine2(
const LeafNode& b0,
const OtherNodeT& b1, CombineOp&);
760 template<
typename BBoxOp>
void visitActiveBBox(BBoxOp&)
const;
762 template<
typename VisitorOp>
void visit(VisitorOp&);
763 template<
typename VisitorOp>
void visit(VisitorOp&)
const;
765 template<
typename OtherLeafNodeType,
typename VisitorOp>
766 void visit2Node(OtherLeafNodeType& other, VisitorOp&);
767 template<
typename OtherLeafNodeType,
typename VisitorOp>
768 void visit2Node(OtherLeafNodeType& other, VisitorOp&)
const;
769 template<
typename IterT,
typename VisitorOp>
770 void visit2(IterT& otherIter, VisitorOp&,
bool otherIsLHS =
false);
771 template<
typename IterT,
typename VisitorOp>
772 void visit2(IterT& otherIter, VisitorOp&,
bool otherIsLHS =
false)
const;
775 template<
typename PruneOp>
void pruneOp(PruneOp&) {}
780 template<
typename AccessorT>
782 template<
typename NodeT>
784 template<
typename NodeT>
786 template<
typename NodeT>
790 void addTile(
Index level,
const Coord&,
const ValueType&,
bool);
791 void addTile(
Index offset,
const ValueType&,
bool);
792 template<
typename AccessorT>
793 void addTileAndCache(
Index,
const Coord&,
const ValueType&,
bool, AccessorT&);
796 LeafNode* touchLeaf(
const Coord&) {
return this; }
798 template<
typename AccessorT>
800 template<
typename NodeT,
typename AccessorT>
804 if (!(boost::is_same<NodeT,LeafNode>::value))
return NULL;
805 return reinterpret_cast<NodeT*
>(
this);
809 template<
typename AccessorT>
813 const LeafNode* probeConstLeaf(
const Coord&)
const {
return this; }
815 template<
typename AccessorT>
817 template<
typename AccessorT>
820 template<
typename NodeT,
typename AccessorT>
824 if (!(boost::is_same<NodeT,LeafNode>::value))
return NULL;
825 return reinterpret_cast<const NodeT*
>(
this);
833 bool isConstant(ValueType& constValue,
bool& state,
834 const ValueType& tolerance = zeroVal<ValueType>())
const;
839 friend class ::TestLeaf;
840 template<
typename>
friend class ::TestLeafIO;
886 template<
typename NodeT,
typename VisitorOp,
typename ChildAllIterT>
887 static inline void doVisit(NodeT&, VisitorOp&);
889 template<
typename NodeT,
typename OtherNodeT,
typename VisitorOp,
890 typename ChildAllIterT,
typename OtherChildAllIterT>
891 static inline void doVisit2Node(NodeT&
self, OtherNodeT& other, VisitorOp&);
893 template<
typename NodeT,
typename VisitorOp,
894 typename ChildAllIterT,
typename OtherChildAllIterT>
895 static inline void doVisit2(NodeT&
self, OtherChildAllIterT&, VisitorOp&,
bool otherIsLHS);
904 template<Index Dim1,
typename NodeT2>
909 template<Index Dim1,
typename T2>
917 template<
typename T, Index Log2Dim>
926 template<
typename T, Index Log2Dim>
931 mOrigin(xyz & (~(DIM - 1)))
936 template<
typename T, Index Log2Dim>
939 mBuffer(other.mBuffer),
940 mValueMask(other.mValueMask),
941 mOrigin(other.mOrigin)
947 template<
typename T, Index Log2Dim>
948 template<
typename OtherValueType>
951 mValueMask(other.mValueMask),
952 mOrigin(other.mOrigin)
956 static inline ValueType convertValue(
const OtherValueType& val) {
return ValueType(val); }
965 template<
typename T, Index Log2Dim>
966 template<
typename OtherValueType>
971 mValueMask(other.mValueMask),
972 mOrigin(other.mOrigin)
977 template<
typename T, Index Log2Dim>
978 template<
typename OtherValueType>
982 mValueMask(other.mValueMask),
983 mOrigin(other.mOrigin)
991 template<
typename T, Index Log2Dim>
998 template<
typename T, Index Log2Dim>
1002 std::ostringstream ostr;
1003 ostr <<
"LeafNode @" << mOrigin <<
": " << mBuffer;
1011 template<
typename T, Index Log2Dim>
1015 assert ((xyz[0] & (DIM-1u)) < DIM && (xyz[1] & (DIM-1u)) < DIM && (xyz[2] & (DIM-1u)) < DIM);
1016 return ((xyz[0] & (DIM-1u)) << 2*Log2Dim)
1017 + ((xyz[1] & (DIM-1u)) << Log2Dim)
1018 + (xyz[2] & (DIM-1u));
1021 template<
typename T, Index Log2Dim>
1025 assert(n<(1<< 3*Log2Dim));
1027 xyz.setX(n >> 2*Log2Dim);
1028 n &= ((1<<2*Log2Dim)-1);
1029 xyz.setY(n >> Log2Dim);
1030 xyz.setZ(n & ((1<<Log2Dim)-1));
1035 template<
typename T, Index Log2Dim>
1039 return (this->offsetToLocalCoord(n) + this->origin());
1046 template<
typename ValueT, Index Log2Dim>
1047 inline const ValueT&
1053 template<
typename ValueT, Index Log2Dim>
1054 inline const ValueT&
1057 assert(offset < SIZE);
1058 return mBuffer[offset];
1062 template<
typename T, Index Log2Dim>
1069 template<
typename T, Index Log2Dim>
1073 assert(offset < SIZE);
1074 val = mBuffer[offset];
1075 return mValueMask.isOn(offset);
1079 template<
typename T, Index Log2Dim>
1086 template<
typename T, Index Log2Dim>
1090 assert(offset < SIZE);
1091 mBuffer[offset] = val;
1092 mValueMask.setOff(offset);
1096 template<
typename T, Index Log2Dim>
1100 mValueMask.set(this->coordToOffset(xyz), on);
1104 template<
typename T, Index Log2Dim>
1111 template<
typename T, Index Log2Dim>
1115 assert(offset<SIZE); mBuffer[offset] = val;
1122 template<
typename T, Index Log2Dim>
1126 for (
Int32 x = bbox.min().x(); x <= bbox.max().x(); ++x) {
1127 const Index offsetX = (x & (DIM-1u)) << 2*Log2Dim;
1128 for (
Int32 y = bbox.min().y(); y <= bbox.max().y(); ++y) {
1129 const Index offsetXY = offsetX + ((y & (DIM-1u)) << Log2Dim);
1130 for (
Int32 z = bbox.min().z(); z <= bbox.max().z(); ++z) {
1131 const Index offset = offsetXY + (z & (DIM-1u));
1132 mBuffer[offset] = value;
1133 mValueMask.set(offset, active);
1139 template<
typename T, Index Log2Dim>
1143 mBuffer.fill(value);
1146 template<
typename T, Index Log2Dim>
1150 mBuffer.fill(value);
1151 mValueMask.set(active);
1158 template<
typename T, Index Log2Dim>
1159 template<
typename DenseT>
1163 typedef typename DenseT::ValueType DenseValueType;
1165 const size_t xStride = dense.xStride(), yStride = dense.yStride(), zStride = dense.zStride();
1166 const Coord&
min = dense.bbox().min();
1167 DenseValueType* t0 = dense.data() + zStride * (bbox.min()[2] - min[2]);
1168 const T* s0 = &mBuffer[bbox.min()[2] & (DIM-1u)];
1169 for (
Int32 x = bbox.min()[0], ex = bbox.max()[0] + 1; x < ex; ++x) {
1170 DenseValueType* t1 = t0 + xStride * (x - min[0]);
1171 const T* s1 = s0 + ((x & (DIM-1u)) << 2*Log2Dim);
1172 for (
Int32 y = bbox.min()[1], ey = bbox.max()[1] + 1; y < ey; ++y) {
1173 DenseValueType* t2 = t1 + yStride * (y - min[1]);
1174 const T* s2 = s1 + ((y & (DIM-1u)) << Log2Dim);
1175 for (
Int32 z = bbox.min()[2], ez = bbox.max()[2] + 1; z < ez; ++z, t2 += zStride) {
1176 *t2 = DenseValueType(*s2++);
1183 template<
typename T, Index Log2Dim>
1184 template<
typename DenseT>
1189 typedef typename DenseT::ValueType DenseValueType;
1191 const size_t xStride = dense.xStride(), yStride = dense.yStride(), zStride = dense.zStride();
1192 const Coord&
min = dense.bbox().min();
1194 const DenseValueType* s0 = dense.data() + zStride * (bbox.min()[2] - min[2]);
1195 const Int32 n0 = bbox.min()[2] & (DIM-1u);
1196 for (
Int32 x = bbox.min()[0], ex = bbox.max()[0]+1; x < ex; ++x) {
1197 const DenseValueType* s1 = s0 + xStride * (x - min[0]);
1198 const Int32 n1 = n0 + ((x & (DIM-1u)) << 2*LOG2DIM);
1199 for (
Int32 y = bbox.min()[1], ey = bbox.max()[1]+1; y < ey; ++y) {
1200 const DenseValueType* s2 = s1 + yStride * (y - min[1]);
1201 Int32 n2 = n1 + ((y & (DIM-1u)) << LOG2DIM);
1202 for (
Int32 z = bbox.min()[2], ez = bbox.max()[2]+1; z < ez; ++z, ++n2, s2 += zStride) {
1204 mValueMask.setOff(n2);
1205 mBuffer[n2] = background;
1207 mValueMask.setOn(n2);
1219 template<
typename T, Index Log2Dim>
1223 mValueMask.load(is);
1227 template<
typename T, Index Log2Dim>
1231 mValueMask.save(os);
1238 template<
typename T, Index Log2Dim>
1243 mValueMask.load(is);
1245 int8_t numBuffers = 1;
1248 is.read(reinterpret_cast<char*>(&mOrigin),
sizeof(Coord::ValueType) * 3);
1251 is.read(reinterpret_cast<char*>(&numBuffers),
sizeof(int8_t));
1256 if (numBuffers > 1) {
1261 for (
int i = 1; i < numBuffers; ++i) {
1265 io::readData<T>(is, temp.mData, SIZE, zipped);
1272 template<
typename T, Index Log2Dim>
1277 mValueMask.save(os);
1287 template<
typename T, Index Log2Dim>
1291 return mOrigin == other.
mOrigin &&
1297 template<
typename T, Index Log2Dim>
1301 return mBuffer.memUsage() +
sizeof(mOrigin) + mValueMask.memUsage();
1305 template<
typename T, Index Log2Dim>
1309 CoordBBox this_bbox = this->getNodeBoundingBox();
1310 if (bbox.isInside(this_bbox))
return;
1314 for(; iter; ++iter) this_bbox.expand(this->offsetToLocalCoord(iter.pos()));
1315 this_bbox.translate(this->origin());
1317 bbox.expand(this_bbox);
1322 template<
typename T, Index Log2Dim>
1323 template<
typename OtherType, Index OtherLog2Dim>
1328 return (Log2Dim == OtherLog2Dim && mValueMask == other->
getValueMask());
1332 template<
typename T, Index Log2Dim>
1335 bool& state,
const ValueType& tolerance)
const
1337 state = mValueMask.isOn();
1339 if (!(state || mValueMask.isOff()))
return false;
1341 bool allEqual =
true;
1342 const T value = mBuffer[0];
1343 for (
Index i = 1; allEqual && i < SIZE; ++i) {
1347 if (allEqual) constValue = value;
1355 template<
typename T, Index Log2Dim>
1360 this->addTile(this->coordToOffset(xyz), val, active);
1363 template<
typename T, Index Log2Dim>
1367 assert(offset < SIZE);
1368 setValueOnly(offset, val);
1369 setActiveState(offset, active);
1372 template<
typename T, Index Log2Dim>
1373 template<
typename AccessorT>
1376 const ValueType& val,
bool active, AccessorT&)
1378 this->addTile(level, xyz, val, active);
1385 template<
typename T, Index Log2Dim>
1392 template<
typename T, Index Log2Dim>
1397 const Index first = mValueMask.findFirstOn();
1399 bool xInside =
math::isNegative(mBuffer[first]), yInside = xInside, zInside = xInside;
1400 for (
Index x = 0; x != (1 << Log2Dim); ++x) {
1401 const Index x00 = x << (2 * Log2Dim);
1402 if (mValueMask.isOn(x00)) {
1406 for (
Index y = 0; y != (1 << Log2Dim); ++y) {
1407 const Index xy0 = x00 + (y << Log2Dim);
1408 if (mValueMask.isOn(xy0)) {
1412 for (
Index z = 0; z != (1 << Log2Dim); ++z) {
1413 const Index xyz = xy0 + z;
1414 if (mValueMask.isOn(xyz)) {
1417 mBuffer[xyz] = zInside ? insideValue : outsideValue;
1428 template<
typename T, Index Log2Dim>
1435 for (iter = this->mValueMask.beginOff(); iter; ++iter) {
1438 inactiveValue = newBackground;
1446 template<
typename T, Index Log2Dim>
1447 template<MergePolicy Policy>
1454 for (; iter; ++iter) {
1456 if (mValueMask.isOff(n)) {
1457 mBuffer[n] = other.
mBuffer[n];
1458 mValueMask.setOn(n);
1464 template<
typename T, Index Log2Dim>
1465 template<MergePolicy Policy>
1470 this->
template merge<Policy>(other);
1473 template<
typename T, Index Log2Dim>
1474 template<MergePolicy Policy>
1480 if (!tileActive)
return;
1483 const Index n = iter.pos();
1484 mBuffer[n] = tileValue;
1485 mValueMask.setOn(n);
1491 template<
typename T, Index Log2Dim>
1492 template<
typename OtherType>
1499 template<
typename T, Index Log2Dim>
1500 template<
typename OtherType>
1508 template<
typename T, Index Log2Dim>
1509 template<
typename OtherType>
1517 template<
typename T, Index Log2Dim>
1521 for (
Index i = 0; i < SIZE; ++i) {
1522 mBuffer[i] = -mBuffer[i];
1530 template<
typename T, Index Log2Dim>
1531 template<
typename CombineOp>
1536 for (
Index i = 0; i < SIZE; ++i) {
1538 .setAIsActive(mValueMask.isOn(i))
1541 .setResultRef(mBuffer[i]));
1547 template<
typename T, Index Log2Dim>
1548 template<
typename CombineOp>
1553 args.
setBRef(value).setBIsActive(valueIsActive);
1554 for (
Index i = 0; i < SIZE; ++i) {
1556 .setAIsActive(mValueMask.isOn(i))
1557 .setResultRef(mBuffer[i]));
1566 template<
typename T, Index Log2Dim>
1567 template<
typename CombineOp,
typename OtherType>
1570 bool valueIsActive, CombineOp& op)
1573 args.
setBRef(value).setBIsActive(valueIsActive);
1574 for (
Index i = 0; i < SIZE; ++i) {
1577 .setResultRef(mBuffer[i]));
1583 template<
typename T, Index Log2Dim>
1584 template<
typename CombineOp,
typename OtherNodeT>
1587 bool valueIsActive, CombineOp& op)
1590 args.
setARef(value).setAIsActive(valueIsActive);
1591 for (
Index i = 0; i < SIZE; ++i) {
1592 op(args.
setBRef(other.mBuffer[i])
1593 .setBIsActive(other.mValueMask.isOn(i))
1594 .setResultRef(mBuffer[i]));
1600 template<
typename T, Index Log2Dim>
1601 template<
typename CombineOp,
typename OtherNodeT>
1606 for (
Index i = 0; i < SIZE; ++i) {
1607 mValueMask.set(i, b0.
mValueMask.
isOn(i) || b1.mValueMask.isOn(i));
1610 .setBRef(b1.mBuffer[i])
1611 .setBIsActive(b1.mValueMask.isOn(i))
1612 .setResultRef(mBuffer[i]));
1621 template<
typename T, Index Log2Dim>
1622 template<
typename BBoxOp>
1626 if (op.template descent<LEVEL>()) {
1629 op.operator()<LEVEL>(CoordBBox::createCube(i.getCoord(), 1));
1631 op.template operator()<LEVEL>(CoordBBox::createCube(i.getCoord(), 1));
1636 op.operator()<LEVEL>(this->getNodeBoundingBox());
1638 op.template operator()<LEVEL>(this->getNodeBoundingBox());
1644 template<
typename T, Index Log2Dim>
1645 template<
typename VisitorOp>
1649 doVisit<LeafNode, VisitorOp, ChildAllIter>(*
this, op);
1653 template<
typename T, Index Log2Dim>
1654 template<
typename VisitorOp>
1658 doVisit<const LeafNode, VisitorOp, ChildAllCIter>(*
this, op);
1662 template<
typename T, Index Log2Dim>
1663 template<
typename NodeT,
typename VisitorOp,
typename ChildAllIterT>
1667 for (ChildAllIterT iter =
self.beginChildAll(); iter; ++iter) {
1676 template<
typename T, Index Log2Dim>
1677 template<
typename OtherLeafNodeType,
typename VisitorOp>
1682 typename OtherLeafNodeType::ChildAllIter>(*
this, other, op);
1686 template<
typename T, Index Log2Dim>
1687 template<
typename OtherLeafNodeType,
typename VisitorOp>
1692 typename OtherLeafNodeType::ChildAllCIter>(*
this, other, op);
1696 template<
typename T, Index Log2Dim>
1699 typename OtherNodeT,
1701 typename ChildAllIterT,
1702 typename OtherChildAllIterT>
1707 BOOST_STATIC_ASSERT(OtherNodeT::SIZE == NodeT::SIZE);
1708 BOOST_STATIC_ASSERT(OtherNodeT::LEVEL == NodeT::LEVEL);
1710 ChildAllIterT iter =
self.beginChildAll();
1711 OtherChildAllIterT otherIter = other.beginChildAll();
1713 for ( ; iter && otherIter; ++iter, ++otherIter) {
1714 op(iter, otherIter);
1722 template<
typename T, Index Log2Dim>
1723 template<
typename IterT,
typename VisitorOp>
1727 doVisit2<LeafNode, VisitorOp, ChildAllIter, IterT>(
1728 *
this, otherIter, op, otherIsLHS);
1732 template<
typename T, Index Log2Dim>
1733 template<
typename IterT,
typename VisitorOp>
1737 doVisit2<const LeafNode, VisitorOp, ChildAllCIter, IterT>(
1738 *
this, otherIter, op, otherIsLHS);
1742 template<
typename T, Index Log2Dim>
1746 typename ChildAllIterT,
1747 typename OtherChildAllIterT>
1750 VisitorOp& op,
bool otherIsLHS)
1752 if (!otherIter)
return;
1755 for (ChildAllIterT iter =
self.beginChildAll(); iter; ++iter) {
1756 op(otherIter, iter);
1759 for (ChildAllIterT iter =
self.beginChildAll(); iter; ++iter) {
1760 op(iter, otherIter);
1769 template<
typename T, Index Log2Dim>
1770 inline std::ostream&
1771 operator<<(std::ostream& os, const typename LeafNode<T, Log2Dim>::Buffer& buf)
1773 for (
Index32 i = 0, N = buf.size(); i < N; ++i) os << buf.mData[i] <<
", ";
1788 #endif // OPENVDB_TREE_LEAFNODE_HAS_BEEN_INCLUDED
bool resultIsActive() const
Definition: Types.h:314
const ValueType & getFirstValue() const
Return a const reference to the first value in the buffer.
Definition: LeafNode.h:675
ValueT & getItem(Index pos) const
Definition: LeafNode.h:298
OPENVDB_API Hermite min(const Hermite &, const Hermite &)
min and max operations done directly on the compressed data.
ChildOffCIter endChildOff() const
Definition: LeafNode.h:407
ChildIter< MaskOffIterator, LeafNode, ChildOff > ChildOffIter
Definition: LeafNode.h:366
DenseIteratorBase< MaskDenseIterator, DenseIter, NodeT, void, ValueT > BaseT
Definition: LeafNode.h:334
ChildIter(const MaskIterT &iter, NodeT *parent)
Definition: LeafNode.h:326
ChildAllIter endChildAll()
Definition: LeafNode.h:411
ValueOffCIter cendValueOff() const
Definition: LeafNode.h:384
ValueOffIter beginValueOff()
Definition: LeafNode.h:376
Index64 offVoxelCount() const
Return the number of voxels marked Off.
Definition: LeafNode.h:226
static Index log2dim()
Return log2 of the dimension of this LeafNode, e.g. 3 if dimensions are 8^3.
Definition: LeafNode.h:205
ChildOnIter beginChildOn()
Definition: LeafNode.h:395
void combine(const LeafNode &other, CombineOp &op)
Definition: LeafNode.h:1533
void combine2(const LeafNode &other, const OtherType &, bool valueIsActive, CombineOp &)
Definition: LeafNode.h:1569
void setValueOff(const Coord &xyz)
Mark the voxel at the given coordinates as inactive but don't change its value.
Definition: LeafNode.h:476
bool isValueOnAndCache(const Coord &xyz, AccessorT &) const
Return true if the voxel at the given coordinates is active.
Definition: LeafNode.h:593
Base class for sparse iterators over internal and leaf nodes.
Definition: Iterator.h:148
void writeCompressedValues(std::ostream &os, ValueT *srcBuf, Index srcCount, const MaskT &valueMask, const MaskT &childMask, bool toHalf)
Definition: Compression.h:381
void modifyValue(const ModifyOp &op) const
Definition: LeafNode.h:317
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:1387
ValueIter< MaskDenseIterator, const LeafNode, const ValueType, ValueAll > ValueAllCIter
Definition: LeafNode.h:363
ChildOffIter beginChildOff()
Definition: LeafNode.h:398
LeafNode< ValueType, Log2Dim > LeafNodeType
Definition: LeafNode.h:69
Definition: LeafNode.h:283
Definition: LeafNode.h:331
bool isChildMaskOn(Index) const
Definition: LeafNode.h:875
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:418
ChildIter< MaskOnIterator, LeafNode, ChildOn > ChildOnIter
Definition: LeafNode.h:364
Definition: LeafNode.h:50
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:468
Index64 onVoxelCount() const
Return the number of voxels marked On.
Definition: LeafNode.h:224
void prune(const ValueType &=zeroVal< ValueType >())
This function exists only to enable template instantiation.
Definition: LeafNode.h:777
bool isValueMaskOn(Index n) const
Definition: LeafNode.h:868
Index64 offLeafVoxelCount() const
Definition: LeafNode.h:228
Coord offsetToGlobalCoord(Index n) const
Return the global coordinates for a linear table offset.
Definition: LeafNode.h:1037
bool operator!=(const Buffer &other) const
Definition: LeafNode.h:144
DenseIter(const MaskDenseIterator &iter, NodeT *parent)
Definition: LeafNode.h:338
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:1502
void visit2Node(OtherLeafNodeType &other, VisitorOp &)
Definition: LeafNode.h:1679
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:1494
ChildOnCIter cbeginChildOn() const
Definition: LeafNode.h:393
ValueConverter::Type is the type of a LeafNode having the same dimensions as this node but a diffe...
Definition: LeafNode.h:85
CombineArgs & setARef(const AValueType &a)
Redirect the A value to a new external source.
Definition: Types.h:303
util::NodeMask< Log2Dim > NodeMaskType
Definition: LeafNode.h:71
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:1325
ChildIter()
Definition: LeafNode.h:325
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:1161
void voxelizeActiveTiles()
Definition: LeafNode.h:699
ChildIter< MaskOffIterator, const LeafNode, ChildOff > ChildOffCIter
Definition: LeafNode.h:367
Index32 Index
Definition: Types.h:57
void swap(Buffer &other)
Replace the values in this Buffer with the values in the other Buffer.
Definition: LeafNode.h:146
void fill(const ValueType &val)
Populates the buffer with a constant value.
Definition: LeafNode.h:111
void negate()
Definition: LeafNode.h:1519
void setOrigin(const Coord &origin)
Set the grid index coordinates of this node's local origin.
Definition: LeafNode.h:249
bool operator==(const LeafNode &other) const
Check for buffer, state and origin equivalence.
Definition: LeafNode.h:1289
ValueOnCIter cbeginValueOn() const
Definition: LeafNode.h:371
ValueIter< MaskDenseIterator, LeafNode, const ValueType, ValueAll > ValueAllIter
Definition: LeafNode.h:362
ValueAllIter beginValueAll()
Definition: LeafNode.h:379
static const Index SIZE
Definition: LeafNode.h:79
static void doVisit2Node(NodeT &self, OtherNodeT &other, VisitorOp &)
Definition: LeafNode.h:1704
bool operator==(const Vec3< T0 > &v0, const Vec3< T1 > &v1)
Equality operator, does exact floating point comparisons.
Definition: Vec3.h:446
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:494
Index32 pos() const
Definition: NodeMasks.h:176
ChildAllCIter endChildAll() const
Definition: LeafNode.h:410
bool isValueOn(Index offset) const
Return true if the voxel at the given offset is active.
Definition: LeafNode.h:535
static Coord offsetToLocalCoord(Index n)
Return the local coordinates for a linear table offset, where offset 0 has coordinates (0...
Definition: LeafNode.h:1023
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:616
void addLeaf(LeafNode *)
This function exists only to enable template instantiation.
Definition: LeafNode.h:779
DenseIter()
Definition: LeafNode.h:337
Definition: NodeMasks.h:188
const ValueType & getValue(const Coord &xyz) const
Return the value of the voxel at the given coordinates.
Definition: LeafNode.h:1048
ChildOnIter endChildOn()
Definition: LeafNode.h:405
void addLeafAndCache(LeafNode *, AccessorT &)
This function exists only to enable template instantiation.
Definition: LeafNode.h:781
static Index coordToOffset(const Coord &xyz)
Return the linear table offset of the given global or local coordinates.
Definition: LeafNode.h:1013
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:632
ValueIter()
Definition: LeafNode.h:295
ValueOnIter beginValueOn()
Definition: LeafNode.h:373
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:504
void readBuffers(std::istream &is, bool fromHalf=false)
Read buffers from a stream.
Definition: LeafNode.h:1240
void setValue(Index i, const ValueType &val)
Set the i'th value of the Buffer to the specified value.
Definition: LeafNode.h:122
ValueOnCIter endValueOn() const
Definition: LeafNode.h:382
void setValueOn(const Coord &xyz)
Mark the voxel at the given coordinates as active but don't change its value.
Definition: LeafNode.h:486
ValueAllCIter endValueAll() const
Definition: LeafNode.h:388
ValueOnIter endValueOn()
Definition: LeafNode.h:383
const NodeT * probeConstNode(const Coord &) const
This function exists only to enable template instantiation.
Definition: LeafNode.h:787
Buffer()
Empty default constructor.
Definition: LeafNode.h:103
ValueOnCIter beginValueOn() const
Definition: LeafNode.h:372
bool operator!=(const LeafNode &other) const
Definition: LeafNode.h:275
static Index64 onTileCount()
Definition: LeafNode.h:229
static Index getChildDim()
Return the dimension of child nodes of this LeafNode, which is one for voxels.
Definition: LeafNode.h:217
Bit mask for the internal and leaf nodes of VDB. This is a 64-bit implementation. ...
Definition: NodeMasks.h:287
static Index64 offTileCount()
Definition: LeafNode.h:230
Buffer(const ValueType &val)
Constructs a buffer populated with the specified value.
Definition: LeafNode.h:105
void setValuesOn()
Mark all voxels as active but don't change their values.
Definition: LeafNode.h:528
Definition: NodeMasks.h:219
ValueT & getValue() const
Definition: LeafNode.h:299
ChildOnCIter cendChildOn() const
Definition: LeafNode.h:403
This struct collects both input and output arguments to "grid combiner" functors used with the tree::...
Definition: Types.h:265
ValueOffCIter cbeginValueOff() const
Definition: LeafNode.h:374
ChildOffCIter cbeginChildOff() const
Definition: LeafNode.h:396
ChildOffIter endChildOff()
Definition: LeafNode.h:408
LeafNode * probeLeafAndCache(const Coord &, AccessorT &)
Return a pointer to this node.
Definition: LeafNode.h:810
void setValueOn(Index offset)
Mark the voxel at the given offset as active but don't change its value.
Definition: LeafNode.h:488
const ValueType & getValue(Index i) const
Return a const reference to the i'th element of the Buffer.
Definition: LeafNode.h:118
void unsetItem(Index pos, const ValueT &value) const
Definition: LeafNode.h:351
Definition: version.h:106
uint64_t Index64
Definition: Types.h:56
Stores the actual values in the LeafNode. Its dimension it fixed to 2^(3*Log2Dim) ...
Definition: LeafNode.h:99
#define OPENVDB_VERSION_NAME
Definition: version.h:45
ValueIter< MaskOffIterator, const LeafNode, const ValueType, ValueOff > ValueOffCIter
Definition: LeafNode.h:361
void setValue(const ValueT &value) const
Definition: LeafNode.h:307
void visitActiveBBox(BBoxOp &) const
Calls the templated functor BBoxOp with bounding box information. An additional level argument is pro...
Definition: LeafNode.h:1624
void visit(VisitorOp &)
Definition: LeafNode.h:1647
~Buffer()
Destructor.
Definition: LeafNode.h:109
static Index memUsage()
Return the memory-footprint of this Buffer in units of bytes.
Definition: LeafNode.h:153
static void doVisit(NodeT &, VisitorOp &)
Definition: LeafNode.h:1665
ValueIter< MaskOnIterator, LeafNode, const ValueType, ValueOn > ValueOnIter
Definition: LeafNode.h:358
NodeMaskType & getValueMask()
Definition: LeafNode.h:873
ChildAllCIter cbeginChildAll() const
Definition: LeafNode.h:399
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:1124
void modifyValueAndActiveStateAndCache(const Coord &xyz, const ModifyOp &op, AccessorT &)
Definition: LeafNode.h:624
LeafNode * probeLeaf(const Coord &)
Return a pointer to this node.
Definition: LeafNode.h:808
bool isEmpty() const
Return true if this node has no active voxels.
Definition: LeafNode.h:232
bool isExactlyEqual(const T0 &a, const T1 &b)
Return true if a is exactly equal to b.
Definition: Math.h:351
Index64 memUsage() const
Return the memory in bytes occupied by this node.
Definition: LeafNode.h:1299
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:1098
Definition: Compression.h:166
bool isValueMaskOff() const
Definition: LeafNode.h:871
Definition: LeafNode.h:284
void addTileAndCache(Index, const Coord &, const ValueType &, bool, AccessorT &)
Definition: LeafNode.h:1375
void modifyItem(Index n, const ModifyOp &op) const
Definition: LeafNode.h:314
Base class for iterators over internal and leaf nodes.
Definition: Iterator.h:58
ChildOnCIter endChildOn() const
Definition: LeafNode.h:404
static Index getLevel()
Return the level of this node, which by definition is zero for LeafNodes.
Definition: LeafNode.h:213
Definition: LeafNode.h:287
NodeMaskType::OffIterator MaskOffIterator
Definition: LeafNode.h:279
ValueIter< MaskOnIterator, const LeafNode, const ValueType, ValueOn > ValueOnCIter
Definition: LeafNode.h:359
bool isValueMaskOn() const
Definition: LeafNode.h:869
bool isOn(Index32 n) const
Return true if the nth bit is on.
Definition: NodeMasks.h:438
NodeT * probeNodeAndCache(const Coord &, AccessorT &)
Return a pointer to this node.
Definition: LeafNode.h:801
ValueOffCIter beginValueOff() const
Definition: LeafNode.h:375
Base class for dense iterators over internal and leaf nodes.
Definition: Iterator.h:211
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:496
ChildAllCIter beginChildAll() const
Definition: LeafNode.h:400
bool isChildMaskOff(Index) const
Definition: LeafNode.h:876
bool isConstant(ValueType &constValue, bool &state, const ValueType &tolerance=zeroVal< ValueType >()) const
Definition: LeafNode.h:1334
NodeT * probeNode(const Coord &)
This function exists only to enable template instantiation.
Definition: LeafNode.h:785
bool isDense() const
Return true if this node contains only active voxels.
Definition: LeafNode.h:234
bool isValueMaskOff(Index n) const
Definition: LeafNode.h:870
void addTile(Index level, const Coord &, const ValueType &, bool)
Definition: LeafNode.h:1357
ChildOffCIter cendChildOff() const
Definition: LeafNode.h:406
CombineArgs & setBRef(const BValueType &b)
Redirect the B value to a new external source.
Definition: Types.h:305
void readTopology(std::istream &is, bool fromHalf=false)
Read in just the topology.
Definition: LeafNode.h:1221
static void doVisit2(NodeT &self, OtherChildAllIterT &, VisitorOp &, bool otherIsLHS)
Definition: LeafNode.h:1749
NodeT * stealNode(const Coord &, const ValueType &, bool)
This function exists only to enable template instantiation.
Definition: LeafNode.h:783
Definition: Compression.h:70
void setValueMask(const NodeMaskType &mask)
Definition: LeafNode.h:874
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:490
uint32_t Index32
Definition: Types.h:55
const NodeMaskType & getValueMask() const
Definition: LeafNode.h:872
static Index dim()
Return the number of voxels in each coordinate dimension.
Definition: LeafNode.h:207
void getOrigin(Coord &origin) const
Return the grid index coordinates of this node's local origin.
Definition: LeafNode.h:253
int32_t Int32
Definition: Types.h:59
Definition: LeafNode.h:284
OPENVDB_IMPORT uint32_t getFormatVersion(std::istream &)
Return the file format version number associated with the given input stream.
static void getNodeLog2Dims(std::vector< Index > &dims)
Append the Log2Dim of this LeafNode to the specified vector.
Definition: LeafNode.h:215
bool probeValue(const Coord &xyz, ValueType &val) const
Return true if the voxel at the given coordinates is active.
Definition: LeafNode.h:1064
Buffer(const Buffer &other)
Copy constructor.
Definition: LeafNode.h:107
bool getItem(Index pos, void *&child, NonConstValueT &value) const
Definition: LeafNode.h:340
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:1186
Leaf nodes have no children, so their child iterators have no get/set accessors.
Definition: LeafNode.h:322
Index64 onLeafVoxelCount() const
Definition: LeafNode.h:227
Buffer & buffer()
Definition: LeafNode.h:420
Buffer & operator=(const Buffer &other)
Assigns the values in the other Buffer to this Buffer.
Definition: LeafNode.h:124
static Index size()
Return the total number of voxels represented by this LeafNode.
Definition: LeafNode.h:209
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:512
void writeBuffers(std::ostream &os, bool toHalf=false) const
Write buffers to a stream.
Definition: LeafNode.h:1274
DenseIter< const LeafNode, const ValueType, ChildAll > ChildAllCIter
Definition: LeafNode.h:369
ChildOffCIter beginChildOff() const
Definition: LeafNode.h:397
Definition: LeafNode.h:57
const NodeT * probeConstNodeAndCache(const Coord &, AccessorT &) const
Return a const pointer to this node.
Definition: LeafNode.h:821
SameConfiguration::value is true if and only if OtherNodeType is the type of a LeafNod...
Definition: LeafNode.h:92
NodeMaskType::DenseIterator MaskDenseIterator
Definition: LeafNode.h:280
ValueOnCIter cendValueOn() const
Definition: LeafNode.h:381
static void evalNodeOrigin(Coord &xyz)
Compute the origin of the leaf node that contains the voxel with the given coordinates.
Definition: LeafNode.h:884
void visit2(IterT &otherIter, VisitorOp &, bool otherIsLHS=false)
Definition: LeafNode.h:1725
std::string str() const
Return a string representation of this node.
Definition: LeafNode.h:1000
void setValuesOff()
Mark all voxels as inactive but don't change their values.
Definition: LeafNode.h:530
const LeafNode * probeConstLeafAndCache(const Coord &, AccessorT &) const
Return a const pointer to this node.
Definition: LeafNode.h:816
ValueIter(const MaskIterT &iter, NodeT *parent)
Definition: LeafNode.h:296
ChildIter< MaskOnIterator, const LeafNode, ChildOn > ChildOnCIter
Definition: LeafNode.h:365
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:1511
const LeafNode * probeLeafAndCache(const Coord &, AccessorT &) const
Return a const pointer to this node.
Definition: LeafNode.h:818
void resetBackground(const ValueType &oldBackground, const ValueType &newBackground)
Replace inactive occurrences of oldBackground with newBackground, and inactive occurrences of -oldBac...
Definition: LeafNode.h:1430
void getOrigin(Int32 &x, Int32 &y, Int32 &z) const
Return the grid index coordinates of this node's local origin.
Definition: LeafNode.h:254
void modifyValueAndActiveState(const Coord &xyz, const ModifyOp &op)
Apply a functor to the voxel at the given coordinates.
Definition: LeafNode.h:519
LeafNode()
Default constructor.
Definition: LeafNode.h:919
bool isApproxEqual(const Hermite &lhs, const Hermite &rhs)
Definition: Hermite.h:470
void setValueMaskOn(Index n)
Definition: LeafNode.h:880
Definition: LeafNode.h:283
T ValueType
Definition: LeafNode.h:68
Coord mOrigin
Global grid index coordinates (x,y,z) of the local origin of this node.
Definition: LeafNode.h:864
bool isInactive() const
Return true if all of this node's values are inactive.
Definition: LeafNode.h:836
void setValueMaskOff(Index n)
Definition: LeafNode.h:881
ChildAllIter beginChildAll()
Definition: LeafNode.h:401
ValueOffIter endValueOff()
Definition: LeafNode.h:386
ValueAllCIter beginValueAll() const
Definition: LeafNode.h:378
ValueAllCIter cbeginValueAll() const
Definition: LeafNode.h:377
static Index getValueLevel(const Coord &)
Return the level (i.e., 0) at which leaf node values reside.
Definition: LeafNode.h:463
T negative(const T &val)
Return the unary negation of the given value.
Definition: Math.h:107
void evalActiveBoundingBox(CoordBBox &bbox, bool visitVoxels=true) const
Definition: LeafNode.h:1307
ChildOnCIter beginChildOn() const
Definition: LeafNode.h:394
Definition: LeafNode.h:283
const ValueType & operator[](Index i) const
Return a const reference to the i'th element of the Buffer.
Definition: LeafNode.h:120
void setItem(Index pos, const ValueT &value) const
Definition: LeafNode.h:302
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:607
boost::shared_ptr< LeafNode > Ptr
Definition: LeafNode.h:70
Definition: NodeMasks.h:250
const LeafNode * probeLeaf(const Coord &) const
Return a const pointer to this node.
Definition: LeafNode.h:819
BaseT::NonConstValueType NonConstValueT
Definition: LeafNode.h:335
void pruneInactive(const ValueType &)
This function exists only to enable template instantiation.
Definition: LeafNode.h:778
static Index32 nonLeafCount()
Return the non-leaf count for this node, which is zero.
Definition: LeafNode.h:221
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:598
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h:67
ValueAllIter endValueAll()
Definition: LeafNode.h:389
bool isNegative(const Type &x)
Return true if x is less than zero.
Definition: Math.h:304
ChildAllCIter cendChildAll() const
Definition: LeafNode.h:409
const ValueType & getValueAndCache(const Coord &xyz, AccessorT &) const
Return the value of the voxel at the given coordinates.
Definition: LeafNode.h:585
NodeMaskType mValueMask
Bitmask that determines which voxels are active.
Definition: LeafNode.h:862
void writeTopology(std::ostream &os, bool toHalf=false) const
Write out just the topology.
Definition: LeafNode.h:1229
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:1106
void setValueOff(Index offset)
Mark the voxel at the given offset as inactive but don't change its value.
Definition: LeafNode.h:478
void merge(const LeafNode &)
Definition: LeafNode.h:1449
ValueAllCIter cendValueAll() const
Definition: LeafNode.h:387
static bool hasActiveTiles()
Return false since leaf nodes never contain tiles.
Definition: LeafNode.h:538
ValueOffCIter endValueOff() const
Definition: LeafNode.h:385
static Index numValues()
Return the total number of voxels represented by this LeafNode.
Definition: LeafNode.h:211
bool operator==(const Buffer &other) const
Definition: LeafNode.h:134
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:659
~LeafNode()
Destructor.
Definition: LeafNode.h:993
void setValueMask(Index n, bool on)
Definition: LeafNode.h:879
const Buffer & buffer() const
Definition: LeafNode.h:419
Templated block class to hold specific data types and a fixed number of values determined by Log2Dim...
Definition: LeafNode.h:65
NodeMaskType::OnIterator MaskOnIterator
Definition: LeafNode.h:278
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.
SparseIteratorBase< MaskIterT, ValueIter, NodeT, ValueT > BaseT
Definition: LeafNode.h:293
bool isChildMaskOff() const
Definition: LeafNode.h:877
CoordBBox getNodeBoundingBox() const
Return the bounding box of this node, i.e., the full index space spanned by this leaf node...
Definition: LeafNode.h:246
static Index size()
Return the number of values represented in this Buffer.
Definition: LeafNode.h:155
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:641
static Index getValueLevelAndCache(const Coord &, AccessorT &)
Return the LEVEL (=0) at which leaf node values reside.
Definition: LeafNode.h:670
LeafNode< OtherValueType, Log2Dim > Type
Definition: LeafNode.h:86
static Index32 leafCount()
Return the leaf count for this node, which is one.
Definition: LeafNode.h:219
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:650
bool isValueOn(const Coord &xyz) const
Return true if the voxel at the given coordinates is active.
Definition: LeafNode.h:533
ValueIter< MaskOffIterator, LeafNode, const ValueType, ValueOff > ValueOffIter
Definition: LeafNode.h:360
ValueType ValueType
Definition: Iterator.h:151
DenseIter< LeafNode, ValueType, ChildAll > ChildAllIter
Definition: LeafNode.h:368
void readCompressedValues(std::istream &is, ValueT *destBuf, Index destCount, const MaskT &valueMask, bool fromHalf)
Definition: Compression.h:277
LeafNode * touchLeafAndCache(const Coord &, AccessorT &)
Return a pointer to this node.
Definition: LeafNode.h:799
boost::remove_const< UnsetItemT >::type NonConstValueType
Definition: Iterator.h:217
Buffer mBuffer
Buffer containing the actual data values.
Definition: LeafNode.h:860
const ValueType & getLastValue() const
Return a const reference to the last value in the buffer.
Definition: LeafNode.h:677