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)
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);
1120 template<
typename T, Index Log2Dim>
1121 template<
typename DenseT>
1125 typedef typename DenseT::ValueType DenseValueType;
1127 const size_t xStride = dense.xStride(), yStride = dense.yStride();
1128 const Coord&
min = dense.bbox().min();
1129 DenseValueType* t0 = dense.data() + bbox.min()[2]-min[2];
1130 const T* s0 = &mBuffer[bbox.min()[2]&DIM-1u];
1131 for (
Int32 x = bbox.min()[0], ex=bbox.max()[0]+1; x<ex; ++x) {
1132 DenseValueType* t1 = t0 + xStride*(x-min[0]);
1133 const T* s1 = s0 + ((x&DIM-1u)<<2*Log2Dim);
1134 for (
Int32 y = bbox.min()[1], ey=bbox.max()[1]+1; y<ey; ++y) {
1135 DenseValueType* t2 = t1 + yStride*(y-min[1]);
1136 const T* s2 = s1 + ((y&DIM-1u)<<Log2Dim);
1137 for (
Int32 z = bbox.min()[2], ez=bbox.max()[2]+1; z<ez ; ++z) {
1138 *t2++ = DenseValueType(*s2++);
1144 template<
typename T, Index Log2Dim>
1145 template<
typename DenseT>
1150 typedef typename DenseT::ValueType DenseValueType;
1152 const size_t xStride = dense.xStride(), yStride = dense.yStride();
1153 const Coord&
min = dense.bbox().min();
1155 const DenseValueType* s0 = dense.data() + bbox.min()[2]-min[2];
1156 const Int32 n0 = bbox.min()[2]&DIM-1u;
1157 for (
Int32 x = bbox.min()[0], ex=bbox.max()[0]+1; x<ex; ++x) {
1158 const DenseValueType* s1 = s0 + xStride*(x-min[0]);
1159 const Int32 n1 = n0 + ((x&DIM-1u)<<2*LOG2DIM);
1160 for (
Int32 y = bbox.min()[1], ey=bbox.max()[1]+1; y<ey; ++y) {
1161 const DenseValueType* s2 = s1 + yStride*(y-min[1]);
1162 Int32 n2 = n1 + ((y&DIM-1u)<<LOG2DIM) ;
1163 for (
Int32 z = bbox.min()[2], ez=bbox.max()[2]+1; z<ez ; ++z, ++n2, ++s2) {
1165 mValueMask.setOff(n2);
1166 mBuffer[n2] = background;
1168 mValueMask.setOn(n2);
1179 template<
typename T, Index Log2Dim>
1183 mValueMask.load(is);
1187 template<
typename T, Index Log2Dim>
1191 mValueMask.save(os);
1198 template<
typename T, Index Log2Dim>
1203 mValueMask.load(is);
1205 int8_t numBuffers = 1;
1208 is.read(reinterpret_cast<char*>(&mOrigin),
sizeof(Coord::ValueType) * 3);
1211 is.read(reinterpret_cast<char*>(&numBuffers),
sizeof(int8_t));
1216 if (numBuffers > 1) {
1221 for (
int i = 1; i < numBuffers; ++i) {
1225 io::readData<T>(is, temp.mData, SIZE, zipped);
1232 template<
typename T, Index Log2Dim>
1237 mValueMask.save(os);
1247 template<
typename T, Index Log2Dim>
1251 return mOrigin == other.
mOrigin &&
1257 template<
typename T, Index Log2Dim>
1261 return mBuffer.memUsage() +
sizeof(mOrigin) + mValueMask.memUsage();
1265 template<
typename T, Index Log2Dim>
1269 CoordBBox this_bbox = this->getNodeBoundingBox();
1270 if (bbox.isInside(this_bbox))
return;
1273 for(; iter; ++iter) this_bbox.expand(this->offsetToLocalCoord(iter.pos()));
1274 this_bbox.translate(this->origin());
1275 bbox.expand(this_bbox);
1279 template<
typename T, Index Log2Dim>
1283 CoordBBox this_bbox = this->getNodeBoundingBox();
1284 if (bbox.isInside(this_bbox))
return;
1288 for(; iter; ++iter) this_bbox.expand(this->offsetToLocalCoord(iter.pos()));
1289 this_bbox.translate(this->origin());
1291 bbox.expand(this_bbox);
1296 template<
typename T, Index Log2Dim>
1297 template<
typename OtherType, Index OtherLog2Dim>
1302 return (Log2Dim == OtherLog2Dim && mValueMask == other->
getValueMask());
1306 template<
typename T, Index Log2Dim>
1309 bool& state,
const ValueType& tolerance)
const
1311 state = mValueMask.isOn();
1313 if (!(state || mValueMask.isOff()))
return false;
1315 bool allEqual =
true;
1316 const T value = mBuffer[0];
1317 for (
Index i = 1; allEqual && i < SIZE; ++i) {
1321 if (allEqual) constValue = value;
1329 template<
typename T, Index Log2Dim>
1334 this->addTile(this->coordToOffset(xyz), val, active);
1337 template<
typename T, Index Log2Dim>
1341 assert(offset < SIZE);
1342 setValueOnly(offset, val);
1343 setActiveState(offset, active);
1346 template<
typename T, Index Log2Dim>
1347 template<
typename AccessorT>
1350 const ValueType& val,
bool active, AccessorT&)
1352 this->addTile(level, xyz, val, active);
1359 template<
typename T, Index Log2Dim>
1366 template<
typename T, Index Log2Dim>
1371 const Index first = mValueMask.findFirstOn();
1373 bool xInside =
math::isNegative(mBuffer[first]), yInside = xInside, zInside = xInside;
1374 for (
Index x = 0; x != (1 << Log2Dim); ++x) {
1375 const Index x00 = x << (2 * Log2Dim);
1376 if (mValueMask.isOn(x00)) {
1380 for (
Index y = 0; y != (1 << Log2Dim); ++y) {
1381 const Index xy0 = x00 + (y << Log2Dim);
1382 if (mValueMask.isOn(xy0)) {
1386 for (
Index z = 0; z != (1 << Log2Dim); ++z) {
1387 const Index xyz = xy0 + z;
1388 if (mValueMask.isOn(xyz)) {
1391 mBuffer[xyz] = zInside ? insideValue : outsideValue;
1402 template<
typename T, Index Log2Dim>
1409 for (iter = this->mValueMask.beginOff(); iter; ++iter) {
1412 inactiveValue = newBackground;
1420 template<
typename T, Index Log2Dim>
1421 template<MergePolicy Policy>
1428 for (; iter; ++iter) {
1430 if (mValueMask.isOff(n)) {
1431 mBuffer[n] = other.
mBuffer[n];
1432 mValueMask.setOn(n);
1438 template<
typename T, Index Log2Dim>
1439 template<MergePolicy Policy>
1444 this->
template merge<Policy>(other);
1447 template<
typename T, Index Log2Dim>
1448 template<MergePolicy Policy>
1454 if (!tileActive)
return;
1457 const Index n = iter.pos();
1458 mBuffer[n] = tileValue;
1459 mValueMask.setOn(n);
1465 template<
typename T, Index Log2Dim>
1466 template<
typename OtherType>
1473 template<
typename T, Index Log2Dim>
1474 template<
typename OtherType>
1482 template<
typename T, Index Log2Dim>
1483 template<
typename OtherType>
1491 template<
typename T, Index Log2Dim>
1495 for (
Index i = 0; i < SIZE; ++i) {
1496 mBuffer[i] = -mBuffer[i];
1504 template<
typename T, Index Log2Dim>
1505 template<
typename CombineOp>
1510 for (
Index i = 0; i < SIZE; ++i) {
1512 .setAIsActive(mValueMask.isOn(i))
1515 .setResultRef(mBuffer[i]));
1521 template<
typename T, Index Log2Dim>
1522 template<
typename CombineOp>
1527 args.
setBRef(value).setBIsActive(valueIsActive);
1528 for (
Index i = 0; i < SIZE; ++i) {
1530 .setAIsActive(mValueMask.isOn(i))
1531 .setResultRef(mBuffer[i]));
1540 template<
typename T, Index Log2Dim>
1541 template<
typename CombineOp>
1544 bool valueIsActive, CombineOp& op)
1547 args.
setBRef(value).setBIsActive(valueIsActive);
1548 for (
Index i = 0; i < SIZE; ++i) {
1551 .setResultRef(mBuffer[i]));
1557 template<
typename T, Index Log2Dim>
1558 template<
typename CombineOp>
1561 bool valueIsActive, CombineOp& op)
1564 args.
setARef(value).setAIsActive(valueIsActive);
1565 for (
Index i = 0; i < SIZE; ++i) {
1568 .setResultRef(mBuffer[i]));
1574 template<
typename T, Index Log2Dim>
1575 template<
typename CombineOp>
1580 for (
Index i = 0; i < SIZE; ++i) {
1586 .setResultRef(mBuffer[i]));
1595 template<
typename T, Index Log2Dim>
1596 template<
typename BBoxOp>
1600 if (op.template descent<LEVEL>()) {
1603 op.operator()<LEVEL>(CoordBBox::createCube(i.getCoord(), 1));
1605 op.template operator()<LEVEL>(CoordBBox::createCube(i.getCoord(), 1));
1610 op.operator()<LEVEL>(this->getNodeBoundingBox());
1612 op.template operator()<LEVEL>(this->getNodeBoundingBox());
1618 template<
typename T, Index Log2Dim>
1619 template<
typename VisitorOp>
1623 doVisit<LeafNode, VisitorOp, ChildAllIter>(*
this, op);
1627 template<
typename T, Index Log2Dim>
1628 template<
typename VisitorOp>
1632 doVisit<const LeafNode, VisitorOp, ChildAllCIter>(*
this, op);
1636 template<
typename T, Index Log2Dim>
1637 template<
typename NodeT,
typename VisitorOp,
typename ChildAllIterT>
1641 for (ChildAllIterT iter =
self.beginChildAll(); iter; ++iter) {
1650 template<
typename T, Index Log2Dim>
1651 template<
typename OtherLeafNodeType,
typename VisitorOp>
1656 typename OtherLeafNodeType::ChildAllIter>(*
this, other, op);
1660 template<
typename T, Index Log2Dim>
1661 template<
typename OtherLeafNodeType,
typename VisitorOp>
1666 typename OtherLeafNodeType::ChildAllCIter>(*
this, other, op);
1670 template<
typename T, Index Log2Dim>
1673 typename OtherNodeT,
1675 typename ChildAllIterT,
1676 typename OtherChildAllIterT>
1681 BOOST_STATIC_ASSERT(OtherNodeT::SIZE == NodeT::SIZE);
1682 BOOST_STATIC_ASSERT(OtherNodeT::LEVEL == NodeT::LEVEL);
1684 ChildAllIterT iter =
self.beginChildAll();
1685 OtherChildAllIterT otherIter = other.beginChildAll();
1687 for ( ; iter && otherIter; ++iter, ++otherIter) {
1688 op(iter, otherIter);
1696 template<
typename T, Index Log2Dim>
1697 template<
typename IterT,
typename VisitorOp>
1701 doVisit2<LeafNode, VisitorOp, ChildAllIter, IterT>(
1702 *
this, otherIter, op, otherIsLHS);
1706 template<
typename T, Index Log2Dim>
1707 template<
typename IterT,
typename VisitorOp>
1711 doVisit2<const LeafNode, VisitorOp, ChildAllCIter, IterT>(
1712 *
this, otherIter, op, otherIsLHS);
1716 template<
typename T, Index Log2Dim>
1720 typename ChildAllIterT,
1721 typename OtherChildAllIterT>
1724 VisitorOp& op,
bool otherIsLHS)
1726 if (!otherIter)
return;
1729 for (ChildAllIterT iter =
self.beginChildAll(); iter; ++iter) {
1730 op(otherIter, iter);
1733 for (ChildAllIterT iter =
self.beginChildAll(); iter; ++iter) {
1734 op(iter, otherIter);
1743 template<
typename T, Index Log2Dim>
1744 inline std::ostream&
1745 operator<<(std::ostream& os, const typename LeafNode<T, Log2Dim>::Buffer& buf)
1747 for (
Index32 i = 0, N = buf.size(); i < N; ++i) os << buf.mData[i] <<
", ";
1762 #endif // OPENVDB_TREE_LEAFNODE_HAS_BEEN_INCLUDED
DenseIter< LeafNode, ValueType, ChildAll > ChildAllIter
Definition: LeafNode.h:358
Buffer(const ValueType &val)
Constructs a buffer populated with the specified value.
Definition: LeafNode.h:94
LeafNode * touchLeafAndCache(const Coord &, AccessorT &)
Return a pointer to this node.
Definition: LeafNode.h:789
static Index log2dim()
Return log2 of the dimension of this LeafNode, e.g. 3 if dimensions are 8^3.
Definition: LeafNode.h:190
void combine(const LeafNode &other, CombineOp &op)
Definition: LeafNode.h:1507
const ValueType & getFirstValue() const
Return a const reference to the first value in the buffer.
Definition: LeafNode.h:665
Definition: LeafNode.h:277
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
void setValue(Index i, const ValueType &val)
Set the i'th value of the Buffer to the specified value.
Definition: LeafNode.h:111
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
ValueType ValueType
Definition: Iterator.h:151
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
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
void evalActiveBoundingBox(CoordBBox &, bool visitVoxels=true) const
Definition: LeafNode.h:1281
LeafNode< ValueType, Log2Dim > LeafNodeType
Definition: LeafNode.h:66
Buffer mBuffer
Buffer containing the actual data values.
Definition: LeafNode.h:850
ChildOnIter beginChildOn()
Definition: LeafNode.h:385
const ValueType & getValue(Index i) const
Return a const reference to the i'th element of the Buffer.
Definition: LeafNode.h:107
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:1299
int32_t Int32
Definition: Types.h:58
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
Coord offsetToGlobalCoord(Index n) const
Return the global coordinates for a linear table offset.
Definition: LeafNode.h:1001
Definition: LeafNode.h:273
Definition: LeafNode.h:50
ChildOnCIter cbeginChildOn() const
Definition: LeafNode.h:383
bool operator==(const LeafNode &other) const
Check for buffer, state and origin equivalence.
Definition: LeafNode.h:1249
ValueOnCIter cbeginValueOn() const
Definition: LeafNode.h:361
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:1123
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
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
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:1361
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
ValueIter< MaskDenseIterator, const LeafNode, const ValueType, ValueAll > ValueAllCIter
Definition: LeafNode.h:353
ChildOffIter beginChildOff()
Definition: LeafNode.h:388
bool operator==(const Buffer &other) const
Definition: LeafNode.h:123
void visit2Node(OtherLeafNodeType &other, VisitorOp &)
Definition: LeafNode.h:1653
Definition: NodeMasks.h:220
bool getItem(Index pos, void *&child, NonConstValueT &value) const
Definition: LeafNode.h:330
This struct collects both input and output arguments to "grid combiner" functors used with the tree::...
Definition: Types.h:232
uint32_t Index32
Definition: Types.h:54
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
ChildIter< MaskOffIterator, const LeafNode, ChildOff > ChildOffCIter
Definition: LeafNode.h:357
bool isChildMaskOn(Index) const
Definition: LeafNode.h:865
static Index coordToOffset(const Coord &xyz)
Return the linear table offset of the given global or local coordinates.
Definition: LeafNode.h:965
ChildIter< MaskOnIterator, LeafNode, ChildOn > ChildOnIter
Definition: LeafNode.h:354
void combine2(const LeafNode &other, const ValueType &, bool valueIsActive, CombineOp &)
Definition: LeafNode.h:1543
ValueOnIter beginValueOn()
Definition: LeafNode.h:363
static Index size()
Return the number of values represented in this Buffer.
Definition: LeafNode.h:144
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:1476
void modifyValue(const ModifyOp &op) const
Definition: LeafNode.h:307
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 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:1468
util::NodeMask< Log2Dim > NodeMaskType
Definition: LeafNode.h:68
ValueOnIter endValueOn()
Definition: LeafNode.h:373
void addLeafAndCache(LeafNode *, AccessorT &)
This function exists only to enable template instantiation.
Definition: LeafNode.h:771
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
ValueT & getValue() const
Definition: LeafNode.h:289
bool isValueOn(Index offset) const
Return true if the voxel at the given offset is active.
Definition: LeafNode.h:525
void negate()
Definition: LeafNode.h:1493
OnIterator beginOn() const
Definition: NodeMasks.h:332
void addLeaf(LeafNode *)
This function exists only to enable template instantiation.
Definition: LeafNode.h:769
void setOrigin(const Coord &origin)
Set the grid index coordinates of this node's local origin.
Definition: LeafNode.h:235
ValueOnCIter endValueOn() const
Definition: LeafNode.h:372
static Index getChildDim()
Return the dimension of child nodes of this LeafNode, which is one for voxels.
Definition: LeafNode.h:202
ValueAllCIter endValueAll() const
Definition: LeafNode.h:378
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.
ValueIter< MaskDenseIterator, LeafNode, const ValueType, ValueAll > ValueAllIter
Definition: LeafNode.h:352
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:1678
Base class for sparse iterators over internal and leaf nodes.
Definition: Iterator.h:148
ChildAllCIter endChildAll() const
Definition: LeafNode.h:400
ValueOnCIter beginValueOn() const
Definition: LeafNode.h:362
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
ValueT & getItem(Index pos) const
Definition: LeafNode.h:288
void readBuffers(std::istream &is, bool fromHalf=false)
Read buffers from a stream.
Definition: LeafNode.h:1200
void setValue(const ValueT &value) const
Definition: LeafNode.h:297
Buffer & operator=(const Buffer &other)
Assigns the values in the other Buffer to this Buffer.
Definition: LeafNode.h:113
ValueOffCIter cbeginValueOff() const
Definition: LeafNode.h:364
Leaf nodes have no children, so their child iterators have no get/set accessors.
Definition: LeafNode.h:312
void readCompressedValues(std::istream &is, ValueT *destBuf, Index destCount, const MaskT &valueMask, bool fromHalf)
Definition: Compression.h:276
void setValueOn(Index offset)
Mark the voxel at the given offset as active but don't change its value.
Definition: LeafNode.h:478
ChildIter()
Definition: LeafNode.h:315
ChildOnCIter cendChildOn() const
Definition: LeafNode.h:393
bool operator!=(const LeafNode &other) const
Definition: LeafNode.h:265
bool operator==(const Vec3< T0 > &v0, const Vec3< T1 > &v1)
Equality operator, does exact floating point comparisons.
Definition: Vec3.h:430
Stores the actual values in the LeafNode. Its dimension it fixed to 2^(3*Log2Dim) ...
Definition: LeafNode.h:88
Templated block class to hold specific data types and a fixed number of values determined by Log2Dim...
Definition: LeafNode.h:62
T negative(const T &val)
Return the unary negation of the given value.
Definition: Math.h:107
void setValueOn(const Coord &xyz)
Mark the voxel at the given coordinates as active but don't change its value.
Definition: LeafNode.h:476
bool isNegative(const Type &x)
Return true if x is less than zero.
Definition: Math.h:306
OPENVDB_IMPORT uint32_t getFormatVersion(std::istream &)
Return the file format version number associated with the given input stream.
bool operator!=(const Buffer &other) const
Definition: LeafNode.h:133
void setValuesOn()
Mark all voxels as active but don't change their values.
Definition: LeafNode.h:518
LeafNode * probeLeafAndCache(const Coord &, AccessorT &)
Return a pointer to this node.
Definition: LeafNode.h:800
ValueConverter<T>::Type is the type of a LeafNode having the same child hierarchy and dimensions as t...
Definition: LeafNode.h:82
static Index64 onTileCount()
Definition: LeafNode.h:214
bool isOn(Index32 n) const
Return true if the nth bit is on.
Definition: NodeMasks.h:440
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
ValueIter< MaskOffIterator, const LeafNode, const ValueType, ValueOff > ValueOffCIter
Definition: LeafNode.h:351
bool isValueMaskOff() const
Definition: LeafNode.h:861
static Index64 offTileCount()
Definition: LeafNode.h:215
ChildOffIter endChildOff()
Definition: LeafNode.h:398
#define OPENVDB_VERSION_NAME
Definition: version.h:45
ChildAllCIter cbeginChildAll() const
Definition: LeafNode.h:389
ChildOnCIter endChildOn() const
Definition: LeafNode.h:394
Definition: LeafNode.h:273
ChildOffCIter cbeginChildOff() const
Definition: LeafNode.h:386
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:1598
void visit(VisitorOp &)
Definition: LeafNode.h:1621
bool isChildMaskOff(Index) const
Definition: LeafNode.h:866
static void doVisit(NodeT &, VisitorOp &)
Definition: LeafNode.h:1639
ValueIter< MaskOnIterator, LeafNode, const ValueType, ValueOn > ValueOnIter
Definition: LeafNode.h:348
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
Base class for iterators over internal and leaf nodes.
Definition: Iterator.h:58
DenseIteratorBase< MaskDenseIterator, DenseIter, NodeT, void, ValueT > BaseT
Definition: LeafNode.h:324
void addTile(Index level, const Coord &, const ValueType &, bool)
Definition: LeafNode.h:1331
CombineArgs & setBRef(const ValueType &b)
Redirect the B value to a new external source.
Definition: Types.h:271
bool isConstant(ValueType &constValue, bool &state, const ValueType &tolerance=zeroVal< ValueType >()) const
Definition: LeafNode.h:1308
void addTileAndCache(Index, const Coord &, const ValueType &, bool, AccessorT &)
Definition: LeafNode.h:1349
OPENVDB_API Hermite min(const Hermite &, const Hermite &)
min and max operations done directly on the compressed data.
NodeMaskType & getValueMask()
Definition: LeafNode.h:863
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
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
NodeMaskType::OffIterator MaskOffIterator
Definition: LeafNode.h:269
LeafNode< OtherValueType, Log2Dim > Type
Definition: LeafNode.h:83
bool isValueMaskOff(Index n) const
Definition: LeafNode.h:860
Index64 memUsage() const
Return the memory in bytes occupied by this node.
Definition: LeafNode.h:1259
NodeT * probeNodeAndCache(const Coord &, AccessorT &)
Return a pointer to this node.
Definition: LeafNode.h:791
ValueOffCIter beginValueOff() const
Definition: LeafNode.h:365
const ValueType & operator[](Index i) const
Return a const reference to the i'th element of the Buffer.
Definition: LeafNode.h:109
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
Base class for dense iterators over internal and leaf nodes.
Definition: Iterator.h:211
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
Index64 onLeafVoxelCount() const
Definition: LeafNode.h:212
const NodeMaskType & getValueMask() const
Definition: LeafNode.h:862
static Index dim()
Return the number of voxels in each coordinate dimension.
Definition: LeafNode.h:192
static Index getLevel()
Return the level of this node, which by definition is zero for LeafNodes.
Definition: LeafNode.h:198
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
ValueIter< MaskOnIterator, const LeafNode, const ValueType, ValueOn > ValueOnCIter
Definition: LeafNode.h:349
bool isValueMaskOn() const
Definition: LeafNode.h:859
ValueIter(const MaskIterT &iter, NodeT *parent)
Definition: LeafNode.h:286
ChildOffCIter cendChildOff() const
Definition: LeafNode.h:396
void readTopology(std::istream &is, bool fromHalf=false)
Read in just the topology.
Definition: LeafNode.h:1181
bool isExactlyEqual(const T0 &a, const T1 &b)
Return true if a is exactly equal to b.
Definition: Math.h:353
static void doVisit2(NodeT &self, OtherChildAllIterT &, VisitorOp &, bool otherIsLHS)
Definition: LeafNode.h:1723
ValueOnCIter cendValueOn() const
Definition: LeafNode.h:371
void getOrigin(Coord &origin) const
Return the grid index coordinates of this node's local origin.
Definition: LeafNode.h:242
static Index size()
Return the total number of voxels represented by this LeafNode.
Definition: LeafNode.h:194
Definition: LeafNode.h:274
Index32 pos() const
Definition: NodeMasks.h:177
std::string str() const
Return a string representation of this node.
Definition: LeafNode.h:952
bool isDense() const
Return true if this node contains only active voxels.
Definition: LeafNode.h:219
Buffer()
Empty default constructor.
Definition: LeafNode.h:92
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 LeafNode * probeLeafAndCache(const Coord &, AccessorT &) const
Return a const pointer to this node.
Definition: LeafNode.h:808
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:1147
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
Definition: NodeMasks.h:189
OPENVDB_DEPRECATED void evalActiveVoxelBoundingBox(CoordBBox &) const
Definition: LeafNode.h:1267
void setItem(Index pos, const ValueT &value) const
Definition: LeafNode.h:292
void visit2(IterT &otherIter, VisitorOp &, bool otherIsLHS=false)
Definition: LeafNode.h:1699
Index32 Index
Definition: Types.h:56
void writeBuffers(std::ostream &os, bool toHalf=false) const
Write buffers to a stream.
Definition: LeafNode.h:1234
Coord mOrigin
Global grid index coordinates (x,y,z) of the local origin of this node.
Definition: LeafNode.h:854
Definition: LeafNode.h:321
ChildOffCIter beginChildOff() const
Definition: LeafNode.h:387
static Index memUsage()
Return the memory-footprint of this Buffer in units of bytes.
Definition: LeafNode.h:142
Definition: LeafNode.h:273
ChildAllIter beginChildAll()
Definition: LeafNode.h:391
void resetBackground(const ValueType &oldBackground, const ValueType &newBackground)
Replace inactive occurrences of oldBackground with newBackground, and inactive occurrences of -oldBac...
Definition: LeafNode.h:1404
boost::remove_const< UnsetItemT >::type NonConstValueType
Definition: Iterator.h:217
DenseIter()
Definition: LeafNode.h:327
Buffer & buffer()
Definition: LeafNode.h:410
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
DenseIter< const LeafNode, const ValueType, ChildAll > ChildAllCIter
Definition: LeafNode.h:359
bool isInactive() const
Return true if all of this node's values are inactive.
Definition: LeafNode.h:826
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
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
ValueAllIter endValueAll()
Definition: LeafNode.h:379
ChildAllCIter cendChildAll() const
Definition: LeafNode.h:399
SparseIteratorBase< MaskIterT, ValueIter, NodeT, ValueT > BaseT
Definition: LeafNode.h:283
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
ValueAllCIter cbeginValueAll() const
Definition: LeafNode.h:367
static Index getValueLevel(const Coord &)
Return the level (i.e., 0) at which leaf node values reside.
Definition: LeafNode.h:453
BaseT::NonConstValueType NonConstValueT
Definition: LeafNode.h:325
LeafNode()
Default constructor.
Definition: LeafNode.h:894
static void evalNodeOrigin(Coord &xyz)
Compute the origin of the leaf node that contains the voxel with the given coordinates.
Definition: LeafNode.h:874
DenseIter(const MaskDenseIterator &iter, NodeT *parent)
Definition: LeafNode.h:328
CombineArgs & setARef(const ValueType &a)
Redirect the A value to a new external source.
Definition: Types.h:269
void setValueMaskOn(Index n)
Definition: LeafNode.h:870
static bool hasActiveTiles()
Return false since leaf nodes never contain tiles.
Definition: LeafNode.h:528
static Index numValues()
Return the total number of voxels represented by this LeafNode.
Definition: LeafNode.h:196
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
~Buffer()
Destructor.
Definition: LeafNode.h:98
void swap(Buffer &other)
Replace the values in this Buffer with the values in the other Buffer.
Definition: LeafNode.h:135
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
ChildIter< MaskOnIterator, const LeafNode, ChildOn > ChildOnCIter
Definition: LeafNode.h:355
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:1485
const ValueType & getValueAndCache(const Coord &xyz, AccessorT &) const
Return the value of the voxel at the given coordinates.
Definition: LeafNode.h:575
void modifyItem(Index n, const ModifyOp &op) const
Definition: LeafNode.h:304
ValueAllCIter beginValueAll() const
Definition: LeafNode.h:368
NodeMaskType::OnIterator MaskOnIterator
Definition: LeafNode.h:268
bool resultIsActive() const
Definition: Types.h:280
Definition: NodeMasks.h:251
bool isChildMaskOff() const
Definition: LeafNode.h:867
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h:56
ValueAllCIter cendValueAll() const
Definition: LeafNode.h:377
bool isApproxEqual(const Hermite &lhs, const Hermite &rhs)
Definition: Hermite.h:470
static Index getValueLevelAndCache(const Coord &, AccessorT &)
Return the LEVEL (=0) at which leaf node values reside.
Definition: LeafNode.h:660
const LeafNode * probeLeaf(const Coord &) const
Return a const pointer to this node.
Definition: LeafNode.h:809
Definition: LeafNode.h:274
~LeafNode()
Destructor.
Definition: LeafNode.h:946
static Index32 nonLeafCount()
Return the non-leaf count for this node, which is zero.
Definition: LeafNode.h:206
Definition: Compression.h:70
ValueOffIter endValueOff()
Definition: LeafNode.h:376
NodeMaskType mValueMask
Bitmask that determines which voxels are active.
Definition: LeafNode.h:852
uint64_t Index64
Definition: Types.h:55
Bit mask for the internal and leaf nodes of VDB. This is a 64-bit implementation. ...
Definition: NodeMasks.h:288
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
void writeCompressedValues(std::ostream &os, ValueT *srcBuf, Index srcCount, const MaskT &valueMask, const MaskT &childMask, bool toHalf)
Definition: Compression.h:378
Buffer(const Buffer &other)
Copy constructor.
Definition: LeafNode.h:96
void unsetItem(Index pos, const ValueT &value) const
Definition: LeafNode.h:341
boost::shared_ptr< LeafNode > Ptr
Definition: LeafNode.h:67
void fill(const ValueType &val)
Populates the buffer with a constant value.
Definition: LeafNode.h:100
ChildOffCIter endChildOff() const
Definition: LeafNode.h:397
OPENVDB_DEPRECATED const Coord & getOrigin() const
Return the grid index coordinates of this node's local origin.
Definition: LeafNode.h:238
ChildAllIter endChildAll()
Definition: LeafNode.h:401
ChildIter(const MaskIterT &iter, NodeT *parent)
Definition: LeafNode.h:316
void writeTopology(std::ostream &os, bool toHalf=false) const
Write out just the topology.
Definition: LeafNode.h:1189
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
ValueOffIter beginValueOff()
Definition: LeafNode.h:366
ValueIter()
Definition: LeafNode.h:285
void setValueOff(Index offset)
Mark the voxel at the given offset as inactive but don't change its value.
Definition: LeafNode.h:468
Index64 offVoxelCount() const
Return the number of voxels marked Off.
Definition: LeafNode.h:211
Definition: Compression.h:165
void merge(const LeafNode &)
Definition: LeafNode.h:1423
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
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
void setValueMask(Index n, bool on)
Definition: LeafNode.h:869
static Index32 leafCount()
Return the leaf count for this node, which is one.
Definition: LeafNode.h:204
const Buffer & buffer() const
Definition: LeafNode.h:409
ChildIter< MaskOffIterator, LeafNode, ChildOff > ChildOffIter
Definition: LeafNode.h:356