4#ifndef OPENVDB_TREE_LEAFNODE_HAS_BEEN_INCLUDED
5#define OPENVDB_TREE_LEAFNODE_HAS_BEEN_INCLUDED
29template<Index,
typename>
struct SameLeafConfig;
36template<
typename T, Index Log2Dim>
51 NUM_VALUES = 1 << 3 * Log2Dim,
52 NUM_VOXELS = NUM_VALUES,
58 template<
typename OtherValueType>
63 template<
typename OtherNodeType>
97 template<
typename OtherValueType>
101 template<
typename OtherValueType>
106 template<
typename OtherValueType>
148 bool isEmpty()
const {
return mValueMask.isOff(); }
150 bool isDense()
const {
return mValueMask.isOn(); }
152 bool isAllocated()
const {
return !mBuffer.isOutOfCore() && !mBuffer.empty(); }
162 void evalActiveBoundingBox(
CoordBBox& bbox,
bool visitVoxels =
true)
const;
185#if OPENVDB_ABI_VERSION_NUMBER >= 9
193 std::string str()
const;
197 template<
typename OtherType, Index OtherLog2Dim>
213 template<
typename MaskIterT,
typename NodeT,
typename ValueT,
typename TagT>
218 MaskIterT, ValueIter<MaskIterT, NodeT, ValueT, TagT>, NodeT, ValueT>
225 ValueT&
getItem(
Index pos)
const {
return this->parent().getValue(pos); }
226 ValueT&
getValue()
const {
return this->parent().getValue(this->pos()); }
231 this->parent().setValueOnly(pos,
value);
236 this->parent().setValueOnly(this->pos(),
value);
240 template<
typename ModifyOp>
241 void modifyItem(
Index n,
const ModifyOp& op)
const { this->parent().modifyValue(n, op); }
243 template<
typename ModifyOp>
244 void modifyValue(
const ModifyOp& op)
const { this->parent().modifyValue(this->pos(), op); }
248 template<
typename MaskIterT,
typename NodeT,
typename TagT>
250 public SparseIteratorBase<MaskIterT, ChildIter<MaskIterT, NodeT, TagT>, NodeT, ValueType>
257 template<
typename NodeT,
typename ValueT,
typename TagT>
259 MaskDenseIterator, DenseIter<NodeT, ValueT, TagT>, NodeT, void, ValueT>
269 value = this->parent().getValue(pos);
280 this->parent().setValueOnly(pos,
value);
355 void readTopology(std::istream& is,
bool fromHalf =
false);
359 void writeTopology(std::ostream& os,
bool toHalf =
false)
const;
364 void readBuffers(std::istream& is,
bool fromHalf =
false);
369 void readBuffers(std::istream& is,
const CoordBBox& bbox,
bool fromHalf =
false);
373 void writeBuffers(std::ostream& os,
bool toHalf =
false)
const;
398 void setActiveState(
const Coord& xyz,
bool on);
403 void setValueOnly(
const Coord& xyz,
const ValueType& val);
405 void setValueOnly(
Index offset,
const ValueType& val);
413 void setValueOff(
const Coord& xyz,
const ValueType& val);
415 void setValueOff(
Index offset,
const ValueType& val);
423 this->setValueOn(LeafNode::coordToOffset(xyz), val);
429 mBuffer.setValue(offset, val);
430 mValueMask.setOn(offset);
435 template<
typename ModifyOp>
438 mBuffer.loadValues();
439 if (!mBuffer.empty()) {
443 mValueMask.setOn(offset);
449 template<
typename ModifyOp>
452 this->modifyValue(this->coordToOffset(xyz), op);
456 template<
typename ModifyOp>
459 mBuffer.loadValues();
460 if (!mBuffer.empty()) {
461 const Index offset = this->coordToOffset(xyz);
462 bool state = mValueMask.isOn(offset);
466 mValueMask.set(offset, state);
487 void fill(
const CoordBBox& bbox,
const ValueType&,
bool active =
true);
491 this->fill(bbox,
value, active);
495 void fill(
const ValueType&
value);
497 void fill(
const ValueType&
value,
bool active);
510 template<
typename DenseT>
529 template<
typename DenseT>
531 const ValueType& background,
const ValueType& tolerance);
535 template<
typename AccessorT>
538 return this->getValue(xyz);
543 template<
typename AccessorT>
548 template<
typename AccessorT>
551 this->setValueOn(xyz, val);
557 template<
typename AccessorT>
560 this->setValueOnly(xyz, val);
566 template<
typename ModifyOp,
typename AccessorT>
569 this->modifyValue(xyz, op);
574 template<
typename ModifyOp,
typename AccessorT>
577 this->modifyValueAndActiveState(xyz, op);
582 template<
typename AccessorT>
585 this->setValueOff(xyz,
value);
591 template<
typename AccessorT>
594 this->setActiveState(xyz, on);
600 template<
typename AccessorT>
603 return this->probeValue(xyz, val);
609 template<
typename AccessorT>
612 const Index offset = this->coordToOffset(xyz);
613 state = mValueMask.isOn(offset);
615 return mBuffer[offset];
620 template<
typename AccessorT>
632 void resetBackground(
const ValueType& oldBackground,
const ValueType& newBackground);
640 template<MergePolicy Policy>
void merge(
const LeafNode&);
641 template<MergePolicy Policy>
void merge(
const ValueType& tileValue,
bool tileActive);
642 template<MergePolicy Policy>
643 void merge(
const LeafNode& other,
const ValueType& ,
const ValueType& );
651 template<
typename OtherType>
665 template<
typename OtherType>
679 template<
typename OtherType>
682 template<
typename CombineOp>
684 template<
typename CombineOp>
685 void combine(
const ValueType&
value,
bool valueIsActive, CombineOp& op);
687 template<
typename CombineOp,
typename OtherType >
688 void combine2(
const LeafNode& other,
const OtherType&,
bool valueIsActive, CombineOp&);
689 template<
typename CombineOp,
typename OtherNodeT >
690 void combine2(
const ValueType&,
const OtherNodeT& other,
bool valueIsActive, CombineOp&);
691 template<
typename CombineOp,
typename OtherNodeT >
692 void combine2(
const LeafNode& b0,
const OtherNodeT& b1, CombineOp&);
699 template<
typename BBoxOp>
void visitActiveBBox(BBoxOp&)
const;
701 template<
typename VisitorOp>
void visit(VisitorOp&);
702 template<
typename VisitorOp>
void visit(VisitorOp&)
const;
704 template<
typename OtherLeafNodeType,
typename VisitorOp>
705 void visit2Node(OtherLeafNodeType& other, VisitorOp&);
706 template<
typename OtherLeafNodeType,
typename VisitorOp>
707 void visit2Node(OtherLeafNodeType& other, VisitorOp&)
const;
708 template<
typename IterT,
typename VisitorOp>
709 void visit2(IterT& otherIter, VisitorOp&,
bool otherIsLHS =
false);
710 template<
typename IterT,
typename VisitorOp>
711 void visit2(IterT& otherIter, VisitorOp&,
bool otherIsLHS =
false)
const;
717 template<
typename AccessorT>
719 template<
typename NodeT>
721 template<
typename NodeT>
723 template<
typename NodeT>
725 template<
typename ArrayT>
void getNodes(ArrayT&)
const {}
729 void addTile(
Index level,
const Coord&,
const ValueType&,
bool);
730 void addTile(
Index offset,
const ValueType&,
bool);
731 template<
typename AccessorT>
732 void addTileAndCache(
Index,
const Coord&,
const ValueType&,
bool, AccessorT&);
737 template<
typename AccessorT>
739 template<
typename NodeT,
typename AccessorT>
744 return reinterpret_cast<NodeT*
>(
this);
748 template<
typename AccessorT>
754 template<
typename AccessorT>
756 template<
typename AccessorT>
759 template<
typename NodeT,
typename AccessorT>
764 return reinterpret_cast<const NodeT*
>(
this);
778 bool isConstant(ValueType& firstValue,
bool& state,
779 const ValueType& tolerance = zeroVal<ValueType>())
const;
792 bool isConstant(ValueType& minValue, ValueType& maxValue,
793 bool& state,
const ValueType& tolerance = zeroVal<ValueType>())
const;
810 ValueType medianAll(ValueType *tmp =
nullptr)
const;
826 Index medianOn(ValueType &
value, ValueType *tmp =
nullptr)
const;
842 Index medianOff(ValueType &
value, ValueType *tmp =
nullptr)
const;
848 friend class ::TestLeaf;
849 template<
typename>
friend class ::TestLeafIO;
886 inline void skipCompressedValues(
bool seekable, std::istream&,
bool fromHalf);
891 template<
typename NodeT,
typename VisitorOp,
typename ChildAllIterT>
892 static inline void doVisit(NodeT&, VisitorOp&);
894 template<
typename NodeT,
typename OtherNodeT,
typename VisitorOp,
895 typename ChildAllIterT,
typename OtherChildAllIterT>
896 static inline void doVisit2Node(NodeT&
self, OtherNodeT& other, VisitorOp&);
898 template<
typename NodeT,
typename VisitorOp,
899 typename ChildAllIterT,
typename OtherChildAllIterT>
900 static inline void doVisit2(NodeT&
self, OtherChildAllIterT&, VisitorOp&,
bool otherIsLHS);
906 NodeMaskType mValueMask;
909#if OPENVDB_ABI_VERSION_NUMBER >= 9
922template<Index Dim1,
typename NodeT2>
925template<Index Dim1,
typename T2>
933template<
typename T, Index Log2Dim>
942template<
typename T, Index Log2Dim>
947 mOrigin(xyz & (~(DIM - 1)))
952template<
typename T, Index Log2Dim>
957 mOrigin(xyz & (~(DIM - 1)))
962template<
typename T, Index Log2Dim>
965 : mBuffer(other.mBuffer)
966 , mValueMask(other.valueMask())
967 , mOrigin(other.mOrigin)
968#if OPENVDB_ABI_VERSION_NUMBER >= 9
969 , mTransientData(other.mTransientData)
976template<
typename T, Index Log2Dim>
977template<
typename OtherValueType>
980 : mValueMask(other.valueMask())
981 , mOrigin(other.mOrigin)
982#if OPENVDB_ABI_VERSION_NUMBER >= 9
983 , mTransientData(other.mTransientData)
988 static inline ValueType convertValue(
const OtherValueType& val) {
return ValueType(val); }
992 mBuffer[i] = Local::convertValue(other.mBuffer[i]);
997template<
typename T, Index Log2Dim>
998template<
typename OtherValueType>
1002 : mBuffer(background)
1003 , mValueMask(other.valueMask())
1004 , mOrigin(other.mOrigin)
1005#if OPENVDB_ABI_VERSION_NUMBER >= 9
1006 , mTransientData(other.mTransientData)
1012template<
typename T, Index Log2Dim>
1013template<
typename OtherValueType>
1017 : mValueMask(other.valueMask())
1018 , mOrigin(other.mOrigin)
1019#if OPENVDB_ABI_VERSION_NUMBER >= 9
1020 , mTransientData(other.mTransientData)
1024 mBuffer[i] = (mValueMask.
isOn(i) ? onValue : offValue);
1029template<
typename T, Index Log2Dim>
1036template<
typename T, Index Log2Dim>
1040 std::ostringstream ostr;
1041 ostr <<
"LeafNode @" << mOrigin <<
": " << mBuffer;
1049template<
typename T, Index Log2Dim>
1053 assert ((xyz[0] & (DIM-1u)) < DIM && (xyz[1] & (DIM-1u)) < DIM && (xyz[2] & (DIM-1u)) < DIM);
1054 return ((xyz[0] & (DIM-1u)) << 2*Log2Dim)
1055 + ((xyz[1] & (DIM-1u)) << Log2Dim)
1056 + (xyz[2] & (DIM-1u));
1059template<
typename T, Index Log2Dim>
1063 assert(n<(1<< 3*Log2Dim));
1065 xyz.
setX(n >> 2*Log2Dim);
1066 n &= ((1<<2*Log2Dim)-1);
1067 xyz.
setY(n >> Log2Dim);
1068 xyz.
setZ(n & ((1<<Log2Dim)-1));
1073template<
typename T, Index Log2Dim>
1077 return (this->offsetToLocalCoord(n) + this->origin());
1084template<
typename ValueT, Index Log2Dim>
1091template<
typename ValueT, Index Log2Dim>
1095 assert(offset < SIZE);
1096 return mBuffer[offset];
1100template<
typename T, Index Log2Dim>
1107template<
typename T, Index Log2Dim>
1111 assert(offset < SIZE);
1112 val = mBuffer[offset];
1113 return mValueMask.isOn(offset);
1117template<
typename T, Index Log2Dim>
1124template<
typename T, Index Log2Dim>
1128 assert(offset < SIZE);
1129 mBuffer.setValue(offset, val);
1130 mValueMask.setOff(offset);
1134template<
typename T, Index Log2Dim>
1138 mValueMask.set(this->coordToOffset(xyz), on);
1142template<
typename T, Index Log2Dim>
1149template<
typename T, Index Log2Dim>
1153 assert(offset<SIZE); mBuffer.setValue(offset, val);
1160template<
typename T, Index Log2Dim>
1164 CoordBBox nodeBBox = this->getNodeBoundingBox();
1167 this->fill(background,
false);
1168 }
else if (clipBBox.
isInside(nodeBBox)) {
1180 int &x = xyz.
x(), &y = xyz.
y(), &z = xyz.
z();
1181 for (x = nodeBBox.
min().
x(); x <= nodeBBox.
max().
x(); ++x) {
1182 for (y = nodeBBox.
min().
y(); y <= nodeBBox.
max().
y(); ++y) {
1183 for (z = nodeBBox.
min().
z(); z <= nodeBBox.
max().
z(); ++z) {
1184 mask.
setOn(
static_cast<Index32>(this->coordToOffset(xyz)));
1192 this->setValueOff(maskIter.pos(), background);
1200template<
typename T, Index Log2Dim>
1206 auto clippedBBox = this->getNodeBoundingBox();
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);
1223template<
typename T, Index Log2Dim>
1227 mBuffer.fill(
value);
1230template<
typename T, Index Log2Dim>
1234 mBuffer.fill(
value);
1235 mValueMask.set(active);
1242template<
typename T, Index Log2Dim>
1243template<
typename DenseT>
1247 mBuffer.loadValues();
1249 using DenseValueType =
typename DenseT::ValueType;
1251 const size_t xStride = dense.xStride(), yStride = dense.yStride(), zStride = dense.zStride();
1252 const Coord&
min = dense.bbox().min();
1253 DenseValueType* t0 = dense.data() + zStride * (bbox.
min()[2] -
min[2]);
1254 const T* s0 = &mBuffer[bbox.
min()[2] & (DIM-1u)];
1255 for (
Int32 x = bbox.
min()[0], ex = bbox.
max()[0] + 1; x < ex; ++x) {
1256 DenseValueType* t1 = t0 + xStride * (x -
min[0]);
1257 const T* s1 = s0 + ((x & (DIM-1u)) << 2*Log2Dim);
1258 for (
Int32 y = bbox.
min()[1], ey = bbox.
max()[1] + 1; y < ey; ++y) {
1259 DenseValueType* t2 = t1 + yStride * (y -
min[1]);
1260 const T* s2 = s1 + ((y & (DIM-1u)) << Log2Dim);
1261 for (
Int32 z = bbox.
min()[2], ez = bbox.
max()[2] + 1; z < ez; ++z, t2 += zStride) {
1262 *t2 = DenseValueType(*s2++);
1269template<
typename T, Index Log2Dim>
1270template<
typename DenseT>
1277 using DenseValueType =
typename DenseT::ValueType;
1279 const size_t xStride = dense.xStride(), yStride = dense.yStride(), zStride = dense.zStride();
1280 const Coord&
min = dense.bbox().min();
1282 const DenseValueType* s0 = dense.data() + zStride * (bbox.
min()[2] -
min[2]);
1283 const Int32 n0 = bbox.
min()[2] & (DIM-1u);
1284 for (
Int32 x = bbox.
min()[0], ex = bbox.
max()[0]+1; x < ex; ++x) {
1285 const DenseValueType* s1 = s0 + xStride * (x -
min[0]);
1286 const Int32 n1 = n0 + ((x & (DIM-1u)) << 2*LOG2DIM);
1287 for (
Int32 y = bbox.
min()[1], ey = bbox.
max()[1]+1; y < ey; ++y) {
1288 const DenseValueType* s2 = s1 + yStride * (y -
min[1]);
1289 Int32 n2 = n1 + ((y & (DIM-1u)) << LOG2DIM);
1290 for (
Int32 z = bbox.
min()[2], ez = bbox.
max()[2]+1; z < ez; ++z, ++n2, s2 += zStride) {
1292 mValueMask.setOff(n2);
1293 mBuffer[n2] = background;
1295 mValueMask.setOn(n2);
1307template<
typename T, Index Log2Dim>
1311 mValueMask.load(is);
1315template<
typename T, Index Log2Dim>
1319 mValueMask.save(os);
1327template<
typename T, Index Log2Dim>
1333 io::readCompressedValues<ValueType, NodeMaskType>(
1334 is,
nullptr, SIZE, mValueMask, fromHalf);
1343template<
typename T, Index Log2Dim>
1351template<
typename T, Index Log2Dim>
1356 const bool seekable = meta && meta->seekable();
1358 std::streamoff maskpos = is.tellg();
1362 mValueMask.seek(is);
1365 mValueMask.load(is);
1368 int8_t numBuffers = 1;
1374 is.read(
reinterpret_cast<char*
>(&numBuffers),
sizeof(int8_t));
1377 CoordBBox nodeBBox = this->getNodeBoundingBox();
1380 skipCompressedValues(seekable, is, fromHalf);
1381 mValueMask.setOff();
1382 mBuffer.setOutOfCore(
false);
1389 const bool delayLoad = ((mappedFile.get() !=
nullptr) && clipBBox.
isInside(nodeBBox));
1392 mBuffer.setOutOfCore(
true);
1393 mBuffer.mFileInfo =
new typename Buffer::FileInfo;
1394 mBuffer.mFileInfo->meta = meta;
1395 mBuffer.mFileInfo->bufpos = is.tellg();
1396 mBuffer.mFileInfo->mapping = mappedFile;
1399 mBuffer.mFileInfo->maskpos = maskpos;
1401 skipCompressedValues(seekable, is, fromHalf);
1405 mBuffer.setOutOfCore(
false);
1408 T background = zeroVal<T>();
1410 background = *
static_cast<const T*
>(bgPtr);
1412 this->
clip(clipBBox, background);
1416 if (numBuffers > 1) {
1421 for (
int i = 1; i < numBuffers; ++i) {
1425 io::readData<T>(is, temp.
mData, SIZE, zipped);
1431 if (meta) meta->setLeaf(meta->leaf() + 1);
1435template<
typename T, Index Log2Dim>
1440 mValueMask.save(os);
1442 mBuffer.loadValues();
1452template<
typename T, Index Log2Dim>
1456 return mOrigin == other.mOrigin &&
1458 mBuffer == other.mBuffer;
1462template<
typename T, Index Log2Dim>
1468 return sizeof(*this) + mBuffer.memUsage() -
sizeof(mBuffer);
1472template<
typename T, Index Log2Dim>
1476 CoordBBox this_bbox = this->getNodeBoundingBox();
1477 if (bbox.
isInside(this_bbox))
return;
1481 for(; iter; ++iter) this_bbox.
expand(this->offsetToLocalCoord(iter.pos()));
1489template<
typename T, Index Log2Dim>
1490template<
typename OtherType, Index OtherLog2Dim>
1495 return (Log2Dim == OtherLog2Dim && mValueMask == other->
getValueMask());
1498template<
typename T, Index Log2Dim>
1504 if (!mValueMask.isConstant(state))
return false;
1505 firstValue = mBuffer[0];
1506 for (
Index i = 1; i < SIZE; ++i) {
1512template<
typename T, Index Log2Dim>
1519 if (!mValueMask.isConstant(state))
return false;
1520 minValue = maxValue = mBuffer[0];
1521 for (
Index i = 1; i < SIZE; ++i) {
1522 const T& v = mBuffer[i];
1524 if ((maxValue - v) > tolerance)
return false;
1526 }
else if (v > maxValue) {
1527 if ((v - minValue) > tolerance)
return false;
1534template<
typename T, Index Log2Dim>
1538 std::unique_ptr<T[]> data(
nullptr);
1539 if (tmp ==
nullptr) {
1540 data.reset(
new T[NUM_VALUES]);
1543 if (tmp != mBuffer.data()) {
1544 const T* src = mBuffer.data();
1545 for (T* dst = tmp; dst-tmp < NUM_VALUES;) *dst++ = *src++;
1547 static const size_t midpoint = (NUM_VALUES - 1) >> 1;
1548 std::nth_element(tmp, tmp + midpoint, tmp + NUM_VALUES);
1549 return tmp[midpoint];
1552template<
typename T, Index Log2Dim>
1556 const Index count = mValueMask.countOn();
1557 if (count == NUM_VALUES) {
1558 value = this->medianAll(tmp);
1560 }
else if (count == 0) {
1563 std::unique_ptr<T[]> data(
nullptr);
1564 if (tmp ==
nullptr) {
1565 data.reset(
new T[count]);
1568 for (
auto iter=this->cbeginValueOn(); iter; ++iter) *tmp++ = *iter;
1569 T *begin = tmp - count;
1570 const size_t midpoint = (count - 1) >> 1;
1571 std::nth_element(begin, begin + midpoint, tmp);
1572 value = begin[midpoint];
1576template<
typename T, Index Log2Dim>
1580 const Index count = mValueMask.countOff();
1581 if (count == NUM_VALUES) {
1582 value = this->medianAll(tmp);
1584 }
else if (count == 0) {
1587 std::unique_ptr<T[]> data(
nullptr);
1588 if (tmp ==
nullptr) {
1589 data.reset(
new T[count]);
1592 for (
auto iter=this->cbeginValueOff(); iter; ++iter) *tmp++ = *iter;
1593 T *begin = tmp - count;
1594 const size_t midpoint = (count - 1) >> 1;
1595 std::nth_element(begin, begin + midpoint, tmp);
1596 value = begin[midpoint];
1603template<
typename T, Index Log2Dim>
1607 this->addTile(this->coordToOffset(xyz), val, active);
1610template<
typename T, Index Log2Dim>
1614 assert(offset < SIZE);
1615 setValueOnly(offset, val);
1616 setActiveState(offset, active);
1619template<
typename T, Index Log2Dim>
1620template<
typename AccessorT>
1623 const ValueType& val,
bool active, AccessorT&)
1625 this->addTile(level, xyz, val, active);
1632template<
typename T, Index Log2Dim>
1641 for (iter = this->mValueMask.beginOff(); iter; ++iter) {
1644 inactiveValue = newBackground;
1652template<
typename T, Index Log2Dim>
1653template<MergePolicy Policy>
1662 for (; iter; ++iter) {
1664 if (mValueMask.isOff(n)) {
1665 mBuffer[n] = other.mBuffer[n];
1666 mValueMask.setOn(n);
1672template<
typename T, Index Log2Dim>
1673template<MergePolicy Policy>
1678 this->
template merge<Policy>(other);
1681template<
typename T, Index Log2Dim>
1682template<MergePolicy Policy>
1690 if (!tileActive)
return;
1693 const Index n = iter.pos();
1694 mBuffer[n] = tileValue;
1695 mValueMask.setOn(n);
1701template<
typename T, Index Log2Dim>
1702template<
typename OtherType>
1709template<
typename T, Index Log2Dim>
1710template<
typename OtherType>
1718template<
typename T, Index Log2Dim>
1719template<
typename OtherType>
1727template<
typename T, Index Log2Dim>
1733 for (
Index i = 0; i < SIZE; ++i) {
1734 mBuffer[i] = -mBuffer[i];
1742template<
typename T, Index Log2Dim>
1743template<
typename CombineOp>
1750 for (
Index i = 0; i < SIZE; ++i) {
1761template<
typename T, Index Log2Dim>
1762template<
typename CombineOp>
1770 for (
Index i = 0; i < SIZE; ++i) {
1782template<
typename T, Index Log2Dim>
1783template<
typename CombineOp,
typename OtherType>
1786 bool valueIsActive, CombineOp& op)
1792 for (
Index i = 0; i < SIZE; ++i) {
1793 op(args.
setARef(other.mBuffer[i])
1801template<
typename T, Index Log2Dim>
1802template<
typename CombineOp,
typename OtherNodeT>
1805 bool valueIsActive, CombineOp& op)
1811 for (
Index i = 0; i < SIZE; ++i) {
1812 op(args.
setBRef(other.mBuffer[i])
1820template<
typename T, Index Log2Dim>
1821template<
typename CombineOp,
typename OtherNodeT>
1828 for (
Index i = 0; i < SIZE; ++i) {
1829 mValueMask.set(i, b0.
valueMask().
isOn(i) || b1.valueMask().isOn(i));
1830 op(args.
setARef(b0.mBuffer[i])
1843template<
typename T, Index Log2Dim>
1844template<
typename BBoxOp>
1848 if (op.template descent<LEVEL>()) {
1853 op.template operator()<LEVEL>(this->getNodeBoundingBox());
1858template<
typename T, Index Log2Dim>
1859template<
typename VisitorOp>
1863 doVisit<LeafNode, VisitorOp, ChildAllIter>(*
this, op);
1867template<
typename T, Index Log2Dim>
1868template<
typename VisitorOp>
1872 doVisit<const LeafNode, VisitorOp, ChildAllCIter>(*
this, op);
1876template<
typename T, Index Log2Dim>
1877template<
typename NodeT,
typename VisitorOp,
typename ChildAllIterT>
1881 for (ChildAllIterT iter =
self.beginChildAll(); iter; ++iter) {
1890template<
typename T, Index Log2Dim>
1891template<
typename OtherLeafNodeType,
typename VisitorOp>
1896 typename OtherLeafNodeType::ChildAllIter>(*
this, other, op);
1900template<
typename T, Index Log2Dim>
1901template<
typename OtherLeafNodeType,
typename VisitorOp>
1906 typename OtherLeafNodeType::ChildAllCIter>(*
this, other, op);
1910template<
typename T, Index Log2Dim>
1913 typename OtherNodeT,
1915 typename ChildAllIterT,
1916 typename OtherChildAllIterT>
1921 static_assert(OtherNodeT::SIZE == NodeT::SIZE,
1922 "can't visit nodes of different sizes simultaneously");
1923 static_assert(OtherNodeT::LEVEL == NodeT::LEVEL,
1924 "can't visit nodes at different tree levels simultaneously");
1926 ChildAllIterT iter =
self.beginChildAll();
1927 OtherChildAllIterT otherIter = other.beginChildAll();
1929 for ( ; iter && otherIter; ++iter, ++otherIter) {
1930 op(iter, otherIter);
1938template<
typename T, Index Log2Dim>
1939template<
typename IterT,
typename VisitorOp>
1943 doVisit2<LeafNode, VisitorOp, ChildAllIter, IterT>(
1944 *
this, otherIter, op, otherIsLHS);
1948template<
typename T, Index Log2Dim>
1949template<
typename IterT,
typename VisitorOp>
1953 doVisit2<const LeafNode, VisitorOp, ChildAllCIter, IterT>(
1954 *
this, otherIter, op, otherIsLHS);
1958template<
typename T, Index Log2Dim>
1962 typename ChildAllIterT,
1963 typename OtherChildAllIterT>
1966 VisitorOp& op,
bool otherIsLHS)
1968 if (!otherIter)
return;
1971 for (ChildAllIterT iter =
self.beginChildAll(); iter; ++iter) {
1972 op(otherIter, iter);
1975 for (ChildAllIterT iter =
self.beginChildAll(); iter; ++iter) {
1976 op(iter, otherIter);
1985template<
typename T, Index Log2Dim>
1989 for (
Index32 i = 0, N = buf.
size(); i < N; ++i) os << buf.
mData[i] <<
", ";
ValueT value
Definition: GridBuilder.h:1287
ChildT * child
Definition: GridBuilder.h:1286
Definition: LeafNode.h:22
This struct collects both input and output arguments to "grid combiner" functors used with the tree::...
Definition: Types.h:451
CombineArgs & setARef(const AValueType &a)
Redirect the A value to a new external source.
Definition: Types.h:503
CombineArgs & setBIsActive(bool b)
Set the active state of the B value.
Definition: Types.h:519
CombineArgs & setResultRef(AValueType &val)
Redirect the result value to a new external destination.
Definition: Types.h:507
CombineArgs & setBRef(const BValueType &b)
Redirect the B value to a new external source.
Definition: Types.h:505
bool resultIsActive() const
Definition: Types.h:514
CombineArgs & setAIsActive(bool b)
Set the active state of the A value.
Definition: Types.h:517
Tag dispatch class that distinguishes constructors during file input.
Definition: Types.h:570
Tag dispatch class that distinguishes topology copy constructors from deep copy constructors.
Definition: Types.h:564
SharedPtr< MappedFile > Ptr
Definition: io.h:136
Axis-aligned bounding box of signed integer coordinates.
Definition: Coord.h:248
void translate(const Coord &t)
Translate this bounding box by (tx, ty, tz).
Definition: Coord.h:457
void expand(ValueType padding)
Pad this bounding box with the specified padding.
Definition: Coord.h:417
const Coord & min() const
Definition: Coord.h:320
bool hasOverlap(const CoordBBox &b) const
Return true if the given bounding box overlaps with this bounding box.
Definition: Coord.h:411
const Coord & max() const
Definition: Coord.h:321
static CoordBBox inf()
Return an "infinite" bounding box, as defined by the Coord value range.
Definition: Coord.h:318
bool isInside(const Coord &xyz) const
Return true if point (x, y, z) is inside this bounding box.
Definition: Coord.h:399
void intersect(const CoordBBox &bbox)
Intersect this bounding box with the given bounding box.
Definition: Coord.h:443
void reset()
Definition: Coord.h:326
static CoordBBox createCube(const Coord &min, ValueType dim)
Definition: Coord.h:312
Signed (x, y, z) 32-bit integer coordinates.
Definition: Coord.h:25
Int32 ValueType
Definition: Coord.h:32
Int32 y() const
Definition: Coord.h:131
Int32 x() const
Definition: Coord.h:130
Coord & setZ(Int32 z)
Definition: Coord.h:81
Coord & setY(Int32 y)
Definition: Coord.h:80
Int32 z() const
Definition: Coord.h:132
Coord & setX(Int32 x)
Definition: Coord.h:79
Base class for iterators over internal and leaf nodes.
Definition: Iterator.h:30
ValueType * mData
Definition: LeafBuffer.h:125
static Index size()
Return the number of values contained in this buffer.
Definition: LeafBuffer.h:91
Templated block class to hold specific data types and a fixed number of values determined by Log2Dim....
Definition: LeafNode.h:38
void stealNodes(ArrayT &, const ValueType &, bool)
Definition: LeafNode.h:726
void visit(VisitorOp &)
Definition: LeafNode.h:1861
LeafNode & operator=(const LeafNode &)=default
Deep assignment operator.
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:601
bool isValueOn(Index offset) const
Return true if the voxel at the given offset is active.
Definition: LeafNode.h:478
static Index64 onTileCount()
Definition: LeafNode.h:145
void getOrigin(Int32 &x, Int32 &y, Int32 &z) const
Definition: LeafNode.h:174
static Coord offsetToLocalCoord(Index n)
Return the local coordinates for a linear table offset, where offset 0 has coordinates (0,...
Definition: LeafNode.h:1061
ChildOnCIter cbeginChildOn() const
Definition: LeafNode.h:320
SharedPtr< LeafNode > Ptr
Definition: LeafNode.h:45
CoordBBox getNodeBoundingBox() const
Return the bounding box of this node, i.e., the full index space spanned by this leaf node.
Definition: LeafNode.h:166
NodeMaskType & getValueMask()
Definition: LeafNode.h:875
void setValueOn(Index offset)
Mark the voxel at the given offset as active but don't change its value.
Definition: LeafNode.h:420
bool isChildMaskOn(Index) const
Definition: LeafNode.h:878
static void doVisit2(NodeT &self, OtherChildAllIterT &, VisitorOp &, bool otherIsLHS)
Definition: LeafNode.h:1965
ChildOnCIter beginChildOn() const
Definition: LeafNode.h:321
ChildOnIter beginChildOn()
Definition: LeafNode.h:322
bool isValueOn(const Coord &xyz) const
Return true if the voxel at the given coordinates is active.
Definition: LeafNode.h:476
ValueOnIter endValueOn()
Definition: LeafNode.h:310
void writeTopology(std::ostream &os, bool toHalf=false) const
Write out just the topology.
Definition: LeafNode.h:1317
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
bool isChildMaskOff() const
Definition: LeafNode.h:880
ValueOffCIter cbeginValueOff() const
Definition: LeafNode.h:301
Index32 transientData() const
Return the transient data value.
Definition: LeafNode.h:187
static Index32 childCount()
Return the child count for this node, which is zero.
Definition: LeafNode.h:137
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:426
static Index getChildDim()
Return the dimension of child nodes of this LeafNode, which is one for voxels.
Definition: LeafNode.h:129
bool operator!=(const LeafNode &other) const
Definition: LeafNode.h:202
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:1272
const ValueType & getValue(const Coord &xyz) const
Return the value of the voxel at the given coordinates.
Definition: LeafNode.h:1086
void setValueMask(const NodeMaskType &mask)
Definition: LeafNode.h:877
ChildOnIter endChildOn()
Definition: LeafNode.h:332
ValueAllIter endValueAll()
Definition: LeafNode.h:316
LeafNode * touchLeaf(const Coord &)
Return a pointer to this node.
Definition: LeafNode.h:736
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:1144
LeafNode * probeLeaf(const Coord &)
Definition: LeafNode.h:747
bool isValueMaskOff() const
Definition: LeafNode.h:873
void prune(const ValueType &=zeroVal< ValueType >())
This function exists only to enable template instantiation.
Definition: LeafNode.h:715
bool isValueMaskOn() const
Definition: LeafNode.h:871
void visit2(IterT &otherIter, VisitorOp &, bool otherIsLHS=false)
Definition: LeafNode.h:1941
void topologyDifference(const LeafNode< OtherType, Log2Dim > &other, const ValueType &)
Difference this node's set of active values with the active values of the other node,...
Definition: LeafNode.h:1721
void getNodes(ArrayT &) const
Definition: LeafNode.h:725
void setValuesOff()
Mark all voxels as inactive but don't change their values.
Definition: LeafNode.h:473
ValueAllCIter endValueAll() const
Definition: LeafNode.h:315
Index medianOff(ValueType &value, ValueType *tmp=nullptr) const
Computes the median value of all the inactive voxels in this node.
Definition: LeafNode.h:1578
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:422
Index64 onLeafVoxelCount() const
Definition: LeafNode.h:143
ChildOffCIter endChildOff() const
Definition: LeafNode.h:334
ValueType medianAll(ValueType *tmp=nullptr) const
Computes the median value of all the active AND inactive voxels in this node.
Definition: LeafNode.h:1536
~LeafNode()
Destructor.
Definition: LeafNode.h:1031
static void doVisit(NodeT &, VisitorOp &)
Definition: LeafNode.h:1879
ValueAllCIter cbeginValueAll() const
Definition: LeafNode.h:304
NodeT * probeNode(const Coord &)
Definition: LeafNode.h:722
void readTopology(std::istream &is, bool fromHalf=false)
Read in just the topology.
Definition: LeafNode.h:1309
ValueOnCIter beginValueOn() const
Definition: LeafNode.h:299
static void evalNodeOrigin(Coord &xyz)
Compute the origin of the leaf node that contains the voxel with the given coordinates.
Definition: LeafNode.h:889
const Buffer & buffer() const
Definition: LeafNode.h:346
LeafNode * probeLeafAndCache(const Coord &, AccessorT &)
Definition: LeafNode.h:749
void setValueMaskOn(Index n)
Definition: LeafNode.h:883
Index medianOn(ValueType &value, ValueType *tmp=nullptr) const
Computes the median value of all the active voxels in this node.
Definition: LeafNode.h:1554
Index64 offLeafVoxelCount() const
Definition: LeafNode.h:144
const LeafNode * probeLeaf(const Coord &) const
Definition: LeafNode.h:758
void addTile(Index level, const Coord &, const ValueType &, bool)
Definition: LeafNode.h:1605
void resetBackground(const ValueType &oldBackground, const ValueType &newBackground)
Replace inactive occurrences of oldBackground with newBackground, and inactive occurrences of -oldBac...
Definition: LeafNode.h:1634
void setOrigin(const Coord &origin)
Set the grid index coordinates of this node's local origin.
Definition: LeafNode.h:169
const Coord & origin() const
Return the grid index coordinates of this node's local origin.
Definition: LeafNode.h:172
static Index getValueLevel(const Coord &)
Return the level (i.e., 0) at which leaf node values reside.
Definition: LeafNode.h:395
bool isInactive() const
Return true if all of this node's values are inactive.
Definition: LeafNode.h:845
void modifyValueAndActiveState(const Coord &xyz, const ModifyOp &op)
Apply a functor to the voxel at the given coordinates.
Definition: LeafNode.h:457
static void doVisit2Node(NodeT &self, OtherNodeT &other, VisitorOp &)
Definition: LeafNode.h:1918
bool isValueMaskOff(Index n) const
Definition: LeafNode.h:872
ValueOnCIter cendValueOn() const
Definition: LeafNode.h:308
bool isAllocated() const
Return true if memory for this node's buffer has been allocated.
Definition: LeafNode.h:152
static Index getValueLevelAndCache(const Coord &, AccessorT &)
Return the LEVEL (=0) at which leaf node values reside.
Definition: LeafNode.h:621
static Index numValues()
Return the total number of voxels represented by this LeafNode.
Definition: LeafNode.h:123
ValueOffCIter beginValueOff() const
Definition: LeafNode.h:302
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:583
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:610
const ValueType & getValueAndCache(const Coord &xyz, AccessorT &) const
Return the value of the voxel at the given coordinates.
Definition: LeafNode.h:536
ChildAllCIter cbeginChildAll() const
Definition: LeafNode.h:326
void topologyIntersection(const LeafNode< OtherType, Log2Dim > &other, const ValueType &)
Intersect this node's set of active values with the active values of the other node,...
Definition: LeafNode.h:1712
ChildOffIter endChildOff()
Definition: LeafNode.h:335
void clip(const CoordBBox &, const ValueType &background)
Set all voxels that lie outside the given axis-aligned box to the background.
Definition: LeafNode.h:1162
ChildAllIter beginChildAll()
Definition: LeafNode.h:328
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:428
static Index getLevel()
Return the level of this node, which by definition is zero for LeafNodes.
Definition: LeafNode.h:125
bool isValueOnAndCache(const Coord &xyz, AccessorT &) const
Return true if the voxel at the given coordinates is active.
Definition: LeafNode.h:544
void addLeaf(LeafNode *)
Definition: LeafNode.h:716
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:1136
ValueOnIter beginValueOn()
Definition: LeafNode.h:300
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:567
void topologyUnion(const LeafNode< OtherType, Log2Dim > &other, const bool preserveTiles=false)
Union this node's set of active values with the active values of the other node, whose ValueType may ...
Definition: LeafNode.h:1704
NodeT * probeNodeAndCache(const Coord &, AccessorT &)
Definition: LeafNode.h:740
const ValueType & getFirstValue() const
Return a const reference to the first value in the buffer.
Definition: LeafNode.h:626
ChildOffCIter cbeginChildOff() const
Definition: LeafNode.h:323
ChildOffIter beginChildOff()
Definition: LeafNode.h:325
bool isChildMaskOff(Index) const
Definition: LeafNode.h:879
Index64 onVoxelCount() const
Return the number of voxels marked On.
Definition: LeafNode.h:140
ChildOffCIter beginChildOff() const
Definition: LeafNode.h:324
static Index coordToOffset(const Coord &xyz)
Return the linear table offset of the given global or local coordinates.
Definition: LeafNode.h:1051
static Index64 offTileCount()
Definition: LeafNode.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:408
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:1492
ValueOffIter endValueOff()
Definition: LeafNode.h:313
void setValueOff(Index offset)
Mark the voxel at the given offset as inactive but don't change its value.
Definition: LeafNode.h:410
const LeafNode * probeConstLeafAndCache(const Coord &, AccessorT &) const
Definition: LeafNode.h:755
ChildAllCIter endChildAll() const
Definition: LeafNode.h:337
const NodeT * probeConstNodeAndCache(const Coord &, AccessorT &) const
Definition: LeafNode.h:760
ValueOnCIter cbeginValueOn() const
Definition: LeafNode.h:298
void writeBuffers(std::ostream &os, bool toHalf=false) const
Write buffers to a stream.
Definition: LeafNode.h:1437
static Index log2dim()
Return log2 of the dimension of this LeafNode, e.g. 3 if dimensions are 8^3.
Definition: LeafNode.h:117
void combine(const LeafNode &other, CombineOp &op)
Definition: LeafNode.h:1745
static void getNodeLog2Dims(std::vector< Index > &dims)
Append the Log2Dim of this LeafNode to the specified vector.
Definition: LeafNode.h:127
ChildOnCIter endChildOn() const
Definition: LeafNode.h:331
const LeafNode * probeConstLeaf(const Coord &) const
Return a const pointer to this node.
Definition: LeafNode.h:753
static Index32 nonLeafCount()
Return the non-leaf count for this node, which is zero.
Definition: LeafNode.h:135
ChildOnCIter cendChildOn() const
Definition: LeafNode.h:330
static bool hasActiveTiles()
Return false since leaf nodes never contain tiles.
Definition: LeafNode.h:481
ChildAllCIter cendChildAll() const
Definition: LeafNode.h:336
void combine2(const LeafNode &other, const OtherType &, bool valueIsActive, CombineOp &)
Definition: LeafNode.h:1785
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:1202
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:450
void visitActiveBBox(BBoxOp &) const
Calls the templated functor BBoxOp with bounding box information. An additional level argument is pro...
Definition: LeafNode.h:1846
ChildAllIter endChildAll()
Definition: LeafNode.h:338
size_t streamingSize(bool toHalf=false) const
void setValueMask(Index n, bool on)
Definition: LeafNode.h:882
const NodeMaskType & valueMask() const
Definition: LeafNode.h:876
Index64 offVoxelCount() const
Return the number of voxels marked Off.
Definition: LeafNode.h:142
typename NodeMaskType::OffIterator MaskOffIterator
Definition: LeafNode.h:206
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:345
void readBuffers(std::istream &is, bool fromHalf=false)
Read buffers from a stream.
Definition: LeafNode.h:1345
bool isConstant(ValueType &firstValue, bool &state, const ValueType &tolerance=zeroVal< ValueType >()) const
Definition: LeafNode.h:1500
T BuildType
Definition: LeafNode.h:40
ValueAllCIter cendValueAll() const
Definition: LeafNode.h:314
friend class LeafNode
Definition: LeafNode.h:853
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:489
void negate()
Definition: LeafNode.h:1729
Coord offsetToGlobalCoord(Index n) const
Return the global coordinates for a linear table offset.
Definition: LeafNode.h:1075
ChildAllCIter beginChildAll() const
Definition: LeafNode.h:327
const LeafNode * probeLeafAndCache(const Coord &, AccessorT &) const
Definition: LeafNode.h:757
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:592
void getOrigin(Coord &origin) const
Definition: LeafNode.h:173
void setValuesOn()
Mark all voxels as active but don't change their values.
Definition: LeafNode.h:471
void setTransientData(Index32 transientData)
Set the transient data value.
Definition: LeafNode.h:189
void nodeCount(std::vector< Index32 > &) const
no-op
Definition: LeafNode.h:133
static Index size()
Return the total number of voxels represented by this LeafNode.
Definition: LeafNode.h:121
ChildOffCIter cendChildOff() const
Definition: LeafNode.h:333
void skipCompressedValues(bool seekable, std::istream &, bool fromHalf)
Definition: LeafNode.h:1329
typename NodeMaskType::OnIterator MaskOnIterator
Definition: LeafNode.h:205
bool operator==(const LeafNode &other) const
Check for buffer, state and origin equivalence.
Definition: LeafNode.h:1454
static const Index SIZE
Definition: LeafNode.h:53
void evalActiveBoundingBox(CoordBBox &bbox, bool visitVoxels=true) const
Definition: LeafNode.h:1474
bool isEmpty() const
Return true if this node has no active voxels.
Definition: LeafNode.h:148
void merge(const LeafNode &)
Definition: LeafNode.h:1655
ValueOffIter beginValueOff()
Definition: LeafNode.h:303
const NodeT * probeConstNode(const Coord &) const
Definition: LeafNode.h:724
void setValueOn(const Coord &xyz)
Mark the voxel at the given coordinates as active but don't change its value.
Definition: LeafNode.h:418
Buffer & buffer()
Definition: LeafNode.h:347
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:558
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:400
static Index32 leafCount()
Return the leaf count for this node, which is one.
Definition: LeafNode.h:131
bool allocate()
Allocate memory for this node's buffer if it has not already been allocated.
Definition: LeafNode.h:154
const NodeMaskType & getValueMask() const
Definition: LeafNode.h:874
void addTileAndCache(Index, const Coord &, const ValueType &, bool, AccessorT &)
Definition: LeafNode.h:1622
void addLeafAndCache(LeafNode *, AccessorT &)
Definition: LeafNode.h:718
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:436
ValueOffCIter cendValueOff() const
Definition: LeafNode.h:311
void setValueMaskOff(Index n)
Definition: LeafNode.h:884
Index64 memUsage() const
Return the memory in bytes occupied by this node.
Definition: LeafNode.h:1464
bool isDense() const
Return true if this node contains only active voxels.
Definition: LeafNode.h:150
ValueOffCIter endValueOff() const
Definition: LeafNode.h:312
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:549
std::string str() const
Return a string representation of this node.
Definition: LeafNode.h:1038
NodeT * stealNode(const Coord &, const ValueType &, bool)
Definition: LeafNode.h:720
T ValueType
Definition: LeafNode.h:41
bool probeValue(const Coord &xyz, ValueType &val) const
Return true if the voxel at the given coordinates is active.
Definition: LeafNode.h:1102
ValueOnCIter endValueOn() const
Definition: LeafNode.h:309
typename NodeMaskType::DenseIterator MaskDenseIterator
Definition: LeafNode.h:207
void voxelizeActiveTiles(bool=true)
No-op.
Definition: LeafNode.h:638
void modifyValueAndActiveStateAndCache(const Coord &xyz, const ModifyOp &op, AccessorT &)
Definition: LeafNode.h:575
LeafNode * touchLeafAndCache(const Coord &, AccessorT &)
Definition: LeafNode.h:738
const ValueType & getLastValue() const
Return a const reference to the last value in the buffer.
Definition: LeafNode.h:628
ValueAllCIter beginValueAll() const
Definition: LeafNode.h:305
static Index dim()
Return the number of voxels in each coordinate dimension.
Definition: LeafNode.h:119
bool isValueMaskOn(Index n) const
Definition: LeafNode.h:870
ValueAllIter beginValueAll()
Definition: LeafNode.h:306
void visit2Node(OtherLeafNodeType &other, VisitorOp &)
Definition: LeafNode.h:1893
Index32 pos() const
Definition: NodeMasks.h:200
Definition: NodeMasks.h:271
Bit mask for the internal and leaf nodes of VDB. This is a 64-bit implementation.
Definition: NodeMasks.h:308
OnIterator beginOn() const
Definition: NodeMasks.h:352
OffIterator beginOff() const
Definition: NodeMasks.h:354
bool isOn(Index32 n) const
Return true if the nth bit is on.
Definition: NodeMasks.h:502
void setOn(Index32 n)
Set the nth bit on.
Definition: NodeMasks.h:452
Definition: NodeMasks.h:240
Definition: NodeMasks.h:209
static void read(std::istream &is, GridHandle< BufferT > &handle, Codec codec)
@ COMPRESS_ZIP
Definition: Compression.h:54
OPENVDB_API SharedPtr< MappedFile > getMappedFilePtr(std::ios_base &)
Return a shared pointer to the memory-mapped file with which the given stream is associated,...
OPENVDB_API uint32_t getFormatVersion(std::ios_base &)
Return the file format version number associated with the given input stream.
void writeCompressedValues(std::ostream &os, ValueT *srcBuf, Index srcCount, const MaskT &valueMask, const MaskT &childMask, bool toHalf)
Definition: Compression.h:645
OPENVDB_API uint32_t getDataCompression(std::ios_base &)
Return a bitwise OR of compression option flags (COMPRESS_ZIP, COMPRESS_ACTIVE_MASK,...
void readCompressedValues(std::istream &is, ValueT *destBuf, Index destCount, const MaskT &valueMask, bool fromHalf)
Definition: Compression.h:465
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 SharedPtr< StreamMetadata > getStreamMetadataPtr(std::ios_base &)
Return a shared pointer to an object that stores metadata (file format, compression scheme,...
bool isApproxEqual(const Type &a, const Type &b, const Type &tolerance)
Return true if a is equal to b to within the given tolerance.
Definition: Math.h:407
bool operator==(const Vec3< T0 > &v0, const Vec3< T1 > &v1)
Equality operator, does exact floating point comparisons.
Definition: Vec3.h:477
T negative(const T &val)
Return the unary negation of the given value.
Definition: Math.h:127
std::ostream & operator<<(std::ostream &os, const typename LeafNode< T, Log2Dim >::Buffer &buf)
Definition: LeafNode.h:1987
Index32 Index
Definition: Types.h:54
uint32_t Index32
Definition: Types.h:52
int32_t Int32
Definition: Types.h:56
uint64_t Index64
Definition: Types.h:53
std::shared_ptr< T > SharedPtr
Definition: Types.h:114
@ MERGE_NODES
Definition: Types.h:390
@ MERGE_ACTIVE_STATES_AND_NODES
Definition: Types.h:391
@ OPENVDB_FILE_VERSION_NODE_MASK_COMPRESSION
Definition: version.h.in:246
ValueType combine(const ValueType &v0, const ValueType &v1, const ValueType &v2, const openvdb::Vec3d &w)
Combine different value types.
Definition: AttributeTransferUtil.h:141
Definition: Exceptions.h:13
static pnanovdb_uint32_t allocate(pnanovdb_uint32_t *poffset, pnanovdb_uint32_t size, pnanovdb_uint32_t alignment)
Definition: pnanovdb_validate_strides.h:20
Definition: Compression.h:292
Base class for dense iterators over internal and leaf nodes.
Definition: Iterator.h:179
typename std::remove_const< UnsetItemT >::type NonConstValueType
Definition: Iterator.h:184
Leaf nodes have no children, so their child iterators have no get/set accessors.
Definition: LeafNode.h:251
ChildIter(const MaskIterT &iter, NodeT *parent)
Definition: LeafNode.h:253
ChildIter()
Definition: LeafNode.h:252
Definition: LeafNode.h:211
Definition: LeafNode.h:211
Definition: LeafNode.h:260
DenseIter(const MaskDenseIterator &iter, NodeT *parent)
Definition: LeafNode.h:265
void unsetItem(Index pos, const ValueT &value) const
Definition: LeafNode.h:278
bool getItem(Index pos, void *&child, NonConstValueT &value) const
Definition: LeafNode.h:267
DenseIter()
Definition: LeafNode.h:264
typename BaseT::NonConstValueType NonConstValueT
Definition: LeafNode.h:262
SameConfiguration<OtherNodeType>::value is true if and only if OtherNodeType is the type of a LeafNod...
Definition: LeafNode.h:64
Definition: LeafNode.h:210
ValueConverter<T>::Type is the type of a LeafNode having the same dimensions as this node but a diffe...
Definition: LeafNode.h:59
Definition: LeafNode.h:219
void setValue(const ValueT &value) const
Definition: LeafNode.h:234
void modifyValue(const ModifyOp &op) const
Definition: LeafNode.h:244
ValueT & getItem(Index pos) const
Definition: LeafNode.h:225
void setItem(Index pos, const ValueT &value) const
Definition: LeafNode.h:229
ValueIter(const MaskIterT &iter, NodeT *parent)
Definition: LeafNode.h:223
ValueT & getValue() const
Definition: LeafNode.h:226
ValueIter()
Definition: LeafNode.h:222
void modifyItem(Index n, const ModifyOp &op) const
Definition: LeafNode.h:241
Definition: LeafNode.h:210
Definition: LeafNode.h:210
Definition: LeafNode.h:923
Base class for sparse iterators over internal and leaf nodes.
Definition: Iterator.h:115
ValueType ValueType
Definition: Iterator.h:117
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition: version.h.in:116
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h.in:202