4 #ifndef OPENVDB_TREE_LEAF_NODE_BOOL_HAS_BEEN_INCLUDED
5 #define OPENVDB_TREE_LEAF_NODE_BOOL_HAS_BEEN_INCLUDED
17 #include <type_traits>
28 template<Index Log2Dim>
50 template<
typename ValueType>
55 template<
typename OtherNodeType>
56 struct SameConfiguration {
80 template<
typename OtherValueType>
95 template<
typename ValueType>
97 template<
typename ValueType>
163 const Coord&
origin()
const {
return mOrigin; }
182 std::string
str()
const;
186 template<
typename OtherType, Index OtherLog2Dim>
206 void readTopology(std::istream&,
bool fromHalf =
false);
208 void writeTopology(std::ostream&,
bool toHalf =
false)
const;
211 void readBuffers(std::istream&,
bool fromHalf =
false);
214 void writeBuffers(std::ostream&,
bool toHalf =
false)
const;
220 const bool&
getValue(
const Coord& xyz)
const;
270 template<
typename ModifyOp>
274 template<
typename ModifyOp>
278 template<
typename ModifyOp>
322 template<
typename DenseT>
341 template<
typename DenseT>
346 template<
typename AccessorT>
351 template<
typename AccessorT>
356 template<
typename AccessorT>
362 template<
typename AccessorT>
367 template<
typename AccessorT>
376 template<
typename ModifyOp,
typename AccessorT>
384 template<
typename ModifyOp,
typename AccessorT>
393 template<
typename AccessorT>
402 template<
typename AccessorT>
410 template<
typename AccessorT>
416 const bool&
getFirstValue()
const {
if (mValueMask.
isOn(0))
return Buffer::sOn;
else return Buffer::sOff; }
420 const bool&
getLastValue()
const {
if (mValueMask.
isOn(
SIZE-1))
return Buffer::sOn;
else return Buffer::sOff; }
425 bool isConstant(
bool& constValue,
bool&
state,
bool tolerance = 0)
const;
478 void negate() { mBuffer.mData.toggle(); }
480 template<MergePolicy Policy>
481 void merge(
const LeafNode& other,
bool bg =
false,
bool otherBG =
false);
482 template<MergePolicy Policy>
void merge(
bool tileValue,
bool tileActive);
494 template<
typename OtherType>
508 template<
typename OtherType>
522 template<
typename OtherType>
525 template<
typename CombineOp>
527 template<
typename CombineOp>
528 void combine(
bool,
bool valueIsActive, CombineOp&
op);
530 template<
typename CombineOp,
typename OtherType >
531 void combine2(
const LeafNode& other,
const OtherType&,
bool valueIsActive, CombineOp&);
532 template<
typename CombineOp,
typename OtherNodeT >
533 void combine2(
bool,
const OtherNodeT& other,
bool valueIsActive, CombineOp&);
534 template<
typename CombineOp,
typename OtherNodeT >
541 template<
typename AccessorT>
543 template<
typename NodeT>
545 template<
typename NodeT>
547 template<
typename NodeT>
549 template<
typename ArrayT>
void getNodes(ArrayT&)
const {}
555 template<
typename AccessorT>
561 template<
typename AccessorT>
564 template<
typename AccessorT>
566 template<
typename NodeT,
typename AccessorT>
571 return reinterpret_cast<NodeT*
>(
this);
578 template<
typename AccessorT>
581 template<
typename AccessorT>
583 template<
typename NodeT,
typename AccessorT>
588 return reinterpret_cast<const NodeT*
>(
this);
601 template<
typename MaskIterT,
typename NodeT,
typename ValueT>
605 public SparseIteratorBase<MaskIterT, ValueIter<MaskIterT, NodeT, ValueT>, NodeT, ValueT>
621 template<
typename ModifyOp>
624 template<
typename ModifyOp>
629 template<
typename MaskIterT,
typename NodeT>
635 MaskIterT,
ChildIter<MaskIterT, NodeT>, NodeT,
bool>(iter, parent) {}
638 template<
typename NodeT,
typename ValueT>
640 MaskDenseIter, DenseIter<NodeT, ValueT>, NodeT, void, ValueT>
650 value = this->
parent().getValue(pos);
664 using ValueOnCIter = ValueIter<MaskOnIter, const LeafNode, const bool>;
775 template<Index Log2Dim>
783 template<Index Log2Dim>
788 , mOrigin(xyz & (~(DIM - 1)))
793 template<Index Log2Dim>
798 , mOrigin(xyz & (~(DIM - 1)))
806 template<Index Log2Dim>
810 , mBuffer(other.mBuffer)
811 , mOrigin(other.mOrigin)
812 , mTransientData(other.mTransientData)
818 template<Index Log2Dim>
819 template<
typename ValueT>
823 , mOrigin(other.origin())
824 , mTransientData(other.mTransientData)
828 static inline bool convertValue(
const ValueT&
val) {
return bool(val); }
832 mBuffer.
setValue(i, Local::convertValue(other.mBuffer[i]));
837 template<Index Log2Dim>
838 template<
typename ValueT>
843 , mBuffer(background)
844 , mOrigin(other.origin())
845 , mTransientData(other.mTransientData)
850 template<Index Log2Dim>
858 , mOrigin(xyz & (~(DIM - 1)))
859 , mTransientData(trans)
863 template<Index Log2Dim>
864 template<
typename ValueT>
870 , mOrigin(other.origin())
871 , mTransientData(other.mTransientData)
874 if (mValueMask.
isOn(i)) {
881 template<Index Log2Dim>
891 template<Index Log2Dim>
896 return sizeof(*this);
900 template<Index Log2Dim>
905 return sizeof(*this);
909 template<Index Log2Dim>
914 if (bbox.isInside(this_bbox))
return;
918 for(; iter; ++iter) this_bbox.expand(
this->offsetToLocalCoord(iter.pos()));
919 this_bbox.translate(this->
origin());
921 bbox.expand(this_bbox);
926 template<Index Log2Dim>
927 template<
typename OtherType, Index OtherLog2Dim>
932 return (Log2Dim == OtherLog2Dim && mValueMask == other->
getValueMask());
936 template<Index Log2Dim>
940 std::ostringstream ostr;
941 ostr <<
"LeafNode @" << mOrigin <<
": ";
950 template<Index Log2Dim>
955 return ((xyz[0] & (
DIM-1u)) << 2*Log2Dim)
956 + ((xyz[1] & (
DIM-1u)) << Log2Dim)
957 + (xyz[2] & (
DIM-1u));
961 template<Index Log2Dim>
967 xyz.setX(n >> 2*Log2Dim);
968 n &= ((1 << 2*Log2Dim) - 1);
969 xyz.setY(n >> Log2Dim);
970 xyz.setZ(n & ((1 << Log2Dim) - 1));
975 template<Index Log2Dim>
986 template<Index Log2Dim>
994 template<Index Log2Dim>
1002 template<Index Log2Dim>
1012 bool background =
false;
1014 background = *
static_cast<const bool*
>(bgPtr);
1016 this->
clip(clipBBox, background);
1020 template<Index Log2Dim>
1027 mValueMask.
load(is);
1032 mBuffer.mData.load(is);
1036 template<Index Log2Dim>
1041 mValueMask.
save(os);
1043 os.write(reinterpret_cast<const char*>(&mOrigin),
sizeof(
Coord::ValueType) * 3);
1045 mBuffer.mData.save(os);
1052 template<Index Log2Dim>
1056 return mOrigin == other.mOrigin &&
1058 mBuffer == other.mBuffer;
1062 template<Index Log2Dim>
1073 template<Index Log2Dim>
1077 if (!mValueMask.
isConstant(state))
return false;
1080 if (!tolerance && !(mBuffer.mData.isOn() || mBuffer.mData.isOff()))
return false;
1082 constValue = mBuffer.mData.isOn();
1088 template<Index Log2Dim>
1092 const Index countTrue = mBuffer.mData.countOn();
1096 template<Index Log2Dim>
1106 template<Index Log2Dim>
1110 const NodeMaskType tmp = mBuffer.mData & (!mValueMask);
1119 template<Index Log2Dim>
1126 template<Index Log2Dim>
1135 template<Index Log2Dim>
1136 template<
typename AccessorT>
1141 this->
addTile(level, xyz, val, active);
1148 template<Index Log2Dim>
1153 if (mBuffer.mData.isOn(
this->coordToOffset(xyz)))
return Buffer::sOn;
else return Buffer::sOff;
1157 template<Index Log2Dim>
1163 if (mBuffer.mData.isOn(offset))
return Buffer::sOn;
else return Buffer::sOff;
1167 template<Index Log2Dim>
1174 template<Index Log2Dim>
1179 val = mBuffer.mData.isOn(offset);
1180 return mValueMask.
isOn(offset);
1183 template<Index Log2Dim>
1191 template<Index Log2Dim>
1196 mValueMask.
setOn(offset);
1197 mBuffer.mData.set(offset, val);
1201 template<Index Log2Dim>
1209 template<Index Log2Dim>
1217 template<Index Log2Dim>
1225 template<Index Log2Dim>
1230 mValueMask.
setOff(offset);
1231 mBuffer.mData.set(offset, val);
1235 template<Index Log2Dim>
1236 template<
typename ModifyOp>
1240 bool val = mBuffer.mData.isOn(offset);
1242 mBuffer.mData.set(offset, val);
1243 mValueMask.
setOn(offset);
1247 template<Index Log2Dim>
1248 template<
typename ModifyOp>
1256 template<Index Log2Dim>
1257 template<
typename ModifyOp>
1262 bool val = mBuffer.mData.isOn(offset),
state = mValueMask.
isOn(offset);
1264 mBuffer.mData.set(offset, val);
1272 template<Index Log2Dim>
1276 if (newBackground != oldBackground) {
1280 mBuffer.mData = (mBuffer.mData & mValueMask) | bgMask;
1288 template<Index Log2Dim>
1289 template<MergePolicy Policy>
1296 const Index n = iter.pos();
1297 if (mValueMask.
isOff(n)) {
1298 mBuffer.mData.set(n, other.mBuffer.mData.isOn(n));
1299 mValueMask.
setOn(n);
1305 template<Index Log2Dim>
1306 template<MergePolicy Policy>
1312 if (!tileActive)
return;
1314 if (tileValue) mBuffer.mData |= !mValueMask;
1315 else mBuffer.mData &= mValueMask;
1324 template<Index Log2Dim>
1325 template<
typename OtherType>
1333 template<Index Log2Dim>
1334 template<
typename OtherType>
1343 template<Index Log2Dim>
1344 template<
typename OtherType>
1356 template<Index Log2Dim>
1361 if (!clipBBox.hasOverlap(nodeBBox)) {
1363 this->
fill(nodeBBox, background,
false);
1364 }
else if (clipBBox.isInside(nodeBBox)) {
1374 nodeBBox.intersect(clipBBox);
1376 int &
x = xyz.x(), &
y = xyz.y(), &
z = xyz.z();
1377 for (x = nodeBBox.min().x(); x <= nodeBBox.max().x(); ++
x) {
1378 for (
y = nodeBBox.min().y();
y <= nodeBBox.max().y(); ++
y) {
1379 for (
z = nodeBBox.min().z();
z <= nodeBBox.max().z(); ++
z) {
1396 template<Index Log2Dim>
1401 clippedBBox.intersect(bbox);
1402 if (!clippedBBox)
return;
1404 for (
Int32 x = clippedBBox.min().x();
x <= clippedBBox.max().x(); ++
x) {
1405 const Index offsetX = (
x & (
DIM-1u))<<2*Log2Dim;
1406 for (
Int32 y = clippedBBox.min().y();
y <= clippedBBox.max().y(); ++
y) {
1407 const Index offsetXY = offsetX + ((
y & (
DIM-1u))<< Log2Dim);
1408 for (
Int32 z = clippedBBox.min().z();
z <= clippedBBox.max().z(); ++
z) {
1410 mValueMask.
set(offset, active);
1411 mBuffer.mData.set(offset, value);
1417 template<Index Log2Dim>
1421 mBuffer.
fill(value);
1424 template<Index Log2Dim>
1428 mBuffer.
fill(value);
1429 mValueMask.
set(active);
1436 template<Index Log2Dim>
1437 template<
typename DenseT>
1443 const size_t xStride = dense.xStride(), yStride = dense.yStride(), zStride = dense.zStride();
1444 const Coord&
min = dense.bbox().min();
1445 DenseValueType* t0 = dense.data() + zStride * (bbox.min()[2] - min[2]);
1446 const Int32 n0 = bbox.min()[2] & (
DIM-1u);
1447 for (
Int32 x = bbox.min()[0], ex = bbox.max()[0] + 1;
x < ex; ++
x) {
1448 DenseValueType* t1 = t0 + xStride * (
x - min[0]);
1450 for (
Int32 y = bbox.min()[1], ey = bbox.max()[1] + 1;
y < ey; ++
y) {
1451 DenseValueType* t2 = t1 + yStride * (
y - min[1]);
1453 for (
Int32 z = bbox.min()[2], ez = bbox.max()[2] + 1;
z < ez; ++
z, t2 += zStride) {
1454 *t2 = DenseValueType(mBuffer.mData.isOn(n2++));
1461 template<Index Log2Dim>
1462 template<
typename DenseT>
1465 bool background,
bool tolerance)
1469 inline static bool toBool(
const DenseValueType&
v) {
return !
math::isZero(v); }
1472 const size_t xStride = dense.xStride(), yStride = dense.yStride(), zStride = dense.zStride();
1473 const Coord&
min = dense.bbox().min();
1474 const DenseValueType* s0 = dense.data() + zStride * (bbox.min()[2] - min[2]);
1475 const Int32 n0 = bbox.min()[2] & (
DIM-1u);
1476 for (
Int32 x = bbox.min()[0], ex = bbox.max()[0] + 1;
x < ex; ++
x) {
1477 const DenseValueType* s1 = s0 + xStride * (
x - min[0]);
1479 for (
Int32 y = bbox.min()[1], ey = bbox.max()[1] + 1;
y < ey; ++
y) {
1480 const DenseValueType* s2 = s1 + yStride * (
y - min[1]);
1482 for (
Int32 z = bbox.min()[2], ez = bbox.max()[2]+1;
z < ez; ++
z, ++n2, s2 += zStride) {
1484 if (tolerance || (background == Local::toBool(*s2))) {
1486 mBuffer.mData.set(n2, background);
1488 mValueMask.
setOn(n2);
1489 mBuffer.mData.set(n2, Local::toBool(*s2));
1500 template<Index Log2Dim>
1501 template<
typename CombineOp>
1507 bool result =
false, aVal = mBuffer.mData.isOn(i), bVal = other.mBuffer.mData.isOn(i);
1509 .setAIsActive(mValueMask.
isOn(i))
1512 .setResultRef(result));
1514 mBuffer.mData.set(i, result);
1519 template<Index Log2Dim>
1520 template<
typename CombineOp>
1525 args.
setBRef(value).setBIsActive(valueIsActive);
1527 bool result =
false, aVal = mBuffer.mData.isOn(i);
1529 .setAIsActive(mValueMask.
isOn(i))
1530 .setResultRef(result));
1532 mBuffer.mData.set(i, result);
1540 template<Index Log2Dim>
1541 template<
typename CombineOp,
typename OtherType>
1544 bool valueIsActive, CombineOp&
op)
1547 args.
setBRef(value).setBIsActive(valueIsActive);
1549 bool result =
false, aVal = other.mBuffer.mData.isOn(i);
1552 .setResultRef(result));
1554 mBuffer.mData.set(i, result);
1559 template<Index Log2Dim>
1560 template<
typename CombineOp,
typename OtherNodeT>
1563 bool valueIsActive, CombineOp&
op)
1566 args.
setARef(value).setAIsActive(valueIsActive);
1568 bool result =
false, bVal = other.mBuffer.mData.isOn(i);
1570 .setBIsActive(other.valueMask().isOn(i))
1571 .setResultRef(result));
1573 mBuffer.mData.set(i, result);
1578 template<Index Log2Dim>
1579 template<
typename CombineOp,
typename OtherNodeT>
1588 bool result =
false, b0Val = b0.mBuffer.mData.isOn(i), b1Val = b1.mBuffer.mData.isOn(i);
1592 .setBIsActive(b1.valueMask().isOn(i))
1593 .setResultRef(result));
1595 mBuffer.mData.set(i, result);
1604 #endif // OPENVDB_TREE_LEAF_NODE_BOOL_HAS_BEEN_INCLUDED
void getNodes(ArrayT &) const
This function exists only to enable template instantiation.
void setValueOffAndCache(const Coord &xyz, bool value, AccessorT &)
Change the value of the voxel at the given coordinates and mark it as inactive.
Index64 memUsageIfLoaded() const
void setValueMask(Index n, bool on)
void setValuesOff()
Mark all voxels as inactive but don't change their values.
void merge(const LeafNode &)
void setItem(Index pos, bool value) const
static void getNodeLog2Dims(std::vector< Index > &dims)
void setValueOffUnsafe(Index offset)
Mark the voxel at the given offset as inactive but don't change its value.
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 ...
void setValueOn(const Coord &xyz)
Mark the voxel at the given coordinates as active but don't change its value.
static const Index NUM_VOXELS
This struct collects both input and output arguments to "grid combiner" functors used with the tree::...
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...
void setValuesOn()
Mark all voxels as active but don't change their values.
bool isValueOn(const Coord &xyz) const
Return true if the voxel at the given coordinates is active.
typename NodeMaskType::OffIterator MaskOffIter
ValueOnIter beginValueOn()
const NodeMaskType & valueMask() const
void setValueOff(Index offset)
Mark the voxel at the given offset as inactive but don't change its value.
Index32 countOn() const
Return the total number of on bits.
const bool & getValueAndCache(const Coord &xyz, AccessorT &) const
Return the value of the voxel at the given coordinates.
ChildAllIter beginChildAll()
void readBuffers(std::istream &is, bool fromHalf=false)
Read buffers from a stream.
void setValueOnUnsafe(Index offset, const bool &value)
Set the value of the voxel at the given coordinates and mark the voxel as active. ...
ChildOnCIter cbeginChildOn() const
ChildOffCIter cendChildOff() const
ChildIter< MaskOffIterator, LeafNode, ChildOff > ChildOffIter
ValueIter< MaskOnIter, const LeafNode, const bool > ValueOnCIter
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.
void readTopology(std::istream &is, bool fromHalf=false)
Read in just the topology.
void setValueMask(const NodeMaskType &mask)
void setValueAndCache(const Coord &xyz, bool val, AccessorT &)
Change the value of the voxel at the given coordinates and mark it as active.
void setValueOnlyUnsafe(Index offset, const bool &value)
Set the value of the voxel at the given coordinates but don't change its active state.
LeafNode specialization for values of type bool that stores both the active states and the values of ...
const ValueType & getValue(const Coord &xyz) const
Return the value of the voxel at the given coordinates.
void setValueOn(const Coord &xyz)
Mark the voxel at the given coordinates as active but don't change its value.
void getOrigin(Int32 &x, Int32 &y, Int32 &z) const
Return the grid index coordinates of this node's local origin.
ChildOnIter beginChildOn()
Index64 offVoxelCount() const
Return the number of inactive voxels.
NodeMaskType & getValueMask()
bool isConstant(ValueType &firstValue, bool &state, const ValueType &tolerance=zeroVal< ValueType >()) const
const LeafNode * probeConstLeaf(const Coord &) const
Return a pointer to this node.
GLsizei const GLfloat * value
LeafNode * probeLeaf(const Coord &)
Return a pointer to this node.
static const Index NUM_VALUES
static Index log2dim()
Return log2 of the size of the buffer storage.
void setOff(Index32 n)
Set the nth bit off.
GLdouble GLdouble GLdouble z
Index pos() const
Identical to offset.
void swap(Buffer &other)
Exchange this node's data buffer with the given data buffer without changing the active states of the...
const LeafNode * probeConstLeafAndCache(const Coord &, AccessorT &) const
Return a pointer to this node.
Index32 transientData() const
Return the transient data value.
const bool & getLastValue() const
Return a const reference to the last entry in the buffer.
LeafNode * touchLeaf(const Coord &)
Return a pointer to this node.
const bool & getValueUnsafe(Index offset) const
Return the value of the voxel at the given offset.
ValueOnCIter cbeginValueOn() const
void setValueMaskOn(Index n)
void addLeaf(LeafNode *)
This function exists only to enable template instantiation.
DenseIterator endDense() const
Index64 memUsage() const
Return the memory in bytes occupied by this node.
const NodeMaskType & getValueMask() const
#define OPENVDB_USE_VERSION_NAMESPACE
bool isValueMaskOn(Index n) const
Coord mOrigin
Global grid index coordinates (x,y,z) of the local origin of this node.
ValueOffCIter beginValueOff() const
NodeT * stealNode(const Coord &, const ValueType &, bool)
This function exists only to enable template instantiation.
Base class for iterators over internal and leaf nodes.
ImageBuf OIIO_API min(Image_or_Const A, Image_or_Const B, ROI roi={}, int nthreads=0)
ChildIter< MaskOnIterator, const LeafNode, ChildOn > ChildOnCIter
ChildIter< MaskOnIter, const LeafNode > ChildOnCIter
**But if you need a or simply need to know when the task has note that the like this
ChildOffCIter cbeginChildOff() const
const bool & getValue() const
ValueT & getItem(Index pos) const
ChildIter< MaskOnIterator, LeafNode, ChildOn > ChildOnIter
DenseIterator beginDense() const
DenseIter< const LeafNode, const bool > ChildAllCIter
ChildAllCIter cbeginChildAll() const
void clip(const CoordBBox &, const ValueType &background)
Set all voxels that lie outside the given axis-aligned box to the background.
**But if you need a result
bool isValueMaskOff(Index n) const
bool allocate()
Allocate memory for this node's buffer if it has not already been allocated.
ValueAllIter endValueAll()
NodeT & parent() const
Return a reference to the node over which this iterator is iterating.
bool isValueMaskOn() const
const NodeT * probeConstNode(const Coord &) const
This function exists only to enable template instantiation.
void topologyIntersection(const LeafNode< OtherType, Log2Dim > &other, const ValueType &)
Intersect this node's set of active values with the active values of the other node, whose ValueType may be different. So a resulting voxel will be active only if both of the original voxels were active.
const LeafNode * probeLeaf(const Coord &) const
Return a pointer to this node.
Index64 onLeafVoxelCount() const
bool isValueMaskOff() const
Tag dispatch class that distinguishes constructors during file input.
ValueOnCIter cbeginValueOn() const
OPENVDB_API void checkFormatVersion(std::ios_base &)
Throws an IoError if the file format version number is not supported.
const NodeMaskType & valueMask() const
void setActiveState(const Coord &xyz, bool on)
Set the active state of the voxel at the given coordinates but don't change its value.
ValueIter< MaskDenseIter, LeafNode, const bool > ValueAllIter
ValueIter< MaskOffIterator, const LeafNode, const ValueType, ValueOff > ValueOffCIter
static Index getValueLevelAndCache(const Coord &, AccessorT &)
Return the LEVEL (=0) at which leaf node values reside.
static Coord offsetToLocalCoord(Index n)
Return the local coordinates for a linear table offset, where offset 0 has coordinates (0...
ValueOffCIter cendValueOff() const
Index32 countOff() const
Return the total number of on bits.
void writeBuffers(std::ostream &os, bool toHalf=false) const
Write buffers to a stream.
ValueIter< MaskDenseIterator, LeafNode, const ValueType, ValueAll > ValueAllIter
ChildAllCIter cendChildAll() const
const Coord & origin() const
Return the grid index coordinates of this node's local origin.
#define OPENVDB_ASSERT(X)
std::shared_ptr< T > SharedPtr
ChildOffCIter beginChildOff() const
bool isValueOn(Index offset) const
Return true if the voxel at the given offset is active.
bool isValueOn(const Coord &xyz) const
Return true if the voxel at the given coordinates is active.
ValueAllCIter beginValueAll() const
void stealNodes(ArrayT &, const ValueType &, bool)
This function exists only to enable template instantiation.
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...
const LeafNode * probeLeafAndCache(const Coord &, AccessorT &) const
Return a pointer to this node.
void modifyItem(Index n, const ModifyOp &op) const
const bool & getItem(Index pos) const
OffMaskIterator< NodeMask > OffIterator
ChildAllCIter beginChildAll() const
Buffer mBuffer
Bitmask representing the values of voxels.
void save(std::ostream &os) const
ValueIter< MaskOnIter, LeafNode, const bool > ValueOnIter
void setValueOff(const Coord &xyz)
Mark the voxel at the given coordinates as inactive but don't change its value.
ValueOnCIter beginValueOn() const
ValueOnCIter cendValueOn() const
void setValueOnUnsafe(Index offset)
Mark the voxel at the given offset as active but don't change its value.
bool isOn(Index32 n) const
Return true if the nth bit is on.
Bit mask for the internal and leaf nodes of VDB. This is a 64-bit implementation. ...
void swap(LeafBuffer &)
Exchange this buffer's values with the other buffer's values.
GA_API const UT_StringHolder trans
void addTile(Index level, const Coord &, const ValueType &, bool)
void denseFill(const CoordBBox &bbox, bool val, bool on=true)
Set all voxels within an axis-aligned box to the specified value and active state.
Index64 onVoxelCount() const
Return the number of voxels marked On.
bool resultIsActive() const
ChildAllIter endChildAll()
static bool hasActiveTiles()
Return false since leaf nodes never contain tiles.
Templated block class to hold specific data types and a fixed number of values determined by Log2Dim...
void modifyValue(const ModifyOp &op) const
bool isValueOff(Index offset) const
Return true if the voxel at the given offset is inactive.
void topologyDifference(const LeafNode< OtherType, Log2Dim > &other, const ValueType &)
Difference this node's set of active values with the active values of the other node, whose ValueType may be different. So a resulting voxel will be active only if the original voxel is active in this LeafNode and inactive in the other LeafNode.
General-purpose arithmetic and comparison routines, most of which accept arbitrary value types (or at...
ValueOnCIter endValueOn() const
ValueIter< MaskOnIterator, LeafNode, const ValueType, ValueOn > ValueOnIter
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.
void modifyItem(Index n, const ModifyOp &op) const
void setValueMaskOff(Index n)
static Index64 offTileCount()
bool isAllocated() const
Return true if memory for this node's buffer has been allocated.
const NodeMaskType & getValueMask() const
bool operator!=(const LeafNode &other) const
const bool & getFirstValue() const
Return a const reference to the first entry in the buffer.
bool isConstant(bool &isOn) const
std::string str() const
Return a string representation of this node.
void set(Index32 n, bool On)
Set the nth bit to the specified state.
OnIterator beginOn() const
void setValueOffUnsafe(Index offset, const bool &value)
Set the value of the voxel at the given coordinates and mark the voxel as active. ...
typename std::remove_const< UnsetItemT >::type NonConstValueType
ValueIter(const MaskIterT &iter, NodeT *parent)
void resetBackground(const ValueType &oldBackground, const ValueType &newBackground)
Replace inactive occurrences of oldBackground with newBackground, and inactive occurrences of -oldBac...
bool isChildMaskOff() const
ValueType medianAll(ValueType *tmp=nullptr) const
Computes the median value of all the active AND inactive voxels in this node.
static const Index LOG2DIM
LeafNode * touchLeafAndCache(const Coord &, AccessorT &)
Return a pointer to this node.
void setOn(Index32 n)
Set the nth bit on.
ValueOffIter endValueOff()
void setValueOff(const Coord &xyz)
Mark the voxel at the given coordinates as inactive but don't change its value.
Index64 offVoxelCount() const
Return the number of voxels marked Off.
void nodeCount(std::vector< Index64 > &) const
no-op
void modifyValueAndActiveStateAndCache(const Coord &xyz, const ModifyOp &op, AccessorT &)
const Coord & origin() const
Return the grid index coordinates of this node's local origin.
void modifyValueAndActiveState(const Coord &xyz, const ModifyOp &op)
Apply a functor to the voxel at the given coordinates.
OffIterator beginOff() const
ValueAllCIter cbeginValueAll() const
ChildOnCIter endChildOn() const
that also have some descendant prim *whose name begins with which in turn has a child named baz where *the predicate active
MaskT< LOG2DIM > mValueMask
ValueIter< MaskOffIter, LeafNode, const bool > ValueOffIter
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...
Coord offsetToGlobalCoord(Index n) const
Return the global coordinates for a linear table offset.
Base class for sparse iterators over internal and leaf nodes.
void setValueOnlyAndCache(const Coord &xyz, bool val, AccessorT &)
Change the value of the voxel at the given coordinates but preserve its state.
static Index64 onTileCount()
void combine2(const LeafNode &other, const OtherType &, bool valueIsActive, CombineOp &)
bool getValueUnsafe(Index offset, bool &value) const
Return true if the voxel at the given offset is active and set value.
Index medianOn(ValueType &value, ValueType *tmp=nullptr) const
Computes the median value of all the active voxels in this node.
CoordBBox getNodeBoundingBox() const
Return the bounding box of this node, i.e., the full index space spanned by this leaf node...
LeafNode()
Default constructor.
NodeT * probeNodeAndCache(const Coord &, AccessorT &)
Return a pointer to this node.
ChildOnCIter beginChildOn() const
bool isChildMaskOff(Index) const
Base class for dense iterators over internal and leaf nodes.
void fill(const ValueType &)
Populate this buffer with a constant value.
ChildIter< MaskOffIter, const LeafNode > ChildOffCIter
OffIterator endOff() const
ChildAllCIter endChildAll() const
void setActiveStateUnsafe(Index offset, bool on)
Set the active state of the voxel at the given offset but don't change its value. ...
DenseMaskIterator< NodeMask > DenseIterator
void setValueOn(Index offset)
Mark the voxel at the given offset as active but don't change its value.
static void evalNodeOrigin(Coord &xyz)
Compute the origin of the leaf node that contains the voxel with the given coordinates.
ValueIter< MaskOnIterator, const LeafNode, const ValueType, ValueOn > ValueOnCIter
ChildIter< MaskOffIter, LeafNode > ChildOffIter
void setItem(Index pos, const ValueT &value) const
DenseIter< LeafNode, bool > ChildAllIter
void setActiveState(Index offset, bool on)
Set the active state of the voxel at the given offset but don't change its value. ...
typename NodeMaskType::OnIterator MaskOnIter
Index64 onVoxelCount() const
Return the number of active voxels.
ValueAllCIter endValueAll() const
bool probeValue(const Coord &xyz, ValueType &val) const
Return true if the voxel at the given coordinates is active.
CombineArgs & setBRef(const BValueType &b)
Redirect the B value to a new external source.
void combine(const LeafNode &other, CombineOp &op)
void prune(const ValueType &=zeroVal< ValueType >())
This function exists only to enable template instantiation.
const NodeT * probeConstNodeAndCache(const Coord &, AccessorT &) const
Return a pointer to this node.
Index medianOff(ValueType &value, ValueType *tmp=nullptr) const
Computes the median value of all the inactive voxels in this node.
void addTileAndCache(Index, const Coord &, const ValueType &, bool, AccessorT &)
ValueIter< MaskOffIter, const LeafNode, const bool > ValueOffCIter
bool isEmpty() const
Return true if this node has no active voxels.
ValueIter< MaskDenseIter, const LeafNode, const bool > ValueAllCIter
void unsetItem(Index pos, const ValueT &val) const
NodeT * probeNode(const Coord &)
This function exists only to enable template instantiation.
void getOrigin(Coord &origin) const
Return the grid index coordinates of this node's local origin.
ValueIter< MaskDenseIterator, const LeafNode, const ValueType, ValueAll > ValueAllCIter
OnMaskIterator< NodeMask > OnIterator
void setValue(const Coord &xyz, bool val)
Set the value of the voxel at the given coordinates and mark the voxel as active. ...
void setTransientData(Index32 transientData)
Set the transient data value.
LeafNode * probeLeafAndCache(const Coord &, AccessorT &)
Return a pointer to this node.
void voxelizeActiveTiles(bool=true)
No-op.
Index64 offLeafVoxelCount() const
static Index getValueLevel(const Coord &)
Return the level (0) at which leaf node values reside.
typename NodeMaskType::DenseIterator MaskDenseIter
**If you just want to fire and args
bool isInactive() const
Return true if all of this node's values are inactive.
bool isDense() const
Return true if this node only contains active voxels.
LeafNode & operator=(const LeafNode &)=default
Deep assignment operator.
CombineArgs & setARef(const AValueType &a)
Redirect the A value to a new external source.
static Index64 nonLeafCount()
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...
ChildIter(const MaskIterT &iter, NodeT *parent)
bool getItem(Index pos, void *&child, NonConstValueT &value) const
static Index dim()
Return the number of voxels in each dimension.
Tag dispatch class that distinguishes topology copy constructors from deep copy constructors.
SharedPtr< LeafNodeType > Ptr
static Index64 leafCount()
void load(std::istream &is)
void addLeafAndCache(LeafNode *, AccessorT &)
This function exists only to enable template instantiation.
ChildOnCIter cendChildOn() const
bool isChildMaskOn(Index) const
bool isValueOff(const Coord &xyz) const
Return true if the voxel at the given coordinates is inactive.
void setValue(Index i, const ValueType &)
Set the i'th value of this buffer to the specified value.
void setActiveStateAndCache(const Coord &xyz, bool on, AccessorT &)
Set the active state of the voxel at the given coordinates without changing its value.
DenseIter< const LeafNode, const ValueType, ChildAll > ChildAllCIter
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...
typename BaseT::NonConstValueType NonConstValueT
ValueAllIter beginValueAll()
bool operator==(const LeafNode &other) const
Check for buffer, state and origin equivalence.
ChildOffIter beginChildOff()
ChildIter< MaskOnIter, LeafNode > ChildOnIter
ChildOffCIter endChildOff() const
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
void evalActiveBoundingBox(CoordBBox &bbox, bool visitVoxels=true) const
ValueAllCIter cendValueAll() const
void setValueOnly(Index offset, bool val)
Set the value of the voxel at the given offset but don't change its active state. ...
static Index coordToOffset(const Coord &xyz)
Return the linear table offset of the given global or local coordinates.
void setValue(bool value) const
DenseIter(const MaskDenseIter &iter, NodeT *parent)
ValueOffCIter endValueOff() const
bool probeValueAndCache(const Coord &xyz, bool &val, AccessorT &) const
Return true if the voxel at the given coordinates is active and return the voxel value in val...
NodeMaskType mValueMask
Bitmask that determines which voxels are active.
ChildIter< MaskOffIterator, const LeafNode, ChildOff > ChildOffCIter
const Buffer & buffer() const
CoordBBox getNodeBoundingBox() const
Return the bounding box of this node, i.e., the full index space spanned by this leaf node...
ChildOffIter endChildOff()
static Index getChildDim()
bool isZero(const Type &x)
Return true if x is exactly equal to zero.
void writeTopology(std::ostream &os, bool toHalf=false) const
Write out just the topology.
void nodeCount(std::vector< Index64 > &) const
no-op
bool isOff(Index32 n) const
Return true if the nth bit is off.
bool isValueOnAndCache(const Coord &xyz, AccessorT &) const
Return true if the voxel at the given coordinates is active.
ValueOffIter beginValueOff()
DenseIter< LeafNode, ValueType, ChildAll > ChildAllIter
void setOrigin(const Coord &origin)
Set the grid index coordinates of this node's local origin.
ValueIter< MaskOffIterator, LeafNode, const ValueType, ValueOff > ValueOffIter
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.
Index32 transientData() const
Return the transient data value.
ValueOffCIter cbeginValueOff() const