35 #ifndef OPENVDB_TREE_INTERNALNODE_HAS_BEEN_INCLUDED 36 #define OPENVDB_TREE_INTERNALNODE_HAS_BEEN_INCLUDED 38 #include <boost/shared_array.hpp> 39 #include <boost/static_assert.hpp> 40 #include <boost/mpl/if.hpp> 41 #include <boost/type_traits/is_const.hpp> 42 #include <boost/type_traits/is_pointer.hpp> 43 #include <boost/type_traits/remove_pointer.hpp> 44 #include <tbb/parallel_for.h> 63 template<
typename _ChildNodeType, Index Log2Dim>
69 typedef typename ChildNodeType::ValueType
ValueType;
70 typedef typename ChildNodeType::BuildType
BuildType;
76 TOTAL = Log2Dim + ChildNodeType::TOTAL,
78 NUM_VALUES = 1 << (3 * Log2Dim),
79 LEVEL = 1 + ChildNodeType::LEVEL;
81 NUM_VOXELS = uint64_t(1) << (3 * TOTAL);
85 template<
typename OtherValueType>
94 template<
typename OtherNodeType>
96 static const bool value =
113 InternalNode(
const Coord& origin,
const ValueType& fillValue,
bool active =
false);
115 #ifndef OPENVDB_2_ABI_COMPATIBLE 127 template<
typename OtherChildNodeType>
133 template<
typename OtherChildNodeType>
140 template<
typename OtherChildNodeType>
142 const ValueType& offValue,
const ValueType& onValue,
TopologyCopy);
159 template<
typename NodeT,
typename ChildT,
typename MaskIterT,
typename TagT>
161 MaskIterT, ChildIter<NodeT, ChildT, MaskIterT, TagT>, NodeT, ChildT>
165 MaskIterT,
ChildIter<NodeT, ChildT, MaskIterT, TagT>, NodeT, ChildT>(iter, parent) {}
169 assert(this->parent().isChildMaskOn(pos));
170 return *(this->parent().getChildNode(pos));
174 void setItem(
Index pos,
const ChildT& c)
const { this->parent().resetChildNode(pos, &c); }
180 template<
typename NodeT,
typename ValueT,
typename MaskIterT,
typename TagT>
182 MaskIterT, ValueIter<NodeT, ValueT, MaskIterT, TagT>, NodeT, ValueT>
186 MaskIterT,
ValueIter<NodeT, ValueT, MaskIterT, TagT>, NodeT, ValueT>(iter, parent) {}
188 const ValueT&
getItem(
Index pos)
const {
return this->parent().mNodes[pos].getValue(); }
191 void setItem(
Index pos,
const ValueT& v)
const { this->parent().mNodes[pos].setValue(v); }
194 template<
typename ModifyOp>
197 op(this->parent().mNodes[pos].getValue());
202 template<
typename NodeT,
typename ChildT,
typename ValueT,
typename TagT>
204 MaskDenseIterator, DenseIter<NodeT, ChildT, ValueT, TagT>, NodeT, ChildT, ValueT>
210 DenseIter(
const MaskDenseIterator& iter, NodeT* parent):
215 if (this->parent().isChildMaskOn(pos)) {
216 child = this->parent().getChildNode(pos);
220 value = this->parent().mNodes[pos].getValue();
227 this->parent().resetChildNode(pos, child);
233 this->parent().unsetChildNode(pos, value);
253 ChildOnCIter
cbeginChildOn()
const {
return ChildOnCIter(mChildMask.beginOn(),
this); }
254 ChildOffCIter
cbeginChildOff()
const {
return ChildOffCIter(mChildMask.beginOff(),
this); }
255 ChildAllCIter
cbeginChildAll()
const {
return ChildAllCIter(mChildMask.beginDense(),
this); }
259 ChildOnIter
beginChildOn() {
return ChildOnIter(mChildMask.beginOn(),
this); }
260 ChildOffIter
beginChildOff() {
return ChildOffIter(mChildMask.beginOff(),
this); }
261 ChildAllIter
beginChildAll() {
return ChildAllIter(mChildMask.beginDense(),
this); }
263 ValueOnCIter
cbeginValueOn()
const {
return ValueOnCIter(mValueMask.beginOn(),
this); }
265 ValueOffCIter
cbeginValueOff()
const {
return ValueOffCIter(mValueMask.beginOff(),
this); }
266 ValueAllCIter
cbeginValueAll()
const {
return ValueAllCIter(mChildMask.beginOff(),
this); }
271 ValueOnIter
beginValueOn() {
return ValueOnIter(mValueMask.beginOn(),
this); }
273 ValueOffIter
beginValueOff() {
return ValueOffIter(mValueMask.beginOff(),
this); }
274 ValueAllIter
beginValueAll() {
return ValueAllIter(mChildMask.beginOff(),
this); }
285 static void getNodeLog2Dims(std::vector<Index>& dims);
295 static void offsetToLocalCoord(
Index n,
Coord& xyz);
308 Index64 onLeafVoxelCount()
const;
309 Index64 offLeafVoxelCount()
const;
319 void evalActiveBoundingBox(
CoordBBox& bbox,
bool visitVoxels =
true)
const;
326 bool isEmpty()
const {
return mChildMask.isOff(); }
333 bool isConstant(ValueType& firstValue,
bool& state,
334 const ValueType& tolerance = zeroVal<ValueType>())
const;
350 bool isConstant(ValueType& minValue, ValueType& maxValue,
351 bool& state,
const ValueType& tolerance = zeroVal<ValueType>())
const;
354 bool isInactive()
const {
return this->isChildMaskOff() && this->isValueMaskOff(); }
357 bool isValueOn(
const Coord& xyz)
const;
362 bool hasActiveTiles()
const;
364 const ValueType& getValue(
const Coord& xyz)
const;
365 bool probeValue(
const Coord& xyz, ValueType& value)
const;
373 const ValueType& getFirstValue()
const;
376 const ValueType& getLastValue()
const;
379 void setActiveState(
const Coord& xyz,
bool on);
381 void setValueOnly(
const Coord& xyz,
const ValueType& value);
383 void setValueOn(
const Coord& xyz);
385 void setValueOn(
const Coord& xyz,
const ValueType& value);
387 void setValueOff(
const Coord& xyz);
389 void setValueOff(
const Coord& xyz,
const ValueType& value);
393 template<
typename ModifyOp>
394 void modifyValue(
const Coord& xyz,
const ModifyOp& op);
396 template<
typename ModifyOp>
397 void modifyValueAndActiveState(
const Coord& xyz,
const ModifyOp& op);
403 template<
typename AccessorT>
404 const ValueType& getValueAndCache(
const Coord& xyz, AccessorT&)
const;
410 template<
typename AccessorT>
411 bool isValueOnAndCache(
const Coord& xyz, AccessorT&)
const;
417 template<
typename AccessorT>
418 void setValueAndCache(
const Coord& xyz,
const ValueType& value, AccessorT&);
424 template<
typename AccessorT>
425 void setValueOnlyAndCache(
const Coord& xyz,
const ValueType& value, AccessorT&);
432 template<
typename ModifyOp,
typename AccessorT>
433 void modifyValueAndCache(
const Coord& xyz,
const ModifyOp& op, AccessorT&);
439 template<
typename ModifyOp,
typename AccessorT>
440 void modifyValueAndActiveStateAndCache(
const Coord& xyz,
const ModifyOp& op, AccessorT&);
446 template<
typename AccessorT>
447 void setValueOffAndCache(
const Coord& xyz,
const ValueType& value, AccessorT&);
453 template<
typename AccessorT>
454 void setActiveStateAndCache(
const Coord& xyz,
bool on, AccessorT&);
461 template<
typename AccessorT>
462 bool probeValueAndCache(
const Coord& xyz, ValueType& value, AccessorT&)
const;
470 template<
typename AccessorT>
471 Index getValueLevelAndCache(
const Coord& xyz, AccessorT&)
const;
479 void writeTopology(std::ostream&,
bool toHalf =
false)
const;
480 void readTopology(std::istream&,
bool fromHalf =
false);
481 void writeBuffers(std::ostream&,
bool toHalf =
false)
const;
482 void readBuffers(std::istream&,
bool fromHalf =
false);
483 void readBuffers(std::istream&,
const CoordBBox&,
bool fromHalf =
false);
501 void fill(
const CoordBBox& bbox,
const ValueType& value,
bool active =
true);
510 void denseFill(
const CoordBBox& bbox,
const ValueType& value,
bool active =
true);
515 void voxelizeActiveTiles(
bool threaded =
true);
524 template<
typename DenseT>
529 template<MergePolicy Policy>
530 void merge(
InternalNode& other,
const ValueType& background,
const ValueType& otherBackground);
534 template<MergePolicy Policy>
void merge(
const ValueType& tileValue,
bool tileActive);
548 template<
typename OtherChildNodeType>
564 template<
typename OtherChildNodeType>
566 const ValueType& background);
579 template<
typename OtherChildNodeType>
581 const ValueType& background);
583 template<
typename CombineOp>
585 template<
typename CombineOp>
586 void combine(
const ValueType& value,
bool valueIsActive, CombineOp&);
588 template<
typename CombineOp,
typename OtherNodeType >
589 void combine2(
const InternalNode& other0,
const OtherNodeType& other1, CombineOp&);
590 template<
typename CombineOp,
typename OtherNodeType >
591 void combine2(
const ValueType& value,
const OtherNodeType& other,
bool valIsActive, CombineOp&);
592 template<
typename CombineOp,
typename OtherValueType>
593 void combine2(
const InternalNode& other,
const OtherValueType&,
bool valIsActive, CombineOp&);
600 template<
typename BBoxOp>
void visitActiveBBox(BBoxOp&)
const;
602 template<
typename VisitorOp>
void visit(VisitorOp&);
603 template<
typename VisitorOp>
void visit(VisitorOp&)
const;
605 template<
typename OtherNodeType,
typename VisitorOp>
606 void visit2Node(OtherNodeType& other, VisitorOp&);
607 template<
typename OtherNodeType,
typename VisitorOp>
608 void visit2Node(OtherNodeType& other, VisitorOp&)
const;
609 template<
typename IterT,
typename VisitorOp>
610 void visit2(IterT& otherIter, VisitorOp&,
bool otherIsLHS =
false);
611 template<
typename IterT,
typename VisitorOp>
612 void visit2(IterT& otherIter, VisitorOp&,
bool otherIsLHS =
false)
const;
620 void prune(
const ValueType& tolerance = zeroVal<ValueType>());
624 void addLeaf(LeafNodeType* leaf);
628 template<
typename AccessorT>
629 void addLeafAndCache(LeafNodeType* leaf, AccessorT&);
639 template<
typename NodeT>
640 NodeT* stealNode(
const Coord& xyz,
const ValueType& value,
bool state);
644 void addTile(
Index level,
const Coord& xyz,
const ValueType& value,
bool state);
647 void addTile(
Index offset,
const ValueType& value,
bool state);
651 template<
typename AccessorT>
652 void addTileAndCache(
Index level,
const Coord& xyz,
const ValueType&,
bool state, AccessorT&);
655 template<
typename NodeType> NodeType* probeNode(
const Coord& xyz);
658 template<
typename NodeType>
const NodeType* probeConstNode(
const Coord& xyz)
const;
662 template<
typename NodeType,
typename AccessorT>
665 NodeType* probeNodeAndCache(
const Coord& xyz, AccessorT&);
666 template<
typename NodeType,
typename AccessorT>
667 const NodeType* probeConstNodeAndCache(
const Coord& xyz, AccessorT&)
const;
671 LeafNodeType* probeLeaf(
const Coord& xyz);
674 const LeafNodeType* probeConstLeaf(
const Coord& xyz)
const;
675 const LeafNodeType* probeLeaf(
const Coord& xyz)
const;
679 template<
typename AccessorT>
682 LeafNodeType* probeLeafAndCache(
const Coord& xyz, AccessorT& acc);
683 template<
typename AccessorT>
684 const LeafNodeType* probeConstLeafAndCache(
const Coord& xyz, AccessorT& acc)
const;
685 template<
typename AccessorT>
686 const LeafNodeType* probeLeafAndCache(
const Coord& xyz, AccessorT& acc)
const;
695 LeafNodeType* touchLeaf(
const Coord& xyz);
699 template<
typename AccessorT>
700 LeafNodeType* touchLeafAndCache(
const Coord& xyz, AccessorT&);
703 template<
typename ArrayT>
726 void getNodes(ArrayT& array);
727 template<
typename ArrayT>
728 void getNodes(ArrayT& array)
const;
754 template<
typename ArrayT>
755 void stealNodes(ArrayT& array,
const ValueType& value,
bool state);
759 void resetBackground(
const ValueType& oldBackground,
const ValueType& newBackground);
763 template<
typename OtherChildNodeType, Index OtherLog2Dim>
768 friend class IteratorBase<MaskOnIterator, InternalNode>;
777 template<
typename, Index>
friend class InternalNode;
792 NodeMaskType mask = mValueMask;
797 const UnionType*
getTable()
const {
return mNodes; }
800 void setValueMask(
Index n,
bool on) { mValueMask.set(n, mChildMask.isOn(n) ? false : on); }
805 void makeChildNodeEmpty(
Index n,
const ValueType& value);
806 void setChildNode(
Index i, ChildNodeType* child);
807 void resetChildNode(
Index i, ChildNodeType* child);
808 ChildNodeType* unsetChildNode(
Index i,
const ValueType& value);
810 template<
typename NodeT,
typename VisitorOp,
typename ChildAllIterT>
811 static inline void doVisit(NodeT&, VisitorOp&);
813 template<
typename NodeT,
typename OtherNodeT,
typename VisitorOp,
814 typename ChildAllIterT,
typename OtherChildAllIterT>
815 static inline void doVisit2Node(NodeT&, OtherNodeT&, VisitorOp&);
817 template<
typename NodeT,
typename VisitorOp,
818 typename ChildAllIterT,
typename OtherChildAllIterT>
819 static inline void doVisit2(NodeT&, OtherChildAllIterT&, VisitorOp&,
bool otherIsLHS);
825 ChildNodeType* getChildNode(
Index n);
826 const ChildNodeType* getChildNode(
Index n)
const;
832 template<
typename OtherInternalNode>
struct DeepCopy;
840 UnionType mNodes[NUM_VALUES];
851 template<
typename ChildT1, Index Dim1,
typename NodeT2>
855 static const bool value =
false;
858 template<
typename ChildT1, Index Dim1,
typename ChildT2>
860 static const bool value = ChildT1::template SameConfiguration<ChildT2>::value;
868 template<
typename ChildT, Index Log2Dim>
872 for (
Index i = 0; i < NUM_VALUES; ++i) mNodes[i].setValue(background);
876 template<
typename ChildT, Index Log2Dim>
879 mOrigin(origin[0] & ~(DIM - 1),
880 origin[1] & ~(DIM - 1),
881 origin[2] & ~(DIM - 1))
888 #ifndef OPENVDB_2_ABI_COMPATIBLE 891 template<
typename ChildT, Index Log2Dim>
902 template<
typename ChildT, Index Log2Dim>
903 template<
typename OtherInternalNode>
907 tbb::parallel_for(tbb::blocked_range<Index>(0,
NUM_VALUES), *
this);
911 for (
Index i = r.begin(), end=r.end(); i!=end; ++i) {
912 if (s->mChildMask.isOff(i)) {
913 t->mNodes[i].setValue(
ValueType(s->mNodes[i].getValue()));
915 t->mNodes[i].setChild(
new ChildNodeType(*(s->mNodes[i].getChild())));
919 const OtherInternalNode*
s;
923 template<
typename ChildT, Index Log2Dim>
935 template<
typename ChildT, Index Log2Dim>
936 template<
typename OtherChildNodeType>
946 template<
typename ChildT, Index Log2Dim>
947 template<
typename OtherInternalNode>
951 const ValueType& background) : s(source), t(target), b(background) {
952 tbb::parallel_for(tbb::blocked_range<Index>(0,
NUM_VALUES), *
this);
956 for (
Index i = r.begin(), end=r.end(); i!=end; ++i) {
957 if (s->isChildMaskOn(i)) {
958 t->mNodes[i].setChild(
new ChildNodeType(*(s->mNodes[i].getChild()),
961 t->mNodes[i].setValue(b);
965 const OtherInternalNode*
s;
970 template<
typename ChildT, Index Log2Dim>
971 template<
typename OtherChildNodeType>
982 template<
typename ChildT, Index Log2Dim>
983 template<
typename OtherInternalNode>
988 : s(source), t(target), offV(offValue), onV(onValue) {
989 tbb::parallel_for(tbb::blocked_range<Index>(0,
NUM_VALUES), *
this);
992 for (
Index i = r.begin(), end=r.end(); i!=end; ++i) {
993 if (s->isChildMaskOn(i)) {
994 t->mNodes[i].setChild(
new ChildNodeType(*(s->mNodes[i].getChild()),
997 t->mNodes[i].setValue(s->isValueMaskOn(i) ? onV : offV);
1001 const OtherInternalNode*
s;
1006 template<
typename ChildT, Index Log2Dim>
1007 template<
typename OtherChildNodeType>
1020 template<
typename ChildT, Index Log2Dim>
1033 template<
typename ChildT, Index Log2Dim>
1040 sum += iter->leafCount();
1046 template<
typename ChildT, Index Log2Dim>
1053 sum += iter->nonLeafCount();
1059 template<
typename ChildT, Index Log2Dim>
1065 sum += iter->onVoxelCount();
1071 template<
typename ChildT, Index Log2Dim>
1077 sum += iter->offVoxelCount();
1083 template<
typename ChildT, Index Log2Dim>
1095 template<
typename ChildT, Index Log2Dim>
1106 template<
typename ChildT, Index Log2Dim>
1112 sum += iter->onTileCount();
1117 template<
typename ChildT, Index Log2Dim>
1124 sum += iter->memUsage();
1130 template<
typename ChildT, Index Log2Dim>
1134 if (bbox.
isInside(this->getNodeBoundingBox()))
return;
1137 bbox.
expand(i.getCoord(), ChildT::DIM);
1140 i->evalActiveBoundingBox(bbox, visitVoxels);
1148 template<
typename ChildT, Index Log2Dim>
1155 const Index i = iter.pos();
1157 child->prune(tolerance);
1158 if (child->isConstant(value, state, tolerance)) {
1171 template<
typename ChildT, Index Log2Dim>
1172 template<
typename NodeT>
1176 if ((NodeT::LEVEL == ChildT::LEVEL && !(boost::is_same<NodeT, ChildT>::value)) ||
1177 NodeT::LEVEL > ChildT::LEVEL)
return NULL;
1182 if (boost::is_same<NodeT, ChildT>::value) {
1187 return (boost::is_same<NodeT, ChildT>::value)
1188 ?
reinterpret_cast<NodeT*
>(child)
1189 : child->template stealNode<NodeT>(xyz, value, state);
1197 template<
typename ChildT, Index Log2Dim>
1198 template<
typename NodeT>
1202 if ((NodeT::LEVEL == ChildT::LEVEL && !(boost::is_same<NodeT, ChildT>::value)) ||
1203 NodeT::LEVEL > ChildT::LEVEL)
return NULL;
1208 return (boost::is_same<NodeT, ChildT>::value)
1209 ?
reinterpret_cast<NodeT*
>(child)
1210 : child->template probeNode<NodeT>(xyz);
1215 template<
typename ChildT, Index Log2Dim>
1216 template<
typename NodeT,
typename AccessorT>
1220 if ((NodeT::LEVEL == ChildT::LEVEL && !(boost::is_same<NodeT, ChildT>::value)) ||
1221 NodeT::LEVEL > ChildT::LEVEL)
return NULL;
1226 acc.insert(xyz, child);
1227 return (boost::is_same<NodeT, ChildT>::value)
1228 ?
reinterpret_cast<NodeT*
>(child)
1229 : child->template probeNodeAndCache<NodeT>(xyz, acc);
1234 template<
typename ChildT, Index Log2Dim>
1235 template<
typename NodeT>
1239 if ((NodeT::LEVEL == ChildT::LEVEL && !(boost::is_same<NodeT, ChildT>::value)) ||
1240 NodeT::LEVEL > ChildT::LEVEL)
return NULL;
1245 return (boost::is_same<NodeT, ChildT>::value)
1246 ?
reinterpret_cast<const NodeT*
>(child)
1247 : child->template probeConstNode<NodeT>(xyz);
1252 template<
typename ChildT, Index Log2Dim>
1253 template<
typename NodeT,
typename AccessorT>
1257 if ((NodeT::LEVEL == ChildT::LEVEL && !(boost::is_same<NodeT, ChildT>::value)) ||
1258 NodeT::LEVEL > ChildT::LEVEL)
return NULL;
1263 acc.insert(xyz, child);
1264 return (boost::is_same<NodeT, ChildT>::value)
1265 ?
reinterpret_cast<const NodeT*
>(child)
1266 : child->template probeConstNodeAndCache<NodeT>(xyz, acc);
1274 template<
typename ChildT, Index Log2Dim>
1275 inline typename ChildT::LeafNodeType*
1278 return this->
template probeNode<LeafNodeType>(xyz);
1282 template<
typename ChildT, Index Log2Dim>
1283 template<
typename AccessorT>
1284 inline typename ChildT::LeafNodeType*
1287 return this->
template probeNodeAndCache<LeafNodeType>(xyz, acc);
1291 template<
typename ChildT, Index Log2Dim>
1292 template<
typename AccessorT>
1293 inline const typename ChildT::LeafNodeType*
1300 template<
typename ChildT, Index Log2Dim>
1301 inline const typename ChildT::LeafNodeType*
1304 return this->
template probeConstNode<LeafNodeType>(xyz);
1308 template<
typename ChildT, Index Log2Dim>
1309 template<
typename AccessorT>
1310 inline const typename ChildT::LeafNodeType*
1313 return this->
template probeConstNodeAndCache<LeafNodeType>(xyz, acc);
1320 template<
typename ChildT, Index Log2Dim>
1324 assert(leaf != NULL);
1325 const Coord& xyz = leaf->origin();
1327 ChildT* child = NULL;
1329 if (ChildT::LEVEL>0) {
1332 child =
reinterpret_cast<ChildT*
>(leaf);
1336 if (ChildT::LEVEL>0) {
1340 child =
reinterpret_cast<ChildT*
>(leaf);
1344 child->addLeaf(leaf);
1348 template<
typename ChildT, Index Log2Dim>
1349 template<
typename AccessorT>
1353 assert(leaf != NULL);
1354 const Coord& xyz = leaf->origin();
1356 ChildT* child = NULL;
1358 if (ChildT::LEVEL>0) {
1360 acc.insert(xyz, child);
1362 child =
reinterpret_cast<ChildT*
>(leaf);
1366 if (ChildT::LEVEL>0) {
1368 acc.insert(xyz, child);
1371 child =
reinterpret_cast<ChildT*
>(leaf);
1375 child->addLeafAndCache(leaf, acc);
1382 template<
typename ChildT, Index Log2Dim>
1392 template<
typename ChildT, Index Log2Dim>
1397 if (
LEVEL >= level) {
1400 if (
LEVEL > level) {
1403 child->addTile(level, xyz, value, state);
1410 if (
LEVEL > level) {
1411 child->addTile(level, xyz, value, state);
1423 template<
typename ChildT, Index Log2Dim>
1424 template<
typename AccessorT>
1427 const ValueType& value,
bool state, AccessorT& acc)
1429 if (
LEVEL >= level) {
1432 if (
LEVEL > level) {
1435 acc.insert(xyz, child);
1436 child->addTileAndCache(level, xyz, value, state, acc);
1443 if (
LEVEL > level) {
1444 acc.insert(xyz, child);
1445 child->addTileAndCache(level, xyz, value, state, acc);
1460 template<
typename ChildT, Index Log2Dim>
1461 inline typename ChildT::LeafNodeType*
1465 ChildT* child = NULL;
1472 return child->touchLeaf(xyz);
1476 template<
typename ChildT, Index Log2Dim>
1477 template<
typename AccessorT>
1478 inline typename ChildT::LeafNodeType*
1485 acc.insert(xyz,
mNodes[n].getChild());
1493 template<
typename ChildT, Index Log2Dim>
1510 template<
typename ChildT, Index Log2Dim>
1523 if ((maxValue - v) > tolerance)
return false;
1525 }
else if (v > maxValue) {
1526 if ((v - minValue) > tolerance)
return false;
1537 template<
typename ChildT, Index Log2Dim>
1543 if (
LEVEL==1 || anyActiveTiles)
return anyActiveTiles;
1545 if (iter->hasActiveTiles())
return true;
1552 template<
typename ChildT, Index Log2Dim>
1561 template<
typename ChildT, Index Log2Dim>
1562 template<
typename AccessorT>
1568 acc.insert(xyz,
mNodes[n].getChild());
1573 template<
typename ChildT, Index Log2Dim>
1574 inline const typename ChildT::ValueType&
1582 template<
typename ChildT, Index Log2Dim>
1583 template<
typename AccessorT>
1584 inline const typename ChildT::ValueType&
1589 acc.insert(xyz,
mNodes[n].getChild());
1596 template<
typename ChildT, Index Log2Dim>
1604 template<
typename ChildT, Index Log2Dim>
1605 template<
typename AccessorT>
1611 acc.insert(xyz,
mNodes[n].getChild());
1618 template<
typename ChildT, Index Log2Dim>
1630 template<
typename ChildT, Index Log2Dim>
1631 template<
typename AccessorT>
1638 acc.insert(xyz,
mNodes[n].getChild());
1639 return mNodes[n].
getChild()->probeValueAndCache(xyz, value, acc);
1646 template<
typename ChildT, Index Log2Dim>
1662 template<
typename ChildT, Index Log2Dim>
1678 template<
typename ChildT, Index Log2Dim>
1697 template<
typename ChildT, Index Log2Dim>
1698 template<
typename AccessorT>
1717 acc.insert(xyz, child);
1718 child->setValueOffAndCache(xyz, value, acc);
1723 template<
typename ChildT, Index Log2Dim>
1742 template<
typename ChildT, Index Log2Dim>
1743 template<
typename AccessorT>
1761 acc.insert(xyz,
mNodes[n].getChild());
1767 template<
typename ChildT, Index Log2Dim>
1783 template<
typename ChildT, Index Log2Dim>
1784 template<
typename AccessorT>
1799 acc.insert(xyz,
mNodes[n].getChild());
1805 template<
typename ChildT, Index Log2Dim>
1823 template<
typename ChildT, Index Log2Dim>
1824 template<
typename AccessorT>
1841 acc.insert(xyz, child);
1842 child->setActiveStateAndCache(xyz, on, acc);
1847 template<
typename ChildT, Index Log2Dim>
1858 template<
typename ChildT, Index Log2Dim>
1859 template<
typename ModifyOp>
1869 bool createChild = !active;
1886 template<
typename ChildT, Index Log2Dim>
1887 template<
typename ModifyOp,
typename AccessorT>
1898 bool createChild = !active;
1914 acc.insert(xyz, child);
1915 child->modifyValueAndCache(xyz, op, acc);
1920 template<
typename ChildT, Index Log2Dim>
1921 template<
typename ModifyOp>
1930 bool modifiedState = !tileState;
1932 op(modifiedVal, modifiedState);
1940 if (hasChild)
mNodes[n].
getChild()->modifyValueAndActiveState(xyz, op);
1943 template<
typename ChildT, Index Log2Dim>
1944 template<
typename ModifyOp,
typename AccessorT>
1947 const Coord& xyz,
const ModifyOp& op, AccessorT& acc)
1954 bool modifiedState = !tileState;
1956 op(modifiedVal, modifiedState);
1966 acc.insert(xyz, child);
1967 child->modifyValueAndActiveStateAndCache(xyz, op, acc);
1975 template<
typename ChildT, Index Log2Dim>
1982 this->
fill(nodeBBox, background,
false);
1983 }
else if (clipBBox.
isInside(nodeBBox)) {
2000 }
else if (!clipBBox.
isInside(tileBBox)) {
2008 tileBBox.intersect(clipBBox);
2013 this->
fill(tileBBox, val, on);
2025 template<
typename ChildT, Index Log2Dim>
2030 clippedBBox.intersect(bbox);
2031 if (!clippedBBox)
return;
2035 Coord xyz, tileMin, tileMax;
2036 for (
int x = clippedBBox.min().x(); x <= clippedBBox.max().x(); x = tileMax.
x() + 1) {
2038 for (
int y = clippedBBox.min().y(); y <= clippedBBox.max().y(); y = tileMax.
y() + 1) {
2040 for (
int z = clippedBBox.min().z(); z <= clippedBBox.max().z(); z = tileMax.
z() + 1) {
2046 tileMax = tileMin.
offsetBy(ChildT::DIM - 1);
2052 ChildT* child = NULL;
2065 child->fill(
CoordBBox(xyz, tmp), value, active);
2081 template<
typename ChildT, Index Log2Dim>
2086 clippedBBox.intersect(bbox);
2087 if (!clippedBBox)
return;
2091 Coord xyz, tileMin, tileMax;
2092 for (
int x = clippedBBox.min().x(); x <= clippedBBox.max().x(); x = tileMax.
x() + 1) {
2094 for (
int y = clippedBBox.min().y(); y <= clippedBBox.max().y(); y = tileMax.
y() + 1) {
2096 for (
int z = clippedBBox.min().z(); z <= clippedBBox.max().z(); z = tileMax.
z() + 1) {
2103 ChildT* child =
nullptr;
2115 tileMax = tileMin.
offsetBy(ChildT::DIM - 1);
2118 child->denseFill(
CoordBBox{xyz, clippedBBox.
max()}, value, active);
2128 template<
typename ChildT, Index Log2Dim>
2129 template<
typename DenseT>
2133 typedef typename DenseT::ValueType DenseValueType;
2135 const size_t xStride = dense.xStride(), yStride = dense.yStride(), zStride = dense.zStride();
2136 const Coord&
min = dense.bbox().min();
2137 for (
Coord xyz = bbox.
min(),
max; xyz[0] <= bbox.
max()[0]; xyz[0] =
max[0] + 1) {
2138 for (xyz[1] = bbox.
min()[1]; xyz[1] <= bbox.
max()[1]; xyz[1] =
max[1] + 1) {
2139 for (xyz[2] = bbox.
min()[2]; xyz[2] <= bbox.
max()[2]; xyz[2] =
max[2] + 1) {
2152 DenseValueType* a0 = dense.data() + zStride*sub.
min()[2];
2153 for (
Int32 x=sub.
min()[0], ex=sub.
max()[0]+1; x<ex; ++x) {
2154 DenseValueType* a1 = a0 + x*xStride;
2155 for (
Int32 y=sub.
min()[1], ey=sub.
max()[1]+1; y<ey; ++y) {
2156 DenseValueType* a2 = a1 + y*yStride;
2157 for (
Int32 z=sub.
min()[2], ez=sub.
max()[2]+1; z<ez; ++z, a2 += zStride) {
2158 *a2 = DenseValueType(value);
2172 template<
typename ChildT, Index Log2Dim>
2182 const ValueType zero = zeroVal<ValueType>();
2191 iter->writeTopology(os, toHalf);
2196 template<
typename ChildT, Index Log2Dim>
2200 #ifndef OPENVDB_2_ABI_COMPATIBLE 2212 #ifdef OPENVDB_2_ABI_COMPATIBLE 2218 child->readTopology(is);
2221 is.read(reinterpret_cast<char*>(&value),
sizeof(
ValueType));
2226 const bool oldVersion =
2232 boost::shared_array<ValueType> values(
new ValueType[numValues]);
2241 assert(n == numValues);
2250 #ifdef OPENVDB_2_ABI_COMPATIBLE 2256 child->readTopology(is, fromHalf);
2265 template<
typename ChildT, Index Log2Dim>
2266 inline const typename ChildT::ValueType&
2273 template<
typename ChildT, Index Log2Dim>
2274 inline const typename ChildT::ValueType&
2285 template<
typename ChildT, Index Log2Dim>
2301 template<
typename ChildT, Index Log2Dim>
2306 tbb::parallel_for(tbb::blocked_range<Index>(0,
NUM_VALUES), *
this);
2313 for (
Index i = r.begin(), end=r.end(); i!=end; ++i) {
2314 if (mNode->mChildMask.isOn(i)) {
2315 mNode->mNodes[i].getChild()->voxelizeActiveTiles(
true);
2316 }
else if (mNode->mValueMask.isOn(i)) {
2317 const Coord &ijk = mNode->offsetToGlobalCoord(i);
2319 child->voxelizeActiveTiles(
true);
2320 mNode->mNodes[i].setChild(child);
2327 template<
typename ChildT, Index Log2Dim>
2338 iter->voxelizeActiveTiles(
false);
2346 template<
typename ChildT, Index Log2Dim>
2347 template<MergePolicy Policy>
2360 const Index n = iter.pos();
2364 background, otherBackground);
2372 child->resetBackground(otherBackground, background);
2379 const Index n = iter.pos();
2392 const Index n = iter.pos();
2395 mNodes[n].
getChild()->template merge<Policy>(*iter, background, otherBackground);
2403 child->resetBackground(otherBackground, background);
2414 const Index n = iter.pos();
2417 mNodes[n].
getChild()->template merge<Policy>(*iter, background, otherBackground);
2424 child->resetBackground(otherBackground, background);
2437 const Index n = iter.pos();
2440 mNodes[n].
getChild()->template merge<Policy>(iter.getValue(),
true);
2455 template<
typename ChildT, Index Log2Dim>
2456 template<MergePolicy Policy>
2465 if (!tileActive)
return;
2469 const Index n = iter.pos();
2475 iter.setValue(tileValue);
2484 template<
typename ChildT, Index Log2Dim>
2485 template<
typename OtherInternalNode>
2489 struct A {
inline void operator()(W &tV,
const W& sV,
const W& tC)
const 2490 { tV = (tV | sV) & ~tC; }
2494 tbb::parallel_for(tbb::blocked_range<Index>(0,
NUM_VALUES), *
this);
2497 t->mChildMask |= s->mChildMask;
2499 t->mValueMask.foreach(s->mValueMask, t->mChildMask, op);
2500 assert((t->mValueMask & t->mChildMask).isOff());
2503 for (
Index i = r.begin(), end=r.end(); i!=end; ++i) {
2504 if (s->mChildMask.isOn(i)) {
2505 const typename OtherInternalNode::ChildNodeType& other = *(s->mNodes[i].getChild());
2506 if (t->mChildMask.isOn(i)) {
2507 t->mNodes[i].getChild()->topologyUnion(other);
2509 ChildT* child =
new ChildT(other, t->mNodes[i].getValue(),
TopologyCopy());
2511 t->mNodes[i].setChild(child);
2513 }
else if (s->mValueMask.isOn(i) && t->mChildMask.isOn(i)) {
2514 t->mNodes[i].getChild()->setValuesOn();
2518 const OtherInternalNode*
s;
2522 template<
typename ChildT, Index Log2Dim>
2523 template<
typename OtherChildT>
2530 template<
typename ChildT, Index Log2Dim>
2531 template<
typename OtherInternalNode>
2535 struct A {
inline void operator()(W &tC,
const W& sC,
const W& sV,
const W& tV)
const 2536 { tC = (tC & (sC | sV)) | (tV & sC); }
2539 const ValueType& background) : s(source), t(target), b(background) {
2541 tbb::parallel_for(tbb::blocked_range<Index>(0,
NUM_VALUES), *
this);
2545 t->mChildMask.foreach(s->mChildMask, s->mValueMask, t->mValueMask, op);
2547 t->mValueMask &= s->mValueMask;
2548 assert((t->mValueMask & t->mChildMask).isOff());
2551 for (
Index i = r.begin(), end=r.end(); i!=end; ++i) {
2552 if (t->mChildMask.isOn(i)) {
2554 if (s->mChildMask.isOn(i)) {
2555 child->topologyIntersection(*(s->mNodes[i].getChild()), b);
2556 }
else if (s->mValueMask.isOff(i)) {
2558 t->mNodes[i].setValue(b);
2560 }
else if (t->mValueMask.isOn(i) && s->mChildMask.isOn(i)) {
2561 t->mNodes[i].setChild(
new ChildT(*(s->mNodes[i].getChild()),
2566 const OtherInternalNode*
s;
2571 template<
typename ChildT, Index Log2Dim>
2572 template<
typename OtherChildT>
2580 template<
typename ChildT, Index Log2Dim>
2581 template<
typename OtherInternalNode>
2585 struct A {
inline void operator()(W &tC,
const W& sC,
const W& sV,
const W& tV)
const 2586 { tC = (tC & (sC | ~sV)) | (tV & sC); }
2588 struct B {
inline void operator()(W &tV,
const W& sC,
const W& sV,
const W& tC)
const 2589 { tV &= ~((tC & sV) | (sC | sV)); }
2592 const ValueType& background) : s(source), t(target), b(background) {
2594 tbb::parallel_for(tbb::blocked_range<Index>(0,
NUM_VALUES), *
this);
2599 t->mChildMask.foreach(s->mChildMask, s->mValueMask, t->mValueMask, op1);
2602 t->mValueMask.foreach(t->mChildMask, s->mValueMask, oldChildMask, op2);
2603 assert((t->mValueMask & t->mChildMask).isOff());
2606 for (
Index i = r.begin(), end=r.end(); i!=end; ++i) {
2607 if (t->mChildMask.isOn(i)) {
2609 if (s->mChildMask.isOn(i)) {
2610 child->topologyDifference(*(s->mNodes[i].getChild()), b);
2611 }
else if (s->mValueMask.isOn(i)) {
2613 t->mNodes[i].setValue(b);
2615 }
else if (t->mValueMask.isOn(i)) {
2616 if (s->mChildMask.isOn(i)) {
2617 const typename OtherInternalNode::ChildNodeType& other = *(s->mNodes[i].getChild());
2618 ChildT* child =
new ChildT(other.origin(), t->mNodes[i].getValue(),
true);
2620 t->mNodes[i].setChild(child);
2625 const OtherInternalNode*
s;
2630 template<
typename ChildT, Index Log2Dim>
2631 template<
typename OtherChildT>
2642 template<
typename ChildT, Index Log2Dim>
2643 template<
typename CombineOp>
2647 const ValueType zero = zeroVal<ValueType>();
2692 if (child && otherChild) {
2693 child->combine(*otherChild, op);
2700 template<
typename ChildT, Index Log2Dim>
2701 template<
typename CombineOp>
2713 .setBIsActive(valueIsActive));
2720 if (child) child->combine(value, valueIsActive, op);
2729 template<
typename ChildT, Index Log2Dim>
2730 template<
typename CombineOp,
typename OtherNodeType>
2741 .setBRef(other1.mNodes[i].getValue())
2742 .setBIsActive(other1.isValueMaskOn(i)));
2751 : other1.mNodes[i].getChild()->origin();
2760 }
else if (other1.isChildMaskOff(i)) {
2764 other1.mNodes[i].getValue(), other1.isValueMaskOn(i), op);
2769 *other1.mNodes[i].getChild(), op);
2776 template<
typename ChildT, Index Log2Dim>
2777 template<
typename CombineOp,
typename OtherNodeType>
2780 bool valueIsActive, CombineOp& op)
2785 if (other.isChildMaskOff(i)) {
2787 .setAIsActive(valueIsActive)
2788 .setBRef(other.mNodes[i].getValue())
2789 .setBIsActive(other.isValueMaskOn(i)));
2794 typename OtherNodeType::ChildNodeType* otherChild = other.mNodes[i].getChild();
2803 mNodes[i].
getChild()->combine2(value, *otherChild, valueIsActive, op);
2809 template<
typename ChildT, Index Log2Dim>
2810 template<
typename CombineOp,
typename OtherValueType>
2813 bool valueIsActive, CombineOp& op)
2822 .setBIsActive(valueIsActive));
2836 mNodes[i].
getChild()->combine2(*otherChild, value, valueIsActive, op);
2845 template<
typename ChildT, Index Log2Dim>
2846 template<
typename BBoxOp>
2857 if (op.template descent<LEVEL>()) {
2862 op.operator()<
LEVEL>(i->getNodeBoundingBox());
2864 op.template operator()<
LEVEL>(i->getNodeBoundingBox());
2871 template<
typename ChildT, Index Log2Dim>
2872 template<
typename VisitorOp>
2876 doVisit<InternalNode, VisitorOp, ChildAllIter>(*
this, op);
2880 template<
typename ChildT, Index Log2Dim>
2881 template<
typename VisitorOp>
2885 doVisit<const InternalNode, VisitorOp, ChildAllCIter>(*
this, op);
2889 template<
typename ChildT, Index Log2Dim>
2890 template<
typename NodeT,
typename VisitorOp,
typename ChildAllIterT>
2894 typename NodeT::ValueType val;
2895 for (ChildAllIterT iter =
self.
beginChildAll(); iter; ++iter) {
2896 if (op(iter))
continue;
2897 if (
typename ChildAllIterT::ChildNodeType* child = iter.probeChild(val)) {
2907 template<
typename ChildT, Index Log2Dim>
2908 template<
typename OtherNodeType,
typename VisitorOp>
2913 typename OtherNodeType::ChildAllIter>(*
this, other, op);
2917 template<
typename ChildT, Index Log2Dim>
2918 template<
typename OtherNodeType,
typename VisitorOp>
2923 typename OtherNodeType::ChildAllCIter>(*
this, other, op);
2927 template<
typename ChildT, Index Log2Dim>
2930 typename OtherNodeT,
2932 typename ChildAllIterT,
2933 typename OtherChildAllIterT>
2938 BOOST_STATIC_ASSERT(OtherNodeT::NUM_VALUES == NodeT::NUM_VALUES);
2939 BOOST_STATIC_ASSERT(OtherNodeT::LEVEL == NodeT::LEVEL);
2941 typename NodeT::ValueType val;
2942 typename OtherNodeT::ValueType otherVal;
2944 ChildAllIterT iter =
self.beginChildAll();
2945 OtherChildAllIterT otherIter = other.beginChildAll();
2947 for ( ; iter && otherIter; ++iter, ++otherIter)
2949 const size_t skipBranch =
static_cast<size_t>(op(iter, otherIter));
2951 typename ChildAllIterT::ChildNodeType* child =
2952 (skipBranch & 1U) ? NULL : iter.probeChild(val);
2953 typename OtherChildAllIterT::ChildNodeType* otherChild =
2954 (skipBranch & 2U) ? NULL : otherIter.probeChild(otherVal);
2956 if (child != NULL && otherChild != NULL) {
2957 child->visit2Node(*otherChild, op);
2958 }
else if (child != NULL) {
2959 child->visit2(otherIter, op);
2960 }
else if (otherChild != NULL) {
2961 otherChild->visit2(iter, op,
true);
2970 template<
typename ChildT, Index Log2Dim>
2971 template<
typename OtherChildAllIterType,
typename VisitorOp>
2974 VisitorOp& op,
bool otherIsLHS)
2976 doVisit2<InternalNode, VisitorOp, ChildAllIter, OtherChildAllIterType>(
2977 *
this, otherIter, op, otherIsLHS);
2981 template<
typename ChildT, Index Log2Dim>
2982 template<
typename OtherChildAllIterType,
typename VisitorOp>
2985 VisitorOp& op,
bool otherIsLHS)
const 2987 doVisit2<const InternalNode, VisitorOp, ChildAllCIter, OtherChildAllIterType>(
2988 *
this, otherIter, op, otherIsLHS);
2992 template<
typename ChildT, Index Log2Dim>
2993 template<
typename NodeT,
typename VisitorOp,
typename ChildAllIterT,
typename OtherChildAllIterT>
2996 VisitorOp& op,
bool otherIsLHS)
2998 if (!otherIter)
return;
3000 const size_t skipBitMask = (otherIsLHS ? 2U : 1U);
3002 typename NodeT::ValueType val;
3003 for (ChildAllIterT iter =
self.
beginChildAll(); iter; ++iter) {
3004 const size_t skipBranch =
static_cast<size_t>(
3005 otherIsLHS ? op(otherIter, iter) : op(iter, otherIter));
3007 typename ChildAllIterT::ChildNodeType* child =
3008 (skipBranch & skipBitMask) ? NULL : iter.probeChild(val);
3010 if (child != NULL) child->visit2(otherIter, op, otherIsLHS);
3018 template<
typename ChildT, Index Log2Dim>
3023 iter->writeBuffers(os, toHalf);
3028 template<
typename ChildT, Index Log2Dim>
3033 iter->readBuffers(is, fromHalf);
3038 template<
typename ChildT, Index Log2Dim>
3041 const CoordBBox& clipBBox,
bool fromHalf)
3048 iter->readBuffers(is, clipBBox, fromHalf);
3052 ValueType background = zeroVal<ValueType>();
3054 background = *
static_cast<const ValueType*
>(bgPtr);
3056 this->
clip(clipBBox, background);
3063 template<
typename ChildT, Index Log2Dim>
3067 dims.push_back(Log2Dim);
3068 ChildNodeType::getNodeLog2Dims(dims);
3072 template<
typename ChildT, Index Log2Dim>
3076 assert(n<(1<<3*Log2Dim));
3077 xyz.
setX(n >> 2*Log2Dim);
3078 n &= ((1<<2*Log2Dim)-1);
3079 xyz.
setY(n >> Log2Dim);
3080 xyz.
setZ(n & ((1<<Log2Dim)-1));
3084 template<
typename ChildT, Index Log2Dim>
3088 return (((xyz[0] & (
DIM-1u)) >> ChildNodeType::TOTAL) << 2*Log2Dim)
3089 + (((xyz[1] & (
DIM-1u)) >> ChildNodeType::TOTAL) << Log2Dim)
3090 + ((xyz[2] & (
DIM-1u)) >> ChildNodeType::TOTAL);
3094 template<
typename ChildT, Index Log2Dim>
3100 local <<= ChildT::TOTAL;
3101 return local + this->
origin();
3106 template<
typename ChildT, Index Log2Dim>
3107 template<
typename ArrayT>
3111 typedef typename ArrayT::value_type T;
3112 BOOST_STATIC_ASSERT(boost::is_pointer<T>::value);
3113 typedef typename boost::mpl::if_<boost::is_const<typename boost::remove_pointer<T>::type>,
3114 const ChildT, ChildT>::type ArrayChildT;
3117 if (boost::is_same<T, ArrayChildT*>::value) {
3118 array.push_back(reinterpret_cast<T>(
mNodes[iter.pos()].
getChild()));
3120 iter->getNodes(array);
3126 template<
typename ChildT, Index Log2Dim>
3127 template<
typename ArrayT>
3131 typedef typename ArrayT::value_type T;
3132 BOOST_STATIC_ASSERT(boost::is_pointer<T>::value);
3133 BOOST_STATIC_ASSERT(boost::is_const<
typename boost::remove_pointer<T>::type>::value);
3136 if (boost::is_same<T, const ChildT*>::value) {
3137 array.push_back(reinterpret_cast<T>(
mNodes[iter.pos()].
getChild()));
3139 iter->getNodes(array);
3147 template<
typename ChildT, Index Log2Dim>
3148 template<
typename ArrayT>
3152 typedef typename ArrayT::value_type T;
3153 BOOST_STATIC_ASSERT(boost::is_pointer<T>::value);
3154 typedef typename boost::mpl::if_<boost::is_const<typename boost::remove_pointer<T>::type>,
3155 const ChildT, ChildT>::type ArrayChildT;
3158 const Index n = iter.pos();
3159 if (boost::is_same<T, ArrayChildT*>::value) {
3160 array.push_back(reinterpret_cast<T>(
mNodes[n].getChild()));
3164 iter->stealNodes(array, value, state);
3174 template<
typename ChildT, Index Log2Dim>
3182 mNodes[i].
getChild()->resetBackground(oldBackground, newBackground);
3193 template<
typename ChildT, Index Log2Dim>
3194 template<
typename OtherChildNodeType, Index OtherLog2Dim>
3202 if (!iter->hasSameTopology(other->
mNodes[iter.pos()].getChild()))
return false;
3208 template<
typename ChildT, Index Log2Dim>
3222 template<
typename ChildT, Index Log2Dim>
3234 template<
typename ChildT, Index Log2Dim>
3249 template<
typename ChildT, Index Log2Dim>
3256 template<
typename ChildT, Index Log2Dim>
3265 template<
typename ChildT, Index Log2Dim>
3266 inline const ChildT*
3277 #endif // OPENVDB_TREE_INTERNALNODE_HAS_BEEN_INCLUDED static Index getChildDim()
Definition: InternalNode.h:289
Definition: InternalNode.h:153
virtual ~InternalNode()
Definition: InternalNode.h:1022
Tag dispatch class that distinguishes topology copy constructors from deep copy constructors.
Definition: Types.h:503
bool isApproxEqual(const Type &a, const Type &b)
Return true if a is equal to b to within the default floating-point comparison tolerance.
Definition: Math.h:370
Coord & setZ(Int32 z)
Definition: Coord.h:105
Definition: InternalNode.h:181
void topologyIntersection(const InternalNode< OtherChildNodeType, Log2Dim > &other, const ValueType &background)
Intersects this tree's set of active values with the active values of the other tree, whose ValueType may be different.
uint32_t Index32
Definition: Types.h:55
bool resultIsActive() const
Definition: Types.h:435
void setValueOnlyAndCache(const Coord &xyz, const ValueType &value, AccessorT &)
Definition: InternalNode.h:1786
Definition: version.h:101
bool isValueMaskOn(Index n) const
Definition: InternalNode.h:781
TopologyDifference(const OtherInternalNode *source, InternalNode *target, const ValueType &background)
Definition: InternalNode.h:2591
bool isChildMaskOff() const
Definition: InternalNode.h:787
const LeafNodeType * probeConstLeaf(const Coord &xyz) const
Return a pointer to the leaf node that contains voxel (x, y, z). If no such node exists, return NULL.
Definition: InternalNode.h:1302
TopologyCopy2(const OtherInternalNode *source, InternalNode *target, const ValueType &offValue, const ValueType &onValue)
Definition: InternalNode.h:986
ChildIter< InternalNode, ChildNodeType, MaskOnIterator, ChildOn > ChildOnIter
Definition: InternalNode.h:239
Int32 z() const
Definition: Coord.h:156
void combine2(const InternalNode &other0, const OtherNodeType &other1, CombineOp &)
Definition: InternalNode.h:2732
void operator()(W &tC, const W &sC, const W &sV, const W &tV) const
Definition: InternalNode.h:2535
DeepCopy(const OtherInternalNode *source, InternalNode *target)
Definition: InternalNode.h:906
Index64 onTileCount() const
Definition: InternalNode.h:1108
Index64 offVoxelCount() const
Definition: InternalNode.h:1073
ValueAllIter beginValueAll()
Definition: InternalNode.h:274
ChildNodeType * unsetChildNode(Index i, const ValueType &value)
Definition: InternalNode.h:3236
void denseFill(const CoordBBox &bbox, const ValueType &value, bool active=true)
Set all voxels within a given axis-aligned box to a constant value and ensure that those voxels are a...
Definition: InternalNode.h:2083
void visit2(IterT &otherIter, VisitorOp &, bool otherIsLHS=false)
void load(std::istream &is)
Definition: NodeMasks.h:569
General-purpose arithmetic and comparison routines, most of which accept arbitrary value types (or at...
NodeMaskType::OnIterator MaskOnIterator
Definition: InternalNode.h:147
NodeUnion< ValueType, ChildNodeType > UnionType
Definition: InternalNode.h:71
ChildIter< const InternalNode, const ChildNodeType, MaskOnIterator, ChildOn > ChildOnCIter
Definition: InternalNode.h:240
ChildAllCIter beginChildAll() const
Definition: InternalNode.h:258
bool isOff(Index32 n) const
Return true if the nth bit is off.
Definition: NodeMasks.h:508
void voxelizeActiveTiles(bool threaded=true)
Densify active tiles, i.e., replace them with leaf-level active voxels.
Definition: InternalNode.h:2329
ChildOffCIter beginChildOff() const
Definition: InternalNode.h:257
TopologyUnion(const OtherInternalNode *source, InternalNode *target)
Definition: InternalNode.h:2492
ValueOnCIter beginValueOn() const
Definition: InternalNode.h:267
static void doVisit(NodeT &, VisitorOp &)
Definition: InternalNode.h:2892
NodeType * probeNode(const Coord &xyz)
Return a pointer to the node that contains voxel (x, y, z). If no such node exists, return NULL.
const ValueType & b
Definition: InternalNode.h:2627
void visit(VisitorOp &)
Definition: InternalNode.h:2874
Definition: InternalNode.h:833
void operator()(const tbb::blocked_range< Index > &r) const
Definition: InternalNode.h:2605
ValueAllCIter beginValueAll() const
Definition: InternalNode.h:270
Axis-aligned bounding box of signed integer coordinates.
Definition: Coord.h:266
ValueIter< const InternalNode, const ValueType, MaskOffIterator, ChildOff > ChildOffCIter
Definition: InternalNode.h:242
InternalNode * t
Definition: InternalNode.h:920
Index64 offLeafVoxelCount() const
Definition: InternalNode.h:1097
const OtherInternalNode * s
Definition: InternalNode.h:2625
ValueIter< InternalNode, const ValueType, MaskOffIterator, ChildOff > ChildOffIter
Definition: InternalNode.h:241
void clip(const CoordBBox &, const ValueType &background)
Set all voxels that lie outside the given axis-aligned box to the background.
Definition: InternalNode.h:1977
void setValueOnly(const Coord &xyz, const ValueType &value)
Set the value of the voxel at the given coordinates but don't change its active state.
Definition: InternalNode.h:1769
void operator()(const tbb::blocked_range< Index > &r) const
Definition: InternalNode.h:991
Int32 y() const
Definition: Coord.h:155
void setActiveStateAndCache(const Coord &xyz, bool on, AccessorT &)
Definition: InternalNode.h:1826
void setValueOn(const Coord &xyz)
Mark the voxel at the given coordinates as active but don't change its value.
Definition: InternalNode.h:1664
ValueIter< const InternalNode, const ValueType, MaskOffIterator, ValueAll > ValueAllCIter
Definition: InternalNode.h:251
Definition: version.h:110
ChildIter(const MaskIterT &iter, NodeT *parent)
Definition: InternalNode.h:164
void writeTopology(std::ostream &, bool toHalf=false) const
Definition: InternalNode.h:2174
ValueOnIter beginValueOn()
Definition: InternalNode.h:271
Definition: InternalNode.h:153
void toggle(Index32 n)
Toggle the state of the nth bit.
Definition: NodeMasks.h:483
static const Index NUM_VALUES
Definition: InternalNode.h:78
static void offsetToLocalCoord(Index n, Coord &xyz)
Return the local coordinates for a linear table offset, where offset 0 has coordinates (0...
Definition: InternalNode.h:3074
InternalNode * t
Definition: InternalNode.h:2626
const OtherInternalNode * s
Definition: InternalNode.h:965
Signed (x, y, z) 32-bit integer coordinates.
Definition: Coord.h:48
ChildNodeType::BuildType BuildType
Definition: InternalNode.h:70
ChildOffCIter cbeginChildOff() const
Definition: InternalNode.h:254
static void doVisit2(NodeT &, OtherChildAllIterT &, VisitorOp &, bool otherIsLHS)
Definition: InternalNode.h:2995
CombineArgs & setARef(const AValueType &a)
Redirect the A value to a new external source.
Definition: Types.h:424
void combine(InternalNode &other, CombineOp &)
Definition: InternalNode.h:2645
void addTileAndCache(Index level, const Coord &xyz, const ValueType &, bool state, AccessorT &)
Same as addTile() except, if necessary, update the accessor with pointers to the nodes along the path...
Definition: InternalNode.h:1426
NodeT * stealNode(const Coord &xyz, const ValueType &value, bool state)
Return a pointer to the node of type NodeT that contains voxel (x, y, z) and replace it with a tile o...
Definition: InternalNode.h:1174
void expand(ValueType padding)
Pad this bounding box with the specified padding.
Definition: Coord.h:408
void setItem(Index pos, ChildT *child) const
Definition: InternalNode.h:225
const LeafNodeType * probeConstLeafAndCache(const Coord &xyz, AccessorT &acc) const
Same as probeLeaf() except, if necessary, update the accessor with pointers to the nodes along the pa...
void makeChildNodeEmpty(Index n, const ValueType &value)
Definition: InternalNode.h:3251
ValueIter()
Definition: InternalNode.h:184
DenseIter()
Definition: InternalNode.h:209
void visit2Node(OtherNodeType &other, VisitorOp &)
Definition: InternalNode.h:2910
void readCompressedValues(std::istream &is, ValueT *destBuf, Index destCount, const MaskT &valueMask, bool fromHalf)
Definition: Compression.h:339
DenseIter< const InternalNode, const ChildNodeType, ValueType, ChildAll > ChildAllCIter
Definition: InternalNode.h:244
const ValueT & getValue() const
Definition: NodeUnion.h:71
ValueOffCIter beginValueOff() const
Definition: InternalNode.h:269
NodeMaskType::Word W
Definition: InternalNode.h:2584
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: InternalNode.h:1807
ChildNodeType * getChildNode(Index n)
Returns a pointer to the child node at the linear offset n.
Definition: InternalNode.h:3258
static void getNodeLog2Dims(std::vector< Index > &dims)
Populated an stil::vector with the dimension of all the nodes in the branch starting with this node...
Definition: InternalNode.h:3065
Index32 countOn() const
Return the total number of on bits.
Definition: NodeMasks.h:443
Definition: InternalNode.h:152
const ValueType & b
Definition: InternalNode.h:967
void visitActiveBBox(BBoxOp &) const
Calls the templated functor BBoxOp with bounding box information for all active tiles and leaf nodes ...
Definition: InternalNode.h:2848
const ValueType & onV
Definition: InternalNode.h:1003
NodeMaskType::Word W
Definition: InternalNode.h:2488
bool isValueMaskOff() const
Definition: InternalNode.h:784
InternalNode()
Default constructor.
Definition: InternalNode.h:103
const ValueType & getValue(const Coord &xyz) const
Definition: InternalNode.h:1575
bool isChildMaskOff(Index n) const
Definition: InternalNode.h:786
void negate()
Change the sign of all the values represented in this node and its child nodes.
Definition: InternalNode.h:2287
Definition: InternalNode.h:152
const ValueType & getLastValue() const
If the last entry in this node's table is a tile, return the tile's value. Otherwise, return the result of calling getLastValue() on the child.
Definition: InternalNode.h:2275
void addTile(Index level, const Coord &xyz, const ValueType &value, bool state)
Add a tile at the specified tree level that contains voxel (x, y, z), possibly creating a parent bran...
Definition: InternalNode.h:1394
util::NodeMask< Log2Dim > NodeMaskType
Definition: InternalNode.h:72
const ValueType & getValueAndCache(const Coord &xyz, AccessorT &) const
ValueIter< const InternalNode, const ValueType, MaskOnIterator, ValueOn > ValueOnCIter
Definition: InternalNode.h:247
Index64 onLeafVoxelCount() const
Definition: InternalNode.h:1085
DenseIter< InternalNode, ChildNodeType, ValueType, ChildAll > ChildAllIter
Definition: InternalNode.h:243
#define OPENVDB_VERSION_NAME
Definition: version.h:43
bool getItem(Index pos, ChildT *&child, NonConstValueT &value) const
Definition: InternalNode.h:213
void setValueOff(const Coord &xyz)
Mark the voxel at the given coordinates as inactive but don't change its value.
Definition: InternalNode.h:1648
bool isValueMaskOn() const
Definition: InternalNode.h:782
void operator()(const tbb::blocked_range< Index > &r) const
Definition: InternalNode.h:2550
void operator()(const tbb::blocked_range< Index > &r) const
Definition: InternalNode.h:2502
Index64 onVoxelCount() const
Definition: InternalNode.h:1061
void setValueAndCache(const Coord &xyz, const ValueType &value, AccessorT &)
Definition: InternalNode.h:1745
ChildOnCIter beginChildOn() const
Definition: InternalNode.h:256
void modifyItem(Index pos, const ModifyOp &op) const
Definition: InternalNode.h:195
void operator()(W &tC, const W &sC, const W &sV, const W &tV) const
Definition: InternalNode.h:2585
void minComponent(const Coord &other)
Perform a component-wise minimum with the other Coord.
Definition: Coord.h:199
static Index getLevel()
Definition: InternalNode.h:282
void setChildNode(Index i, ChildNodeType *child)
Definition: InternalNode.h:3224
Index32 countOff() const
Return the total number of on bits.
Definition: NodeMasks.h:450
void addLeaf(LeafNodeType *leaf)
Add the specified leaf to this node, possibly creating a child branch in the process. If the leaf node already exists, replace it.
Definition: InternalNode.h:1322
Coord offsetToGlobalCoord(Index n) const
Return the global coordinates for a linear table offset.
Definition: InternalNode.h:3096
Definition: InternalNode.h:160
This struct collects both input and output arguments to "grid combiner" functors used with the tree::...
Definition: Types.h:371
void setOrigin(const Coord &origin)
Set the grid index coordinates of this node's local origin.
Definition: InternalNode.h:302
void getNodes(ArrayT &array)
Adds all nodes of a certain type to a container with the following API:
Definition: InternalNode.h:3109
bool isEmpty() const
Definition: InternalNode.h:326
Coord & setX(Int32 x)
Definition: Coord.h:103
void unsetItem(Index pos, const ValueT &value) const
Definition: InternalNode.h:231
InternalNode * t
Definition: InternalNode.h:966
Definition: InternalNode.h:836
const ValueT & getItem(Index pos) const
Definition: InternalNode.h:188
const ValueType & b
Definition: InternalNode.h:2568
void writeBuffers(std::ostream &, bool toHalf=false) const
Definition: InternalNode.h:3020
const Coord & max() const
Definition: Coord.h:340
InternalNode * t
Definition: InternalNode.h:2519
Index64 Word
Definition: NodeMasks.h:316
bool isConstant(bool &isOn) const
Definition: NodeMasks.h:526
NodeMaskType mChildMask
Definition: InternalNode.h:841
ValueOffCIter cbeginValueOff() const
Definition: InternalNode.h:265
Definition: NodeMasks.h:239
ChildNodeType::ValueType ValueType
Definition: InternalNode.h:69
Definition: Exceptions.h:39
const Coord & origin() const
Return the grid index coordinates of this node's local origin.
Definition: InternalNode.h:300
const NodeType * probeConstNode(const Coord &xyz) const
Return a pointer to the node that contains voxel (x, y, z). If no such node exists, return NULL.
Coord mOrigin
Global grid index coordinates (x,y,z) of the local origin of this node.
Definition: InternalNode.h:843
static const Index LEVEL
Definition: InternalNode.h:79
Definition: InternalNode.h:203
Definition: InternalNode.h:2585
void set(Index32 n, bool On)
Set the nth bit to the specified state.
Definition: NodeMasks.h:462
Level getLevel()
Return the current logging level.
Definition: logging.h:163
ChildNodeType::LeafNodeType LeafNodeType
Definition: InternalNode.h:68
SameConfiguration<OtherNodeType>::value is true if and only if OtherNodeType is the type of an Intern...
Definition: InternalNode.h:95
void setValue(const ValueT &val)
Definition: NodeUnion.h:73
static Index32 memUsage()
Return the byte size of this NodeMask.
Definition: NodeMasks.h:441
bool isValueMaskOff(Index n) const
Definition: InternalNode.h:783
ChildIter()
Definition: InternalNode.h:163
static Coord max()
Return the largest possible coordinate.
Definition: Coord.h:70
ChildAllIter beginChildAll()
Definition: InternalNode.h:261
InternalNode * t
Definition: InternalNode.h:2567
bool hasActiveTiles() const
Return true if this node or any of its child nodes have any active tiles.
Definition: InternalNode.h:1539
DenseIteratorBase< MaskDenseIterator, DenseIter, NodeT, ChildT, ValueT > BaseT
Definition: InternalNode.h:206
Definition: InternalNode.h:837
Base class for dense iterators over internal and leaf nodes.
Definition: Iterator.h:206
ValueConverter<T>::Type is the type of an InternalNode having the same child hierarchy and dimensions...
Definition: InternalNode.h:86
ValueIter< InternalNode, const ValueType, MaskOnIterator, ValueOn > ValueOnIter
Definition: InternalNode.h:246
void setValueOffAndCache(const Coord &xyz, const ValueType &value, AccessorT &)
Definition: InternalNode.h:1700
void operator()(W &tV, const W &sC, const W &sV, const W &tC) const
Definition: InternalNode.h:2588
const OtherInternalNode * s
Definition: InternalNode.h:2566
Definition: NodeMasks.h:270
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 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: InternalNode.h:1889
LeafNodeType * touchLeafAndCache(const Coord &xyz, AccessorT &)
Same as touchLeaf() except, if necessary, update the accessor with pointers to the nodes along the pa...
Base class for sparse iterators over internal and leaf nodes.
Definition: Iterator.h:143
Definition: InternalNode.h:2535
bool isInside(const Coord &xyz) const
Return true if point (x, y, z) is inside this bounding box.
Definition: Coord.h:390
void resetChildNode(Index i, ChildNodeType *child)
Definition: InternalNode.h:3210
ChildOnIter beginChildOn()
Definition: InternalNode.h:259
const OtherInternalNode * s
Definition: InternalNode.h:919
bool probeValue(const Coord &xyz, ValueType &value) const
Definition: InternalNode.h:1620
void setItem(Index pos, const ValueT &v) const
Definition: InternalNode.h:191
NodeMaskType::Word W
Definition: InternalNode.h:2534
LeafNodeType * probeLeafAndCache(const Coord &xyz, AccessorT &acc)
Same as probeLeaf() except, if necessary, update the accessor with pointers to the nodes along the pa...
NodeMaskType::DenseIterator MaskDenseIterator
Definition: InternalNode.h:149
Index32 nonLeafCount() const
Definition: InternalNode.h:1048
void readBuffers(std::istream &, bool fromHalf=false)
Definition: InternalNode.h:3030
Definition: InternalNode.h:832
uint64_t Index64
Definition: Types.h:56
Definition: InternalNode.h:64
void setValuesOn()
Mark all values (both tiles and voxels) as active.
Definition: InternalNode.h:1849
void translate(const Coord &t)
Translate this bounding box by .
Definition: Coord.h:447
void setOff(Index32 n)
Set the nth bit off.
Definition: NodeMasks.h:457
NodeMaskType::OffIterator MaskOffIterator
Definition: InternalNode.h:148
TopologyCopy1(const OtherInternalNode *source, InternalNode *target, const ValueType &background)
Definition: InternalNode.h:950
bool isValueOnAndCache(const Coord &xyz, AccessorT &) const
Definition: InternalNode.h:1564
VoxelizeActiveTiles(InternalNode &node)
Definition: InternalNode.h:2304
void setOn(Index32 n)
Set the nth bit on.
Definition: NodeMasks.h:452
bool isExactlyEqual(const T0 &a, const T1 &b)
Return true if a is exactly equal to b.
Definition: Math.h:407
OPENVDB_API uint32_t getFormatVersion(std::ios_base &)
Return the file format version number associated with the given input stream.
static Index coordToOffset(const Coord &xyz)
Return the linear table offset of the given global or local coordinates.
Definition: InternalNode.h:3086
Definition: NodeMasks.h:208
Int32 x() const
Definition: Coord.h:154
void addLeafAndCache(LeafNodeType *leaf, AccessorT &)
Same as addLeaf() except, if necessary, update the accessor with pointers to the nodes along the path...
Definition: InternalNode.h:1351
void setChild(ChildT *child)
Definition: NodeUnion.h:69
bool isValueOn(Index offset) const
Return true if the voxel at the given offset is active.
Definition: InternalNode.h:359
void setItem(Index pos, const ChildT &c) const
Definition: InternalNode.h:174
bool isValueOn(const Coord &xyz) const
Return true if the voxel at the given coordinates is active.
Definition: InternalNode.h:1554
T negative(const T &val)
Return the unary negation of the given value.
Definition: Math.h:116
LeafNodeType * probeLeaf(const Coord &xyz)
Return a pointer to the leaf node that contains voxel (x, y, z). If no such node exists, return NULL.
Definition: InternalNode.h:1276
void save(std::ostream &os) const
Definition: NodeMasks.h:565
Definition: InternalNode.h:60
ChildT & getItem(Index pos) const
Definition: InternalNode.h:167
ChildAllCIter cbeginChildAll() const
Definition: InternalNode.h:255
NodeMaskType getValueOffMask() const
Definition: InternalNode.h:790
Definition: InternalNode.h:153
void stealNodes(ArrayT &array, const ValueType &value, bool state)
Steals all nodes of a certain type from the tree and adds them to a container with the following API:...
Definition: InternalNode.h:3150
ValueIter< InternalNode, const ValueType, MaskOffIterator, ValueOff > ValueOffIter
Definition: InternalNode.h:248
Definition: InternalNode.h:2489
ChildOffIter beginChildOff()
Definition: InternalNode.h:260
static void doVisit2Node(NodeT &, OtherNodeT &, VisitorOp &)
Definition: InternalNode.h:2935
const NodeMaskType & getChildMask() const
Definition: InternalNode.h:789
void modifyValue(const Coord &xyz, const ModifyOp &op)
Apply a functor to the value of the voxel at the given coordinates and mark the voxel as active...
Definition: InternalNode.h:1861
void operator()(const tbb::blocked_range< Index > &r) const
Definition: InternalNode.h:955
Definition: InternalNode.h:2588
const UnionType * getTable() const
Definition: InternalNode.h:797
Definition: InternalNode.h:835
static CoordBBox createCube(const Coord &min, ValueType dim)
Definition: Coord.h:331
Coord & setY(Int32 y)
Definition: Coord.h:104
NodeType * probeNodeAndCache(const Coord &xyz, AccessorT &)
Same as probeNode() except, if necessary, update the accessor with pointers to the nodes along the pa...
void modifyValueAndActiveState(const Coord &xyz, const ModifyOp &op)
Apply a functor to the voxel at the given coordinates.
Definition: InternalNode.h:1923
_ChildNodeType ChildNodeType
Definition: InternalNode.h:67
bool isChildMaskOn(Index n) const
Definition: InternalNode.h:785
static bool lessThan(const Coord &a, const Coord &b)
Definition: Coord.h:232
LeafNodeType * touchLeaf(const Coord &xyz)
Return the leaf node that contains voxel (x, y, z). If no such node exists, create one...
Definition: InternalNode.h:1462
DenseIter(const MaskDenseIterator &iter, NodeT *parent)
Definition: InternalNode.h:210
Definition: InternalNode.h:2302
Bit mask for the internal and leaf nodes of VDB. This is a 64-bit implementation. ...
Definition: NodeMasks.h:307
const OtherInternalNode * s
Definition: InternalNode.h:1001
Index getValueLevel(const Coord &xyz) const
Return the level of the tree (0 = leaf) at which the value at the given coordinates resides...
Definition: InternalNode.h:1598
static const Index DIM
Definition: InternalNode.h:77
BaseT::NonConstValueType NonConstValueT
Definition: InternalNode.h:207
UnionType mNodes[NUM_VALUES]
Definition: InternalNode.h:837
void topologyDifference(const InternalNode< OtherChildNodeType, Log2Dim > &other, const ValueType &background)
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 node and inactive in the other node.
Tag dispatch class that distinguishes constructors during file input.
Definition: Types.h:505
InternalNode * mNode
Definition: InternalNode.h:2324
void operator()(const tbb::blocked_range< Index > &r) const
Definition: InternalNode.h:2311
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h:71
void prune(const ValueType &tolerance=zeroVal< ValueType >())
Reduce the memory footprint of this tree by replacing with tiles any nodes whose values are all the s...
Definition: InternalNode.h:1150
ValueIter(const MaskIterT &iter, NodeT *parent)
Definition: InternalNode.h:185
const Coord & min() const
Definition: Coord.h:339
ValueIter< const InternalNode, const ValueType, MaskOffIterator, ValueOff > ValueOffCIter
Definition: InternalNode.h:249
int32_t Int32
Definition: Types.h:59
ChildOnCIter cbeginChildOn() const
Definition: InternalNode.h:253
Index32 Index
Definition: Types.h:57
boost::remove_const< UnsetItemT >::type NonConstValueType
Definition: Iterator.h:212
TopologyIntersection(const OtherInternalNode *source, InternalNode *target, const ValueType &background)
Definition: InternalNode.h:2538
ValueIter< InternalNode, const ValueType, MaskOffIterator, ValueAll > ValueAllIter
Definition: InternalNode.h:250
void readTopology(std::istream &, bool fromHalf=false)
Definition: InternalNode.h:2198
Index64 memUsage() const
Return the total amount of memory in bytes occupied by this node and its children.
Definition: InternalNode.h:1119
ValueAllCIter cbeginValueAll() const
Definition: InternalNode.h:266
CoordBBox getNodeBoundingBox() const
Return the bounding box of this node, i.e., the full index space spanned by the node regardless of it...
Definition: InternalNode.h:323
NodeMaskType mValueMask
Definition: InternalNode.h:841
const OtherInternalNode * s
Definition: InternalNode.h:2518
bool hasOverlap(const CoordBBox &b) const
Return true if the given bounding box overlaps with this bounding box.
Definition: Coord.h:402
InternalNode< typename ChildNodeType::template ValueConverter< OtherValueType >::Type, Log2Dim > Type
Definition: InternalNode.h:88
void fill(const CoordBBox &bbox, const ValueType &value, bool active=true)
Set all voxels within a given axis-aligned box to a constant value.
Definition: InternalNode.h:2027
Index getValueLevelAndCache(const Coord &xyz, AccessorT &) const
Return the level of the tree (0 = leaf) at which the value at the given coordinates resides...
Definition: InternalNode.h:1607
bool isOn(Index32 n) const
Return true if the nth bit is on.
Definition: NodeMasks.h:502
const NodeType * probeConstNodeAndCache(const Coord &xyz, AccessorT &) const
Same as probeNode() except, if necessary, update the accessor with pointers to the nodes along the pa...
void operator()(const tbb::blocked_range< Index > &r) const
Definition: InternalNode.h:910
bool probeValueAndCache(const Coord &xyz, ValueType &value, AccessorT &) const
Definition: InternalNode.h:1633
const ValueType & getFirstValue() const
If the first entry in this node's table is a tile, return the tile's value. Otherwise, return the result of calling getFirstValue() on the child.
Definition: InternalNode.h:2267
void evalActiveBoundingBox(CoordBBox &bbox, bool visitVoxels=true) const
Expand the specified bounding box so that it includes the active tiles of this internal node as well ...
Definition: InternalNode.h:1132
Index32 leafCount() const
Definition: InternalNode.h:1035
void operator()(W &tV, const W &sV, const W &tC) const
Definition: InternalNode.h:2489
Base class for iterators over internal and leaf nodes.
Definition: Iterator.h:58
static Index dim()
Definition: InternalNode.h:279
const NodeMaskType & getValueMask() const
Definition: InternalNode.h:788
const AValueType & result() const
Get the output value.
Definition: Types.h:416
InternalNode * t
Definition: InternalNode.h:1002
Definition: InternalNode.h:834
Definition: InternalNode.h:152
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: InternalNode.h:2131
void topologyUnion(const InternalNode< OtherChildNodeType, Log2Dim > &other)
Union this branch's set of active values with the other branch's active values. The value type of the...
void merge(InternalNode &other, const ValueType &background, const ValueType &otherBackground)
Efficiently merge another tree into this tree using one of several schemes.
Definition: InternalNode.h:2349
void resetBackground(const ValueType &oldBackground, const ValueType &newBackground)
Change inactive tiles or voxels with value oldBackground to newBackground or -oldBackground to -newBa...
Definition: InternalNode.h:3176
void writeCompressedValues(std::ostream &os, ValueT *srcBuf, Index srcCount, const MaskT &valueMask, const MaskT &childMask, bool toHalf)
Definition: Compression.h:462
bool isInactive() const
Return true if this node has no children and only contains inactive values.
Definition: InternalNode.h:354
bool hasSameTopology(const InternalNode< OtherChildNodeType, OtherLog2Dim > *other) const
Return true if the given tree branch has the same node and active value topology as this tree branch ...
Definition: InternalNode.h:3196
ValueOffIter beginValueOff()
Definition: InternalNode.h:273
Coord offsetBy(Int32 dx, Int32 dy, Int32 dz) const
Definition: Coord.h:115
bool isConstant(ValueType &firstValue, bool &state, const ValueType &tolerance=zeroVal< ValueType >()) const
Definition: InternalNode.h:1495
void modifyValueAndActiveStateAndCache(const Coord &xyz, const ModifyOp &op, AccessorT &)
Definition: InternalNode.h:1946
ChildT * getChild() const
Definition: NodeUnion.h:68
ValueOnCIter cbeginValueOn() const
Definition: InternalNode.h:263