31 #ifndef OPENVDB_TREE_LEAFNODEBOOL_HAS_BEEN_INCLUDED
32 #define OPENVDB_TREE_LEAFNODEBOOL_HAS_BEEN_INCLUDED
35 #include <boost/shared_ptr.hpp>
36 #include <boost/shared_array.hpp>
37 #include <boost/static_assert.hpp>
53 template<Index Log2Dim>
58 typedef boost::shared_ptr<LeafNodeType>
Ptr;
63 static const Index LOG2DIM = Log2Dim;
64 static const Index TOTAL = Log2Dim;
65 static const Index DIM = 1 << TOTAL;
66 static const Index NUM_VALUES = 1 << 3 * Log2Dim;
67 static const Index NUM_VOXELS = NUM_VALUES;
68 static const Index SIZE = NUM_VALUES;
73 template<
typename ValueType>
78 template<
typename OtherNodeType>
79 struct SameConfiguration {
88 static const Index WORD_COUNT = NodeMaskType::WORD_COUNT;
91 Buffer(
const NodeMaskType& other): mData(other) {}
92 Buffer(
const Buffer& other): mData(other.mData) {}
94 void fill(
bool val) { mData.set(val); }
95 Buffer&
operator=(
const Buffer& b) {
if (&b !=
this) { mData = b.mData; }
return *
this; }
102 if (mData.isOn(i))
return LeafNode::sOn;
else return LeafNode::sOff;
106 bool operator==(
const Buffer& other)
const {
return mData == other.mData; }
107 bool operator!=(
const Buffer& other)
const {
return mData != other.mData; }
111 void swap(Buffer& other) {
if (&other !=
this) std::swap(mData, other.mData); }
121 return &(mData.template getWord<WordType>(0));
129 return const_cast<Buffer*
>(
this)->data();
133 friend class ::TestLeaf;
148 explicit LeafNode(
const Coord& xyz,
bool value =
false,
bool active =
false);
150 #ifndef OPENVDB_2_ABI_COMPATIBLE
159 template<
typename OtherValueType>
163 template<
typename ValueType>
167 template<
typename ValueType>
171 template<
typename ValueType>
204 bool isEmpty()
const {
return mValueMask.isOff(); }
206 bool isDense()
const {
return mValueMask.isOn(); }
208 #ifndef OPENVDB_2_ABI_COMPATIBLE
209 bool isAllocated()
const {
return true; }
225 void evalActiveBoundingBox(CoordBBox& bbox,
bool visitVoxels =
true)
const;
232 void setOrigin(
const Coord& origin) { mOrigin = origin; }
234 const Coord& origin()
const {
return mOrigin; }
236 void getOrigin(Coord& origin)
const { origin = mOrigin; }
241 static Index coordToOffset(
const Coord& xyz);
244 static Coord offsetToLocalCoord(
Index n);
246 Coord offsetToGlobalCoord(
Index n)
const;
249 std::string str()
const;
253 template<
typename OtherType, Index OtherLog2Dim>
265 void swap(Buffer& other) { mBuffer.swap(other); }
266 const Buffer&
buffer()
const {
return mBuffer; }
273 void readTopology(std::istream&,
bool fromHalf =
false);
275 void writeTopology(std::ostream&,
bool toHalf =
false)
const;
278 void readBuffers(std::istream&,
bool fromHalf =
false);
279 void readBuffers(std::istream& is,
const CoordBBox&,
bool fromHalf =
false);
281 void writeBuffers(std::ostream&,
bool toHalf =
false)
const;
287 const bool& getValue(
const Coord& xyz)
const;
289 const bool& getValue(
Index offset)
const;
294 bool probeValue(
const Coord& xyz,
bool& val)
const;
300 void setActiveState(
const Coord& xyz,
bool on);
305 void setValueOnly(
const Coord& xyz,
bool val);
307 void setValueOnly(
Index offset,
bool val) { assert(offset<SIZE); mBuffer.setValue(offset,val); }
310 void setValueOff(
const Coord& xyz) { mValueMask.setOff(this->coordToOffset(xyz)); }
315 void setValueOff(
const Coord& xyz,
bool val);
317 void setValueOff(
Index offset,
bool val);
320 void setValueOn(
const Coord& xyz) { mValueMask.setOn(this->coordToOffset(xyz)); }
325 void setValueOn(
const Coord& xyz,
bool val);
327 void setValue(
const Coord& xyz,
bool val) { this->setValueOn(xyz, val); }
329 void setValueOn(
Index offset,
bool val);
333 template<
typename ModifyOp>
334 void modifyValue(
Index offset,
const ModifyOp& op);
337 template<
typename ModifyOp>
338 void modifyValue(
const Coord& xyz,
const ModifyOp& op);
341 template<
typename ModifyOp>
342 void modifyValueAndActiveState(
const Coord& xyz,
const ModifyOp& op);
350 bool isValueOn(
const Coord& xyz)
const {
return mValueMask.isOn(this->coordToOffset(xyz)); }
352 bool isValueOn(
Index offset)
const { assert(offset < SIZE);
return mValueMask.isOn(offset); }
358 void clip(
const CoordBBox&,
bool background);
361 void fill(
const CoordBBox& bbox,
bool value,
bool active =
true);
364 void fill(
const bool& value);
366 void fill(
const bool& value,
bool active);
379 template<
typename DenseT>
380 void copyToDense(
const CoordBBox& bbox, DenseT& dense)
const;
398 template<
typename DenseT>
399 void copyFromDense(
const CoordBBox& bbox,
const DenseT& dense,
bool background,
bool tolerance);
403 template<
typename AccessorT>
404 const bool&
getValueAndCache(
const Coord& xyz, AccessorT&)
const {
return this->getValue(xyz);}
408 template<
typename AccessorT>
413 template<
typename AccessorT>
414 void setValueAndCache(
const Coord& xyz,
bool val, AccessorT&) { this->setValueOn(xyz, val); }
419 template<
typename AccessorT>
424 template<
typename AccessorT>
427 this->setValueOff(xyz, value);
433 template<
typename ModifyOp,
typename AccessorT>
436 this->modifyValue(xyz, op);
441 template<
typename ModifyOp,
typename AccessorT>
444 this->modifyValueAndActiveState(xyz, op);
450 template<
typename AccessorT>
453 this->setActiveState(xyz, on);
459 template<
typename AccessorT>
462 return this->probeValue(xyz, val);
467 template<
typename AccessorT>
473 const bool&
getFirstValue()
const {
if (mValueMask.isOn(0))
return sOn;
else return sOff; }
477 const bool&
getLastValue()
const {
if (mValueMask.isOn(SIZE-1))
return sOn;
else return sOff; }
482 bool isConstant(
bool& constValue,
bool& state,
bool tolerance = 0)
const;
486 void resetBackground(
bool oldBackground,
bool newBackground);
488 void negate() { mBuffer.mData.toggle(); }
490 template<MergePolicy Policy>
491 void merge(
const LeafNode& other,
bool bg =
false,
bool otherBG =
false);
492 template<MergePolicy Policy>
void merge(
bool tileValue,
bool tileActive);
502 template<
typename OtherType>
516 template<
typename OtherType>
530 template<
typename OtherType>
533 template<
typename CombineOp>
534 void combine(
const LeafNode& other, CombineOp& op);
535 template<
typename CombineOp>
536 void combine(
bool,
bool valueIsActive, CombineOp& op);
538 template<
typename CombineOp,
typename OtherType >
539 void combine2(
const LeafNode& other,
const OtherType&,
bool valueIsActive, CombineOp&);
540 template<
typename CombineOp,
typename OtherNodeT >
541 void combine2(
bool,
const OtherNodeT& other,
bool valueIsActive, CombineOp&);
542 template<
typename CombineOp,
typename OtherNodeT >
543 void combine2(
const LeafNode& b0,
const OtherNodeT& b1, CombineOp&);
549 template<
typename BBoxOp>
void visitActiveBBox(BBoxOp&)
const;
551 template<
typename VisitorOp>
void visit(VisitorOp&);
552 template<
typename VisitorOp>
void visit(VisitorOp&)
const;
554 template<
typename OtherLeafNodeType,
typename VisitorOp>
555 void visit2Node(OtherLeafNodeType& other, VisitorOp&);
556 template<
typename OtherLeafNodeType,
typename VisitorOp>
557 void visit2Node(OtherLeafNodeType& other, VisitorOp&)
const;
558 template<
typename IterT,
typename VisitorOp>
559 void visit2(IterT& otherIter, VisitorOp&,
bool otherIsLHS =
false);
560 template<
typename IterT,
typename VisitorOp>
561 void visit2(IterT& otherIter, VisitorOp&,
bool otherIsLHS =
false)
const;
564 void prune(
const ValueType& = zeroVal<ValueType>()) {}
567 template<
typename AccessorT>
569 template<
typename NodeT>
570 NodeT*
stealNode(
const Coord&,
const ValueType&,
bool) {
return NULL; }
571 template<
typename NodeT>
573 template<
typename NodeT>
575 template<
typename ArrayT>
void getNodes(ArrayT&)
const {}
576 template<
typename ArrayT>
void stealNodes(ArrayT&,
const ValueType&,
bool) {}
579 void addTile(
Index level,
const Coord&,
bool val,
bool active);
580 void addTile(
Index offset,
bool val,
bool active);
581 template<
typename AccessorT>
582 void addTileAndCache(
Index level,
const Coord&,
bool val,
bool active, AccessorT&);
585 LeafNode* touchLeaf(
const Coord&) {
return this; }
587 template<
typename AccessorT>
590 template<
typename AccessorT>
592 template<
typename NodeT,
typename AccessorT>
596 if (!(boost::is_same<NodeT,LeafNode>::value))
return NULL;
597 return reinterpret_cast<NodeT*
>(
this);
602 const LeafNode* probeLeaf(
const Coord&)
const {
return this; }
604 template<
typename AccessorT>
607 template<
typename AccessorT>
609 template<
typename NodeT,
typename AccessorT>
613 if (!(boost::is_same<NodeT,LeafNode>::value))
return NULL;
614 return reinterpret_cast<const NodeT*
>(
this);
627 template<
typename MaskIterT,
typename NodeT,
typename ValueT>
631 public SparseIteratorBase<MaskIterT, ValueIter<MaskIterT, NodeT, ValueT>, NodeT, ValueT>
636 ValueIter(
const MaskIterT& iter, NodeT* parent): BaseT(iter, parent) {}
638 const bool&
getItem(
Index pos)
const {
return this->parent().getValue(pos); }
639 const bool&
getValue()
const {
return this->getItem(this->pos()); }
642 void setItem(
Index pos,
bool value)
const { this->parent().setValueOnly(pos, value); }
644 void setValue(
bool value)
const { this->setItem(this->pos(), value); }
647 template<
typename ModifyOp>
648 void modifyItem(
Index n,
const ModifyOp& op)
const { this->parent().modifyValue(n, op); }
650 template<
typename ModifyOp>
651 void modifyValue(
const ModifyOp& op)
const { this->modifyItem(this->pos(), op); }
655 template<
typename MaskIterT,
typename NodeT>
661 MaskIterT, ChildIter<MaskIterT, NodeT>, NodeT, bool>(iter, parent) {}
664 template<
typename NodeT,
typename ValueT>
666 MaskDenseIter, DenseIter<NodeT, ValueT>, NodeT, void, ValueT>
672 DenseIter(
const MaskDenseIter& iter, NodeT* parent): BaseT(iter, parent) {}
676 value = this->parent().getValue(pos);
685 void unsetItem(
Index pos,
const ValueT& val)
const {this->parent().setValueOnly(pos, val);}
690 typedef ValueIter<MaskOnIter, const LeafNode, const bool>
ValueOnCIter;
702 ValueOnCIter
cbeginValueOn()
const {
return ValueOnCIter(mValueMask.beginOn(),
this); }
703 ValueOnCIter
beginValueOn()
const {
return ValueOnCIter(mValueMask.beginOn(),
this); }
704 ValueOnIter
beginValueOn() {
return ValueOnIter(mValueMask.beginOn(),
this); }
705 ValueOffCIter
cbeginValueOff()
const {
return ValueOffCIter(mValueMask.beginOff(),
this); }
706 ValueOffCIter
beginValueOff()
const {
return ValueOffCIter(mValueMask.beginOff(),
this); }
707 ValueOffIter
beginValueOff() {
return ValueOffIter(mValueMask.beginOff(),
this); }
708 ValueAllCIter
cbeginValueAll()
const {
return ValueAllCIter(mValueMask.beginDense(),
this); }
709 ValueAllCIter
beginValueAll()
const {
return ValueAllCIter(mValueMask.beginDense(),
this); }
710 ValueAllIter
beginValueAll() {
return ValueAllIter(mValueMask.beginDense(),
this); }
712 ValueOnCIter
cendValueOn()
const {
return ValueOnCIter(mValueMask.endOn(),
this); }
713 ValueOnCIter
endValueOn()
const {
return ValueOnCIter(mValueMask.endOn(),
this); }
714 ValueOnIter
endValueOn() {
return ValueOnIter(mValueMask.endOn(),
this); }
715 ValueOffCIter
cendValueOff()
const {
return ValueOffCIter(mValueMask.endOff(),
this); }
716 ValueOffCIter
endValueOff()
const {
return ValueOffCIter(mValueMask.endOff(),
this); }
717 ValueOffIter
endValueOff() {
return ValueOffIter(mValueMask.endOff(),
this); }
718 ValueAllCIter
cendValueAll()
const {
return ValueAllCIter(mValueMask.endDense(),
this); }
719 ValueAllCIter
endValueAll()
const {
return ValueAllCIter(mValueMask.endDense(),
this); }
720 ValueAllIter
endValueAll() {
return ValueAllIter(mValueMask.endDense(),
this); }
724 ChildOnCIter
cbeginChildOn()
const {
return ChildOnCIter(mValueMask.endOn(),
this); }
725 ChildOnCIter
beginChildOn()
const {
return ChildOnCIter(mValueMask.endOn(),
this); }
726 ChildOnIter
beginChildOn() {
return ChildOnIter(mValueMask.endOn(),
this); }
727 ChildOffCIter
cbeginChildOff()
const {
return ChildOffCIter(mValueMask.endOff(),
this); }
728 ChildOffCIter
beginChildOff()
const {
return ChildOffCIter(mValueMask.endOff(),
this); }
729 ChildOffIter
beginChildOff() {
return ChildOffIter(mValueMask.endOff(),
this); }
730 ChildAllCIter
cbeginChildAll()
const {
return ChildAllCIter(mValueMask.beginDense(),
this); }
731 ChildAllCIter
beginChildAll()
const {
return ChildAllCIter(mValueMask.beginDense(),
this); }
732 ChildAllIter
beginChildAll() {
return ChildAllIter(mValueMask.beginDense(),
this); }
734 ChildOnCIter
cendChildOn()
const {
return ChildOnCIter(mValueMask.endOn(),
this); }
735 ChildOnCIter
endChildOn()
const {
return ChildOnCIter(mValueMask.endOn(),
this); }
736 ChildOnIter
endChildOn() {
return ChildOnIter(mValueMask.endOn(),
this); }
737 ChildOffCIter
cendChildOff()
const {
return ChildOffCIter(mValueMask.endOff(),
this); }
738 ChildOffCIter
endChildOff()
const {
return ChildOffCIter(mValueMask.endOff(),
this); }
739 ChildOffIter
endChildOff() {
return ChildOffIter(mValueMask.endOff(),
this); }
740 ChildAllCIter
cendChildAll()
const {
return ChildAllCIter(mValueMask.endDense(),
this); }
741 ChildAllCIter
endChildAll()
const {
return ChildAllCIter(mValueMask.endDense(),
this); }
742 ChildAllIter
endChildAll() {
return ChildAllIter(mValueMask.endDense(),
this); }
765 template<
typename NodeT,
typename VisitorOp,
typename ChildAllIterT>
766 static inline void doVisit(NodeT&, VisitorOp&);
768 template<
typename NodeT,
typename OtherNodeT,
typename VisitorOp,
769 typename ChildAllIterT,
typename OtherChildAllIterT>
770 static inline void doVisit2Node(NodeT&
self, OtherNodeT& other, VisitorOp&);
772 template<
typename NodeT,
typename VisitorOp,
773 typename ChildAllIterT,
typename OtherChildAllIterT>
774 static inline void doVisit2(NodeT&
self, OtherChildAllIterT&, VisitorOp&,
bool otherIsLHS);
793 friend struct ValueIter<MaskOnIter,
LeafNode, bool>;
794 friend struct ValueIter<MaskOffIter,
LeafNode, bool>;
795 friend struct ValueIter<MaskDenseIter,
LeafNode, bool>;
796 friend struct ValueIter<MaskOnIter, const
LeafNode, bool>;
797 friend struct ValueIter<MaskOffIter, const
LeafNode, bool>;
798 friend struct ValueIter<MaskDenseIter, const
LeafNode, bool>;
822 template<Index Log2Dim>
829 template<Index Log2Dim>
834 mOrigin(xyz & (~(DIM - 1)))
839 #ifndef OPENVDB_2_ABI_COMPATIBLE
840 template<Index Log2Dim>
845 mOrigin(xyz & (~(DIM - 1)))
854 template<Index Log2Dim>
857 mValueMask(other.mValueMask),
858 mBuffer(other.mBuffer),
859 mOrigin(other.mOrigin)
865 template<Index Log2Dim>
866 template<
typename ValueT>
869 mValueMask(other.getValueMask()),
870 mOrigin(other.origin())
874 static inline bool convertValue(
const ValueT& val) {
return bool(val); }
878 mBuffer.
setValue(i, Local::convertValue(other.mBuffer[i]));
883 template<Index Log2Dim>
884 template<
typename ValueT>
888 mValueMask(other.getValueMask()),
890 mOrigin(other.origin())
895 template<Index Log2Dim>
896 template<
typename ValueT>
899 mValueMask(other.getValueMask()),
900 mBuffer(other.getValueMask()),
901 mOrigin(other.origin())
906 template<Index Log2Dim>
907 template<
typename ValueT>
911 mValueMask(other.getValueMask()),
912 mBuffer(other.getValueMask()),
913 mOrigin(other.origin())
915 if (offValue) {
if (!onValue) mBuffer.
mData.toggle();
else mBuffer.
mData.setOn(); }
919 template<Index Log2Dim>
929 template<Index Log2Dim>
937 template<Index Log2Dim>
942 if (bbox.isInside(this_bbox))
return;
946 for(; iter; ++iter) this_bbox.expand(this->offsetToLocalCoord(iter.pos()));
947 this_bbox.translate(this->
origin());
949 bbox.expand(this_bbox);
954 template<Index Log2Dim>
955 template<
typename OtherType, Index OtherLog2Dim>
960 return (Log2Dim == OtherLog2Dim && mValueMask == other->
getValueMask());
964 template<Index Log2Dim>
968 std::ostringstream ostr;
969 ostr <<
"LeafNode @" << mOrigin <<
": ";
970 for (
Index32 n = 0; n <
SIZE; ++n) ostr << (mValueMask.
isOn(n) ?
'#' :
'.');
978 template<Index Log2Dim>
982 assert ((xyz[0] & (DIM-1u)) < DIM && (xyz[1] & (DIM-1u)) < DIM && (xyz[2] & (DIM-1u)) < DIM);
983 return ((xyz[0] & (DIM-1u)) << 2*Log2Dim)
984 + ((xyz[1] & (DIM-1u)) << Log2Dim)
985 + (xyz[2] & (DIM-1u));
989 template<Index Log2Dim>
993 assert(n < (1 << 3*Log2Dim));
995 xyz.setX(n >> 2*Log2Dim);
996 n &= ((1 << 2*Log2Dim) - 1);
997 xyz.setY(n >> Log2Dim);
998 xyz.setZ(n & ((1 << Log2Dim) - 1));
1003 template<Index Log2Dim>
1014 template<Index Log2Dim>
1018 mValueMask.
load(is);
1022 template<Index Log2Dim>
1026 mValueMask.
save(os);
1030 template<Index Log2Dim>
1040 bool background =
false;
1042 background = *
static_cast<const bool*
>(bgPtr);
1044 this->
clip(clipBBox, background);
1048 template<Index Log2Dim>
1053 mValueMask.
load(is);
1055 is.read(reinterpret_cast<char*>(&mOrigin),
sizeof(Coord::ValueType) * 3);
1059 mBuffer.
mData.load(is);
1064 int8_t numBuffers = 0;
1065 is.read(reinterpret_cast<char*>(&numBuffers),
sizeof(int8_t));
1069 boost::shared_array<bool> buf(
new bool[SIZE]);
1070 io::readData<bool>(is, buf.get(),
SIZE,
true);
1073 mBuffer.
mData.setOff();
1075 if (buf[i]) mBuffer.
mData.setOn(i);
1078 if (numBuffers > 1) {
1081 for (
int i = 1; i < numBuffers; ++i) {
1082 io::readData<bool>(is, buf.get(),
SIZE,
true);
1089 template<Index Log2Dim>
1094 mValueMask.
save(os);
1096 os.write(reinterpret_cast<const char*>(&mOrigin),
sizeof(Coord::ValueType) * 3);
1098 mBuffer.
mData.save(os);
1105 template<Index Log2Dim>
1109 return (mValueMask == other.mValueMask && mBuffer.
mData == other.mBuffer.
mData);
1113 template<Index Log2Dim>
1124 template<Index Log2Dim>
1128 state = mValueMask.
isOn();
1130 if (!(state || mValueMask.
isOff()))
return false;
1133 if (!tolerance && !(mBuffer.
mData.isOn() || mBuffer.
mData.isOff()))
return false;
1135 state = mValueMask.
isOn();
1136 constValue = mBuffer.
mData.isOn();
1144 template<Index Log2Dim>
1151 template<Index Log2Dim>
1155 assert(offset < SIZE);
1160 template<Index Log2Dim>
1161 template<
typename AccessorT>
1164 bool val,
bool active, AccessorT&)
1166 this->
addTile(level, xyz, val, active);
1173 template<Index Log2Dim>
1178 if (mBuffer.
mData.isOn(this->coordToOffset(xyz)))
return sOn;
else return sOff;
1182 template<Index Log2Dim>
1186 assert(offset < SIZE);
1188 if (mBuffer.
mData.isOn(offset))
return sOn;
else return sOff;
1192 template<Index Log2Dim>
1197 val = mBuffer.
mData.isOn(offset);
1198 return mValueMask.
isOn(offset);
1202 template<Index Log2Dim>
1210 template<Index Log2Dim>
1214 assert(offset < SIZE);
1215 mValueMask.
setOn(offset);
1216 mBuffer.
mData.set(offset, val);
1220 template<Index Log2Dim>
1228 template<Index Log2Dim>
1236 template<Index Log2Dim>
1244 template<Index Log2Dim>
1248 assert(offset < SIZE);
1249 mValueMask.
setOff(offset);
1250 mBuffer.
mData.set(offset, val);
1254 template<Index Log2Dim>
1255 template<
typename ModifyOp>
1259 bool val = mBuffer.
mData.isOn(offset);
1261 mBuffer.
mData.set(offset, val);
1262 mValueMask.
setOn(offset);
1266 template<Index Log2Dim>
1267 template<
typename ModifyOp>
1275 template<Index Log2Dim>
1276 template<
typename ModifyOp>
1281 bool val = mBuffer.
mData.isOn(offset), state = mValueMask.
isOn(offset);
1283 mBuffer.
mData.set(offset, val);
1284 mValueMask.
set(offset, state);
1291 template<Index Log2Dim>
1295 if (newBackground != oldBackground) {
1297 NodeMaskType bgMask = !(mBuffer.
mData | mValueMask);
1299 mBuffer.
mData = (mBuffer.
mData & mValueMask) | bgMask;
1307 template<Index Log2Dim>
1308 template<MergePolicy Policy>
1315 const Index n = iter.pos();
1316 if (mValueMask.
isOff(n)) {
1317 mBuffer.
mData.set(n, other.mBuffer.
mData.isOn(n));
1318 mValueMask.
setOn(n);
1324 template<Index Log2Dim>
1325 template<MergePolicy Policy>
1331 if (!tileActive)
return;
1333 if (tileValue) mBuffer.
mData |= !mValueMask;
1334 else mBuffer.
mData &= mValueMask;
1343 template<Index Log2Dim>
1344 template<
typename OtherType>
1352 template<Index Log2Dim>
1353 template<
typename OtherType>
1362 template<Index Log2Dim>
1363 template<
typename OtherType>
1375 template<Index Log2Dim>
1380 if (!clipBBox.hasOverlap(nodeBBox)) {
1382 this->
fill(nodeBBox, background,
false);
1383 }
else if (clipBBox.isInside(nodeBBox)) {
1393 nodeBBox.intersect(clipBBox);
1395 int &x = xyz.x(), &y = xyz.y(), &z = xyz.z();
1396 for (x = nodeBBox.min().x(); x <= nodeBBox.max().x(); ++x) {
1397 for (y = nodeBBox.min().y(); y <= nodeBBox.max().y(); ++y) {
1398 for (z = nodeBBox.min().z(); z <= nodeBBox.max().z(); ++z) {
1415 template<Index Log2Dim>
1419 for (
Int32 x = bbox.min().x(); x <= bbox.max().x(); ++x) {
1420 const Index offsetX = (x & (DIM-1u))<<2*Log2Dim;
1421 for (
Int32 y = bbox.min().y(); y <= bbox.max().y(); ++y) {
1422 const Index offsetXY = offsetX + ((y & (DIM-1u))<< Log2Dim);
1423 for (
Int32 z = bbox.min().z(); z <= bbox.max().z(); ++z) {
1424 const Index offset = offsetXY + (z & (DIM-1u));
1425 mValueMask.
set(offset, active);
1426 mBuffer.
mData.set(offset, value);
1432 template<Index Log2Dim>
1436 mBuffer.
fill(value);
1439 template<Index Log2Dim>
1443 mBuffer.
fill(value);
1444 mValueMask.
set(active);
1451 template<Index Log2Dim>
1452 template<
typename DenseT>
1456 typedef typename DenseT::ValueType DenseValueType;
1458 const size_t xStride = dense.xStride(), yStride = dense.yStride(), zStride = dense.zStride();
1459 const Coord&
min = dense.bbox().min();
1460 DenseValueType* t0 = dense.data() + zStride * (bbox.min()[2] - min[2]);
1461 const Int32 n0 = bbox.min()[2] & (DIM-1u);
1462 for (
Int32 x = bbox.min()[0], ex = bbox.max()[0] + 1; x < ex; ++x) {
1463 DenseValueType* t1 = t0 + xStride * (x - min[0]);
1465 for (
Int32 y = bbox.min()[1], ey = bbox.max()[1] + 1; y < ey; ++y) {
1466 DenseValueType* t2 = t1 + yStride * (y - min[1]);
1468 for (
Int32 z = bbox.min()[2], ez = bbox.max()[2] + 1; z < ez; ++z, t2 += zStride) {
1469 *t2 = DenseValueType(mBuffer.
mData.isOn(n2++));
1476 template<Index Log2Dim>
1477 template<
typename DenseT>
1480 bool background,
bool tolerance)
1482 typedef typename DenseT::ValueType DenseValueType;
1484 inline static bool toBool(
const DenseValueType& v) {
return !
math::isZero(v); }
1487 const size_t xStride = dense.xStride(), yStride = dense.yStride(), zStride = dense.zStride();
1488 const Coord&
min = dense.bbox().min();
1489 const DenseValueType* s0 = dense.data() + zStride * (bbox.min()[2] - min[2]);
1490 const Int32 n0 = bbox.min()[2] & (DIM-1u);
1491 for (
Int32 x = bbox.min()[0], ex = bbox.max()[0] + 1; x < ex; ++x) {
1492 const DenseValueType* s1 = s0 + xStride * (x - min[0]);
1494 for (
Int32 y = bbox.min()[1], ey = bbox.max()[1] + 1; y < ey; ++y) {
1495 const DenseValueType* s2 = s1 + yStride * (y - min[1]);
1497 for (
Int32 z = bbox.min()[2], ez = bbox.max()[2]+1; z < ez; ++z, ++n2, s2 += zStride) {
1499 if (tolerance || (background == Local::toBool(*s2))) {
1501 mBuffer.
mData.set(n2, background);
1503 mValueMask.
setOn(n2);
1504 mBuffer.
mData.set(n2, Local::toBool(*s2));
1515 template<Index Log2Dim>
1516 template<
typename CombineOp>
1522 bool result =
false, aVal = mBuffer.
mData.isOn(i), bVal = other.mBuffer.
mData.isOn(i);
1524 .setAIsActive(mValueMask.
isOn(i))
1526 .setBIsActive(other.mValueMask.
isOn(i))
1527 .setResultRef(result));
1529 mBuffer.
mData.set(i, result);
1534 template<Index Log2Dim>
1535 template<
typename CombineOp>
1540 args.
setBRef(value).setBIsActive(valueIsActive);
1542 bool result =
false, aVal = mBuffer.
mData.isOn(i);
1544 .setAIsActive(mValueMask.
isOn(i))
1545 .setResultRef(result));
1547 mBuffer.
mData.set(i, result);
1555 template<Index Log2Dim>
1556 template<
typename CombineOp,
typename OtherType>
1559 bool valueIsActive, CombineOp& op)
1562 args.
setBRef(value).setBIsActive(valueIsActive);
1564 bool result =
false, aVal = other.mBuffer.
mData.isOn(i);
1566 .setAIsActive(other.mValueMask.
isOn(i))
1567 .setResultRef(result));
1569 mBuffer.
mData.set(i, result);
1574 template<Index Log2Dim>
1575 template<
typename CombineOp,
typename OtherNodeT>
1578 bool valueIsActive, CombineOp& op)
1581 args.
setARef(value).setAIsActive(valueIsActive);
1583 bool result =
false, bVal = other.mBuffer.mData.isOn(i);
1585 .setBIsActive(other.mValueMask.isOn(i))
1586 .setResultRef(result));
1588 mBuffer.
mData.set(i, result);
1593 template<Index Log2Dim>
1594 template<
typename CombineOp,
typename OtherNodeT>
1601 mValueMask.
set(i, b0.mValueMask.
isOn(i) || b1.mValueMask.isOn(i));
1603 bool result =
false, b0Val = b0.mBuffer.
mData.isOn(i), b1Val = b1.mBuffer.mData.isOn(i);
1605 .setAIsActive(b0.mValueMask.
isOn(i))
1607 .setBIsActive(b1.mValueMask.isOn(i))
1608 .setResultRef(result));
1610 mBuffer.
mData.set(i, result);
1617 template<Index Log2Dim>
1618 template<
typename BBoxOp>
1622 if (op.template descent<LEVEL>()) {
1625 op.operator()<LEVEL>(CoordBBox::createCube(i.getCoord(), 1));
1627 op.template operator()<LEVEL>(CoordBBox::createCube(i.getCoord(), 1));
1640 template<Index Log2Dim>
1641 template<
typename VisitorOp>
1645 doVisit<LeafNode, VisitorOp, ChildAllIter>(*
this, op);
1649 template<Index Log2Dim>
1650 template<
typename VisitorOp>
1654 doVisit<const LeafNode, VisitorOp, ChildAllCIter>(*
this, op);
1658 template<Index Log2Dim>
1659 template<
typename NodeT,
typename VisitorOp,
typename ChildAllIterT>
1663 for (ChildAllIterT iter =
self.
beginChildAll(); iter; ++iter) {
1672 template<Index Log2Dim>
1673 template<
typename OtherLeafNodeType,
typename VisitorOp>
1678 typename OtherLeafNodeType::ChildAllIter>(*
this, other, op);
1682 template<Index Log2Dim>
1683 template<
typename OtherLeafNodeType,
typename VisitorOp>
1688 typename OtherLeafNodeType::ChildAllCIter>(*
this, other, op);
1692 template<Index Log2Dim>
1695 typename OtherNodeT,
1697 typename ChildAllIterT,
1698 typename OtherChildAllIterT>
1703 BOOST_STATIC_ASSERT(OtherNodeT::SIZE == NodeT::SIZE);
1704 BOOST_STATIC_ASSERT(OtherNodeT::LEVEL == NodeT::LEVEL);
1706 ChildAllIterT iter =
self.beginChildAll();
1707 OtherChildAllIterT otherIter = other.beginChildAll();
1709 for ( ; iter && otherIter; ++iter, ++otherIter) {
1710 op(iter, otherIter);
1718 template<Index Log2Dim>
1719 template<
typename IterT,
typename VisitorOp>
1723 doVisit2<LeafNode, VisitorOp, ChildAllIter, IterT>(*
this, otherIter, op, otherIsLHS);
1727 template<Index Log2Dim>
1728 template<
typename IterT,
typename VisitorOp>
1732 doVisit2<const LeafNode, VisitorOp, ChildAllCIter, IterT>(*
this, otherIter, op, otherIsLHS);
1736 template<Index Log2Dim>
1740 typename ChildAllIterT,
1741 typename OtherChildAllIterT>
1744 VisitorOp& op,
bool otherIsLHS)
1746 if (!otherIter)
return;
1749 for (ChildAllIterT iter =
self.
beginChildAll(); iter; ++iter) {
1750 op(otherIter, iter);
1753 for (ChildAllIterT iter =
self.
beginChildAll(); iter; ++iter) {
1754 op(iter, otherIter);
1763 #endif // OPENVDB_TREE_LEAFNODEBOOL_HAS_BEEN_INCLUDED
bool getItem(Index pos, void *&child, NonConstValueT &value) const
Definition: LeafNodeBool.h:674
void modifyValueAndActiveStateAndCache(const Coord &xyz, const ModifyOp &op, AccessorT &)
Definition: LeafNodeBool.h:442
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:1422
ChildOnCIter cendChildOn() const
Definition: LeafNodeBool.h:734
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:420
void addLeafAndCache(LeafNode *, AccessorT &)
This function exists only to enable template instantiation.
Definition: LeafNodeBool.h:568
ValueOnCIter endValueOn() const
Definition: LeafNodeBool.h:713
void writeBuffers(std::ostream &os, bool toHalf=false) const
Write buffers to a stream.
Definition: LeafNode.h:1685
void load(std::istream &is)
Definition: NodeMasks.h:555
const bool & getValueAndCache(const Coord &xyz, AccessorT &) const
Return the value of the voxel at the given coordinates.
Definition: LeafNodeBool.h:404
Index32 Index
Definition: Types.h:58
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:302
const bool & getItem(Index pos) const
Definition: LeafNodeBool.h:638
bool isChildMaskOn(Index) const
Definition: LeafNodeBool.h:754
static Index coordToOffset(const Coord &xyz)
Return the linear table offset of the given global or local coordinates.
Definition: LeafNode.h:1271
void setItem(Index pos, bool value) const
Definition: LeafNodeBool.h:642
static Index dim()
Return the number of voxels in each dimension.
Definition: LeafNodeBool.h:184
const NodeMaskType & getValueMask() const
Definition: LeafNode.h:1105
CombineArgs & setBRef(const BValueType &b)
Redirect the B value to a new external source.
Definition: Types.h:344
ValueOnCIter beginValueOn() const
Definition: LeafNodeBool.h:703
Coord offsetToGlobalCoord(Index n) const
Return the global coordinates for a linear table offset.
Definition: LeafNode.h:1295
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:320
ValueIter< MaskOnIter, LeafNode, const bool > ValueOnIter
Definition: LeafNodeBool.h:689
void addTile(Index level, const Coord &, const ValueType &, bool)
Definition: LeafNode.h:1790
void setValueOff(Index offset)
Mark the voxel at the given offset as inactive but don't change its value.
Definition: LeafNodeBool.h:312
Buffer & buffer()
Definition: LeafNodeBool.h:267
ChildOnCIter cbeginChildOn() const
Definition: LeafNodeBool.h:724
NodeMaskType::DenseIterator MaskDenseIter
Definition: LeafNodeBool.h:625
General-purpose arithmetic and comparison routines, most of which accept arbitrary value types (or at...
bool operator==(const LeafNode &other) const
Check for buffer, state and origin equivalence.
Definition: LeafNode.h:1702
bool operator==(const Vec3< T0 > &v0, const Vec3< T1 > &v1)
Equality operator, does exact floating point comparisons.
Definition: Vec3.h:450
ValueIter< MaskOffIter, const LeafNode, const bool > ValueOffCIter
Definition: LeafNodeBool.h:692
NodeT * probeNode(const Coord &)
This function exists only to enable template instantiation.
Definition: LeafNodeBool.h:572
ValueIter< MaskDenseIter, const LeafNode, const bool > ValueAllCIter
Definition: LeafNodeBool.h:694
void setValue(Index i, bool val)
Definition: LeafNodeBool.h:109
bool isValueMaskOn() const
Definition: LeafNodeBool.h:748
ValueAllCIter cbeginValueAll() const
Definition: LeafNodeBool.h:708
const Buffer & buffer() const
Definition: LeafNodeBool.h:266
static Coord offsetToLocalCoord(Index n)
Return the local coordinates for a linear table offset, where offset 0 has coordinates (0...
Definition: LeafNode.h:1281
void modifyItem(Index n, const ModifyOp &op) const
Definition: LeafNodeBool.h:648
static Index log2dim()
Return log2 of the size of the buffer storage.
Definition: LeafNodeBool.h:182
NodeMaskType mValueMask
Bitmask that determines which voxels are active.
Definition: LeafNodeBool.h:778
LeafNode< bool, Log2Dim > LeafNodeType
Definition: LeafNodeBool.h:57
ChildOffCIter endChildOff() const
Definition: LeafNodeBool.h:738
CoordBBox getNodeBoundingBox() const
Return the bounding box of this node, i.e., the full index space spanned by this leaf node...
Definition: LeafNode.h:467
bool resultIsActive() const
Definition: Types.h:353
ChildOffCIter beginChildOff() const
Definition: LeafNodeBool.h:728
ValueAllIter beginValueAll()
Definition: LeafNodeBool.h:710
Bit mask for the internal and leaf nodes of VDB. This is a 64-bit implementation. ...
Definition: NodeMasks.h:304
void setValueOn(const Coord &xyz)
Mark the voxel at the given coordinates as active but don't change its value.
Definition: LeafNode.h:712
Definition: NodeMasks.h:205
void getNodes(ArrayT &) const
This function exists only to enable template instantiation.
Definition: LeafNodeBool.h:575
ChildAllIter beginChildAll()
Definition: LeafNodeBool.h:732
bool isValueOn(Index offset) const
Return true if the voxel at the given offset is active.
Definition: LeafNodeBool.h:352
Definition: NodeMasks.h:236
uint32_t Index32
Definition: Types.h:56
static Index getValueLevel(const Coord &)
Return the level (0) at which leaf node values reside.
Definition: LeafNodeBool.h:297
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:730
WordType * data()
Definition: LeafNodeBool.h:119
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:460
ChildOffCIter cendChildOff() const
Definition: LeafNodeBool.h:737
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:1912
bool isValueOn(const Coord &xyz) const
Return true if the voxel at the given coordinates is active.
Definition: LeafNodeBool.h:350
bool operator!=(const Vec3< T0 > &v0, const Vec3< T1 > &v1)
Inequality operator, does exact floating point comparisons.
Definition: Vec3.h:458
void visit(VisitorOp &)
Definition: LeafNode.h:2066
Buffer mBuffer
Bitmask representing the values of voxels.
Definition: LeafNodeBool.h:780
void setValuesOff()
Mark all voxels as inactive but don't change their values.
Definition: LeafNodeBool.h:347
Index64 onVoxelCount() const
Return the number of active voxels.
Definition: LeafNodeBool.h:195
boost::remove_const< UnsetItemT >::type NonConstValueType
Definition: Iterator.h:217
BaseT::NonConstValueType NonConstValueT
Definition: LeafNodeBool.h:669
static Index32 nonLeafCount()
Definition: LeafNodeBool.h:192
DenseIter< const LeafNode, const ValueType, ChildAll > ChildAllCIter
Definition: LeafNode.h:590
bool isValueMaskOff(Index n) const
Definition: LeafNodeBool.h:749
const bool & getValue(Index i) const
Definition: LeafNodeBool.h:97
ValueOffCIter cendValueOff() const
Definition: LeafNodeBool.h:715
ValueOffIter endValueOff()
Definition: LeafNodeBool.h:717
static Index32 leafCount()
Definition: LeafNodeBool.h:191
bool allocate()
Allocate memory for this node's buffer if it has not already been allocated.
Definition: LeafNodeBool.h:216
void resetBackground(const ValueType &oldBackground, const ValueType &newBackground)
Replace inactive occurrences of oldBackground with newBackground, and inactive occurrences of -oldBac...
Definition: LeafNode.h:1819
const NodeT * probeConstNodeAndCache(const Coord &, AccessorT &) const
Return a const pointer to this node.
Definition: LeafNodeBool.h:610
const WordType * data() const
Definition: LeafNodeBool.h:127
CoordBBox getNodeBoundingBox() const
Return the bounding box of this node, i.e., the full index space spanned by this leaf node...
Definition: LeafNodeBool.h:229
static const bool sOn
Definition: LeafNodeBool.h:785
bool isInactive() const
Return true if all of this node's values are inactive.
Definition: LeafNodeBool.h:484
void readBuffers(std::istream &is, bool fromHalf=false)
Read buffers from a stream.
Definition: LeafNode.h:1593
DenseIter(const MaskDenseIter &iter, NodeT *parent)
Definition: LeafNodeBool.h:672
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 operator!=(const LeafNode &other) const
Definition: LeafNode.h:496
void voxelizeActiveTiles()
Definition: LeafNodeBool.h:494
void getOrigin(Coord &origin) const
Return the grid index coordinates of this node's local origin.
Definition: LeafNodeBool.h:236
ChildAllCIter beginChildAll() const
Definition: LeafNode.h:621
void visitActiveBBox(BBoxOp &) const
Calls the templated functor BBoxOp with bounding box information. An additional level argument is pro...
Definition: LeafNode.h:2043
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:1740
bool isOn(Index32 n) const
Return true if the nth bit is on.
Definition: NodeMasks.h:499
void getOrigin(Int32 &x, Int32 &y, Int32 &z) const
Return the grid index coordinates of this node's local origin.
Definition: LeafNodeBool.h:237
void combine2(const LeafNode &other, const OtherType &, bool valueIsActive, CombineOp &)
Definition: LeafNode.h:1979
const bool & getValue() const
Definition: LeafNodeBool.h:639
static Index getLevel()
Definition: LeafNodeBool.h:187
ValueIter< MaskOffIter, LeafNode, const bool > ValueOffIter
Definition: LeafNodeBool.h:691
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:307
ValueAllCIter cendValueAll() const
Definition: LeafNodeBool.h:718
Buffer & operator=(const Buffer &b)
Definition: LeafNodeBool.h:95
void addLeaf(LeafNode *)
This function exists only to enable template instantiation.
Definition: LeafNodeBool.h:566
const bool & getFirstValue() const
Return a const reference to the first entry in the buffer.
Definition: LeafNodeBool.h:473
static const bool sOff
Definition: LeafNodeBool.h:786
Definition: PointIndexGrid.h:68
void setValuesOn()
Mark all voxels as active but don't change their values.
Definition: LeafNodeBool.h:345
void negate()
Definition: LeafNodeBool.h:488
ChildOffCIter cbeginChildOff() const
Definition: LeafNodeBool.h:727
#define OPENVDB_VERSION_NAME
Definition: version.h:43
void setValueMask(const NodeMaskType &mask)
Definition: LeafNodeBool.h:753
OPENVDB_API uint32_t getFormatVersion(std::ios_base &)
Return the file format version number associated with the given input stream.
OffIterator beginOff() const
Definition: NodeMasks.h:351
ChildAllIter endChildAll()
Definition: LeafNodeBool.h:742
~LeafNode()
Destructor.
Definition: LeafNode.h:1251
bool isValueMaskOff() const
Definition: LeafNodeBool.h:750
void setOrigin(const Coord &origin)
Set the grid index coordinates of this node's local origin.
Definition: LeafNodeBool.h:232
bool isEmpty() const
Return true if this node has no active voxels.
Definition: LeafNodeBool.h:204
ChildAllCIter cbeginChildAll() const
Definition: LeafNodeBool.h:730
void setValueOff(const Coord &xyz)
Mark the voxel at the given coordinates as inactive but don't change its value.
Definition: LeafNodeBool.h:310
const NodeMaskType & getValueMask() const
Definition: LeafNodeBool.h:751
ChildIter< MaskOffIter, const LeafNode > ChildOffCIter
Definition: LeafNodeBool.h:698
ChildOffIter endChildOff()
Definition: LeafNodeBool.h:739
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:1356
void clip(const CoordBBox &, const ValueType &background)
Set all voxels that lie outside the given axis-aligned box to the background.
Definition: LeafNode.h:1382
ChildAllCIter endChildAll() const
Definition: LeafNodeBool.h:741
static Index64 onTileCount()
Definition: LeafNodeBool.h:200
ChildIter()
Definition: LeafNodeBool.h:659
Buffer()
Definition: LeafNodeBool.h:89
bool isZero(const Type &x)
Return true if x is exactly equal to zero.
Definition: Math.h:324
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:434
util::NodeMask< Log2Dim > NodeMaskType
Definition: LeafNodeBool.h:60
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:414
ValueOffCIter endValueOff() const
Definition: LeafNodeBool.h:716
ChildAllCIter beginChildAll() const
Definition: LeafNodeBool.h:731
CombineArgs & setARef(const AValueType &a)
Redirect the A value to a new external source.
Definition: Types.h:342
Index64 Word
Definition: NodeMasks.h:313
void fill(bool val)
Definition: LeafNodeBool.h:94
static Index32 memUsage()
Return the byte size of this NodeMask.
Definition: NodeMasks.h:438
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:451
static Index getChildDim()
Definition: LeafNodeBool.h:189
void modifyValue(const ModifyOp &op) const
Definition: LeafNodeBool.h:651
ChildIter(const MaskIterT &iter, NodeT *parent)
Definition: LeafNodeBool.h:660
std::string str() const
Return a string representation of this node.
Definition: LeafNode.h:1258
void set(Index32 n, bool On)
Set the nth bit to the specified state.
Definition: NodeMasks.h:459
Definition: Exceptions.h:39
Index64 offLeafVoxelCount() const
Definition: LeafNodeBool.h:199
ChildOnIter beginChildOn()
Definition: LeafNodeBool.h:726
bool isChildMaskOff() const
Definition: LeafNodeBool.h:756
ValueAllIter endValueAll()
Definition: LeafNodeBool.h:720
Buffer(const Buffer &other)
Definition: LeafNodeBool.h:92
bool isOff(Index32 n) const
Return true if the nth bit is off.
Definition: NodeMasks.h:505
NodeMaskType::OffIterator MaskOffIter
Definition: LeafNodeBool.h:624
boost::shared_ptr< LeafNodeType > Ptr
Definition: LeafNodeBool.h:58
void visit2Node(OtherLeafNodeType &other, VisitorOp &)
Definition: LeafNode.h:2098
DenseIter()
Definition: LeafNodeBool.h:671
DenseIter< const LeafNode, const bool > ChildAllCIter
Definition: LeafNodeBool.h:700
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:1895
static Index numValues()
Definition: LeafNodeBool.h:186
DenseIteratorBase< MaskDenseIter, DenseIter, NodeT, void, ValueT > BaseT
Definition: LeafNodeBool.h:668
const ValueType & getValue(const Coord &xyz) const
Return the value of the voxel at the given coordinates.
Definition: LeafNode.h:1306
ValueIter< MaskDenseIter, LeafNode, const bool > ValueAllIter
Definition: LeafNodeBool.h:693
void setValue(bool value) const
Definition: LeafNodeBool.h:644
NodeT * probeNodeAndCache(const Coord &, AccessorT &)
Return a pointer to this node.
Definition: LeafNodeBool.h:593
void combine(const LeafNode &other, CombineOp &op)
Definition: LeafNode.h:1937
void setValueOn(Index offset)
Mark the voxel at the given offset as active but don't change its value.
Definition: LeafNodeBool.h:322
~Buffer()
Definition: LeafNodeBool.h:93
ValueOnIter beginValueOn()
Definition: LeafNodeBool.h:704
void addTileAndCache(Index, const Coord &, const ValueType &, bool, AccessorT &)
Definition: LeafNode.h:1807
Base class for dense iterators over internal and leaf nodes.
Definition: Iterator.h:211
ChildIter< MaskOnIter, const LeafNode > ChildOnCIter
Definition: LeafNodeBool.h:696
ValueAllCIter endValueAll() const
Definition: LeafNodeBool.h:719
ValueOnCIter cbeginValueOn() const
Definition: LeafNode.h:592
void readTopology(std::istream &is, bool fromHalf=false)
Read in just the topology.
Definition: LeafNode.h:1531
const bool & operator[](Index i) const
Definition: LeafNodeBool.h:104
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:1463
ChildIter< MaskOffIter, LeafNode > ChildOffIter
Definition: LeafNodeBool.h:697
Index memUsage() const
Definition: LeafNodeBool.h:113
void setOff(Index32 n)
Set the nth bit off.
Definition: NodeMasks.h:454
LeafNode * probeLeaf(const Coord &)
Return a pointer to this node.
Definition: LeafNodeBool.h:589
Definition: NodeMasks.h:267
void unsetItem(Index pos, const ValueT &val) const
Definition: LeafNodeBool.h:685
ValueOnCIter cendValueOn() const
Definition: LeafNodeBool.h:712
Buffer(bool on)
Definition: LeafNodeBool.h:90
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:327
static void evalNodeOrigin(Coord &xyz)
Compute the origin of the leaf node that contains the voxel with the given coordinates.
Definition: LeafNodeBool.h:763
static const Index SIZE
Definition: LeafNode.h:79
NodeMaskType::Word WordType
Definition: LeafNodeBool.h:87
LeafNode< ValueType, Log2Dim > Type
Definition: LeafNodeBool.h:74
LeafNode * touchLeafAndCache(const Coord &, AccessorT &)
Return a pointer to this node.
Definition: LeafNodeBool.h:588
Base class for sparse iterators over internal and leaf nodes.
Definition: Iterator.h:148
Coord mOrigin
Global grid index coordinates (x,y,z) of the local origin of this node.
Definition: LeafNodeBool.h:782
void swap(Buffer &other)
Definition: LeafNodeBool.h:111
static void doVisit2(NodeT &self, OtherChildAllIterT &, VisitorOp &, bool otherIsLHS)
Definition: LeafNode.h:2168
ValueOffCIter beginValueOff() const
Definition: LeafNodeBool.h:706
ChildOffIter beginChildOff()
Definition: LeafNodeBool.h:729
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:265
Index64 memUsage() const
Return the memory in bytes occupied by this node.
Definition: LeafNode.h:1712
const LeafNode * probeLeafAndCache(const Coord &, AccessorT &) const
Return a const pointer to this node.
Definition: LeafNodeBool.h:605
bool probeValue(const Coord &xyz, ValueType &val) const
Return true if the voxel at the given coordinates is active.
Definition: LeafNode.h:1322
static void doVisit2Node(NodeT &self, OtherNodeT &other, VisitorOp &)
Definition: LeafNode.h:2123
void setValueMask(Index n, bool on)
Definition: LeafNodeBool.h:758
This struct collects both input and output arguments to "grid combiner" functors used with the tree::...
Definition: Types.h:304
const LeafNode * probeConstLeaf(const Coord &) const
Return a const pointer to this node.
Definition: LeafNodeBool.h:606
ValueAllCIter beginValueAll() const
Definition: LeafNodeBool.h:709
const bool & getLastValue() const
Return a const reference to the last entry in the buffer.
Definition: LeafNodeBool.h:477
void setOn(Index32 n)
Set the nth bit on.
Definition: NodeMasks.h:449
const LeafNode * probeConstLeafAndCache(const Coord &, AccessorT &) const
Return a const pointer to this node.
Definition: LeafNodeBool.h:608
NodeMaskType::OnIterator MaskOnIter
Definition: LeafNodeBool.h:623
int32_t Int32
Definition: Types.h:60
LeafNode specialization for values of type bool that stores both the active states and the values of ...
Definition: LeafNodeBool.h:54
static Index getValueLevelAndCache(const Coord &, AccessorT &)
Return the LEVEL (=0) at which leaf node values reside.
Definition: LeafNodeBool.h:468
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:1364
uint64_t Index64
Definition: Types.h:57
static const Index LOG2DIM
Definition: LeafNode.h:74
NodeMaskType & getValueMask()
Definition: LeafNodeBool.h:752
bool isChildMaskOff(Index) const
Definition: LeafNodeBool.h:755
ChildIter< MaskOnIter, LeafNode > ChildOnIter
Definition: LeafNodeBool.h:695
ValueIter< MaskOnIter, const LeafNode, const bool > ValueOnCIter
Definition: LeafNodeBool.h:690
LeafNode()
Default constructor.
Definition: LeafNode.h:1165
const NodeT * probeConstNode(const Coord &) const
This function exists only to enable template instantiation.
Definition: LeafNodeBool.h:574
Index64 onLeafVoxelCount() const
Definition: LeafNodeBool.h:198
bool operator==(const Buffer &other) const
Definition: LeafNodeBool.h:106
bool ValueType
Definition: LeafNodeBool.h:59
void setValue(Index i, const ValueType &val)
Set the i'th value of this buffer to the specified value.
Definition: LeafNode.h:185
OnIterator beginOn() const
Definition: NodeMasks.h:349
static Index64 offTileCount()
Definition: LeafNodeBool.h:201
bool isDense() const
Return true if this node only contains active voxels.
Definition: LeafNodeBool.h:206
static bool hasActiveTiles()
Return false since leaf nodes never contain tiles.
Definition: LeafNodeBool.h:355
Index64 offVoxelCount() const
Return the number of inactive voxels.
Definition: LeafNodeBool.h:197
static Index size()
Definition: LeafNodeBool.h:114
void visit2(IterT &otherIter, VisitorOp &, bool otherIsLHS=false)
Definition: LeafNode.h:2144
ValueOnIter endValueOn()
Definition: LeafNodeBool.h:714
void evalActiveBoundingBox(CoordBBox &bbox, bool visitVoxels=true) const
Definition: LeafNode.h:1722
void setValueOff(const Coord &xyz)
Mark the voxel at the given coordinates as inactive but don't change its value.
Definition: LeafNode.h:702
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:425
void stealNodes(ArrayT &, const ValueType &, bool)
This function exists only to enable template instantiation.
Definition: LeafNodeBool.h:576
Templated block class to hold specific data types and a fixed number of values determined by Log2Dim...
Definition: LeafNode.h:65
ChildAllCIter cendChildAll() const
Definition: LeafNodeBool.h:740
DenseIter< LeafNode, ValueType, ChildAll > ChildAllIter
Definition: LeafNode.h:589
DenseIter< LeafNode, bool > ChildAllIter
Definition: LeafNodeBool.h:699
LeafNode * probeLeafAndCache(const Coord &, AccessorT &)
Return a pointer to this node.
Definition: LeafNodeBool.h:591
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h:71
Index memUsage() const
Return the memory footprint of this buffer in bytes.
Definition: LeafNode.h:250
ChildOnCIter beginChildOn() const
Definition: LeafNodeBool.h:725
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:1492
ValueIter()
Definition: LeafNodeBool.h:635
void fill(const ValueType &val)
Populate this buffer with a constant value.
Definition: LeafNode.h:170
ValueOffCIter cbeginValueOff() const
Definition: LeafNodeBool.h:705
ValueIter(const MaskIterT &iter, NodeT *parent)
Definition: LeafNodeBool.h:636
NodeT * stealNode(const Coord &, const ValueType &, bool)
This function exists only to enable template instantiation.
Definition: LeafNodeBool.h:570
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:1903
Base class for iterators over internal and leaf nodes.
Definition: Iterator.h:58
ValueType * mData
Definition: LeafNode.h:359
void merge(const LeafNode &)
Definition: LeafNode.h:1842
ValueOnCIter cbeginValueOn() const
Definition: LeafNodeBool.h:702
static Index size()
Definition: LeafNodeBool.h:185
ValueOffIter beginValueOff()
Definition: LeafNodeBool.h:707
bool isConstant(ValueType &constValue, bool &state, const ValueType &tolerance=zeroVal< ValueType >()) const
Definition: LeafNode.h:1749
void setValueMaskOff(Index n)
Definition: LeafNodeBool.h:760
static void doVisit(NodeT &, VisitorOp &)
Definition: LeafNode.h:2084
Buffer(const NodeMaskType &other)
Definition: LeafNodeBool.h:91
bool isValueMaskOn(Index n) const
Definition: LeafNodeBool.h:747
void writeTopology(std::ostream &os, bool toHalf=false) const
Write out just the topology.
Definition: LeafNode.h:1539
ChildOnIter endChildOn()
Definition: LeafNodeBool.h:736
void save(std::ostream &os) const
Definition: NodeMasks.h:551
ChildOnCIter endChildOn() const
Definition: LeafNodeBool.h:735
void setValueMaskOn(Index n)
Definition: LeafNodeBool.h:759
Definition: version.h:104
void modifyValueAndActiveState(const Coord &xyz, const ModifyOp &op)
Apply a functor to the voxel at the given coordinates.
Definition: LeafNode.h:747
bool isValueOnAndCache(const Coord &xyz, AccessorT &) const
Return true if the voxel at the given coordinates is active.
Definition: LeafNodeBool.h:409
static void getNodeLog2Dims(std::vector< Index > &dims)
Definition: LeafNodeBool.h:188
const Coord & origin() const
Return the grid index coordinates of this node's local origin.
Definition: LeafNode.h:473
SparseIteratorBase< MaskIterT, ValueIter, NodeT, ValueT > BaseT
Definition: LeafNodeBool.h:633