31 #ifndef OPENVDB_TREE_LEAF_NODE_BOOL_HAS_BEEN_INCLUDED 32 #define OPENVDB_TREE_LEAF_NODE_BOOL_HAS_BEEN_INCLUDED 35 #include <boost/shared_ptr.hpp> 36 #include <boost/shared_array.hpp> 37 #include <boost/static_assert.hpp> 38 #include <openvdb/Types.h> 39 #include <openvdb/io/Compression.h> 40 #include <openvdb/math/Math.h> 41 #include <openvdb/util/NodeMasks.h> 53 template<Index Log2Dim>
58 typedef boost::shared_ptr<LeafNodeType>
Ptr;
64 static const Index LOG2DIM = Log2Dim;
65 static const Index TOTAL = Log2Dim;
66 static const Index DIM = 1 << TOTAL;
67 static const Index NUM_VALUES = 1 << 3 * Log2Dim;
68 static const Index NUM_VOXELS = NUM_VALUES;
69 static const Index SIZE = NUM_VALUES;
74 template<
typename ValueType>
79 template<
typename OtherNodeType>
80 struct SameConfiguration {
89 static const Index WORD_COUNT = NodeMaskType::WORD_COUNT;
92 Buffer(
const NodeMaskType& other): mData(other) {}
93 Buffer(
const Buffer& other): mData(other.mData) {}
95 void fill(
bool val) { mData.set(val); }
96 Buffer&
operator=(
const Buffer& b) {
if (&b !=
this) { mData = b.mData; }
return *
this; }
103 if (mData.isOn(i))
return LeafNode::sOn;
else return LeafNode::sOff;
107 bool operator==(
const Buffer& other)
const {
return mData == other.mData; }
108 bool operator!=(
const Buffer& other)
const {
return mData != other.mData; }
112 void swap(Buffer& other) {
if (&other !=
this) std::swap(mData, other.mData); }
122 return &(mData.template getWord<WordType>(0));
130 return const_cast<Buffer*
>(
this)->data();
134 friend class ::TestLeaf;
149 explicit LeafNode(
const Coord& xyz,
bool value =
false,
bool active =
false);
151 #ifndef OPENVDB_2_ABI_COMPATIBLE 160 template<
typename OtherValueType>
164 template<
typename ValueType>
168 template<
typename ValueType>
172 template<
typename ValueType>
205 bool isEmpty()
const {
return mValueMask.isOff(); }
207 bool isDense()
const {
return mValueMask.isOn(); }
209 #ifndef OPENVDB_2_ABI_COMPATIBLE 210 bool isAllocated()
const {
return true; }
226 void evalActiveBoundingBox(CoordBBox& bbox,
bool visitVoxels =
true)
const;
233 void setOrigin(
const Coord& origin) { mOrigin = origin; }
235 const Coord& origin()
const {
return mOrigin; }
237 void getOrigin(Coord& origin)
const { origin = mOrigin; }
242 static Index coordToOffset(
const Coord& xyz);
245 static Coord offsetToLocalCoord(
Index n);
247 Coord offsetToGlobalCoord(
Index n)
const;
250 std::string str()
const;
254 template<
typename OtherType, Index OtherLog2Dim>
266 void swap(Buffer& other) { mBuffer.swap(other); }
267 const Buffer&
buffer()
const {
return mBuffer; }
274 void readTopology(std::istream&,
bool fromHalf =
false);
276 void writeTopology(std::ostream&,
bool toHalf =
false)
const;
279 void readBuffers(std::istream&,
bool fromHalf =
false);
280 void readBuffers(std::istream& is,
const CoordBBox&,
bool fromHalf =
false);
282 void writeBuffers(std::ostream&,
bool toHalf =
false)
const;
288 const bool& getValue(
const Coord& xyz)
const;
290 const bool& getValue(
Index offset)
const;
295 bool probeValue(
const Coord& xyz,
bool& val)
const;
301 void setActiveState(
const Coord& xyz,
bool on);
306 void setValueOnly(
const Coord& xyz,
bool val);
308 void setValueOnly(
Index offset,
bool val) { assert(offset<SIZE); mBuffer.setValue(offset,val); }
311 void setValueOff(
const Coord& xyz) { mValueMask.setOff(this->coordToOffset(xyz)); }
316 void setValueOff(
const Coord& xyz,
bool val);
318 void setValueOff(
Index offset,
bool val);
321 void setValueOn(
const Coord& xyz) { mValueMask.setOn(this->coordToOffset(xyz)); }
326 void setValueOn(
const Coord& xyz,
bool val);
328 void setValue(
const Coord& xyz,
bool val) { this->setValueOn(xyz, val); }
330 void setValueOn(
Index offset,
bool val);
334 template<
typename ModifyOp>
335 void modifyValue(
Index offset,
const ModifyOp& op);
338 template<
typename ModifyOp>
339 void modifyValue(
const Coord& xyz,
const ModifyOp& op);
342 template<
typename ModifyOp>
343 void modifyValueAndActiveState(
const Coord& xyz,
const ModifyOp& op);
351 bool isValueOn(
const Coord& xyz)
const {
return mValueMask.isOn(this->coordToOffset(xyz)); }
353 bool isValueOn(
Index offset)
const { assert(offset < SIZE);
return mValueMask.isOn(offset); }
359 void clip(
const CoordBBox&,
bool background);
362 void fill(
const CoordBBox& bbox,
bool value,
bool active =
true);
365 void fill(
const bool& value);
367 void fill(
const bool& value,
bool active);
380 template<
typename DenseT>
381 void copyToDense(
const CoordBBox& bbox, DenseT& dense)
const;
399 template<
typename DenseT>
400 void copyFromDense(
const CoordBBox& bbox,
const DenseT& dense,
bool background,
bool tolerance);
404 template<
typename AccessorT>
405 const bool&
getValueAndCache(
const Coord& xyz, AccessorT&)
const {
return this->getValue(xyz);}
409 template<
typename AccessorT>
414 template<
typename AccessorT>
415 void setValueAndCache(
const Coord& xyz,
bool val, AccessorT&) { this->setValueOn(xyz, val); }
420 template<
typename AccessorT>
425 template<
typename AccessorT>
428 this->setValueOff(xyz, value);
434 template<
typename ModifyOp,
typename AccessorT>
437 this->modifyValue(xyz, op);
442 template<
typename ModifyOp,
typename AccessorT>
445 this->modifyValueAndActiveState(xyz, op);
451 template<
typename AccessorT>
454 this->setActiveState(xyz, on);
460 template<
typename AccessorT>
463 return this->probeValue(xyz, val);
468 template<
typename AccessorT>
474 const bool&
getFirstValue()
const {
if (mValueMask.isOn(0))
return sOn;
else return sOff; }
478 const bool&
getLastValue()
const {
if (mValueMask.isOn(SIZE-1))
return sOn;
else return sOff; }
483 bool isConstant(
bool& constValue,
bool& state,
bool tolerance = 0)
const;
487 void resetBackground(
bool oldBackground,
bool newBackground);
489 void negate() { mBuffer.mData.toggle(); }
491 template<MergePolicy Policy>
492 void merge(
const LeafNode& other,
bool bg =
false,
bool otherBG =
false);
493 template<MergePolicy Policy>
void merge(
bool tileValue,
bool tileActive);
505 template<
typename OtherType>
519 template<
typename OtherType>
533 template<
typename OtherType>
536 template<
typename CombineOp>
537 void combine(
const LeafNode& other, CombineOp& op);
538 template<
typename CombineOp>
539 void combine(
bool,
bool valueIsActive, CombineOp& op);
541 template<
typename CombineOp,
typename OtherType >
542 void combine2(
const LeafNode& other,
const OtherType&,
bool valueIsActive, CombineOp&);
543 template<
typename CombineOp,
typename OtherNodeT >
544 void combine2(
bool,
const OtherNodeT& other,
bool valueIsActive, CombineOp&);
545 template<
typename CombineOp,
typename OtherNodeT >
546 void combine2(
const LeafNode& b0,
const OtherNodeT& b1, CombineOp&);
552 template<
typename BBoxOp>
void visitActiveBBox(BBoxOp&)
const;
554 template<
typename VisitorOp>
void visit(VisitorOp&);
555 template<
typename VisitorOp>
void visit(VisitorOp&)
const;
557 template<
typename OtherLeafNodeType,
typename VisitorOp>
558 void visit2Node(OtherLeafNodeType& other, VisitorOp&);
559 template<
typename OtherLeafNodeType,
typename VisitorOp>
560 void visit2Node(OtherLeafNodeType& other, VisitorOp&)
const;
561 template<
typename IterT,
typename VisitorOp>
562 void visit2(IterT& otherIter, VisitorOp&,
bool otherIsLHS =
false);
563 template<
typename IterT,
typename VisitorOp>
564 void visit2(IterT& otherIter, VisitorOp&,
bool otherIsLHS =
false)
const;
567 void prune(
const ValueType& = zeroVal<ValueType>()) {}
570 template<
typename AccessorT>
572 template<
typename NodeT>
573 NodeT*
stealNode(
const Coord&,
const ValueType&,
bool) {
return NULL; }
574 template<
typename NodeT>
576 template<
typename NodeT>
578 template<
typename ArrayT>
void getNodes(ArrayT&)
const {}
579 template<
typename ArrayT>
void stealNodes(ArrayT&,
const ValueType&,
bool) {}
582 void addTile(
Index level,
const Coord&,
bool val,
bool active);
583 void addTile(
Index offset,
bool val,
bool active);
584 template<
typename AccessorT>
585 void addTileAndCache(
Index level,
const Coord&,
bool val,
bool active, AccessorT&);
588 LeafNode* touchLeaf(
const Coord&) {
return this; }
590 template<
typename AccessorT>
593 template<
typename AccessorT>
595 template<
typename NodeT,
typename AccessorT>
599 if (!(boost::is_same<NodeT,LeafNode>::value))
return NULL;
600 return reinterpret_cast<NodeT*
>(
this);
605 const LeafNode* probeLeaf(
const Coord&)
const {
return this; }
607 template<
typename AccessorT>
610 template<
typename AccessorT>
612 template<
typename NodeT,
typename AccessorT>
616 if (!(boost::is_same<NodeT,LeafNode>::value))
return NULL;
617 return reinterpret_cast<const NodeT*
>(
this);
630 template<
typename MaskIterT,
typename NodeT,
typename ValueT>
634 public SparseIteratorBase<MaskIterT, ValueIter<MaskIterT, NodeT, ValueT>, NodeT, ValueT>
639 ValueIter(
const MaskIterT& iter, NodeT* parent): BaseT(iter, parent) {}
641 const bool&
getItem(
Index pos)
const {
return this->parent().getValue(pos); }
642 const bool&
getValue()
const {
return this->getItem(this->pos()); }
645 void setItem(
Index pos,
bool value)
const { this->parent().setValueOnly(pos, value); }
647 void setValue(
bool value)
const { this->setItem(this->pos(), value); }
650 template<
typename ModifyOp>
651 void modifyItem(
Index n,
const ModifyOp& op)
const { this->parent().modifyValue(n, op); }
653 template<
typename ModifyOp>
654 void modifyValue(
const ModifyOp& op)
const { this->modifyItem(this->pos(), op); }
658 template<
typename MaskIterT,
typename NodeT>
664 MaskIterT, ChildIter<MaskIterT, NodeT>, NodeT, bool>(iter, parent) {}
667 template<
typename NodeT,
typename ValueT>
669 MaskDenseIter, DenseIter<NodeT, ValueT>, NodeT, void, ValueT>
675 DenseIter(
const MaskDenseIter& iter, NodeT* parent): BaseT(iter, parent) {}
679 value = this->parent().getValue(pos);
688 void unsetItem(
Index pos,
const ValueT& val)
const {this->parent().setValueOnly(pos, val);}
693 typedef ValueIter<MaskOnIter, const LeafNode, const bool>
ValueOnCIter;
705 ValueOnCIter
cbeginValueOn()
const {
return ValueOnCIter(mValueMask.beginOn(),
this); }
706 ValueOnCIter
beginValueOn()
const {
return ValueOnCIter(mValueMask.beginOn(),
this); }
707 ValueOnIter
beginValueOn() {
return ValueOnIter(mValueMask.beginOn(),
this); }
708 ValueOffCIter
cbeginValueOff()
const {
return ValueOffCIter(mValueMask.beginOff(),
this); }
709 ValueOffCIter
beginValueOff()
const {
return ValueOffCIter(mValueMask.beginOff(),
this); }
710 ValueOffIter
beginValueOff() {
return ValueOffIter(mValueMask.beginOff(),
this); }
711 ValueAllCIter
cbeginValueAll()
const {
return ValueAllCIter(mValueMask.beginDense(),
this); }
712 ValueAllCIter
beginValueAll()
const {
return ValueAllCIter(mValueMask.beginDense(),
this); }
713 ValueAllIter
beginValueAll() {
return ValueAllIter(mValueMask.beginDense(),
this); }
715 ValueOnCIter
cendValueOn()
const {
return ValueOnCIter(mValueMask.endOn(),
this); }
716 ValueOnCIter
endValueOn()
const {
return ValueOnCIter(mValueMask.endOn(),
this); }
717 ValueOnIter
endValueOn() {
return ValueOnIter(mValueMask.endOn(),
this); }
718 ValueOffCIter
cendValueOff()
const {
return ValueOffCIter(mValueMask.endOff(),
this); }
719 ValueOffCIter
endValueOff()
const {
return ValueOffCIter(mValueMask.endOff(),
this); }
720 ValueOffIter
endValueOff() {
return ValueOffIter(mValueMask.endOff(),
this); }
721 ValueAllCIter
cendValueAll()
const {
return ValueAllCIter(mValueMask.endDense(),
this); }
722 ValueAllCIter
endValueAll()
const {
return ValueAllCIter(mValueMask.endDense(),
this); }
723 ValueAllIter
endValueAll() {
return ValueAllIter(mValueMask.endDense(),
this); }
727 ChildOnCIter
cbeginChildOn()
const {
return ChildOnCIter(mValueMask.endOn(),
this); }
728 ChildOnCIter
beginChildOn()
const {
return ChildOnCIter(mValueMask.endOn(),
this); }
729 ChildOnIter
beginChildOn() {
return ChildOnIter(mValueMask.endOn(),
this); }
730 ChildOffCIter
cbeginChildOff()
const {
return ChildOffCIter(mValueMask.endOff(),
this); }
731 ChildOffCIter
beginChildOff()
const {
return ChildOffCIter(mValueMask.endOff(),
this); }
732 ChildOffIter
beginChildOff() {
return ChildOffIter(mValueMask.endOff(),
this); }
733 ChildAllCIter
cbeginChildAll()
const {
return ChildAllCIter(mValueMask.beginDense(),
this); }
734 ChildAllCIter
beginChildAll()
const {
return ChildAllCIter(mValueMask.beginDense(),
this); }
735 ChildAllIter
beginChildAll() {
return ChildAllIter(mValueMask.beginDense(),
this); }
737 ChildOnCIter
cendChildOn()
const {
return ChildOnCIter(mValueMask.endOn(),
this); }
738 ChildOnCIter
endChildOn()
const {
return ChildOnCIter(mValueMask.endOn(),
this); }
739 ChildOnIter
endChildOn() {
return ChildOnIter(mValueMask.endOn(),
this); }
740 ChildOffCIter
cendChildOff()
const {
return ChildOffCIter(mValueMask.endOff(),
this); }
741 ChildOffCIter
endChildOff()
const {
return ChildOffCIter(mValueMask.endOff(),
this); }
742 ChildOffIter
endChildOff() {
return ChildOffIter(mValueMask.endOff(),
this); }
743 ChildAllCIter
cendChildAll()
const {
return ChildAllCIter(mValueMask.endDense(),
this); }
744 ChildAllCIter
endChildAll()
const {
return ChildAllCIter(mValueMask.endDense(),
this); }
745 ChildAllIter
endChildAll() {
return ChildAllIter(mValueMask.endDense(),
this); }
755 const NodeMaskType&
valueMask()
const {
return mValueMask; }
769 template<
typename NodeT,
typename VisitorOp,
typename ChildAllIterT>
770 static inline void doVisit(NodeT&, VisitorOp&);
772 template<
typename NodeT,
typename OtherNodeT,
typename VisitorOp,
773 typename ChildAllIterT,
typename OtherChildAllIterT>
774 static inline void doVisit2Node(NodeT&
self, OtherNodeT& other, VisitorOp&);
776 template<
typename NodeT,
typename VisitorOp,
777 typename ChildAllIterT,
typename OtherChildAllIterT>
778 static inline void doVisit2(NodeT&
self, OtherChildAllIterT&, VisitorOp&,
bool otherIsLHS);
797 friend struct ValueIter<MaskOnIter,
LeafNode, bool>;
798 friend struct ValueIter<MaskOffIter,
LeafNode, bool>;
799 friend struct ValueIter<MaskDenseIter,
LeafNode, bool>;
800 friend struct ValueIter<MaskOnIter, const
LeafNode, bool>;
801 friend struct ValueIter<MaskOffIter, const
LeafNode, bool>;
802 friend struct ValueIter<MaskDenseIter, const
LeafNode, bool>;
826 template<Index Log2Dim>
834 template<Index Log2Dim>
839 , mOrigin(xyz & (~(
DIM - 1)))
844 #ifndef OPENVDB_2_ABI_COMPATIBLE 845 template<Index Log2Dim>
850 , mOrigin(xyz & (~(
DIM - 1)))
859 template<Index Log2Dim>
863 , mBuffer(other.mBuffer)
864 , mOrigin(other.mOrigin)
870 template<Index Log2Dim>
871 template<
typename ValueT>
879 static inline bool convertValue(
const ValueT& val) {
return bool(val); }
883 mBuffer.setValue(i, Local::convertValue(other.mBuffer[i]));
888 template<Index Log2Dim>
889 template<
typename ValueT>
894 , mBuffer(background)
900 template<Index Log2Dim>
901 template<
typename ValueT>
911 template<Index Log2Dim>
912 template<
typename ValueT>
920 if (offValue) {
if (!onValue) mBuffer.
mData.toggle();
else mBuffer.
mData.setOn(); }
924 template<Index Log2Dim>
934 template<Index Log2Dim>
939 return sizeof(*this);
943 template<Index Log2Dim>
948 if (bbox.isInside(this_bbox))
return;
952 for(; iter; ++iter) this_bbox.expand(this->offsetToLocalCoord(iter.pos()));
953 this_bbox.translate(this->
origin());
955 bbox.expand(this_bbox);
960 template<Index Log2Dim>
961 template<
typename OtherType, Index OtherLog2Dim>
966 return (Log2Dim == OtherLog2Dim && mValueMask == other->
getValueMask());
970 template<Index Log2Dim>
974 std::ostringstream ostr;
975 ostr <<
"LeafNode @" << mOrigin <<
": ";
976 for (
Index32 n = 0; n <
SIZE; ++n) ostr << (mValueMask.
isOn(n) ?
'#' :
'.');
984 template<Index Log2Dim>
988 assert ((xyz[0] & (
DIM-1u)) <
DIM && (xyz[1] & (
DIM-1u)) <
DIM && (xyz[2] & (
DIM-1u)) <
DIM);
989 return ((xyz[0] & (
DIM-1u)) << 2*Log2Dim)
990 + ((xyz[1] & (
DIM-1u)) << Log2Dim)
991 + (xyz[2] & (
DIM-1u));
995 template<Index Log2Dim>
999 assert(n < (1 << 3*Log2Dim));
1001 xyz.setX(n >> 2*Log2Dim);
1002 n &= ((1 << 2*Log2Dim) - 1);
1003 xyz.setY(n >> Log2Dim);
1004 xyz.setZ(n & ((1 << Log2Dim) - 1));
1009 template<Index Log2Dim>
1020 template<Index Log2Dim>
1024 mValueMask.
load(is);
1028 template<Index Log2Dim>
1032 mValueMask.
save(os);
1036 template<Index Log2Dim>
1046 bool background =
false;
1048 background = *
static_cast<const bool*
>(bgPtr);
1050 this->
clip(clipBBox, background);
1054 template<Index Log2Dim>
1059 mValueMask.
load(is);
1061 is.read(reinterpret_cast<char*>(&mOrigin),
sizeof(Coord::ValueType) * 3);
1065 mBuffer.
mData.load(is);
1070 int8_t numBuffers = 0;
1071 is.read(reinterpret_cast<char*>(&numBuffers),
sizeof(int8_t));
1075 boost::shared_array<bool> buf(
new bool[
SIZE]);
1076 io::readData<bool>(is, buf.get(),
SIZE,
true);
1079 mBuffer.
mData.setOff();
1081 if (buf[i]) mBuffer.
mData.setOn(i);
1084 if (numBuffers > 1) {
1087 for (
int i = 1; i < numBuffers; ++i) {
1088 io::readData<bool>(is, buf.get(),
SIZE,
true);
1095 template<Index Log2Dim>
1100 mValueMask.
save(os);
1102 os.write(reinterpret_cast<const char*>(&mOrigin),
sizeof(Coord::ValueType) * 3);
1104 mBuffer.
mData.save(os);
1111 template<Index Log2Dim>
1115 return mOrigin == other.mOrigin &&
1117 mBuffer == other.mBuffer;
1121 template<Index Log2Dim>
1132 template<Index Log2Dim>
1136 if (!mValueMask.
isConstant(state))
return false;
1139 if (!tolerance && !(mBuffer.
mData.isOn() || mBuffer.
mData.isOff()))
return false;
1141 constValue = mBuffer.
mData.isOn();
1149 template<Index Log2Dim>
1156 template<Index Log2Dim>
1160 assert(offset <
SIZE);
1165 template<Index Log2Dim>
1166 template<
typename AccessorT>
1169 bool val,
bool active, AccessorT&)
1171 this->
addTile(level, xyz, val, active);
1178 template<Index Log2Dim>
1183 if (mBuffer.
mData.isOn(this->coordToOffset(xyz)))
return sOn;
else return sOff;
1187 template<Index Log2Dim>
1191 assert(offset <
SIZE);
1193 if (mBuffer.
mData.isOn(offset))
return sOn;
else return sOff;
1197 template<Index Log2Dim>
1202 val = mBuffer.
mData.isOn(offset);
1203 return mValueMask.
isOn(offset);
1207 template<Index Log2Dim>
1215 template<Index Log2Dim>
1219 assert(offset <
SIZE);
1220 mValueMask.
setOn(offset);
1221 mBuffer.
mData.set(offset, val);
1225 template<Index Log2Dim>
1233 template<Index Log2Dim>
1241 template<Index Log2Dim>
1249 template<Index Log2Dim>
1253 assert(offset <
SIZE);
1254 mValueMask.
setOff(offset);
1255 mBuffer.
mData.set(offset, val);
1259 template<Index Log2Dim>
1260 template<
typename ModifyOp>
1264 bool val = mBuffer.
mData.isOn(offset);
1266 mBuffer.
mData.set(offset, val);
1267 mValueMask.
setOn(offset);
1271 template<Index Log2Dim>
1272 template<
typename ModifyOp>
1280 template<Index Log2Dim>
1281 template<
typename ModifyOp>
1286 bool val = mBuffer.
mData.isOn(offset), state = mValueMask.
isOn(offset);
1288 mBuffer.
mData.set(offset, val);
1289 mValueMask.
set(offset, state);
1296 template<Index Log2Dim>
1300 if (newBackground != oldBackground) {
1304 mBuffer.
mData = (mBuffer.
mData & mValueMask) | bgMask;
1312 template<Index Log2Dim>
1313 template<MergePolicy Policy>
1320 const Index n = iter.pos();
1321 if (mValueMask.
isOff(n)) {
1322 mBuffer.
mData.set(n, other.mBuffer.
mData.isOn(n));
1323 mValueMask.
setOn(n);
1329 template<Index Log2Dim>
1330 template<MergePolicy Policy>
1336 if (!tileActive)
return;
1338 if (tileValue) mBuffer.
mData |= !mValueMask;
1339 else mBuffer.
mData &= mValueMask;
1348 template<Index Log2Dim>
1349 template<
typename OtherType>
1357 template<Index Log2Dim>
1358 template<
typename OtherType>
1367 template<Index Log2Dim>
1368 template<
typename OtherType>
1380 template<Index Log2Dim>
1385 if (!clipBBox.hasOverlap(nodeBBox)) {
1387 this->
fill(nodeBBox, background,
false);
1388 }
else if (clipBBox.isInside(nodeBBox)) {
1398 nodeBBox.intersect(clipBBox);
1400 int &x = xyz.x(), &y = xyz.y(), &z = xyz.z();
1401 for (x = nodeBBox.min().x(); x <= nodeBBox.max().x(); ++x) {
1402 for (y = nodeBBox.min().y(); y <= nodeBBox.max().y(); ++y) {
1403 for (z = nodeBBox.min().z(); z <= nodeBBox.max().z(); ++z) {
1420 template<Index Log2Dim>
1424 for (
Int32 x = bbox.min().x(); x <= bbox.max().x(); ++x) {
1425 const Index offsetX = (x & (
DIM-1u))<<2*Log2Dim;
1426 for (
Int32 y = bbox.min().y(); y <= bbox.max().y(); ++y) {
1427 const Index offsetXY = offsetX + ((y & (
DIM-1u))<< Log2Dim);
1428 for (
Int32 z = bbox.min().z(); z <= bbox.max().z(); ++z) {
1429 const Index offset = offsetXY + (z & (
DIM-1u));
1430 mValueMask.
set(offset, active);
1431 mBuffer.
mData.set(offset, value);
1437 template<Index Log2Dim>
1441 mBuffer.
fill(value);
1444 template<Index Log2Dim>
1448 mBuffer.
fill(value);
1449 mValueMask.
set(active);
1456 template<Index Log2Dim>
1457 template<
typename DenseT>
1461 typedef typename DenseT::ValueType DenseValueType;
1463 const size_t xStride = dense.xStride(), yStride = dense.yStride(), zStride = dense.zStride();
1464 const Coord&
min = dense.bbox().min();
1465 DenseValueType* t0 = dense.data() + zStride * (bbox.min()[2] - min[2]);
1466 const Int32 n0 = bbox.min()[2] & (
DIM-1u);
1467 for (
Int32 x = bbox.min()[0], ex = bbox.max()[0] + 1; x < ex; ++x) {
1468 DenseValueType* t1 = t0 + xStride * (x - min[0]);
1470 for (
Int32 y = bbox.min()[1], ey = bbox.max()[1] + 1; y < ey; ++y) {
1471 DenseValueType* t2 = t1 + yStride * (y - min[1]);
1473 for (
Int32 z = bbox.min()[2], ez = bbox.max()[2] + 1; z < ez; ++z, t2 += zStride) {
1474 *t2 = DenseValueType(mBuffer.
mData.isOn(n2++));
1481 template<Index Log2Dim>
1482 template<
typename DenseT>
1485 bool background,
bool tolerance)
1487 typedef typename DenseT::ValueType DenseValueType;
1489 inline static bool toBool(
const DenseValueType& v) {
return !
math::isZero(v); }
1492 const size_t xStride = dense.xStride(), yStride = dense.yStride(), zStride = dense.zStride();
1493 const Coord&
min = dense.bbox().min();
1494 const DenseValueType* s0 = dense.data() + zStride * (bbox.min()[2] - min[2]);
1495 const Int32 n0 = bbox.min()[2] & (
DIM-1u);
1496 for (
Int32 x = bbox.min()[0], ex = bbox.max()[0] + 1; x < ex; ++x) {
1497 const DenseValueType* s1 = s0 + xStride * (x - min[0]);
1499 for (
Int32 y = bbox.min()[1], ey = bbox.max()[1] + 1; y < ey; ++y) {
1500 const DenseValueType* s2 = s1 + yStride * (y - min[1]);
1502 for (
Int32 z = bbox.min()[2], ez = bbox.max()[2]+1; z < ez; ++z, ++n2, s2 += zStride) {
1504 if (tolerance || (background == Local::toBool(*s2))) {
1505 mValueMask.setOff(n2);
1506 mBuffer.mData.set(n2, background);
1508 mValueMask.setOn(n2);
1509 mBuffer.mData.set(n2, Local::toBool(*s2));
1520 template<Index Log2Dim>
1521 template<
typename CombineOp>
1527 bool result =
false, aVal = mBuffer.mData.isOn(i), bVal = other.mBuffer.
mData.isOn(i);
1529 .setAIsActive(mValueMask.isOn(i))
1532 .setResultRef(result));
1534 mBuffer.mData.set(i, result);
1539 template<Index Log2Dim>
1540 template<
typename CombineOp>
1545 args.
setBRef(value).setBIsActive(valueIsActive);
1547 bool result =
false, aVal = mBuffer.mData.isOn(i);
1549 .setAIsActive(mValueMask.isOn(i))
1550 .setResultRef(result));
1552 mBuffer.mData.set(i, result);
1560 template<Index Log2Dim>
1561 template<
typename CombineOp,
typename OtherType>
1564 bool valueIsActive, CombineOp& op)
1567 args.
setBRef(value).setBIsActive(valueIsActive);
1569 bool result =
false, aVal = other.mBuffer.
mData.isOn(i);
1572 .setResultRef(result));
1574 mBuffer.mData.set(i, result);
1579 template<Index Log2Dim>
1580 template<
typename CombineOp,
typename OtherNodeT>
1583 bool valueIsActive, CombineOp& op)
1586 args.
setARef(value).setAIsActive(valueIsActive);
1588 bool result =
false, bVal = other.mBuffer.mData.isOn(i);
1590 .setBIsActive(other.valueMask().isOn(i))
1591 .setResultRef(result));
1593 mBuffer.mData.set(i, result);
1598 template<Index Log2Dim>
1599 template<
typename CombineOp,
typename OtherNodeT>
1606 mValueMask.set(i, b0.
valueMask().
isOn(i) || b1.valueMask().isOn(i));
1608 bool result =
false, b0Val = b0.mBuffer.
mData.isOn(i), b1Val = b1.mBuffer.mData.isOn(i);
1612 .setBIsActive(b1.valueMask().isOn(i))
1613 .setResultRef(result));
1615 mBuffer.mData.set(i, result);
1622 template<Index Log2Dim>
1623 template<
typename BBoxOp>
1627 if (op.template descent<LEVEL>()) {
1630 op.operator()<
LEVEL>(CoordBBox::createCube(i.getCoord(), 1));
1632 op.template operator()<
LEVEL>(CoordBBox::createCube(i.getCoord(), 1));
1645 template<Index Log2Dim>
1646 template<
typename VisitorOp>
1650 doVisit<LeafNode, VisitorOp, ChildAllIter>(*
this, op);
1654 template<Index Log2Dim>
1655 template<
typename VisitorOp>
1659 doVisit<const LeafNode, VisitorOp, ChildAllCIter>(*
this, op);
1663 template<Index Log2Dim>
1664 template<
typename NodeT,
typename VisitorOp,
typename ChildAllIterT>
1668 for (ChildAllIterT iter =
self.
beginChildAll(); iter; ++iter) {
1677 template<Index Log2Dim>
1678 template<
typename OtherLeafNodeType,
typename VisitorOp>
1683 typename OtherLeafNodeType::ChildAllIter>(*
this, other, op);
1687 template<Index Log2Dim>
1688 template<
typename OtherLeafNodeType,
typename VisitorOp>
1693 typename OtherLeafNodeType::ChildAllCIter>(*
this, other, op);
1697 template<Index Log2Dim>
1700 typename OtherNodeT,
1702 typename ChildAllIterT,
1703 typename OtherChildAllIterT>
1708 BOOST_STATIC_ASSERT(OtherNodeT::SIZE == NodeT::SIZE);
1709 BOOST_STATIC_ASSERT(OtherNodeT::LEVEL == NodeT::LEVEL);
1711 ChildAllIterT iter =
self.beginChildAll();
1712 OtherChildAllIterT otherIter = other.beginChildAll();
1714 for ( ; iter && otherIter; ++iter, ++otherIter) {
1715 op(iter, otherIter);
1723 template<Index Log2Dim>
1724 template<
typename IterT,
typename VisitorOp>
1728 doVisit2<LeafNode, VisitorOp, ChildAllIter, IterT>(*
this, otherIter, op, otherIsLHS);
1732 template<Index Log2Dim>
1733 template<
typename IterT,
typename VisitorOp>
1737 doVisit2<const LeafNode, VisitorOp, ChildAllCIter, IterT>(*
this, otherIter, op, otherIsLHS);
1741 template<Index Log2Dim>
1745 typename ChildAllIterT,
1746 typename OtherChildAllIterT>
1749 VisitorOp& op,
bool otherIsLHS)
1751 if (!otherIter)
return;
1754 for (ChildAllIterT iter =
self.
beginChildAll(); iter; ++iter) {
1755 op(otherIter, iter);
1758 for (ChildAllIterT iter =
self.
beginChildAll(); iter; ++iter) {
1759 op(iter, otherIter);
1768 #endif // OPENVDB_TREE_LEAF_NODE_BOOL_HAS_BEEN_INCLUDED NodeMaskType & getValueMask()
Definition: LeafNodeBool.h:756
bool isConstant(bool &isOn) const
Definition: NodeMasks.h:523
bool isChildMaskOff(Index) const
Definition: LeafNodeBool.h:759
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...
Definition: LeafNodeBool.h:461
Index64 onLeafVoxelCount() const
Definition: LeafNodeBool.h:199
bool isValueOn(const Coord &xyz) const
Return true if the voxel at the given coordinates is active.
Definition: LeafNodeBool.h:351
static bool hasActiveTiles()
Return false since leaf nodes never contain tiles.
Definition: LeafNodeBool.h:356
Index64 offVoxelCount() const
Return the number of inactive voxels.
Definition: LeafNodeBool.h:198
ValueIter()
Definition: LeafNodeBool.h:638
static const Index LEVEL
Definition: LeafNode.h:81
static Index32 nonLeafCount()
Definition: LeafNodeBool.h:193
ValueOnIter endValueOn()
Definition: LeafNodeBool.h:717
static Index coordToOffset(const Coord &xyz)
Return the linear table offset of the given global or local coordinates.
Definition: LeafNode.h:1276
void setValueOffAndCache(const Coord &xyz, bool value, AccessorT &)
Change the value of the voxel at the given coordinates and mark it as inactive.
Definition: LeafNodeBool.h:426
void stealNodes(ArrayT &, const ValueType &, bool)
This function exists only to enable template instantiation.
Definition: LeafNodeBool.h:579
const Coord & origin() const
Return the grid index coordinates of this node's local origin.
Definition: LeafNode.h:475
DenseIter< LeafNode, bool > ChildAllIter
Definition: LeafNodeBool.h:702
ValueOffCIter cendValueOff() const
Definition: LeafNodeBool.h:718
static Index32 leafCount()
Definition: LeafNodeBool.h:192
void modifyItem(Index n, const ModifyOp &op) const
Definition: LeafNodeBool.h:651
bool allocate()
Allocate memory for this node's buffer if it has not already been allocated.
Definition: LeafNodeBool.h:217
ChildOnCIter beginChildOn() const
Definition: LeafNodeBool.h:728
const NodeT * probeConstNodeAndCache(const Coord &, AccessorT &) const
Return a const pointer to this node.
Definition: LeafNodeBool.h:613
CoordBBox getNodeBoundingBox() const
Return the bounding box of this node, i.e., the full index space spanned by this leaf node...
Definition: LeafNode.h:469
static const bool sOn
Definition: LeafNodeBool.h:789
void addTile(Index level, const Coord &, const ValueType &, bool)
Definition: LeafNode.h:1792
bool operator!=(const Buffer &other) const
Definition: LeafNodeBool.h:108
NodeT * stealNode(const Coord &, const ValueType &, bool)
This function exists only to enable template instantiation.
Definition: LeafNodeBool.h:573
bool BuildType
Definition: LeafNodeBool.h:59
const NodeMaskType & valueMask() const
Definition: LeafNodeBool.h:755
void unsetItem(Index pos, const ValueT &val) const
Definition: LeafNodeBool.h:688
const NodeMaskType & getValueMask() const
Definition: LeafNode.h:1109
DenseIter()
Definition: LeafNodeBool.h:674
DenseIteratorBase< MaskDenseIter, DenseIter, NodeT, void, ValueT > BaseT
Definition: LeafNodeBool.h:671
bool operator==(const LeafNode &other) const
Check for buffer, state and origin equivalence.
Definition: LeafNode.h:1707
Coord offsetToGlobalCoord(Index n) const
Return the global coordinates for a linear table offset.
Definition: LeafNode.h:1300
void getOrigin(Coord &origin) const
Return the grid index coordinates of this node's local origin.
Definition: LeafNodeBool.h:237
Definition: version.h:104
static Index size()
Definition: LeafNodeBool.h:186
void load(std::istream &is)
Definition: NodeMasks.h:566
void setValueMaskOff(Index n)
Definition: LeafNodeBool.h:764
void setValueOn(const Coord &xyz)
Mark the voxel at the given coordinates as active but don't change its value.
Definition: LeafNode.h:714
void visit(VisitorOp &)
Definition: LeafNode.h:2068
static Coord offsetToLocalCoord(Index n)
Return the local coordinates for a linear table offset, where offset 0 has coordinates (0...
Definition: LeafNode.h:1286
bool isValueMaskOn(Index n) const
Definition: LeafNodeBool.h:750
ChildIter(const MaskIterT &iter, NodeT *parent)
Definition: LeafNodeBool.h:663
ChildOnCIter endChildOn() const
Definition: LeafNodeBool.h:738
void setValueMaskOn(Index n)
Definition: LeafNodeBool.h:763
CombineArgs & setARef(const AValueType &a)
Redirect the A value to a new external source.
Definition: Types.h:365
void setValueOnly(Index offset, bool val)
Set the value of the voxel at the given offset but don't change its active state. ...
Definition: LeafNodeBool.h:308
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.
Definition: LeafNode.h:1914
static void getNodeLog2Dims(std::vector< Index > &dims)
Definition: LeafNodeBool.h:189
const bool & getFirstValue() const
Return a const reference to the first entry in the buffer.
Definition: LeafNodeBool.h:474
static const bool sOff
Definition: LeafNodeBool.h:790
ChildOnCIter cendChildOn() const
Definition: LeafNodeBool.h:737
void setItem(Index pos, bool value) const
Definition: LeafNodeBool.h:645
void setValueOnlyAndCache(const Coord &xyz, bool val, AccessorT &)
Change the value of the voxel at the given coordinates but preserve its state.
Definition: LeafNodeBool.h:421
bool isZero(const Type &x)
Return true if x is exactly equal to zero.
Definition: Math.h:324
ValueOnCIter endValueOn() const
Definition: LeafNodeBool.h:716
bool isConstant(ValueType &firstValue, bool &state, const ValueType &tolerance=zeroVal< ValueType >()) const
Definition: LeafNode.h:1753
bool isValueMaskOff() const
Definition: LeafNodeBool.h:753
void modifyValue(Index offset, const ModifyOp &op)
Apply a functor to the value of the voxel at the given offset and mark the voxel as active...
Definition: LeafNode.h:732
void readBuffers(std::istream &is, bool fromHalf=false)
Read buffers from a stream.
Definition: LeafNode.h:1598
Definition: PointIndexGrid.h:69
DenseIter< const LeafNode, const ValueType, ChildAll > ChildAllCIter
Definition: LeafNode.h:592
static Index dim()
Return the number of voxels in each dimension.
Definition: LeafNodeBool.h:185
const NodeMaskType & getValueMask() const
Definition: LeafNodeBool.h:754
bool operator!=(const LeafNode &other) const
Definition: LeafNode.h:498
ChildAllCIter endChildAll() const
Definition: LeafNodeBool.h:744
static Index64 onTileCount()
Definition: LeafNodeBool.h:201
void visitActiveBBox(BBoxOp &) const
Calls the templated functor BBoxOp with bounding box information. An additional level argument is pro...
Definition: LeafNode.h:2045
ValueIter< MaskOnIter, LeafNode, const bool > ValueOnIter
Definition: LeafNodeBool.h:692
util::NodeMask< Log2Dim > NodeMaskType
Definition: LeafNodeBool.h:61
void setValueAndCache(const Coord &xyz, bool val, AccessorT &)
Change the value of the voxel at the given coordinates and mark it as active.
Definition: LeafNodeBool.h:415
ChildOnCIter cbeginChildOn() const
Definition: LeafNodeBool.h:727
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 setActiveStateAndCache(const Coord &xyz, bool on, AccessorT &)
Set the active state of the voxel at the given coordinates without changing its value.
Definition: LeafNodeBool.h:452
NodeMaskType::DenseIterator MaskDenseIter
Definition: LeafNodeBool.h:628
static Index getChildDim()
Definition: LeafNodeBool.h:190
const bool & getValue(Index i) const
Definition: LeafNodeBool.h:98
NodeT * probeNode(const Coord &)
This function exists only to enable template instantiation.
Definition: LeafNodeBool.h:575
ValueAllIter endValueAll()
Definition: LeafNodeBool.h:723
ValueAllCIter cbeginValueAll() const
Definition: LeafNodeBool.h:711
const WordType * data() const
Definition: LeafNodeBool.h:128
boost::shared_ptr< LeafNodeType > Ptr
Definition: LeafNodeBool.h:58
ValueType * mData
Definition: LeafNode.h:361
DenseIter< const LeafNode, const bool > ChildAllCIter
Definition: LeafNodeBool.h:703
static Index numValues()
Definition: LeafNodeBool.h:187
OffIterator beginOff() const
Definition: NodeMasks.h:351
LeafNode< bool, Log2Dim > LeafNodeType
Definition: LeafNodeBool.h:57
void resetBackground(const ValueType &oldBackground, const ValueType &newBackground)
Replace inactive occurrences of oldBackground with newBackground, and inactive occurrences of -oldBac...
Definition: LeafNode.h:1821
Index32 Index
Definition: Types.h:58
ValueIter< MaskDenseIter, LeafNode, const bool > ValueAllIter
Definition: LeafNodeBool.h:696
ChildOffCIter beginChildOff() const
Definition: LeafNodeBool.h:731
NodeT * probeNodeAndCache(const Coord &, AccessorT &)
Return a pointer to this node.
Definition: LeafNodeBool.h:596
ChildAllCIter beginChildAll() const
Definition: LeafNode.h:623
ChildIter< MaskOnIter, const LeafNode > ChildOnCIter
Definition: LeafNodeBool.h:699
ValueAllCIter endValueAll() const
Definition: LeafNodeBool.h:722
bool hasSameTopology(const LeafNode< OtherType, OtherLog2Dim > *other) const
Return true if the given node (which may have a different ValueType than this node) has the same acti...
Definition: LeafNode.h:1745
int32_t Int32
Definition: Types.h:60
ChildAllIter beginChildAll()
Definition: LeafNodeBool.h:735
bool isValueOn(Index offset) const
Return true if the voxel at the given offset is active.
Definition: LeafNodeBool.h:353
void combine2(const LeafNode &other, const OtherType &, bool valueIsActive, CombineOp &)
Definition: LeafNode.h:1981
uint64_t Index64
Definition: Types.h:57
void fill(const ValueType &val)
Populate this buffer with a constant value.
Definition: LeafNode.h:171
ChildOffCIter cendChildOff() const
Definition: LeafNodeBool.h:740
#define OPENVDB_VERSION_NAME
Definition: version.h:43
ValueOnCIter cendValueOn() const
Definition: LeafNodeBool.h:715
bool getItem(Index pos, void *&child, NonConstValueT &value) const
Definition: LeafNodeBool.h:677
bool isOn(Index32 n) const
Return true if the nth bit is on.
Definition: NodeMasks.h:499
WordType * data()
Definition: LeafNodeBool.h:120
Buffer()
Definition: LeafNodeBool.h:90
NodeMaskType::Word WordType
Definition: LeafNodeBool.h:88
void clip(const CoordBBox &, const ValueType &background)
Set all voxels that lie outside the given axis-aligned box to the background.
Definition: LeafNode.h:1387
const bool & getValue() const
Definition: LeafNodeBool.h:642
Buffer mBuffer
Bitmask representing the values of voxels.
Definition: LeafNodeBool.h:784
void fill(bool val)
Definition: LeafNodeBool.h:95
LeafNode * touchLeafAndCache(const Coord &, AccessorT &)
Return a pointer to this node.
Definition: LeafNodeBool.h:591
void swap(Buffer &other)
Definition: LeafNodeBool.h:112
void setValuesOff()
Mark all voxels as inactive but don't change their values.
Definition: LeafNodeBool.h:348
Index64 onVoxelCount() const
Return the number of active voxels.
Definition: LeafNodeBool.h:196
bool isValueMaskOff(Index n) const
Definition: LeafNodeBool.h:752
Templated block class to hold specific data types and a fixed number of values determined by Log2Dim...
Definition: LeafNode.h:65
void visit2Node(OtherLeafNodeType &other, VisitorOp &)
Definition: LeafNode.h:2100
ValueOffIter endValueOff()
Definition: LeafNodeBool.h:720
void setActiveState(const Coord &xyz, bool on)
Set the active state of the voxel at the given coordinates but don't change its value.
Definition: LeafNode.h:1361
OPENVDB_API uint32_t getFormatVersion(std::ios_base &)
Return the file format version number associated with the given input stream.
CoordBBox getNodeBoundingBox() const
Return the bounding box of this node, i.e., the full index space spanned by this leaf node...
Definition: LeafNodeBool.h:230
ValueAllCIter beginValueAll() const
Definition: LeafNodeBool.h:712
Bit mask for the internal and leaf nodes of VDB. This is a 64-bit implementation. ...
Definition: NodeMasks.h:304
void addTileAndCache(Index, const Coord &, const ValueType &, bool, AccessorT &)
Definition: LeafNode.h:1809
~LeafNode()
Destructor.
Definition: LeafNode.h:1256
const bool & getLastValue() const
Return a const reference to the last entry in the buffer.
Definition: LeafNodeBool.h:478
bool isInactive() const
Return true if all of this node's values are inactive.
Definition: LeafNodeBool.h:485
void setValue(bool value) const
Definition: LeafNodeBool.h:647
NodeMaskType::OnIterator MaskOnIter
Definition: LeafNodeBool.h:626
void readTopology(std::istream &is, bool fromHalf=false)
Read in just the topology.
Definition: LeafNode.h:1536
Definition: Exceptions.h:39
void topologyUnion(const LeafNode< OtherType, Log2Dim > &other)
Union this node's set of active values with the active values of the other node, whose ValueType may ...
Definition: LeafNode.h:1897
uint32_t Index32
Definition: Types.h:56
std::string str() const
Return a string representation of this node.
Definition: LeafNode.h:1263
ChildIter< MaskOnIter, LeafNode > ChildOnIter
Definition: LeafNodeBool.h:698
ValueIter< MaskOnIter, const LeafNode, const bool > ValueOnCIter
Definition: LeafNodeBool.h:693
const NodeT * probeConstNode(const Coord &) const
This function exists only to enable template instantiation.
Definition: LeafNodeBool.h:577
bool ValueType
Definition: LeafNodeBool.h:60
Index memUsage() const
Definition: LeafNodeBool.h:114
void getOrigin(Int32 &x, Int32 &y, Int32 &z) const
Return the grid index coordinates of this node's local origin.
Definition: LeafNodeBool.h:238
Index64 Word
Definition: NodeMasks.h:313
static Index64 offTileCount()
Definition: LeafNodeBool.h:202
Base class for dense iterators over internal and leaf nodes.
Definition: Iterator.h:211
static Index size()
Definition: LeafNodeBool.h:115
bool isDense() const
Return true if this node only contains active voxels.
Definition: LeafNodeBool.h:207
Base class for sparse iterators over internal and leaf nodes.
Definition: Iterator.h:148
const ValueType & getValue(const Coord &xyz) const
Return the value of the voxel at the given coordinates.
Definition: LeafNode.h:1311
boost::remove_const< UnsetItemT >::type NonConstValueType
Definition: Iterator.h:217
static Index getLevel()
Definition: LeafNodeBool.h:188
void set(Index32 n, bool On)
Set the nth bit to the specified state.
Definition: NodeMasks.h:459
ValueIter< MaskOffIter, LeafNode, const bool > ValueOffIter
Definition: LeafNodeBool.h:694
static void doVisit2(NodeT &self, OtherChildAllIterT &, VisitorOp &, bool otherIsLHS)
Definition: LeafNode.h:2170
ValueAllCIter cendValueAll() const
Definition: LeafNodeBool.h:721
void addLeaf(LeafNode *)
This function exists only to enable template instantiation.
Definition: LeafNodeBool.h:569
ChildAllCIter cendChildAll() const
Definition: LeafNodeBool.h:743
bool isOff(Index32 n) const
Return true if the nth bit is off.
Definition: NodeMasks.h:505
ValueOnCIter cbeginValueOn() const
Definition: LeafNode.h:594
void setValuesOn()
Mark all voxels as active but don't change their values.
Definition: LeafNodeBool.h:346
LeafNode * probeLeafAndCache(const Coord &, AccessorT &)
Return a pointer to this node.
Definition: LeafNodeBool.h:594
void negate()
Definition: LeafNodeBool.h:489
Buffer & operator=(const Buffer &b)
Definition: LeafNodeBool.h:96
Definition: NodeMasks.h:267
bool probeValue(const Coord &xyz, ValueType &val) const
Return true if the voxel at the given coordinates is active.
Definition: LeafNode.h:1327
static const Index SIZE
Definition: LeafNode.h:80
ChildOffCIter cbeginChildOff() const
Definition: LeafNodeBool.h:730
void setValueMask(const NodeMaskType &mask)
Definition: LeafNodeBool.h:757
ChildAllIter endChildAll()
Definition: LeafNodeBool.h:745
const bool & operator[](Index i) const
Definition: LeafNodeBool.h:105
void setOn(Index32 n)
Set the nth bit on.
Definition: NodeMasks.h:449
ValueOffCIter cbeginValueOff() const
Definition: LeafNodeBool.h:708
void combine(const LeafNode &other, CombineOp &op)
Definition: LeafNode.h:1939
void setOrigin(const Coord &origin)
Set the grid index coordinates of this node's local origin.
Definition: LeafNodeBool.h:233
bool isEmpty() const
Return true if this node has no active voxels.
Definition: LeafNodeBool.h:205
ChildAllCIter cbeginChildAll() const
Definition: LeafNodeBool.h:733
void setValueOff(const Coord &xyz)
Mark the voxel at the given coordinates as inactive but don't change its value.
Definition: LeafNodeBool.h:311
Index64 memUsage() const
Return the memory in bytes occupied by this node.
Definition: LeafNode.h:1717
ChildIter< MaskOffIter, const LeafNode > ChildOffCIter
Definition: LeafNodeBool.h:701
ChildOffIter endChildOff()
Definition: LeafNodeBool.h:742
void copyToDense(const CoordBBox &bbox, DenseT &dense) const
Copy into a dense grid the values of the voxels that lie within a given bounding box.
Definition: LeafNode.h:1468
Buffer(const NodeMaskType &other)
Definition: LeafNodeBool.h:92
void modifyValue(const ModifyOp &op) const
Definition: LeafNodeBool.h:654
static void doVisit2Node(NodeT &self, OtherNodeT &other, VisitorOp &)
Definition: LeafNode.h:2125
ValueOnCIter cbeginValueOn() const
Definition: LeafNodeBool.h:705
bool operator==(const Vec3< T0 > &v0, const Vec3< T1 > &v1)
Equality operator, does exact floating point comparisons.
Definition: Vec3.h:450
LeafNode()
Default constructor.
Definition: LeafNode.h:1170
ValueOffIter beginValueOff()
Definition: LeafNodeBool.h:710
ValueIter(const MaskIterT &iter, NodeT *parent)
Definition: LeafNodeBool.h:639
void modifyValueAndCache(const Coord &xyz, const ModifyOp &op, AccessorT &)
Apply a functor to the value of the voxel at the given coordinates and mark the voxel as active...
Definition: LeafNodeBool.h:435
Buffer(bool on)
Definition: LeafNodeBool.h:91
ValueOffCIter endValueOff() const
Definition: LeafNodeBool.h:719
ChildAllCIter beginChildAll() const
Definition: LeafNodeBool.h:734
OnIterator beginOn() const
Definition: NodeMasks.h:349
BaseT::NonConstValueType NonConstValueT
Definition: LeafNodeBool.h:672
CombineArgs & setBRef(const BValueType &b)
Redirect the B value to a new external source.
Definition: Types.h:367
void setValueOnly(const Coord &xyz, const ValueType &val)
Set the value of the voxel at the given coordinates but don't change its active state.
Definition: LeafNode.h:1369
ChildOnIter endChildOn()
Definition: LeafNodeBool.h:739
static const Index LOG2DIM
Definition: LeafNode.h:75
void voxelizeActiveTiles(bool=true)
No-op.
Definition: LeafNodeBool.h:497
void setOff(Index32 n)
Set the nth bit off.
Definition: NodeMasks.h:454
LeafNode specialization for values of type bool that stores both the active states and the values of ...
Definition: LeafNodeBool.h:54
bool isValueOnAndCache(const Coord &xyz, AccessorT &) const
Return true if the voxel at the given coordinates is active.
Definition: LeafNodeBool.h:410
void evalActiveBoundingBox(CoordBBox &bbox, bool visitVoxels=true) const
Definition: LeafNode.h:1727
Index64 offLeafVoxelCount() const
Definition: LeafNodeBool.h:200
ChildOnIter beginChildOn()
Definition: LeafNodeBool.h:729
bool isChildMaskOff() const
Definition: LeafNodeBool.h:760
const NodeMaskType & valueMask() const
Definition: LeafNode.h:1111
DenseIter(const MaskDenseIter &iter, NodeT *parent)
Definition: LeafNodeBool.h:675
DenseIter< LeafNode, ValueType, ChildAll > ChildAllIter
Definition: LeafNode.h:591
void modifyValueAndActiveStateAndCache(const Coord &xyz, const ModifyOp &op, AccessorT &)
Definition: LeafNodeBool.h:443
NodeMaskType::OffIterator MaskOffIter
Definition: LeafNodeBool.h:627
Buffer(const Buffer &other)
Definition: LeafNodeBool.h:93
bool operator!=(const Vec3< T0 > &v0, const Vec3< T1 > &v1)
Inequality operator, does exact floating point comparisons.
Definition: Vec3.h:458
void addLeafAndCache(LeafNode *, AccessorT &)
This function exists only to enable template instantiation.
Definition: LeafNodeBool.h:571
void copyFromDense(const CoordBBox &bbox, const DenseT &dense, const ValueType &background, const ValueType &tolerance)
Copy from a dense grid into this node the values of the voxels that lie within a given bounding box...
Definition: LeafNode.h:1497
const bool & getValueAndCache(const Coord &xyz, AccessorT &) const
Return the value of the voxel at the given coordinates.
Definition: LeafNodeBool.h:405
void setActiveState(Index offset, bool on)
Set the active state of the voxel at the given offset but don't change its value. ...
Definition: LeafNodeBool.h:303
void setValueOn(Index offset)
Mark the voxel at the given offset as active but don't change its value.
Definition: LeafNodeBool.h:323
bool isChildMaskOn(Index) const
Definition: LeafNodeBool.h:758
ValueOnIter beginValueOn()
Definition: LeafNodeBool.h:707
SparseIteratorBase< MaskIterT, ValueIter, NodeT, ValueT > BaseT
Definition: LeafNodeBool.h:636
~Buffer()
Definition: LeafNodeBool.h:94
Definition: NodeMasks.h:205
ValueOnCIter beginValueOn() const
Definition: LeafNodeBool.h:706
Definition: NodeMasks.h:236
bool operator==(const Buffer &other) const
Definition: LeafNodeBool.h:107
void setValueOn(const Coord &xyz)
Mark the voxel at the given coordinates as active but don't change its value.
Definition: LeafNodeBool.h:321
ChildIter< MaskOffIter, LeafNode > ChildOffIter
Definition: LeafNodeBool.h:700
LeafNode * probeLeaf(const Coord &)
Return a pointer to this node.
Definition: LeafNodeBool.h:592
static void doVisit(NodeT &, VisitorOp &)
Definition: LeafNode.h:2086
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h:71
void setValueOff(Index offset)
Mark the voxel at the given offset as inactive but don't change its value.
Definition: LeafNodeBool.h:313
Buffer & buffer()
Definition: LeafNodeBool.h:268
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.
Definition: LeafNode.h:1905
void save(std::ostream &os) const
Definition: NodeMasks.h:562
void setValue(const Coord &xyz, bool val)
Set the value of the voxel at the given coordinates and mark the voxel as active. ...
Definition: LeafNodeBool.h:328
static void evalNodeOrigin(Coord &xyz)
Compute the origin of the leaf node that contains the voxel with the given coordinates.
Definition: LeafNodeBool.h:767
void merge(const LeafNode &)
Definition: LeafNode.h:1844
void setValue(Index i, bool val)
Definition: LeafNodeBool.h:110
ValueIter< MaskOffIter, const LeafNode, const bool > ValueOffCIter
Definition: LeafNodeBool.h:695
void modifyValueAndActiveState(const Coord &xyz, const ModifyOp &op)
Apply a functor to the voxel at the given coordinates.
Definition: LeafNode.h:749
LeafNode< ValueType, Log2Dim > Type
Definition: LeafNodeBool.h:75
ValueIter< MaskDenseIter, const LeafNode, const bool > ValueAllCIter
Definition: LeafNodeBool.h:697
bool isValueMaskOn() const
Definition: LeafNodeBool.h:751
Coord mOrigin
Global grid index coordinates (x,y,z) of the local origin of this node.
Definition: LeafNodeBool.h:786
void visit2(IterT &otherIter, VisitorOp &, bool otherIsLHS=false)
Definition: LeafNode.h:2146
void fill(const CoordBBox &bbox, const ValueType &, bool active=true)
Set all voxels within an axis-aligned box to the specified value and active state.
Definition: LeafNode.h:1427
const Buffer & buffer() const
Definition: LeafNodeBool.h:267
void setValueOff(const Coord &xyz)
Mark the voxel at the given coordinates as inactive but don't change its value.
Definition: LeafNode.h:704
ValueOffCIter beginValueOff() const
Definition: LeafNodeBool.h:709
static Index log2dim()
Return log2 of the size of the buffer storage.
Definition: LeafNodeBool.h:183
ChildOffIter beginChildOff()
Definition: LeafNodeBool.h:732
void swap(Buffer &other)
Exchange this node's data buffer with the given data buffer without changing the active states of the...
Definition: LeafNodeBool.h:266
NodeMaskType mValueMask
Bitmask that determines which voxels are active.
Definition: LeafNodeBool.h:782
void writeTopology(std::ostream &os, bool toHalf=false) const
Write out just the topology.
Definition: LeafNode.h:1544
This struct collects both input and output arguments to "grid combiner" functors used with the tree::...
Definition: Types.h:312
bool resultIsActive() const
Definition: Types.h:376
void writeBuffers(std::ostream &os, bool toHalf=false) const
Write buffers to a stream.
Definition: LeafNode.h:1690
const LeafNode * probeLeafAndCache(const Coord &, AccessorT &) const
Return a const pointer to this node.
Definition: LeafNodeBool.h:608
ChildOffCIter endChildOff() const
Definition: LeafNodeBool.h:741
ValueAllIter beginValueAll()
Definition: LeafNodeBool.h:713
ChildIter()
Definition: LeafNodeBool.h:662
void setValueMask(Index n, bool on)
Definition: LeafNodeBool.h:762
const LeafNode * probeConstLeaf(const Coord &) const
Return a const pointer to this node.
Definition: LeafNodeBool.h:609
static const Index DIM
Definition: LeafNode.h:77
const bool & getItem(Index pos) const
Definition: LeafNodeBool.h:641
const LeafNode * probeConstLeafAndCache(const Coord &, AccessorT &) const
Return a const pointer to this node.
Definition: LeafNodeBool.h:611
void getNodes(ArrayT &) const
This function exists only to enable template instantiation.
Definition: LeafNodeBool.h:578
Base class for iterators over internal and leaf nodes.
Definition: Iterator.h:58
static Index getValueLevelAndCache(const Coord &, AccessorT &)
Return the LEVEL (=0) at which leaf node values reside.
Definition: LeafNodeBool.h:469
static Index getValueLevel(const Coord &)
Return the level (0) at which leaf node values reside.
Definition: LeafNodeBool.h:298