Go to the documentation of this file.
31 #ifndef OPENVDB_TREE_LEAFNODE_HAS_BEEN_INCLUDED
32 #define OPENVDB_TREE_LEAFNODE_HAS_BEEN_INCLUDED
44 #include <type_traits>
56 template<Index,
typename>
struct SameLeafConfig;
63 template<
typename T, Index Log2Dim>
78 NUM_VALUES = 1 << 3 * Log2Dim,
79 NUM_VOXELS = NUM_VALUES,
85 template<
typename OtherValueType>
90 template<
typename OtherNodeType>
104 const ValueType& value = zeroVal<ValueType>(),
105 bool active =
false);
108 #if OPENVDB_ABI_VERSION_NUMBER >= 3
116 const ValueType& value = zeroVal<ValueType>(),
117 bool active =
false);
127 template<
typename OtherValueType>
131 template<
typename OtherValueType>
136 template<
typename OtherValueType>
174 bool isEmpty()
const {
return mValueMask.isOff(); }
176 bool isDense()
const {
return mValueMask.isOn(); }
178 #if OPENVDB_ABI_VERSION_NUMBER >= 3
179 bool isAllocated()
const {
return !mBuffer.isOutOfCore() && !mBuffer.empty(); }
191 void evalActiveBoundingBox(
CoordBBox& bbox,
bool visitVoxels =
true)
const;
200 const Coord& origin()
const {
return mOrigin; }
215 std::string str()
const;
219 template<
typename OtherType, Index OtherLog2Dim>
235 template<
typename MaskIterT,
typename NodeT,
typename ValueT,
typename TagT>
240 MaskIterT, ValueIter<MaskIterT, NodeT, ValueT, TagT>, NodeT, ValueT>
247 ValueT&
getItem(
Index pos)
const {
return this->parent().getValue(pos); }
248 ValueT&
getValue()
const {
return this->parent().getValue(this->pos()); }
253 this->parent().setValueOnly(pos, value);
258 this->parent().setValueOnly(this->pos(), value);
262 template<
typename ModifyOp>
263 void modifyItem(
Index n,
const ModifyOp& op)
const { this->parent().modifyValue(n, op); }
265 template<
typename ModifyOp>
266 void modifyValue(
const ModifyOp& op)
const { this->parent().modifyValue(this->pos(), op); }
270 template<
typename MaskIterT,
typename NodeT,
typename TagT>
272 public SparseIteratorBase<MaskIterT, ChildIter<MaskIterT, NodeT, TagT>, NodeT, ValueType>
279 template<
typename NodeT,
typename ValueT,
typename TagT>
281 MaskDenseIterator, DenseIter<NodeT, ValueT, TagT>, NodeT, void, ValueT>
291 value = this->parent().getValue(pos);
302 this->parent().setValueOnly(pos, value);
377 void readTopology(std::istream& is,
bool fromHalf =
false);
381 void writeTopology(std::ostream& os,
bool toHalf =
false)
const;
386 void readBuffers(std::istream& is,
bool fromHalf =
false);
391 void readBuffers(std::istream& is,
const CoordBBox& bbox,
bool fromHalf =
false);
395 void writeBuffers(std::ostream& os,
bool toHalf =
false)
const;
397 size_t streamingSize(
bool toHalf =
false)
const;
403 const ValueType& getValue(
const Coord& xyz)
const;
405 const ValueType& getValue(
Index offset)
const;
410 bool probeValue(
const Coord& xyz, ValueType& val)
const;
414 bool probeValue(
Index offset, ValueType& val)
const;
420 void setActiveState(
const Coord& xyz,
bool on);
425 void setValueOnly(
const Coord& xyz,
const ValueType& val);
427 void setValueOnly(
Index offset,
const ValueType& val);
435 void setValueOff(
const Coord& xyz,
const ValueType& val);
437 void setValueOff(
Index offset,
const ValueType& val);
445 this->setValueOn(LeafNode::coordToOffset(xyz), val);
451 mBuffer.setValue(offset, val);
452 mValueMask.setOn(offset);
457 template<
typename ModifyOp>
460 mBuffer.loadValues();
461 if (!mBuffer.empty()) {
463 ValueType& val = const_cast<ValueType&>(mBuffer[offset]);
465 mValueMask.setOn(offset);
471 template<
typename ModifyOp>
474 this->modifyValue(this->coordToOffset(xyz), op);
478 template<
typename ModifyOp>
481 mBuffer.loadValues();
482 if (!mBuffer.empty()) {
483 const Index offset = this->coordToOffset(xyz);
484 bool state = mValueMask.isOn(offset);
486 ValueType& val = const_cast<ValueType&>(mBuffer[offset]);
488 mValueMask.set(offset, state);
509 void fill(
const CoordBBox& bbox,
const ValueType&,
bool active =
true);
513 this->fill(bbox, value, active);
517 void fill(
const ValueType& value);
519 void fill(
const ValueType& value,
bool active);
532 template<
typename DenseT>
551 template<
typename DenseT>
553 const ValueType& background,
const ValueType& tolerance);
557 template<
typename AccessorT>
560 return this->getValue(xyz);
565 template<
typename AccessorT>
570 template<
typename AccessorT>
573 this->setValueOn(xyz, val);
579 template<
typename AccessorT>
582 this->setValueOnly(xyz, val);
588 template<
typename ModifyOp,
typename AccessorT>
591 this->modifyValue(xyz, op);
596 template<
typename ModifyOp,
typename AccessorT>
599 this->modifyValueAndActiveState(xyz, op);
604 template<
typename AccessorT>
607 this->setValueOff(xyz, value);
613 template<
typename AccessorT>
616 this->setActiveState(xyz, on);
622 template<
typename AccessorT>
625 return this->probeValue(xyz, val);
631 template<
typename AccessorT>
634 const Index offset = this->coordToOffset(xyz);
635 state = mValueMask.isOn(offset);
637 return mBuffer[offset];
642 template<
typename AccessorT>
654 void resetBackground(
const ValueType& oldBackground,
const ValueType& newBackground);
662 template<MergePolicy Policy>
void merge(
const LeafNode&);
663 template<MergePolicy Policy>
void merge(
const ValueType& tileValue,
bool tileActive);
664 template<MergePolicy Policy>
665 void merge(
const LeafNode& other,
const ValueType& ,
const ValueType& );
673 template<
typename OtherType>
687 template<
typename OtherType>
701 template<
typename OtherType>
704 template<
typename CombineOp>
705 void combine(
const LeafNode& other, CombineOp& op);
706 template<
typename CombineOp>
707 void combine(
const ValueType& value,
bool valueIsActive, CombineOp& op);
709 template<
typename CombineOp,
typename OtherType >
710 void combine2(
const LeafNode& other,
const OtherType&,
bool valueIsActive, CombineOp&);
711 template<
typename CombineOp,
typename OtherNodeT >
712 void combine2(
const ValueType&,
const OtherNodeT& other,
bool valueIsActive, CombineOp&);
713 template<
typename CombineOp,
typename OtherNodeT >
714 void combine2(
const LeafNode& b0,
const OtherNodeT& b1, CombineOp&);
721 template<
typename BBoxOp>
void visitActiveBBox(BBoxOp&)
const;
723 template<
typename VisitorOp>
void visit(VisitorOp&);
724 template<
typename VisitorOp>
void visit(VisitorOp&)
const;
726 template<
typename OtherLeafNodeType,
typename VisitorOp>
727 void visit2Node(OtherLeafNodeType& other, VisitorOp&);
728 template<
typename OtherLeafNodeType,
typename VisitorOp>
729 void visit2Node(OtherLeafNodeType& other, VisitorOp&)
const;
730 template<
typename IterT,
typename VisitorOp>
731 void visit2(IterT& otherIter, VisitorOp&,
bool otherIsLHS =
false);
732 template<
typename IterT,
typename VisitorOp>
733 void visit2(IterT& otherIter, VisitorOp&,
bool otherIsLHS =
false)
const;
736 void prune(
const ValueType& = zeroVal<ValueType>()) {}
739 template<
typename AccessorT>
741 template<
typename NodeT>
743 template<
typename NodeT>
745 template<
typename NodeT>
747 template<
typename ArrayT>
void getNodes(ArrayT&)
const {}
751 void addTile(
Index level,
const Coord&,
const ValueType&,
bool);
752 void addTile(
Index offset,
const ValueType&,
bool);
753 template<
typename AccessorT>
754 void addTileAndCache(
Index,
const Coord&,
const ValueType&,
bool, AccessorT&);
759 template<
typename AccessorT>
761 template<
typename NodeT,
typename AccessorT>
765 if (!(std::is_same<NodeT, LeafNode>::value))
return nullptr;
766 return reinterpret_cast<NodeT*>(
this);
770 template<
typename AccessorT>
774 const LeafNode* probeConstLeaf(
const Coord&)
const {
return this; }
776 template<
typename AccessorT>
778 template<
typename AccessorT>
781 template<
typename NodeT,
typename AccessorT>
785 if (!(std::is_same<NodeT, LeafNode>::value))
return nullptr;
786 return reinterpret_cast<const NodeT*>(
this);
800 bool isConstant(ValueType& firstValue,
bool& state,
801 const ValueType& tolerance = zeroVal<ValueType>())
const;
814 bool isConstant(ValueType& minValue, ValueType& maxValue,
815 bool& state,
const ValueType& tolerance = zeroVal<ValueType>())
const;
832 ValueType medianAll(ValueType *tmp =
nullptr)
const;
848 Index medianOn(ValueType &value, ValueType *tmp =
nullptr)
const;
864 Index medianOff(ValueType &value, ValueType *tmp =
nullptr)
const;
870 friend class ::TestLeaf;
871 template<
typename>
friend class ::TestLeafIO;
908 inline void skipCompressedValues(
bool seekable, std::istream&,
bool fromHalf);
913 template<
typename NodeT,
typename VisitorOp,
typename ChildAllIterT>
914 static inline void doVisit(NodeT&, VisitorOp&);
916 template<
typename NodeT,
typename OtherNodeT,
typename VisitorOp,
917 typename ChildAllIterT,
typename OtherChildAllIterT>
918 static inline void doVisit2Node(NodeT&
self, OtherNodeT& other, VisitorOp&);
920 template<
typename NodeT,
typename VisitorOp,
921 typename ChildAllIterT,
typename OtherChildAllIterT>
922 static inline void doVisit2(NodeT&
self, OtherChildAllIterT&, VisitorOp&,
bool otherIsLHS);
928 NodeMaskType mValueMask;
938 template<Index Dim1,
typename NodeT2>
943 template<Index Dim1,
typename T2>
951 template<
typename T, Index Log2Dim>
960 template<
typename T, Index Log2Dim>
965 mOrigin(xyz & (~(DIM - 1)))
970 #if OPENVDB_ABI_VERSION_NUMBER >= 3
971 template<
typename T, Index Log2Dim>
976 mOrigin(xyz & (~(DIM - 1)))
982 template<
typename T, Index Log2Dim>
985 mBuffer(other.mBuffer),
986 mValueMask(other.valueMask()),
987 mOrigin(other.mOrigin)
993 template<
typename T, Index Log2Dim>
994 template<
typename OtherValueType>
997 mValueMask(other.valueMask()),
998 mOrigin(other.mOrigin)
1002 static inline ValueType convertValue(
const OtherValueType& val) {
return ValueType(val); }
1006 mBuffer[i] = Local::convertValue(other.mBuffer[i]);
1011 template<
typename T, Index Log2Dim>
1012 template<
typename OtherValueType>
1016 mBuffer(background),
1017 mValueMask(other.valueMask()),
1018 mOrigin(other.mOrigin)
1023 template<
typename T, Index Log2Dim>
1024 template<
typename OtherValueType>
1028 mValueMask(other.valueMask()),
1029 mOrigin(other.mOrigin)
1032 mBuffer[i] = (mValueMask.
isOn(i) ? onValue : offValue);
1037 template<
typename T, Index Log2Dim>
1044 template<
typename T, Index Log2Dim>
1048 std::ostringstream ostr;
1049 ostr <<
"LeafNode @" << mOrigin <<
": " << mBuffer;
1057 template<
typename T, Index Log2Dim>
1061 assert ((xyz[0] & (DIM-1u)) < DIM && (xyz[1] & (DIM-1u)) < DIM && (xyz[2] & (DIM-1u)) < DIM);
1062 return ((xyz[0] & (DIM-1u)) << 2*Log2Dim)
1063 + ((xyz[1] & (DIM-1u)) << Log2Dim)
1064 + (xyz[2] & (DIM-1u));
1067 template<
typename T, Index Log2Dim>
1071 assert(n<(1<< 3*Log2Dim));
1073 xyz.
setX(n >> 2*Log2Dim);
1074 n &= ((1<<2*Log2Dim)-1);
1075 xyz.
setY(n >> Log2Dim);
1076 xyz.
setZ(n & ((1<<Log2Dim)-1));
1081 template<
typename T, Index Log2Dim>
1085 return (this->offsetToLocalCoord(n) + this->origin());
1092 template<
typename ValueT, Index Log2Dim>
1093 inline const ValueT&
1099 template<
typename ValueT, Index Log2Dim>
1100 inline const ValueT&
1103 assert(offset < SIZE);
1104 return mBuffer[offset];
1108 template<
typename T, Index Log2Dim>
1115 template<
typename T, Index Log2Dim>
1119 assert(offset < SIZE);
1120 val = mBuffer[offset];
1121 return mValueMask.isOn(offset);
1125 template<
typename T, Index Log2Dim>
1132 template<
typename T, Index Log2Dim>
1136 assert(offset < SIZE);
1137 mBuffer.setValue(offset, val);
1138 mValueMask.setOff(offset);
1142 template<
typename T, Index Log2Dim>
1146 mValueMask.set(this->coordToOffset(xyz), on);
1150 template<
typename T, Index Log2Dim>
1157 template<
typename T, Index Log2Dim>
1161 assert(offset<SIZE); mBuffer.setValue(offset, val);
1168 template<
typename T, Index Log2Dim>
1172 CoordBBox nodeBBox = this->getNodeBoundingBox();
1175 this->fill(background,
false);
1176 }
else if (clipBBox.
isInside(nodeBBox)) {
1188 int &x = xyz.
x(), &y = xyz.
y(), &z = xyz.
z();
1189 for (x = nodeBBox.
min().
x(); x <= nodeBBox.
max().
x(); ++x) {
1190 for (y = nodeBBox.
min().
y(); y <= nodeBBox.
max().
y(); ++y) {
1191 for (z = nodeBBox.
min().
z(); z <= nodeBBox.
max().
z(); ++z) {
1192 mask.
setOn(static_cast<Index32>(this->coordToOffset(xyz)));
1200 this->setValueOff(maskIter.pos(), background);
1208 template<
typename T, Index Log2Dim>
1212 #if OPENVDB_ABI_VERSION_NUMBER >= 3
1213 if (!this->allocate())
return;
1216 auto clippedBBox = this->getNodeBoundingBox();
1217 clippedBBox.intersect(bbox);
1218 if (!clippedBBox)
return;
1220 for (
Int32 x = clippedBBox.min().x(); x <= clippedBBox.max().x(); ++x) {
1221 const Index offsetX = (x & (DIM-1u)) << 2*Log2Dim;
1222 for (
Int32 y = clippedBBox.min().y(); y <= clippedBBox.max().y(); ++y) {
1223 const Index offsetXY = offsetX + ((y & (DIM-1u)) << Log2Dim);
1224 for (
Int32 z = clippedBBox.min().z(); z <= clippedBBox.max().z(); ++z) {
1225 const Index offset = offsetXY + (z & (DIM-1u));
1226 mBuffer[offset] = value;
1227 mValueMask.set(offset, active);
1233 template<
typename T, Index Log2Dim>
1237 mBuffer.fill(value);
1240 template<
typename T, Index Log2Dim>
1244 mBuffer.fill(value);
1245 mValueMask.set(active);
1252 template<
typename T, Index Log2Dim>
1253 template<
typename DenseT>
1257 #if OPENVDB_ABI_VERSION_NUMBER >= 3
1258 mBuffer.loadValues();
1261 using DenseValueType =
typename DenseT::ValueType;
1263 const size_t xStride = dense.xStride(), yStride = dense.yStride(), zStride = dense.zStride();
1264 const Coord&
min = dense.bbox().min();
1265 DenseValueType* t0 = dense.data() + zStride * (bbox.
min()[2] -
min[2]);
1266 const T* s0 = &mBuffer[bbox.
min()[2] & (DIM-1u)];
1267 for (
Int32 x = bbox.
min()[0], ex = bbox.
max()[0] + 1; x < ex; ++x) {
1268 DenseValueType* t1 = t0 + xStride * (x -
min[0]);
1269 const T* s1 = s0 + ((x & (DIM-1u)) << 2*Log2Dim);
1270 for (
Int32 y = bbox.
min()[1], ey = bbox.
max()[1] + 1; y < ey; ++y) {
1271 DenseValueType* t2 = t1 + yStride * (y -
min[1]);
1272 const T* s2 = s1 + ((y & (DIM-1u)) << Log2Dim);
1273 for (
Int32 z = bbox.
min()[2], ez = bbox.
max()[2] + 1; z < ez; ++z, t2 += zStride) {
1274 *t2 = DenseValueType(*s2++);
1281 template<
typename T, Index Log2Dim>
1282 template<
typename DenseT>
1287 #if OPENVDB_ABI_VERSION_NUMBER >= 3
1288 if (!this->allocate())
return;
1291 using DenseValueType =
typename DenseT::ValueType;
1293 const size_t xStride = dense.xStride(), yStride = dense.yStride(), zStride = dense.zStride();
1294 const Coord&
min = dense.bbox().min();
1296 const DenseValueType* s0 = dense.data() + zStride * (bbox.
min()[2] -
min[2]);
1297 const Int32 n0 = bbox.
min()[2] & (DIM-1u);
1298 for (
Int32 x = bbox.
min()[0], ex = bbox.
max()[0]+1; x < ex; ++x) {
1299 const DenseValueType* s1 = s0 + xStride * (x -
min[0]);
1300 const Int32 n1 = n0 + ((x & (DIM-1u)) << 2*LOG2DIM);
1301 for (
Int32 y = bbox.
min()[1], ey = bbox.
max()[1]+1; y < ey; ++y) {
1302 const DenseValueType* s2 = s1 + yStride * (y -
min[1]);
1303 Int32 n2 = n1 + ((y & (DIM-1u)) << LOG2DIM);
1304 for (
Int32 z = bbox.
min()[2], ez = bbox.
max()[2]+1; z < ez; ++z, ++n2, s2 += zStride) {
1306 mValueMask.setOff(n2);
1307 mBuffer[n2] = background;
1309 mValueMask.setOn(n2);
1321 template<
typename T, Index Log2Dim>
1325 mValueMask.load(is);
1329 template<
typename T, Index Log2Dim>
1333 mValueMask.save(os);
1341 template<
typename T, Index Log2Dim>
1347 io::readCompressedValues<ValueType, NodeMaskType>(
1348 is,
nullptr, SIZE, mValueMask, fromHalf);
1357 template<
typename T, Index Log2Dim>
1365 template<
typename T, Index Log2Dim>
1370 const bool seekable = meta && meta->seekable();
1372 #if OPENVDB_ABI_VERSION_NUMBER >= 3
1373 std::streamoff maskpos = is.tellg();
1378 mValueMask.seek(is);
1381 mValueMask.load(is);
1384 int8_t numBuffers = 1;
1390 is.read(reinterpret_cast<char*>(&numBuffers),
sizeof(int8_t));
1393 CoordBBox nodeBBox = this->getNodeBoundingBox();
1396 skipCompressedValues(seekable, is, fromHalf);
1397 mValueMask.setOff();
1398 mBuffer.setOutOfCore(
false);
1400 #if OPENVDB_ABI_VERSION_NUMBER >= 3
1406 const bool delayLoad = ((mappedFile.get() !=
nullptr) && clipBBox.
isInside(nodeBBox));
1409 mBuffer.setOutOfCore(
true);
1410 mBuffer.mFileInfo =
new typename Buffer::FileInfo;
1411 mBuffer.mFileInfo->meta = meta;
1412 mBuffer.mFileInfo->bufpos = is.tellg();
1413 mBuffer.mFileInfo->mapping = mappedFile;
1416 mBuffer.mFileInfo->maskpos = maskpos;
1418 skipCompressedValues(seekable, is, fromHalf);
1423 mBuffer.setOutOfCore(
false);
1426 T background = zeroVal<T>();
1428 background = *static_cast<const T*>(bgPtr);
1430 this->
clip(clipBBox, background);
1431 #if OPENVDB_ABI_VERSION_NUMBER >= 3
1436 if (numBuffers > 1) {
1441 for (
int i = 1; i < numBuffers; ++i) {
1445 io::readData<T>(is, temp.
mData, SIZE, zipped);
1451 if (meta) meta->setLeaf(meta->leaf() + 1);
1455 template<
typename T, Index Log2Dim>
1460 mValueMask.save(os);
1462 mBuffer.loadValues();
1472 template<
typename T, Index Log2Dim>
1476 return mOrigin == other.mOrigin &&
1478 mBuffer == other.mBuffer;
1482 template<
typename T, Index Log2Dim>
1488 return sizeof(*this) + mBuffer.memUsage() -
sizeof(mBuffer);
1492 template<
typename T, Index Log2Dim>
1496 CoordBBox this_bbox = this->getNodeBoundingBox();
1497 if (bbox.
isInside(this_bbox))
return;
1501 for(; iter; ++iter) this_bbox.
expand(this->offsetToLocalCoord(iter.pos()));
1509 template<
typename T, Index Log2Dim>
1510 template<
typename OtherType, Index OtherLog2Dim>
1515 return (Log2Dim == OtherLog2Dim && mValueMask == other->
getValueMask());
1518 template<
typename T, Index Log2Dim>
1524 if (!mValueMask.isConstant(state))
return false;
1525 firstValue = mBuffer[0];
1526 for (
Index i = 1; i < SIZE; ++i) {
1532 template<
typename T, Index Log2Dim>
1539 if (!mValueMask.isConstant(state))
return false;
1540 minValue = maxValue = mBuffer[0];
1541 for (
Index i = 1; i < SIZE; ++i) {
1542 const T& v = mBuffer[i];
1544 if ((maxValue - v) > tolerance)
return false;
1546 }
else if (v > maxValue) {
1547 if ((v - minValue) > tolerance)
return false;
1554 template<
typename T, Index Log2Dim>
1558 std::unique_ptr<T[]> data(
nullptr);
1559 if (tmp ==
nullptr) {
1560 data.reset(
new T[NUM_VALUES]);
1563 if (tmp != mBuffer.data()) {
1564 const T* src = mBuffer.data();
1565 for (T* dst = tmp; dst-tmp < NUM_VALUES;) *dst++ = *src++;
1567 static const size_t midpoint = (NUM_VALUES - 1) >> 1;
1568 std::nth_element(tmp, tmp + midpoint, tmp + NUM_VALUES);
1569 return tmp[midpoint];
1572 template<
typename T, Index Log2Dim>
1576 const Index count = mValueMask.countOn();
1577 if (count == NUM_VALUES) {
1578 value = this->medianAll(tmp);
1580 }
else if (count == 0) {
1583 std::unique_ptr<T[]> data(
nullptr);
1584 if (tmp ==
nullptr) {
1585 data.reset(
new T[count]);
1588 for (
auto iter=this->cbeginValueOn(); iter; ++iter) *tmp++ = *iter;
1589 T *begin = tmp - count;
1590 const size_t midpoint = (count - 1) >> 1;
1591 std::nth_element(begin, begin + midpoint, tmp);
1592 value = begin[midpoint];
1596 template<
typename T, Index Log2Dim>
1600 const Index count = mValueMask.countOff();
1601 if (count == NUM_VALUES) {
1602 value = this->medianAll(tmp);
1604 }
else if (count == 0) {
1607 std::unique_ptr<T[]> data(
nullptr);
1608 if (tmp ==
nullptr) {
1609 data.reset(
new T[count]);
1612 for (
auto iter=this->cbeginValueOff(); iter; ++iter) *tmp++ = *iter;
1613 T *begin = tmp - count;
1614 const size_t midpoint = (count - 1) >> 1;
1615 std::nth_element(begin, begin + midpoint, tmp);
1616 value = begin[midpoint];
1623 template<
typename T, Index Log2Dim>
1627 this->addTile(this->coordToOffset(xyz), val, active);
1630 template<
typename T, Index Log2Dim>
1634 assert(offset < SIZE);
1635 setValueOnly(offset, val);
1636 setActiveState(offset, active);
1639 template<
typename T, Index Log2Dim>
1640 template<
typename AccessorT>
1643 const ValueType& val,
bool active, AccessorT&)
1645 this->addTile(level, xyz, val, active);
1652 template<
typename T, Index Log2Dim>
1657 #if OPENVDB_ABI_VERSION_NUMBER >= 3
1658 if (!this->allocate())
return;
1663 for (iter = this->mValueMask.beginOff(); iter; ++iter) {
1666 inactiveValue = newBackground;
1674 template<
typename T, Index Log2Dim>
1675 template<MergePolicy Policy>
1679 #if OPENVDB_ABI_VERSION_NUMBER >= 3
1680 if (!this->allocate())
return;
1686 for (; iter; ++iter) {
1688 if (mValueMask.isOff(n)) {
1689 mBuffer[n] = other.mBuffer[n];
1690 mValueMask.setOn(n);
1696 template<
typename T, Index Log2Dim>
1697 template<MergePolicy Policy>
1702 this->
template merge<Policy>(other);
1705 template<
typename T, Index Log2Dim>
1706 template<MergePolicy Policy>
1710 #if OPENVDB_ABI_VERSION_NUMBER >= 3
1711 if (!this->allocate())
return;
1716 if (!tileActive)
return;
1719 const Index n = iter.pos();
1720 mBuffer[n] = tileValue;
1721 mValueMask.setOn(n);
1727 template<
typename T, Index Log2Dim>
1728 template<
typename OtherType>
1735 template<
typename T, Index Log2Dim>
1736 template<
typename OtherType>
1744 template<
typename T, Index Log2Dim>
1745 template<
typename OtherType>
1753 template<
typename T, Index Log2Dim>
1757 #if OPENVDB_ABI_VERSION_NUMBER >= 3
1758 if (!this->allocate())
return;
1760 for (
Index i = 0; i < SIZE; ++i) {
1761 mBuffer[i] = -mBuffer[i];
1769 template<
typename T, Index Log2Dim>
1770 template<
typename CombineOp>
1774 #if OPENVDB_ABI_VERSION_NUMBER >= 3
1775 if (!this->allocate())
return;
1778 for (
Index i = 0; i < SIZE; ++i) {
1780 .setAIsActive(mValueMask.isOn(i))
1781 .setBRef(other.mBuffer[i])
1783 .setResultRef(mBuffer[i]));
1789 template<
typename T, Index Log2Dim>
1790 template<
typename CombineOp>
1794 #if OPENVDB_ABI_VERSION_NUMBER >= 3
1795 if (!this->allocate())
return;
1798 args.
setBRef(value).setBIsActive(valueIsActive);
1799 for (
Index i = 0; i < SIZE; ++i) {
1801 .setAIsActive(mValueMask.isOn(i))
1802 .setResultRef(mBuffer[i]));
1811 template<
typename T, Index Log2Dim>
1812 template<
typename CombineOp,
typename OtherType>
1815 bool valueIsActive, CombineOp& op)
1817 #if OPENVDB_ABI_VERSION_NUMBER >= 3
1818 if (!this->allocate())
return;
1821 args.
setBRef(value).setBIsActive(valueIsActive);
1822 for (
Index i = 0; i < SIZE; ++i) {
1823 op(args.
setARef(other.mBuffer[i])
1825 .setResultRef(mBuffer[i]));
1831 template<
typename T, Index Log2Dim>
1832 template<
typename CombineOp,
typename OtherNodeT>
1835 bool valueIsActive, CombineOp& op)
1837 #if OPENVDB_ABI_VERSION_NUMBER >= 3
1838 if (!this->allocate())
return;
1841 args.
setARef(value).setAIsActive(valueIsActive);
1842 for (
Index i = 0; i < SIZE; ++i) {
1843 op(args.
setBRef(other.mBuffer[i])
1844 .setBIsActive(other.valueMask().isOn(i))
1845 .setResultRef(mBuffer[i]));
1851 template<
typename T, Index Log2Dim>
1852 template<
typename CombineOp,
typename OtherNodeT>
1856 #if OPENVDB_ABI_VERSION_NUMBER >= 3
1857 if (!this->allocate())
return;
1860 for (
Index i = 0; i < SIZE; ++i) {
1861 mValueMask.set(i, b0.
valueMask().
isOn(i) || b1.valueMask().isOn(i));
1862 op(args.
setARef(b0.mBuffer[i])
1864 .setBRef(b1.mBuffer[i])
1865 .setBIsActive(b1.valueMask().isOn(i))
1866 .setResultRef(mBuffer[i]));
1875 template<
typename T, Index Log2Dim>
1876 template<
typename BBoxOp>
1880 if (op.template descent<LEVEL>()) {
1890 op.operator()<LEVEL>(this->getNodeBoundingBox());
1892 op.template operator()<LEVEL>(this->getNodeBoundingBox());
1898 template<
typename T, Index Log2Dim>
1899 template<
typename VisitorOp>
1903 doVisit<LeafNode, VisitorOp, ChildAllIter>(*
this, op);
1907 template<
typename T, Index Log2Dim>
1908 template<
typename VisitorOp>
1912 doVisit<const LeafNode, VisitorOp, ChildAllCIter>(*
this, op);
1916 template<
typename T, Index Log2Dim>
1917 template<
typename NodeT,
typename VisitorOp,
typename ChildAllIterT>
1921 for (ChildAllIterT iter =
self.beginChildAll(); iter; ++iter) {
1930 template<
typename T, Index Log2Dim>
1931 template<
typename OtherLeafNodeType,
typename VisitorOp>
1936 typename OtherLeafNodeType::ChildAllIter>(*
this, other, op);
1940 template<
typename T, Index Log2Dim>
1941 template<
typename OtherLeafNodeType,
typename VisitorOp>
1946 typename OtherLeafNodeType::ChildAllCIter>(*
this, other, op);
1950 template<
typename T, Index Log2Dim>
1953 typename OtherNodeT,
1955 typename ChildAllIterT,
1956 typename OtherChildAllIterT>
1961 static_assert(OtherNodeT::SIZE == NodeT::SIZE,
1962 "can't visit nodes of different sizes simultaneously");
1963 static_assert(OtherNodeT::LEVEL == NodeT::LEVEL,
1964 "can't visit nodes at different tree levels simultaneously");
1966 ChildAllIterT iter =
self.beginChildAll();
1967 OtherChildAllIterT otherIter = other.beginChildAll();
1969 for ( ; iter && otherIter; ++iter, ++otherIter) {
1970 op(iter, otherIter);
1978 template<
typename T, Index Log2Dim>
1979 template<
typename IterT,
typename VisitorOp>
1983 doVisit2<LeafNode, VisitorOp, ChildAllIter, IterT>(
1984 *
this, otherIter, op, otherIsLHS);
1988 template<
typename T, Index Log2Dim>
1989 template<
typename IterT,
typename VisitorOp>
1993 doVisit2<const LeafNode, VisitorOp, ChildAllCIter, IterT>(
1994 *
this, otherIter, op, otherIsLHS);
1998 template<
typename T, Index Log2Dim>
2002 typename ChildAllIterT,
2003 typename OtherChildAllIterT>
2006 VisitorOp& op,
bool otherIsLHS)
2008 if (!otherIter)
return;
2011 for (ChildAllIterT iter =
self.beginChildAll(); iter; ++iter) {
2012 op(otherIter, iter);
2015 for (ChildAllIterT iter =
self.beginChildAll(); iter; ++iter) {
2016 op(iter, otherIter);
2025 template<
typename T, Index Log2Dim>
2026 inline std::ostream&
2029 for (
Index32 i = 0, N = buf.
size(); i < N; ++i) os << buf.
mData[i] <<
", ";
2047 #endif // OPENVDB_TREE_LEAFNODE_HAS_BEEN_INCLUDED
ValueAllCIter endValueAll() const
Definition: LeafNode.h:337
static Index size()
Return the total number of voxels represented by this LeafNode.
Definition: LeafNode.h:151
Base class for sparse iterators over internal and leaf nodes.
Definition: Iterator.h:141
typename NodeMaskType::OnIterator MaskOnIterator
Definition: LeafNode.h:227
ValueOnCIter cbeginValueOn() const
Definition: LeafNode.h:320
void evalActiveBoundingBox(CoordBBox &bbox, bool visitVoxels=true) const
Definition: LeafNode.h:1494
T BuildType
Definition: LeafNode.h:67
void addLeaf(LeafNode *)
Definition: LeafNode.h:738
bool isValueMaskOn(Index n) const
Definition: LeafNode.h:892
Signed (x, y, z) 32-bit integer coordinates.
Definition: Coord.h:52
Coord & setX(Int32 x)
Definition: Coord.h:107
bool isChildMaskOff() const
Definition: LeafNode.h:902
ChildOnCIter endChildOn() const
Definition: LeafNode.h:353
const ValueType & getFirstValue() const
Return a const reference to the first value in the buffer.
Definition: LeafNode.h:648
LeafNode * probeLeaf(const Coord &)
Definition: LeafNode.h:769
LeafNode()
Default constructor.
Definition: LeafNode.h:953
bool isValueMaskOff(Index n) const
Definition: LeafNode.h:894
ValueOffCIter cendValueOff() const
Definition: LeafNode.h:333
void combine2(const LeafNode &other, const OtherType &, bool valueIsActive, CombineOp &)
Definition: LeafNode.h:1814
typename NodeMaskType::OffIterator MaskOffIterator
Definition: LeafNode.h:228
ValueType ValueType
Definition: Iterator.h:144
ChildOnCIter beginChildOn() const
Definition: LeafNode.h:343
ValueAllIter beginValueAll()
Definition: LeafNode.h:328
const ValueType & getLastValue() const
Return a const reference to the last value in the buffer.
Definition: LeafNode.h:650
bool probeValue(const Coord &xyz, ValueType &val) const
Return true if the voxel at the given coordinates is active.
Definition: LeafNode.h:1110
void setItem(Index pos, const ValueT &value) const
Definition: LeafNode.h:251
ChildAllCIter endChildAll() const
Definition: LeafNode.h:359
const OPENVDB_API void * getGridBackgroundValuePtr(std::ios_base &)
Return a pointer to the background value of the grid currently being read from or written to the give...
void clip(const CoordBBox &, const ValueType &background)
Set all voxels that lie outside the given axis-aligned box to the background.
Definition: LeafNode.h:1170
void reset()
Definition: Coord.h:354
void unsetItem(Index pos, const ValueT &value) const
Definition: LeafNode.h:300
ChildIter(const MaskIterT &iter, NodeT *parent)
Definition: LeafNode.h:275
std::string str() const
Return a string representation of this node.
Definition: LeafNode.h:1046
SharedPtr< LeafNode > Ptr
Definition: LeafNode.h:72
ValueIter(const MaskIterT &iter, NodeT *parent)
Definition: LeafNode.h:245
Index64 offVoxelCount() const
Return the number of voxels marked Off.
Definition: LeafNode.h:168
static void doVisit2Node(NodeT &self, OtherNodeT &other, VisitorOp &)
Definition: LeafNode.h:1958
void setOn(Index32 n)
Set the nth bit on.
Definition: NodeMasks.h:454
Buffer & buffer()
Definition: LeafNode.h:369
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:605
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:450
Templated block class to hold specific data types and a fixed number of values determined by Log2Dim....
Definition: LeafNode.h:64
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:1284
ValueOffCIter endValueOff() const
Definition: LeafNode.h:334
void setValueMaskOn(Index n)
Definition: LeafNode.h:905
static Index64 onTileCount()
Definition: LeafNode.h:171
Tag dispatch class that distinguishes topology copy constructors from deep copy constructors.
Definition: Types.h:750
void resetBackground(const ValueType &oldBackground, const ValueType &newBackground)
Replace inactive occurrences of oldBackground with newBackground, and inactive occurrences of -oldBac...
Definition: LeafNode.h:1654
bool isValueOn(const Coord &xyz) const
Return true if the voxel at the given coordinates is active.
Definition: LeafNode.h:498
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:448
CombineArgs & setBRef(const BValueType &b)
Redirect the B value to a new external source.
Definition: Types.h:672
ValueOnCIter beginValueOn() const
Definition: LeafNode.h:321
OPENVDB_API SharedPtr< MappedFile > getMappedFilePtr(std::ios_base &)
Return a shared pointer to the memory-mapped file with which the given stream is associated,...
ChildAllIter endChildAll()
Definition: LeafNode.h:360
void setValueMask(const NodeMaskType &mask)
Definition: LeafNode.h:899
void readBuffers(std::istream &is, bool fromHalf=false)
Read buffers from a stream.
Definition: LeafNode.h:1359
ValueOnCIter cendValueOn() const
Definition: LeafNode.h:330
void visit(VisitorOp &)
Definition: LeafNode.h:1901
ChildOffIter beginChildOff()
Definition: LeafNode.h:347
bool hasOverlap(const CoordBBox &b) const
Return true if the given bounding box overlaps with this bounding box.
Definition: Coord.h:439
Index medianOff(ValueType &value, ValueType *tmp=nullptr) const
Computes the median value of all the inactive voxels in this node.
Definition: LeafNode.h:1598
Index64 memUsage() const
Return the memory in bytes occupied by this node.
Definition: LeafNode.h:1484
bool isEmpty() const
Return true if this node has no active voxels.
Definition: LeafNode.h:174
Definition: LeafNode.h:49
void readTopology(std::istream &is, bool fromHalf=false)
Read in just the topology.
Definition: LeafNode.h:1323
Definition: LeafNode.h:233
int32_t Int32
Definition: Types.h:63
void voxelizeActiveTiles(bool=true)
No-op.
Definition: LeafNode.h:660
Index32 pos() const
Definition: NodeMasks.h:202
ValueOnCIter endValueOn() const
Definition: LeafNode.h:331
ValueOnIter beginValueOn()
Definition: LeafNode.h:322
const NodeMaskType & getValueMask() const
Definition: LeafNode.h:896
Index32 Index
Definition: Types.h:61
ValueType medianAll(ValueType *tmp=nullptr) const
Computes the median value of all the active AND inactive voxels in this node.
Definition: LeafNode.h:1556
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:632
Definition: NodeMasks.h:272
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:614
Definition: Compression.h:319
ChildOffIter endChildOff()
Definition: LeafNode.h:357
void setValueOn(Index offset)
Mark the voxel at the given offset as active but don't change its value.
Definition: LeafNode.h:442
bool isInactive() const
Return true if all of this node's values are inactive.
Definition: LeafNode.h:867
Definition: LeafNode.h:232
ValueT & getValue() const
Definition: LeafNode.h:248
ValueOffIter beginValueOff()
Definition: LeafNode.h:325
typename BaseT::NonConstValueType NonConstValueT
Definition: LeafNode.h:284
Definition: LeafNode.h:236
void modifyValue(const ModifyOp &op) const
Definition: LeafNode.h:266
bool isChildMaskOff(Index) const
Definition: LeafNode.h:901
ChildOffCIter cbeginChildOff() const
Definition: LeafNode.h:345
ValueAllCIter cbeginValueAll() const
Definition: LeafNode.h:326
Index64 offLeafVoxelCount() const
Definition: LeafNode.h:170
bool isDense() const
Return true if this node contains only active voxels.
Definition: LeafNode.h:176
static void getNodeLog2Dims(std::vector< Index > &dims)
Append the Log2Dim of this LeafNode to the specified vector.
Definition: LeafNode.h:157
Coord & setZ(Int32 z)
Definition: Coord.h:109
ChildOffCIter endChildOff() const
Definition: LeafNode.h:356
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,...
Definition: LeafNode.h:1738
Int32 z() const
Definition: Coord.h:160
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:367
const LeafNode * probeLeaf(const Coord &) const
Definition: LeafNode.h:780
void writeBuffers(std::ostream &os, bool toHalf=false) const
Write buffers to a stream.
Definition: LeafNode.h:1457
ValueAllCIter beginValueAll() const
Definition: LeafNode.h:327
void negate()
Definition: LeafNode.h:1755
static Index32 leafCount()
Return the leaf count for this node, which is one.
Definition: LeafNode.h:161
void setValueMask(Index n, bool on)
Definition: LeafNode.h:904
static Index getLevel()
Return the level of this node, which by definition is zero for LeafNodes.
Definition: LeafNode.h:155
static Index getValueLevel(const Coord &)
Return the level (i.e., 0) at which leaf node values reside.
Definition: LeafNode.h:417
ChildOnIter endChildOn()
Definition: LeafNode.h:354
Definition: Compression.h:81
void readCompressedValues(std::istream &is, ValueT *destBuf, Index destCount, const MaskT &valueMask, bool fromHalf)
Definition: Compression.h:492
bool allocate()
Allocate memory for this node's buffer if it has not already been allocated.
Definition: LeafNode.h:182
void modifyItem(Index n, const ModifyOp &op) const
Definition: LeafNode.h:263
std::shared_ptr< T > SharedPtr
Definition: Types.h:139
ValueOnIter endValueOn()
Definition: LeafNode.h:332
static Index32 nonLeafCount()
Return the non-leaf count for this node, which is zero.
Definition: LeafNode.h:163
static void doVisit2(NodeT &self, OtherChildAllIterT &, VisitorOp &, bool otherIsLHS)
Definition: LeafNode.h:2005
const NodeT * probeConstNodeAndCache(const Coord &, AccessorT &) const
Definition: LeafNode.h:782
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:589
void modifyValueAndActiveState(const Coord &xyz, const ModifyOp &op)
Apply a functor to the voxel at the given coordinates.
Definition: LeafNode.h:479
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:444
Definition: NodeMasks.h:241
static Index64 offTileCount()
Definition: LeafNode.h:172
static Index getChildDim()
Return the dimension of child nodes of this LeafNode, which is one for voxels.
Definition: LeafNode.h:159
void visitActiveBBox(BBoxOp &) const
Calls the templated functor BBoxOp with bounding box information. An additional level argument is pro...
Definition: LeafNode.h:1878
Int32 ValueType
Definition: Coord.h:60
static Coord offsetToLocalCoord(Index n)
Return the local coordinates for a linear table offset, where offset 0 has coordinates (0,...
Definition: LeafNode.h:1069
bool isValueMaskOff() const
Definition: LeafNode.h:895
void addTileAndCache(Index, const Coord &, const ValueType &, bool, AccessorT &)
Definition: LeafNode.h:1642
static void evalNodeOrigin(Coord &xyz)
Compute the origin of the leaf node that contains the voxel with the given coordinates.
Definition: LeafNode.h:911
Leaf nodes have no children, so their child iterators have no get/set accessors.
Definition: LeafNode.h:271
LeafNode * touchLeafAndCache(const Coord &, AccessorT &)
Definition: LeafNode.h:760
ChildOnIter beginChildOn()
Definition: LeafNode.h:344
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:623
static CoordBBox inf()
Return an "infinite" bounding box, as defined by the Coord value range.
Definition: Coord.h:346
ValueT & getItem(Index pos) const
Definition: LeafNode.h:247
Index64 onLeafVoxelCount() const
Definition: LeafNode.h:169
const LeafNode * probeLeafAndCache(const Coord &, AccessorT &) const
Definition: LeafNode.h:779
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:1255
~LeafNode()
Destructor.
Definition: LeafNode.h:1039
Base class for iterators over internal and leaf nodes.
Definition: Iterator.h:56
void getOrigin(Coord &origin) const
Definition: LeafNode.h:202
ValueOffCIter beginValueOff() const
Definition: LeafNode.h:324
static Index getValueLevelAndCache(const Coord &, AccessorT &)
Return the LEVEL (=0) at which leaf node values reside.
Definition: LeafNode.h:643
void writeCompressedValues(std::ostream &os, ValueT *srcBuf, Index srcCount, const MaskT &valueMask, const MaskT &childMask, bool toHalf)
Definition: Compression.h:672
std::ostream & operator<<(std::ostream &os, const typename LeafNode< T, Log2Dim >::Buffer &buf)
Definition: LeafNode.h:2027
ValueType * mData
Definition: LeafBuffer.h:225
void writeTopology(std::ostream &os, bool toHalf=false) const
Write out just the topology.
Definition: LeafNode.h:1331
ValueOffIter endValueOff()
Definition: LeafNode.h:335
SameConfiguration<OtherNodeType>::value is true if and only if OtherNodeType is the type of a LeafNod...
Definition: LeafNode.h:91
Definition: LeafNode.h:233
T ValueType
Definition: LeafNode.h:68
CoordBBox getNodeBoundingBox() const
Return the bounding box of this node, i.e., the full index space spanned by this leaf node.
Definition: LeafNode.h:195
typename NodeMaskType::DenseIterator MaskDenseIterator
Definition: LeafNode.h:229
Axis-aligned bounding box of signed integer coordinates.
Definition: Coord.h:275
Definition: PointDataGrid.h:201
void setValue(const ValueT &value) const
Definition: LeafNode.h:256
void setValuesOff()
Mark all voxels as inactive but don't change their values.
Definition: LeafNode.h:495
const Coord & min() const
Definition: Coord.h:348
ChildOffCIter beginChildOff() const
Definition: LeafNode.h:346
OPENVDB_API uint32_t getDataCompression(std::ios_base &)
Return a bitwise OR of compression option flags (COMPRESS_ZIP, COMPRESS_ACTIVE_MASK,...
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:580
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:1730
bool getItem(Index pos, void *&child, NonConstValueT &value) const
Definition: LeafNode.h:289
void denseFill(const CoordBBox &bbox, const ValueType &value, bool active=true)
Set all voxels within an axis-aligned box to the specified value and active state.
Definition: LeafNode.h:511
const ValueType & getValueAndCache(const Coord &xyz, AccessorT &) const
Return the value of the voxel at the given coordinates.
Definition: LeafNode.h:558
static Index coordToOffset(const Coord &xyz)
Return the linear table offset of the given global or local coordinates.
Definition: LeafNode.h:1059
bool isInside(const Coord &xyz) const
Return true if point (x, y, z) is inside this bounding box.
Definition: Coord.h:427
Definition: LeafNode.h:232
CombineArgs & setARef(const AValueType &a)
Redirect the A value to a new external source.
Definition: Types.h:670
Coord offsetToGlobalCoord(Index n) const
Return the global coordinates for a linear table offset.
Definition: LeafNode.h:1083
OffIterator beginOff() const
Definition: NodeMasks.h:356
DenseIter()
Definition: LeafNode.h:286
void addTile(Index level, const Coord &, const ValueType &, bool)
Definition: LeafNode.h:1625
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:1152
void getNodes(ArrayT &) const
Definition: LeafNode.h:747
Bit mask for the internal and leaf nodes of VDB. This is a 64-bit implementation.
Definition: NodeMasks.h:309
void expand(ValueType padding)
Pad this bounding box with the specified padding.
Definition: Coord.h:445
bool operator!=(const LeafNode &other) const
Definition: LeafNode.h:224
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:1144
ValueOffCIter cbeginValueOff() const
Definition: LeafNode.h:323
void modifyValueAndActiveStateAndCache(const Coord &xyz, const ModifyOp &op, AccessorT &)
Definition: LeafNode.h:597
ChildOffCIter cendChildOff() const
Definition: LeafNode.h:355
OnIterator beginOn() const
Definition: NodeMasks.h:354
Definition: LeafNode.h:232
void stealNodes(ArrayT &, const ValueType &, bool)
Definition: LeafNode.h:748
bool isApproxEqual(const Type &a, const Type &b)
Return true if a is equal to b to within the default floating-point comparison tolerance.
Definition: Math.h:378
void visit2(IterT &otherIter, VisitorOp &, bool otherIsLHS=false)
Definition: LeafNode.h:1981
Int32 y() const
Definition: Coord.h:159
static Index dim()
Return the number of voxels in each coordinate dimension.
Definition: LeafNode.h:149
bool resultIsActive() const
Definition: Types.h:681
void combine(const LeafNode &other, CombineOp &op)
Definition: LeafNode.h:1772
uint32_t Index32
Definition: Types.h:59
const NodeT * probeConstNode(const Coord &) const
Definition: LeafNode.h:746
static void doVisit(NodeT &, VisitorOp &)
Definition: LeafNode.h:1919
Definition: LeafNode.h:280
void getOrigin(Int32 &x, Int32 &y, Int32 &z) const
Definition: LeafNode.h:203
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h:180
void setOrigin(const Coord &origin)
Set the grid index coordinates of this node's local origin.
Definition: LeafNode.h:198
NodeT * probeNodeAndCache(const Coord &, AccessorT &)
Definition: LeafNode.h:762
ChildAllCIter cbeginChildAll() const
Definition: LeafNode.h:348
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,...
Definition: LeafNode.h:1747
void addLeafAndCache(LeafNode *, AccessorT &)
Definition: LeafNode.h:740
void translate(const Coord &t)
Translate this bounding box by (tx, ty, tz).
Definition: Coord.h:485
OPENVDB_API uint32_t getFormatVersion(std::ios_base &)
Return the file format version number associated with the given input stream.
static CoordBBox createCube(const Coord &min, ValueType dim)
Definition: Coord.h:340
ChildAllIter beginChildAll()
Definition: LeafNode.h:350
static bool hasActiveTiles()
Return false since leaf nodes never contain tiles.
Definition: LeafNode.h:503
Int32 x() const
Definition: Coord.h:158
void setValuesOn()
Mark all voxels as active but don't change their values.
Definition: LeafNode.h:493
uint64_t Index64
Definition: Types.h:60
const Coord & max() const
Definition: Coord.h:349
bool isValueOnAndCache(const Coord &xyz, AccessorT &) const
Return true if the voxel at the given coordinates is active.
Definition: LeafNode.h:566
void skipCompressedValues(bool seekable, std::istream &, bool fromHalf)
Definition: LeafNode.h:1343
Base class for dense iterators over internal and leaf nodes.
Definition: Iterator.h:205
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:1210
void modifyValue(Index offset, const ModifyOp &op)
Apply a functor to the value of the voxel at the given offset and mark the voxel as active.
Definition: LeafNode.h:458
T negative(const T &val)
Return the unary negation of the given value.
Definition: Math.h:108
OPENVDB_API SharedPtr< StreamMetadata > getStreamMetadataPtr(std::ios_base &)
Return a shared pointer to an object that stores metadata (file format, compression scheme,...
ValueAllCIter cendValueAll() const
Definition: LeafNode.h:336
static Index log2dim()
Return log2 of the dimension of this LeafNode, e.g. 3 if dimensions are 8^3.
Definition: LeafNode.h:147
Coord & setY(Int32 y)
Definition: Coord.h:108
bool isValueOn(Index offset) const
Return true if the voxel at the given offset is active.
Definition: LeafNode.h:500
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:1512
void visit2Node(OtherLeafNodeType &other, VisitorOp &)
Definition: LeafNode.h:1933
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:571
static Index numValues()
Return the total number of voxels represented by this LeafNode.
Definition: LeafNode.h:153
ValueIter()
Definition: LeafNode.h:244
void setValueMaskOff(Index n)
Definition: LeafNode.h:906
void merge(const LeafNode &)
Definition: LeafNode.h:1677
Definition: version.h:221
NodeMaskType & getValueMask()
Definition: LeafNode.h:897
void setValueOff(const Coord &xyz)
Mark the voxel at the given coordinates as inactive but don't change its value.
Definition: LeafNode.h:430
void 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:422
ValueAllIter endValueAll()
Definition: LeafNode.h:338
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition: version.h:128
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:472
void setValueOn(const Coord &xyz)
Mark the voxel at the given coordinates as active but don't change its value.
Definition: LeafNode.h:440
DenseIter(const MaskDenseIterator &iter, NodeT *parent)
Definition: LeafNode.h:287
NodeT * stealNode(const Coord &, const ValueType &, bool)
Definition: LeafNode.h:742
ChildAllCIter cendChildAll() const
Definition: LeafNode.h:358
LeafNode * probeLeafAndCache(const Coord &, AccessorT &)
Definition: LeafNode.h:771
ChildAllCIter beginChildAll() const
Definition: LeafNode.h:349
const LeafNode * probeConstLeafAndCache(const Coord &, AccessorT &) const
Definition: LeafNode.h:777
Definition: NodeMasks.h:210
typename std::remove_const< UnsetItemT >::type NonConstValueType
Definition: Iterator.h:211
bool operator==(const LeafNode &other) const
Check for buffer, state and origin equivalence.
Definition: LeafNode.h:1474
bool isChildMaskOn(Index) const
Definition: LeafNode.h:900
ChildOnCIter cbeginChildOn() const
Definition: LeafNode.h:342
bool isConstant(ValueType &firstValue, bool &state, const ValueType &tolerance=zeroVal< ValueType >()) const
Definition: LeafNode.h:1520
static const Index SIZE
Definition: LeafNode.h:80
ChildOnCIter cendChildOn() const
Definition: LeafNode.h:352
Definition: Exceptions.h:40
This struct collects both input and output arguments to "grid combiner" functors used with the tree::...
Definition: Types.h:617
const ValueType & getValue(const Coord &xyz) const
Return the value of the voxel at the given coordinates.
Definition: LeafNode.h:1094
bool operator==(const Vec3< T0 > &v0, const Vec3< T1 > &v1)
Equality operator, does exact floating point comparisons.
Definition: Vec3.h:498
void intersect(const CoordBBox &bbox)
Intersect this bounding box with the given bounding box.
Definition: Coord.h:471
bool isOn(Index32 n) const
Return true if the nth bit is on.
Definition: NodeMasks.h:504
ChildIter()
Definition: LeafNode.h:274
const Buffer & buffer() const
Definition: LeafNode.h:368
NodeT * probeNode(const Coord &)
Definition: LeafNode.h:744
bool isValueMaskOn() const
Definition: LeafNode.h:893
SharedPtr< MappedFile > Ptr
Definition: io.h:163
void setValueOff(Index offset)
Mark the voxel at the given offset as inactive but don't change its value.
Definition: LeafNode.h:432
Tag dispatch class that distinguishes constructors during file input.
Definition: Types.h:752
ValueConverter<T>::Type is the type of a LeafNode having the same dimensions as this node but a diffe...
Definition: LeafNode.h:86
Index medianOn(ValueType &value, ValueType *tmp=nullptr) const
Computes the median value of all the active voxels in this node.
Definition: LeafNode.h:1574
Index64 onVoxelCount() const
Return the number of voxels marked On.
Definition: LeafNode.h:166
const NodeMaskType & valueMask() const
Definition: LeafNode.h:898
static Index size()
Return the number of values contained in this buffer.
Definition: LeafBuffer.h:180