31 #ifndef OPENVDB_TREE_LEAFNODE_HAS_BEEN_INCLUDED 32 #define OPENVDB_TREE_LEAFNODE_HAS_BEEN_INCLUDED 42 #include <type_traits> 53 template<Index,
typename>
struct SameLeafConfig;
60 template<
typename T, Index Log2Dim>
75 NUM_VALUES = 1 << 3 * Log2Dim,
76 NUM_VOXELS = NUM_VALUES,
82 template<
typename OtherValueType>
87 template<
typename OtherNodeType>
101 const ValueType& value = zeroVal<ValueType>(),
102 bool active =
false);
105 #ifndef OPENVDB_2_ABI_COMPATIBLE 113 const ValueType& value = zeroVal<ValueType>(),
114 bool active =
false);
124 template<
typename OtherValueType>
128 template<
typename OtherValueType>
133 template<
typename OtherValueType>
171 bool isEmpty()
const {
return mValueMask.isOff(); }
173 bool isDense()
const {
return mValueMask.isOn(); }
175 #ifndef OPENVDB_2_ABI_COMPATIBLE 176 bool isAllocated()
const {
return !mBuffer.isOutOfCore() && !mBuffer.empty(); }
188 void evalActiveBoundingBox(
CoordBBox& bbox,
bool visitVoxels =
true)
const;
197 const Coord& origin()
const {
return mOrigin; }
212 std::string str()
const;
216 template<
typename OtherType, Index OtherLog2Dim>
232 template<
typename MaskIterT,
typename NodeT,
typename ValueT,
typename TagT>
237 MaskIterT, ValueIter<MaskIterT, NodeT, ValueT, TagT>, NodeT, ValueT>
244 ValueT&
getItem(
Index pos)
const {
return this->parent().getValue(pos); }
245 ValueT&
getValue()
const {
return this->parent().getValue(this->pos()); }
250 this->parent().setValueOnly(pos, value);
255 this->parent().setValueOnly(this->pos(), value);
259 template<
typename ModifyOp>
260 void modifyItem(
Index n,
const ModifyOp& op)
const { this->parent().modifyValue(n, op); }
262 template<
typename ModifyOp>
263 void modifyValue(
const ModifyOp& op)
const { this->parent().modifyValue(this->pos(), op); }
267 template<
typename MaskIterT,
typename NodeT,
typename TagT>
269 public SparseIteratorBase<MaskIterT, ChildIter<MaskIterT, NodeT, TagT>, NodeT, ValueType>
276 template<
typename NodeT,
typename ValueT,
typename TagT>
278 MaskDenseIterator, DenseIter<NodeT, ValueT, TagT>, NodeT, void, ValueT>
288 value = this->parent().getValue(pos);
299 this->parent().setValueOnly(pos, value);
374 void readTopology(std::istream& is,
bool fromHalf =
false);
378 void writeTopology(std::ostream& os,
bool toHalf =
false)
const;
383 void readBuffers(std::istream& is,
bool fromHalf =
false);
388 void readBuffers(std::istream& is,
const CoordBBox& bbox,
bool fromHalf =
false);
392 void writeBuffers(std::ostream& os,
bool toHalf =
false)
const;
394 size_t streamingSize(
bool toHalf =
false)
const;
417 void setActiveState(
const Coord& xyz,
bool on);
442 this->setValueOn(LeafNode::coordToOffset(xyz), val);
448 mBuffer.setValue(offset, val);
449 mValueMask.setOn(offset);
454 template<
typename ModifyOp>
459 mBuffer.setValue(offset, val);
460 mValueMask.setOn(offset);
464 template<
typename ModifyOp>
467 this->modifyValue(this->coordToOffset(xyz), op);
471 template<
typename ModifyOp>
474 const Index offset = this->coordToOffset(xyz);
475 bool state = mValueMask.isOn(offset);
478 mBuffer.setValue(offset, val);
479 mValueMask.set(offset, state);
503 this->fill(bbox, value, active);
509 void fill(
const ValueType& value,
bool active);
522 template<
typename DenseT>
541 template<
typename DenseT>
547 template<
typename AccessorT>
550 return this->getValue(xyz);
555 template<
typename AccessorT>
560 template<
typename AccessorT>
563 this->setValueOn(xyz, val);
569 template<
typename AccessorT>
572 this->setValueOnly(xyz, val);
578 template<
typename ModifyOp,
typename AccessorT>
581 this->modifyValue(xyz, op);
586 template<
typename ModifyOp,
typename AccessorT>
589 this->modifyValueAndActiveState(xyz, op);
594 template<
typename AccessorT>
597 this->setValueOff(xyz, value);
603 template<
typename AccessorT>
606 this->setActiveState(xyz, on);
612 template<
typename AccessorT>
615 return this->probeValue(xyz, val);
621 template<
typename AccessorT>
624 const Index offset = this->coordToOffset(xyz);
625 state = mValueMask.isOn(offset);
627 return mBuffer[offset];
632 template<
typename AccessorT>
652 template<MergePolicy Policy>
void merge(
const LeafNode&);
653 template<MergePolicy Policy>
void merge(
const ValueType& tileValue,
bool tileActive);
654 template<MergePolicy Policy>
663 template<
typename OtherType>
677 template<
typename OtherType>
691 template<
typename OtherType>
694 template<
typename CombineOp>
695 void combine(
const LeafNode& other, CombineOp& op);
696 template<
typename CombineOp>
697 void combine(
const ValueType& value,
bool valueIsActive, CombineOp& op);
699 template<
typename CombineOp,
typename OtherType >
700 void combine2(
const LeafNode& other,
const OtherType&,
bool valueIsActive, CombineOp&);
701 template<
typename CombineOp,
typename OtherNodeT >
702 void combine2(
const ValueType&,
const OtherNodeT& other,
bool valueIsActive, CombineOp&);
703 template<
typename CombineOp,
typename OtherNodeT >
704 void combine2(
const LeafNode& b0,
const OtherNodeT& b1, CombineOp&);
711 template<
typename BBoxOp>
void visitActiveBBox(BBoxOp&)
const;
713 template<
typename VisitorOp>
void visit(VisitorOp&);
714 template<
typename VisitorOp>
void visit(VisitorOp&)
const;
716 template<
typename OtherLeafNodeType,
typename VisitorOp>
717 void visit2Node(OtherLeafNodeType& other, VisitorOp&);
718 template<
typename OtherLeafNodeType,
typename VisitorOp>
719 void visit2Node(OtherLeafNodeType& other, VisitorOp&)
const;
720 template<
typename IterT,
typename VisitorOp>
721 void visit2(IterT& otherIter, VisitorOp&,
bool otherIsLHS =
false);
722 template<
typename IterT,
typename VisitorOp>
723 void visit2(IterT& otherIter, VisitorOp&,
bool otherIsLHS =
false)
const;
729 template<
typename AccessorT>
731 template<
typename NodeT>
733 template<
typename NodeT>
735 template<
typename NodeT>
737 template<
typename ArrayT>
void getNodes(ArrayT&)
const {}
743 template<
typename AccessorT>
749 template<
typename AccessorT>
751 template<
typename NodeT,
typename AccessorT>
755 if (!(std::is_same<NodeT, LeafNode>::value))
return nullptr;
756 return reinterpret_cast<NodeT*
>(
this);
760 template<
typename AccessorT>
764 const LeafNode* probeConstLeaf(
const Coord&)
const {
return this; }
766 template<
typename AccessorT>
768 template<
typename AccessorT>
771 template<
typename NodeT,
typename AccessorT>
775 if (!(std::is_same<NodeT, LeafNode>::value))
return nullptr;
776 return reinterpret_cast<const NodeT*
>(
this);
790 bool isConstant(
ValueType& firstValue,
bool& state,
791 const ValueType& tolerance = zeroVal<ValueType>())
const;
805 bool& state,
const ValueType& tolerance = zeroVal<ValueType>())
const;
860 friend class ::TestLeaf;
861 template<
typename>
friend class ::TestLeafIO;
898 inline void skipCompressedValues(
bool seekable, std::istream&,
bool fromHalf);
903 template<
typename NodeT,
typename VisitorOp,
typename ChildAllIterT>
904 static inline void doVisit(NodeT&, VisitorOp&);
906 template<
typename NodeT,
typename OtherNodeT,
typename VisitorOp,
907 typename ChildAllIterT,
typename OtherChildAllIterT>
908 static inline void doVisit2Node(NodeT&
self, OtherNodeT& other, VisitorOp&);
910 template<
typename NodeT,
typename VisitorOp,
911 typename ChildAllIterT,
typename OtherChildAllIterT>
912 static inline void doVisit2(NodeT&
self, OtherChildAllIterT&, VisitorOp&,
bool otherIsLHS);
928 template<Index Dim1,
typename NodeT2>
933 template<Index Dim1,
typename T2>
941 template<
typename T, Index Log2Dim>
950 template<
typename T, Index Log2Dim>
955 mOrigin(xyz & (~(
DIM - 1)))
960 #ifndef OPENVDB_2_ABI_COMPATIBLE 961 template<
typename T, Index Log2Dim>
966 mOrigin(xyz & (~(
DIM - 1)))
972 template<
typename T, Index Log2Dim>
975 mBuffer(other.mBuffer),
977 mOrigin(other.mOrigin)
983 template<
typename T, Index Log2Dim>
984 template<
typename OtherValueType>
988 mOrigin(other.mOrigin)
992 static inline ValueType convertValue(
const OtherValueType& val) {
return ValueType(val); }
996 mBuffer[
i] = Local::convertValue(other.mBuffer[
i]);
1001 template<
typename T, Index Log2Dim>
1002 template<
typename OtherValueType>
1006 mBuffer(background),
1008 mOrigin(other.mOrigin)
1013 template<
typename T, Index Log2Dim>
1014 template<
typename OtherValueType>
1019 mOrigin(other.mOrigin)
1022 mBuffer[
i] = (mValueMask.
isOn(
i) ? onValue : offValue);
1027 template<
typename T, Index Log2Dim>
1034 template<
typename T, Index Log2Dim>
1038 std::ostringstream ostr;
1039 ostr <<
"LeafNode @" << mOrigin <<
": " << mBuffer;
1047 template<
typename T, Index Log2Dim>
1051 assert ((xyz[0] & (
DIM-1u)) <
DIM && (xyz[1] & (
DIM-1u)) <
DIM && (xyz[2] & (
DIM-1u)) <
DIM);
1052 return ((xyz[0] & (
DIM-1u)) << 2*Log2Dim)
1053 + ((xyz[1] & (
DIM-1u)) << Log2Dim)
1054 + (xyz[2] & (
DIM-1u));
1057 template<
typename T, Index Log2Dim>
1061 assert(n<(1<< 3*Log2Dim));
1063 xyz.
setX(n >> 2*Log2Dim);
1064 n &= ((1<<2*Log2Dim)-1);
1065 xyz.
setY(n >> Log2Dim);
1066 xyz.
setZ(n & ((1<<Log2Dim)-1));
1071 template<
typename T, Index Log2Dim>
1082 template<
typename ValueT, Index Log2Dim>
1083 inline const ValueT&
1089 template<
typename ValueT, Index Log2Dim>
1090 inline const ValueT&
1093 assert(offset <
SIZE);
1094 return mBuffer[offset];
1098 template<
typename T, Index Log2Dim>
1105 template<
typename T, Index Log2Dim>
1109 assert(offset <
SIZE);
1110 val = mBuffer[offset];
1111 return mValueMask.
isOn(offset);
1115 template<
typename T, Index Log2Dim>
1122 template<
typename T, Index Log2Dim>
1126 assert(offset <
SIZE);
1128 mValueMask.
setOff(offset);
1132 template<
typename T, Index Log2Dim>
1140 template<
typename T, Index Log2Dim>
1147 template<
typename T, Index Log2Dim>
1158 template<
typename T, Index Log2Dim>
1165 this->
fill(background,
false);
1166 }
else if (clipBBox.
isInside(nodeBBox)) {
1178 int &x = xyz.
x(), &y = xyz.
y(), &z = xyz.
z();
1179 for (x = nodeBBox.
min().
x(); x <= nodeBBox.
max().
x(); ++x) {
1180 for (y = nodeBBox.
min().
y(); y <= nodeBBox.
max().
y(); ++y) {
1181 for (z = nodeBBox.
min().
z(); z <= nodeBBox.
max().
z(); ++z) {
1198 template<
typename T, Index Log2Dim>
1202 #ifndef OPENVDB_2_ABI_COMPATIBLE 1207 clippedBBox.intersect(bbox);
1208 if (!clippedBBox)
return;
1210 for (
Int32 x = clippedBBox.min().x(); x <= clippedBBox.max().x(); ++x) {
1211 const Index offsetX = (x & (
DIM-1u)) << 2*Log2Dim;
1212 for (
Int32 y = clippedBBox.min().y(); y <= clippedBBox.max().y(); ++y) {
1213 const Index offsetXY = offsetX + ((y & (
DIM-1u)) << Log2Dim);
1214 for (
Int32 z = clippedBBox.min().z(); z <= clippedBBox.max().z(); ++z) {
1215 const Index offset = offsetXY + (z & (
DIM-1u));
1216 mBuffer[offset] = value;
1217 mValueMask.
set(offset, active);
1223 template<
typename T, Index Log2Dim>
1227 mBuffer.
fill(value);
1230 template<
typename T, Index Log2Dim>
1234 mBuffer.
fill(value);
1235 mValueMask.
set(active);
1242 template<
typename T, Index Log2Dim>
1243 template<
typename DenseT>
1247 #ifndef OPENVDB_2_ABI_COMPATIBLE 1248 mBuffer.loadValues();
1251 using DenseValueType =
typename DenseT::ValueType;
1253 const size_t xStride = dense.xStride(), yStride = dense.yStride(), zStride = dense.zStride();
1254 const Coord&
min = dense.bbox().min();
1255 DenseValueType* t0 = dense.data() + zStride * (bbox.
min()[2] - min[2]);
1256 const T* s0 = &mBuffer[bbox.
min()[2] & (
DIM-1u)];
1257 for (
Int32 x = bbox.
min()[0], ex = bbox.
max()[0] + 1; x < ex; ++x) {
1258 DenseValueType* t1 = t0 + xStride * (x - min[0]);
1259 const T* s1 = s0 + ((x & (
DIM-1u)) << 2*Log2Dim);
1260 for (
Int32 y = bbox.
min()[1], ey = bbox.
max()[1] + 1; y < ey; ++y) {
1261 DenseValueType* t2 = t1 + yStride * (y - min[1]);
1262 const T* s2 = s1 + ((y & (
DIM-1u)) << Log2Dim);
1263 for (
Int32 z = bbox.
min()[2], ez = bbox.
max()[2] + 1; z < ez; ++z, t2 += zStride) {
1264 *t2 = DenseValueType(*s2++);
1271 template<
typename T, Index Log2Dim>
1272 template<
typename DenseT>
1277 #ifndef OPENVDB_2_ABI_COMPATIBLE 1281 using DenseValueType =
typename DenseT::ValueType;
1283 const size_t xStride = dense.xStride(), yStride = dense.yStride(), zStride = dense.zStride();
1284 const Coord&
min = dense.bbox().min();
1286 const DenseValueType* s0 = dense.data() + zStride * (bbox.
min()[2] - min[2]);
1288 for (
Int32 x = bbox.
min()[0], ex = bbox.
max()[0]+1; x < ex; ++x) {
1289 const DenseValueType* s1 = s0 + xStride * (x - min[0]);
1291 for (
Int32 y = bbox.
min()[1], ey = bbox.
max()[1]+1; y < ey; ++y) {
1292 const DenseValueType* s2 = s1 + yStride * (y - min[1]);
1294 for (
Int32 z = bbox.
min()[2], ez = bbox.
max()[2]+1; z < ez; ++z, ++n2, s2 += zStride) {
1297 mBuffer[n2] = background;
1299 mValueMask.
setOn(n2);
1311 template<
typename T, Index Log2Dim>
1315 mValueMask.
load(is);
1319 template<
typename T, Index Log2Dim>
1323 mValueMask.
save(os);
1331 template<
typename T, Index Log2Dim>
1337 io::readCompressedValues<ValueType, NodeMaskType>(
1338 is,
nullptr,
SIZE, mValueMask, fromHalf);
1347 template<
typename T, Index Log2Dim>
1355 template<
typename T, Index Log2Dim>
1360 const bool seekable = meta && meta->seekable();
1362 #ifndef OPENVDB_2_ABI_COMPATIBLE 1363 std::streamoff maskpos = is.tellg();
1368 mValueMask.
seek(is);
1371 mValueMask.
load(is);
1374 int8_t numBuffers = 1;
1380 is.read(reinterpret_cast<char*>(&numBuffers),
sizeof(int8_t));
1388 mBuffer.setOutOfCore(
false);
1390 #ifndef OPENVDB_2_ABI_COMPATIBLE 1396 const bool delayLoad = ((mappedFile.get() !=
nullptr) && clipBBox.
isInside(nodeBBox));
1399 mBuffer.setOutOfCore(
true);
1400 mBuffer.
mFileInfo =
new typename Buffer::FileInfo;
1403 mBuffer.
mFileInfo->mapping = mappedFile;
1413 mBuffer.setOutOfCore(
false);
1416 T background = zeroVal<T>();
1418 background = *
static_cast<const T*
>(bgPtr);
1420 this->
clip(clipBBox, background);
1421 #ifndef OPENVDB_2_ABI_COMPATIBLE 1426 if (numBuffers > 1) {
1431 for (
int i = 1;
i < numBuffers; ++
i) {
1435 io::readData<T>(is, temp.
mData,
SIZE, zipped);
1442 template<
typename T, Index Log2Dim>
1447 mValueMask.
save(os);
1449 mBuffer.loadValues();
1459 template<
typename T, Index Log2Dim>
1463 return mOrigin == other.mOrigin &&
1465 mBuffer == other.mBuffer;
1469 template<
typename T, Index Log2Dim>
1475 return sizeof(*this) + mBuffer.
memUsage() -
sizeof(mBuffer);
1479 template<
typename T, Index Log2Dim>
1484 if (bbox.
isInside(this_bbox))
return;
1488 for(; iter; ++iter) this_bbox.
expand(this->offsetToLocalCoord(iter.pos()));
1496 template<
typename T, Index Log2Dim>
1497 template<
typename OtherType, Index OtherLog2Dim>
1502 return (Log2Dim == OtherLog2Dim && mValueMask == other->
getValueMask());
1505 template<
typename T, Index Log2Dim>
1511 if (!mValueMask.
isConstant(state))
return false;
1512 firstValue = mBuffer[0];
1519 template<
typename T, Index Log2Dim>
1526 if (!mValueMask.
isConstant(state))
return false;
1527 minValue = maxValue = mBuffer[0];
1529 const T& v = mBuffer[
i];
1531 if ((maxValue - v) > tolerance)
return false;
1533 }
else if (v > maxValue) {
1534 if ((v - minValue) > tolerance)
return false;
1541 template<
typename T, Index Log2Dim>
1545 std::unique_ptr<T[]>
data(
nullptr);
1546 if (tmp ==
nullptr) {
1550 if (tmp != mBuffer.
data()) {
1551 const T* src = mBuffer.
data();
1552 for (T* dst = tmp; dst-tmp <
NUM_VALUES;) *dst++ = *src++;
1554 static const size_t midpoint = (
NUM_VALUES - 1) >> 1;
1555 std::nth_element(tmp, tmp + midpoint, tmp +
NUM_VALUES);
1556 return tmp[midpoint];
1559 template<
typename T, Index Log2Dim>
1567 }
else if (count == 0) {
1570 std::unique_ptr<T[]>
data(
nullptr);
1571 if (tmp ==
nullptr) {
1572 data.reset(
new T[count]);
1575 for (
auto iter=this->
cbeginValueOn(); iter; ++iter) *tmp++ = *iter;
1576 T *begin = tmp - count;
1577 const size_t midpoint = (count - 1) >> 1;
1578 std::nth_element(begin, begin + midpoint, tmp);
1579 value = begin[midpoint];
1583 template<
typename T, Index Log2Dim>
1591 }
else if (count == 0) {
1594 std::unique_ptr<T[]>
data(
nullptr);
1595 if (tmp ==
nullptr) {
1596 data.reset(
new T[count]);
1599 for (
auto iter=this->
cbeginValueOff(); iter; ++iter) *tmp++ = *iter;
1600 T *begin = tmp - count;
1601 const size_t midpoint = (count - 1) >> 1;
1602 std::nth_element(begin, begin + midpoint, tmp);
1603 value = begin[midpoint];
1610 template<
typename T, Index Log2Dim>
1617 template<
typename T, Index Log2Dim>
1621 assert(offset <
SIZE);
1626 template<
typename T, Index Log2Dim>
1627 template<
typename AccessorT>
1630 const ValueType& val,
bool active, AccessorT&)
1632 this->
addTile(level, xyz, val, active);
1639 template<
typename T, Index Log2Dim>
1644 #ifndef OPENVDB_2_ABI_COMPATIBLE 1650 for (iter = this->mValueMask.
beginOff(); iter; ++iter) {
1653 inactiveValue = newBackground;
1661 template<
typename T, Index Log2Dim>
1662 template<MergePolicy Policy>
1666 #ifndef OPENVDB_2_ABI_COMPATIBLE 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>
1697 #ifndef OPENVDB_2_ABI_COMPATIBLE 1703 if (!tileActive)
return;
1706 const Index n = iter.pos();
1707 mBuffer[n] = tileValue;
1708 mValueMask.
setOn(n);
1714 template<
typename T, Index Log2Dim>
1715 template<
typename OtherType>
1722 template<
typename T, Index Log2Dim>
1723 template<
typename OtherType>
1731 template<
typename T, Index Log2Dim>
1732 template<
typename OtherType>
1740 template<
typename T, Index Log2Dim>
1744 #ifndef OPENVDB_2_ABI_COMPATIBLE 1748 mBuffer[
i] = -mBuffer[
i];
1756 template<
typename T, Index Log2Dim>
1757 template<
typename CombineOp>
1761 #ifndef OPENVDB_2_ABI_COMPATIBLE 1767 .setAIsActive(mValueMask.
isOn(i))
1768 .setBRef(other.mBuffer[i])
1770 .setResultRef(mBuffer[i]));
1776 template<
typename T, Index Log2Dim>
1777 template<
typename CombineOp>
1781 #ifndef OPENVDB_2_ABI_COMPATIBLE 1785 args.
setBRef(value).setBIsActive(valueIsActive);
1788 .setAIsActive(mValueMask.
isOn(i))
1789 .setResultRef(mBuffer[i]));
1798 template<
typename T, Index Log2Dim>
1799 template<
typename CombineOp,
typename OtherType>
1802 bool valueIsActive, CombineOp& op)
1804 #ifndef OPENVDB_2_ABI_COMPATIBLE 1808 args.
setBRef(value).setBIsActive(valueIsActive);
1812 .setResultRef(mBuffer[
i]));
1818 template<
typename T, Index Log2Dim>
1819 template<
typename CombineOp,
typename OtherNodeT>
1822 bool valueIsActive, CombineOp& op)
1824 #ifndef OPENVDB_2_ABI_COMPATIBLE 1828 args.
setARef(value).setAIsActive(valueIsActive);
1831 .setBIsActive(other.valueMask().isOn(
i))
1832 .setResultRef(mBuffer[
i]));
1838 template<
typename T, Index Log2Dim>
1839 template<
typename CombineOp,
typename OtherNodeT>
1843 #ifndef OPENVDB_2_ABI_COMPATIBLE 1851 .setBRef(b1.mBuffer[
i])
1852 .setBIsActive(b1.valueMask().isOn(
i))
1853 .setResultRef(mBuffer[
i]));
1862 template<
typename T, Index Log2Dim>
1863 template<
typename BBoxOp>
1867 if (op.template descent<LEVEL>()) {
1885 template<
typename T, Index Log2Dim>
1886 template<
typename VisitorOp>
1890 doVisit<LeafNode, VisitorOp, ChildAllIter>(*
this, op);
1894 template<
typename T, Index Log2Dim>
1895 template<
typename VisitorOp>
1899 doVisit<const LeafNode, VisitorOp, ChildAllCIter>(*
this, op);
1903 template<
typename T, Index Log2Dim>
1904 template<
typename NodeT,
typename VisitorOp,
typename ChildAllIterT>
1908 for (ChildAllIterT iter =
self.
beginChildAll(); iter; ++iter) {
1917 template<
typename T, Index Log2Dim>
1918 template<
typename OtherLeafNodeType,
typename VisitorOp>
1923 typename OtherLeafNodeType::ChildAllIter>(*
this, other, op);
1927 template<
typename T, Index Log2Dim>
1928 template<
typename OtherLeafNodeType,
typename VisitorOp>
1933 typename OtherLeafNodeType::ChildAllCIter>(*
this, other, op);
1937 template<
typename T, Index Log2Dim>
1940 typename OtherNodeT,
1942 typename ChildAllIterT,
1943 typename OtherChildAllIterT>
1948 static_assert(OtherNodeT::SIZE == NodeT::SIZE,
1949 "can't visit nodes of different sizes simultaneously");
1950 static_assert(OtherNodeT::LEVEL == NodeT::LEVEL,
1951 "can't visit nodes at different tree levels simultaneously");
1953 ChildAllIterT iter =
self.beginChildAll();
1954 OtherChildAllIterT otherIter = other.beginChildAll();
1956 for ( ; iter && otherIter; ++iter, ++otherIter) {
1957 op(iter, otherIter);
1965 template<
typename T, Index Log2Dim>
1966 template<
typename IterT,
typename VisitorOp>
1970 doVisit2<LeafNode, VisitorOp, ChildAllIter, IterT>(
1971 *
this, otherIter, op, otherIsLHS);
1975 template<
typename T, Index Log2Dim>
1976 template<
typename IterT,
typename VisitorOp>
1980 doVisit2<const LeafNode, VisitorOp, ChildAllCIter, IterT>(
1981 *
this, otherIter, op, otherIsLHS);
1985 template<
typename T, Index Log2Dim>
1989 typename ChildAllIterT,
1990 typename OtherChildAllIterT>
1993 VisitorOp& op,
bool otherIsLHS)
1995 if (!otherIter)
return;
1998 for (ChildAllIterT iter =
self.
beginChildAll(); iter; ++iter) {
1999 op(otherIter, iter);
2002 for (ChildAllIterT iter =
self.
beginChildAll(); iter; ++iter) {
2003 op(iter, otherIter);
2012 template<
typename T, Index Log2Dim>
2013 inline std::ostream&
2014 operator<<(std::ostream& os, const typename LeafNode<T, Log2Dim>::Buffer& buf)
2016 for (
Index32 i = 0, N = buf.size();
i < N; ++
i) os << buf.mData[
i] <<
", ";
2034 #endif // OPENVDB_TREE_LEAFNODE_HAS_BEEN_INCLUDED void writeBuffers(std::ostream &os, bool toHalf=false) const
Write buffers to a stream.
Definition: LeafNode.h:1444
const Buffer & buffer() const
Definition: LeafNode.h:365
bool isValueMaskOn() const
Definition: LeafNode.h:883
Base class for sparse iterators over internal and leaf nodes.
Definition: Iterator.h:143
ValueOnCIter cendValueOn() const
Definition: LeafNode.h:327
NodeT * probeNodeAndCache(const Coord &, AccessorT &)
Return a pointer to this node.
Definition: LeafNode.h:752
ValueT & getValue() const
Definition: LeafNode.h:245
static void getNodeLog2Dims(std::vector< Index > &dims)
Append the Log2Dim of this LeafNode to the specified vector.
Definition: LeafNode.h:154
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:447
Index memUsage() const
Return the memory footprint of this buffer in bytes.
Definition: LeafBuffer.h:377
bool operator!=(const LeafNode &other) const
Definition: LeafNode.h:221
NodeT * stealNode(const Coord &, const ValueType &, bool)
This function exists only to enable template instantiation.
Definition: LeafNode.h:732
typename NodeMaskType::DenseIterator MaskDenseIterator
Definition: LeafNode.h:226
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...
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.
static Index getLevel()
Return the level of this node, which by definition is zero for LeafNodes.
Definition: LeafNode.h:152
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:465
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:1134
Index64 offLeafVoxelCount() const
Definition: LeafNode.h:167
SharedPtr< LeafNode > Ptr
Definition: LeafNode.h:69
static Index64 offTileCount()
Definition: LeafNode.h:169
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:1499
ChildOffIter endChildOff()
Definition: LeafNode.h:354
std::shared_ptr< T > SharedPtr
Definition: Types.h:130
bool isValueMaskOn(Index n) const
Definition: LeafNode.h:882
OPENVDB_API SharedPtr< StreamMetadata > getStreamMetadataPtr(std::ios_base &)
Return a shared pointer to an object that stores metadata (file format, compression scheme...
Int32 z() const
Definition: Coord.h:156
Coord offsetToGlobalCoord(Index n) const
Return the global coordinates for a linear table offset.
Definition: LeafNode.h:1073
NodeMaskType & getValueMask()
Definition: LeafNode.h:887
void modifyValueAndActiveStateAndCache(const Coord &xyz, const ModifyOp &op, AccessorT &)
Definition: LeafNode.h:587
Coord & setZ(Int32 z)
Definition: Coord.h:105
Definition: LeafNode.h:46
Index64 memUsage() const
Return the memory in bytes occupied by this node.
Definition: LeafNode.h:1471
ValueOnCIter beginValueOn() const
Definition: LeafNode.h:318
std::string str() const
Return a string representation of this node.
Definition: LeafNode.h:1036
bool isOn(Index32 n) const
Return true if the nth bit is on.
Definition: NodeMasks.h:502
void visit(VisitorOp &)
Definition: LeafNode.h:1888
ChildOnCIter cendChildOn() const
Definition: LeafNode.h:349
void clip(const CoordBBox &, const ValueType &background)
Set all voxels that lie outside the given axis-aligned box to the background.
Definition: LeafNode.h:1160
bool operator==(const LeafNode &other) const
Check for buffer, state and origin equivalence.
Definition: LeafNode.h:1461
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:1200
Base class for iterators over internal and leaf nodes.
Definition: Iterator.h:58
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:613
static Index dim()
Return the number of voxels in each coordinate dimension.
Definition: LeafNode.h:146
void skipCompressedValues(bool seekable, std::istream &, bool fromHalf)
Definition: LeafNode.h:1333
static Index getValueLevel(const Coord &)
Return the level (i.e., 0) at which leaf node values reside.
Definition: LeafNode.h:414
LeafNode()
Default constructor.
Definition: LeafNode.h:943
static void evalNodeOrigin(Coord &xyz)
Compute the origin of the leaf node that contains the voxel with the given coordinates.
Definition: LeafNode.h:901
void setValueMaskOn(Index n)
Definition: LeafNode.h:895
bool isValueOn(Index offset) const
Return true if the voxel at the given offset is active.
Definition: LeafNode.h:490
Int32 y() const
Definition: Coord.h:155
void visitActiveBBox(BBoxOp &) const
Calls the templated functor BBoxOp with bounding box information. An additional level argument is pro...
Definition: LeafNode.h:1865
void modifyItem(Index n, const ModifyOp &op) const
Definition: LeafNode.h:260
uint32_t Index32
Definition: Types.h:55
static const Index LEVEL
Definition: LeafNode.h:78
void addTileAndCache(Index, const Coord &, const ValueType &, bool, AccessorT &)
Definition: LeafNode.h:1629
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:1734
ChildOffCIter endChildOff() const
Definition: LeafNode.h:353
void modifyValue(const ModifyOp &op) const
Definition: LeafNode.h:263
tbb::atomic< Index32 > i
Definition: LeafBuffer.h:71
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
bool isDense() const
Return true if this node contains only active voxels.
Definition: LeafNode.h:173
void setValueMaskOff(Index n)
Definition: LeafNode.h:896
ValueAllIter endValueAll()
Definition: LeafNode.h:335
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:1274
Index64 offVoxelCount() const
Return the number of voxels marked Off.
Definition: LeafNode.h:165
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:441
Axis-aligned bounding box of signed integer coordinates.
Definition: Coord.h:261
T * data
Definition: LeafBuffer.h:71
ValueIter(const MaskIterT &iter, NodeT *parent)
Definition: LeafNode.h:242
DenseIter(const MaskDenseIterator &iter, NodeT *parent)
Definition: LeafNode.h:284
Index32 pos() const
Definition: NodeMasks.h:200
Definition: LeafNode.h:277
void visit2(IterT &otherIter, VisitorOp &, bool otherIsLHS=false)
Definition: LeafNode.h:1968
void expand(ValueType padding)
Pad this bounding box with the specified padding.
Definition: Coord.h:419
static bool hasActiveTiles()
Return false since leaf nodes never contain tiles.
Definition: LeafNode.h:493
OffIterator beginOff() const
Definition: NodeMasks.h:354
static Index numValues()
Return the total number of voxels represented by this LeafNode.
Definition: LeafNode.h:150
Definition: LeafNode.h:230
typename BaseT::NonConstValueType NonConstValueT
Definition: LeafNode.h:281
ChildAllIter beginChildAll()
Definition: LeafNode.h:347
static void doVisit2(NodeT &self, OtherChildAllIterT &, VisitorOp &, bool otherIsLHS)
Definition: LeafNode.h:1992
const NodeMaskType & getValueMask() const
Definition: LeafNode.h:886
Index32 Index
Definition: Types.h:57
Definition: NodeMasks.h:270
ValueOnCIter cbeginValueOn() const
Definition: LeafNode.h:317
bool isEmpty() const
Return true if this node has no active voxels.
Definition: LeafNode.h:171
DenseIter< LeafNode, ValueType, ChildAll > ChildAllIter
Definition: LeafNode.h:314
ValueOffCIter cbeginValueOff() const
Definition: LeafNode.h:320
static Index size()
Return the total number of voxels represented by this LeafNode.
Definition: LeafNode.h:148
Tag dispatch class that distinguishes constructors during file input.
Definition: Types.h:505
ChildAllCIter cbeginChildAll() const
Definition: LeafNode.h:345
const ValueType & getValue(const Coord &xyz) const
Return the value of the voxel at the given coordinates.
Definition: LeafNode.h:1084
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:1142
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:570
ValueType * mData
Definition: LeafBuffer.h:220
void combine2(const LeafNode &other, const OtherType &, bool valueIsActive, CombineOp &)
Definition: LeafNode.h:1801
const ValueType * data() const
Return a const pointer to the array of voxel values.
Definition: LeafBuffer.h:392
static Index32 nonLeafCount()
Return the non-leaf count for this node, which is zero.
Definition: LeafNode.h:160
bool isConstant(ValueType &firstValue, bool &state, const ValueType &tolerance=zeroVal< ValueType >()) const
Definition: LeafNode.h:1507
typename NodeMaskType::OffIterator MaskOffIterator
Definition: LeafNode.h:225
void writeTopology(std::ostream &os, bool toHalf=false) const
Write out just the topology.
Definition: LeafNode.h:1321
ValueOffCIter endValueOff() const
Definition: LeafNode.h:331
ValueAllCIter cbeginValueAll() const
Definition: LeafNode.h:323
LeafNode * touchLeafAndCache(const Coord &, AccessorT &)
Return a pointer to this node.
Definition: LeafNode.h:750
bool isChildMaskOff() const
Definition: LeafNode.h:892
ValueType ValueType
Definition: Iterator.h:146
void setValuesOff()
Mark all voxels as inactive but don't change their values.
Definition: LeafNode.h:485
void writeCompressedValues(std::ostream &os, ValueT *srcBuf, Index srcCount, const MaskT &valueMask, const MaskT &childMask, bool toHalf)
Definition: Compression.h:462
void setValueOff(const Coord &xyz)
Mark the voxel at the given coordinates as inactive but don't change its value.
Definition: LeafNode.h:427
void resetBackground(const ValueType &oldBackground, const ValueType &newBackground)
Replace inactive occurrences of oldBackground with newBackground, and inactive occurrences of -oldBac...
Definition: LeafNode.h:1641
Templated block class to hold specific data types and a fixed number of values determined by Log2Dim...
Definition: LeafNode.h:61
uint64_t Index64
Definition: Types.h:56
const LeafNode * probeLeafAndCache(const Coord &, AccessorT &) const
Return a const pointer to this node.
Definition: LeafNode.h:769
Buffer & buffer()
Definition: LeafNode.h:366
void setValueOff(Index offset)
Mark the voxel at the given offset as inactive but don't change its value.
Definition: LeafNode.h:429
ValueConverter<T>::Type is the type of a LeafNode having the same dimensions as this node but a diffe...
Definition: LeafNode.h:83
void merge(const LeafNode &)
Definition: LeafNode.h:1664
static Index getValueLevelAndCache(const Coord &, AccessorT &)
Return the LEVEL (=0) at which leaf node values reside.
Definition: LeafNode.h:633
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:561
Index medianOn(ValueType &value, ValueType *tmp=nullptr) const
Computes the median value of all the active voxels in this node.
Definition: LeafNode.h:1561
~LeafNode()
Destructor.
Definition: LeafNode.h:1029
Definition: LeafNode.h:229
const NodeT * probeConstNode(const Coord &) const
This function exists only to enable template instantiation.
Definition: LeafNode.h:736
void modifyValueAndActiveState(const Coord &xyz, const ModifyOp &op)
Apply a functor to the voxel at the given coordinates.
Definition: LeafNode.h:472
#define OPENVDB_VERSION_NAME
Definition: version.h:43
const Coord & origin() const
Return the grid index coordinates of this node's local origin.
Definition: LeafNode.h:198
CombineArgs & setBRef(const BValueType &b)
Redirect the B value to a new external source.
Definition: Types.h:426
void unsetItem(Index pos, const ValueT &value) const
Definition: LeafNode.h:297
ValueT & getItem(Index pos) const
Definition: LeafNode.h:244
void translate(const Coord &t)
Translate this bounding box by .
Definition: Coord.h:458
DenseIter()
Definition: LeafNode.h:283
CoordBBox getNodeBoundingBox() const
Return the bounding box of this node, i.e., the full index space spanned by this leaf node...
Definition: LeafNode.h:192
static Index log2dim()
Return log2 of the dimension of this LeafNode, e.g. 3 if dimensions are 8^3.
Definition: LeafNode.h:144
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:622
typename NodeMaskType::OnIterator MaskOnIterator
Definition: LeafNode.h:224
T negative(const T &val)
Return the unary negation of the given value.
Definition: Math.h:108
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:604
Index64 onLeafVoxelCount() const
Definition: LeafNode.h:166
static const Index NUM_VALUES
Definition: LeafNode.h:75
void stealNodes(ArrayT &, const ValueType &, bool)
This function exists only to enable template instantiation.
Definition: LeafNode.h:738
Definition: LeafNode.h:229
ChildAllIter endChildAll()
Definition: LeafNode.h:357
const ValueType & getValueAndCache(const Coord &xyz, AccessorT &) const
Return the value of the voxel at the given coordinates.
Definition: LeafNode.h:548
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:445
Leaf nodes have no children, so their child iterators have no get/set accessors.
Definition: LeafNode.h:268
ValueOffIter beginValueOff()
Definition: LeafNode.h:322
ChildAllCIter endChildAll() const
Definition: LeafNode.h:356
ChildAllCIter beginChildAll() const
Definition: LeafNode.h:346
static Coord offsetToLocalCoord(Index n)
Return the local coordinates for a linear table offset, where offset 0 has coordinates (0...
Definition: LeafNode.h:1059
void readCompressedValues(std::istream &is, ValueT *destBuf, Index destCount, const MaskT &valueMask, bool fromHalf)
Definition: Compression.h:339
static CoordBBox inf()
Return an "infinite" bounding box, as defined by the Coord value range.
Definition: Coord.h:332
ChildOnIter beginChildOn()
Definition: LeafNode.h:341
const ValueType & getLastValue() const
Return a const reference to the last value in the buffer.
Definition: LeafNode.h:640
void setValueMask(Index n, bool on)
Definition: LeafNode.h:894
ChildOnCIter endChildOn() const
Definition: LeafNode.h:350
bool isValueOnAndCache(const Coord &xyz, AccessorT &) const
Return true if the voxel at the given coordinates is active.
Definition: LeafNode.h:556
bool isChildMaskOn(Index) const
Definition: LeafNode.h:890
void seek(std::istream &is) const
Definition: NodeMasks.h:572
bool isInactive() const
Return true if all of this node's values are inactive.
Definition: LeafNode.h:857
ValueOffIter endValueOff()
Definition: LeafNode.h:332
bool isValueMaskOff() const
Definition: LeafNode.h:885
bool allocate()
Allocate memory for this buffer if it has not already been allocated.
Definition: LeafBuffer.h:147
static Index coordToOffset(const Coord &xyz)
Return the linear table offset of the given global or local coordinates.
Definition: LeafNode.h:1049
Definition: LeafNode.h:229
void save(std::ostream &os) const
Definition: NodeMasks.h:565
bool isInside(const Coord &xyz) const
Return true if point (x, y, z) is inside this bounding box.
Definition: Coord.h:401
Definition: Exceptions.h:39
Coord & setX(Int32 x)
Definition: Coord.h:103
bool operator==(const Vec3< T0 > &v0, const Vec3< T1 > &v1)
Equality operator, does exact floating point comparisons.
Definition: Vec3.h:487
ChildIter(const MaskIterT &iter, NodeT *parent)
Definition: LeafNode.h:272
Definition: version.h:110
ValueAllCIter beginValueAll() const
Definition: LeafNode.h:324
void setItem(Index pos, const ValueT &value) const
Definition: LeafNode.h:248
void combine(const LeafNode &other, CombineOp &op)
Definition: LeafNode.h:1759
Index32 countOn() const
Return the total number of on bits.
Definition: NodeMasks.h:443
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:1717
const Coord & max() const
Definition: Coord.h:335
Definition: NodeMasks.h:239
bool resultIsActive() const
Definition: Types.h:435
This struct collects both input and output arguments to "grid combiner" functors used with the tree::...
Definition: Types.h:371
bool isValueMaskOff(Index n) const
Definition: LeafNode.h:884
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:364
void intersect(const CoordBBox &bbox)
Intersect this bounding box with the given bounding box.
Definition: Coord.h:445
ChildOffCIter cbeginChildOff() const
Definition: LeafNode.h:342
Index64 onVoxelCount() const
Return the number of voxels marked On.
Definition: LeafNode.h:163
ChildOffCIter beginChildOff() const
Definition: LeafNode.h:343
T ValueType
Definition: LeafNode.h:65
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:501
void visit2Node(OtherLeafNodeType &other, VisitorOp &)
Definition: LeafNode.h:1920
void negate()
Definition: LeafNode.h:1742
SameConfiguration<OtherNodeType>::value is true if and only if OtherNodeType is the type of a LeafNod...
Definition: LeafNode.h:88
static Index32 leafCount()
Return the leaf count for this node, which is one.
Definition: LeafNode.h:158
static const Index LOG2DIM
Definition: LeafNode.h:72
OPENVDB_API uint32_t getFormatVersion(std::ios_base &)
Return the file format version number associated with the given input stream.
ChildOnIter endChildOn()
Definition: LeafNode.h:351
CombineArgs & setARef(const AValueType &a)
Redirect the A value to a new external source.
Definition: Types.h:424
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:419
ChildOffCIter cendChildOff() const
Definition: LeafNode.h:352
static const Index SIZE
Definition: LeafNode.h:77
const NodeT * probeConstNodeAndCache(const Coord &, AccessorT &) const
Return a const pointer to this node.
Definition: LeafNode.h:772
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:455
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:579
static CoordBBox createCube(const Coord &min, ValueType dim)
Definition: Coord.h:326
void readBuffers(std::istream &is, bool fromHalf=false)
Read buffers from a stream.
Definition: LeafNode.h:1349
bool probeValue(const Coord &xyz, ValueType &val) const
Return true if the voxel at the given coordinates is active.
Definition: LeafNode.h:1100
FileInfo * mFileInfo
Definition: LeafBuffer.h:221
void addLeafAndCache(LeafNode *, AccessorT &)
This function exists only to enable template instantiation.
Definition: LeafNode.h:730
const NodeMaskType & valueMask() const
Definition: LeafNode.h:888
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:595
void fill(const ValueType &)
Populate this buffer with a constant value.
Definition: LeafBuffer.h:338
SharedPtr< MappedFile > Ptr
Definition: io.h:152
void setValueOn(Index offset)
Mark the voxel at the given offset as active but don't change its value.
Definition: LeafNode.h:439
ChildOffIter beginChildOff()
Definition: LeafNode.h:344
Index32 countOff() const
Return the total number of on bits.
Definition: NodeMasks.h:450
ValueIter()
Definition: LeafNode.h:241
bool getItem(Index pos, void *&child, NonConstValueT &value) const
Definition: LeafNode.h:286
Int32 x() const
Definition: Coord.h:154
const LeafNode * probeConstLeafAndCache(const Coord &, AccessorT &) const
Return a const pointer to this node.
Definition: LeafNode.h:767
const ValueType & getFirstValue() const
Return a const reference to the first value in the buffer.
Definition: LeafNode.h:638
Definition: LeafNode.h:230
void setValue(const ValueT &value) const
Definition: LeafNode.h:253
static Index getChildDim()
Return the dimension of child nodes of this LeafNode, which is one for voxels.
Definition: LeafNode.h:156
Definition: NodeMasks.h:208
void getNodes(ArrayT &) const
This function exists only to enable template instantiation.
Definition: LeafNode.h:737
T BuildType
Definition: LeafNode.h:64
const LeafNode * probeLeaf(const Coord &) const
Return a const pointer to this node.
Definition: LeafNode.h:770
ChildIter()
Definition: LeafNode.h:271
ValueOnIter beginValueOn()
Definition: LeafNode.h:319
LeafNode * probeLeafAndCache(const Coord &, AccessorT &)
Return a pointer to this node.
Definition: LeafNode.h:761
ValueOffCIter beginValueOff() const
Definition: LeafNode.h:321
bool isConstant(bool &isOn) const
Definition: NodeMasks.h:526
ValueOffCIter cendValueOff() const
Definition: LeafNode.h:330
Definition: PointDataGrid.h:192
ValueOnIter endValueOn()
Definition: LeafNode.h:329
Definition: Compression.h:79
void set(Index32 n, bool On)
Set the nth bit to the specified state.
Definition: NodeMasks.h:462
Tag dispatch class that distinguishes topology copy constructors from deep copy constructors.
Definition: Types.h:503
Index medianOff(ValueType &value, ValueType *tmp=nullptr) const
Computes the median value of all the inactive voxels in this node.
Definition: LeafNode.h:1585
ValueType medianAll(ValueType *tmp=nullptr) const
Computes the median value of all the active AND inactive voxels in this node.
Definition: LeafNode.h:1543
ValueOnCIter endValueOn() const
Definition: LeafNode.h:328
Signed (x, y, z) 32-bit integer coordinates.
Definition: Coord.h:48
void getOrigin(Int32 &x, Int32 &y, Int32 &z) const
Return the grid index coordinates of this node's local origin.
Definition: LeafNode.h:200
ChildAllCIter cendChildAll() const
Definition: LeafNode.h:355
ChildOnCIter cbeginChildOn() const
Definition: LeafNode.h:339
void setOrigin(const Coord &origin)
Set the grid index coordinates of this node's local origin.
Definition: LeafNode.h:195
ChildOnCIter beginChildOn() const
Definition: LeafNode.h:340
ValueAllCIter cendValueAll() const
Definition: LeafNode.h:333
int32_t Int32
Definition: Types.h:59
void voxelizeActiveTiles(bool=true)
No-op.
Definition: LeafNode.h:650
Bit mask for the internal and leaf nodes of VDB. This is a 64-bit implementation. ...
Definition: NodeMasks.h:307
void setValueOn(const Coord &xyz)
Mark the voxel at the given coordinates as active but don't change its value.
Definition: LeafNode.h:437
ValueAllCIter endValueAll() const
Definition: LeafNode.h:334
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:1725
static void doVisit(NodeT &, VisitorOp &)
Definition: LeafNode.h:1906
DenseIter< const LeafNode, const ValueType, ChildAll > ChildAllCIter
Definition: LeafNode.h:315
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h:71
Int32 ValueType
Definition: Coord.h:56
static Index64 onTileCount()
Definition: LeafNode.h:168
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:1245
Coord & setY(Int32 y)
Definition: Coord.h:104
void load(std::istream &is)
Definition: NodeMasks.h:569
const Coord & min() const
Definition: Coord.h:334
bool isOff(Index32 n) const
Return true if the nth bit is off.
Definition: NodeMasks.h:508
void addLeaf(LeafNode *)
This function exists only to enable template instantiation.
Definition: LeafNode.h:728
void reset()
Definition: Coord.h:340
void evalActiveBoundingBox(CoordBBox &bbox, bool visitVoxels=true) const
Definition: LeafNode.h:1481
NodeT * probeNode(const Coord &)
This function exists only to enable template instantiation.
Definition: LeafNode.h:734
LeafNode * probeLeaf(const Coord &)
Return a pointer to this node.
Definition: LeafNode.h:759
void setOff(Index32 n)
Set the nth bit off.
Definition: NodeMasks.h:457
bool hasOverlap(const CoordBBox &b) const
Return true if the given bounding box overlaps with this bounding box.
Definition: Coord.h:413
ValueAllIter beginValueAll()
Definition: LeafNode.h:325
static void doVisit2Node(NodeT &self, OtherNodeT &other, VisitorOp &)
Definition: LeafNode.h:1945
void setValuesOn()
Mark all voxels as active but don't change their values.
Definition: LeafNode.h:483
bool isValueOn(const Coord &xyz) const
Return true if the voxel at the given coordinates is active.
Definition: LeafNode.h:488
void setOn(Index32 n)
Set the nth bit on.
Definition: NodeMasks.h:452
static const Index DIM
Definition: LeafNode.h:74
void setValueMask(const NodeMaskType &mask)
Definition: LeafNode.h:889
Definition: LeafNode.h:233
boost::remove_const< UnsetItemT >::type NonConstValueType
Definition: Iterator.h:212
void setValue(Index i, const ValueType &)
Set the i'th value of this buffer to the specified value.
Definition: LeafBuffer.h:289
void getOrigin(Coord &origin) const
Return the grid index coordinates of this node's local origin.
Definition: LeafNode.h:199
Definition: Compression.h:216
void addTile(Index level, const Coord &, const ValueType &, bool)
Definition: LeafNode.h:1612
bool allocate()
Allocate memory for this node's buffer if it has not already been allocated.
Definition: LeafNode.h:179
Base class for dense iterators over internal and leaf nodes.
Definition: Iterator.h:206
OnIterator beginOn() const
Definition: NodeMasks.h:352
bool isChildMaskOff(Index) const
Definition: LeafNode.h:891
void readTopology(std::istream &is, bool fromHalf=false)
Read in just the topology.
Definition: LeafNode.h:1313
Definition: LeafNode.h:230
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.