4 #ifndef OPENVDB_TREE_LEAF_NODE_MASK_HAS_BEEN_INCLUDED
5 #define OPENVDB_TREE_LEAF_NODE_MASK_HAS_BEEN_INCLUDED
17 #include <type_traits>
29 template<Index Log2Dim>
51 template<
typename OtherValueType>
56 template<
typename OtherNodeType>
57 struct SameConfiguration {
77 template<
typename OtherValueType>
81 template<
typename ValueType>
87 template<
typename ValueType>
89 template<
typename ValueType>
130 bool isEmpty()
const {
return mBuffer.mData.isOff(); }
132 bool isDense()
const {
return mBuffer.mData.isOn(); }
159 const Coord&
origin()
const {
return mOrigin; }
172 #if OPENVDB_ABI_VERSION_NUMBER >= 9
174 Index32 transientData()
const {
return mTransientData; }
176 void setTransientData(
Index32 transientData) { mTransientData = transientData; }
184 template<
typename OtherType, Index OtherLog2Dim>
185 bool hasSameTopology(
const LeafNode<OtherType, OtherLog2Dim>* other)
const;
204 void readTopology(std::istream&,
bool fromHalf =
false);
206 void writeTopology(std::ostream&,
bool toHalf =
false)
const;
209 void readBuffers(std::istream&,
bool fromHalf =
false);
210 void readBuffers(std::istream& is,
const CoordBBox&,
bool fromHalf =
false);
212 void writeBuffers(std::ostream&,
bool toHalf =
false)
const;
218 const bool&
getValue(
const Coord& xyz)
const;
264 template<
typename ModifyOp>
268 template<
typename ModifyOp>
269 void modifyValue(
const Coord& xyz,
const ModifyOp& op);
272 template<
typename ModifyOp>
289 void clip(
const CoordBBox&,
bool background);
292 void fill(
const CoordBBox& bbox,
bool value,
bool =
false);
310 template<
typename DenseT>
311 void copyToDense(
const CoordBBox& bbox, DenseT& dense)
const;
329 template<
typename DenseT>
330 void copyFromDense(
const CoordBBox& bbox,
const DenseT& dense,
bool background,
bool tolerance);
334 template<
typename AccessorT>
339 template<
typename AccessorT>
344 template<
typename AccessorT>
350 template<
typename AccessorT>
355 template<
typename AccessorT>
364 template<
typename ModifyOp,
typename AccessorT>
372 template<
typename ModifyOp,
typename AccessorT>
381 template<
typename AccessorT>
390 template<
typename AccessorT>
398 template<
typename AccessorT>
404 const bool&
getFirstValue()
const {
if (mBuffer.mData.isOn(0))
return Buffer::sOn;
else return Buffer::sOff; }
408 const bool&
getLastValue()
const {
if (mBuffer.mData.isOn(
SIZE-1))
return Buffer::sOn;
else return Buffer::sOff; }
413 bool isConstant(
bool& constValue,
bool& state,
bool tolerance = 0)
const;
449 void negate() { mBuffer.mData.toggle(); }
451 template<MergePolicy Policy>
452 void merge(
const LeafNode& other,
bool bg =
false,
bool otherBG =
false);
453 template<MergePolicy Policy>
void merge(
bool tileValue,
bool tileActive=
false);
465 template<
typename OtherType>
479 template<
typename OtherType>
493 template<
typename OtherType>
496 template<
typename CombineOp>
498 template<
typename CombineOp>
499 void combine(
bool,
bool valueIsActive, CombineOp& op);
501 template<
typename CombineOp,
typename OtherType >
502 void combine2(
const LeafNode& other,
const OtherType&,
bool valueIsActive, CombineOp&);
503 template<
typename CombineOp,
typename OtherNodeT >
504 void combine2(
bool,
const OtherNodeT& other,
bool valueIsActive, CombineOp&);
505 template<
typename CombineOp,
typename OtherNodeT >
512 template<
typename AccessorT>
514 template<
typename NodeT>
516 template<
typename NodeT>
518 template<
typename NodeT>
520 template<
typename ArrayT>
void getNodes(ArrayT&)
const {}
526 template<
typename AccessorT>
532 template<
typename AccessorT>
535 template<
typename AccessorT>
537 template<
typename NodeT,
typename AccessorT>
542 return reinterpret_cast<NodeT*
>(
this);
549 template<
typename AccessorT>
552 template<
typename AccessorT>
554 template<
typename NodeT,
typename AccessorT>
559 return reinterpret_cast<const NodeT*
>(
this);
572 template<
typename MaskIterT,
typename NodeT,
typename ValueT>
576 public SparseIteratorBase<MaskIterT, ValueIter<MaskIterT, NodeT, ValueT>, NodeT, ValueT>
592 template<
typename ModifyOp>
595 template<
typename ModifyOp>
600 template<
typename MaskIterT,
typename NodeT>
606 MaskIterT,
ChildIter<MaskIterT, NodeT>, NodeT, bool>(iter, parent) {}
609 template<
typename NodeT,
typename ValueT>
611 MaskDenseIter, DenseIter<NodeT, ValueT>, NodeT, void, ValueT>
621 value = this->
parent().getValue(pos);
635 using ValueOnCIter = ValueIter<MaskOnIter, const LeafNode, const bool>;
715 #if OPENVDB_ABI_VERSION_NUMBER >= 9
748 template<Index Log2Dim>
755 template<Index Log2Dim>
758 : mBuffer(value || active)
759 , mOrigin(xyz & (~(DIM - 1)))
764 template<Index Log2Dim>
767 : mBuffer(value || active)
768 , mOrigin(xyz & (~(DIM - 1)))
773 template<Index Log2Dim>
776 : mBuffer(other.mBuffer)
777 , mOrigin(other.mOrigin)
779 , mTransientData(other.mTransientData)
786 template<Index Log2Dim>
787 template<
typename ValueT>
790 : mBuffer(other.valueMask())
791 , mOrigin(other.origin())
793 , mTransientData(other.mTransientData)
799 template<Index Log2Dim>
800 template<
typename ValueT>
804 : mBuffer(other.valueMask())
805 , mOrigin(other.origin())
807 , mTransientData(other.mTransientData)
813 template<Index Log2Dim>
814 template<
typename ValueT>
817 : mBuffer(other.valueMask())
818 , mOrigin(other.origin())
820 , mTransientData(other.mTransientData)
826 template<Index Log2Dim>
827 template<
typename ValueT>
831 : mBuffer(other.valueMask())
832 , mOrigin(other.origin())
834 , mTransientData(other.mTransientData)
837 if (offValue==
true) {
838 if (onValue==
false) {
839 mBuffer.mData.toggle();
841 mBuffer.mData.setOn();
847 template<Index Log2Dim>
857 template<Index Log2Dim>
862 return sizeof(*this);
866 template<Index Log2Dim>
871 return sizeof(*this);
875 template<Index Log2Dim>
880 if (bbox.isInside(this_bbox))
return;
884 for(; iter; ++iter) this_bbox.expand(
this->offsetToLocalCoord(iter.pos()));
885 this_bbox.translate(this->
origin());
887 bbox.expand(this_bbox);
892 template<Index Log2Dim>
893 template<
typename OtherType, Index OtherLog2Dim>
898 return (Log2Dim == OtherLog2Dim && mBuffer.mData == other->
getValueMask());
902 template<Index Log2Dim>
906 std::ostringstream ostr;
907 ostr <<
"LeafNode @" << mOrigin <<
": ";
908 for (
Index32 n = 0;
n <
SIZE; ++
n) ostr << (mBuffer.mData.isOn(
n) ?
'#' :
'.');
916 template<Index Log2Dim>
920 assert ((xyz[0] & (
DIM-1u)) <
DIM && (xyz[1] & (
DIM-1u)) <
DIM && (xyz[2] & (
DIM-1u)) <
DIM);
921 return ((xyz[0] & (
DIM-1u)) << 2*Log2Dim)
922 + ((xyz[1] & (
DIM-1u)) << Log2Dim)
923 + (xyz[2] & (
DIM-1u));
927 template<Index Log2Dim>
931 assert(n < (1 << 3*Log2Dim));
933 xyz.setX(n >> 2*Log2Dim);
934 n &= ((1 << 2*Log2Dim) - 1);
935 xyz.setY(n >> Log2Dim);
936 xyz.setZ(n & ((1 << Log2Dim) - 1));
941 template<Index Log2Dim>
952 template<Index Log2Dim>
956 mBuffer.mData.load(is);
960 template<Index Log2Dim>
964 mBuffer.mData.save(os);
968 template<Index Log2Dim>
978 bool background =
false;
980 background = *
static_cast<const bool*
>(bgPtr);
982 this->
clip(clipBBox, background);
986 template<Index Log2Dim>
991 mBuffer.mData.load(is);
993 is.read(reinterpret_cast<char*>(&mOrigin),
sizeof(Coord::ValueType) * 3);
997 template<Index Log2Dim>
1002 mBuffer.mData.save(os);
1004 os.write(reinterpret_cast<const char*>(&mOrigin),
sizeof(Coord::ValueType) * 3);
1011 template<Index Log2Dim>
1015 return mOrigin == other.mOrigin && mBuffer == other.mBuffer;
1019 template<Index Log2Dim>
1030 template<Index Log2Dim>
1034 if (!mBuffer.mData.isConstant(state))
return false;
1043 template<Index Log2Dim>
1047 const Index countTrue = mBuffer.mData.countOn();
1051 template<Index Log2Dim>
1055 const Index countTrueOn = mBuffer.mData.countOn();
1060 template<Index Log2Dim>
1064 const Index countFalseOff = mBuffer.mData.countOff();
1066 return countFalseOff;
1073 template<Index Log2Dim>
1080 template<Index Log2Dim>
1084 assert(offset <
SIZE);
1089 template<Index Log2Dim>
1090 template<
typename AccessorT>
1093 bool val,
bool active, AccessorT&)
1095 this->
addTile(level, xyz, val, active);
1102 template<Index Log2Dim>
1107 if (mBuffer.mData.isOn(
this->coordToOffset(xyz)))
return Buffer::sOn;
else return Buffer::sOff;
1111 template<Index Log2Dim>
1115 assert(offset <
SIZE);
1117 if (mBuffer.mData.isOn(offset))
return Buffer::sOn;
else return Buffer::sOff;
1121 template<Index Log2Dim>
1126 val = mBuffer.mData.isOn(offset);
1131 template<Index Log2Dim>
1139 template<Index Log2Dim>
1143 assert(offset <
SIZE);
1144 mBuffer.mData.set(offset, val);
1148 template<Index Log2Dim>
1156 template<Index Log2Dim>
1164 template<Index Log2Dim>
1172 template<Index Log2Dim>
1176 assert(offset <
SIZE);
1177 mBuffer.mData.set(offset, val);
1181 template<Index Log2Dim>
1182 template<
typename ModifyOp>
1186 bool val = mBuffer.mData.isOn(offset);
1188 mBuffer.mData.set(offset, val);
1192 template<Index Log2Dim>
1193 template<
typename ModifyOp>
1201 template<Index Log2Dim>
1202 template<
typename ModifyOp>
1207 bool val = mBuffer.mData.isOn(offset), state =
val;
1209 mBuffer.mData.set(offset, val);
1216 template<Index Log2Dim>
1217 template<MergePolicy Policy>
1223 mBuffer.mData |= other.mBuffer.mData;
1227 template<Index Log2Dim>
1228 template<MergePolicy Policy>
1234 if (tileValue) mBuffer.mData.setOn();
1242 template<Index Log2Dim>
1243 template<
typename OtherType>
1251 template<Index Log2Dim>
1252 template<
typename OtherType>
1261 template<Index Log2Dim>
1262 template<
typename OtherType>
1274 template<Index Log2Dim>
1279 if (!clipBBox.hasOverlap(nodeBBox)) {
1281 this->
fill(nodeBBox, background,
false);
1282 }
else if (clipBBox.isInside(nodeBBox)) {
1292 nodeBBox.intersect(clipBBox);
1294 int &
x = xyz.x(), &
y = xyz.y(), &
z = xyz.z();
1295 for (x = nodeBBox.min().x(); x <= nodeBBox.max().x(); ++
x) {
1296 for (
y = nodeBBox.min().y();
y <= nodeBBox.max().y(); ++
y) {
1297 for (
z = nodeBBox.min().z();
z <= nodeBBox.max().z(); ++
z) {
1314 template<Index Log2Dim>
1319 clippedBBox.intersect(bbox);
1320 if (!clippedBBox)
return;
1322 for (
Int32 x = clippedBBox.min().x();
x <= clippedBBox.max().x(); ++
x) {
1323 const Index offsetX = (
x & (
DIM-1u))<<2*Log2Dim;
1324 for (
Int32 y = clippedBBox.min().y();
y <= clippedBBox.max().y(); ++
y) {
1325 const Index offsetXY = offsetX + ((
y & (
DIM-1u))<< Log2Dim);
1326 for (
Int32 z = clippedBBox.min().z();
z <= clippedBBox.max().z(); ++
z) {
1328 mBuffer.mData.set(offset, value);
1334 template<Index Log2Dim>
1338 mBuffer.
fill(value);
1345 template<Index Log2Dim>
1346 template<
typename DenseT>
1350 using DenseValueType =
typename DenseT::ValueType;
1352 const size_t xStride = dense.xStride(), yStride = dense.yStride(), zStride = dense.zStride();
1353 const Coord&
min = dense.bbox().min();
1354 DenseValueType* t0 = dense.data() + zStride * (bbox.min()[2] - min[2]);
1355 const Int32 n0 = bbox.min()[2] & (
DIM-1u);
1356 for (
Int32 x = bbox.min()[0], ex = bbox.max()[0] + 1;
x < ex; ++
x) {
1357 DenseValueType* t1 = t0 + xStride * (
x - min[0]);
1359 for (
Int32 y = bbox.min()[1], ey = bbox.max()[1] + 1;
y < ey; ++
y) {
1360 DenseValueType* t2 = t1 + yStride * (
y - min[1]);
1362 for (
Int32 z = bbox.min()[2], ez = bbox.max()[2] + 1;
z < ez; ++
z, t2 += zStride) {
1363 *t2 = DenseValueType(mBuffer.mData.isOn(n2++));
1370 template<Index Log2Dim>
1371 template<
typename DenseT>
1374 bool background,
bool tolerance)
1376 using DenseValueType =
typename DenseT::ValueType;
1378 inline static bool toBool(
const DenseValueType&
v) {
return !
math::isZero(v); }
1381 const size_t xStride = dense.xStride(), yStride = dense.yStride(), zStride = dense.zStride();
1382 const Coord&
min = dense.bbox().min();
1383 const DenseValueType* s0 = dense.data() + zStride * (bbox.min()[2] - min[2]);
1384 const Int32 n0 = bbox.min()[2] & (
DIM-1u);
1385 for (
Int32 x = bbox.min()[0], ex = bbox.max()[0] + 1;
x < ex; ++
x) {
1386 const DenseValueType* s1 = s0 + xStride * (
x - min[0]);
1388 for (
Int32 y = bbox.min()[1], ey = bbox.max()[1] + 1;
y < ey; ++
y) {
1389 const DenseValueType* s2 = s1 + yStride * (
y - min[1]);
1391 for (
Int32 z = bbox.min()[2], ez = bbox.max()[2]+1;
z < ez; ++
z, ++n2, s2 += zStride) {
1393 if (tolerance || (background == Local::toBool(*s2))) {
1394 mBuffer.mData.set(n2, background);
1396 mBuffer.mData.set(n2, Local::toBool(*s2));
1407 template<Index Log2Dim>
1408 template<
typename CombineOp>
1414 bool result =
false, aVal = mBuffer.mData.isOn(i), bVal = other.mBuffer.mData.isOn(i);
1419 .setResultRef(result));
1420 mBuffer.mData.set(i, result);
1425 template<Index Log2Dim>
1426 template<
typename CombineOp>
1431 args.
setBRef(value).setBIsActive(valueIsActive);
1433 bool result =
false, aVal = mBuffer.mData.isOn(i);
1436 .setResultRef(result));
1437 mBuffer.mData.set(i, result);
1445 template<Index Log2Dim>
1446 template<
typename CombineOp,
typename OtherType>
1449 bool valueIsActive, CombineOp& op)
1452 args.
setBRef(value).setBIsActive(valueIsActive);
1454 bool result =
false, aVal = other.mBuffer.mData.isOn(i);
1457 .setResultRef(result));
1458 mBuffer.mData.set(i, result);
1463 template<Index Log2Dim>
1464 template<
typename CombineOp,
typename OtherNodeT>
1467 bool valueIsActive, CombineOp& op)
1470 args.
setARef(value).setAIsActive(valueIsActive);
1472 bool result =
false, bVal = other.mBuffer.mData.isOn(i);
1475 .setResultRef(result));
1476 mBuffer.mData.set(i, result);
1481 template<Index Log2Dim>
1482 template<
typename CombineOp,
typename OtherNodeT>
1488 bool result =
false, b0Val = b0.mBuffer.mData.isOn(i), b1Val = b1.mBuffer.mData.isOn(i);
1490 .setAIsActive(b0Val)
1492 .setBIsActive(b1Val)
1493 .setResultRef(result));
1494 mBuffer.mData.set(i, result);
1503 #endif // OPENVDB_TREE_LEAF_NODE_MASK_HAS_BEEN_INCLUDED
ChildOffCIter beginChildOff() const
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
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.
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 GLchar *const * string
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
#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.
#define OPENVDB_ABI_VERSION_NUMBER
The ABI version that OpenVDB was built with.
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.
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
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 nodeCount(std::vector< Index32 > &) const
no-op
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.
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.
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.
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
static Index32 nonLeafCount()
Return the non-leaf count for this node, which is zero.
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
static Index32 leafCount()
Return the leaf count for this node, which is one.
void denseFill(const CoordBBox &bbox, bool value, bool=false)
Set all voxels within an axis-aligned box to the specified value.
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 &)
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.
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
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 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
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.
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.