31 #ifndef OPENVDB_TREE_LEAFNODE_HAS_BEEN_INCLUDED 32 #define OPENVDB_TREE_LEAFNODE_HAS_BEEN_INCLUDED 34 #include <openvdb/Types.h> 35 #include <openvdb/util/NodeMasks.h> 36 #include <openvdb/io/Compression.h> 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;
420 void setActiveState(
const Coord& xyz,
bool on);
445 this->setValueOn(LeafNode::coordToOffset(xyz), val);
451 mBuffer.setValue(offset, val);
452 mValueMask.setOn(offset);
457 template<
typename ModifyOp>
462 mBuffer.setValue(offset, val);
463 mValueMask.setOn(offset);
467 template<
typename ModifyOp>
470 this->modifyValue(this->coordToOffset(xyz), op);
474 template<
typename ModifyOp>
477 const Index offset = this->coordToOffset(xyz);
478 bool state = mValueMask.isOn(offset);
481 mBuffer.setValue(offset, val);
482 mValueMask.set(offset, state);
506 this->fill(bbox, value, active);
512 void fill(
const ValueType& value,
bool active);
525 template<
typename DenseT>
544 template<
typename DenseT>
550 template<
typename AccessorT>
553 return this->getValue(xyz);
558 template<
typename AccessorT>
563 template<
typename AccessorT>
566 this->setValueOn(xyz, val);
572 template<
typename AccessorT>
575 this->setValueOnly(xyz, val);
581 template<
typename ModifyOp,
typename AccessorT>
584 this->modifyValue(xyz, op);
589 template<
typename ModifyOp,
typename AccessorT>
592 this->modifyValueAndActiveState(xyz, op);
597 template<
typename AccessorT>
600 this->setValueOff(xyz, value);
606 template<
typename AccessorT>
609 this->setActiveState(xyz, on);
615 template<
typename AccessorT>
618 return this->probeValue(xyz, val);
624 template<
typename AccessorT>
627 const Index offset = this->coordToOffset(xyz);
628 state = mValueMask.isOn(offset);
630 return mBuffer[offset];
635 template<
typename AccessorT>
655 template<MergePolicy Policy>
void merge(
const LeafNode&);
656 template<MergePolicy Policy>
void merge(
const ValueType& tileValue,
bool tileActive);
657 template<MergePolicy Policy>
666 template<
typename OtherType>
680 template<
typename OtherType>
694 template<
typename OtherType>
697 template<
typename CombineOp>
698 void combine(
const LeafNode& other, CombineOp& op);
699 template<
typename CombineOp>
700 void combine(
const ValueType& value,
bool valueIsActive, CombineOp& op);
702 template<
typename CombineOp,
typename OtherType >
703 void combine2(
const LeafNode& other,
const OtherType&,
bool valueIsActive, CombineOp&);
704 template<
typename CombineOp,
typename OtherNodeT >
705 void combine2(
const ValueType&,
const OtherNodeT& other,
bool valueIsActive, CombineOp&);
706 template<
typename CombineOp,
typename OtherNodeT >
707 void combine2(
const LeafNode& b0,
const OtherNodeT& b1, CombineOp&);
714 template<
typename BBoxOp>
void visitActiveBBox(BBoxOp&)
const;
716 template<
typename VisitorOp>
void visit(VisitorOp&);
717 template<
typename VisitorOp>
void visit(VisitorOp&)
const;
719 template<
typename OtherLeafNodeType,
typename VisitorOp>
720 void visit2Node(OtherLeafNodeType& other, VisitorOp&);
721 template<
typename OtherLeafNodeType,
typename VisitorOp>
722 void visit2Node(OtherLeafNodeType& other, VisitorOp&)
const;
723 template<
typename IterT,
typename VisitorOp>
724 void visit2(IterT& otherIter, VisitorOp&,
bool otherIsLHS =
false);
725 template<
typename IterT,
typename VisitorOp>
726 void visit2(IterT& otherIter, VisitorOp&,
bool otherIsLHS =
false)
const;
732 template<
typename AccessorT>
734 template<
typename NodeT>
736 template<
typename NodeT>
738 template<
typename NodeT>
740 template<
typename ArrayT>
void getNodes(ArrayT&)
const {}
746 template<
typename AccessorT>
752 template<
typename AccessorT>
754 template<
typename NodeT,
typename AccessorT>
758 if (!(std::is_same<NodeT, LeafNode>::value))
return nullptr;
759 return reinterpret_cast<NodeT*
>(
this);
763 template<
typename AccessorT>
767 const LeafNode* probeConstLeaf(
const Coord&)
const {
return this; }
769 template<
typename AccessorT>
771 template<
typename AccessorT>
774 template<
typename NodeT,
typename AccessorT>
778 if (!(std::is_same<NodeT, LeafNode>::value))
return nullptr;
779 return reinterpret_cast<const NodeT*
>(
this);
793 bool isConstant(
ValueType& firstValue,
bool& state,
794 const ValueType& tolerance = zeroVal<ValueType>())
const;
808 bool& state,
const ValueType& tolerance = zeroVal<ValueType>())
const;
863 friend class ::TestLeaf;
864 template<
typename>
friend class ::TestLeafIO;
901 inline void skipCompressedValues(
bool seekable, std::istream&,
bool fromHalf);
906 template<
typename NodeT,
typename VisitorOp,
typename ChildAllIterT>
907 static inline void doVisit(NodeT&, VisitorOp&);
909 template<
typename NodeT,
typename OtherNodeT,
typename VisitorOp,
910 typename ChildAllIterT,
typename OtherChildAllIterT>
911 static inline void doVisit2Node(NodeT&
self, OtherNodeT& other, VisitorOp&);
913 template<
typename NodeT,
typename VisitorOp,
914 typename ChildAllIterT,
typename OtherChildAllIterT>
915 static inline void doVisit2(NodeT&
self, OtherChildAllIterT&, VisitorOp&,
bool otherIsLHS);
931 template<Index Dim1,
typename NodeT2>
936 template<Index Dim1,
typename T2>
944 template<
typename T, Index Log2Dim>
953 template<
typename T, Index Log2Dim>
958 mOrigin(xyz & (~(
DIM - 1)))
963 #if OPENVDB_ABI_VERSION_NUMBER >= 3 964 template<
typename T, Index Log2Dim>
969 mOrigin(xyz & (~(
DIM - 1)))
975 template<
typename T, Index Log2Dim>
978 mBuffer(other.mBuffer),
980 mOrigin(other.mOrigin)
986 template<
typename T, Index Log2Dim>
987 template<
typename OtherValueType>
991 mOrigin(other.mOrigin)
995 static inline ValueType convertValue(
const OtherValueType& val) {
return ValueType(val); }
999 mBuffer[i] = Local::convertValue(other.mBuffer[i]);
1004 template<
typename T, Index Log2Dim>
1005 template<
typename OtherValueType>
1009 mBuffer(background),
1011 mOrigin(other.mOrigin)
1016 template<
typename T, Index Log2Dim>
1017 template<
typename OtherValueType>
1022 mOrigin(other.mOrigin)
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>
1168 this->
fill(background,
false);
1169 }
else if (clipBBox.
isInside(nodeBBox)) {
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>
1205 #if OPENVDB_ABI_VERSION_NUMBER >= 3 1210 clippedBBox.intersect(bbox);
1211 if (!clippedBBox)
return;
1213 for (
Int32 x = clippedBBox.min().x(); x <= clippedBBox.max().x(); ++x) {
1214 const Index offsetX = (x & (
DIM-1u)) << 2*Log2Dim;
1215 for (
Int32 y = clippedBBox.min().y(); y <= clippedBBox.max().y(); ++y) {
1216 const Index offsetXY = offsetX + ((y & (
DIM-1u)) << Log2Dim);
1217 for (
Int32 z = clippedBBox.min().z(); z <= clippedBBox.max().z(); ++z) {
1218 const Index offset = offsetXY + (z & (
DIM-1u));
1219 mBuffer[offset] = value;
1220 mValueMask.
set(offset, active);
1226 template<
typename T, Index Log2Dim>
1230 mBuffer.
fill(value);
1233 template<
typename T, Index Log2Dim>
1237 mBuffer.
fill(value);
1238 mValueMask.
set(active);
1245 template<
typename T, Index Log2Dim>
1246 template<
typename DenseT>
1250 #if OPENVDB_ABI_VERSION_NUMBER >= 3 1251 mBuffer.loadValues();
1254 using DenseValueType =
typename DenseT::ValueType;
1256 const size_t xStride = dense.xStride(), yStride = dense.yStride(), zStride = dense.zStride();
1257 const Coord&
min = dense.bbox().min();
1258 DenseValueType* t0 = dense.data() + zStride * (bbox.
min()[2] - min[2]);
1259 const T* s0 = &mBuffer[bbox.
min()[2] & (
DIM-1u)];
1260 for (
Int32 x = bbox.
min()[0], ex = bbox.
max()[0] + 1; x < ex; ++x) {
1261 DenseValueType* t1 = t0 + xStride * (x - min[0]);
1262 const T* s1 = s0 + ((x & (
DIM-1u)) << 2*Log2Dim);
1263 for (
Int32 y = bbox.
min()[1], ey = bbox.
max()[1] + 1; y < ey; ++y) {
1264 DenseValueType* t2 = t1 + yStride * (y - min[1]);
1265 const T* s2 = s1 + ((y & (
DIM-1u)) << Log2Dim);
1266 for (
Int32 z = bbox.
min()[2], ez = bbox.
max()[2] + 1; z < ez; ++z, t2 += zStride) {
1267 *t2 = DenseValueType(*s2++);
1274 template<
typename T, Index Log2Dim>
1275 template<
typename DenseT>
1280 #if OPENVDB_ABI_VERSION_NUMBER >= 3 1284 using DenseValueType =
typename DenseT::ValueType;
1286 const size_t xStride = dense.xStride(), yStride = dense.yStride(), zStride = dense.zStride();
1287 const Coord&
min = dense.bbox().min();
1289 const DenseValueType* s0 = dense.data() + zStride * (bbox.
min()[2] - min[2]);
1291 for (
Int32 x = bbox.
min()[0], ex = bbox.
max()[0]+1; x < ex; ++x) {
1292 const DenseValueType* s1 = s0 + xStride * (x - min[0]);
1294 for (
Int32 y = bbox.
min()[1], ey = bbox.
max()[1]+1; y < ey; ++y) {
1295 const DenseValueType* s2 = s1 + yStride * (y - min[1]);
1297 for (
Int32 z = bbox.
min()[2], ez = bbox.
max()[2]+1; z < ez; ++z, ++n2, s2 += zStride) {
1300 mBuffer[n2] = background;
1302 mValueMask.
setOn(n2);
1314 template<
typename T, Index Log2Dim>
1318 mValueMask.
load(is);
1322 template<
typename T, Index Log2Dim>
1326 mValueMask.
save(os);
1334 template<
typename T, Index Log2Dim>
1340 io::readCompressedValues<ValueType, NodeMaskType>(
1341 is,
nullptr,
SIZE, mValueMask, fromHalf);
1350 template<
typename T, Index Log2Dim>
1358 template<
typename T, Index Log2Dim>
1363 const bool seekable = meta && meta->seekable();
1365 #if OPENVDB_ABI_VERSION_NUMBER >= 3 1366 std::streamoff maskpos = is.tellg();
1371 mValueMask.
seek(is);
1374 mValueMask.
load(is);
1377 int8_t numBuffers = 1;
1383 is.read(reinterpret_cast<char*>(&numBuffers),
sizeof(int8_t));
1391 mBuffer.setOutOfCore(
false);
1393 #if OPENVDB_ABI_VERSION_NUMBER >= 3 1399 const bool delayLoad = ((mappedFile.get() !=
nullptr) && clipBBox.
isInside(nodeBBox));
1402 mBuffer.setOutOfCore(
true);
1403 mBuffer.
mFileInfo =
new typename Buffer::FileInfo;
1406 mBuffer.
mFileInfo->mapping = mappedFile;
1416 mBuffer.setOutOfCore(
false);
1419 T background = zeroVal<T>();
1421 background = *
static_cast<const T*
>(bgPtr);
1423 this->
clip(clipBBox, background);
1424 #if OPENVDB_ABI_VERSION_NUMBER >= 3 1429 if (numBuffers > 1) {
1434 for (
int i = 1; i < numBuffers; ++i) {
1438 io::readData<T>(is, temp.
mData,
SIZE, zipped);
1445 template<
typename T, Index Log2Dim>
1450 mValueMask.
save(os);
1452 mBuffer.loadValues();
1462 template<
typename T, Index Log2Dim>
1466 return mOrigin == other.mOrigin &&
1468 mBuffer == other.mBuffer;
1472 template<
typename T, Index Log2Dim>
1478 return sizeof(*this) + mBuffer.
memUsage() -
sizeof(mBuffer);
1482 template<
typename T, Index Log2Dim>
1487 if (bbox.
isInside(this_bbox))
return;
1491 for(; iter; ++iter) this_bbox.
expand(this->offsetToLocalCoord(iter.pos()));
1499 template<
typename T, Index Log2Dim>
1500 template<
typename OtherType, Index OtherLog2Dim>
1505 return (Log2Dim == OtherLog2Dim && mValueMask == other->
getValueMask());
1508 template<
typename T, Index Log2Dim>
1514 if (!mValueMask.
isConstant(state))
return false;
1515 firstValue = mBuffer[0];
1522 template<
typename T, Index Log2Dim>
1529 if (!mValueMask.
isConstant(state))
return false;
1530 minValue = maxValue = mBuffer[0];
1532 const T& v = mBuffer[i];
1534 if ((maxValue - v) > tolerance)
return false;
1536 }
else if (v > maxValue) {
1537 if ((v - minValue) > tolerance)
return false;
1544 template<
typename T, Index Log2Dim>
1548 std::unique_ptr<T[]> data(
nullptr);
1549 if (tmp ==
nullptr) {
1553 if (tmp != mBuffer.
data()) {
1554 const T* src = mBuffer.
data();
1555 for (T* dst = tmp; dst-tmp <
NUM_VALUES;) *dst++ = *src++;
1557 static const size_t midpoint = (
NUM_VALUES - 1) >> 1;
1558 std::nth_element(tmp, tmp + midpoint, tmp +
NUM_VALUES);
1559 return tmp[midpoint];
1562 template<
typename T, Index Log2Dim>
1570 }
else if (count == 0) {
1573 std::unique_ptr<T[]> data(
nullptr);
1574 if (tmp ==
nullptr) {
1575 data.reset(
new T[count]);
1578 for (
auto iter=this->
cbeginValueOn(); iter; ++iter) *tmp++ = *iter;
1579 T *begin = tmp - count;
1580 const size_t midpoint = (count - 1) >> 1;
1581 std::nth_element(begin, begin + midpoint, tmp);
1582 value = begin[midpoint];
1586 template<
typename T, Index Log2Dim>
1594 }
else if (count == 0) {
1597 std::unique_ptr<T[]> data(
nullptr);
1598 if (tmp ==
nullptr) {
1599 data.reset(
new T[count]);
1602 for (
auto iter=this->
cbeginValueOff(); iter; ++iter) *tmp++ = *iter;
1603 T *begin = tmp - count;
1604 const size_t midpoint = (count - 1) >> 1;
1605 std::nth_element(begin, begin + midpoint, tmp);
1606 value = begin[midpoint];
1613 template<
typename T, Index Log2Dim>
1620 template<
typename T, Index Log2Dim>
1624 assert(offset <
SIZE);
1629 template<
typename T, Index Log2Dim>
1630 template<
typename AccessorT>
1633 const ValueType& val,
bool active, AccessorT&)
1635 this->
addTile(level, xyz, val, active);
1642 template<
typename T, Index Log2Dim>
1647 #if OPENVDB_ABI_VERSION_NUMBER >= 3 1653 for (iter = this->mValueMask.
beginOff(); iter; ++iter) {
1656 inactiveValue = newBackground;
1664 template<
typename T, Index Log2Dim>
1665 template<MergePolicy Policy>
1669 #if OPENVDB_ABI_VERSION_NUMBER >= 3 1676 for (; iter; ++iter) {
1678 if (mValueMask.
isOff(n)) {
1679 mBuffer[n] = other.mBuffer[n];
1680 mValueMask.
setOn(n);
1686 template<
typename T, Index Log2Dim>
1687 template<MergePolicy Policy>
1692 this->
template merge<Policy>(other);
1695 template<
typename T, Index Log2Dim>
1696 template<MergePolicy Policy>
1700 #if OPENVDB_ABI_VERSION_NUMBER >= 3 1706 if (!tileActive)
return;
1709 const Index n = iter.pos();
1710 mBuffer[n] = tileValue;
1711 mValueMask.
setOn(n);
1717 template<
typename T, Index Log2Dim>
1718 template<
typename OtherType>
1725 template<
typename T, Index Log2Dim>
1726 template<
typename OtherType>
1734 template<
typename T, Index Log2Dim>
1735 template<
typename OtherType>
1743 template<
typename T, Index Log2Dim>
1747 #if OPENVDB_ABI_VERSION_NUMBER >= 3 1751 mBuffer[i] = -mBuffer[i];
1759 template<
typename T, Index Log2Dim>
1760 template<
typename CombineOp>
1764 #if OPENVDB_ABI_VERSION_NUMBER >= 3 1770 .setAIsActive(mValueMask.
isOn(i))
1771 .setBRef(other.mBuffer[i])
1773 .setResultRef(mBuffer[i]));
1779 template<
typename T, Index Log2Dim>
1780 template<
typename CombineOp>
1784 #if OPENVDB_ABI_VERSION_NUMBER >= 3 1788 args.
setBRef(value).setBIsActive(valueIsActive);
1791 .setAIsActive(mValueMask.
isOn(i))
1792 .setResultRef(mBuffer[i]));
1801 template<
typename T, Index Log2Dim>
1802 template<
typename CombineOp,
typename OtherType>
1805 bool valueIsActive, CombineOp& op)
1807 #if OPENVDB_ABI_VERSION_NUMBER >= 3 1811 args.
setBRef(value).setBIsActive(valueIsActive);
1813 op(args.
setARef(other.mBuffer[i])
1815 .setResultRef(mBuffer[i]));
1821 template<
typename T, Index Log2Dim>
1822 template<
typename CombineOp,
typename OtherNodeT>
1825 bool valueIsActive, CombineOp& op)
1827 #if OPENVDB_ABI_VERSION_NUMBER >= 3 1831 args.
setARef(value).setAIsActive(valueIsActive);
1833 op(args.
setBRef(other.mBuffer[i])
1834 .setBIsActive(other.valueMask().isOn(i))
1835 .setResultRef(mBuffer[i]));
1841 template<
typename T, Index Log2Dim>
1842 template<
typename CombineOp,
typename OtherNodeT>
1846 #if OPENVDB_ABI_VERSION_NUMBER >= 3 1852 op(args.
setARef(b0.mBuffer[i])
1854 .setBRef(b1.mBuffer[i])
1855 .setBIsActive(b1.valueMask().isOn(i))
1856 .setResultRef(mBuffer[i]));
1865 template<
typename T, Index Log2Dim>
1866 template<
typename BBoxOp>
1870 if (op.template descent<LEVEL>()) {
1888 template<
typename T, Index Log2Dim>
1889 template<
typename VisitorOp>
1893 doVisit<LeafNode, VisitorOp, ChildAllIter>(*
this, op);
1897 template<
typename T, Index Log2Dim>
1898 template<
typename VisitorOp>
1902 doVisit<const LeafNode, VisitorOp, ChildAllCIter>(*
this, op);
1906 template<
typename T, Index Log2Dim>
1907 template<
typename NodeT,
typename VisitorOp,
typename ChildAllIterT>
1911 for (ChildAllIterT iter =
self.
beginChildAll(); iter; ++iter) {
1920 template<
typename T, Index Log2Dim>
1921 template<
typename OtherLeafNodeType,
typename VisitorOp>
1926 typename OtherLeafNodeType::ChildAllIter>(*
this, other, op);
1930 template<
typename T, Index Log2Dim>
1931 template<
typename OtherLeafNodeType,
typename VisitorOp>
1936 typename OtherLeafNodeType::ChildAllCIter>(*
this, other, op);
1940 template<
typename T, Index Log2Dim>
1943 typename OtherNodeT,
1945 typename ChildAllIterT,
1946 typename OtherChildAllIterT>
1951 static_assert(OtherNodeT::SIZE == NodeT::SIZE,
1952 "can't visit nodes of different sizes simultaneously");
1953 static_assert(OtherNodeT::LEVEL == NodeT::LEVEL,
1954 "can't visit nodes at different tree levels simultaneously");
1956 ChildAllIterT iter =
self.beginChildAll();
1957 OtherChildAllIterT otherIter = other.beginChildAll();
1959 for ( ; iter && otherIter; ++iter, ++otherIter) {
1960 op(iter, otherIter);
1968 template<
typename T, Index Log2Dim>
1969 template<
typename IterT,
typename VisitorOp>
1973 doVisit2<LeafNode, VisitorOp, ChildAllIter, IterT>(
1974 *
this, otherIter, op, otherIsLHS);
1978 template<
typename T, Index Log2Dim>
1979 template<
typename IterT,
typename VisitorOp>
1983 doVisit2<const LeafNode, VisitorOp, ChildAllCIter, IterT>(
1984 *
this, otherIter, op, otherIsLHS);
1988 template<
typename T, Index Log2Dim>
1992 typename ChildAllIterT,
1993 typename OtherChildAllIterT>
1996 VisitorOp& op,
bool otherIsLHS)
1998 if (!otherIter)
return;
2001 for (ChildAllIterT iter =
self.
beginChildAll(); iter; ++iter) {
2002 op(otherIter, iter);
2005 for (ChildAllIterT iter =
self.
beginChildAll(); iter; ++iter) {
2006 op(iter, otherIter);
2015 template<
typename T, Index Log2Dim>
2016 inline std::ostream&
2017 operator<<(std::ostream& os, const typename LeafNode<T, Log2Dim>::Buffer& buf)
2019 for (
Index32 i = 0, N = buf.size(); i < N; ++i) os << buf.mData[i] <<
", ";
2037 #endif // OPENVDB_TREE_LEAFNODE_HAS_BEEN_INCLUDED ValueT & getValue() const
Definition: LeafNode.h:248
void combine(const LeafNode &other, CombineOp &op)
Definition: LeafNode.h:1762
void setItem(Index pos, const ValueT &value) const
Definition: LeafNode.h:251
static void getNodeLog2Dims(std::vector< Index > &dims)
Append the Log2Dim of this LeafNode to the specified vector.
Definition: LeafNode.h:157
void visit2(IterT &otherIter, VisitorOp &, bool otherIsLHS=false)
Definition: LeafNode.h:1971
NodeT * probeNodeAndCache(const Coord &, AccessorT &)
Return a pointer to this node.
Definition: LeafNode.h:755
void addLeaf(LeafNode *)
This function exists only to enable template instantiation.
Definition: LeafNode.h:731
bool operator!=(const LeafNode &other) const
Definition: LeafNode.h:224
T ValueType
Definition: LeafNode.h:68
bool isValueMaskOn() const
Definition: LeafNode.h:886
Index32 countOn() const
Return the total number of on bits.
Definition: NodeMasks.h:445
Definition: NodeMasks.h:272
ValueOnCIter beginValueOn() const
Definition: LeafNode.h:321
const NodeMaskType & valueMask() const
Definition: LeafNode.h:891
ChildOnCIter cbeginChildOn() const
Definition: LeafNode.h:342
ValueOnCIter cendValueOn() const
Definition: LeafNode.h:330
ValueType ValueType
Definition: Iterator.h:146
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 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:598
const NodeT * probeConstNode(const Coord &) const
This function exists only to enable template instantiation.
Definition: LeafNode.h:739
Axis-aligned bounding box of signed integer coordinates.
Definition: Coord.h:264
ChildAllCIter cbeginChildAll() const
Definition: LeafNode.h:348
void setValueOn(Index offset)
Mark the voxel at the given offset as active but don't change its value.
Definition: LeafNode.h:442
void setOn(Index32 n)
Set the nth bit on.
Definition: NodeMasks.h:454
const ValueType & getFirstValue() const
Return a const reference to the first value in the buffer.
Definition: LeafNode.h:641
bool hasOverlap(const CoordBBox &b) const
Return true if the given bounding box overlaps with this bounding box.
Definition: Coord.h:416
OPENVDB_API SharedPtr< StreamMetadata > getStreamMetadataPtr(std::ios_base &)
Return a shared pointer to an object that stores metadata (file format, compression scheme...
void modifyValueAndActiveStateAndCache(const Coord &xyz, const ModifyOp &op, AccessorT &)
Definition: LeafNode.h:590
SharedPtr< MappedFile > Ptr
Definition: io.h:152
Definition: LeafNode.h:232
ChildOffIter endChildOff()
Definition: LeafNode.h:357
static Index64 onTileCount()
Definition: LeafNode.h:171
LeafNode * probeLeaf(const Coord &)
Return a pointer to this node.
Definition: LeafNode.h:762
void addLeafAndCache(LeafNode *, AccessorT &)
This function exists only to enable template instantiation.
Definition: LeafNode.h:733
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:607
ChildAllCIter beginChildAll() const
Definition: LeafNode.h:349
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
Definition: LeafNode.h:49
uint64_t Index64
Definition: Types.h:59
static void doVisit2(NodeT &self, OtherChildAllIterT &, VisitorOp &, bool otherIsLHS)
Definition: LeafNode.h:1995
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
static Index getValueLevel(const Coord &)
Return the level (i.e., 0) at which leaf node values reside.
Definition: LeafNode.h:417
void fill(const ValueType &)
Populate this buffer with a constant value.
Definition: LeafBuffer.h:343
Base class for dense iterators over internal and leaf nodes.
Definition: Iterator.h:206
bool isChildMaskOn(Index) const
Definition: LeafNode.h:893
Base class for iterators over internal and leaf nodes.
Definition: Iterator.h:58
void evalActiveBoundingBox(CoordBBox &bbox, bool visitVoxels=true) const
Definition: LeafNode.h:1484
void setOrigin(const Coord &origin)
Set the grid index coordinates of this node's local origin.
Definition: LeafNode.h:198
Definition: LeafNode.h:233
static Index dim()
Return the number of voxels in each coordinate dimension.
Definition: LeafNode.h:149
const ValueType * data() const
Return a const pointer to the array of voxel values.
Definition: LeafBuffer.h:397
OffIterator beginOff() const
Definition: NodeMasks.h:356
ChildOffCIter beginChildOff() const
Definition: LeafNode.h:346
Index64 memUsage() const
Return the memory in bytes occupied by this node.
Definition: LeafNode.h:1474
ValueOnCIter cbeginValueOn() const
Definition: LeafNode.h:320
static const Index LOG2DIM
Definition: LeafNode.h:75
bool getItem(Index pos, void *&child, NonConstValueT &value) const
Definition: LeafNode.h:289
void seek(std::istream &is) const
Definition: NodeMasks.h:572
void readTopology(std::istream &is, bool fromHalf=false)
Read in just the topology.
Definition: LeafNode.h:1316
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:1277
bool operator==(const Vec3< T0 > &v0, const Vec3< T1 > &v1)
Equality operator, does exact floating point comparisons.
Definition: Vec3.h:488
OnIterator beginOn() const
Definition: NodeMasks.h:354
ChildIter()
Definition: LeafNode.h:274
ValueAllIter endValueAll()
Definition: LeafNode.h:338
ValueOnIter beginValueOn()
Definition: LeafNode.h:322
ValueOffCIter cendValueOff() const
Definition: LeafNode.h:333
FileInfo * mFileInfo
Definition: LeafBuffer.h:226
ChildOnIter beginChildOn()
Definition: LeafNode.h:344
ValueType medianAll(ValueType *tmp=nullptr) const
Computes the median value of all the active AND inactive voxels in this node.
Definition: LeafNode.h:1546
Index medianOn(ValueType &value, ValueType *tmp=nullptr) const
Computes the median value of all the active voxels in this node.
Definition: LeafNode.h:1564
Definition: LeafNode.h:233
bool isValueMaskOff(Index n) const
Definition: LeafNode.h:887
ChildOnCIter beginChildOn() const
Definition: LeafNode.h:343
void setOff(Index32 n)
Set the nth bit off.
Definition: NodeMasks.h:459
bool allocate()
Allocate memory for this buffer if it has not already been allocated.
Definition: LeafBuffer.h:152
void setValueOff(Index offset)
Mark the voxel at the given offset as inactive but don't change its value.
Definition: LeafNode.h:432
ValueAllCIter cendValueAll() const
Definition: LeafNode.h:336
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:1728
void modifyValueAndActiveState(const Coord &xyz, const ModifyOp &op)
Apply a functor to the voxel at the given coordinates.
Definition: LeafNode.h:475
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
const Coord & origin() const
Return the grid index coordinates of this node's local origin.
Definition: LeafNode.h:201
ValueOnIter endValueOn()
Definition: LeafNode.h:332
void unsetItem(Index pos, const ValueT &value) const
Definition: LeafNode.h:300
void stealNodes(ArrayT &, const ValueType &, bool)
This function exists only to enable template instantiation.
Definition: LeafNode.h:741
static void evalNodeOrigin(Coord &xyz)
Compute the origin of the leaf node that contains the voxel with the given coordinates.
Definition: LeafNode.h:904
void writeCompressedValues(std::ostream &os, ValueT *srcBuf, Index srcCount, const MaskT &valueMask, const MaskT &childMask, bool toHalf)
Definition: Compression.h:462
Int32 ValueType
Definition: Coord.h:59
const LeafNode * probeConstLeafAndCache(const Coord &, AccessorT &) const
Return a const pointer to this node.
Definition: LeafNode.h:770
Definition: LeafNode.h:232
bool isValueMaskOn(Index n) const
Definition: LeafNode.h:885
Definition: Compression.h:216
ChildIter(const MaskIterT &iter, NodeT *parent)
Definition: LeafNode.h:275
T BuildType
Definition: LeafNode.h:67
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:354
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:582
ValueOffCIter beginValueOff() const
Definition: LeafNode.h:324
void combine2(const LeafNode &other, const OtherType &, bool valueIsActive, CombineOp &)
Definition: LeafNode.h:1804
const Coord & min() const
Definition: Coord.h:337
Definition: LeafNode.h:280
Signed (x, y, z) 32-bit integer coordinates.
Definition: Coord.h:51
const ValueType & getValue(const Coord &xyz) const
Return the value of the voxel at the given coordinates.
Definition: LeafNode.h:1087
ChildOnCIter endChildOn() const
Definition: LeafNode.h:353
void expand(ValueType padding)
Pad this bounding box with the specified padding.
Definition: Coord.h:422
void visitActiveBBox(BBoxOp &) const
Calls the templated functor BBoxOp with bounding box information. An additional level argument is pro...
Definition: LeafNode.h:1868
static const Index SIZE
Definition: LeafNode.h:80
Index32 countOff() const
Return the total number of on bits.
Definition: NodeMasks.h:452
bool isValueOn(const Coord &xyz) const
Return true if the voxel at the given coordinates is active.
Definition: LeafNode.h:491
const LeafNode * probeLeaf(const Coord &) const
Return a const pointer to this node.
Definition: LeafNode.h:773
bool isInactive() const
Return true if all of this node's values are inactive.
Definition: LeafNode.h:860
LeafNode()
Default constructor.
Definition: LeafNode.h:946
bool isValueOn(Index offset) const
Return true if the voxel at the given offset is active.
Definition: LeafNode.h:493
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:1248
bool allocate()
Allocate memory for this node's buffer if it has not already been allocated.
Definition: LeafNode.h:182
void set(Index32 n, bool On)
Set the nth bit to the specified state.
Definition: NodeMasks.h:464
void setValueMask(const NodeMaskType &mask)
Definition: LeafNode.h:892
static Index getChildDim()
Return the dimension of child nodes of this LeafNode, which is one for voxels.
Definition: LeafNode.h:159
void addTile(Index level, const Coord &, const ValueType &, bool)
Definition: LeafNode.h:1615
ValueOffCIter endValueOff() const
Definition: LeafNode.h:334
bool isChildMaskOff() const
Definition: LeafNode.h:895
void load(std::istream &is)
Definition: NodeMasks.h:571
typename BaseT::NonConstValueType NonConstValueT
Definition: LeafNode.h:284
Definition: NodeMasks.h:241
static Index32 nonLeafCount()
Return the non-leaf count for this node, which is zero.
Definition: LeafNode.h:163
Coord & setY(Int32 y)
Definition: Coord.h:107
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
bool operator==(const LeafNode &other) const
Check for buffer, state and origin equivalence.
Definition: LeafNode.h:1464
const ValueType & getLastValue() const
Return a const reference to the last value in the buffer.
Definition: LeafNode.h:643
void writeTopology(std::ostream &os, bool toHalf=false) const
Write out just the topology.
Definition: LeafNode.h:1324
void setValue(Index i, const ValueType &)
Set the i'th value of this buffer to the specified value.
Definition: LeafBuffer.h:294
void setValuesOff()
Mark all voxels as inactive but don't change their values.
Definition: LeafNode.h:488
Definition: version.h:229
static Index log2dim()
Return log2 of the dimension of this LeafNode, e.g. 3 if dimensions are 8^3.
Definition: LeafNode.h:147
static Index numValues()
Return the total number of voxels represented by this LeafNode.
Definition: LeafNode.h:153
uint32_t Index32
Definition: Types.h:58
ChildOnCIter cendChildOn() const
Definition: LeafNode.h:352
void getNodes(ArrayT &) const
This function exists only to enable template instantiation.
Definition: LeafNode.h:740
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:1737
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:468
Index32 Index
Definition: Types.h:60
static void doVisit(NodeT &, VisitorOp &)
Definition: LeafNode.h:1909
Definition: Compression.h:79
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition: version.h:136
static Index getValueLevelAndCache(const Coord &, AccessorT &)
Return the LEVEL (=0) at which leaf node values reside.
Definition: LeafNode.h:636
static Index32 leafCount()
Return the leaf count for this node, which is one.
Definition: LeafNode.h:161
bool resultIsActive() const
Definition: Types.h:440
static bool hasActiveTiles()
Return false since leaf nodes never contain tiles.
Definition: LeafNode.h:496
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.
Index64 offVoxelCount() const
Return the number of voxels marked Off.
Definition: LeafNode.h:168
SameConfiguration<OtherNodeType>::value is true if and only if OtherNodeType is the type of a LeafNod...
Definition: LeafNode.h:91
Buffer & buffer()
Definition: LeafNode.h:369
void setValue(const ValueT &value) const
Definition: LeafNode.h:256
static Index64 offTileCount()
Definition: LeafNode.h:172
ChildOffIter beginChildOff()
Definition: LeafNode.h:347
bool isChildMaskOff(Index) const
Definition: LeafNode.h:894
const NodeMaskType & getValueMask() const
Definition: LeafNode.h:889
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:573
Definition: LeafNode.h:233
bool isConstant(bool &isOn) const
Definition: NodeMasks.h:528
Int32 z() const
Definition: Coord.h:159
DenseIter(const MaskDenseIterator &iter, NodeT *parent)
Definition: LeafNode.h:287
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
bool isDense() const
Return true if this node contains only active voxels.
Definition: LeafNode.h:176
NodeMaskType & getValueMask()
Definition: LeafNode.h:890
ValueAllCIter beginValueAll() const
Definition: LeafNode.h:327
Definition: Exceptions.h:39
static void doVisit2Node(NodeT &self, OtherNodeT &other, VisitorOp &)
Definition: LeafNode.h:1948
ValueOnCIter endValueOn() const
Definition: LeafNode.h:331
const Buffer & buffer() const
Definition: LeafNode.h:368
ValueOffIter endValueOff()
Definition: LeafNode.h:335
static CoordBBox inf()
Return an "infinite" bounding box, as defined by the Coord value range.
Definition: Coord.h:335
ValueIter()
Definition: LeafNode.h:244
This struct collects both input and output arguments to "grid combiner" functors used with the tree::...
Definition: Types.h:376
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:564
Index64 onVoxelCount() const
Return the number of voxels marked On.
Definition: LeafNode.h:166
bool probeValue(const Coord &xyz, ValueType &val) const
Return true if the voxel at the given coordinates is active.
Definition: LeafNode.h:1103
Int32 y() const
Definition: Coord.h:158
ValueAllIter beginValueAll()
Definition: LeafNode.h:328
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
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
T negative(const T &val)
Return the unary negation of the given value.
Definition: Math.h:108
void visit2Node(OtherLeafNodeType &other, VisitorOp &)
Definition: LeafNode.h:1923
static Index getLevel()
Return the level of this node, which by definition is zero for LeafNodes.
Definition: LeafNode.h:155
bool isOn(Index32 n) const
Return true if the nth bit is on.
Definition: NodeMasks.h:504
static const Index NUM_VALUES
Definition: LeafNode.h:78
Index64 onLeafVoxelCount() const
Definition: LeafNode.h:169
const NodeT * probeConstNodeAndCache(const Coord &, AccessorT &) const
Return a const pointer to this node.
Definition: LeafNode.h:775
void skipCompressedValues(bool seekable, std::istream &, bool fromHalf)
Definition: LeafNode.h:1336
ChildOnIter endChildOn()
Definition: LeafNode.h:354
Index32 pos() const
Definition: NodeMasks.h:202
void writeBuffers(std::ostream &os, bool toHalf=false) const
Write buffers to a stream.
Definition: LeafNode.h:1447
const ValueType & getValueAndCache(const Coord &xyz, AccessorT &) const
Return the value of the voxel at the given coordinates.
Definition: LeafNode.h:551
DenseIter< const LeafNode, const ValueType, ChildAll > ChildAllCIter
Definition: LeafNode.h:318
SharedPtr< LeafNode > Ptr
Definition: LeafNode.h:72
typename NodeMaskType::OnIterator MaskOnIterator
Definition: LeafNode.h:227
Definition: LeafNode.h:236
Definition: NodeMasks.h:210
Definition: PointDataGrid.h:201
void setValueMaskOff(Index n)
Definition: LeafNode.h:899
void negate()
Definition: LeafNode.h:1745
Coord & setZ(Int32 z)
Definition: Coord.h:108
CombineArgs & setBRef(const BValueType &b)
Redirect the B value to a new external source.
Definition: Types.h:431
bool isConstant(ValueType &firstValue, bool &state, const ValueType &tolerance=zeroVal< ValueType >()) const
Definition: LeafNode.h:1510
typename NodeMaskType::DenseIterator MaskDenseIterator
Definition: LeafNode.h:229
void visit(VisitorOp &)
Definition: LeafNode.h:1891
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
ValueConverter<T>::Type is the type of a LeafNode having the same dimensions as this node but a diffe...
Definition: LeafNode.h:86
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
std::shared_ptr< T > SharedPtr
Definition: Types.h:134
typename NodeMaskType::OffIterator MaskOffIterator
Definition: LeafNode.h:228
void resetBackground(const ValueType &oldBackground, const ValueType &newBackground)
Replace inactive occurrences of oldBackground with newBackground, and inactive occurrences of -oldBac...
Definition: LeafNode.h:1644
static Index coordToOffset(const Coord &xyz)
Return the linear table offset of the given global or local coordinates.
Definition: LeafNode.h:1052
ValueOffIter beginValueOff()
Definition: LeafNode.h:325
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:625
ChildAllCIter endChildAll() const
Definition: LeafNode.h:359
void setValueMask(Index n, bool on)
Definition: LeafNode.h:897
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:1502
Index medianOff(ValueType &value, ValueType *tmp=nullptr) const
Computes the median value of all the inactive voxels in this node.
Definition: LeafNode.h:1588
std::string str() const
Return a string representation of this node.
Definition: LeafNode.h:1039
void readBuffers(std::istream &is, bool fromHalf=false)
Read buffers from a stream.
Definition: LeafNode.h:1352
Tag dispatch class that distinguishes topology copy constructors from deep copy constructors.
Definition: Types.h:508
ChildOffCIter cbeginChildOff() const
Definition: LeafNode.h:345
Coord offsetToGlobalCoord(Index n) const
Return the global coordinates for a linear table offset.
Definition: LeafNode.h:1076
void voxelizeActiveTiles(bool=true)
No-op.
Definition: LeafNode.h:653
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 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:616
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 translate(const Coord &t)
Definition: Coord.h:462
Coord & setX(Int32 x)
Definition: Coord.h:106
ValueAllCIter cbeginValueAll() const
Definition: LeafNode.h:326
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:1720
void getOrigin(Int32 &x, Int32 &y, Int32 &z) const
Return the grid index coordinates of this node's local origin.
Definition: LeafNode.h:203
bool isValueMaskOff() const
Definition: LeafNode.h:888
ChildOffCIter endChildOff() const
Definition: LeafNode.h:356
void save(std::ostream &os) const
Definition: NodeMasks.h:567
ValueAllCIter endValueAll() const
Definition: LeafNode.h:337
static const Index DIM
Definition: LeafNode.h:77
CombineArgs & setARef(const AValueType &a)
Redirect the A value to a new external source.
Definition: Types.h:429
LeafNode * probeLeafAndCache(const Coord &, AccessorT &)
Return a pointer to this node.
Definition: LeafNode.h:764
void getOrigin(Coord &origin) const
Return the grid index coordinates of this node's local origin.
Definition: LeafNode.h:202
bool isOff(Index32 n) const
Return true if the nth bit is off.
Definition: NodeMasks.h:510
ChildAllCIter cendChildAll() const
Definition: LeafNode.h:358
void addTileAndCache(Index, const Coord &, const ValueType &, bool, AccessorT &)
Definition: LeafNode.h:1632
Tag dispatch class that distinguishes constructors during file input.
Definition: Types.h:510
void setValueOn(const Coord &xyz)
Mark the voxel at the given coordinates as active but don't change its value.
Definition: LeafNode.h:440
void intersect(const CoordBBox &bbox)
Intersect this bounding box with the given bounding box.
Definition: Coord.h:448
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:504
ChildOffCIter cendChildOff() const
Definition: LeafNode.h:355
static const Index LEVEL
Definition: LeafNode.h:81
NodeT * stealNode(const Coord &, const ValueType &, bool)
This function exists only to enable template instantiation.
Definition: LeafNode.h:735
void setValueMaskOn(Index n)
Definition: LeafNode.h:898
DenseIter< LeafNode, ValueType, ChildAll > ChildAllIter
Definition: LeafNode.h:317
void reset()
Definition: Coord.h:343
ValueIter(const MaskIterT &iter, NodeT *parent)
Definition: LeafNode.h:245
Base class for sparse iterators over internal and leaf nodes.
Definition: Iterator.h:143
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
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h:188
ChildAllIter beginChildAll()
Definition: LeafNode.h:350
void readCompressedValues(std::istream &is, ValueT *destBuf, Index destCount, const MaskT &valueMask, bool fromHalf)
Definition: Compression.h:339
ChildAllIter endChildAll()
Definition: LeafNode.h:360
Index64 offLeafVoxelCount() const
Definition: LeafNode.h:170
void modifyValue(const ModifyOp &op) const
Definition: LeafNode.h:266
OPENVDB_API uint32_t getFormatVersion(std::ios_base &)
Return the file format version number associated with the given input stream.
~LeafNode()
Destructor.
Definition: LeafNode.h:1032
const Coord & max() const
Definition: Coord.h:338
void merge(const LeafNode &)
Definition: LeafNode.h:1667
Leaf nodes have no children, so their child iterators have no get/set accessors.
Definition: LeafNode.h:271
void modifyItem(Index n, const ModifyOp &op) const
Definition: LeafNode.h:263
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
void setValuesOn()
Mark all voxels as active but don't change their values.
Definition: LeafNode.h:486
ValueType * mData
Definition: LeafBuffer.h:225
bool isValueOnAndCache(const Coord &xyz, AccessorT &) const
Return true if the voxel at the given coordinates is active.
Definition: LeafNode.h:559
Index memUsage() const
Return the memory footprint of this buffer in bytes.
Definition: LeafBuffer.h:382
Templated block class to hold specific data types and a fixed number of values determined by Log2Dim...
Definition: LeafNode.h:64
DenseIter()
Definition: LeafNode.h:286
NodeT * probeNode(const Coord &)
This function exists only to enable template instantiation.
Definition: LeafNode.h:737
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...
static Index size()
Return the total number of voxels represented by this LeafNode.
Definition: LeafNode.h:151
int32_t Int32
Definition: Types.h:62
ValueOffCIter cbeginValueOff() const
Definition: LeafNode.h:323
bool isInside(const Coord &xyz) const
Return true if point (x, y, z) is inside this bounding box.
Definition: Coord.h:404
const LeafNode * probeLeafAndCache(const Coord &, AccessorT &) const
Return a const pointer to this node.
Definition: LeafNode.h:772
static CoordBBox createCube(const Coord &min, ValueType dim)
Definition: Coord.h:329
boost::remove_const< UnsetItemT >::type NonConstValueType
Definition: Iterator.h:212
Int32 x() const
Definition: Coord.h:157
bool isEmpty() const
Return true if this node has no active voxels.
Definition: LeafNode.h:174
Definition: LeafNode.h:232
ValueT & getItem(Index pos) const
Definition: LeafNode.h:247
LeafNode * touchLeafAndCache(const Coord &, AccessorT &)
Return a pointer to this node.
Definition: LeafNode.h:753
Bit mask for the internal and leaf nodes of VDB. This is a 64-bit implementation. ...
Definition: NodeMasks.h:309