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> 45 #include <openvdb/Platform.h> 46 #include <openvdb/util/NodeMasks.h> 47 #include <openvdb/io/Compression.h> 48 #include <openvdb/math/Math.h> 49 #include <openvdb/version.h> 50 #include <openvdb/Types.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);
292 static Index coordToOffset(
const Coord& xyz);
295 static void offsetToLocalCoord(
Index n, Coord& xyz);
297 Coord offsetToGlobalCoord(
Index n)
const;
300 const Coord&
origin()
const {
return mOrigin; }
302 void setOrigin(
const Coord& origin) { mOrigin = origin; }
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;
369 Index getValueLevel(
const Coord& xyz)
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);
498 void fill(
const CoordBBox& bbox,
const ValueType& value,
bool active =
true);
506 void voxelizeActiveTiles(
bool threaded =
true);
515 template<
typename DenseT>
516 void copyToDense(
const CoordBBox& bbox, DenseT& dense)
const;
520 template<MergePolicy Policy>
521 void merge(
InternalNode& other,
const ValueType& background,
const ValueType& otherBackground);
525 template<MergePolicy Policy>
void merge(
const ValueType& tileValue,
bool tileActive);
539 template<
typename OtherChildNodeType>
555 template<
typename OtherChildNodeType>
557 const ValueType& background);
570 template<
typename OtherChildNodeType>
572 const ValueType& background);
574 template<
typename CombineOp>
576 template<
typename CombineOp>
577 void combine(
const ValueType& value,
bool valueIsActive, CombineOp&);
579 template<
typename CombineOp,
typename OtherNodeType >
580 void combine2(
const InternalNode& other0,
const OtherNodeType& other1, CombineOp&);
581 template<
typename CombineOp,
typename OtherNodeType >
582 void combine2(
const ValueType& value,
const OtherNodeType& other,
bool valIsActive, CombineOp&);
583 template<
typename CombineOp,
typename OtherValueType>
584 void combine2(
const InternalNode& other,
const OtherValueType&,
bool valIsActive, CombineOp&);
591 template<
typename BBoxOp>
void visitActiveBBox(BBoxOp&)
const;
593 template<
typename VisitorOp>
void visit(VisitorOp&);
594 template<
typename VisitorOp>
void visit(VisitorOp&)
const;
596 template<
typename OtherNodeType,
typename VisitorOp>
597 void visit2Node(OtherNodeType& other, VisitorOp&);
598 template<
typename OtherNodeType,
typename VisitorOp>
599 void visit2Node(OtherNodeType& other, VisitorOp&)
const;
600 template<
typename IterT,
typename VisitorOp>
601 void visit2(IterT& otherIter, VisitorOp&,
bool otherIsLHS =
false);
602 template<
typename IterT,
typename VisitorOp>
603 void visit2(IterT& otherIter, VisitorOp&,
bool otherIsLHS =
false)
const;
606 void clip(
const CoordBBox&,
const ValueType& background);
611 void prune(
const ValueType& tolerance = zeroVal<ValueType>());
615 void addLeaf(LeafNodeType* leaf);
619 template<
typename AccessorT>
620 void addLeafAndCache(LeafNodeType* leaf, AccessorT&);
630 template<
typename NodeT>
631 NodeT* stealNode(
const Coord& xyz,
const ValueType& value,
bool state);
635 void addTile(
Index level,
const Coord& xyz,
const ValueType& value,
bool state);
638 void addTile(
Index offset,
const ValueType& value,
bool state);
642 template<
typename AccessorT>
643 void addTileAndCache(
Index level,
const Coord& xyz,
const ValueType&,
bool state, AccessorT&);
646 template<
typename NodeType> NodeType* probeNode(
const Coord& xyz);
649 template<
typename NodeType>
const NodeType* probeConstNode(
const Coord& xyz)
const;
653 template<
typename NodeType,
typename AccessorT>
656 NodeType* probeNodeAndCache(
const Coord& xyz, AccessorT&);
657 template<
typename NodeType,
typename AccessorT>
658 const NodeType* probeConstNodeAndCache(
const Coord& xyz, AccessorT&)
const;
662 LeafNodeType* probeLeaf(
const Coord& xyz);
665 const LeafNodeType* probeConstLeaf(
const Coord& xyz)
const;
666 const LeafNodeType* probeLeaf(
const Coord& xyz)
const;
670 template<
typename AccessorT>
673 LeafNodeType* probeLeafAndCache(
const Coord& xyz, AccessorT& acc);
674 template<
typename AccessorT>
675 const LeafNodeType* probeConstLeafAndCache(
const Coord& xyz, AccessorT& acc)
const;
676 template<
typename AccessorT>
677 const LeafNodeType* probeLeafAndCache(
const Coord& xyz, AccessorT& acc)
const;
686 LeafNodeType* touchLeaf(
const Coord& xyz);
690 template<
typename AccessorT>
691 LeafNodeType* touchLeafAndCache(
const Coord& xyz, AccessorT&);
694 template<
typename ArrayT>
717 void getNodes(ArrayT& array);
718 template<
typename ArrayT>
719 void getNodes(ArrayT& array)
const;
745 template<
typename ArrayT>
746 void stealNodes(ArrayT& array,
const ValueType& value,
bool state);
750 void resetBackground(
const ValueType& oldBackground,
const ValueType& newBackground);
754 template<
typename OtherChildNodeType, Index OtherLog2Dim>
759 friend class IteratorBase<MaskOnIterator, InternalNode>;
768 template<
typename, Index>
friend class InternalNode;
783 NodeMaskType mask = mValueMask;
788 const UnionType*
getTable()
const {
return mNodes; }
791 void setValueMask(
Index n,
bool on) { mValueMask.set(n, mChildMask.isOn(n) ?
false : on); }
796 void makeChildNodeEmpty(
Index n,
const ValueType& value);
797 void setChildNode(
Index i, ChildNodeType* child);
798 void resetChildNode(
Index i, ChildNodeType* child);
799 ChildNodeType* unsetChildNode(
Index i,
const ValueType& value);
801 template<
typename NodeT,
typename VisitorOp,
typename ChildAllIterT>
802 static inline void doVisit(NodeT&, VisitorOp&);
804 template<
typename NodeT,
typename OtherNodeT,
typename VisitorOp,
805 typename ChildAllIterT,
typename OtherChildAllIterT>
806 static inline void doVisit2Node(NodeT&, OtherNodeT&, VisitorOp&);
808 template<
typename NodeT,
typename VisitorOp,
809 typename ChildAllIterT,
typename OtherChildAllIterT>
810 static inline void doVisit2(NodeT&, OtherChildAllIterT&, VisitorOp&,
bool otherIsLHS);
816 ChildNodeType* getChildNode(
Index n);
817 const ChildNodeType* getChildNode(
Index n)
const;
823 template<
typename OtherInternalNode>
struct DeepCopy;
831 UnionType mNodes[NUM_VALUES];
842 template<
typename ChildT1, Index Dim1,
typename NodeT2>
846 static const bool value =
false;
849 template<
typename ChildT1, Index Dim1,
typename ChildT2>
851 static const bool value = ChildT1::template SameConfiguration<ChildT2>::value;
859 template<
typename ChildT, Index Log2Dim>
863 for (
Index i = 0; i < NUM_VALUES; ++i) mNodes[i].setValue(background);
867 template<
typename ChildT, Index Log2Dim>
870 mOrigin(origin[0] & ~(DIM - 1),
871 origin[1] & ~(DIM - 1),
872 origin[2] & ~(DIM - 1))
879 #ifndef OPENVDB_2_ABI_COMPATIBLE 882 template<
typename ChildT, Index Log2Dim>
893 template<
typename ChildT, Index Log2Dim>
894 template<
typename OtherInternalNode>
898 tbb::parallel_for(tbb::blocked_range<Index>(0,
NUM_VALUES), *
this);
902 for (
Index i = r.begin(), end=r.end(); i!=end; ++i) {
903 if (s->mChildMask.isOff(i)) {
904 t->mNodes[i].setValue(
ValueType(s->mNodes[i].getValue()));
906 t->mNodes[i].setChild(
new ChildNodeType(*(s->mNodes[i].getChild())));
910 const OtherInternalNode*
s;
914 template<
typename ChildT, Index Log2Dim>
926 template<
typename ChildT, Index Log2Dim>
927 template<
typename OtherChildNodeType>
937 template<
typename ChildT, Index Log2Dim>
938 template<
typename OtherInternalNode>
942 const ValueType& background) : s(source), t(target), b(background) {
943 tbb::parallel_for(tbb::blocked_range<Index>(0,
NUM_VALUES), *
this);
947 for (
Index i = r.begin(), end=r.end(); i!=end; ++i) {
948 if (s->isChildMaskOn(i)) {
949 t->mNodes[i].setChild(
new ChildNodeType(*(s->mNodes[i].getChild()),
952 t->mNodes[i].setValue(b);
956 const OtherInternalNode*
s;
961 template<
typename ChildT, Index Log2Dim>
962 template<
typename OtherChildNodeType>
973 template<
typename ChildT, Index Log2Dim>
974 template<
typename OtherInternalNode>
979 : s(source), t(target), offV(offValue), onV(onValue) {
980 tbb::parallel_for(tbb::blocked_range<Index>(0,
NUM_VALUES), *
this);
983 for (
Index i = r.begin(), end=r.end(); i!=end; ++i) {
984 if (s->isChildMaskOn(i)) {
985 t->mNodes[i].setChild(
new ChildNodeType(*(s->mNodes[i].getChild()),
988 t->mNodes[i].setValue(s->isValueMaskOn(i) ? onV : offV);
992 const OtherInternalNode*
s;
997 template<
typename ChildT, Index Log2Dim>
998 template<
typename OtherChildNodeType>
1011 template<
typename ChildT, Index Log2Dim>
1016 delete mNodes[iter.pos()].getChild();
1024 template<
typename ChildT, Index Log2Dim>
1031 sum += iter->leafCount();
1037 template<
typename ChildT, Index Log2Dim>
1042 if (ChildNodeType::getLevel() == 0)
return sum;
1044 sum += iter->nonLeafCount();
1050 template<
typename ChildT, Index Log2Dim>
1056 sum += iter->onVoxelCount();
1062 template<
typename ChildT, Index Log2Dim>
1068 sum += iter->offVoxelCount();
1074 template<
typename ChildT, Index Log2Dim>
1080 sum +=
mNodes[iter.pos()].getChild()->onLeafVoxelCount();
1086 template<
typename ChildT, Index Log2Dim>
1092 sum +=
mNodes[iter.pos()].getChild()->offLeafVoxelCount();
1097 template<
typename ChildT, Index Log2Dim>
1103 sum += iter->onTileCount();
1108 template<
typename ChildT, Index Log2Dim>
1115 sum += iter->memUsage();
1121 template<
typename ChildT, Index Log2Dim>
1125 if (bbox.isInside(this->getNodeBoundingBox()))
return;
1128 bbox.expand(i.getCoord(), ChildT::DIM);
1131 i->evalActiveBoundingBox(bbox, visitVoxels);
1139 template<
typename ChildT, Index Log2Dim>
1146 const Index i = iter.pos();
1147 ChildT* child =
mNodes[i].getChild();
1148 child->prune(tolerance);
1149 if (child->isConstant(value, state, tolerance)) {
1153 mNodes[i].setValue(value);
1162 template<
typename ChildT, Index Log2Dim>
1163 template<
typename NodeT>
1167 if ((NodeT::LEVEL == ChildT::LEVEL && !(boost::is_same<NodeT, ChildT>::value)) ||
1168 NodeT::LEVEL > ChildT::LEVEL)
return NULL;
1172 ChildT* child =
mNodes[n].getChild();
1173 if (boost::is_same<NodeT, ChildT>::value) {
1176 mNodes[n].setValue(value);
1178 return (boost::is_same<NodeT, ChildT>::value)
1179 ?
reinterpret_cast<NodeT*
>(child)
1180 : child->template stealNode<NodeT>(xyz, value, state);
1188 template<
typename ChildT, Index Log2Dim>
1189 template<
typename NodeT>
1193 if ((NodeT::LEVEL == ChildT::LEVEL && !(boost::is_same<NodeT, ChildT>::value)) ||
1194 NodeT::LEVEL > ChildT::LEVEL)
return NULL;
1198 ChildT* child =
mNodes[n].getChild();
1199 return (boost::is_same<NodeT, ChildT>::value)
1200 ?
reinterpret_cast<NodeT*
>(child)
1201 : child->template probeNode<NodeT>(xyz);
1206 template<
typename ChildT, Index Log2Dim>
1207 template<
typename NodeT,
typename AccessorT>
1211 if ((NodeT::LEVEL == ChildT::LEVEL && !(boost::is_same<NodeT, ChildT>::value)) ||
1212 NodeT::LEVEL > ChildT::LEVEL)
return NULL;
1216 ChildT* child =
mNodes[n].getChild();
1217 acc.insert(xyz, child);
1218 return (boost::is_same<NodeT, ChildT>::value)
1219 ?
reinterpret_cast<NodeT*
>(child)
1220 : child->template probeNodeAndCache<NodeT>(xyz, acc);
1225 template<
typename ChildT, Index Log2Dim>
1226 template<
typename NodeT>
1230 if ((NodeT::LEVEL == ChildT::LEVEL && !(boost::is_same<NodeT, ChildT>::value)) ||
1231 NodeT::LEVEL > ChildT::LEVEL)
return NULL;
1235 const ChildT* child =
mNodes[n].getChild();
1236 return (boost::is_same<NodeT, ChildT>::value)
1237 ?
reinterpret_cast<const NodeT*
>(child)
1238 : child->template probeConstNode<NodeT>(xyz);
1243 template<
typename ChildT, Index Log2Dim>
1244 template<
typename NodeT,
typename AccessorT>
1248 if ((NodeT::LEVEL == ChildT::LEVEL && !(boost::is_same<NodeT, ChildT>::value)) ||
1249 NodeT::LEVEL > ChildT::LEVEL)
return NULL;
1253 const ChildT* child =
mNodes[n].getChild();
1254 acc.insert(xyz, child);
1255 return (boost::is_same<NodeT, ChildT>::value)
1256 ?
reinterpret_cast<const NodeT*
>(child)
1257 : child->template probeConstNodeAndCache<NodeT>(xyz, acc);
1265 template<
typename ChildT, Index Log2Dim>
1266 inline typename ChildT::LeafNodeType*
1269 return this->
template probeNode<LeafNodeType>(xyz);
1273 template<
typename ChildT, Index Log2Dim>
1274 template<
typename AccessorT>
1275 inline typename ChildT::LeafNodeType*
1278 return this->
template probeNodeAndCache<LeafNodeType>(xyz, acc);
1282 template<
typename ChildT, Index Log2Dim>
1283 template<
typename AccessorT>
1284 inline const typename ChildT::LeafNodeType*
1291 template<
typename ChildT, Index Log2Dim>
1292 inline const typename ChildT::LeafNodeType*
1295 return this->
template probeConstNode<LeafNodeType>(xyz);
1299 template<
typename ChildT, Index Log2Dim>
1300 template<
typename AccessorT>
1301 inline const typename ChildT::LeafNodeType*
1304 return this->
template probeConstNodeAndCache<LeafNodeType>(xyz, acc);
1311 template<
typename ChildT, Index Log2Dim>
1315 assert(leaf != NULL);
1316 const Coord& xyz = leaf->origin();
1318 ChildT* child = NULL;
1320 if (ChildT::LEVEL>0) {
1323 child =
reinterpret_cast<ChildT*
>(leaf);
1327 if (ChildT::LEVEL>0) {
1328 child =
mNodes[n].getChild();
1330 delete mNodes[n].getChild();
1331 child =
reinterpret_cast<ChildT*
>(leaf);
1332 mNodes[n].setChild(child);
1335 child->addLeaf(leaf);
1339 template<
typename ChildT, Index Log2Dim>
1340 template<
typename AccessorT>
1344 assert(leaf != NULL);
1345 const Coord& xyz = leaf->origin();
1347 ChildT* child = NULL;
1349 if (ChildT::LEVEL>0) {
1351 acc.insert(xyz, child);
1353 child =
reinterpret_cast<ChildT*
>(leaf);
1357 if (ChildT::LEVEL>0) {
1358 child =
mNodes[n].getChild();
1359 acc.insert(xyz, child);
1361 delete mNodes[n].getChild();
1362 child =
reinterpret_cast<ChildT*
>(leaf);
1363 mNodes[n].setChild(child);
1366 child->addLeafAndCache(leaf, acc);
1373 template<
typename ChildT, Index Log2Dim>
1383 template<
typename ChildT, Index Log2Dim>
1388 if (
LEVEL >= level) {
1391 if (
LEVEL > level) {
1394 child->addTile(level, xyz, value, state);
1397 mNodes[n].setValue(value);
1400 ChildT* child =
mNodes[n].getChild();
1401 if (
LEVEL > level) {
1402 child->addTile(level, xyz, value, state);
1407 mNodes[n].setValue(value);
1414 template<
typename ChildT, Index Log2Dim>
1415 template<
typename AccessorT>
1418 const ValueType& value,
bool state, AccessorT& acc)
1420 if (
LEVEL >= level) {
1423 if (
LEVEL > level) {
1426 acc.insert(xyz, child);
1427 child->addTileAndCache(level, xyz, value, state, acc);
1430 mNodes[n].setValue(value);
1433 ChildT* child =
mNodes[n].getChild();
1434 if (
LEVEL > level) {
1435 acc.insert(xyz, child);
1436 child->addTileAndCache(level, xyz, value, state, acc);
1441 mNodes[n].setValue(value);
1451 template<
typename ChildT, Index Log2Dim>
1452 inline typename ChildT::LeafNodeType*
1456 ChildT* child = NULL;
1461 child =
mNodes[n].getChild();
1463 return child->touchLeaf(xyz);
1467 template<
typename ChildT, Index Log2Dim>
1468 template<
typename AccessorT>
1469 inline typename ChildT::LeafNodeType*
1476 acc.insert(xyz,
mNodes[n].getChild());
1477 return mNodes[n].getChild()->touchLeafAndCache(xyz, acc);
1484 template<
typename ChildT, Index Log2Dim>
1491 firstValue =
mNodes[0].getValue();
1501 template<
typename ChildT, Index Log2Dim>
1510 minValue = maxValue =
mNodes[0].getValue();
1514 if ((maxValue - v) > tolerance)
return false;
1516 }
else if (v > maxValue) {
1517 if ((v - minValue) > tolerance)
return false;
1528 template<
typename ChildT, Index Log2Dim>
1534 if (
LEVEL==1 || anyActiveTiles)
return anyActiveTiles;
1536 if (iter->hasActiveTiles())
return true;
1543 template<
typename ChildT, Index Log2Dim>
1549 return mNodes[n].getChild()->isValueOn(xyz);
1552 template<
typename ChildT, Index Log2Dim>
1553 template<
typename AccessorT>
1559 acc.insert(xyz,
mNodes[n].getChild());
1560 return mNodes[n].getChild()->isValueOnAndCache(xyz, acc);
1564 template<
typename ChildT, Index Log2Dim>
1565 inline const typename ChildT::ValueType&
1570 :
mNodes[n].getChild()->getValue(xyz);
1573 template<
typename ChildT, Index Log2Dim>
1574 template<
typename AccessorT>
1575 inline const typename ChildT::ValueType&
1580 acc.insert(xyz,
mNodes[n].getChild());
1581 return mNodes[n].getChild()->getValueAndCache(xyz, acc);
1583 return mNodes[n].getValue();
1587 template<
typename ChildT, Index Log2Dim>
1595 template<
typename ChildT, Index Log2Dim>
1596 template<
typename AccessorT>
1602 acc.insert(xyz,
mNodes[n].getChild());
1603 return mNodes[n].getChild()->getValueLevelAndCache(xyz, acc);
1609 template<
typename ChildT, Index Log2Dim>
1615 value =
mNodes[n].getValue();
1618 return mNodes[n].getChild()->probeValue(xyz, value);
1621 template<
typename ChildT, Index Log2Dim>
1622 template<
typename AccessorT>
1629 acc.insert(xyz,
mNodes[n].getChild());
1630 return mNodes[n].getChild()->probeValueAndCache(xyz, value, acc);
1632 value =
mNodes[n].getValue();
1637 template<
typename ChildT, Index Log2Dim>
1649 if (hasChild)
mNodes[n].getChild()->setValueOff(xyz);
1653 template<
typename ChildT, Index Log2Dim>
1665 if (hasChild)
mNodes[n].getChild()->setValueOn(xyz);
1669 template<
typename ChildT, Index Log2Dim>
1685 if (hasChild)
mNodes[n].getChild()->setValueOff(xyz, value);
1688 template<
typename ChildT, Index Log2Dim>
1689 template<
typename AccessorT>
1707 ChildT* child =
mNodes[n].getChild();
1708 acc.insert(xyz, child);
1709 child->setValueOffAndCache(xyz, value, acc);
1714 template<
typename ChildT, Index Log2Dim>
1730 if (hasChild)
mNodes[n].getChild()->setValueOn(xyz, value);
1733 template<
typename ChildT, Index Log2Dim>
1734 template<
typename AccessorT>
1752 acc.insert(xyz,
mNodes[n].getChild());
1753 mNodes[n].getChild()->setValueAndCache(xyz, value, acc);
1758 template<
typename ChildT, Index Log2Dim>
1771 if (hasChild)
mNodes[n].getChild()->setValueOnly(xyz, value);
1774 template<
typename ChildT, Index Log2Dim>
1775 template<
typename AccessorT>
1790 acc.insert(xyz,
mNodes[n].getChild());
1791 mNodes[n].getChild()->setValueOnlyAndCache(xyz, value, acc);
1796 template<
typename ChildT, Index Log2Dim>
1811 if (hasChild)
mNodes[n].getChild()->setActiveState(xyz, on);
1814 template<
typename ChildT, Index Log2Dim>
1815 template<
typename AccessorT>
1831 ChildT* child =
mNodes[n].getChild();
1832 acc.insert(xyz, child);
1833 child->setActiveStateAndCache(xyz, on, acc);
1838 template<
typename ChildT, Index Log2Dim>
1844 mNodes[iter.pos()].getChild()->setValuesOn();
1849 template<
typename ChildT, Index Log2Dim>
1850 template<
typename ModifyOp>
1860 bool createChild = !active;
1874 if (hasChild)
mNodes[n].getChild()->modifyValue(xyz, op);
1877 template<
typename ChildT, Index Log2Dim>
1878 template<
typename ModifyOp,
typename AccessorT>
1889 bool createChild = !active;
1905 acc.insert(xyz, child);
1906 child->modifyValueAndCache(xyz, op, acc);
1911 template<
typename ChildT, Index Log2Dim>
1912 template<
typename ModifyOp>
1921 bool modifiedState = !tileState;
1923 op(modifiedVal, modifiedState);
1931 if (hasChild)
mNodes[n].getChild()->modifyValueAndActiveState(xyz, op);
1934 template<
typename ChildT, Index Log2Dim>
1935 template<
typename ModifyOp,
typename AccessorT>
1938 const Coord& xyz,
const ModifyOp& op, AccessorT& acc)
1945 bool modifiedState = !tileState;
1947 op(modifiedVal, modifiedState);
1957 acc.insert(xyz, child);
1958 child->modifyValueAndActiveStateAndCache(xyz, op, acc);
1966 template<
typename ChildT, Index Log2Dim>
1971 if (!clipBBox.hasOverlap(nodeBBox)) {
1973 this->
fill(nodeBBox, background,
false);
1974 }
else if (clipBBox.isInside(nodeBBox)) {
1985 CoordBBox tileBBox(xyz, xyz.offsetBy(ChildT::DIM - 1));
1986 if (!clipBBox.hasOverlap(tileBBox)) {
1991 }
else if (!clipBBox.isInside(tileBBox)) {
1995 mNodes[pos].getChild()->clip(clipBBox, background);
1999 tileBBox.intersect(clipBBox);
2002 mNodes[pos].setValue(background);
2004 this->
fill(tileBBox, val, on);
2016 template<
typename ChildT, Index Log2Dim>
2020 Coord xyz, tileMin, tileMax;
2021 for (
int x = bbox.min().x(); x <= bbox.max().x(); x = tileMax.x() + 1) {
2023 for (
int y = bbox.min().y(); y <= bbox.max().y(); y = tileMax.y() + 1) {
2025 for (
int z = bbox.min().z(); z <= bbox.max().z(); z = tileMax.z() + 1) {
2031 tileMax = tileMin.offsetBy(ChildT::DIM - 1);
2033 if (xyz != tileMin || Coord::lessThan(bbox.max(), tileMax)) {
2037 ChildT* child = NULL;
2044 child =
mNodes[n].getChild();
2050 child->fill(CoordBBox(xyz, tmp), value, active);
2069 template<
typename ChildT, Index Log2Dim>
2070 template<
typename DenseT>
2074 typedef typename DenseT::ValueType DenseValueType;
2076 const size_t xStride = dense.xStride(), yStride = dense.yStride(), zStride = dense.zStride();
2077 const Coord&
min = dense.bbox().min();
2078 for (Coord xyz = bbox.min(),
max; xyz[0] <= bbox.max()[0]; xyz[0] =
max[0] + 1) {
2079 for (xyz[1] = bbox.min()[1]; xyz[1] <= bbox.max()[1]; xyz[1] =
max[1] + 1) {
2080 for (xyz[2] = bbox.min()[2]; xyz[2] <= bbox.max()[2]; xyz[2] =
max[2] + 1) {
2089 mNodes[n].getChild()->copyToDense(sub, dense);
2092 sub.translate(-min);
2093 DenseValueType* a0 = dense.data() + zStride*sub.min()[2];
2094 for (
Int32 x=sub.min()[0], ex=sub.max()[0]+1; x<ex; ++x) {
2095 DenseValueType* a1 = a0 + x*xStride;
2096 for (
Int32 y=sub.min()[1], ey=sub.max()[1]+1; y<ey; ++y) {
2097 DenseValueType* a2 = a1 + y*yStride;
2098 for (
Int32 z=sub.min()[2], ez=sub.max()[2]+1; z<ez; ++z, a2 += zStride) {
2099 *a2 = DenseValueType(value);
2113 template<
typename ChildT, Index Log2Dim>
2123 const ValueType zero = zeroVal<ValueType>();
2132 iter->writeTopology(os, toHalf);
2137 template<
typename ChildT, Index Log2Dim>
2141 #ifndef OPENVDB_2_ABI_COMPATIBLE 2153 #ifdef OPENVDB_2_ABI_COMPATIBLE 2158 mNodes[i].setChild(child);
2159 child->readTopology(is);
2162 is.read(reinterpret_cast<char*>(&value),
sizeof(
ValueType));
2163 mNodes[i].setValue(value);
2167 const bool oldVersion =
2173 boost::shared_array<ValueType> values(
new ValueType[numValues]);
2180 mNodes[iter.pos()].setValue(values[n++]);
2182 assert(n == numValues);
2185 mNodes[iter.pos()].setValue(values[iter.pos()]);
2191 #ifdef OPENVDB_2_ABI_COMPATIBLE 2196 mNodes[iter.pos()].setChild(child);
2197 child->readTopology(is, fromHalf);
2206 template<
typename ChildT, Index Log2Dim>
2207 inline const typename ChildT::ValueType&
2214 template<
typename ChildT, Index Log2Dim>
2215 inline const typename ChildT::ValueType&
2226 template<
typename ChildT, Index Log2Dim>
2232 mNodes[i].getChild()->negate();
2242 template<
typename ChildT, Index Log2Dim>
2247 tbb::parallel_for(tbb::blocked_range<Index>(0,
NUM_VALUES), *
this);
2254 for (
Index i = r.begin(), end=r.end(); i!=end; ++i) {
2255 if (mNode->mChildMask.isOn(i)) {
2256 mNode->mNodes[i].getChild()->voxelizeActiveTiles(
true);
2257 }
else if (mNode->mValueMask.isOn(i)) {
2258 const Coord &ijk = mNode->offsetToGlobalCoord(i);
2260 child->voxelizeActiveTiles(
true);
2261 mNode->mNodes[i].setChild(child);
2268 template<
typename ChildT, Index Log2Dim>
2279 iter->voxelizeActiveTiles(
false);
2287 template<
typename ChildT, Index Log2Dim>
2288 template<MergePolicy Policy>
2301 const Index n = iter.pos();
2304 mNodes[n].getChild()->template merge<MERGE_ACTIVE_STATES>(*iter,
2305 background, otherBackground);
2313 child->resetBackground(otherBackground, background);
2320 const Index n = iter.pos();
2333 const Index n = iter.pos();
2336 mNodes[n].getChild()->template merge<Policy>(*iter, background, otherBackground);
2344 child->resetBackground(otherBackground, background);
2355 const Index n = iter.pos();
2358 mNodes[n].getChild()->template merge<Policy>(*iter, background, otherBackground);
2365 child->resetBackground(otherBackground, background);
2368 child->template merge<Policy>(
mNodes[n].getValue(),
true);
2372 mNodes[n].setChild(child);
2378 const Index n = iter.pos();
2381 mNodes[n].getChild()->template merge<Policy>(iter.getValue(),
true);
2384 mNodes[n].setValue(iter.getValue());
2396 template<
typename ChildT, Index Log2Dim>
2397 template<MergePolicy Policy>
2406 if (!tileActive)
return;
2410 const Index n = iter.pos();
2413 mNodes[n].getChild()->template merge<Policy>(tileValue,
true);
2416 iter.setValue(tileValue);
2425 template<
typename ChildT, Index Log2Dim>
2426 template<
typename OtherInternalNode>
2430 struct A {
inline void operator()(W &tV,
const W& sV,
const W& tC)
const 2431 { tV = (tV | sV) & ~tC; }
2435 tbb::parallel_for(tbb::blocked_range<Index>(0,
NUM_VALUES), *
this);
2438 t->mChildMask |= s->mChildMask;
2440 t->mValueMask.foreach(s->mValueMask, t->mChildMask, op);
2441 assert((t->mValueMask & t->mChildMask).isOff());
2444 for (
Index i = r.begin(), end=r.end(); i!=end; ++i) {
2445 if (s->mChildMask.isOn(i)) {
2446 const typename OtherInternalNode::ChildNodeType& other = *(s->mNodes[i].getChild());
2447 if (t->mChildMask.isOn(i)) {
2448 t->mNodes[i].getChild()->topologyUnion(other);
2450 ChildT* child =
new ChildT(other, t->mNodes[i].getValue(),
TopologyCopy());
2452 t->mNodes[i].setChild(child);
2454 }
else if (s->mValueMask.isOn(i) && t->mChildMask.isOn(i)) {
2455 t->mNodes[i].getChild()->setValuesOn();
2459 const OtherInternalNode*
s;
2463 template<
typename ChildT, Index Log2Dim>
2464 template<
typename OtherChildT>
2471 template<
typename ChildT, Index Log2Dim>
2472 template<
typename OtherInternalNode>
2476 struct A {
inline void operator()(W &tC,
const W& sC,
const W& sV,
const W& tV)
const 2477 { tC = (tC & (sC | sV)) | (tV & sC); }
2480 const ValueType& background) : s(source), t(target), b(background) {
2482 tbb::parallel_for(tbb::blocked_range<Index>(0,
NUM_VALUES), *
this);
2486 t->mChildMask.foreach(s->mChildMask, s->mValueMask, t->mValueMask, op);
2488 t->mValueMask &= s->mValueMask;
2489 assert((t->mValueMask & t->mChildMask).isOff());
2492 for (
Index i = r.begin(), end=r.end(); i!=end; ++i) {
2493 if (t->mChildMask.isOn(i)) {
2494 ChildT* child = t->
mNodes[i].getChild();
2495 if (s->mChildMask.isOn(i)) {
2496 child->topologyIntersection(*(s->mNodes[i].getChild()), b);
2497 }
else if (s->mValueMask.isOff(i)) {
2499 t->mNodes[i].setValue(b);
2501 }
else if (t->mValueMask.isOn(i) && s->mChildMask.isOn(i)) {
2502 t->mNodes[i].setChild(
new ChildT(*(s->mNodes[i].getChild()),
2507 const OtherInternalNode*
s;
2512 template<
typename ChildT, Index Log2Dim>
2513 template<
typename OtherChildT>
2521 template<
typename ChildT, Index Log2Dim>
2522 template<
typename OtherInternalNode>
2526 struct A {
inline void operator()(W &tC,
const W& sC,
const W& sV,
const W& tV)
const 2527 { tC = (tC & (sC | ~sV)) | (tV & sC); }
2529 struct B {
inline void operator()(W &tV,
const W& sC,
const W& sV,
const W& tC)
const 2530 { tV &= ~((tC & sV) | (sC | sV)); }
2533 const ValueType& background) : s(source), t(target), b(background) {
2535 tbb::parallel_for(tbb::blocked_range<Index>(0,
NUM_VALUES), *
this);
2540 t->mChildMask.foreach(s->mChildMask, s->mValueMask, t->mValueMask, op1);
2543 t->mValueMask.foreach(t->mChildMask, s->mValueMask, oldChildMask, op2);
2544 assert((t->mValueMask & t->mChildMask).isOff());
2547 for (
Index i = r.begin(), end=r.end(); i!=end; ++i) {
2548 if (t->mChildMask.isOn(i)) {
2549 ChildT* child = t->
mNodes[i].getChild();
2550 if (s->mChildMask.isOn(i)) {
2551 child->topologyDifference(*(s->mNodes[i].getChild()), b);
2552 }
else if (s->mValueMask.isOn(i)) {
2554 t->mNodes[i].setValue(b);
2556 }
else if (t->mValueMask.isOn(i)) {
2557 if (s->mChildMask.isOn(i)) {
2558 const typename OtherInternalNode::ChildNodeType& other = *(s->mNodes[i].getChild());
2559 ChildT* child =
new ChildT(other.origin(), t->mNodes[i].getValue(),
true);
2561 t->mNodes[i].setChild(child);
2566 const OtherInternalNode*
s;
2571 template<
typename ChildT, Index Log2Dim>
2572 template<
typename OtherChildT>
2583 template<
typename ChildT, Index Log2Dim>
2584 template<
typename CombineOp>
2588 const ValueType zero = zeroVal<ValueType>();
2596 op(args.setARef(
mNodes[i].getValue())
2598 .setBRef(other.
mNodes[i].getValue())
2600 mNodes[i].setValue(args.result());
2622 other.
mNodes[i].setValue(zero);
2629 *child =
mNodes[i].getChild(),
2630 *otherChild = other.
mNodes[i].getChild();
2633 if (child && otherChild) {
2634 child->combine(*otherChild, op);
2641 template<
typename ChildT, Index Log2Dim>
2642 template<
typename CombineOp>
2654 .setBIsActive(valueIsActive));
2661 if (child) child->combine(value, valueIsActive, op);
2670 template<
typename ChildT, Index Log2Dim>
2671 template<
typename CombineOp,
typename OtherNodeType>
2682 .setBRef(other1.mNodes[i].getValue())
2683 .setBIsActive(other1.isValueMaskOn(i)));
2691 ? other0.
mNodes[i].getChild()->origin()
2692 : other1.mNodes[i].getChild()->origin();
2699 mNodes[i].getChild()->combine2(other0.
mNodes[i].getValue(),
2701 }
else if (other1.isChildMaskOff(i)) {
2704 mNodes[i].getChild()->combine2(*other0.
mNodes[i].getChild(),
2705 other1.mNodes[i].getValue(), other1.isValueMaskOn(i), op);
2709 mNodes[i].getChild()->combine2(*other0.
mNodes[i].getChild(),
2710 *other1.mNodes[i].getChild(), op);
2717 template<
typename ChildT, Index Log2Dim>
2718 template<
typename CombineOp,
typename OtherNodeType>
2721 bool valueIsActive, CombineOp& op)
2726 if (other.isChildMaskOff(i)) {
2728 .setAIsActive(valueIsActive)
2729 .setBRef(other.mNodes[i].getValue())
2730 .setBIsActive(other.isValueMaskOn(i)));
2735 typename OtherNodeType::ChildNodeType* otherChild = other.mNodes[i].getChild();
2744 mNodes[i].getChild()->combine2(value, *otherChild, valueIsActive, op);
2750 template<
typename ChildT, Index Log2Dim>
2751 template<
typename CombineOp,
typename OtherValueType>
2754 bool valueIsActive, CombineOp& op)
2763 .setBIsActive(valueIsActive));
2777 mNodes[i].getChild()->combine2(*otherChild, value, valueIsActive, op);
2786 template<
typename ChildT, Index Log2Dim>
2787 template<
typename BBoxOp>
2793 op.operator()<
LEVEL>(CoordBBox::createCube(i.getCoord(), ChildNodeType::DIM));
2795 op.template operator()<
LEVEL>(CoordBBox::createCube(i.getCoord(), ChildNodeType::DIM));
2798 if (op.template descent<LEVEL>()) {
2803 op.operator()<
LEVEL>(i->getNodeBoundingBox());
2805 op.template operator()<
LEVEL>(i->getNodeBoundingBox());
2812 template<
typename ChildT, Index Log2Dim>
2813 template<
typename VisitorOp>
2817 doVisit<InternalNode, VisitorOp, ChildAllIter>(*
this, op);
2821 template<
typename ChildT, Index Log2Dim>
2822 template<
typename VisitorOp>
2826 doVisit<const InternalNode, VisitorOp, ChildAllCIter>(*
this, op);
2830 template<
typename ChildT, Index Log2Dim>
2831 template<
typename NodeT,
typename VisitorOp,
typename ChildAllIterT>
2835 typename NodeT::ValueType val;
2836 for (ChildAllIterT iter =
self.
beginChildAll(); iter; ++iter) {
2837 if (op(iter))
continue;
2838 if (
typename ChildAllIterT::ChildNodeType* child = iter.probeChild(val)) {
2848 template<
typename ChildT, Index Log2Dim>
2849 template<
typename OtherNodeType,
typename VisitorOp>
2854 typename OtherNodeType::ChildAllIter>(*
this, other, op);
2858 template<
typename ChildT, Index Log2Dim>
2859 template<
typename OtherNodeType,
typename VisitorOp>
2864 typename OtherNodeType::ChildAllCIter>(*
this, other, op);
2868 template<
typename ChildT, Index Log2Dim>
2871 typename OtherNodeT,
2873 typename ChildAllIterT,
2874 typename OtherChildAllIterT>
2879 BOOST_STATIC_ASSERT(OtherNodeT::NUM_VALUES == NodeT::NUM_VALUES);
2880 BOOST_STATIC_ASSERT(OtherNodeT::LEVEL == NodeT::LEVEL);
2882 typename NodeT::ValueType val;
2883 typename OtherNodeT::ValueType otherVal;
2885 ChildAllIterT iter =
self.beginChildAll();
2886 OtherChildAllIterT otherIter = other.beginChildAll();
2888 for ( ; iter && otherIter; ++iter, ++otherIter)
2890 const size_t skipBranch =
static_cast<size_t>(op(iter, otherIter));
2892 typename ChildAllIterT::ChildNodeType* child =
2893 (skipBranch & 1U) ? NULL : iter.probeChild(val);
2894 typename OtherChildAllIterT::ChildNodeType* otherChild =
2895 (skipBranch & 2U) ? NULL : otherIter.probeChild(otherVal);
2897 if (child != NULL && otherChild != NULL) {
2898 child->visit2Node(*otherChild, op);
2899 }
else if (child != NULL) {
2900 child->visit2(otherIter, op);
2901 }
else if (otherChild != NULL) {
2902 otherChild->visit2(iter, op,
true);
2911 template<
typename ChildT, Index Log2Dim>
2912 template<
typename OtherChildAllIterType,
typename VisitorOp>
2915 VisitorOp& op,
bool otherIsLHS)
2917 doVisit2<InternalNode, VisitorOp, ChildAllIter, OtherChildAllIterType>(
2918 *
this, otherIter, op, otherIsLHS);
2922 template<
typename ChildT, Index Log2Dim>
2923 template<
typename OtherChildAllIterType,
typename VisitorOp>
2926 VisitorOp& op,
bool otherIsLHS)
const 2928 doVisit2<const InternalNode, VisitorOp, ChildAllCIter, OtherChildAllIterType>(
2929 *
this, otherIter, op, otherIsLHS);
2933 template<
typename ChildT, Index Log2Dim>
2934 template<
typename NodeT,
typename VisitorOp,
typename ChildAllIterT,
typename OtherChildAllIterT>
2937 VisitorOp& op,
bool otherIsLHS)
2939 if (!otherIter)
return;
2941 const size_t skipBitMask = (otherIsLHS ? 2U : 1U);
2943 typename NodeT::ValueType val;
2944 for (ChildAllIterT iter =
self.
beginChildAll(); iter; ++iter) {
2945 const size_t skipBranch =
static_cast<size_t>(
2946 otherIsLHS ? op(otherIter, iter) : op(iter, otherIter));
2948 typename ChildAllIterT::ChildNodeType* child =
2949 (skipBranch & skipBitMask) ? NULL : iter.probeChild(val);
2951 if (child != NULL) child->visit2(otherIter, op, otherIsLHS);
2959 template<
typename ChildT, Index Log2Dim>
2964 iter->writeBuffers(os, toHalf);
2969 template<
typename ChildT, Index Log2Dim>
2974 iter->readBuffers(is, fromHalf);
2979 template<
typename ChildT, Index Log2Dim>
2982 const CoordBBox& clipBBox,
bool fromHalf)
2989 iter->readBuffers(is, clipBBox, fromHalf);
2993 ValueType background = zeroVal<ValueType>();
2995 background = *
static_cast<const ValueType*
>(bgPtr);
2997 this->
clip(clipBBox, background);
3004 template<
typename ChildT, Index Log2Dim>
3008 dims.push_back(Log2Dim);
3009 ChildNodeType::getNodeLog2Dims(dims);
3013 template<
typename ChildT, Index Log2Dim>
3017 assert(n<(1<<3*Log2Dim));
3018 xyz.setX(n >> 2*Log2Dim);
3019 n &= ((1<<2*Log2Dim)-1);
3020 xyz.setY(n >> Log2Dim);
3021 xyz.setZ(n & ((1<<Log2Dim)-1));
3025 template<
typename ChildT, Index Log2Dim>
3029 return (((xyz[0] & (
DIM-1u)) >> ChildNodeType::TOTAL) << 2*Log2Dim)
3030 + (((xyz[1] & (
DIM-1u)) >> ChildNodeType::TOTAL) << Log2Dim)
3031 + ((xyz[2] & (
DIM-1u)) >> ChildNodeType::TOTAL);
3035 template<
typename ChildT, Index Log2Dim>
3041 local <<= ChildT::TOTAL;
3042 return local + this->
origin();
3047 template<
typename ChildT, Index Log2Dim>
3048 template<
typename ArrayT>
3052 typedef typename ArrayT::value_type T;
3053 BOOST_STATIC_ASSERT(boost::is_pointer<T>::value);
3054 typedef typename boost::mpl::if_<boost::is_const<typename boost::remove_pointer<T>::type>,
3055 const ChildT, ChildT>::type ArrayChildT;
3058 if (boost::is_same<T, ArrayChildT*>::value) {
3059 array.push_back(reinterpret_cast<T>(
mNodes[iter.pos()].getChild()));
3061 iter->getNodes(array);
3067 template<
typename ChildT, Index Log2Dim>
3068 template<
typename ArrayT>
3072 typedef typename ArrayT::value_type T;
3073 BOOST_STATIC_ASSERT(boost::is_pointer<T>::value);
3074 BOOST_STATIC_ASSERT(boost::is_const<
typename boost::remove_pointer<T>::type>::value);
3077 if (boost::is_same<T, const ChildT*>::value) {
3078 array.push_back(reinterpret_cast<T>(
mNodes[iter.pos()].getChild()));
3080 iter->getNodes(array);
3088 template<
typename ChildT, Index Log2Dim>
3089 template<
typename ArrayT>
3093 typedef typename ArrayT::value_type T;
3094 BOOST_STATIC_ASSERT(boost::is_pointer<T>::value);
3095 typedef typename boost::mpl::if_<boost::is_const<typename boost::remove_pointer<T>::type>,
3096 const ChildT, ChildT>::type ArrayChildT;
3099 const Index n = iter.pos();
3100 if (boost::is_same<T, ArrayChildT*>::value) {
3101 array.push_back(reinterpret_cast<T>(
mNodes[n].getChild()));
3103 mNodes[n].setValue(value);
3105 iter->stealNodes(array, value, state);
3115 template<
typename ChildT, Index Log2Dim>
3123 mNodes[i].getChild()->resetBackground(oldBackground, newBackground);
3126 mNodes[i].setValue(newBackground);
3134 template<
typename ChildT, Index Log2Dim>
3135 template<
typename OtherChildNodeType, Index OtherLog2Dim>
3143 if (!iter->hasSameTopology(other->
mNodes[iter.pos()].getChild()))
return false;
3149 template<
typename ChildT, Index Log2Dim>
3155 delete mNodes[i].getChild();
3160 mNodes[i].setChild(child);
3163 template<
typename ChildT, Index Log2Dim>
3171 mNodes[i].setChild(child);
3175 template<
typename ChildT, Index Log2Dim>
3180 mNodes[i].setValue(value);
3185 mNodes[i].setValue(value);
3190 template<
typename ChildT, Index Log2Dim>
3197 template<
typename ChildT, Index Log2Dim>
3202 return mNodes[n].getChild();
3206 template<
typename ChildT, Index Log2Dim>
3207 inline const ChildT*
3211 return mNodes[n].getChild();
3218 #endif // OPENVDB_TREE_INTERNALNODE_HAS_BEEN_INCLUDED ChildT & getItem(Index pos) const
Definition: InternalNode.h:167
bool isConstant(bool &isOn) const
Definition: NodeMasks.h:523
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:2018
ChildIter< const InternalNode, const ChildNodeType, MaskOnIterator, ChildOn > ChildOnCIter
Definition: InternalNode.h:240
ValueOffCIter cbeginValueOff() const
Definition: InternalNode.h:265
Definition: InternalNode.h:203
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:3050
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:2072
const OtherInternalNode * s
Definition: InternalNode.h:2459
void visit(VisitorOp &)
Definition: InternalNode.h:2815
Index32 countOff() const
Return the total number of on bits.
Definition: NodeMasks.h:447
const OtherInternalNode * s
Definition: InternalNode.h:2566
bool isExactlyEqual(const T0 &a, const T1 &b)
Return true if a is exactly equal to b.
Definition: Math.h:407
InternalNode * t
Definition: InternalNode.h:957
ValueIter< InternalNode, const ValueType, MaskOffIterator, ValueOff > ValueOffIter
Definition: InternalNode.h:248
Vec2< T > minComponent(const Vec2< T > &v1, const Vec2< T > &v2)
Return component-wise minimum of the two vectors.
Definition: Vec2.h:519
ValueOnCIter cbeginValueOn() const
Definition: InternalNode.h:263
const ValueType & getValueAndCache(const Coord &xyz, AccessorT &) const
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:3137
InternalNode * t
Definition: InternalNode.h:2567
Definition: InternalNode.h:2526
void writeTopology(std::ostream &, bool toHalf=false) const
Definition: InternalNode.h:2115
void load(std::istream &is)
Definition: NodeMasks.h:566
TopologyDifference(const OtherInternalNode *source, InternalNode *target, const ValueType &background)
Definition: InternalNode.h:2532
void resetChildNode(Index i, ChildNodeType *child)
Definition: InternalNode.h:3151
ChildIter(const MaskIterT &iter, NodeT *parent)
Definition: InternalNode.h:164
Definition: InternalNode.h:824
VoxelizeActiveTiles(InternalNode &node)
Definition: InternalNode.h:2245
static void doVisit2(NodeT &, OtherChildAllIterT &, VisitorOp &, bool otherIsLHS)
Definition: InternalNode.h:2936
bool isValueOn(Index offset) const
Return true if the voxel at the given offset is active.
Definition: InternalNode.h:359
ChildOnCIter cbeginChildOn() const
Definition: InternalNode.h:253
Definition: InternalNode.h:153
ChildNodeType * unsetChildNode(Index i, const ValueType &value)
Definition: InternalNode.h:3177
Definition: InternalNode.h:153
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:1141
static Index getLevel()
Definition: InternalNode.h:282
CombineArgs & setARef(const AValueType &a)
Redirect the A value to a new external source.
Definition: Types.h:365
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:1313
ValueOnCIter beginValueOn() const
Definition: InternalNode.h:267
NodeMaskType mChildMask
Definition: InternalNode.h:832
static Index dim()
Definition: InternalNode.h:279
Coord offsetToGlobalCoord(Index n) const
Return the global coordinates for a linear table offset.
Definition: InternalNode.h:3037
bool isValueMaskOn() const
Definition: InternalNode.h:773
bool isChildMaskOff() const
Definition: InternalNode.h:778
const ValueType & b
Definition: InternalNode.h:2568
bool isConstant(ValueType &firstValue, bool &state, const ValueType &tolerance=zeroVal< ValueType >()) const
Definition: InternalNode.h:1486
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:3006
ChildNodeType::ValueType ValueType
Definition: InternalNode.h:69
bool probeValue(const Coord &xyz, ValueType &value) const
Definition: InternalNode.h:1611
void modifyValueAndActiveStateAndCache(const Coord &xyz, const ModifyOp &op, AccessorT &)
Definition: InternalNode.h:1937
bool isChildMaskOff(Index n) const
Definition: InternalNode.h:777
const OtherInternalNode * s
Definition: InternalNode.h:992
InternalNode * t
Definition: InternalNode.h:911
Index64 onTileCount() const
Definition: InternalNode.h:1099
Index32 nonLeafCount() const
Definition: InternalNode.h:1039
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:2290
ChildAllIter beginChildAll()
Definition: InternalNode.h:261
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:2216
TopologyCopy1(const OtherInternalNode *source, InternalNode *target, const ValueType &background)
Definition: InternalNode.h:941
ValueIter()
Definition: InternalNode.h:184
ValueIter< InternalNode, const ValueType, MaskOnIterator, ValueOn > ValueOnIter
Definition: InternalNode.h:246
SameConfiguration<OtherNodeType>::value is true if and only if OtherNodeType is the type of an Intern...
Definition: InternalNode.h:95
DenseIter()
Definition: InternalNode.h:209
Definition: InternalNode.h:152
bool isValueMaskOn(Index n) const
Definition: InternalNode.h:772
const UnionType * getTable() const
Definition: InternalNode.h:788
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 modifyValueAndActiveState(const Coord &xyz, const ModifyOp &op)
Apply a functor to the voxel at the given coordinates.
Definition: InternalNode.h:1914
void operator()(const tbb::blocked_range< Index > &r) const
Definition: InternalNode.h:2443
Index64 onVoxelCount() const
Definition: InternalNode.h:1052
DenseIter< InternalNode, ChildNodeType, ValueType, ChildAll > ChildAllIter
Definition: InternalNode.h:243
ValueAllCIter cbeginValueAll() const
Definition: InternalNode.h:266
Definition: InternalNode.h:152
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:1598
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.
Definition: InternalNode.h:2529
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
void visit2(IterT &otherIter, VisitorOp &, bool otherIsLHS=false)
Index32 Index
Definition: Types.h:58
void toggle(Index32 n)
Toggle the state of the nth bit.
Definition: NodeMasks.h:480
TopologyUnion(const OtherInternalNode *source, InternalNode *target)
Definition: InternalNode.h:2433
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:1165
ChildOnIter beginChildOn()
Definition: InternalNode.h:259
void operator()(const tbb::blocked_range< Index > &r) const
Definition: InternalNode.h:982
NodeMaskType::OffIterator MaskOffIterator
Definition: InternalNode.h:148
NodeMaskType::OnIterator MaskOnIterator
Definition: InternalNode.h:147
int32_t Int32
Definition: Types.h:60
void operator()(const tbb::blocked_range< Index > &r) const
Definition: InternalNode.h:2491
void readBuffers(std::istream &, bool fromHalf=false)
Definition: InternalNode.h:2971
uint64_t Index64
Definition: Types.h:57
InternalNode * mNode
Definition: InternalNode.h:2265
ChildOffCIter beginChildOff() const
Definition: InternalNode.h:257
NodeUnion< ValueType, ChildNodeType > UnionType
Definition: InternalNode.h:71
void operator()(const tbb::blocked_range< Index > &r) const
Definition: InternalNode.h:2252
Definition: InternalNode.h:827
NodeMaskType::Word W
Definition: InternalNode.h:2525
const ValueType & b
Definition: InternalNode.h:2509
#define OPENVDB_VERSION_NAME
Definition: version.h:43
void setItem(Index pos, const ValueT &v) const
Definition: InternalNode.h:191
void operator()(W &tV, const W &sC, const W &sV, const W &tC) const
Definition: InternalNode.h:2529
static Index coordToOffset(const Coord &xyz)
Return the linear table offset of the given global or local coordinates.
Definition: InternalNode.h:3027
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:1342
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...
const AValueType & result() const
Get the output value.
Definition: Types.h:357
bool isChildMaskOn(Index n) const
Definition: InternalNode.h:776
void readCompressedValues(std::istream &is, ValueT *destBuf, Index destCount, const MaskT &valueMask, bool fromHalf)
Definition: Compression.h:329
bool isOn(Index32 n) const
Return true if the nth bit is on.
Definition: NodeMasks.h:499
const NodeMaskType & getChildMask() const
Definition: InternalNode.h:780
const ValueT & getItem(Index pos) const
Definition: InternalNode.h:188
Definition: InternalNode.h:64
const ValueType & getValue(const Coord &xyz) const
Definition: InternalNode.h:1566
static void doVisit(NodeT &, VisitorOp &)
Definition: InternalNode.h:2833
void operator()(const tbb::blocked_range< Index > &r) const
Definition: InternalNode.h:2546
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...
NodeType * probeNodeAndCache(const Coord &xyz, AccessorT &)
Same as probeNode() except, if necessary, update the accessor with pointers to the nodes along the pa...
Definition: version.h:110
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:3117
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:1267
bool isValueOn(const Coord &xyz) const
Return true if the voxel at the given coordinates is active.
Definition: InternalNode.h:1545
_ChildNodeType ChildNodeType
Definition: InternalNode.h:67
bool isInactive() const
Return true if this node has no children and only contains inactive values.
Definition: InternalNode.h:354
Definition: InternalNode.h:181
Definition: InternalNode.h:2430
void setActiveStateAndCache(const Coord &xyz, bool on, AccessorT &)
Definition: InternalNode.h:1817
TopologyCopy2(const OtherInternalNode *source, InternalNode *target, const ValueType &offValue, const ValueType &onValue)
Definition: InternalNode.h:977
Index32 countOn() const
Return the total number of on bits.
Definition: NodeMasks.h:440
ChildOnCIter beginChildOn() const
Definition: InternalNode.h:256
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
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:1852
ValueIter< const InternalNode, const ValueType, MaskOffIterator, ChildOff > ChildOffCIter
Definition: InternalNode.h:242
InternalNode * t
Definition: InternalNode.h:2508
InternalNode * t
Definition: InternalNode.h:993
OPENVDB_API uint32_t getFormatVersion(std::ios_base &)
Return the file format version number associated with the given input stream.
void visitActiveBBox(BBoxOp &) const
Calls the templated functor BBoxOp with bounding box information for all active tiles and leaf nodes ...
Definition: InternalNode.h:2789
Index64 offVoxelCount() const
Definition: InternalNode.h:1064
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:3015
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.
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: InternalNode.h:1655
void writeCompressedValues(std::ostream &os, ValueT *srcBuf, Index srcCount, const MaskT &valueMask, const MaskT &childMask, bool toHalf)
Definition: Compression.h:431
NodeMaskType::Word W
Definition: InternalNode.h:2429
ValueOffCIter beginValueOff() const
Definition: InternalNode.h:269
void operator()(W &tC, const W &sC, const W &sV, const W &tV) const
Definition: InternalNode.h:2476
const Coord & origin() const
Return the grid index coordinates of this node's local origin.
Definition: InternalNode.h:300
Definition: Exceptions.h:39
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:1123
UnionType mNodes[NUM_VALUES]
Definition: InternalNode.h:828
void setValueAndCache(const Coord &xyz, const ValueType &value, AccessorT &)
Definition: InternalNode.h:1736
uint32_t Index32
Definition: Types.h:56
NodeMaskType mValueMask
Definition: InternalNode.h:832
ValueConverter<T>::Type is the type of an InternalNode having the same child hierarchy and dimensions...
Definition: InternalNode.h:86
const OtherInternalNode * s
Definition: InternalNode.h:910
void setChildNode(Index i, ChildNodeType *child)
Definition: InternalNode.h:3165
void setItem(Index pos, const ChildT &c) const
Definition: InternalNode.h:174
Index64 Word
Definition: NodeMasks.h:313
bool probeValueAndCache(const Coord &xyz, ValueType &value, AccessorT &) const
Definition: InternalNode.h:1624
ValueIter< InternalNode, const ValueType, MaskOffIterator, ValueAll > ValueAllIter
Definition: InternalNode.h:250
Index32 leafCount() const
Definition: InternalNode.h:1026
NodeMaskType::DenseIterator MaskDenseIterator
Definition: InternalNode.h:149
void visit2Node(OtherNodeType &other, VisitorOp &)
Definition: InternalNode.h:2851
void unsetItem(Index pos, const ValueT &value) const
Definition: InternalNode.h:231
Base class for dense iterators over internal and leaf nodes.
Definition: Iterator.h:211
Definition: InternalNode.h:60
Base class for sparse iterators over internal and leaf nodes.
Definition: Iterator.h:148
void setValuesOn()
Mark all values (both tiles and voxels) as active.
Definition: InternalNode.h:1840
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...
DenseIteratorBase< MaskDenseIterator, DenseIter, NodeT, ChildT, ValueT > BaseT
Definition: InternalNode.h:206
boost::remove_const< UnsetItemT >::type NonConstValueType
Definition: Iterator.h:217
void set(Index32 n, bool On)
Set the nth bit to the specified state.
Definition: NodeMasks.h:459
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:1798
ValueOffIter beginValueOff()
Definition: InternalNode.h:273
ChildNodeType * getChildNode(Index n)
Returns a pointer to the child node at the linear offset n.
Definition: InternalNode.h:3199
bool isOff(Index32 n) const
Return true if the nth bit is off.
Definition: NodeMasks.h:505
static Index32 memUsage()
Return the byte size of this NodeMask.
Definition: NodeMasks.h:438
Definition: NodeMasks.h:267
Definition: InternalNode.h:823
Coord mOrigin
Global grid index coordinates (x,y,z) of the local origin of this node.
Definition: InternalNode.h:834
ChildIter()
Definition: InternalNode.h:163
Definition: InternalNode.h:828
Definition: InternalNode.h:2476
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.
void clip(const CoordBBox &, const ValueType &background)
Set all voxels that lie outside the given axis-aligned box to the background.
Definition: InternalNode.h:1968
void setOn(Index32 n)
Set the nth bit on.
Definition: NodeMasks.h:449
const OtherInternalNode * s
Definition: InternalNode.h:956
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:3091
ChildOffIter beginChildOff()
Definition: InternalNode.h:260
Definition: version.h:101
static void doVisit2Node(NodeT &, OtherNodeT &, VisitorOp &)
Definition: InternalNode.h:2876
bool isValueMaskOff() const
Definition: InternalNode.h:775
ChildNodeType::LeafNodeType LeafNodeType
Definition: InternalNode.h:68
Index64 offLeafVoxelCount() const
Definition: InternalNode.h:1088
Index64 onLeafVoxelCount() const
Definition: InternalNode.h:1076
ValueIter< const InternalNode, const ValueType, MaskOnIterator, ValueOn > ValueOnCIter
Definition: InternalNode.h:247
void setValueOnlyAndCache(const Coord &xyz, const ValueType &value, AccessorT &)
Definition: InternalNode.h:1777
InternalNode()
Default constructor.
Definition: InternalNode.h:103
static Index getChildDim()
Definition: InternalNode.h:289
void negate()
Definition: InternalNode.h:2228
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:2208
void setValueOffAndCache(const Coord &xyz, const ValueType &value, AccessorT &)
Definition: InternalNode.h:1691
bool getItem(Index pos, ChildT *&child, NonConstValueT &value) const
Definition: InternalNode.h:213
NodeMaskType getValueOffMask() const
Definition: InternalNode.h:781
util::NodeMask< Log2Dim > NodeMaskType
Definition: InternalNode.h:72
ChildIter< InternalNode, ChildNodeType, MaskOnIterator, ChildOn > ChildOnIter
Definition: InternalNode.h:239
ValueOnIter beginValueOn()
Definition: InternalNode.h:271
const OtherInternalNode * s
Definition: InternalNode.h:2507
static const Index DIM
Definition: InternalNode.h:77
void setItem(Index pos, ChildT *child) const
Definition: InternalNode.h:225
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:1880
void combine(InternalNode &other, CombineOp &)
Definition: InternalNode.h:2586
Definition: InternalNode.h:160
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:1417
void setOff(Index32 n)
Set the nth bit off.
Definition: NodeMasks.h:454
void modifyItem(Index pos, const ModifyOp &op) const
Definition: InternalNode.h:195
void operator()(const tbb::blocked_range< Index > &r) const
Definition: InternalNode.h:901
ChildNodeType::BuildType BuildType
Definition: InternalNode.h:70
ValueIter< const InternalNode, const ValueType, MaskOffIterator, ValueOff > ValueOffCIter
Definition: InternalNode.h:249
void operator()(W &tC, const W &sC, const W &sV, const W &tV) const
Definition: InternalNode.h:2526
void setValueOff(const Coord &xyz)
Mark the voxel at the given coordinates as inactive but don't change its value.
Definition: InternalNode.h:1639
NodeMaskType::Word W
Definition: InternalNode.h:2475
TopologyIntersection(const OtherInternalNode *source, InternalNode *target, const ValueType &background)
Definition: InternalNode.h:2479
void makeChildNodeEmpty(Index n, const ValueType &value)
Definition: InternalNode.h:3192
DenseIter< const InternalNode, const ChildNodeType, ValueType, ChildAll > ChildAllCIter
Definition: InternalNode.h:244
Definition: InternalNode.h:826
ChildOffCIter cbeginChildOff() const
Definition: InternalNode.h:254
DenseIter(const MaskDenseIterator &iter, NodeT *parent)
Definition: InternalNode.h:210
Definition: InternalNode.h:2243
void writeBuffers(std::ostream &, bool toHalf=false) const
Definition: InternalNode.h:2961
void voxelizeActiveTiles(bool threaded=true)
Densify active tiles, i.e., replace them with leaf-level active voxels.
Definition: InternalNode.h:2270
Definition: NodeMasks.h:205
bool isValueOnAndCache(const Coord &xyz, AccessorT &) const
Definition: InternalNode.h:1555
InternalNode * t
Definition: InternalNode.h:2460
ChildAllCIter beginChildAll() const
Definition: InternalNode.h:258
Definition: NodeMasks.h:236
T negative(const T &val)
Return the unary negation of the given value.
Definition: Math.h:116
BaseT::NonConstValueType NonConstValueT
Definition: InternalNode.h:207
NodeType * probeNode(const Coord &xyz)
Return a pointer to the node that contains voxel (x, y, z). If no such node exists, return NULL.
static const Index LEVEL
Definition: InternalNode.h:79
ValueIter(const MaskIterT &iter, NodeT *parent)
Definition: InternalNode.h:185
ValueIter< InternalNode, const ValueType, MaskOffIterator, ChildOff > ChildOffIter
Definition: InternalNode.h:241
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h:71
Definition: InternalNode.h:153
const NodeMaskType & getValueMask() const
Definition: InternalNode.h:779
ValueIter< const InternalNode, const ValueType, MaskOffIterator, ValueAll > ValueAllCIter
Definition: InternalNode.h:251
void operator()(W &tV, const W &sV, const W &tC) const
Definition: InternalNode.h:2430
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:1385
void save(std::ostream &os) const
Definition: NodeMasks.h:562
Index64 memUsage() const
Return the total amount of memory in bytes occupied by this node and its children.
Definition: InternalNode.h:1110
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:1760
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:1453
bool isEmpty() const
Definition: InternalNode.h:326
virtual ~InternalNode()
Definition: InternalNode.h:1013
const ValueType & b
Definition: InternalNode.h:958
bool hasActiveTiles() const
Return true if this node or any of its child nodes have any active tiles.
Definition: InternalNode.h:1530
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:1589
This struct collects both input and output arguments to "grid combiner" functors used with the tree::...
Definition: Types.h:312
bool resultIsActive() const
Definition: Types.h:376
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:1293
Definition: InternalNode.h:825
Definition: InternalNode.h:152
const ValueType & onV
Definition: InternalNode.h:994
LeafNodeType * touchLeafAndCache(const Coord &xyz, AccessorT &)
Same as touchLeaf() except, if necessary, update the accessor with pointers to the nodes along the pa...
ValueAllCIter beginValueAll() const
Definition: InternalNode.h:270
LeafNodeType * probeLeafAndCache(const Coord &xyz, AccessorT &acc)
Same as probeLeaf() except, if necessary, update the accessor with pointers to the nodes along the pa...
void combine2(const InternalNode &other0, const OtherNodeType &other1, CombineOp &)
Definition: InternalNode.h:2673
DeepCopy(const OtherInternalNode *source, InternalNode *target)
Definition: InternalNode.h:897
void operator()(const tbb::blocked_range< Index > &r) const
Definition: InternalNode.h:946
void readTopology(std::istream &, bool fromHalf=false)
Definition: InternalNode.h:2139
ValueAllIter beginValueAll()
Definition: InternalNode.h:274
Base class for iterators over internal and leaf nodes.
Definition: Iterator.h:58
bool isValueMaskOff(Index n) const
Definition: InternalNode.h:774
ChildAllCIter cbeginChildAll() const
Definition: InternalNode.h:255