Go to the documentation of this file.
4 #ifndef OPENVDB_TREE_LEAFNODE_HAS_BEEN_INCLUDED
5 #define OPENVDB_TREE_LEAFNODE_HAS_BEEN_INCLUDED
17 #include <type_traits>
29 template<Index,
typename>
struct SameLeafConfig;
36 template<
typename T, Index Log2Dim>
51 NUM_VALUES = 1 << 3 * Log2Dim,
52 NUM_VOXELS = NUM_VALUES,
58 template<
typename OtherValueType>
63 template<
typename OtherNodeType>
77 const ValueType& value = zeroVal<ValueType>(),
87 const ValueType& value = zeroVal<ValueType>(),
97 template<
typename OtherValueType>
101 template<
typename OtherValueType>
106 template<
typename OtherValueType>
146 bool isEmpty()
const {
return mValueMask.isOff(); }
148 bool isDense()
const {
return mValueMask.isOn(); }
150 bool isAllocated()
const {
return !mBuffer.isOutOfCore() && !mBuffer.empty(); }
160 void evalActiveBoundingBox(
CoordBBox& bbox,
bool visitVoxels =
true)
const;
169 const Coord& origin()
const {
return mOrigin; }
184 std::string str()
const;
188 template<
typename OtherType, Index OtherLog2Dim>
204 template<
typename MaskIterT,
typename NodeT,
typename ValueT,
typename TagT>
209 MaskIterT, ValueIter<MaskIterT, NodeT, ValueT, TagT>, NodeT, ValueT>
216 ValueT&
getItem(
Index pos)
const {
return this->parent().getValue(pos); }
217 ValueT&
getValue()
const {
return this->parent().getValue(this->pos()); }
222 this->parent().setValueOnly(pos, value);
227 this->parent().setValueOnly(this->pos(), value);
231 template<
typename ModifyOp>
232 void modifyItem(
Index n,
const ModifyOp& op)
const { this->parent().modifyValue(n, op); }
234 template<
typename ModifyOp>
235 void modifyValue(
const ModifyOp& op)
const { this->parent().modifyValue(this->pos(), op); }
239 template<
typename MaskIterT,
typename NodeT,
typename TagT>
241 public SparseIteratorBase<MaskIterT, ChildIter<MaskIterT, NodeT, TagT>, NodeT, ValueType>
248 template<
typename NodeT,
typename ValueT,
typename TagT>
250 MaskDenseIterator, DenseIter<NodeT, ValueT, TagT>, NodeT, void, ValueT>
260 value = this->parent().getValue(pos);
271 this->parent().setValueOnly(pos, value);
346 void readTopology(std::istream& is,
bool fromHalf =
false);
350 void writeTopology(std::ostream& os,
bool toHalf =
false)
const;
355 void readBuffers(std::istream& is,
bool fromHalf =
false);
360 void readBuffers(std::istream& is,
const CoordBBox& bbox,
bool fromHalf =
false);
364 void writeBuffers(std::ostream& os,
bool toHalf =
false)
const;
366 size_t streamingSize(
bool toHalf =
false)
const;
372 const ValueType& getValue(
const Coord& xyz)
const;
374 const ValueType& getValue(
Index offset)
const;
379 bool probeValue(
const Coord& xyz, ValueType& val)
const;
383 bool probeValue(
Index offset, ValueType& val)
const;
389 void setActiveState(
const Coord& xyz,
bool on);
394 void setValueOnly(
const Coord& xyz,
const ValueType& val);
396 void setValueOnly(
Index offset,
const ValueType& val);
404 void setValueOff(
const Coord& xyz,
const ValueType& val);
406 void setValueOff(
Index offset,
const ValueType& val);
414 this->setValueOn(LeafNode::coordToOffset(xyz), val);
420 mBuffer.setValue(offset, val);
421 mValueMask.setOn(offset);
426 template<
typename ModifyOp>
429 mBuffer.loadValues();
430 if (!mBuffer.empty()) {
432 ValueType& val = const_cast<ValueType&>(mBuffer[offset]);
434 mValueMask.setOn(offset);
440 template<
typename ModifyOp>
443 this->modifyValue(this->coordToOffset(xyz), op);
447 template<
typename ModifyOp>
450 mBuffer.loadValues();
451 if (!mBuffer.empty()) {
452 const Index offset = this->coordToOffset(xyz);
453 bool state = mValueMask.isOn(offset);
455 ValueType& val = const_cast<ValueType&>(mBuffer[offset]);
457 mValueMask.set(offset, state);
478 void fill(
const CoordBBox& bbox,
const ValueType&,
bool active =
true);
482 this->fill(bbox, value, active);
486 void fill(
const ValueType& value);
488 void fill(
const ValueType& value,
bool active);
501 template<
typename DenseT>
520 template<
typename DenseT>
522 const ValueType& background,
const ValueType& tolerance);
526 template<
typename AccessorT>
529 return this->getValue(xyz);
534 template<
typename AccessorT>
539 template<
typename AccessorT>
542 this->setValueOn(xyz, val);
548 template<
typename AccessorT>
551 this->setValueOnly(xyz, val);
557 template<
typename ModifyOp,
typename AccessorT>
560 this->modifyValue(xyz, op);
565 template<
typename ModifyOp,
typename AccessorT>
568 this->modifyValueAndActiveState(xyz, op);
573 template<
typename AccessorT>
576 this->setValueOff(xyz, value);
582 template<
typename AccessorT>
585 this->setActiveState(xyz, on);
591 template<
typename AccessorT>
594 return this->probeValue(xyz, val);
600 template<
typename AccessorT>
603 const Index offset = this->coordToOffset(xyz);
604 state = mValueMask.isOn(offset);
606 return mBuffer[offset];
611 template<
typename AccessorT>
623 void resetBackground(
const ValueType& oldBackground,
const ValueType& newBackground);
631 template<MergePolicy Policy>
void merge(
const LeafNode&);
632 template<MergePolicy Policy>
void merge(
const ValueType& tileValue,
bool tileActive);
633 template<MergePolicy Policy>
634 void merge(
const LeafNode& other,
const ValueType& ,
const ValueType& );
642 template<
typename OtherType>
656 template<
typename OtherType>
670 template<
typename OtherType>
673 template<
typename CombineOp>
674 void combine(
const LeafNode& other, CombineOp& op);
675 template<
typename CombineOp>
676 void combine(
const ValueType& value,
bool valueIsActive, CombineOp& op);
678 template<
typename CombineOp,
typename OtherType >
679 void combine2(
const LeafNode& other,
const OtherType&,
bool valueIsActive, CombineOp&);
680 template<
typename CombineOp,
typename OtherNodeT >
681 void combine2(
const ValueType&,
const OtherNodeT& other,
bool valueIsActive, CombineOp&);
682 template<
typename CombineOp,
typename OtherNodeT >
683 void combine2(
const LeafNode& b0,
const OtherNodeT& b1, CombineOp&);
690 template<
typename BBoxOp>
void visitActiveBBox(BBoxOp&)
const;
692 template<
typename VisitorOp>
void visit(VisitorOp&);
693 template<
typename VisitorOp>
void visit(VisitorOp&)
const;
695 template<
typename OtherLeafNodeType,
typename VisitorOp>
696 void visit2Node(OtherLeafNodeType& other, VisitorOp&);
697 template<
typename OtherLeafNodeType,
typename VisitorOp>
698 void visit2Node(OtherLeafNodeType& other, VisitorOp&)
const;
699 template<
typename IterT,
typename VisitorOp>
700 void visit2(IterT& otherIter, VisitorOp&,
bool otherIsLHS =
false);
701 template<
typename IterT,
typename VisitorOp>
702 void visit2(IterT& otherIter, VisitorOp&,
bool otherIsLHS =
false)
const;
705 void prune(
const ValueType& = zeroVal<ValueType>()) {}
708 template<
typename AccessorT>
710 template<
typename NodeT>
712 template<
typename NodeT>
714 template<
typename NodeT>
716 template<
typename ArrayT>
void getNodes(ArrayT&)
const {}
720 void addTile(
Index level,
const Coord&,
const ValueType&,
bool);
721 void addTile(
Index offset,
const ValueType&,
bool);
722 template<
typename AccessorT>
723 void addTileAndCache(
Index,
const Coord&,
const ValueType&,
bool, AccessorT&);
728 template<
typename AccessorT>
730 template<
typename NodeT,
typename AccessorT>
734 if (!(std::is_same<NodeT, LeafNode>::value))
return nullptr;
735 return reinterpret_cast<NodeT*>(
this);
739 template<
typename AccessorT>
743 const LeafNode* probeConstLeaf(
const Coord&)
const {
return this; }
745 template<
typename AccessorT>
747 template<
typename AccessorT>
750 template<
typename NodeT,
typename AccessorT>
754 if (!(std::is_same<NodeT, LeafNode>::value))
return nullptr;
755 return reinterpret_cast<const NodeT*>(
this);
769 bool isConstant(ValueType& firstValue,
bool& state,
770 const ValueType& tolerance = zeroVal<ValueType>())
const;
783 bool isConstant(ValueType& minValue, ValueType& maxValue,
784 bool& state,
const ValueType& tolerance = zeroVal<ValueType>())
const;
801 ValueType medianAll(ValueType *tmp =
nullptr)
const;
817 Index medianOn(ValueType &value, ValueType *tmp =
nullptr)
const;
833 Index medianOff(ValueType &value, ValueType *tmp =
nullptr)
const;
839 friend class ::TestLeaf;
840 template<
typename>
friend class ::TestLeafIO;
877 inline void skipCompressedValues(
bool seekable, std::istream&,
bool fromHalf);
882 template<
typename NodeT,
typename VisitorOp,
typename ChildAllIterT>
883 static inline void doVisit(NodeT&, VisitorOp&);
885 template<
typename NodeT,
typename OtherNodeT,
typename VisitorOp,
886 typename ChildAllIterT,
typename OtherChildAllIterT>
887 static inline void doVisit2Node(NodeT&
self, OtherNodeT& other, VisitorOp&);
889 template<
typename NodeT,
typename VisitorOp,
890 typename ChildAllIterT,
typename OtherChildAllIterT>
891 static inline void doVisit2(NodeT&
self, OtherChildAllIterT&, VisitorOp&,
bool otherIsLHS);
897 NodeMaskType mValueMask;
907 template<Index Dim1,
typename NodeT2>
912 template<Index Dim1,
typename T2>
920 template<
typename T, Index Log2Dim>
929 template<
typename T, Index Log2Dim>
934 mOrigin(xyz & (~(DIM - 1)))
939 template<
typename T, Index Log2Dim>
944 mOrigin(xyz & (~(DIM - 1)))
949 template<
typename T, Index Log2Dim>
952 mBuffer(other.mBuffer),
953 mValueMask(other.valueMask()),
954 mOrigin(other.mOrigin)
960 template<
typename T, Index Log2Dim>
961 template<
typename OtherValueType>
964 mValueMask(other.valueMask()),
965 mOrigin(other.mOrigin)
969 static inline ValueType convertValue(
const OtherValueType& val) {
return ValueType(val); }
973 mBuffer[i] = Local::convertValue(other.mBuffer[i]);
978 template<
typename T, Index Log2Dim>
979 template<
typename OtherValueType>
984 mValueMask(other.valueMask()),
985 mOrigin(other.mOrigin)
990 template<
typename T, Index Log2Dim>
991 template<
typename OtherValueType>
995 mValueMask(other.valueMask()),
996 mOrigin(other.mOrigin)
999 mBuffer[i] = (mValueMask.
isOn(i) ? onValue : offValue);
1004 template<
typename T, Index Log2Dim>
1011 template<
typename T, Index Log2Dim>
1015 std::ostringstream ostr;
1016 ostr <<
"LeafNode @" << mOrigin <<
": " << mBuffer;
1024 template<
typename T, Index Log2Dim>
1028 assert ((xyz[0] & (DIM-1u)) < DIM && (xyz[1] & (DIM-1u)) < DIM && (xyz[2] & (DIM-1u)) < DIM);
1029 return ((xyz[0] & (DIM-1u)) << 2*Log2Dim)
1030 + ((xyz[1] & (DIM-1u)) << Log2Dim)
1031 + (xyz[2] & (DIM-1u));
1034 template<
typename T, Index Log2Dim>
1038 assert(n<(1<< 3*Log2Dim));
1040 xyz.
setX(n >> 2*Log2Dim);
1041 n &= ((1<<2*Log2Dim)-1);
1042 xyz.
setY(n >> Log2Dim);
1043 xyz.
setZ(n & ((1<<Log2Dim)-1));
1048 template<
typename T, Index Log2Dim>
1052 return (this->offsetToLocalCoord(n) + this->origin());
1059 template<
typename ValueT, Index Log2Dim>
1060 inline const ValueT&
1066 template<
typename ValueT, Index Log2Dim>
1067 inline const ValueT&
1070 assert(offset < SIZE);
1071 return mBuffer[offset];
1075 template<
typename T, Index Log2Dim>
1082 template<
typename T, Index Log2Dim>
1086 assert(offset < SIZE);
1087 val = mBuffer[offset];
1088 return mValueMask.isOn(offset);
1092 template<
typename T, Index Log2Dim>
1099 template<
typename T, Index Log2Dim>
1103 assert(offset < SIZE);
1104 mBuffer.setValue(offset, val);
1105 mValueMask.setOff(offset);
1109 template<
typename T, Index Log2Dim>
1113 mValueMask.set(this->coordToOffset(xyz), on);
1117 template<
typename T, Index Log2Dim>
1124 template<
typename T, Index Log2Dim>
1128 assert(offset<SIZE); mBuffer.setValue(offset, val);
1135 template<
typename T, Index Log2Dim>
1139 CoordBBox nodeBBox = this->getNodeBoundingBox();
1142 this->fill(background,
false);
1143 }
else if (clipBBox.
isInside(nodeBBox)) {
1155 int &x = xyz.
x(), &y = xyz.
y(), &z = xyz.
z();
1156 for (x = nodeBBox.
min().
x(); x <= nodeBBox.
max().
x(); ++x) {
1157 for (y = nodeBBox.
min().
y(); y <= nodeBBox.
max().
y(); ++y) {
1158 for (z = nodeBBox.
min().
z(); z <= nodeBBox.
max().
z(); ++z) {
1159 mask.
setOn(static_cast<Index32>(this->coordToOffset(xyz)));
1167 this->setValueOff(maskIter.pos(), background);
1175 template<
typename T, Index Log2Dim>
1179 if (!this->allocate())
return;
1181 auto clippedBBox = this->getNodeBoundingBox();
1182 clippedBBox.intersect(bbox);
1183 if (!clippedBBox)
return;
1185 for (
Int32 x = clippedBBox.min().x(); x <= clippedBBox.max().x(); ++x) {
1186 const Index offsetX = (x & (DIM-1u)) << 2*Log2Dim;
1187 for (
Int32 y = clippedBBox.min().y(); y <= clippedBBox.max().y(); ++y) {
1188 const Index offsetXY = offsetX + ((y & (DIM-1u)) << Log2Dim);
1189 for (
Int32 z = clippedBBox.min().z(); z <= clippedBBox.max().z(); ++z) {
1190 const Index offset = offsetXY + (z & (DIM-1u));
1191 mBuffer[offset] = value;
1192 mValueMask.set(offset, active);
1198 template<
typename T, Index Log2Dim>
1202 mBuffer.fill(value);
1205 template<
typename T, Index Log2Dim>
1209 mBuffer.fill(value);
1210 mValueMask.set(active);
1217 template<
typename T, Index Log2Dim>
1218 template<
typename DenseT>
1222 mBuffer.loadValues();
1224 using DenseValueType =
typename DenseT::ValueType;
1226 const size_t xStride = dense.xStride(), yStride = dense.yStride(), zStride = dense.zStride();
1227 const Coord&
min = dense.bbox().min();
1228 DenseValueType* t0 = dense.data() + zStride * (bbox.
min()[2] -
min[2]);
1229 const T* s0 = &mBuffer[bbox.
min()[2] & (DIM-1u)];
1230 for (
Int32 x = bbox.
min()[0], ex = bbox.
max()[0] + 1; x < ex; ++x) {
1231 DenseValueType* t1 = t0 + xStride * (x -
min[0]);
1232 const T* s1 = s0 + ((x & (DIM-1u)) << 2*Log2Dim);
1233 for (
Int32 y = bbox.
min()[1], ey = bbox.
max()[1] + 1; y < ey; ++y) {
1234 DenseValueType* t2 = t1 + yStride * (y -
min[1]);
1235 const T* s2 = s1 + ((y & (DIM-1u)) << Log2Dim);
1236 for (
Int32 z = bbox.
min()[2], ez = bbox.
max()[2] + 1; z < ez; ++z, t2 += zStride) {
1237 *t2 = DenseValueType(*s2++);
1244 template<
typename T, Index Log2Dim>
1245 template<
typename DenseT>
1250 if (!this->allocate())
return;
1252 using DenseValueType =
typename DenseT::ValueType;
1254 const size_t xStride = dense.xStride(), yStride = dense.yStride(), zStride = dense.zStride();
1255 const Coord&
min = dense.bbox().min();
1257 const DenseValueType* s0 = dense.data() + zStride * (bbox.
min()[2] -
min[2]);
1258 const Int32 n0 = bbox.
min()[2] & (DIM-1u);
1259 for (
Int32 x = bbox.
min()[0], ex = bbox.
max()[0]+1; x < ex; ++x) {
1260 const DenseValueType* s1 = s0 + xStride * (x -
min[0]);
1261 const Int32 n1 = n0 + ((x & (DIM-1u)) << 2*LOG2DIM);
1262 for (
Int32 y = bbox.
min()[1], ey = bbox.
max()[1]+1; y < ey; ++y) {
1263 const DenseValueType* s2 = s1 + yStride * (y -
min[1]);
1264 Int32 n2 = n1 + ((y & (DIM-1u)) << LOG2DIM);
1265 for (
Int32 z = bbox.
min()[2], ez = bbox.
max()[2]+1; z < ez; ++z, ++n2, s2 += zStride) {
1267 mValueMask.setOff(n2);
1268 mBuffer[n2] = background;
1270 mValueMask.setOn(n2);
1282 template<
typename T, Index Log2Dim>
1286 mValueMask.load(is);
1290 template<
typename T, Index Log2Dim>
1294 mValueMask.save(os);
1302 template<
typename T, Index Log2Dim>
1308 io::readCompressedValues<ValueType, NodeMaskType>(
1309 is,
nullptr, SIZE, mValueMask, fromHalf);
1318 template<
typename T, Index Log2Dim>
1326 template<
typename T, Index Log2Dim>
1331 const bool seekable = meta && meta->seekable();
1333 std::streamoff maskpos = is.tellg();
1337 mValueMask.seek(is);
1340 mValueMask.load(is);
1343 int8_t numBuffers = 1;
1349 is.read(reinterpret_cast<char*>(&numBuffers),
sizeof(int8_t));
1352 CoordBBox nodeBBox = this->getNodeBoundingBox();
1355 skipCompressedValues(seekable, is, fromHalf);
1356 mValueMask.setOff();
1357 mBuffer.setOutOfCore(
false);
1364 const bool delayLoad = ((mappedFile.get() !=
nullptr) && clipBBox.
isInside(nodeBBox));
1367 mBuffer.setOutOfCore(
true);
1368 mBuffer.mFileInfo =
new typename Buffer::FileInfo;
1369 mBuffer.mFileInfo->meta = meta;
1370 mBuffer.mFileInfo->bufpos = is.tellg();
1371 mBuffer.mFileInfo->mapping = mappedFile;
1374 mBuffer.mFileInfo->maskpos = maskpos;
1376 skipCompressedValues(seekable, is, fromHalf);
1380 mBuffer.setOutOfCore(
false);
1383 T background = zeroVal<T>();
1385 background = *static_cast<const T*>(bgPtr);
1387 this->
clip(clipBBox, background);
1391 if (numBuffers > 1) {
1396 for (
int i = 1; i < numBuffers; ++i) {
1400 io::readData<T>(is, temp.
mData, SIZE, zipped);
1406 if (meta) meta->setLeaf(meta->leaf() + 1);
1410 template<
typename T, Index Log2Dim>
1415 mValueMask.save(os);
1417 mBuffer.loadValues();
1427 template<
typename T, Index Log2Dim>
1431 return mOrigin == other.mOrigin &&
1433 mBuffer == other.mBuffer;
1437 template<
typename T, Index Log2Dim>
1443 return sizeof(*this) + mBuffer.memUsage() -
sizeof(mBuffer);
1447 template<
typename T, Index Log2Dim>
1451 CoordBBox this_bbox = this->getNodeBoundingBox();
1452 if (bbox.
isInside(this_bbox))
return;
1456 for(; iter; ++iter) this_bbox.
expand(this->offsetToLocalCoord(iter.pos()));
1464 template<
typename T, Index Log2Dim>
1465 template<
typename OtherType, Index OtherLog2Dim>
1470 return (Log2Dim == OtherLog2Dim && mValueMask == other->
getValueMask());
1473 template<
typename T, Index Log2Dim>
1479 if (!mValueMask.isConstant(state))
return false;
1480 firstValue = mBuffer[0];
1481 for (
Index i = 1; i < SIZE; ++i) {
1487 template<
typename T, Index Log2Dim>
1494 if (!mValueMask.isConstant(state))
return false;
1495 minValue = maxValue = mBuffer[0];
1496 for (
Index i = 1; i < SIZE; ++i) {
1497 const T& v = mBuffer[i];
1499 if ((maxValue - v) > tolerance)
return false;
1501 }
else if (v > maxValue) {
1502 if ((v - minValue) > tolerance)
return false;
1509 template<
typename T, Index Log2Dim>
1513 std::unique_ptr<T[]> data(
nullptr);
1514 if (tmp ==
nullptr) {
1515 data.reset(
new T[NUM_VALUES]);
1518 if (tmp != mBuffer.data()) {
1519 const T* src = mBuffer.data();
1520 for (T* dst = tmp; dst-tmp < NUM_VALUES;) *dst++ = *src++;
1522 static const size_t midpoint = (NUM_VALUES - 1) >> 1;
1523 std::nth_element(tmp, tmp + midpoint, tmp + NUM_VALUES);
1524 return tmp[midpoint];
1527 template<
typename T, Index Log2Dim>
1531 const Index count = mValueMask.countOn();
1532 if (count == NUM_VALUES) {
1533 value = this->medianAll(tmp);
1535 }
else if (count == 0) {
1538 std::unique_ptr<T[]> data(
nullptr);
1539 if (tmp ==
nullptr) {
1540 data.reset(
new T[count]);
1543 for (
auto iter=this->cbeginValueOn(); iter; ++iter) *tmp++ = *iter;
1544 T *begin = tmp - count;
1545 const size_t midpoint = (count - 1) >> 1;
1546 std::nth_element(begin, begin + midpoint, tmp);
1547 value = begin[midpoint];
1551 template<
typename T, Index Log2Dim>
1555 const Index count = mValueMask.countOff();
1556 if (count == NUM_VALUES) {
1557 value = this->medianAll(tmp);
1559 }
else if (count == 0) {
1562 std::unique_ptr<T[]> data(
nullptr);
1563 if (tmp ==
nullptr) {
1564 data.reset(
new T[count]);
1567 for (
auto iter=this->cbeginValueOff(); iter; ++iter) *tmp++ = *iter;
1568 T *begin = tmp - count;
1569 const size_t midpoint = (count - 1) >> 1;
1570 std::nth_element(begin, begin + midpoint, tmp);
1571 value = begin[midpoint];
1578 template<
typename T, Index Log2Dim>
1582 this->addTile(this->coordToOffset(xyz), val, active);
1585 template<
typename T, Index Log2Dim>
1589 assert(offset < SIZE);
1590 setValueOnly(offset, val);
1591 setActiveState(offset, active);
1594 template<
typename T, Index Log2Dim>
1595 template<
typename AccessorT>
1598 const ValueType& val,
bool active, AccessorT&)
1600 this->addTile(level, xyz, val, active);
1607 template<
typename T, Index Log2Dim>
1612 if (!this->allocate())
return;
1616 for (iter = this->mValueMask.beginOff(); iter; ++iter) {
1619 inactiveValue = newBackground;
1627 template<
typename T, Index Log2Dim>
1628 template<MergePolicy Policy>
1632 if (!this->allocate())
return;
1637 for (; iter; ++iter) {
1639 if (mValueMask.isOff(n)) {
1640 mBuffer[n] = other.mBuffer[n];
1641 mValueMask.setOn(n);
1647 template<
typename T, Index Log2Dim>
1648 template<MergePolicy Policy>
1653 this->
template merge<Policy>(other);
1656 template<
typename T, Index Log2Dim>
1657 template<MergePolicy Policy>
1661 if (!this->allocate())
return;
1665 if (!tileActive)
return;
1668 const Index n = iter.pos();
1669 mBuffer[n] = tileValue;
1670 mValueMask.setOn(n);
1676 template<
typename T, Index Log2Dim>
1677 template<
typename OtherType>
1684 template<
typename T, Index Log2Dim>
1685 template<
typename OtherType>
1693 template<
typename T, Index Log2Dim>
1694 template<
typename OtherType>
1702 template<
typename T, Index Log2Dim>
1706 if (!this->allocate())
return;
1708 for (
Index i = 0; i < SIZE; ++i) {
1709 mBuffer[i] = -mBuffer[i];
1717 template<
typename T, Index Log2Dim>
1718 template<
typename CombineOp>
1722 if (!this->allocate())
return;
1725 for (
Index i = 0; i < SIZE; ++i) {
1727 .setAIsActive(mValueMask.isOn(i))
1728 .setBRef(other.mBuffer[i])
1730 .setResultRef(mBuffer[i]));
1736 template<
typename T, Index Log2Dim>
1737 template<
typename CombineOp>
1741 if (!this->allocate())
return;
1744 args.
setBRef(value).setBIsActive(valueIsActive);
1745 for (
Index i = 0; i < SIZE; ++i) {
1747 .setAIsActive(mValueMask.isOn(i))
1748 .setResultRef(mBuffer[i]));
1757 template<
typename T, Index Log2Dim>
1758 template<
typename CombineOp,
typename OtherType>
1761 bool valueIsActive, CombineOp& op)
1763 if (!this->allocate())
return;
1766 args.
setBRef(value).setBIsActive(valueIsActive);
1767 for (
Index i = 0; i < SIZE; ++i) {
1768 op(args.
setARef(other.mBuffer[i])
1770 .setResultRef(mBuffer[i]));
1776 template<
typename T, Index Log2Dim>
1777 template<
typename CombineOp,
typename OtherNodeT>
1780 bool valueIsActive, CombineOp& op)
1782 if (!this->allocate())
return;
1785 args.
setARef(value).setAIsActive(valueIsActive);
1786 for (
Index i = 0; i < SIZE; ++i) {
1787 op(args.
setBRef(other.mBuffer[i])
1788 .setBIsActive(other.valueMask().isOn(i))
1789 .setResultRef(mBuffer[i]));
1795 template<
typename T, Index Log2Dim>
1796 template<
typename CombineOp,
typename OtherNodeT>
1800 if (!this->allocate())
return;
1803 for (
Index i = 0; i < SIZE; ++i) {
1804 mValueMask.set(i, b0.
valueMask().
isOn(i) || b1.valueMask().isOn(i));
1805 op(args.
setARef(b0.mBuffer[i])
1807 .setBRef(b1.mBuffer[i])
1808 .setBIsActive(b1.valueMask().isOn(i))
1809 .setResultRef(mBuffer[i]));
1818 template<
typename T, Index Log2Dim>
1819 template<
typename BBoxOp>
1823 if (op.template descent<LEVEL>()) {
1833 op.operator()<LEVEL>(this->getNodeBoundingBox());
1835 op.template operator()<LEVEL>(this->getNodeBoundingBox());
1841 template<
typename T, Index Log2Dim>
1842 template<
typename VisitorOp>
1846 doVisit<LeafNode, VisitorOp, ChildAllIter>(*
this, op);
1850 template<
typename T, Index Log2Dim>
1851 template<
typename VisitorOp>
1855 doVisit<const LeafNode, VisitorOp, ChildAllCIter>(*
this, op);
1859 template<
typename T, Index Log2Dim>
1860 template<
typename NodeT,
typename VisitorOp,
typename ChildAllIterT>
1864 for (ChildAllIterT iter =
self.beginChildAll(); iter; ++iter) {
1873 template<
typename T, Index Log2Dim>
1874 template<
typename OtherLeafNodeType,
typename VisitorOp>
1879 typename OtherLeafNodeType::ChildAllIter>(*
this, other, op);
1883 template<
typename T, Index Log2Dim>
1884 template<
typename OtherLeafNodeType,
typename VisitorOp>
1889 typename OtherLeafNodeType::ChildAllCIter>(*
this, other, op);
1893 template<
typename T, Index Log2Dim>
1896 typename OtherNodeT,
1898 typename ChildAllIterT,
1899 typename OtherChildAllIterT>
1904 static_assert(OtherNodeT::SIZE == NodeT::SIZE,
1905 "can't visit nodes of different sizes simultaneously");
1906 static_assert(OtherNodeT::LEVEL == NodeT::LEVEL,
1907 "can't visit nodes at different tree levels simultaneously");
1909 ChildAllIterT iter =
self.beginChildAll();
1910 OtherChildAllIterT otherIter = other.beginChildAll();
1912 for ( ; iter && otherIter; ++iter, ++otherIter) {
1913 op(iter, otherIter);
1921 template<
typename T, Index Log2Dim>
1922 template<
typename IterT,
typename VisitorOp>
1926 doVisit2<LeafNode, VisitorOp, ChildAllIter, IterT>(
1927 *
this, otherIter, op, otherIsLHS);
1931 template<
typename T, Index Log2Dim>
1932 template<
typename IterT,
typename VisitorOp>
1936 doVisit2<const LeafNode, VisitorOp, ChildAllCIter, IterT>(
1937 *
this, otherIter, op, otherIsLHS);
1941 template<
typename T, Index Log2Dim>
1945 typename ChildAllIterT,
1946 typename OtherChildAllIterT>
1949 VisitorOp& op,
bool otherIsLHS)
1951 if (!otherIter)
return;
1954 for (ChildAllIterT iter =
self.beginChildAll(); iter; ++iter) {
1955 op(otherIter, iter);
1958 for (ChildAllIterT iter =
self.beginChildAll(); iter; ++iter) {
1959 op(iter, otherIter);
1968 template<
typename T, Index Log2Dim>
1969 inline std::ostream&
1972 for (
Index32 i = 0, N = buf.
size(); i < N; ++i) os << buf.
mData[i] <<
", ";
1990 #endif // OPENVDB_TREE_LEAFNODE_HAS_BEEN_INCLUDED
typename NodeMaskType::DenseIterator MaskDenseIterator
Definition: LeafNode.h:198
void expand(ValueType padding)
Pad this bounding box with the specified padding.
Definition: Coord.h:418
ChildAllCIter cbeginChildAll() const
Definition: LeafNode.h:317
Definition: LeafNode.h:205
Coord & setY(Int32 y)
Definition: Coord.h:81
void stealNodes(ArrayT &, const ValueType &, bool)
Definition: LeafNode.h:717
bool isValueOnAndCache(const Coord &xyz, AccessorT &) const
Return true if the voxel at the given coordinates is active.
Definition: LeafNode.h:535
const NodeT * probeConstNodeAndCache(const Coord &, AccessorT &) const
Definition: LeafNode.h:751
void modifyValueAndActiveState(const Coord &xyz, const ModifyOp &op)
Apply a functor to the voxel at the given coordinates.
Definition: LeafNode.h:448
void merge(const LeafNode &)
Definition: LeafNode.h:1630
static Coord offsetToLocalCoord(Index n)
Return the local coordinates for a linear table offset, where offset 0 has coordinates (0,...
Definition: LeafNode.h:1036
void negate()
Definition: LeafNode.h:1704
bool isChildMaskOff(Index) const
Definition: LeafNode.h:870
static CoordBBox inf()
Return an "infinite" bounding box, as defined by the Coord value range.
Definition: Coord.h:319
ChildOffCIter cbeginChildOff() const
Definition: LeafNode.h:314
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:391
ValueAllCIter cbeginValueAll() const
Definition: LeafNode.h:295
LeafNode * touchLeafAndCache(const Coord &, AccessorT &)
Definition: LeafNode.h:729
ChildOnIter beginChildOn()
Definition: LeafNode.h:313
static void getNodeLog2Dims(std::vector< Index > &dims)
Append the Log2Dim of this LeafNode to the specified vector.
Definition: LeafNode.h:127
ChildOffCIter endChildOff() const
Definition: LeafNode.h:325
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:1467
void setValuesOff()
Mark all voxels as inactive but don't change their values.
Definition: LeafNode.h:464
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:351
NodeT * stealNode(const Coord &, const ValueType &, bool)
Definition: LeafNode.h:711
ChildIter(const MaskIterT &iter, NodeT *parent)
Definition: LeafNode.h:244
void unsetItem(Index pos, const ValueT &value) const
Definition: LeafNode.h:269
OnIterator beginOn() const
Definition: NodeMasks.h:333
static Index64 offTileCount()
Definition: LeafNode.h:144
SharedPtr< MappedFile > Ptr
Definition: io.h:136
NodeT * probeNodeAndCache(const Coord &, AccessorT &)
Definition: LeafNode.h:731
Definition: Compression.h:292
bool operator!=(const LeafNode &other) const
Definition: LeafNode.h:193
Signed (x, y, z) 32-bit integer coordinates.
Definition: Coord.h:25
bool isConstant(ValueType &firstValue, bool &state, const ValueType &tolerance=zeroVal< ValueType >()) const
Definition: LeafNode.h:1475
ChildOffCIter beginChildOff() const
Definition: LeafNode.h:315
ValueOffCIter cbeginValueOff() const
Definition: LeafNode.h:292
static const Index SIZE
Definition: LeafNode.h:53
static Index log2dim()
Return log2 of the dimension of this LeafNode, e.g. 3 if dimensions are 8^3.
Definition: LeafNode.h:117
Int32 ValueType
Definition: Coord.h:33
ValueOnIter endValueOn()
Definition: LeafNode.h:301
void setValuesOn()
Mark all voxels as active but don't change their values.
Definition: LeafNode.h:462
static void doVisit2(NodeT &self, OtherChildAllIterT &, VisitorOp &, bool otherIsLHS)
Definition: LeafNode.h:1948
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:1220
Definition: PointDataGrid.h:174
void addTile(Index level, const Coord &, const ValueType &, bool)
Definition: LeafNode.h:1580
void visit2(IterT &otherIter, VisitorOp &, bool otherIsLHS=false)
Definition: LeafNode.h:1924
void setValueMaskOff(Index n)
Definition: LeafNode.h:875
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:1177
Definition: LeafNode.h:202
Coord & setZ(Int32 z)
Definition: Coord.h:82
NodeT * probeNode(const Coord &)
Definition: LeafNode.h:713
void writeTopology(std::ostream &os, bool toHalf=false) const
Write out just the topology.
Definition: LeafNode.h:1292
void setOn(Index32 n)
Set the nth bit on.
Definition: NodeMasks.h:433
bool isValueMaskOn() const
Definition: LeafNode.h:862
std::ostream & operator<<(std::ostream &os, const typename LeafNode< T, Log2Dim >::Buffer &buf)
Definition: LeafNode.h:1970
bool isValueMaskOff() const
Definition: LeafNode.h:864
ValueOffIter endValueOff()
Definition: LeafNode.h:304
void setValueOff(const Coord &xyz)
Mark the voxel at the given coordinates as inactive but don't change its value.
Definition: LeafNode.h:399
ValueAllCIter cendValueAll() const
Definition: LeafNode.h:305
void setOrigin(const Coord &origin)
Set the grid index coordinates of this node's local origin.
Definition: LeafNode.h:167
SameConfiguration<OtherNodeType>::value is true if and only if OtherNodeType is the type of a LeafNod...
Definition: LeafNode.h:64
bool isValueOn(Index offset) const
Return true if the voxel at the given offset is active.
Definition: LeafNode.h:469
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:1696
void visit2Node(OtherLeafNodeType &other, VisitorOp &)
Definition: LeafNode.h:1876
void writeCompressedValues(std::ostream &os, ValueT *srcBuf, Index srcCount, const MaskT &valueMask, const MaskT &childMask, bool toHalf)
Definition: Compression.h:645
Int32 y() const
Definition: Coord.h:132
const LeafNode * probeConstLeafAndCache(const Coord &, AccessorT &) const
Definition: LeafNode.h:746
const NodeMaskType & valueMask() const
Definition: LeafNode.h:867
Coord offsetToGlobalCoord(Index n) const
Return the global coordinates for a linear table offset.
Definition: LeafNode.h:1050
CombineArgs & setARef(const AValueType &a)
Redirect the A value to a new external source.
Definition: Types.h:620
Definition: LeafNode.h:22
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:441
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:1119
void nodeCount(std::vector< Index32 > &) const
no-op
Definition: LeafNode.h:133
void modifyValueAndActiveStateAndCache(const Coord &xyz, const ModifyOp &op, AccessorT &)
Definition: LeafNode.h:566
void evalActiveBoundingBox(CoordBBox &bbox, bool visitVoxels=true) const
Definition: LeafNode.h:1449
ChildOffCIter cendChildOff() const
Definition: LeafNode.h:324
Definition: NodeMasks.h:189
Index medianOn(ValueType &value, ValueType *tmp=nullptr) const
Computes the median value of all the active voxels in this node.
Definition: LeafNode.h:1529
static bool hasActiveTiles()
Return false since leaf nodes never contain tiles.
Definition: LeafNode.h:472
Int32 x() const
Definition: Coord.h:131
static Index coordToOffset(const Coord &xyz)
Return the linear table offset of the given global or local coordinates.
Definition: LeafNode.h:1026
void setItem(Index pos, const ValueT &value) const
Definition: LeafNode.h:220
Base class for iterators over internal and leaf nodes.
Definition: Iterator.h:29
void skipCompressedValues(bool seekable, std::istream &, bool fromHalf)
Definition: LeafNode.h:1304
ChildIter()
Definition: LeafNode.h:243
static Index dim()
Return the number of voxels in each coordinate dimension.
Definition: LeafNode.h:119
void intersect(const CoordBBox &bbox)
Intersect this bounding box with the given bounding box.
Definition: Coord.h:444
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:427
T negative(const T &val)
Return the unary negation of the given value.
Definition: Math.h:81
typename NodeMaskType::OnIterator MaskOnIterator
Definition: LeafNode.h:196
std::shared_ptr< T > SharedPtr
Definition: Types.h:91
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:1111
ValueOffCIter cendValueOff() const
Definition: LeafNode.h:302
bool resultIsActive() const
Definition: Types.h:631
NodeMaskType & getValueMask()
Definition: LeafNode.h:866
void reset()
Definition: Coord.h:327
const ValueType & getValue(const Coord &xyz) const
Return the value of the voxel at the given coordinates.
Definition: LeafNode.h:1061
ValueT & getValue() const
Definition: LeafNode.h:217
void addLeafAndCache(LeafNode *, AccessorT &)
Definition: LeafNode.h:709
void setValueOff(Index offset)
Mark the voxel at the given offset as inactive but don't change its value.
Definition: LeafNode.h:401
static Index numValues()
Return the total number of voxels represented by this LeafNode.
Definition: LeafNode.h:123
LeafNode * probeLeafAndCache(const Coord &, AccessorT &)
Definition: LeafNode.h:740
Axis-aligned bounding box of signed integer coordinates.
Definition: Coord.h:248
ChildOnCIter beginChildOn() const
Definition: LeafNode.h:312
ValueAllIter beginValueAll()
Definition: LeafNode.h:297
const NodeT * probeConstNode(const Coord &) const
Definition: LeafNode.h:715
const Buffer & buffer() const
Definition: LeafNode.h:337
bool probeValue(const Coord &xyz, ValueType &val) const
Return true if the voxel at the given coordinates is active.
Definition: LeafNode.h:1077
bool hasOverlap(const CoordBBox &b) const
Return true if the given bounding box overlaps with this bounding box.
Definition: Coord.h:412
Base class for sparse iterators over internal and leaf nodes.
Definition: Iterator.h:114
ValueAllIter endValueAll()
Definition: LeafNode.h:307
static Index size()
Return the total number of voxels represented by this LeafNode.
Definition: LeafNode.h:121
typename std::remove_const< UnsetItemT >::type NonConstValueType
Definition: Iterator.h:184
bool isChildMaskOn(Index) const
Definition: LeafNode.h:869
ChildOnCIter cbeginChildOn() const
Definition: LeafNode.h:311
Index64 offVoxelCount() const
Return the number of voxels marked Off.
Definition: LeafNode.h:140
Definition: NodeMasks.h:251
Definition: NodeMasks.h:220
ChildAllCIter cendChildAll() const
Definition: LeafNode.h:327
ChildAllIter beginChildAll()
Definition: LeafNode.h:319
OPENVDB_API uint32_t getDataCompression(std::ios_base &)
Return a bitwise OR of compression option flags (COMPRESS_ZIP, COMPRESS_ACTIVE_MASK,...
ChildAllCIter beginChildAll() const
Definition: LeafNode.h:318
bool isInside(const Coord &xyz) const
Return true if point (x, y, z) is inside this bounding box.
Definition: Coord.h:400
Definition: LeafNode.h:249
void translate(const Coord &t)
Translate this bounding box by (tx, ty, tz).
Definition: Coord.h:458
ChildOnCIter endChildOn() const
Definition: LeafNode.h:322
OPENVDB_API SharedPtr< StreamMetadata > getStreamMetadataPtr(std::ios_base &)
Return a shared pointer to an object that stores metadata (file format, compression scheme,...
SharedPtr< LeafNode > Ptr
Definition: LeafNode.h:45
LeafNode * probeLeaf(const Coord &)
Definition: LeafNode.h:738
static CoordBBox createCube(const Coord &min, ValueType dim)
Definition: Coord.h:313
void setValueOn(const Coord &xyz)
Mark the voxel at the given coordinates as active but don't change its value.
Definition: LeafNode.h:409
void addLeaf(LeafNode *)
Definition: LeafNode.h:707
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:1247
ValueOffCIter endValueOff() const
Definition: LeafNode.h:303
bool isChildMaskOff() const
Definition: LeafNode.h:871
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:540
void setValueMask(const NodeMaskType &mask)
Definition: LeafNode.h:868
bool isValueMaskOff(Index n) const
Definition: LeafNode.h:863
void clip(const CoordBBox &, const ValueType &background)
Set all voxels that lie outside the given axis-aligned box to the background.
Definition: LeafNode.h:1137
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:417
bool isEmpty() const
Return true if this node has no active voxels.
Definition: LeafNode.h:146
typename NodeMaskType::OffIterator MaskOffIterator
Definition: LeafNode.h:197
Bit mask for the internal and leaf nodes of VDB. This is a 64-bit implementation.
Definition: NodeMasks.h:288
void readCompressedValues(std::istream &is, ValueT *destBuf, Index destCount, const MaskT &valueMask, bool fromHalf)
Definition: Compression.h:465
ValueType medianAll(ValueType *tmp=nullptr) const
Computes the median value of all the active AND inactive voxels in this node.
Definition: LeafNode.h:1511
bool operator==(const Vec3< T0 > &v0, const Vec3< T1 > &v1)
Equality operator, does exact floating point comparisons.
Definition: Vec3.h:471
T BuildType
Definition: LeafNode.h:40
Tag dispatch class that distinguishes topology copy constructors from deep copy constructors.
Definition: Types.h:681
bool getItem(Index pos, void *&child, NonConstValueT &value) const
Definition: LeafNode.h:258
ValueType * mData
Definition: LeafBuffer.h:169
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:574
void visit(VisitorOp &)
Definition: LeafNode.h:1844
const Coord & max() const
Definition: Coord.h:322
void readTopology(std::istream &is, bool fromHalf=false)
Read in just the topology.
Definition: LeafNode.h:1284
bool operator==(const LeafNode &other) const
Check for buffer, state and origin equivalence.
Definition: LeafNode.h:1429
const ValueType & getFirstValue() const
Return a const reference to the first value in the buffer.
Definition: LeafNode.h:617
const Coord & min() const
Definition: Coord.h:321
typename BaseT::NonConstValueType NonConstValueT
Definition: LeafNode.h:253
bool isDense() const
Return true if this node contains only active voxels.
Definition: LeafNode.h:148
ChildOnCIter cendChildOn() const
Definition: LeafNode.h:321
Templated block class to hold specific data types and a fixed number of values determined by Log2Dim....
Definition: LeafNode.h:37
Int32 z() const
Definition: Coord.h:133
This struct collects both input and output arguments to "grid combiner" functors used with the tree::...
Definition: Types.h:567
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:419
const LeafNode * probeLeaf(const Coord &) const
Definition: LeafNode.h:749
Definition: LeafNode.h:201
DenseIter()
Definition: LeafNode.h:255
LeafNode()
Default constructor.
Definition: LeafNode.h:922
Definition: version.h:195
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h:154
Index64 onVoxelCount() const
Return the number of voxels marked On.
Definition: LeafNode.h:138
static Index getLevel()
Return the level of this node, which by definition is zero for LeafNodes.
Definition: LeafNode.h:125
static Index getValueLevel(const Coord &)
Return the level (i.e., 0) at which leaf node values reside.
Definition: LeafNode.h:386
ChildAllCIter endChildAll() const
Definition: LeafNode.h:328
ChildOffIter beginChildOff()
Definition: LeafNode.h:316
Definition: LeafNode.h:201
Index64 offLeafVoxelCount() const
Definition: LeafNode.h:142
ValueAllCIter endValueAll() const
Definition: LeafNode.h:306
ValueOnCIter beginValueOn() const
Definition: LeafNode.h:290
std::string str() const
Return a string representation of this node.
Definition: LeafNode.h:1013
OffIterator beginOff() const
Definition: NodeMasks.h:335
Definition: LeafNode.h:201
const NodeMaskType & getValueMask() const
Definition: LeafNode.h:865
ValueOnCIter cbeginValueOn() const
Definition: LeafNode.h:289
const ValueType & getLastValue() const
Return a const reference to the last value in the buffer.
Definition: LeafNode.h:619
ValueT & getItem(Index pos) const
Definition: LeafNode.h:216
static Index32 leafCount()
Return the leaf count for this node, which is one.
Definition: LeafNode.h:131
bool isOn(Index32 n) const
Return true if the nth bit is on.
Definition: NodeMasks.h:483
Index64 memUsage() const
Return the memory in bytes occupied by this node.
Definition: LeafNode.h:1439
OPENVDB_API uint32_t getFormatVersion(std::ios_base &)
Return the file format version number associated with the given input stream.
bool isValueMaskOn(Index n) const
Definition: LeafNode.h:861
void visitActiveBBox(BBoxOp &) const
Calls the templated functor BBoxOp with bounding box information. An additional level argument is pro...
Definition: LeafNode.h:1821
Index32 pos() const
Definition: NodeMasks.h:181
ValueType ValueType
Definition: Iterator.h:117
ValueOnIter beginValueOn()
Definition: LeafNode.h:291
Coord & setX(Int32 x)
Definition: Coord.h:80
ValueIter()
Definition: LeafNode.h:213
Index32 Index
Definition: Types.h:31
~LeafNode()
Destructor.
Definition: LeafNode.h:1006
void modifyValue(const ModifyOp &op) const
Definition: LeafNode.h:235
OPENVDB_API SharedPtr< MappedFile > getMappedFilePtr(std::ios_base &)
Return a shared pointer to the memory-mapped file with which the given stream is associated,...
static Index getChildDim()
Return the dimension of child nodes of this LeafNode, which is one for voxels.
Definition: LeafNode.h:129
const OPENVDB_API void * getGridBackgroundValuePtr(std::ios_base &)
Return a pointer to the background value of the grid currently being read from or written to the give...
void combine2(const LeafNode &other, const OtherType &, bool valueIsActive, CombineOp &)
Definition: LeafNode.h:1760
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:592
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition: version.h:102
ValueIter(const MaskIterT &iter, NodeT *parent)
Definition: LeafNode.h:214
Base class for dense iterators over internal and leaf nodes.
Definition: Iterator.h:178
Leaf nodes have no children, so their child iterators have no get/set accessors.
Definition: LeafNode.h:240
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:336
ValueOffCIter beginValueOff() const
Definition: LeafNode.h:293
ChildAllIter endChildAll()
Definition: LeafNode.h:329
static void doVisit2Node(NodeT &self, OtherNodeT &other, VisitorOp &)
Definition: LeafNode.h:1901
ValueConverter<T>::Type is the type of a LeafNode having the same dimensions as this node but a diffe...
Definition: LeafNode.h:59
void readBuffers(std::istream &is, bool fromHalf=false)
Read buffers from a stream.
Definition: LeafNode.h:1320
void writeBuffers(std::ostream &os, bool toHalf=false) const
Write buffers to a stream.
Definition: LeafNode.h:1412
Buffer & buffer()
Definition: LeafNode.h:338
uint32_t Index32
Definition: Types.h:29
ValueOnCIter cendValueOn() const
Definition: LeafNode.h:299
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:583
void modifyItem(Index n, const ModifyOp &op) const
Definition: LeafNode.h:232
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:558
ChildOnIter endChildOn()
Definition: LeafNode.h:323
Index medianOff(ValueType &value, ValueType *tmp=nullptr) const
Computes the median value of all the inactive voxels in this node.
Definition: LeafNode.h:1553
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:413
CoordBBox getNodeBoundingBox() const
Return the bounding box of this node, i.e., the full index space spanned by this leaf node.
Definition: LeafNode.h:164
bool isAllocated() const
Return true if memory for this node's buffer has been allocated.
Definition: LeafNode.h:150
void getNodes(ArrayT &) const
Definition: LeafNode.h:716
Tag dispatch class that distinguishes constructors during file input.
Definition: Types.h:683
bool allocate()
Allocate memory for this node's buffer if it has not already been allocated.
Definition: LeafNode.h:152
Definition: LeafNode.h:202
static void evalNodeOrigin(Coord &xyz)
Compute the origin of the leaf node that contains the voxel with the given coordinates.
Definition: LeafNode.h:880
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:549
static Index64 onTileCount()
Definition: LeafNode.h:143
void resetBackground(const ValueType &oldBackground, const ValueType &newBackground)
Replace inactive occurrences of oldBackground with newBackground, and inactive occurrences of -oldBac...
Definition: LeafNode.h:1609
const ValueType & getValueAndCache(const Coord &xyz, AccessorT &) const
Return the value of the voxel at the given coordinates.
Definition: LeafNode.h:527
Definition: Exceptions.h:13
int32_t Int32
Definition: Types.h:33
static Index32 nonLeafCount()
Return the non-leaf count for this node, which is zero.
Definition: LeafNode.h:135
Definition: Compression.h:54
Index64 onLeafVoxelCount() const
Definition: LeafNode.h:141
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:1687
void getOrigin(Coord &origin) const
Definition: LeafNode.h:171
void setValue(const ValueT &value) const
Definition: LeafNode.h:225
uint64_t Index64
Definition: Types.h:30
ChildOffIter endChildOff()
Definition: LeafNode.h:326
void setValueOn(Index offset)
Mark the voxel at the given offset as active but don't change its value.
Definition: LeafNode.h:411
bool isInactive() const
Return true if all of this node's values are inactive.
Definition: LeafNode.h:836
void combine(const LeafNode &other, CombineOp &op)
Definition: LeafNode.h:1720
ValueOffIter beginValueOff()
Definition: LeafNode.h:294
ValueAllCIter beginValueAll() const
Definition: LeafNode.h:296
void addTileAndCache(Index, const Coord &, const ValueType &, bool, AccessorT &)
Definition: LeafNode.h:1597
void setValueMask(Index n, bool on)
Definition: LeafNode.h:873
void setValueMaskOn(Index n)
Definition: LeafNode.h:874
T ValueType
Definition: LeafNode.h:41
bool isValueOn(const Coord &xyz) const
Return true if the voxel at the given coordinates is active.
Definition: LeafNode.h:467
DenseIter(const MaskDenseIterator &iter, NodeT *parent)
Definition: LeafNode.h:256
const LeafNode * probeLeafAndCache(const Coord &, AccessorT &) const
Definition: LeafNode.h:748
void voxelizeActiveTiles(bool=true)
No-op.
Definition: LeafNode.h:629
static Index size()
Return the number of values contained in this buffer.
Definition: LeafBuffer.h:135
CombineArgs & setBRef(const BValueType &b)
Redirect the B value to a new external source.
Definition: Types.h:622
static Index getValueLevelAndCache(const Coord &, AccessorT &)
Return the LEVEL (=0) at which leaf node values reside.
Definition: LeafNode.h:612
ValueOnCIter endValueOn() const
Definition: LeafNode.h:300
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:1679
static void doVisit(NodeT &, VisitorOp &)
Definition: LeafNode.h:1862
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:480
void getOrigin(Int32 &x, Int32 &y, Int32 &z) const
Definition: LeafNode.h:172
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:601