4 #ifndef OPENVDB_TREE_LEAF_NODE_MASK_HAS_BEEN_INCLUDED
5 #define OPENVDB_TREE_LEAF_NODE_MASK_HAS_BEEN_INCLUDED
18 #include <type_traits>
30 template<Index Log2Dim>
52 template<
typename OtherValueType>
57 template<
typename OtherNodeType>
58 struct SameConfiguration {
78 template<
typename OtherValueType>
82 template<
typename ValueType>
88 template<
typename ValueType>
90 template<
typename ValueType>
133 bool isEmpty()
const {
return mBuffer.mData.isOff(); }
135 bool isDense()
const {
return mBuffer.mData.isOn(); }
162 const Coord&
origin()
const {
return mOrigin; }
181 std::string
str()
const;
185 template<
typename OtherType, Index OtherLog2Dim>
205 void readTopology(std::istream&,
bool fromHalf =
false);
207 void writeTopology(std::ostream&,
bool toHalf =
false)
const;
210 void readBuffers(std::istream&,
bool fromHalf =
false);
213 void writeBuffers(std::ostream&,
bool toHalf =
false)
const;
219 const bool&
getValue(
const Coord& xyz)
const;
269 template<
typename ModifyOp>
273 template<
typename ModifyOp>
277 template<
typename ModifyOp>
319 template<
typename DenseT>
338 template<
typename DenseT>
343 template<
typename AccessorT>
348 template<
typename AccessorT>
353 template<
typename AccessorT>
359 template<
typename AccessorT>
364 template<
typename AccessorT>
373 template<
typename ModifyOp,
typename AccessorT>
381 template<
typename ModifyOp,
typename AccessorT>
390 template<
typename AccessorT>
399 template<
typename AccessorT>
407 template<
typename AccessorT>
413 const bool&
getFirstValue()
const {
if (mBuffer.mData.isOn(0))
return Buffer::sOn;
else return Buffer::sOff; }
417 const bool&
getLastValue()
const {
if (mBuffer.mData.isOn(
SIZE-1))
return Buffer::sOn;
else return Buffer::sOff; }
422 bool isConstant(
bool& constValue,
bool&
state,
bool tolerance = 0)
const;
481 void negate() { mBuffer.mData.toggle(); }
483 template<MergePolicy Policy>
484 void merge(
const LeafNode& other,
bool bg =
false,
bool otherBG =
false);
485 template<MergePolicy Policy>
void merge(
bool tileValue,
bool tileActive=
false);
497 template<
typename OtherType>
511 template<
typename OtherType>
525 template<
typename OtherType>
528 template<
typename CombineOp>
530 template<
typename CombineOp>
531 void combine(
bool,
bool valueIsActive, CombineOp&
op);
533 template<
typename CombineOp,
typename OtherType >
534 void combine2(
const LeafNode& other,
const OtherType&,
bool valueIsActive, CombineOp&);
535 template<
typename CombineOp,
typename OtherNodeT >
536 void combine2(
bool,
const OtherNodeT& other,
bool valueIsActive, CombineOp&);
537 template<
typename CombineOp,
typename OtherNodeT >
544 template<
typename AccessorT>
546 template<
typename NodeT>
548 template<
typename NodeT>
550 template<
typename NodeT>
552 template<
typename ArrayT>
void getNodes(ArrayT&)
const {}
558 template<
typename AccessorT>
564 template<
typename AccessorT>
567 template<
typename AccessorT>
569 template<
typename NodeT,
typename AccessorT>
574 return reinterpret_cast<NodeT*
>(
this);
581 template<
typename AccessorT>
584 template<
typename AccessorT>
586 template<
typename NodeT,
typename AccessorT>
591 return reinterpret_cast<const NodeT*
>(
this);
604 template<
typename MaskIterT,
typename NodeT,
typename ValueT>
608 public SparseIteratorBase<MaskIterT, ValueIter<MaskIterT, NodeT, ValueT>, NodeT, ValueT>
624 template<
typename ModifyOp>
627 template<
typename ModifyOp>
632 template<
typename MaskIterT,
typename NodeT>
638 MaskIterT,
ChildIter<MaskIterT, NodeT>, NodeT,
bool>(iter, parent) {}
641 template<
typename NodeT,
typename ValueT>
643 MaskDenseIter, DenseIter<NodeT, ValueT>, NodeT, void, ValueT>
653 value = this->
parent().getValue(pos);
667 using ValueOnCIter = ValueIter<MaskOnIter, const LeafNode, const bool>;
778 template<Index Log2Dim>
785 template<Index Log2Dim>
788 : mBuffer(value || active)
789 , mOrigin(xyz & (~(DIM - 1)))
794 template<Index Log2Dim>
797 : mBuffer(value || active)
798 , mOrigin(xyz & (~(DIM - 1)))
803 template<Index Log2Dim>
806 : mBuffer(other.mBuffer)
807 , mOrigin(other.mOrigin)
808 , mTransientData(other.mTransientData)
814 template<Index Log2Dim>
815 template<
typename ValueT>
818 : mBuffer(other.valueMask())
819 , mOrigin(other.origin())
820 , mTransientData(other.mTransientData)
825 template<Index Log2Dim>
826 template<
typename ValueT>
830 : mBuffer(other.valueMask())
831 , mOrigin(other.origin())
832 , mTransientData(other.mTransientData)
837 template<Index Log2Dim>
838 template<
typename ValueT>
841 : mBuffer(other.valueMask())
842 , mOrigin(other.origin())
843 , mTransientData(other.mTransientData)
848 template<Index Log2Dim>
849 template<
typename ValueT>
853 : mBuffer(other.valueMask())
854 , mOrigin(other.origin())
855 , mTransientData(other.mTransientData)
857 if (offValue==
true) {
858 if (onValue==
false) {
859 mBuffer.mData.toggle();
861 mBuffer.mData.setOn();
867 template<Index Log2Dim>
877 template<Index Log2Dim>
882 return sizeof(*this);
886 template<Index Log2Dim>
891 return sizeof(*this);
895 template<Index Log2Dim>
900 if (bbox.isInside(this_bbox))
return;
904 for(; iter; ++iter) this_bbox.expand(
this->offsetToLocalCoord(iter.pos()));
905 this_bbox.translate(this->
origin());
907 bbox.expand(this_bbox);
912 template<Index Log2Dim>
913 template<
typename OtherType, Index OtherLog2Dim>
918 return (Log2Dim == OtherLog2Dim && mBuffer.mData == other->
getValueMask());
922 template<Index Log2Dim>
926 std::ostringstream ostr;
927 ostr <<
"LeafNode @" << mOrigin <<
": ";
928 for (
Index32 n = 0;
n <
SIZE; ++
n) ostr << (mBuffer.mData.isOn(
n) ?
'#' :
'.');
936 template<Index Log2Dim>
941 return ((xyz[0] & (
DIM-1u)) << 2*Log2Dim)
942 + ((xyz[1] & (
DIM-1u)) << Log2Dim)
943 + (xyz[2] & (
DIM-1u));
947 template<Index Log2Dim>
953 xyz.setX(n >> 2*Log2Dim);
954 n &= ((1 << 2*Log2Dim) - 1);
955 xyz.setY(n >> Log2Dim);
956 xyz.setZ(n & ((1 << Log2Dim) - 1));
961 template<Index Log2Dim>
972 template<Index Log2Dim>
976 mBuffer.mData.load(is);
980 template<Index Log2Dim>
984 mBuffer.mData.save(os);
988 template<Index Log2Dim>
998 bool background =
false;
1000 background = *
static_cast<const bool*
>(bgPtr);
1002 this->
clip(clipBBox, background);
1006 template<Index Log2Dim>
1011 mBuffer.mData.load(is);
1017 template<Index Log2Dim>
1022 mBuffer.mData.save(os);
1024 os.write(reinterpret_cast<const char*>(&mOrigin),
sizeof(
Coord::ValueType) * 3);
1031 template<Index Log2Dim>
1035 return mOrigin == other.mOrigin && mBuffer == other.mBuffer;
1039 template<Index Log2Dim>
1050 template<Index Log2Dim>
1054 if (!mBuffer.mData.isConstant(state))
return false;
1063 template<Index Log2Dim>
1067 const Index countTrue = mBuffer.mData.countOn();
1071 template<Index Log2Dim>
1075 const Index countTrueOn = mBuffer.mData.countOn();
1080 template<Index Log2Dim>
1084 const Index countFalseOff = mBuffer.mData.countOff();
1086 return countFalseOff;
1093 template<Index Log2Dim>
1100 template<Index Log2Dim>
1109 template<Index Log2Dim>
1110 template<
typename AccessorT>
1115 this->
addTile(level, xyz, val, active);
1122 template<Index Log2Dim>
1127 if (mBuffer.mData.isOn(
this->coordToOffset(xyz)))
return Buffer::sOn;
else return Buffer::sOff;
1131 template<Index Log2Dim>
1137 if (mBuffer.mData.isOn(offset))
return Buffer::sOn;
else return Buffer::sOff;
1141 template<Index Log2Dim>
1149 template<Index Log2Dim>
1153 val = mBuffer.mData.isOn(offset);
1158 template<Index Log2Dim>
1166 template<Index Log2Dim>
1171 mBuffer.mData.set(offset, val);
1175 template<Index Log2Dim>
1183 template<Index Log2Dim>
1191 template<Index Log2Dim>
1199 template<Index Log2Dim>
1204 mBuffer.mData.set(offset, val);
1208 template<Index Log2Dim>
1209 template<
typename ModifyOp>
1213 bool val = mBuffer.mData.isOn(offset);
1215 mBuffer.mData.set(offset, val);
1219 template<Index Log2Dim>
1220 template<
typename ModifyOp>
1228 template<Index Log2Dim>
1229 template<
typename ModifyOp>
1234 bool val = mBuffer.mData.isOn(offset),
state =
val;
1236 mBuffer.mData.set(offset, val);
1243 template<Index Log2Dim>
1244 template<MergePolicy Policy>
1250 mBuffer.mData |= other.mBuffer.mData;
1254 template<Index Log2Dim>
1255 template<MergePolicy Policy>
1261 if (tileValue) mBuffer.mData.setOn();
1269 template<Index Log2Dim>
1270 template<
typename OtherType>
1278 template<Index Log2Dim>
1279 template<
typename OtherType>
1288 template<Index Log2Dim>
1289 template<
typename OtherType>
1301 template<Index Log2Dim>
1306 if (!clipBBox.hasOverlap(nodeBBox)) {
1308 this->
fill(nodeBBox, background,
false);
1309 }
else if (clipBBox.isInside(nodeBBox)) {
1319 nodeBBox.intersect(clipBBox);
1321 int &
x = xyz.x(), &
y = xyz.y(), &
z = xyz.z();
1322 for (x = nodeBBox.min().x(); x <= nodeBBox.max().x(); ++
x) {
1323 for (
y = nodeBBox.min().y();
y <= nodeBBox.max().y(); ++
y) {
1324 for (
z = nodeBBox.min().z();
z <= nodeBBox.max().z(); ++
z) {
1341 template<Index Log2Dim>
1346 clippedBBox.intersect(bbox);
1347 if (!clippedBBox)
return;
1349 for (
Int32 x = clippedBBox.min().x();
x <= clippedBBox.max().x(); ++
x) {
1350 const Index offsetX = (
x & (
DIM-1u))<<2*Log2Dim;
1351 for (
Int32 y = clippedBBox.min().y();
y <= clippedBBox.max().y(); ++
y) {
1352 const Index offsetXY = offsetX + ((
y & (
DIM-1u))<< Log2Dim);
1353 for (
Int32 z = clippedBBox.min().z();
z <= clippedBBox.max().z(); ++
z) {
1355 mBuffer.mData.set(offset, value);
1361 template<Index Log2Dim>
1365 mBuffer.
fill(value);
1372 template<Index Log2Dim>
1373 template<
typename DenseT>
1379 const size_t xStride = dense.xStride(), yStride = dense.yStride(), zStride = dense.zStride();
1380 const Coord&
min = dense.bbox().min();
1381 DenseValueType* t0 = dense.data() + zStride * (bbox.min()[2] - min[2]);
1382 const Int32 n0 = bbox.min()[2] & (
DIM-1u);
1383 for (
Int32 x = bbox.min()[0], ex = bbox.max()[0] + 1;
x < ex; ++
x) {
1384 DenseValueType* t1 = t0 + xStride * (
x - min[0]);
1386 for (
Int32 y = bbox.min()[1], ey = bbox.max()[1] + 1;
y < ey; ++
y) {
1387 DenseValueType* t2 = t1 + yStride * (
y - min[1]);
1389 for (
Int32 z = bbox.min()[2], ez = bbox.max()[2] + 1;
z < ez; ++
z, t2 += zStride) {
1390 *t2 = DenseValueType(mBuffer.mData.isOn(n2++));
1397 template<Index Log2Dim>
1398 template<
typename DenseT>
1401 bool background,
bool tolerance)
1405 inline static bool toBool(
const DenseValueType&
v) {
return !
math::isZero(v); }
1408 const size_t xStride = dense.xStride(), yStride = dense.yStride(), zStride = dense.zStride();
1409 const Coord&
min = dense.bbox().min();
1410 const DenseValueType* s0 = dense.data() + zStride * (bbox.min()[2] - min[2]);
1411 const Int32 n0 = bbox.min()[2] & (
DIM-1u);
1412 for (
Int32 x = bbox.min()[0], ex = bbox.max()[0] + 1;
x < ex; ++
x) {
1413 const DenseValueType* s1 = s0 + xStride * (
x - min[0]);
1415 for (
Int32 y = bbox.min()[1], ey = bbox.max()[1] + 1;
y < ey; ++
y) {
1416 const DenseValueType* s2 = s1 + yStride * (
y - min[1]);
1418 for (
Int32 z = bbox.min()[2], ez = bbox.max()[2]+1;
z < ez; ++
z, ++n2, s2 += zStride) {
1420 if (tolerance || (background == Local::toBool(*s2))) {
1421 mBuffer.mData.set(n2, background);
1423 mBuffer.mData.set(n2, Local::toBool(*s2));
1434 template<Index Log2Dim>
1435 template<
typename CombineOp>
1441 bool result =
false, aVal = mBuffer.mData.isOn(i), bVal = other.mBuffer.mData.isOn(i);
1446 .setResultRef(result));
1447 mBuffer.mData.set(i, result);
1452 template<Index Log2Dim>
1453 template<
typename CombineOp>
1458 args.
setBRef(value).setBIsActive(valueIsActive);
1460 bool result =
false, aVal = mBuffer.mData.isOn(i);
1463 .setResultRef(result));
1464 mBuffer.mData.set(i, result);
1472 template<Index Log2Dim>
1473 template<
typename CombineOp,
typename OtherType>
1476 bool valueIsActive, CombineOp&
op)
1479 args.
setBRef(value).setBIsActive(valueIsActive);
1481 bool result =
false, aVal = other.mBuffer.mData.isOn(i);
1484 .setResultRef(result));
1485 mBuffer.mData.set(i, result);
1490 template<Index Log2Dim>
1491 template<
typename CombineOp,
typename OtherNodeT>
1494 bool valueIsActive, CombineOp&
op)
1497 args.
setARef(value).setAIsActive(valueIsActive);
1499 bool result =
false, bVal = other.mBuffer.mData.isOn(i);
1502 .setResultRef(result));
1503 mBuffer.mData.set(i, result);
1508 template<Index Log2Dim>
1509 template<
typename CombineOp,
typename OtherNodeT>
1515 bool result =
false, b0Val = b0.mBuffer.mData.isOn(i), b1Val = b1.mBuffer.mData.isOn(i);
1517 .setAIsActive(b0Val)
1519 .setBIsActive(b1Val)
1520 .setResultRef(result));
1521 mBuffer.mData.set(i, result);
1530 #endif // OPENVDB_TREE_LEAF_NODE_MASK_HAS_BEEN_INCLUDED
ChildOffCIter beginChildOff() const
static Index64 leafCount()
Return the leaf count for this node, which is one.
void setTransientData(Index32 transientData)
Set the transient data value.
void modifyValue(const ModifyOp &op) const
static Index dim()
Return the number of voxels in each dimension.
static Index64 onTileCount()
Index64 memUsageIfLoaded() const
void merge(const LeafNode &)
LeafNode specialization for values of type ValueMask that encodes both the active states and the bool...
ValueIter< MaskOnIter, LeafNode, const bool > ValueOnIter
bool isValueMaskOn() const
bool isValueOnAndCache(const Coord &xyz, AccessorT &) const
Return true if the voxel at the given coordinates is active.
void stealNodes(ArrayT &, const ValueType &, bool)
This function exists only to enable template instantiation.
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 ...
ValueOffIter endValueOff()
ValueIter< MaskOffIter, LeafNode, const bool > ValueOffIter
static const Index NUM_VOXELS
ValueOnIter beginValueOn()
ValueOffCIter beginValueOff() const
This struct collects both input and output arguments to "grid combiner" functors used with the tree::...
ValueOffCIter cendValueOff() const
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...
bool allocate()
Allocate memory for this node's buffer if it has not already been allocated.
ChildIter(const MaskIterT &iter, NodeT *parent)
const NodeMaskType & valueMask() const
const bool & getValueUnsafe(Index offset) const
Return the value of the voxel at the given offset.
bool getItem(Index pos, void *&child, NonConstValueT &value) const
void readBuffers(std::istream &is, bool fromHalf=false)
Read buffers from a stream.
ChildAllIter beginChildAll()
const bool & getLastValue() const
Return a const reference to the last entry in the buffer.
ValueIter< MaskDenseIter, const LeafNode, const bool > ValueAllCIter
void setValueAndCache(const Coord &xyz, bool val, AccessorT &)
Change the value of the voxel at the given coordinates and mark it as active.
ChildIter< MaskOffIterator, LeafNode, ChildOff > ChildOffIter
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.
DenseIter< const LeafNode, const bool > ChildAllCIter
void readTopology(std::istream &is, bool fromHalf=false)
Read in just the topology.
const NodeMaskType & valueMask() const
void setActiveState(Index offset, bool on)
Set the active state of the voxel at the given offset but don't change its value. ...
NodeMaskType & getValueMask()
ChildAllCIter endChildAll() const
const ValueType & getValue(const Coord &xyz) const
Return the value of the voxel at the given coordinates.
static Index64 nonLeafCount()
Return the non-leaf count for this node, which is zero.
void setValueOn(const Coord &xyz)
Mark the voxel at the given coordinates as active but don't change its value.
ValueAllCIter cbeginValueAll() const
const NodeT * probeConstNode(const Coord &) const
This function exists only to enable template instantiation.
void getNodes(ArrayT &) const
This function exists only to enable template instantiation.
static Index size()
Return the total number of voxels represented by this LeafNode.
const LeafNode * probeConstLeaf(const Coord &) const
Return a pointer to this node.
Buffer mBuffer
Bitmask representing the values AND state of voxels.
bool isConstant(ValueType &firstValue, bool &state, const ValueType &tolerance=zeroVal< ValueType >()) const
ChildIter< MaskOffIter, const LeafNode > ChildOffCIter
GLsizei const GLfloat * value
void setValueMaskOn(Index n)
static const Index NUM_VALUES
const LeafNode * probeConstLeafAndCache(const Coord &, AccessorT &) const
Return a pointer to this node.
SharedPtr< LeafNodeType > Ptr
GLdouble GLdouble GLdouble z
bool isChildMaskOff(Index) const
Index pos() const
Identical to offset.
const NodeMaskType & getValueMask() const
LeafNode * touchLeafAndCache(const Coord &, AccessorT &)
Return a pointer to this node.
bool isAllocated() const
Return true if memory for this node's buffer has been allocated.
Coord mOrigin
Global grid index coordinates (x,y,z) of the local origin of this node.
Index64 memUsage() const
Return the memory in bytes occupied by this node.
ChildAllCIter cendChildAll() const
void setValueOnUnsafe(Index offset)
Mark the voxel at the given offset as active but don't change its value.
#define OPENVDB_USE_VERSION_NAMESPACE
typename NodeMaskType::DenseIterator MaskDenseIter
Index64 offLeafVoxelCount() const
ValueOnCIter endValueOn() const
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
**But if you need a or simply need to know when the task has note that the like this
ValueT & getItem(Index pos) const
ChildAllCIter beginChildAll() const
ChildIter< MaskOnIterator, LeafNode, ChildOn > ChildOnIter
ValueIter< MaskDenseIter, LeafNode, const bool > ValueAllIter
void setValue(bool value) 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
static Index log2dim()
Return log2 of the size of the buffer storage.
ChildOnCIter beginChildOn() const
NodeT & parent() const
Return a reference to the node over which this iterator is iterating.
void setValueMaskOff(Index n)
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.
bool isChildMaskOff() const
DenseIter< LeafNode, bool > ChildAllIter
void setValuesOn()
Mark all voxels as active but don't change their values.
ValueIter(const MaskIterT &iter, NodeT *parent)
Tag dispatch class that distinguishes constructors during file input.
ValueOffCIter endValueOff() const
ValueOnCIter cbeginValueOn() const
void setValueOff(const Coord &xyz)
Mark the voxel at the given coordinates as inactive but don't change its value.
void setActiveStateUnsafe(Index offset, bool on)
Set the active state of the voxel at the given offset but don't change its value. ...
bool isValueMaskOn(Index n) const
void setItem(Index pos, bool value) 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< MaskOffIterator, const LeafNode, const ValueType, ValueOff > ValueOffCIter
bool getValueUnsafe(Index offset, bool &value) const
Return true if the voxel at the given offset is active and set value.
const NodeT * probeConstNodeAndCache(const Coord &, AccessorT &) const
Return a pointer to this node.
static Coord offsetToLocalCoord(Index n)
Return the local coordinates for a linear table offset, where offset 0 has coordinates (0...
void writeBuffers(std::ostream &os, bool toHalf=false) const
Write buffers to a stream.
ValueIter< MaskDenseIterator, LeafNode, const ValueType, ValueAll > ValueAllIter
void prune(const ValueType &=zeroVal< ValueType >())
This function exists only to enable template instantiation.
static bool hasActiveTiles()
Return false since leaf nodes never contain tiles.
#define OPENVDB_ASSERT(X)
bool isValueOn(Index offset) const
Return true if the voxel at the given offset is active.
CoordBBox getNodeBoundingBox() const
Return the bounding box of this node, i.e., the full index space spanned by this leaf node...
std::shared_ptr< T > SharedPtr
LeafNode * touchLeaf(const Coord &)
Return a pointer to this node.
ValueOnCIter cendValueOn() const
bool isValueOn(const Coord &xyz) const
Return true if the voxel at the given coordinates is active.
void setValueOnUnsafe(Index offset, const bool &value)
Set the value of the voxel at the given coordinates and mark the voxel as active. ...
const bool & getItem(Index pos) const
ChildOffIter beginChildOff()
const Coord & origin() const
Return the grid index coordinates of this node's local origin.
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...
bool isDense() const
Return true if this node only contains active voxels.
bool isValueOff(Index offset) const
Return true if the voxel at the given offset is inactive.
void modifyItem(Index n, const ModifyOp &op) const
OffMaskIterator< NodeMask > OffIterator
ChildOnCIter cbeginChildOn() const
Index64 onVoxelCount() const
Return the number of active voxels.
typename BaseT::NonConstValueType NonConstValueT
ValueAllCIter beginValueAll() const
void setOrigin(const Coord &origin)
Set the grid index coordinates of this node's local origin.
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.
void addTile(Index level, const Coord &, const ValueType &, bool)
Index64 onVoxelCount() const
Return the number of voxels marked On.
const bool & getFirstValue() const
Return a const reference to the first entry in the buffer.
NodeT * probeNodeAndCache(const Coord &, AccessorT &)
Return a pointer to this node.
ValueIter< MaskOnIter, const LeafNode, const bool > ValueOnCIter
Templated block class to hold specific data types and a fixed number of values determined by Log2Dim...
ChildOnIter beginChildOn()
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.
ChildOnCIter cendChildOn() const
General-purpose arithmetic and comparison routines, most of which accept arbitrary value types (or at...
const LeafNode * probeLeaf(const Coord &) const
Return a pointer to this node.
ValueAllCIter endValueAll() const
ValueIter< MaskOnIterator, LeafNode, const ValueType, ValueOn > ValueOnIter
void unsetItem(Index pos, const ValueT &val) const
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
const bool & getValueAndCache(const Coord &xyz, AccessorT &) const
Return the value of the voxel at the given coordinates.
ChildIter< MaskOnIter, const LeafNode > ChildOnCIter
static Index getValueLevel(const Coord &)
Return the level (0) at which leaf node values reside.
const NodeMaskType & getValueMask() const
static Index getLevel()
Return the level of this node, which by definition is zero for LeafNodes.
bool operator!=(const LeafNode &other) const
const Buffer & buffer() const
void setValueMask(const NodeMaskType &mask)
constexpr enabler dummy
An instance to use in EnableIf.
bool isValueMaskOff(Index n) const
ValueAllCIter cendValueAll() const
void getOrigin(Int32 &x, Int32 &y, Int32 &z) const
Return the grid index coordinates of this node's local origin.
ChildIter< MaskOnIter, LeafNode > ChildOnIter
ChildAllCIter cbeginChildAll() const
std::string str() const
Return a string representation of this node.
typename std::remove_const< UnsetItemT >::type NonConstValueType
bool isEmpty() const
Return true if this node has no active voxels.
ValueType medianAll(ValueType *tmp=nullptr) const
Computes the median value of all the active AND inactive voxels in this node.
static const Index LOG2DIM
void setOn(Index32 n)
Set the nth bit on.
ValueAllIter endValueAll()
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.
ChildOnCIter endChildOn() const
void swap(Buffer &other)
Exchange this node's data buffer with the given data buffer without changing the active states of the...
void setValueOffAndCache(const Coord &xyz, bool value, AccessorT &)
Change the value of the voxel at the given coordinates and mark it as inactive.
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
void setValueOnlyUnsafe(Index offset, const bool &value)
Set the value of the voxel at the given coordinates but don't change its active state.
void denseFill(const CoordBBox &bbox, bool value, bool=false)
Set all voxels within an axis-aligned box to the specified value.
that also have some descendant prim *whose name begins with which in turn has a child named baz where *the predicate active
void setValueOnly(Index offset, bool val)
Set the value of the voxel at the given offset but don't change its active state. ...
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 combine2(const LeafNode &other, const OtherType &, bool valueIsActive, CombineOp &)
Index32 transientData() const
Return the transient data value.
Index medianOn(ValueType &value, ValueType *tmp=nullptr) const
Computes the median value of all the active voxels in this node.
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...
CoordBBox getNodeBoundingBox() const
Return the bounding box of this node, i.e., the full index space spanned by this leaf node...
LeafNode()
Default constructor.
const LeafNode * probeLeafAndCache(const Coord &, AccessorT &) const
Return a pointer to this node.
static Index64 offTileCount()
Base class for dense iterators over internal and leaf nodes.
void fill(const ValueType &)
Populate this buffer with a constant value.
bool isInactive() const
Return true if all of this node's values are inactive.
DenseMaskIterator< NodeMask > DenseIterator
Library and file format version numbers.
void negate()
Invert the bits of the voxels, i.e. states and values.
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...
LeafNode * probeLeafAndCache(const Coord &, AccessorT &)
Return a pointer to this node.
ValueIter< MaskOnIterator, const LeafNode, const ValueType, ValueOn > ValueOnCIter
void setValueOn(const Coord &xyz)
Mark the voxel at the given coordinates as active but don't change its value.
void setValueMask(Index n, bool on)
void setItem(Index pos, const ValueT &value) const
NodeT * stealNode(const Coord &, const ValueType &, bool)
This function exists only to enable template instantiation.
void nodeCount(std::vector< Index64 > &) const
no-op
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 modifyValueAndActiveStateAndCache(const Coord &xyz, const ModifyOp &op, AccessorT &)
Index64 offVoxelCount() const
Return the number of inactive voxels.
static void getNodeLog2Dims(std::vector< Index > &dims)
Append the Log2Dim of this LeafNode to the specified vector.
void voxelizeActiveTiles(bool=true)
No-op.
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 &)
ValueOnCIter cbeginValueOn() const
ValueIter< MaskDenseIterator, const LeafNode, const ValueType, ValueAll > ValueAllCIter
OnMaskIterator< NodeMask > OnIterator
void setValueOffUnsafe(Index offset, const bool &value)
Set the value of the voxel at the given coordinates and mark the voxel as active. ...
const bool & getValue() const
ChildOffCIter cendChildOff() const
ValueAllIter beginValueAll()
void setValueOnlyAndCache(const Coord &xyz, bool val, AccessorT &)
Change the value of the voxel at the given coordinates but preserve its state.
**If you just want to fire and args
CombineArgs & setARef(const AValueType &a)
Redirect the A value to a new external source.
ValueIter< MaskOffIter, const LeafNode, const bool > ValueOffCIter
ChildOffCIter cbeginChildOff() const
void addLeafAndCache(LeafNode *, AccessorT &)
This function exists only to enable template instantiation.
NodeT * probeNode(const Coord &)
This function exists only to enable template instantiation.
void setValueOffUnsafe(Index offset)
Mark the voxel at the given offset as inactive but don't change its value.
void setValueOn(Index offset)
Mark the voxel at the given offset as active but don't change its value.
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...
static Index getChildDim()
Return the dimension of child nodes of this LeafNode, which is one for voxels.
ChildIter< MaskOffIter, LeafNode > ChildOffIter
ChildOffIter endChildOff()
void setValuesOff()
Mark all voxels as inactive but don't change their values.
DenseIter(const MaskDenseIter &iter, NodeT *parent)
bool isValueMaskOff() const
Tag dispatch class that distinguishes topology copy constructors from deep copy constructors.
ValueOffIter beginValueOff()
typename NodeMaskType::OffIterator MaskOffIter
bool isValueOff(const Coord &xyz) const
Return true if the voxel at the given coordinates is inactive.
LeafNode * probeLeaf(const Coord &)
Return a pointer to this node.
void setValue(Index i, const ValueType &)
Set the i'th value of this buffer to the specified value.
DenseIter< const LeafNode, const ValueType, ChildAll > ChildAllCIter
void setValueOff(Index offset)
Mark the voxel at the given offset as inactive but don't change its value.
bool isValueOn(const Coord &xyz) const
Return true if the voxel at the given coordinates is active.
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...
ChildAllIter endChildAll()
bool operator==(const LeafNode &other) const
Check for buffer, state and origin equivalence.
ValueOffCIter cbeginValueOff() const
Index64 onLeafVoxelCount() const
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
void evalActiveBoundingBox(CoordBBox &bbox, bool visitVoxels=true) const
static Index numValues()
Return the total number of voxels represented by this LeafNode.
static Index coordToOffset(const Coord &xyz)
Return the linear table offset of the given global or local coordinates.
static void evalNodeOrigin(Coord &xyz)
Compute the origin of the leaf node that contains the voxel with the given coordinates.
bool isChildMaskOn(Index) const
ChildIter< MaskOffIterator, const LeafNode, ChildOff > ChildOffCIter
void setValue(const Coord &xyz, bool val)
Set the value of the voxel at the given coordinates and mark the voxel as active. ...
static Index getValueLevelAndCache(const Coord &, AccessorT &)
Return the LEVEL (=0) at which leaf node values reside.
void addLeaf(LeafNode *)
This function exists only to enable template instantiation.
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
ChildOffCIter endChildOff() const
typename NodeMaskType::OnIterator MaskOnIter
DenseIter< LeafNode, ValueType, ChildAll > ChildAllIter
void resetBackground(bool, bool)
no-op since for this template specialization voxel values and states are indistinguishable.
void getOrigin(Coord &origin) const
Return the grid index coordinates of this node's local origin.
ValueOnCIter beginValueOn() const
ValueIter< MaskOffIterator, LeafNode, const ValueType, ValueOff > ValueOffIter
void setActiveStateAndCache(const Coord &xyz, bool on, AccessorT &)
Set the active state of the voxel at the given coordinates without changing its value.
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.