4 #ifndef OPENVDB_TREE_LEAFNODE_HAS_BEEN_INCLUDED 5 #define OPENVDB_TREE_LEAFNODE_HAS_BEEN_INCLUDED 17 #include <type_traits> 29 template<Index,
typename>
struct SameLeafConfig;
36 template<
typename T, Index Log2Dim>
51 NUM_VALUES = 1 << 3 * Log2Dim,
52 NUM_VOXELS = NUM_VALUES,
58 template<
typename OtherValueType>
63 template<
typename OtherNodeType>
76 explicit LeafNode(
const Coord& coords,
97 template<
typename OtherValueType>
101 template<
typename OtherValueType>
106 template<
typename OtherValueType>
148 bool isEmpty()
const {
return mValueMask.isOff(); }
150 bool isDense()
const {
return mValueMask.isOn(); }
152 bool isAllocated()
const {
return !mBuffer.isOutOfCore() && !mBuffer.empty(); }
163 void evalActiveBoundingBox(
CoordBBox& bbox,
bool visitVoxels =
true)
const;
170 void setOrigin(
const Coord& origin) { mOrigin = origin; }
173 const Coord&
origin()
const {
return mOrigin; }
174 void getOrigin(Coord& origin)
const { origin = mOrigin; }
179 static Index coordToOffset(
const Coord& xyz);
182 static Coord offsetToLocalCoord(
Index n);
184 Coord offsetToGlobalCoord(
Index n)
const;
186 #if OPENVDB_ABI_VERSION_NUMBER >= 9 194 std::string str()
const;
198 template<
typename OtherType, Index OtherLog2Dim>
214 template<
typename MaskIterT,
typename NodeT,
typename ValueT,
typename TagT>
219 MaskIterT, ValueIter<MaskIterT, NodeT, ValueT, TagT>, NodeT, ValueT>
226 ValueT&
getItem(
Index pos)
const {
return this->parent().getValue(pos); }
227 ValueT&
getValue()
const {
return this->parent().getValue(this->pos()); }
232 this->parent().setValueOnly(pos, value);
237 this->parent().setValueOnly(this->pos(), value);
241 template<
typename ModifyOp>
242 void modifyItem(
Index n,
const ModifyOp& op)
const { this->parent().modifyValue(n, op); }
244 template<
typename ModifyOp>
245 void modifyValue(
const ModifyOp& op)
const { this->parent().modifyValue(this->pos(), op); }
249 template<
typename MaskIterT,
typename NodeT,
typename TagT>
251 public SparseIteratorBase<MaskIterT, ChildIter<MaskIterT, NodeT, TagT>, NodeT, ValueType>
258 template<
typename NodeT,
typename ValueT,
typename TagT>
260 MaskDenseIterator, DenseIter<NodeT, ValueT, TagT>, NodeT, void, ValueT>
270 value = this->parent().getValue(pos);
281 this->parent().setValueOnly(pos, value);
356 void readTopology(std::istream& is,
bool fromHalf =
false);
360 void writeTopology(std::ostream& os,
bool toHalf =
false)
const;
365 void readBuffers(std::istream& is,
bool fromHalf =
false);
370 void readBuffers(std::istream& is,
const CoordBBox& bbox,
bool fromHalf =
false);
374 void writeBuffers(std::ostream& os,
bool toHalf =
false)
const;
376 size_t streamingSize(
bool toHalf =
false)
const;
382 const ValueType& getValue(
const Coord& xyz)
const;
389 bool probeValue(
const Coord& xyz,
ValueType& val)
const;
399 void setActiveState(
const Coord& xyz,
bool on);
404 void setValueOnly(
const Coord& xyz,
const ValueType& val);
409 void setValueOff(
const Coord& xyz) { mValueMask.setOff(LeafNode::coordToOffset(xyz)); }
414 void setValueOff(
const Coord& xyz,
const ValueType& val);
419 void setValueOn(
const Coord& xyz) { mValueMask.setOn(LeafNode::coordToOffset(xyz)); }
424 this->setValueOn(LeafNode::coordToOffset(xyz), val);
430 mBuffer.setValue(offset, val);
431 mValueMask.setOn(offset);
436 template<
typename ModifyOp>
439 mBuffer.loadValues();
440 if (!mBuffer.empty()) {
444 mValueMask.setOn(offset);
450 template<
typename ModifyOp>
453 this->modifyValue(this->coordToOffset(xyz), op);
457 template<
typename ModifyOp>
460 mBuffer.loadValues();
461 if (!mBuffer.empty()) {
462 const Index offset = this->coordToOffset(xyz);
463 bool state = mValueMask.isOn(offset);
467 mValueMask.set(offset, state);
492 this->fill(bbox, value, active);
498 void fill(
const ValueType& value,
bool active);
511 template<
typename DenseT>
530 template<
typename DenseT>
536 template<
typename AccessorT>
539 return this->getValue(xyz);
544 template<
typename AccessorT>
549 template<
typename AccessorT>
552 this->setValueOn(xyz, val);
558 template<
typename AccessorT>
561 this->setValueOnly(xyz, val);
567 template<
typename ModifyOp,
typename AccessorT>
570 this->modifyValue(xyz, op);
575 template<
typename ModifyOp,
typename AccessorT>
578 this->modifyValueAndActiveState(xyz, op);
583 template<
typename AccessorT>
586 this->setValueOff(xyz, value);
592 template<
typename AccessorT>
595 this->setActiveState(xyz, on);
601 template<
typename AccessorT>
604 return this->probeValue(xyz, val);
610 template<
typename AccessorT>
613 const Index offset = this->coordToOffset(xyz);
614 state = mValueMask.isOn(offset);
616 return mBuffer[offset];
621 template<
typename AccessorT>
641 template<MergePolicy Policy>
void merge(
const LeafNode&);
642 template<MergePolicy Policy>
void merge(
const ValueType& tileValue,
bool tileActive);
643 template<MergePolicy Policy>
652 template<
typename OtherType>
666 template<
typename OtherType>
680 template<
typename OtherType>
683 template<
typename CombineOp>
685 template<
typename CombineOp>
688 template<
typename CombineOp,
typename OtherType >
689 void combine2(
const LeafNode& other,
const OtherType&,
bool valueIsActive, CombineOp&);
690 template<
typename CombineOp,
typename OtherNodeT >
691 void combine2(
const ValueType&,
const OtherNodeT& other,
bool valueIsActive, CombineOp&);
692 template<
typename CombineOp,
typename OtherNodeT >
693 void combine2(
const LeafNode& b0,
const OtherNodeT& b1, CombineOp&);
700 template<
typename BBoxOp>
void visitActiveBBox(BBoxOp&)
const;
702 template<
typename VisitorOp>
void visit(VisitorOp&);
703 template<
typename VisitorOp>
void visit(VisitorOp&)
const;
705 template<
typename OtherLeafNodeType,
typename VisitorOp>
706 void visit2Node(OtherLeafNodeType& other, VisitorOp&);
707 template<
typename OtherLeafNodeType,
typename VisitorOp>
708 void visit2Node(OtherLeafNodeType& other, VisitorOp&)
const;
709 template<
typename IterT,
typename VisitorOp>
710 void visit2(IterT& otherIter, VisitorOp&,
bool otherIsLHS =
false);
711 template<
typename IterT,
typename VisitorOp>
712 void visit2(IterT& otherIter, VisitorOp&,
bool otherIsLHS =
false)
const;
718 template<
typename AccessorT>
720 template<
typename NodeT>
722 template<
typename NodeT>
724 template<
typename NodeT>
726 template<
typename ArrayT>
void getNodes(ArrayT&)
const {}
732 template<
typename AccessorT>
733 void addTileAndCache(
Index,
const Coord&,
const ValueType&,
bool, AccessorT&);
738 template<
typename AccessorT>
740 template<
typename NodeT,
typename AccessorT>
745 return reinterpret_cast<NodeT*
>(
this);
749 template<
typename AccessorT>
755 template<
typename AccessorT>
757 template<
typename AccessorT>
760 template<
typename NodeT,
typename AccessorT>
765 return reinterpret_cast<const NodeT*
>(
this);
779 bool isConstant(
ValueType& firstValue,
bool& state,
780 const ValueType& tolerance = zeroVal<ValueType>())
const;
794 bool& state,
const ValueType& tolerance = zeroVal<ValueType>())
const;
849 friend class ::TestLeaf;
850 template<
typename>
friend class ::TestLeafIO;
887 inline void skipCompressedValues(
bool seekable, std::istream&,
bool fromHalf);
892 template<
typename NodeT,
typename VisitorOp,
typename ChildAllIterT>
893 static inline void doVisit(NodeT&, VisitorOp&);
895 template<
typename NodeT,
typename OtherNodeT,
typename VisitorOp,
896 typename ChildAllIterT,
typename OtherChildAllIterT>
897 static inline void doVisit2Node(NodeT&
self, OtherNodeT& other, VisitorOp&);
899 template<
typename NodeT,
typename VisitorOp,
900 typename ChildAllIterT,
typename OtherChildAllIterT>
901 static inline void doVisit2(NodeT&
self, OtherChildAllIterT&, VisitorOp&,
bool otherIsLHS);
910 #if OPENVDB_ABI_VERSION_NUMBER >= 9 923 template<Index Dim1,
typename NodeT2>
926 template<Index Dim1,
typename T2>
934 template<
typename T, Index Log2Dim>
943 template<
typename T, Index Log2Dim>
948 mOrigin(xyz & (~(
DIM - 1)))
953 template<
typename T, Index Log2Dim>
958 mOrigin(xyz & (~(
DIM - 1)))
963 template<
typename T, Index Log2Dim>
966 : mBuffer(other.mBuffer)
968 , mOrigin(other.mOrigin)
969 #if OPENVDB_ABI_VERSION_NUMBER >= 9
970 , mTransientData(other.mTransientData)
977 template<
typename T, Index Log2Dim>
978 template<
typename OtherValueType>
982 , mOrigin(other.mOrigin)
983 #if OPENVDB_ABI_VERSION_NUMBER >= 9
984 , mTransientData(other.mTransientData)
989 static inline ValueType convertValue(
const OtherValueType& val) {
return ValueType(val); }
993 mBuffer[i] = Local::convertValue(other.mBuffer[i]);
998 template<
typename T, Index Log2Dim>
999 template<
typename OtherValueType>
1003 : mBuffer(background)
1005 , mOrigin(other.mOrigin)
1006 #if OPENVDB_ABI_VERSION_NUMBER >= 9
1007 , mTransientData(other.mTransientData)
1013 template<
typename T, Index Log2Dim>
1014 template<
typename OtherValueType>
1019 , mOrigin(other.mOrigin)
1020 #if OPENVDB_ABI_VERSION_NUMBER >= 9
1021 , mTransientData(other.mTransientData)
1025 mBuffer[i] = (mValueMask.
isOn(i) ? onValue : offValue);
1030 template<
typename T, Index Log2Dim>
1037 template<
typename T, Index Log2Dim>
1041 std::ostringstream ostr;
1042 ostr <<
"LeafNode @" << mOrigin <<
": " << mBuffer;
1050 template<
typename T, Index Log2Dim>
1054 assert ((xyz[0] & (
DIM-1u)) <
DIM && (xyz[1] & (
DIM-1u)) <
DIM && (xyz[2] & (
DIM-1u)) <
DIM);
1055 return ((xyz[0] & (
DIM-1u)) << 2*Log2Dim)
1056 + ((xyz[1] & (
DIM-1u)) << Log2Dim)
1057 + (xyz[2] & (
DIM-1u));
1060 template<
typename T, Index Log2Dim>
1064 assert(n<(1<< 3*Log2Dim));
1066 xyz.setX(n >> 2*Log2Dim);
1067 n &= ((1<<2*Log2Dim)-1);
1068 xyz.setY(n >> Log2Dim);
1069 xyz.setZ(n & ((1<<Log2Dim)-1));
1074 template<
typename T, Index Log2Dim>
1085 template<
typename ValueT, Index Log2Dim>
1086 inline const ValueT&
1092 template<
typename ValueT, Index Log2Dim>
1093 inline const ValueT&
1096 assert(offset <
SIZE);
1097 return mBuffer[offset];
1101 template<
typename T, Index Log2Dim>
1108 template<
typename T, Index Log2Dim>
1112 assert(offset <
SIZE);
1113 val = mBuffer[offset];
1114 return mValueMask.
isOn(offset);
1118 template<
typename T, Index Log2Dim>
1125 template<
typename T, Index Log2Dim>
1129 assert(offset <
SIZE);
1131 mValueMask.
setOff(offset);
1135 template<
typename T, Index Log2Dim>
1143 template<
typename T, Index Log2Dim>
1150 template<
typename T, Index Log2Dim>
1161 template<
typename T, Index Log2Dim>
1166 if (!clipBBox.hasOverlap(nodeBBox)) {
1168 this->
fill(background,
false);
1169 }
else if (clipBBox.isInside(nodeBBox)) {
1179 nodeBBox.intersect(clipBBox);
1181 int &x = xyz.x(), &y = xyz.y(), &z = xyz.z();
1182 for (x = nodeBBox.min().x(); x <= nodeBBox.max().x(); ++x) {
1183 for (y = nodeBBox.min().y(); y <= nodeBBox.max().y(); ++y) {
1184 for (z = nodeBBox.min().z(); z <= nodeBBox.max().z(); ++z) {
1201 template<
typename T, Index Log2Dim>
1208 clippedBBox.intersect(bbox);
1209 if (!clippedBBox)
return;
1211 for (
Int32 x = clippedBBox.min().x(); x <= clippedBBox.max().x(); ++x) {
1212 const Index offsetX = (x & (
DIM-1u)) << 2*Log2Dim;
1213 for (
Int32 y = clippedBBox.min().y(); y <= clippedBBox.max().y(); ++y) {
1214 const Index offsetXY = offsetX + ((y & (
DIM-1u)) << Log2Dim);
1215 for (
Int32 z = clippedBBox.min().z(); z <= clippedBBox.max().z(); ++z) {
1216 const Index offset = offsetXY + (z & (
DIM-1u));
1217 mBuffer[offset] =
value;
1218 mValueMask.
set(offset, active);
1224 template<
typename T, Index Log2Dim>
1228 mBuffer.
fill(value);
1231 template<
typename T, Index Log2Dim>
1235 mBuffer.
fill(value);
1236 mValueMask.
set(active);
1243 template<
typename T, Index Log2Dim>
1244 template<
typename DenseT>
1248 mBuffer.loadValues();
1250 using DenseValueType =
typename DenseT::ValueType;
1252 const size_t xStride = dense.xStride(), yStride = dense.yStride(), zStride = dense.zStride();
1253 const Coord&
min = dense.bbox().min();
1254 DenseValueType* t0 = dense.data() + zStride * (bbox.min()[2] - min[2]);
1255 const T* s0 = &mBuffer[bbox.min()[2] & (
DIM-1u)];
1256 for (
Int32 x = bbox.min()[0], ex = bbox.max()[0] + 1; x < ex; ++x) {
1257 DenseValueType* t1 = t0 + xStride * (x - min[0]);
1258 const T* s1 = s0 + ((x & (
DIM-1u)) << 2*Log2Dim);
1259 for (
Int32 y = bbox.min()[1], ey = bbox.max()[1] + 1; y < ey; ++y) {
1260 DenseValueType* t2 = t1 + yStride * (y - min[1]);
1261 const T* s2 = s1 + ((y & (
DIM-1u)) << Log2Dim);
1262 for (
Int32 z = bbox.min()[2], ez = bbox.max()[2] + 1; z < ez; ++z, t2 += zStride) {
1263 *t2 = DenseValueType(*s2++);
1270 template<
typename T, Index Log2Dim>
1271 template<
typename DenseT>
1278 using DenseValueType =
typename DenseT::ValueType;
1280 const size_t xStride = dense.xStride(), yStride = dense.yStride(), zStride = dense.zStride();
1281 const Coord&
min = dense.bbox().min();
1283 const DenseValueType* s0 = dense.data() + zStride * (bbox.min()[2] - min[2]);
1284 const Int32 n0 = bbox.min()[2] & (
DIM-1u);
1285 for (
Int32 x = bbox.min()[0], ex = bbox.max()[0]+1; x < ex; ++x) {
1286 const DenseValueType* s1 = s0 + xStride * (x - min[0]);
1288 for (
Int32 y = bbox.min()[1], ey = bbox.max()[1]+1; y < ey; ++y) {
1289 const DenseValueType* s2 = s1 + yStride * (y - min[1]);
1291 for (
Int32 z = bbox.min()[2], ez = bbox.max()[2]+1; z < ez; ++z, ++n2, s2 += zStride) {
1294 mBuffer[n2] = background;
1296 mValueMask.
setOn(n2);
1308 template<
typename T, Index Log2Dim>
1312 mValueMask.
load(is);
1316 template<
typename T, Index Log2Dim>
1320 mValueMask.
save(os);
1328 template<
typename T, Index Log2Dim>
1334 io::readCompressedValues<ValueType, NodeMaskType>(
1335 is,
nullptr,
SIZE, mValueMask, fromHalf);
1344 template<
typename T, Index Log2Dim>
1348 this->
readBuffers(is, CoordBBox::inf(), fromHalf);
1352 template<
typename T, Index Log2Dim>
1357 const bool seekable = meta && meta->seekable();
1359 std::streamoff maskpos = is.tellg();
1363 mValueMask.
seek(is);
1366 mValueMask.
load(is);
1369 int8_t numBuffers = 1;
1372 is.read(reinterpret_cast<char*>(&mOrigin),
sizeof(Coord::ValueType) * 3);
1375 is.read(reinterpret_cast<char*>(&numBuffers),
sizeof(int8_t));
1379 if (!clipBBox.hasOverlap(nodeBBox)) {
1383 mBuffer.setOutOfCore(
false);
1390 const bool delayLoad = ((mappedFile.get() !=
nullptr) && clipBBox.isInside(nodeBBox));
1393 mBuffer.setOutOfCore(
true);
1394 mBuffer.
mFileInfo =
new typename Buffer::FileInfo;
1397 mBuffer.
mFileInfo->mapping = mappedFile;
1406 mBuffer.setOutOfCore(
false);
1409 T background = zeroVal<T>();
1411 background = *
static_cast<const T*
>(bgPtr);
1413 this->
clip(clipBBox, background);
1417 if (numBuffers > 1) {
1422 for (
int i = 1; i < numBuffers; ++i) {
1426 io::readData<T>(is, temp.
mData,
SIZE, zipped);
1432 if (meta) meta->setLeaf(meta->leaf() + 1);
1436 template<
typename T, Index Log2Dim>
1441 mValueMask.
save(os);
1443 mBuffer.loadValues();
1453 template<
typename T, Index Log2Dim>
1457 return mOrigin == other.mOrigin &&
1459 mBuffer == other.mBuffer;
1463 template<
typename T, Index Log2Dim>
1469 return sizeof(*this) + mBuffer.
memUsage() -
sizeof(mBuffer);
1473 template<
typename T, Index Log2Dim>
1483 template<
typename T, Index Log2Dim>
1488 if (bbox.isInside(this_bbox))
return;
1492 for(; iter; ++iter) this_bbox.expand(this->offsetToLocalCoord(iter.pos()));
1493 this_bbox.translate(this->
origin());
1495 bbox.expand(this_bbox);
1500 template<
typename T, Index Log2Dim>
1501 template<
typename OtherType, Index OtherLog2Dim>
1506 return (Log2Dim == OtherLog2Dim && mValueMask == other->
getValueMask());
1509 template<
typename T, Index Log2Dim>
1515 if (!mValueMask.
isConstant(state))
return false;
1516 firstValue = mBuffer[0];
1523 template<
typename T, Index Log2Dim>
1530 if (!mValueMask.
isConstant(state))
return false;
1531 minValue = maxValue = mBuffer[0];
1533 const T& v = mBuffer[i];
1535 if ((maxValue - v) > tolerance)
return false;
1537 }
else if (v > maxValue) {
1538 if ((v - minValue) > tolerance)
return false;
1545 template<
typename T, Index Log2Dim>
1549 std::unique_ptr<T[]> data(
nullptr);
1550 if (tmp ==
nullptr) {
1554 if (tmp != mBuffer.
data()) {
1555 const T* src = mBuffer.
data();
1556 for (T* dst = tmp; dst-tmp <
NUM_VALUES;) *dst++ = *src++;
1558 static const size_t midpoint = (
NUM_VALUES - 1) >> 1;
1559 std::nth_element(tmp, tmp + midpoint, tmp +
NUM_VALUES);
1560 return tmp[midpoint];
1563 template<
typename T, Index Log2Dim>
1571 }
else if (count == 0) {
1574 std::unique_ptr<T[]> data(
nullptr);
1575 if (tmp ==
nullptr) {
1576 data.reset(
new T[count]);
1579 for (
auto iter=this->
cbeginValueOn(); iter; ++iter) *tmp++ = *iter;
1580 T *begin = tmp - count;
1581 const size_t midpoint = (count - 1) >> 1;
1582 std::nth_element(begin, begin + midpoint, tmp);
1583 value = begin[midpoint];
1587 template<
typename T, Index Log2Dim>
1595 }
else if (count == 0) {
1598 std::unique_ptr<T[]> data(
nullptr);
1599 if (tmp ==
nullptr) {
1600 data.reset(
new T[count]);
1603 for (
auto iter=this->
cbeginValueOff(); iter; ++iter) *tmp++ = *iter;
1604 T *begin = tmp - count;
1605 const size_t midpoint = (count - 1) >> 1;
1606 std::nth_element(begin, begin + midpoint, tmp);
1607 value = begin[midpoint];
1614 template<
typename T, Index Log2Dim>
1621 template<
typename T, Index Log2Dim>
1625 assert(offset <
SIZE);
1630 template<
typename T, Index Log2Dim>
1631 template<
typename AccessorT>
1634 const ValueType& val,
bool active, AccessorT&)
1636 this->
addTile(level, xyz, val, active);
1643 template<
typename T, Index Log2Dim>
1652 for (iter = this->mValueMask.
beginOff(); iter; ++iter) {
1655 inactiveValue = newBackground;
1663 template<
typename T, Index Log2Dim>
1664 template<MergePolicy Policy>
1673 for (; iter; ++iter) {
1675 if (mValueMask.
isOff(n)) {
1676 mBuffer[n] = other.mBuffer[n];
1677 mValueMask.
setOn(n);
1683 template<
typename T, Index Log2Dim>
1684 template<MergePolicy Policy>
1689 this->
template merge<Policy>(other);
1692 template<
typename T, Index Log2Dim>
1693 template<MergePolicy Policy>
1701 if (!tileActive)
return;
1704 const Index n = iter.pos();
1705 mBuffer[n] = tileValue;
1706 mValueMask.
setOn(n);
1712 template<
typename T, Index Log2Dim>
1713 template<
typename OtherType>
1720 template<
typename T, Index Log2Dim>
1721 template<
typename OtherType>
1729 template<
typename T, Index Log2Dim>
1730 template<
typename OtherType>
1738 template<
typename T, Index Log2Dim>
1745 mBuffer[i] = -mBuffer[i];
1753 template<
typename T, Index Log2Dim>
1754 template<
typename CombineOp>
1763 .setAIsActive(mValueMask.
isOn(i))
1764 .setBRef(other.mBuffer[i])
1766 .setResultRef(mBuffer[i]));
1772 template<
typename T, Index Log2Dim>
1773 template<
typename CombineOp>
1780 args.
setBRef(value).setBIsActive(valueIsActive);
1783 .setAIsActive(mValueMask.
isOn(i))
1784 .setResultRef(mBuffer[i]));
1793 template<
typename T, Index Log2Dim>
1794 template<
typename CombineOp,
typename OtherType>
1797 bool valueIsActive, CombineOp& op)
1802 args.
setBRef(value).setBIsActive(valueIsActive);
1804 op(args.
setARef(other.mBuffer[i])
1806 .setResultRef(mBuffer[i]));
1812 template<
typename T, Index Log2Dim>
1813 template<
typename CombineOp,
typename OtherNodeT>
1816 bool valueIsActive, CombineOp& op)
1821 args.
setARef(value).setAIsActive(valueIsActive);
1823 op(args.
setBRef(other.mBuffer[i])
1824 .setBIsActive(other.valueMask().isOn(i))
1825 .setResultRef(mBuffer[i]));
1831 template<
typename T, Index Log2Dim>
1832 template<
typename CombineOp,
typename OtherNodeT>
1841 op(args.
setARef(b0.mBuffer[i])
1843 .setBRef(b1.mBuffer[i])
1844 .setBIsActive(b1.valueMask().isOn(i))
1845 .setResultRef(mBuffer[i]));
1854 template<
typename T, Index Log2Dim>
1855 template<
typename BBoxOp>
1859 if (op.template descent<LEVEL>()) {
1861 op.template operator()<
LEVEL>(CoordBBox::createCube(i.getCoord(), 1));
1869 template<
typename T, Index Log2Dim>
1870 template<
typename VisitorOp>
1874 doVisit<LeafNode, VisitorOp, ChildAllIter>(*
this, op);
1878 template<
typename T, Index Log2Dim>
1879 template<
typename VisitorOp>
1883 doVisit<const LeafNode, VisitorOp, ChildAllCIter>(*
this, op);
1887 template<
typename T, Index Log2Dim>
1888 template<
typename NodeT,
typename VisitorOp,
typename ChildAllIterT>
1892 for (ChildAllIterT iter =
self.
beginChildAll(); iter; ++iter) {
1901 template<
typename T, Index Log2Dim>
1902 template<
typename OtherLeafNodeType,
typename VisitorOp>
1907 typename OtherLeafNodeType::ChildAllIter>(*
this, other, op);
1911 template<
typename T, Index Log2Dim>
1912 template<
typename OtherLeafNodeType,
typename VisitorOp>
1917 typename OtherLeafNodeType::ChildAllCIter>(*
this, other, op);
1921 template<
typename T, Index Log2Dim>
1924 typename OtherNodeT,
1926 typename ChildAllIterT,
1927 typename OtherChildAllIterT>
1932 static_assert(OtherNodeT::SIZE == NodeT::SIZE,
1933 "can't visit nodes of different sizes simultaneously");
1934 static_assert(OtherNodeT::LEVEL == NodeT::LEVEL,
1935 "can't visit nodes at different tree levels simultaneously");
1937 ChildAllIterT iter =
self.beginChildAll();
1938 OtherChildAllIterT otherIter = other.beginChildAll();
1940 for ( ; iter && otherIter; ++iter, ++otherIter) {
1941 op(iter, otherIter);
1949 template<
typename T, Index Log2Dim>
1950 template<
typename IterT,
typename VisitorOp>
1954 doVisit2<LeafNode, VisitorOp, ChildAllIter, IterT>(
1955 *
this, otherIter, op, otherIsLHS);
1959 template<
typename T, Index Log2Dim>
1960 template<
typename IterT,
typename VisitorOp>
1964 doVisit2<const LeafNode, VisitorOp, ChildAllCIter, IterT>(
1965 *
this, otherIter, op, otherIsLHS);
1969 template<
typename T, Index Log2Dim>
1973 typename ChildAllIterT,
1974 typename OtherChildAllIterT>
1977 VisitorOp& op,
bool otherIsLHS)
1979 if (!otherIter)
return;
1982 for (ChildAllIterT iter =
self.
beginChildAll(); iter; ++iter) {
1983 op(otherIter, iter);
1986 for (ChildAllIterT iter =
self.
beginChildAll(); iter; ++iter) {
1987 op(iter, otherIter);
1996 template<
typename T, Index Log2Dim>
1997 inline std::ostream&
1998 operator<<(std::ostream& os, const typename LeafNode<T, Log2Dim>::Buffer& buf)
2000 for (
Index32 i = 0, N = buf.size(); i < N; ++i) os << buf.mData[i] <<
", ";
2018 #endif // OPENVDB_TREE_LEAFNODE_HAS_BEEN_INCLUDED typename std::remove_const< UnsetItemT >::type NonConstValueType
Definition: Iterator.h:184
const NodeT * probeConstNode(const Coord &) const
This function exists only to enable template instantiation.
Definition: LeafNode.h:725
ChildAllCIter endChildAll() const
Definition: LeafNode.h:338
static Index32 childCount()
Return the child count for this node, which is zero.
Definition: LeafNode.h:137
void setValueOn(const Coord &xyz)
Mark the voxel at the given coordinates as active but don't change its value.
Definition: LeafNode.h:419
bool isValueOn(const Coord &xyz) const
Return true if the voxel at the given coordinates is active.
Definition: LeafNode.h:477
LeafNode * probeLeafAndCache(const Coord &, AccessorT &)
Return a pointer to this node.
Definition: LeafNode.h:750
ChildT * child
Definition: GridBuilder.h:1286
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:490
Index64 onVoxelCount() const
Return the number of voxels marked On.
Definition: LeafNode.h:140
bool isValueOnAndCache(const Coord &xyz, AccessorT &) const
Return true if the voxel at the given coordinates is active.
Definition: LeafNode.h:545
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:437
Index32 Index
Definition: Types.h:54
T ValueType
Definition: LeafNode.h:41
OPENVDB_API uint32_t getFormatVersion(std::ios_base &)
Return the file format version number associated with the given input stream.
bool isOff(Index32 n) const
Return true if the nth bit is off.
Definition: NodeMasks.h:508
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:401
ValueOnIter beginValueOn()
Definition: LeafNode.h:301
const Coord & origin() const
Return the grid index coordinates of this node's local origin.
Definition: LeafNode.h:173
ChildOnCIter cbeginChildOn() const
Definition: LeafNode.h:321
SharedPtr< LeafNode > Ptr
Definition: LeafNode.h:45
void setValueOn(Index offset)
Mark the voxel at the given offset as active but don't change its value.
Definition: LeafNode.h:421
typename NodeMaskType::OnIterator MaskOnIterator
Definition: LeafNode.h:206
static Index64 onTileCount()
Definition: LeafNode.h:145
void setOff(Index32 n)
Set the nth bit off.
Definition: NodeMasks.h:457
void addLeafAndCache(LeafNode *, AccessorT &)
This function exists only to enable template instantiation.
Definition: LeafNode.h:719
ValueOnIter endValueOn()
Definition: LeafNode.h:311
void stealNodes(ArrayT &, const ValueType &, bool)
This function exists only to enable template instantiation.
Definition: LeafNode.h:727
static void evalNodeOrigin(Coord &xyz)
Compute the origin of the leaf node that contains the voxel with the given coordinates.
Definition: LeafNode.h:890
Definition: LeafNode.h:22
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:1723
Index64 offLeafVoxelCount() const
Definition: LeafNode.h:144
std::string str() const
Return a string representation of this node.
Definition: LeafNode.h:1039
Templated block class to hold specific data types and a fixed number of values determined by Log2Dim...
Definition: LeafNode.h:37
Definition: LeafNode.h:212
CoordBBox getNodeBoundingBox() const
Return the bounding box of this node, i.e., the full index space spanned by this leaf node...
Definition: LeafNode.h:167
void setValueMask(const NodeMaskType &mask)
Definition: LeafNode.h:878
const LeafNode * probeLeaf(const Coord &) const
Return a const pointer to this node.
Definition: LeafNode.h:759
CombineArgs & setBRef(const BValueType &b)
Redirect the B value to a new external source.
Definition: Types.h:584
OPENVDB_API const void * getGridBackgroundValuePtr(std::ios_base &)
Return a pointer to the background value of the grid currently being read from or written to the give...
ValueOffIter beginValueOff()
Definition: LeafNode.h:304
void combine2(const LeafNode &other, const OtherType &, bool valueIsActive, CombineOp &)
Definition: LeafNode.h:1796
void modifyItem(Index n, const ModifyOp &op) const
Definition: LeafNode.h:242
void getNodes(ArrayT &) const
This function exists only to enable template instantiation.
Definition: LeafNode.h:726
ChildOffIter beginChildOff()
Definition: LeafNode.h:326
bool getItem(Index pos, void *&child, NonConstValueT &value) const
Definition: LeafNode.h:268
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:346
const LeafNode * probeConstLeafAndCache(const Coord &, AccessorT &) const
Return a const pointer to this node.
Definition: LeafNode.h:756
ValueIter()
Definition: LeafNode.h:223
void modifyValueAndActiveStateAndCache(const Coord &xyz, const ModifyOp &op, AccessorT &)
Definition: LeafNode.h:576
void visit2Node(OtherLeafNodeType &other, VisitorOp &)
Definition: LeafNode.h:1904
void modifyValue(const ModifyOp &op) const
Definition: LeafNode.h:245
ValueAllCIter cendValueAll() const
Definition: LeafNode.h:315
SharedPtr< MappedFile > Ptr
Definition: io.h:136
void writeBuffers(std::ostream &os, bool toHalf=false) const
Write buffers to a stream.
Definition: LeafNode.h:1438
Definition: NodeMasks.h:239
ChildAllCIter cbeginChildAll() const
Definition: LeafNode.h:327
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:451
void nodeCount(std::vector< Index32 > &) const
no-op
Definition: LeafNode.h:133
const ValueType & getValueAndCache(const Coord &xyz, AccessorT &) const
Return the value of the voxel at the given coordinates.
Definition: LeafNode.h:537
void setValueOff(Index offset)
Mark the voxel at the given offset as inactive but don't change its value.
Definition: LeafNode.h:411
OPENVDB_API SharedPtr< MappedFile > getMappedFilePtr(std::ios_base &)
Return a shared pointer to the memory-mapped file with which the given stream is associated, or a null pointer if the stream is not associated with a memory-mapped file.
ValueType ValueType
Definition: Iterator.h:117
Index memUsage() const
Return the memory footprint of this buffer in bytes.
Definition: LeafBuffer.h:270
void setValueMaskOff(Index n)
Definition: LeafNode.h:885
void evalActiveBoundingBox(CoordBBox &bbox, bool visitVoxels=true) const
Definition: LeafNode.h:1485
const Buffer & buffer() const
Definition: LeafNode.h:347
void set(Index32 n, bool On)
Set the nth bit to the specified state.
Definition: NodeMasks.h:462
void prune(const ValueType &=zeroVal< ValueType >())
This function exists only to enable template instantiation.
Definition: LeafNode.h:716
Index64 memUsageIfLoaded() const
Definition: LeafNode.h:1475
NodeT * probeNodeAndCache(const Coord &, AccessorT &)
Return a pointer to this node.
Definition: LeafNode.h:741
void combine(const LeafNode &other, CombineOp &op)
Definition: LeafNode.h:1756
LeafNode * touchLeaf(const Coord &)
Return a pointer to this node.
Definition: LeafNode.h:737
void addTile(Index level, const Coord &, const ValueType &, bool)
Definition: LeafNode.h:1616
Index memUsageIfLoaded() const
Definition: LeafBuffer.h:281
static const Index NUM_VALUES
Definition: LeafNode.h:51
void resetBackground(const ValueType &oldBackground, const ValueType &newBackground)
Replace inactive occurrences of oldBackground with newBackground, and inactive occurrences of -oldBac...
Definition: LeafNode.h:1645
ChildOnCIter beginChildOn() const
Definition: LeafNode.h:322
bool operator==(const Vec3< T0 > &v0, const Vec3< T1 > &v1)
Equality operator, does exact floating point comparisons.
Definition: Vec3.h:477
ValueAllCIter beginValueAll() const
Definition: LeafNode.h:306
ValueAllIter endValueAll()
Definition: LeafNode.h:317
static Index getValueLevelAndCache(const Coord &, AccessorT &)
Return the LEVEL (=0) at which leaf node values reside.
Definition: LeafNode.h:622
Definition: LeafNode.h:212
ValueAllCIter endValueAll() const
Definition: LeafNode.h:316
Leaf nodes have no children, so their child iterators have no get/set accessors.
Definition: LeafNode.h:250
void visitActiveBBox(BBoxOp &) const
Calls the templated functor BBoxOp with bounding box information. An additional level argument is pro...
Definition: LeafNode.h:1857
~LeafNode()
Destructor.
Definition: LeafNode.h:1032
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:559
bool isInactive() const
Return true if all of this node's values are inactive.
Definition: LeafNode.h:846
bool isValueMaskOff(Index n) const
Definition: LeafNode.h:873
ValueOffIter endValueOff()
Definition: LeafNode.h:314
bool allocate()
Allocate memory for this node's buffer if it has not already been allocated.
Definition: LeafNode.h:154
bool isConstant(ValueType &firstValue, bool &state, const ValueType &tolerance=zeroVal< ValueType >()) const
Definition: LeafNode.h:1511
bool isOn(Index32 n) const
Return true if the nth bit is on.
Definition: NodeMasks.h:502
int32_t Int32
Definition: Types.h:56
void fill(const ValueType &)
Populate this buffer with a constant value.
Definition: LeafBuffer.h:226
NodeMaskType & getValueMask()
Definition: LeafNode.h:876
const NodeT * probeConstNodeAndCache(const Coord &, AccessorT &) const
Return a const pointer to this node.
Definition: LeafNode.h:761
Tag dispatch class that distinguishes constructors during file input.
Definition: Types.h:650
static Index getValueLevel(const Coord &)
Return the level (i.e., 0) at which leaf node values reside.
Definition: LeafNode.h:396
static Index32 nonLeafCount()
Return the non-leaf count for this node, which is zero.
Definition: LeafNode.h:135
static void read(std::istream &is, GridHandle< BufferT > &handle, Codec codec)
ValueOffCIter cendValueOff() const
Definition: LeafNode.h:312
static bool hasActiveTiles()
Return false since leaf nodes never contain tiles.
Definition: LeafNode.h:482
Definition: LeafNode.h:212
BBox< Coord > CoordBBox
Definition: NanoVDB.h:1658
void addTileAndCache(Index, const Coord &, const ValueType &, bool, AccessorT &)
Definition: LeafNode.h:1633
bool allocate()
Allocate memory for this buffer if it has not already been allocated.
Definition: LeafBuffer.h:63
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:611
void visit(VisitorOp &)
Definition: LeafNode.h:1872
Index32 transientData() const
Return the transient data value.
Definition: LeafNode.h:188
bool isAllocated() const
Return true if memory for this node's buffer has been allocated.
Definition: LeafNode.h:152
void writeTopology(std::ostream &os, bool toHalf=false) const
Write out just the topology.
Definition: LeafNode.h:1318
T BuildType
Definition: LeafNode.h:40
ChildOffCIter endChildOff() const
Definition: LeafNode.h:335
void setValuesOff()
Mark all voxels as inactive but don't change their values.
Definition: LeafNode.h:474
bool isValueOn(Index offset) const
Return true if the voxel at the given offset is active.
Definition: LeafNode.h:479
LeafNode * touchLeafAndCache(const Coord &, AccessorT &)
Return a pointer to this node.
Definition: LeafNode.h:739
Index32 countOff() const
Return the total number of on bits.
Definition: NodeMasks.h:450
Definition: Compression.h:292
void getOrigin(Int32 &x, Int32 &y, Int32 &z) const
Return the grid index coordinates of this node's local origin.
Definition: LeafNode.h:175
uint32_t Index32
Definition: Types.h:52
bool isValueMaskOff() const
Definition: LeafNode.h:874
OPENVDB_API uint32_t getDataCompression(std::ios_base &)
Return a bitwise OR of compression option flags (COMPRESS_ZIP, COMPRESS_ACTIVE_MASK, etc.) specifying whether and how input data is compressed or output data should be compressed.
void visit2(IterT &otherIter, VisitorOp &, bool otherIsLHS=false)
Definition: LeafNode.h:1952
This struct collects both input and output arguments to "grid combiner" functors used with the tree::...
Definition: Types.h:529
bool operator==(const LeafNode &other) const
Check for buffer, state and origin equivalence.
Definition: LeafNode.h:1455
void getOrigin(Coord &origin) const
Return the grid index coordinates of this node's local origin.
Definition: LeafNode.h:174
Coord offsetToGlobalCoord(Index n) const
Return the global coordinates for a linear table offset.
Definition: LeafNode.h:1076
T negative(const T &val)
Return the unary negation of the given value.
Definition: Math.h:128
const LeafNode * probeLeafAndCache(const Coord &, AccessorT &) const
Return a const pointer to this node.
Definition: LeafNode.h:758
Definition: LeafNode.h:211
DenseIter< LeafNode, ValueType, ChildAll > ChildAllIter
Definition: LeafNode.h:296
ValueOffCIter endValueOff() const
Definition: LeafNode.h:313
ValueOnCIter beginValueOn() const
Definition: LeafNode.h:300
ValueOffCIter beginValueOff() const
Definition: LeafNode.h:303
static Index getLevel()
Return the level of this node, which by definition is zero for LeafNodes.
Definition: LeafNode.h:125
void negate()
Definition: LeafNode.h:1740
void setValueMask(Index n, bool on)
Definition: LeafNode.h:883
Index32 countOn() const
Return the total number of on bits.
Definition: NodeMasks.h:443
void skipCompressedValues(bool seekable, std::istream &, bool fromHalf)
Definition: LeafNode.h:1330
void setTransientData(Index32 transientData)
Set the transient data value.
Definition: LeafNode.h:190
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:593
NodeT * stealNode(const Coord &, const ValueType &, bool)
This function exists only to enable template instantiation.
Definition: LeafNode.h:721
DenseIter()
Definition: LeafNode.h:265
const NodeMaskType & valueMask() const
Definition: LeafNode.h:877
static const Index SIZE
Definition: LeafNode.h:53
ChildAllCIter beginChildAll() const
Definition: LeafNode.h:328
Definition: Exceptions.h:13
void modifyValueAndActiveState(const Coord &xyz, const ModifyOp &op)
Apply a functor to the voxel at the given coordinates.
Definition: LeafNode.h:458
static Index numValues()
Return the total number of voxels represented by this LeafNode.
Definition: LeafNode.h:123
OnIterator beginOn() const
Definition: NodeMasks.h:352
void fill(const CoordBBox &bbox, const ValueType &, bool active=true)
Set all voxels within an axis-aligned box to the specified value and active state.
Definition: LeafNode.h:1203
void setValuesOn()
Mark all voxels as active but don't change their values.
Definition: LeafNode.h:472
ValueT value
Definition: GridBuilder.h:1287
OffIterator beginOff() const
Definition: NodeMasks.h:354
ValueType medianAll(ValueType *tmp=nullptr) const
Computes the median value of all the active AND inactive voxels in this node.
Definition: LeafNode.h:1547
void setValue(Index i, const ValueType &)
Set the i'th value of this buffer to the specified value.
Definition: LeafBuffer.h:190
ValueT & getValue() const
Definition: LeafNode.h:227
static Index32 leafCount()
Return the leaf count for this node, which is one.
Definition: LeafNode.h:131
void merge(const LeafNode &)
Definition: LeafNode.h:1666
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:602
Definition: NodeMasks.h:270
void readTopology(std::istream &is, bool fromHalf=false)
Read in just the topology.
Definition: LeafNode.h:1310
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:1273
static Index log2dim()
Return log2 of the dimension of this LeafNode, e.g. 3 if dimensions are 8^3.
Definition: LeafNode.h:117
SameConfiguration<OtherNodeType>::value is true if and only if OtherNodeType is the type of a LeafNod...
Definition: LeafNode.h:64
ChildOnIter endChildOn()
Definition: LeafNode.h:333
ChildOffCIter cendChildOff() const
Definition: LeafNode.h:334
ChildOnCIter cendChildOn() const
Definition: LeafNode.h:331
const ValueType * data() const
Return a const pointer to the array of voxel values.
Definition: LeafBuffer.h:291
ValueOnCIter cendValueOn() const
Definition: LeafNode.h:309
ValueOnCIter endValueOn() const
Definition: LeafNode.h:310
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:1732
static void doVisit(NodeT &, VisitorOp &)
Definition: LeafNode.h:1890
void load(std::istream &is)
Definition: NodeMasks.h:569
ChildAllIter endChildAll()
Definition: LeafNode.h:339
void setActiveState(const Coord &xyz, bool on)
Set the active state of the voxel at the given coordinates but don't change its value.
Definition: LeafNode.h:1137
ChildOnCIter endChildOn() const
Definition: LeafNode.h:332
Buffer & buffer()
Definition: LeafNode.h:348
typename NodeMaskType::DenseIterator MaskDenseIterator
Definition: LeafNode.h:208
static Index getChildDim()
Return the dimension of child nodes of this LeafNode, which is one for voxels.
Definition: LeafNode.h:129
bool isChildMaskOff(Index) const
Definition: LeafNode.h:880
void clip(const CoordBBox &, const ValueType &background)
Set all voxels that lie outside the given axis-aligned box to the background.
Definition: LeafNode.h:1163
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:1503
Base class for dense iterators over internal and leaf nodes.
Definition: Iterator.h:178
CombineArgs & setARef(const AValueType &a)
Redirect the A value to a new external source.
Definition: Types.h:582
Index32 pos() const
Definition: NodeMasks.h:200
ChildIter(const MaskIterT &iter, NodeT *parent)
Definition: LeafNode.h:254
static Index64 offTileCount()
Definition: LeafNode.h:146
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:427
void setValueMaskOn(Index n)
Definition: LeafNode.h:884
ValueType * mData
Definition: LeafBuffer.h:126
static Index size()
Return the total number of voxels represented by this LeafNode.
Definition: LeafNode.h:121
bool resultIsActive() const
Definition: Types.h:593
bool probeValue(const Coord &xyz, ValueType &val) const
Return true if the voxel at the given coordinates is active.
Definition: LeafNode.h:1103
Definition: LeafNode.h:259
void save(std::ostream &os) const
Definition: NodeMasks.h:565
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:423
ChildAllIter beginChildAll()
Definition: LeafNode.h:329
NodeT * probeNode(const Coord &)
This function exists only to enable template instantiation.
Definition: LeafNode.h:723
bool isChildMaskOn(Index) const
Definition: LeafNode.h:879
typename BaseT::NonConstValueType NonConstValueT
Definition: LeafNode.h:263
ChildOffCIter beginChildOff() const
Definition: LeafNode.h:325
Index64 memUsage() const
Return the memory in bytes occupied by this node.
Definition: LeafNode.h:1465
void readBuffers(std::istream &is, bool fromHalf=false)
Read buffers from a stream.
Definition: LeafNode.h:1346
void voxelizeActiveTiles(bool=true)
No-op.
Definition: LeafNode.h:639
static void doVisit2Node(NodeT &self, OtherNodeT &other, VisitorOp &)
Definition: LeafNode.h:1929
void setOn(Index32 n)
Set the nth bit on.
Definition: NodeMasks.h:452
Definition: LeafNode.h:211
Base class for sparse iterators over internal and leaf nodes.
Definition: Iterator.h:114
LeafNode()
Default constructor.
Definition: LeafNode.h:936
void topologyUnion(const LeafNode< OtherType, Log2Dim > &other, const bool preserveTiles=false)
Union this node's set of active values with the active values of the other node, whose ValueType may ...
Definition: LeafNode.h:1715
void setValueOnly(const Coord &xyz, const ValueType &val)
Set the value of the voxel at the given coordinates but don't change its active state.
Definition: LeafNode.h:1145
void 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:550
Index medianOn(ValueType &value, ValueType *tmp=nullptr) const
Computes the median value of all the active voxels in this node.
Definition: LeafNode.h:1565
bool isValueMaskOn(Index n) const
Definition: LeafNode.h:871
Bit mask for the internal and leaf nodes of VDB. This is a 64-bit implementation. ...
Definition: NodeMasks.h:307
ValueAllCIter cbeginValueAll() const
Definition: LeafNode.h:305
void setValue(const ValueT &value) const
Definition: LeafNode.h:235
const ValueType & getFirstValue() const
Return a const reference to the first value in the buffer.
Definition: LeafNode.h:627
void setItem(Index pos, const ValueT &value) const
Definition: LeafNode.h:230
Index medianOff(ValueType &value, ValueType *tmp=nullptr) const
Computes the median value of all the inactive voxels in this node.
Definition: LeafNode.h:1589
void addLeaf(LeafNode *)
This function exists only to enable template instantiation.
Definition: LeafNode.h:717
bool isConstant(bool &isOn) const
Definition: NodeMasks.h:526
static Index dim()
Return the number of voxels in each coordinate dimension.
Definition: LeafNode.h:119
static Index coordToOffset(const Coord &xyz)
Return the linear table offset of the given global or local coordinates.
Definition: LeafNode.h:1052
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:1246
Index64 offVoxelCount() const
Return the number of voxels marked Off.
Definition: LeafNode.h:142
OPENVDB_API SharedPtr< StreamMetadata > getStreamMetadataPtr(std::ios_base &)
Return a shared pointer to an object that stores metadata (file format, compression scheme...
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:584
Definition: LeafNode.h:215
ChildIter()
Definition: LeafNode.h:253
Definition: NodeMasks.h:208
Definition: PointDataGrid.h:170
void writeCompressedValues(std::ostream &os, ValueT *srcBuf, Index srcCount, const MaskT &valueMask, const MaskT &childMask, bool toHalf)
Definition: Compression.h:645
bool isChildMaskOff() const
Definition: LeafNode.h:881
ValueIter(const MaskIterT &iter, NodeT *parent)
Definition: LeafNode.h:224
const LeafNode * probeConstLeaf(const Coord &) const
Return a const pointer to this node.
Definition: LeafNode.h:754
DenseIter< const LeafNode, const ValueType, ChildAll > ChildAllCIter
Definition: LeafNode.h:297
std::shared_ptr< T > SharedPtr
Definition: Types.h:114
Definition: LeafNode.h:211
const NodeMaskType & getValueMask() const
Definition: LeafNode.h:875
Definition: version.h.in:246
const ValueType & getLastValue() const
Return a const reference to the last value in the buffer.
Definition: LeafNode.h:629
ValueConverter<T>::Type is the type of a LeafNode having the same dimensions as this node but a diffe...
Definition: LeafNode.h:59
ChildOnIter beginChildOn()
Definition: LeafNode.h:323
static void doVisit2(NodeT &self, OtherChildAllIterT &, VisitorOp &, bool otherIsLHS)
Definition: LeafNode.h:1976
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition: version.h.in:116
static void getNodeLog2Dims(std::vector< Index > &dims)
Append the Log2Dim of this LeafNode to the specified vector.
Definition: LeafNode.h:127
typename NodeMaskType::OffIterator MaskOffIterator
Definition: LeafNode.h:207
bool operator!=(const LeafNode &other) const
Definition: LeafNode.h:203
Tag dispatch class that distinguishes topology copy constructors from deep copy constructors.
Definition: Types.h:644
void seek(std::istream &is) const
Definition: NodeMasks.h:570
static const Index DIM
Definition: LeafNode.h:50
ValueType combine(const ValueType &v0, const ValueType &v1, const ValueType &v2, const openvdb::Vec3d &w)
Combine different value types.
Definition: AttributeTransferUtil.h:141
ChildOffCIter cbeginChildOff() const
Definition: LeafNode.h:324
static const Index LEVEL
Definition: LeafNode.h:54
void setValueOff(const Coord &xyz)
Mark the voxel at the given coordinates as inactive but don't change its value.
Definition: LeafNode.h:409
bool isValueMaskOn() const
Definition: LeafNode.h:872
DenseIter(const MaskDenseIterator &iter, NodeT *parent)
Definition: LeafNode.h:266
bool isDense() const
Return true if this node contains only active voxels.
Definition: LeafNode.h:150
void setOrigin(const Coord &origin)
Set the grid index coordinates of this node's local origin.
Definition: LeafNode.h:170
ValueAllIter beginValueAll()
Definition: LeafNode.h:307
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:568
Index64 onLeafVoxelCount() const
Definition: LeafNode.h:143
uint64_t Index64
Definition: Types.h:53
void readCompressedValues(std::istream &is, ValueT *destBuf, Index destCount, const MaskT &valueMask, bool fromHalf)
Definition: Compression.h:465
bool isEmpty() const
Return true if this node has no active voxels.
Definition: LeafNode.h:148
Base class for iterators over internal and leaf nodes.
Definition: Iterator.h:29
ValueOffCIter cbeginValueOff() const
Definition: LeafNode.h:302
static const Index LOG2DIM
Definition: LeafNode.h:48
Definition: Compression.h:54
LeafNode * probeLeaf(const Coord &)
Return a pointer to this node.
Definition: LeafNode.h:748
ValueT & getItem(Index pos) const
Definition: LeafNode.h:226
ValueOnCIter cbeginValueOn() const
Definition: LeafNode.h:299
const ValueType & getValue(const Coord &xyz) const
Return the value of the voxel at the given coordinates.
Definition: LeafNode.h:1087
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h.in:202
ChildAllCIter cendChildAll() const
Definition: LeafNode.h:337
static Coord offsetToLocalCoord(Index n)
Return the local coordinates for a linear table offset, where offset 0 has coordinates (0...
Definition: LeafNode.h:1062
bool isApproxEqual(const Type &a, const Type &b, const Type &tolerance)
Return true if a is equal to b to within the given tolerance.
Definition: Math.h:406
FileInfo * mFileInfo
Definition: LeafBuffer.h:127
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:429
void unsetItem(Index pos, const ValueT &value) const
Definition: LeafNode.h:279
ChildOffIter endChildOff()
Definition: LeafNode.h:336