37 #ifndef OPENVDB_TREE_INTERNALNODE_HAS_BEEN_INCLUDED 38 #define OPENVDB_TREE_INTERNALNODE_HAS_BEEN_INCLUDED 40 #include <boost/shared_array.hpp> 41 #include <boost/static_assert.hpp> 42 #include <boost/mpl/if.hpp> 43 #include <boost/type_traits/is_const.hpp> 44 #include <boost/type_traits/is_pointer.hpp> 45 #include <boost/type_traits/remove_pointer.hpp> 46 #include <tbb/parallel_for.h> 47 #include <openvdb/Platform.h> 48 #include <openvdb/util/NodeMasks.h> 49 #include <openvdb/io/Compression.h> 50 #include <openvdb/math/Math.h> 51 #include <openvdb/version.h> 52 #include <openvdb/Types.h> 65 template<
typename _ChildNodeType, Index Log2Dim>
71 typedef typename ChildNodeType::ValueType
ValueType;
77 TOTAL = Log2Dim + ChildNodeType::TOTAL,
79 NUM_VALUES = 1 << (3 * Log2Dim),
80 LEVEL = 1 + ChildNodeType::LEVEL;
82 NUM_VOXELS = uint64_t(1) << (3 * TOTAL);
86 template<
typename OtherValueType>
95 template<
typename OtherNodeType>
97 static const bool value =
106 InternalNode(
const Coord&,
const ValueType& fillValue,
bool active =
false);
108 #ifndef OPENVDB_2_ABI_COMPATIBLE 120 template<
typename OtherChildNodeType>
126 template<
typename OtherChildNodeType>
133 template<
typename OtherChildNodeType>
135 const ValueType& offValue,
const ValueType& onValue,
TopologyCopy);
151 template<
typename NodeT,
typename ChildT,
typename MaskIterT,
typename TagT>
153 MaskIterT, ChildIter<NodeT, ChildT, MaskIterT, TagT>, NodeT, ChildT>
157 MaskIterT,
ChildIter<NodeT, ChildT, MaskIterT, TagT>, NodeT, ChildT>(iter, parent) {}
161 assert(this->parent().isChildMaskOn(pos));
162 return *(this->parent().getChildNode(pos));
166 void setItem(
Index pos,
const ChildT& c)
const { this->parent().resetChildNode(pos, &c); }
171 template<
typename NodeT,
typename ValueT,
typename MaskIterT,
typename TagT>
173 MaskIterT, ValueIter<NodeT, ValueT, MaskIterT, TagT>, NodeT, ValueT>
177 MaskIterT,
ValueIter<NodeT, ValueT, MaskIterT, TagT>, NodeT, ValueT>(iter, parent) {}
179 const ValueT&
getItem(
Index pos)
const {
return this->parent().mNodes[pos].getValue(); }
182 void setItem(
Index pos,
const ValueT& v)
const { this->parent().mNodes[pos].setValue(v); }
185 template<
typename ModifyOp>
188 op(this->parent().mNodes[pos].getValue());
192 template<
typename NodeT,
typename ChildT,
typename ValueT,
typename TagT>
194 MaskDenseIterator, DenseIter<NodeT, ChildT, ValueT, TagT>, NodeT, ChildT, ValueT>
200 DenseIter(
const MaskDenseIterator& iter, NodeT* parent):
205 if (this->parent().isChildMaskOn(pos)) {
206 child = this->parent().getChildNode(pos);
210 value = this->parent().mNodes[pos].getValue();
217 this->parent().resetChildNode(pos, child);
223 this->parent().unsetChildNode(pos, value);
243 ChildOnCIter
cbeginChildOn()
const {
return ChildOnCIter(mChildMask.beginOn(),
this); }
244 ChildOffCIter
cbeginChildOff()
const {
return ChildOffCIter(mChildMask.beginOff(),
this); }
245 ChildAllCIter
cbeginChildAll()
const {
return ChildAllCIter(mChildMask.beginDense(),
this); }
249 ChildOnIter
beginChildOn() {
return ChildOnIter(mChildMask.beginOn(),
this); }
250 ChildOffIter
beginChildOff() {
return ChildOffIter(mChildMask.beginOff(),
this); }
251 ChildAllIter
beginChildAll() {
return ChildAllIter(mChildMask.beginDense(),
this); }
253 ValueOnCIter
cbeginValueOn()
const {
return ValueOnCIter(mValueMask.beginOn(),
this); }
255 ValueOffCIter
cbeginValueOff()
const {
return ValueOffCIter(mValueMask.beginOff(),
this); }
256 ValueAllCIter
cbeginValueAll()
const {
return ValueAllCIter(mChildMask.beginOff(),
this); }
261 ValueOnIter
beginValueOn() {
return ValueOnIter(mValueMask.beginOn(),
this); }
263 ValueOffIter
beginValueOff() {
return ValueOffIter(mValueMask.beginOff(),
this); }
264 ValueAllIter
beginValueAll() {
return ValueAllIter(mChildMask.beginOff(),
this); }
269 static void getNodeLog2Dims(std::vector<Index>& dims);
273 static Index coordToOffset(
const Coord& xyz);
276 static void offsetToLocalCoord(
Index n, Coord& xyz);
278 Coord offsetToGlobalCoord(
Index n)
const;
281 const Coord&
origin()
const {
return mOrigin; }
283 void setOrigin(
const Coord& origin) { mOrigin = origin; }
289 Index64 onLeafVoxelCount()
const;
290 Index64 offLeafVoxelCount()
const;
300 void evalActiveBoundingBox(CoordBBox& bbox,
bool visitVoxels =
true)
const;
306 bool isEmpty()
const {
return mChildMask.isOff(); }
313 bool isConstant(ValueType& constValue,
bool& state,
314 const ValueType& tolerance = zeroVal<ValueType>())
const;
330 bool isConstant(ValueType& minValue, ValueType& maxValue,
331 bool& state,
const ValueType& tolerance = zeroVal<ValueType>())
const;
334 bool isInactive()
const {
return this->isChildMaskOff() && this->isValueMaskOff(); }
337 bool isValueOn(
const Coord& xyz)
const;
342 bool hasActiveTiles()
const;
344 const ValueType& getValue(
const Coord& xyz)
const;
345 bool probeValue(
const Coord& xyz, ValueType& value)
const;
349 Index getValueLevel(
const Coord& xyz)
const;
353 const ValueType& getFirstValue()
const;
356 const ValueType& getLastValue()
const;
359 void setActiveState(
const Coord& xyz,
bool on);
361 void setValueOnly(
const Coord& xyz,
const ValueType& value);
363 void setValueOn(
const Coord& xyz);
365 void setValueOn(
const Coord& xyz,
const ValueType& value);
367 void setValueOff(
const Coord& xyz);
369 void setValueOff(
const Coord& xyz,
const ValueType& value);
373 template<
typename ModifyOp>
374 void modifyValue(
const Coord& xyz,
const ModifyOp& op);
376 template<
typename ModifyOp>
377 void modifyValueAndActiveState(
const Coord& xyz,
const ModifyOp& op);
383 template<
typename AccessorT>
384 const ValueType& getValueAndCache(
const Coord& xyz, AccessorT&)
const;
390 template<
typename AccessorT>
391 bool isValueOnAndCache(
const Coord& xyz, AccessorT&)
const;
397 template<
typename AccessorT>
398 void setValueAndCache(
const Coord& xyz,
const ValueType& value, AccessorT&);
404 template<
typename AccessorT>
405 void setValueOnlyAndCache(
const Coord& xyz,
const ValueType& value, AccessorT&);
412 template<
typename ModifyOp,
typename AccessorT>
413 void modifyValueAndCache(
const Coord& xyz,
const ModifyOp& op, AccessorT&);
419 template<
typename ModifyOp,
typename AccessorT>
420 void modifyValueAndActiveStateAndCache(
const Coord& xyz,
const ModifyOp& op, AccessorT&);
426 template<
typename AccessorT>
427 void setValueOffAndCache(
const Coord& xyz,
const ValueType& value, AccessorT&);
433 template<
typename AccessorT>
434 void setActiveStateAndCache(
const Coord& xyz,
bool on, AccessorT&);
441 template<
typename AccessorT>
442 bool probeValueAndCache(
const Coord& xyz, ValueType& value, AccessorT&)
const;
450 template<
typename AccessorT>
451 Index getValueLevelAndCache(
const Coord& xyz, AccessorT&)
const;
459 void writeTopology(std::ostream&,
bool toHalf =
false)
const;
460 void readTopology(std::istream&,
bool fromHalf =
false);
461 void writeBuffers(std::ostream&,
bool toHalf =
false)
const;
462 void readBuffers(std::istream&,
bool fromHalf =
false);
463 void readBuffers(std::istream&,
const CoordBBox&,
bool fromHalf =
false);
471 void fill(
const CoordBBox& bbox,
const ValueType&,
bool active =
true);
478 void voxelizeActiveTiles();
487 template<
typename DenseT>
488 void copyToDense(
const CoordBBox& bbox, DenseT& dense)
const;
492 template<MergePolicy Policy>
493 void merge(
InternalNode& other,
const ValueType& background,
const ValueType& otherBackground);
497 template<MergePolicy Policy>
void merge(
const ValueType& tileValue,
bool tileActive);
511 template<
typename OtherChildNodeType>
527 template<
typename OtherChildNodeType>
529 const ValueType& background);
542 template<
typename OtherChildNodeType>
544 const ValueType& background);
546 template<
typename CombineOp>
548 template<
typename CombineOp>
549 void combine(
const ValueType& value,
bool valueIsActive, CombineOp&);
551 template<
typename CombineOp,
typename OtherNodeType >
552 void combine2(
const InternalNode& other0,
const OtherNodeType& other1, CombineOp&);
553 template<
typename CombineOp,
typename OtherNodeType >
554 void combine2(
const ValueType& value,
const OtherNodeType& other,
bool valIsActive, CombineOp&);
555 template<
typename CombineOp,
typename OtherValueType>
556 void combine2(
const InternalNode& other,
const OtherValueType&,
bool valIsActive, CombineOp&);
563 template<
typename BBoxOp>
void visitActiveBBox(BBoxOp&)
const;
565 template<
typename VisitorOp>
void visit(VisitorOp&);
566 template<
typename VisitorOp>
void visit(VisitorOp&)
const;
568 template<
typename OtherNodeType,
typename VisitorOp>
569 void visit2Node(OtherNodeType& other, VisitorOp&);
570 template<
typename OtherNodeType,
typename VisitorOp>
571 void visit2Node(OtherNodeType& other, VisitorOp&)
const;
572 template<
typename IterT,
typename VisitorOp>
573 void visit2(IterT& otherIter, VisitorOp&,
bool otherIsLHS =
false);
574 template<
typename IterT,
typename VisitorOp>
575 void visit2(IterT& otherIter, VisitorOp&,
bool otherIsLHS =
false)
const;
578 void clip(
const CoordBBox&,
const ValueType& background);
583 void prune(
const ValueType& tolerance = zeroVal<ValueType>());
587 void addLeaf(LeafNodeType* leaf);
591 template<
typename AccessorT>
592 void addLeafAndCache(LeafNodeType* leaf, AccessorT&);
602 template<
typename NodeT>
603 NodeT* stealNode(
const Coord& xyz,
const ValueType& value,
bool state);
607 void addTile(
Index level,
const Coord& xyz,
const ValueType& value,
bool state);
610 void addTile(
Index offset,
const ValueType& value,
bool state);
614 template<
typename AccessorT>
615 void addTileAndCache(
Index level,
const Coord& xyz,
const ValueType&,
bool state, AccessorT&);
618 template<
typename NodeType> NodeType* probeNode(
const Coord& xyz);
621 template<
typename NodeType>
const NodeType* probeConstNode(
const Coord& xyz)
const;
625 template<
typename NodeType,
typename AccessorT>
628 NodeType* probeNodeAndCache(
const Coord& xyz, AccessorT&);
629 template<
typename NodeType,
typename AccessorT>
630 const NodeType* probeConstNodeAndCache(
const Coord& xyz, AccessorT&)
const;
634 LeafNodeType* probeLeaf(
const Coord& xyz);
637 const LeafNodeType* probeConstLeaf(
const Coord& xyz)
const;
638 const LeafNodeType* probeLeaf(
const Coord& xyz)
const;
642 template<
typename AccessorT>
645 LeafNodeType* probeLeafAndCache(
const Coord& xyz, AccessorT& acc);
646 template<
typename AccessorT>
647 const LeafNodeType* probeConstLeafAndCache(
const Coord& xyz, AccessorT& acc)
const;
648 template<
typename AccessorT>
649 const LeafNodeType* probeLeafAndCache(
const Coord& xyz, AccessorT& acc)
const;
658 LeafNodeType* touchLeaf(
const Coord& xyz);
662 template<
typename AccessorT>
663 LeafNodeType* touchLeafAndCache(
const Coord& xyz, AccessorT&);
666 template<
typename ArrayT>
689 void getNodes(ArrayT& array);
690 template<
typename ArrayT>
691 void getNodes(ArrayT& array)
const;
717 template<
typename ArrayT>
718 void stealNodes(ArrayT& array,
const ValueType& value,
bool state);
722 void resetBackground(
const ValueType& oldBackground,
const ValueType& newBackground);
726 template<
typename OtherChildNodeType, Index OtherLog2Dim>
731 friend class IteratorBase<MaskOnIterator, InternalNode>;
740 template<
typename, Index>
friend class InternalNode;
755 NodeMaskType mask = mValueMask;
760 const UnionType*
getTable()
const {
return mNodes; }
763 void setValueMask(
Index n,
bool on) { mValueMask.set(n, mChildMask.isOn(n) ?
false : on); }
768 void makeChildNodeEmpty(
Index n,
const ValueType& value);
769 void setChildNode(
Index i, ChildNodeType* child);
770 void resetChildNode(
Index i, ChildNodeType* child);
771 ChildNodeType* unsetChildNode(
Index i,
const ValueType& value);
773 template<
typename NodeT,
typename VisitorOp,
typename ChildAllIterT>
774 static inline void doVisit(NodeT&, VisitorOp&);
776 template<
typename NodeT,
typename OtherNodeT,
typename VisitorOp,
777 typename ChildAllIterT,
typename OtherChildAllIterT>
778 static inline void doVisit2Node(NodeT&, OtherNodeT&, VisitorOp&);
780 template<
typename NodeT,
typename VisitorOp,
781 typename ChildAllIterT,
typename OtherChildAllIterT>
782 static inline void doVisit2(NodeT&, OtherChildAllIterT&, VisitorOp&,
bool otherIsLHS);
788 ChildNodeType* getChildNode(
Index n);
789 const ChildNodeType* getChildNode(
Index n)
const;
793 template<
typename OtherInternalNode>
struct DeepCopy;
800 UnionType mNodes[NUM_VALUES];
811 template<
typename ChildT1, Index Dim1,
typename NodeT2>
815 static const bool value =
false;
818 template<
typename ChildT1, Index Dim1,
typename ChildT2>
820 static const bool value = ChildT1::template SameConfiguration<ChildT2>::value;
828 template<
typename ChildT, Index Log2Dim>
832 for (
Index i = 0; i < NUM_VALUES; ++i) mNodes[i].setValue(background);
836 template<
typename ChildT, Index Log2Dim>
839 mOrigin(origin[0] & ~(DIM - 1),
840 origin[1] & ~(DIM - 1),
841 origin[2] & ~(DIM - 1))
848 #ifndef OPENVDB_2_ABI_COMPATIBLE 851 template<
typename ChildT, Index Log2Dim>
862 template<
typename ChildT, Index Log2Dim>
863 template<
typename OtherInternalNode>
867 tbb::parallel_for(tbb::blocked_range<Index>(0,
NUM_VALUES), *
this);
871 for (
Index i = r.begin(), end=r.end(); i!=end; ++i) {
872 if (s->mChildMask.isOff(i)) {
873 t->mNodes[i].setValue(
ValueType(s->mNodes[i].getValue()));
875 t->mNodes[i].setChild(
new ChildNodeType(*(s->mNodes[i].getChild())));
879 const OtherInternalNode*
s;
883 template<
typename ChildT, Index Log2Dim>
895 template<
typename ChildT, Index Log2Dim>
896 template<
typename OtherChildNodeType>
906 template<
typename ChildT, Index Log2Dim>
907 template<
typename OtherInternalNode>
911 const ValueType& background) : s(source), t(target), b(background) {
912 tbb::parallel_for(tbb::blocked_range<Index>(0,
NUM_VALUES), *
this);
916 for (
Index i = r.begin(), end=r.end(); i!=end; ++i) {
917 if (s->isChildMaskOn(i)) {
918 t->mNodes[i].setChild(
new ChildNodeType(*(s->mNodes[i].getChild()),
921 t->mNodes[i].setValue(b);
925 const OtherInternalNode*
s;
930 template<
typename ChildT, Index Log2Dim>
931 template<
typename OtherChildNodeType>
942 template<
typename ChildT, Index Log2Dim>
943 template<
typename OtherInternalNode>
948 : s(source), t(target), offV(offValue), onV(onValue) {
949 tbb::parallel_for(tbb::blocked_range<Index>(0,
NUM_VALUES), *
this);
952 for (
Index i = r.begin(), end=r.end(); i!=end; ++i) {
953 if (s->isChildMaskOn(i)) {
954 t->mNodes[i].setChild(
new ChildNodeType(*(s->mNodes[i].getChild()),
957 t->mNodes[i].setValue(s->isValueMaskOn(i) ? onV : offV);
961 const OtherInternalNode*
s;
966 template<
typename ChildT, Index Log2Dim>
967 template<
typename OtherChildNodeType>
980 template<
typename ChildT, Index Log2Dim>
985 delete mNodes[iter.pos()].getChild();
993 template<
typename ChildT, Index Log2Dim>
1000 sum += iter->leafCount();
1006 template<
typename ChildT, Index Log2Dim>
1011 if (ChildNodeType::getLevel() == 0)
return sum;
1013 sum += iter->nonLeafCount();
1019 template<
typename ChildT, Index Log2Dim>
1025 sum += iter->onVoxelCount();
1031 template<
typename ChildT, Index Log2Dim>
1037 sum += iter->offVoxelCount();
1043 template<
typename ChildT, Index Log2Dim>
1049 sum +=
mNodes[iter.pos()].getChild()->onLeafVoxelCount();
1055 template<
typename ChildT, Index Log2Dim>
1061 sum +=
mNodes[iter.pos()].getChild()->offLeafVoxelCount();
1066 template<
typename ChildT, Index Log2Dim>
1072 sum += iter->onTileCount();
1077 template<
typename ChildT, Index Log2Dim>
1084 sum += iter->memUsage();
1090 template<
typename ChildT, Index Log2Dim>
1094 if (bbox.isInside(this->getNodeBoundingBox()))
return;
1097 bbox.expand(i.getCoord(), ChildT::DIM);
1100 i->evalActiveBoundingBox(bbox, visitVoxels);
1108 template<
typename ChildT, Index Log2Dim>
1115 const Index i = iter.pos();
1116 ChildT* child =
mNodes[i].getChild();
1117 child->prune(tolerance);
1118 if (child->isConstant(value, state, tolerance)) {
1122 mNodes[i].setValue(value);
1131 template<
typename ChildT, Index Log2Dim>
1132 template<
typename NodeT>
1136 if ((NodeT::LEVEL == ChildT::LEVEL && !(boost::is_same<NodeT, ChildT>::value)) ||
1137 NodeT::LEVEL > ChildT::LEVEL)
return NULL;
1141 ChildT* child =
mNodes[n].getChild();
1142 if (boost::is_same<NodeT, ChildT>::value) {
1145 mNodes[n].setValue(value);
1147 return (boost::is_same<NodeT, ChildT>::value)
1148 ?
reinterpret_cast<NodeT*
>(child)
1149 : child->template stealNode<NodeT>(xyz, value, state);
1157 template<
typename ChildT, Index Log2Dim>
1158 template<
typename NodeT>
1162 if ((NodeT::LEVEL == ChildT::LEVEL && !(boost::is_same<NodeT, ChildT>::value)) ||
1163 NodeT::LEVEL > ChildT::LEVEL)
return NULL;
1167 ChildT* child =
mNodes[n].getChild();
1168 return (boost::is_same<NodeT, ChildT>::value)
1169 ?
reinterpret_cast<NodeT*
>(child)
1170 : child->template probeNode<NodeT>(xyz);
1175 template<
typename ChildT, Index Log2Dim>
1176 template<
typename NodeT,
typename AccessorT>
1180 if ((NodeT::LEVEL == ChildT::LEVEL && !(boost::is_same<NodeT, ChildT>::value)) ||
1181 NodeT::LEVEL > ChildT::LEVEL)
return NULL;
1185 ChildT* child =
mNodes[n].getChild();
1186 acc.insert(xyz, child);
1187 return (boost::is_same<NodeT, ChildT>::value)
1188 ?
reinterpret_cast<NodeT*
>(child)
1189 : child->template probeNodeAndCache<NodeT>(xyz, acc);
1194 template<
typename ChildT, Index Log2Dim>
1195 template<
typename NodeT>
1199 if ((NodeT::LEVEL == ChildT::LEVEL && !(boost::is_same<NodeT, ChildT>::value)) ||
1200 NodeT::LEVEL > ChildT::LEVEL)
return NULL;
1204 const ChildT* child =
mNodes[n].getChild();
1205 return (boost::is_same<NodeT, ChildT>::value)
1206 ?
reinterpret_cast<const NodeT*
>(child)
1207 : child->template probeConstNode<NodeT>(xyz);
1212 template<
typename ChildT, Index Log2Dim>
1213 template<
typename NodeT,
typename AccessorT>
1217 if ((NodeT::LEVEL == ChildT::LEVEL && !(boost::is_same<NodeT, ChildT>::value)) ||
1218 NodeT::LEVEL > ChildT::LEVEL)
return NULL;
1222 const ChildT* child =
mNodes[n].getChild();
1223 acc.insert(xyz, child);
1224 return (boost::is_same<NodeT, ChildT>::value)
1225 ?
reinterpret_cast<const NodeT*
>(child)
1226 : child->template probeConstNodeAndCache<NodeT>(xyz, acc);
1234 template<
typename ChildT, Index Log2Dim>
1235 inline typename ChildT::LeafNodeType*
1238 return this->
template probeNode<LeafNodeType>(xyz);
1242 template<
typename ChildT, Index Log2Dim>
1243 template<
typename AccessorT>
1244 inline typename ChildT::LeafNodeType*
1247 return this->
template probeNodeAndCache<LeafNodeType>(xyz, acc);
1251 template<
typename ChildT, Index Log2Dim>
1252 template<
typename AccessorT>
1253 inline const typename ChildT::LeafNodeType*
1260 template<
typename ChildT, Index Log2Dim>
1261 inline const typename ChildT::LeafNodeType*
1264 return this->
template probeConstNode<LeafNodeType>(xyz);
1268 template<
typename ChildT, Index Log2Dim>
1269 template<
typename AccessorT>
1270 inline const typename ChildT::LeafNodeType*
1273 return this->
template probeConstNodeAndCache<LeafNodeType>(xyz, acc);
1280 template<
typename ChildT, Index Log2Dim>
1284 assert(leaf != NULL);
1285 const Coord& xyz = leaf->origin();
1287 ChildT* child = NULL;
1289 if (ChildT::LEVEL>0) {
1292 child =
reinterpret_cast<ChildT*
>(leaf);
1296 if (ChildT::LEVEL>0) {
1297 child =
mNodes[n].getChild();
1299 delete mNodes[n].getChild();
1300 child =
reinterpret_cast<ChildT*
>(leaf);
1301 mNodes[n].setChild(child);
1304 child->addLeaf(leaf);
1308 template<
typename ChildT, Index Log2Dim>
1309 template<
typename AccessorT>
1313 assert(leaf != NULL);
1314 const Coord& xyz = leaf->origin();
1316 ChildT* child = NULL;
1318 if (ChildT::LEVEL>0) {
1320 acc.insert(xyz, child);
1322 child =
reinterpret_cast<ChildT*
>(leaf);
1326 if (ChildT::LEVEL>0) {
1327 child =
mNodes[n].getChild();
1328 acc.insert(xyz, child);
1330 delete mNodes[n].getChild();
1331 child =
reinterpret_cast<ChildT*
>(leaf);
1332 mNodes[n].setChild(child);
1335 child->addLeafAndCache(leaf, acc);
1342 template<
typename ChildT, Index Log2Dim>
1352 template<
typename ChildT, Index Log2Dim>
1357 if (
LEVEL >= level) {
1360 if (
LEVEL > level) {
1363 child->addTile(level, xyz, value, state);
1366 mNodes[n].setValue(value);
1369 ChildT* child =
mNodes[n].getChild();
1370 if (
LEVEL > level) {
1371 child->addTile(level, xyz, value, state);
1376 mNodes[n].setValue(value);
1383 template<
typename ChildT, Index Log2Dim>
1384 template<
typename AccessorT>
1387 const ValueType& value,
bool state, AccessorT& acc)
1389 if (
LEVEL >= level) {
1392 if (
LEVEL > level) {
1395 acc.insert(xyz, child);
1396 child->addTileAndCache(level, xyz, value, state, acc);
1399 mNodes[n].setValue(value);
1402 ChildT* child =
mNodes[n].getChild();
1403 if (
LEVEL > level) {
1404 acc.insert(xyz, child);
1405 child->addTileAndCache(level, xyz, value, state, acc);
1410 mNodes[n].setValue(value);
1420 template<
typename ChildT, Index Log2Dim>
1421 inline typename ChildT::LeafNodeType*
1425 ChildT* child = NULL;
1430 child =
mNodes[n].getChild();
1432 return child->touchLeaf(xyz);
1436 template<
typename ChildT, Index Log2Dim>
1437 template<
typename AccessorT>
1438 inline typename ChildT::LeafNodeType*
1445 acc.insert(xyz,
mNodes[n].getChild());
1446 return mNodes[n].getChild()->touchLeafAndCache(xyz, acc);
1453 template<
typename ChildT, Index Log2Dim>
1463 value =
mNodes[0].getValue();
1473 template<
typename ChildT, Index Log2Dim>
1476 bool& state,
const ValueType& tolerance)
const 1484 minValue = maxValue =
mNodes[0].getValue();
1488 if ((maxValue - v) > range)
return false;
1490 }
else if (v > maxValue) {
1491 if ((v - minValue) > range)
return false;
1502 template<
typename ChildT, Index Log2Dim>
1508 if (
LEVEL==1 || anyActiveTiles)
return anyActiveTiles;
1510 if (iter->hasActiveTiles())
return true;
1517 template<
typename ChildT, Index Log2Dim>
1523 return mNodes[n].getChild()->isValueOn(xyz);
1526 template<
typename ChildT, Index Log2Dim>
1527 template<
typename AccessorT>
1533 acc.insert(xyz,
mNodes[n].getChild());
1534 return mNodes[n].getChild()->isValueOnAndCache(xyz, acc);
1538 template<
typename ChildT, Index Log2Dim>
1539 inline const typename ChildT::ValueType&
1544 :
mNodes[n].getChild()->getValue(xyz);
1547 template<
typename ChildT, Index Log2Dim>
1548 template<
typename AccessorT>
1549 inline const typename ChildT::ValueType&
1554 acc.insert(xyz,
mNodes[n].getChild());
1555 return mNodes[n].getChild()->getValueAndCache(xyz, acc);
1557 return mNodes[n].getValue();
1561 template<
typename ChildT, Index Log2Dim>
1569 template<
typename ChildT, Index Log2Dim>
1570 template<
typename AccessorT>
1576 acc.insert(xyz,
mNodes[n].getChild());
1577 return mNodes[n].getChild()->getValueLevelAndCache(xyz, acc);
1583 template<
typename ChildT, Index Log2Dim>
1589 value =
mNodes[n].getValue();
1592 return mNodes[n].getChild()->probeValue(xyz, value);
1595 template<
typename ChildT, Index Log2Dim>
1596 template<
typename AccessorT>
1603 acc.insert(xyz,
mNodes[n].getChild());
1604 return mNodes[n].getChild()->probeValueAndCache(xyz, value, acc);
1606 value =
mNodes[n].getValue();
1611 template<
typename ChildT, Index Log2Dim>
1623 if (hasChild)
mNodes[n].getChild()->setValueOff(xyz);
1627 template<
typename ChildT, Index Log2Dim>
1639 if (hasChild)
mNodes[n].getChild()->setValueOn(xyz);
1643 template<
typename ChildT, Index Log2Dim>
1659 if (hasChild)
mNodes[n].getChild()->setValueOff(xyz, value);
1662 template<
typename ChildT, Index Log2Dim>
1663 template<
typename AccessorT>
1681 ChildT* child =
mNodes[n].getChild();
1682 acc.insert(xyz, child);
1683 child->setValueOffAndCache(xyz, value, acc);
1688 template<
typename ChildT, Index Log2Dim>
1704 if (hasChild)
mNodes[n].getChild()->setValueOn(xyz, value);
1707 template<
typename ChildT, Index Log2Dim>
1708 template<
typename AccessorT>
1726 acc.insert(xyz,
mNodes[n].getChild());
1727 mNodes[n].getChild()->setValueAndCache(xyz, value, acc);
1732 template<
typename ChildT, Index Log2Dim>
1745 if (hasChild)
mNodes[n].getChild()->setValueOnly(xyz, value);
1748 template<
typename ChildT, Index Log2Dim>
1749 template<
typename AccessorT>
1764 acc.insert(xyz,
mNodes[n].getChild());
1765 mNodes[n].getChild()->setValueOnlyAndCache(xyz, value, acc);
1770 template<
typename ChildT, Index Log2Dim>
1785 if (hasChild)
mNodes[n].getChild()->setActiveState(xyz, on);
1788 template<
typename ChildT, Index Log2Dim>
1789 template<
typename AccessorT>
1805 ChildT* child =
mNodes[n].getChild();
1806 acc.insert(xyz, child);
1807 child->setActiveStateAndCache(xyz, on, acc);
1812 template<
typename ChildT, Index Log2Dim>
1818 mNodes[iter.pos()].getChild()->setValuesOn();
1823 template<
typename ChildT, Index Log2Dim>
1824 template<
typename ModifyOp>
1834 bool createChild = !active;
1848 if (hasChild)
mNodes[n].getChild()->modifyValue(xyz, op);
1851 template<
typename ChildT, Index Log2Dim>
1852 template<
typename ModifyOp,
typename AccessorT>
1863 bool createChild = !active;
1879 acc.insert(xyz, child);
1880 child->modifyValueAndCache(xyz, op, acc);
1885 template<
typename ChildT, Index Log2Dim>
1886 template<
typename ModifyOp>
1895 bool modifiedState = !tileState;
1897 op(modifiedVal, modifiedState);
1905 if (hasChild)
mNodes[n].getChild()->modifyValueAndActiveState(xyz, op);
1908 template<
typename ChildT, Index Log2Dim>
1909 template<
typename ModifyOp,
typename AccessorT>
1912 const Coord& xyz,
const ModifyOp& op, AccessorT& acc)
1919 bool modifiedState = !tileState;
1921 op(modifiedVal, modifiedState);
1931 acc.insert(xyz, child);
1932 child->modifyValueAndActiveStateAndCache(xyz, op, acc);
1940 template<
typename ChildT, Index Log2Dim>
1945 if (!clipBBox.hasOverlap(nodeBBox)) {
1947 this->
fill(nodeBBox, background,
false);
1948 }
else if (clipBBox.isInside(nodeBBox)) {
1959 CoordBBox tileBBox(xyz, xyz.offsetBy(ChildT::DIM - 1));
1960 if (!clipBBox.hasOverlap(tileBBox)) {
1965 }
else if (!clipBBox.isInside(tileBBox)) {
1969 mNodes[pos].getChild()->clip(clipBBox, background);
1973 tileBBox.intersect(clipBBox);
1976 mNodes[pos].setValue(background);
1978 this->
fill(tileBBox, val, on);
1990 template<
typename ChildT, Index Log2Dim>
1994 Coord xyz, tileMin, tileMax;
1995 for (
int x = bbox.min().x(); x <= bbox.max().x(); x = tileMax.x() + 1) {
1997 for (
int y = bbox.min().y(); y <= bbox.max().y(); y = tileMax.y() + 1) {
1999 for (
int z = bbox.min().z(); z <= bbox.max().z(); z = tileMax.z() + 1) {
2005 tileMax = tileMin.offsetBy(ChildT::DIM - 1);
2007 if (xyz != tileMin || Coord::lessThan(bbox.max(), tileMax)) {
2011 ChildT* child = NULL;
2018 child =
mNodes[n].getChild();
2043 template<
typename ChildT, Index Log2Dim>
2044 template<
typename DenseT>
2048 typedef typename DenseT::ValueType DenseValueType;
2050 const size_t xStride = dense.xStride(), yStride = dense.yStride(), zStride = dense.zStride();
2051 const Coord&
min = dense.bbox().min();
2052 for (Coord xyz = bbox.min(),
max; xyz[0] <= bbox.max()[0]; xyz[0] =
max[0] + 1) {
2053 for (xyz[1] = bbox.min()[1]; xyz[1] <= bbox.max()[1]; xyz[1] =
max[1] + 1) {
2054 for (xyz[2] = bbox.min()[2]; xyz[2] <= bbox.max()[2]; xyz[2] =
max[2] + 1) {
2063 mNodes[n].getChild()->copyToDense(sub, dense);
2066 sub.translate(-min);
2067 DenseValueType* a0 = dense.data() + zStride*sub.min()[2];
2068 for (
Int32 x=sub.min()[0], ex=sub.max()[0]+1; x<ex; ++x) {
2069 DenseValueType* a1 = a0 + x*xStride;
2070 for (
Int32 y=sub.min()[1], ey=sub.max()[1]+1; y<ey; ++y) {
2071 DenseValueType* a2 = a1 + y*yStride;
2072 for (
Int32 z=sub.min()[2], ez=sub.max()[2]+1; z<ez; ++z, a2 += zStride) {
2073 *a2 = DenseValueType(value);
2087 template<
typename ChildT, Index Log2Dim>
2097 const ValueType zero = zeroVal<ValueType>();
2106 iter->writeTopology(os, toHalf);
2111 template<
typename ChildT, Index Log2Dim>
2115 #ifndef OPENVDB_2_ABI_COMPATIBLE 2127 #ifdef OPENVDB_2_ABI_COMPATIBLE 2132 mNodes[i].setChild(child);
2133 child->readTopology(is);
2136 is.read(reinterpret_cast<char*>(&value),
sizeof(
ValueType));
2137 mNodes[i].setValue(value);
2141 const bool oldVersion =
2147 boost::shared_array<ValueType> values(
new ValueType[numValues]);
2154 mNodes[iter.pos()].setValue(values[n++]);
2156 assert(n == numValues);
2159 mNodes[iter.pos()].setValue(values[iter.pos()]);
2165 #ifdef OPENVDB_2_ABI_COMPATIBLE 2170 mNodes[iter.pos()].setChild(child);
2171 child->readTopology(is, fromHalf);
2180 template<
typename ChildT, Index Log2Dim>
2181 inline const typename ChildT::ValueType&
2188 template<
typename ChildT, Index Log2Dim>
2189 inline const typename ChildT::ValueType&
2200 template<
typename ChildT, Index Log2Dim>
2206 mNodes[i].getChild()->negate();
2215 template<
typename ChildT, Index Log2Dim>
2229 template<
typename ChildT, Index Log2Dim>
2230 template<MergePolicy Policy>
2243 const Index n = iter.pos();
2246 mNodes[n].getChild()->template merge<MERGE_ACTIVE_STATES>(*iter,
2247 background, otherBackground);
2255 child->resetBackground(otherBackground, background);
2262 const Index n = iter.pos();
2275 const Index n = iter.pos();
2278 mNodes[n].getChild()->template merge<Policy>(*iter, background, otherBackground);
2286 child->resetBackground(otherBackground, background);
2297 const Index n = iter.pos();
2300 mNodes[n].getChild()->template merge<Policy>(*iter, background, otherBackground);
2307 child->resetBackground(otherBackground, background);
2310 child->template merge<Policy>(
mNodes[n].getValue(),
true);
2314 mNodes[n].setChild(child);
2320 const Index n = iter.pos();
2323 mNodes[n].getChild()->template merge<Policy>(iter.getValue(),
true);
2326 mNodes[n].setValue(iter.getValue());
2338 template<
typename ChildT, Index Log2Dim>
2339 template<MergePolicy Policy>
2348 if (!tileActive)
return;
2352 const Index n = iter.pos();
2355 mNodes[n].getChild()->template merge<Policy>(tileValue,
true);
2358 iter.setValue(tileValue);
2367 template<
typename ChildT, Index Log2Dim>
2368 template<
typename OtherInternalNode>
2372 struct A {
inline void operator()(W &tV,
const W& sV,
const W& tC)
const 2373 { tV = (tV | sV) & ~tC; }
2377 tbb::parallel_for(tbb::blocked_range<Index>(0,
NUM_VALUES), *
this);
2380 t->mChildMask |= s->mChildMask;
2382 t->mValueMask.foreach(s->mValueMask, t->mChildMask, op);
2383 assert((t->mValueMask & t->mChildMask).isOff());
2386 for (
Index i = r.begin(), end=r.end(); i!=end; ++i) {
2387 if (s->mChildMask.isOn(i)) {
2388 const typename OtherInternalNode::ChildNodeType& other = *(s->mNodes[i].getChild());
2389 if (t->mChildMask.isOn(i)) {
2390 t->mNodes[i].getChild()->topologyUnion(other);
2392 ChildT* child =
new ChildT(other, t->mNodes[i].getValue(),
TopologyCopy());
2394 t->mNodes[i].setChild(child);
2396 }
else if (s->mValueMask.isOn(i) && t->mChildMask.isOn(i)) {
2397 t->mNodes[i].getChild()->setValuesOn();
2401 const OtherInternalNode*
s;
2405 template<
typename ChildT, Index Log2Dim>
2406 template<
typename OtherChildT>
2413 template<
typename ChildT, Index Log2Dim>
2414 template<
typename OtherInternalNode>
2418 struct A {
inline void operator()(W &tC,
const W& sC,
const W& sV,
const W& tV)
const 2419 { tC = (tC & (sC | sV)) | (tV & sC); }
2422 const ValueType& background) : s(source), t(target), b(background) {
2424 tbb::parallel_for(tbb::blocked_range<Index>(0,
NUM_VALUES), *
this);
2428 t->mChildMask.foreach(s->mChildMask, s->mValueMask, t->mValueMask, op);
2430 t->mValueMask &= s->mValueMask;
2431 assert((t->mValueMask & t->mChildMask).isOff());
2434 for (
Index i = r.begin(), end=r.end(); i!=end; ++i) {
2435 if (t->mChildMask.isOn(i)) {
2436 ChildT* child = t->
mNodes[i].getChild();
2437 if (s->mChildMask.isOn(i)) {
2438 child->topologyIntersection(*(s->mNodes[i].getChild()), b);
2439 }
else if (s->mValueMask.isOff(i)) {
2441 t->mNodes[i].setValue(b);
2443 }
else if (t->mValueMask.isOn(i) && s->mChildMask.isOn(i)) {
2444 t->mNodes[i].setChild(
new ChildT(*(s->mNodes[i].getChild()),
2449 const OtherInternalNode*
s;
2454 template<
typename ChildT, Index Log2Dim>
2455 template<
typename OtherChildT>
2463 template<
typename ChildT, Index Log2Dim>
2464 template<
typename OtherInternalNode>
2468 struct A {
inline void operator()(W &tC,
const W& sC,
const W& sV,
const W& tV)
const 2469 { tC = (tC & (sC | ~sV)) | (tV & sC); }
2471 struct B {
inline void operator()(W &tV,
const W& sC,
const W& sV,
const W& tC)
const 2472 { tV &= ~((tC & sV) | (sC | sV)); }
2475 const ValueType& background) : s(source), t(target), b(background) {
2477 tbb::parallel_for(tbb::blocked_range<Index>(0,
NUM_VALUES), *
this);
2482 t->mChildMask.foreach(s->mChildMask, s->mValueMask, t->mValueMask, op1);
2485 t->mValueMask.foreach(t->mChildMask, s->mValueMask, oldChildMask, op2);
2486 assert((t->mValueMask & t->mChildMask).isOff());
2489 for (
Index i = r.begin(), end=r.end(); i!=end; ++i) {
2490 if (t->mChildMask.isOn(i)) {
2491 ChildT* child = t->
mNodes[i].getChild();
2492 if (s->mChildMask.isOn(i)) {
2493 child->topologyDifference(*(s->mNodes[i].getChild()), b);
2494 }
else if (s->mValueMask.isOn(i)) {
2496 t->mNodes[i].setValue(b);
2498 }
else if (t->mValueMask.isOn(i)) {
2499 if (s->mChildMask.isOn(i)) {
2500 const typename OtherInternalNode::ChildNodeType& other = *(s->mNodes[i].getChild());
2501 ChildT* child =
new ChildT(other.origin(), t->mNodes[i].getValue(),
true);
2503 t->mNodes[i].setChild(child);
2508 const OtherInternalNode*
s;
2513 template<
typename ChildT, Index Log2Dim>
2514 template<
typename OtherChildT>
2525 template<
typename ChildT, Index Log2Dim>
2526 template<
typename CombineOp>
2530 const ValueType zero = zeroVal<ValueType>();
2538 op(args.setARef(
mNodes[i].getValue())
2540 .setBRef(other.
mNodes[i].getValue())
2542 mNodes[i].setValue(args.result());
2564 other.
mNodes[i].setValue(zero);
2571 *child =
mNodes[i].getChild(),
2572 *otherChild = other.
mNodes[i].getChild();
2575 if (child && otherChild) {
2576 child->combine(*otherChild, op);
2583 template<
typename ChildT, Index Log2Dim>
2584 template<
typename CombineOp>
2596 .setBIsActive(valueIsActive));
2603 if (child) child->combine(value, valueIsActive, op);
2612 template<
typename ChildT, Index Log2Dim>
2613 template<
typename CombineOp,
typename OtherNodeType>
2624 .setBRef(other1.mNodes[i].getValue())
2625 .setBIsActive(other1.isValueMaskOn(i)));
2633 ? other0.
mNodes[i].getChild()->origin()
2634 : other1.mNodes[i].getChild()->origin();
2641 mNodes[i].getChild()->combine2(other0.
mNodes[i].getValue(),
2643 }
else if (other1.isChildMaskOff(i)) {
2646 mNodes[i].getChild()->combine2(*other0.
mNodes[i].getChild(),
2647 other1.mNodes[i].getValue(), other1.isValueMaskOn(i), op);
2651 mNodes[i].getChild()->combine2(*other0.
mNodes[i].getChild(),
2652 *other1.mNodes[i].getChild(), op);
2659 template<
typename ChildT, Index Log2Dim>
2660 template<
typename CombineOp,
typename OtherNodeType>
2663 bool valueIsActive, CombineOp& op)
2668 if (other.isChildMaskOff(i)) {
2670 .setAIsActive(valueIsActive)
2671 .setBRef(other.mNodes[i].getValue())
2672 .setBIsActive(other.isValueMaskOn(i)));
2677 typename OtherNodeType::ChildNodeType* otherChild = other.mNodes[i].getChild();
2686 mNodes[i].getChild()->combine2(value, *otherChild, valueIsActive, op);
2692 template<
typename ChildT, Index Log2Dim>
2693 template<
typename CombineOp,
typename OtherValueType>
2696 bool valueIsActive, CombineOp& op)
2705 .setBIsActive(valueIsActive));
2719 mNodes[i].getChild()->combine2(*otherChild, value, valueIsActive, op);
2728 template<
typename ChildT, Index Log2Dim>
2729 template<
typename BBoxOp>
2735 op.operator()<
LEVEL>(CoordBBox::createCube(i.getCoord(), ChildNodeType::DIM));
2737 op.template operator()<
LEVEL>(CoordBBox::createCube(i.getCoord(), ChildNodeType::DIM));
2740 if (op.template descent<LEVEL>()) {
2745 op.operator()<
LEVEL>(i->getNodeBoundingBox());
2747 op.template operator()<
LEVEL>(i->getNodeBoundingBox());
2754 template<
typename ChildT, Index Log2Dim>
2755 template<
typename VisitorOp>
2759 doVisit<InternalNode, VisitorOp, ChildAllIter>(*
this, op);
2763 template<
typename ChildT, Index Log2Dim>
2764 template<
typename VisitorOp>
2768 doVisit<const InternalNode, VisitorOp, ChildAllCIter>(*
this, op);
2772 template<
typename ChildT, Index Log2Dim>
2773 template<
typename NodeT,
typename VisitorOp,
typename ChildAllIterT>
2777 typename NodeT::ValueType val;
2778 for (ChildAllIterT iter =
self.
beginChildAll(); iter; ++iter) {
2779 if (op(iter))
continue;
2780 if (
typename ChildAllIterT::ChildNodeType* child = iter.probeChild(val)) {
2790 template<
typename ChildT, Index Log2Dim>
2791 template<
typename OtherNodeType,
typename VisitorOp>
2796 typename OtherNodeType::ChildAllIter>(*
this, other, op);
2800 template<
typename ChildT, Index Log2Dim>
2801 template<
typename OtherNodeType,
typename VisitorOp>
2806 typename OtherNodeType::ChildAllCIter>(*
this, other, op);
2810 template<
typename ChildT, Index Log2Dim>
2813 typename OtherNodeT,
2815 typename ChildAllIterT,
2816 typename OtherChildAllIterT>
2821 BOOST_STATIC_ASSERT(OtherNodeT::NUM_VALUES == NodeT::NUM_VALUES);
2822 BOOST_STATIC_ASSERT(OtherNodeT::LEVEL == NodeT::LEVEL);
2824 typename NodeT::ValueType val;
2825 typename OtherNodeT::ValueType otherVal;
2827 ChildAllIterT iter =
self.beginChildAll();
2828 OtherChildAllIterT otherIter = other.beginChildAll();
2830 for ( ; iter && otherIter; ++iter, ++otherIter)
2832 const size_t skipBranch =
static_cast<size_t>(op(iter, otherIter));
2834 typename ChildAllIterT::ChildNodeType* child =
2835 (skipBranch & 1U) ? NULL : iter.probeChild(val);
2836 typename OtherChildAllIterT::ChildNodeType* otherChild =
2837 (skipBranch & 2U) ? NULL : otherIter.probeChild(otherVal);
2839 if (child != NULL && otherChild != NULL) {
2840 child->visit2Node(*otherChild, op);
2841 }
else if (child != NULL) {
2842 child->visit2(otherIter, op);
2843 }
else if (otherChild != NULL) {
2844 otherChild->visit2(iter, op,
true);
2853 template<
typename ChildT, Index Log2Dim>
2854 template<
typename OtherChildAllIterType,
typename VisitorOp>
2857 VisitorOp& op,
bool otherIsLHS)
2859 doVisit2<InternalNode, VisitorOp, ChildAllIter, OtherChildAllIterType>(
2860 *
this, otherIter, op, otherIsLHS);
2864 template<
typename ChildT, Index Log2Dim>
2865 template<
typename OtherChildAllIterType,
typename VisitorOp>
2868 VisitorOp& op,
bool otherIsLHS)
const 2870 doVisit2<const InternalNode, VisitorOp, ChildAllCIter, OtherChildAllIterType>(
2871 *
this, otherIter, op, otherIsLHS);
2875 template<
typename ChildT, Index Log2Dim>
2876 template<
typename NodeT,
typename VisitorOp,
typename ChildAllIterT,
typename OtherChildAllIterT>
2879 VisitorOp& op,
bool otherIsLHS)
2881 if (!otherIter)
return;
2883 const size_t skipBitMask = (otherIsLHS ? 2U : 1U);
2885 typename NodeT::ValueType val;
2886 for (ChildAllIterT iter =
self.
beginChildAll(); iter; ++iter) {
2887 const size_t skipBranch =
static_cast<size_t>(
2888 otherIsLHS ? op(otherIter, iter) : op(iter, otherIter));
2890 typename ChildAllIterT::ChildNodeType* child =
2891 (skipBranch & skipBitMask) ? NULL : iter.probeChild(val);
2893 if (child != NULL) child->visit2(otherIter, op, otherIsLHS);
2901 template<
typename ChildT, Index Log2Dim>
2906 iter->writeBuffers(os, toHalf);
2911 template<
typename ChildT, Index Log2Dim>
2916 iter->readBuffers(is, fromHalf);
2921 template<
typename ChildT, Index Log2Dim>
2924 const CoordBBox& clipBBox,
bool fromHalf)
2931 iter->readBuffers(is, clipBBox, fromHalf);
2935 ValueType background = zeroVal<ValueType>();
2937 background = *
static_cast<const ValueType*
>(bgPtr);
2939 this->
clip(clipBBox, background);
2946 template<
typename ChildT, Index Log2Dim>
2950 dims.push_back(Log2Dim);
2951 ChildNodeType::getNodeLog2Dims(dims);
2955 template<
typename ChildT, Index Log2Dim>
2959 assert(n<(1<<3*Log2Dim));
2960 xyz.setX(n >> 2*Log2Dim);
2961 n &= ((1<<2*Log2Dim)-1);
2962 xyz.setY(n >> Log2Dim);
2963 xyz.setZ(n & ((1<<Log2Dim)-1));
2967 template<
typename ChildT, Index Log2Dim>
2971 return (((xyz[0] & (
DIM-1u)) >> ChildNodeType::TOTAL) << 2*Log2Dim)
2972 + (((xyz[1] & (
DIM-1u)) >> ChildNodeType::TOTAL) << Log2Dim)
2973 + ((xyz[2] & (
DIM-1u)) >> ChildNodeType::TOTAL);
2977 template<
typename ChildT, Index Log2Dim>
2983 local <<= ChildT::TOTAL;
2984 return local + this->
origin();
2989 template<
typename ChildT, Index Log2Dim>
2990 template<
typename ArrayT>
2994 typedef typename ArrayT::value_type T;
2995 BOOST_STATIC_ASSERT(boost::is_pointer<T>::value);
2996 typedef typename boost::mpl::if_<boost::is_const<typename boost::remove_pointer<T>::type>,
2997 const ChildT, ChildT>::type ArrayChildT;
3000 if (boost::is_same<T, ArrayChildT*>::value) {
3001 array.push_back(reinterpret_cast<T>(
mNodes[iter.pos()].getChild()));
3003 iter->getNodes(array);
3009 template<
typename ChildT, Index Log2Dim>
3010 template<
typename ArrayT>
3014 typedef typename ArrayT::value_type T;
3015 BOOST_STATIC_ASSERT(boost::is_pointer<T>::value);
3016 BOOST_STATIC_ASSERT(boost::is_const<
typename boost::remove_pointer<T>::type>::value);
3019 if (boost::is_same<T, const ChildT*>::value) {
3020 array.push_back(reinterpret_cast<T>(
mNodes[iter.pos()].getChild()));
3022 iter->getNodes(array);
3030 template<
typename ChildT, Index Log2Dim>
3031 template<
typename ArrayT>
3035 typedef typename ArrayT::value_type T;
3036 BOOST_STATIC_ASSERT(boost::is_pointer<T>::value);
3037 typedef typename boost::mpl::if_<boost::is_const<typename boost::remove_pointer<T>::type>,
3038 const ChildT, ChildT>::type ArrayChildT;
3041 const Index n = iter.pos();
3042 if (boost::is_same<T, ArrayChildT*>::value) {
3043 array.push_back(reinterpret_cast<T>(
mNodes[n].getChild()));
3045 mNodes[n].setValue(value);
3047 iter->stealNodes(array, value, state);
3057 template<
typename ChildT, Index Log2Dim>
3065 mNodes[i].getChild()->resetBackground(oldBackground, newBackground);
3068 mNodes[i].setValue(newBackground);
3076 template<
typename ChildT, Index Log2Dim>
3077 template<
typename OtherChildNodeType, Index OtherLog2Dim>
3085 if (!iter->hasSameTopology(other->
mNodes[iter.pos()].getChild()))
return false;
3091 template<
typename ChildT, Index Log2Dim>
3097 delete mNodes[i].getChild();
3102 mNodes[i].setChild(child);
3105 template<
typename ChildT, Index Log2Dim>
3113 mNodes[i].setChild(child);
3117 template<
typename ChildT, Index Log2Dim>
3122 mNodes[i].setValue(value);
3127 mNodes[i].setValue(value);
3132 template<
typename ChildT, Index Log2Dim>
3139 template<
typename ChildT, Index Log2Dim>
3144 return mNodes[n].getChild();
3148 template<
typename ChildT, Index Log2Dim>
3149 inline const ChildT*
3153 return mNodes[n].getChild();
3160 #endif // OPENVDB_TREE_INTERNALNODE_HAS_BEEN_INCLUDED ChildNodeType * getChildNode(Index n)
Returns a pointer to the child node at the linear offset n.
Definition: InternalNode.h:3141
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:1572
bool isChildMaskOn(Index n) const
Definition: InternalNode.h:748
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.
const NodeMaskType & getChildMask() const
Definition: InternalNode.h:752
ChildT & getItem(Index pos) const
Definition: InternalNode.h:159
Index32 countOff() const
Return the total number of on bits.
Definition: NodeMasks.h:447
const ValueType & getValue(const Coord &xyz) const
Definition: InternalNode.h:1540
T negative(const T &val)
Return the unary negation of the given value.
Definition: Math.h:116
const ValueType & b
Definition: InternalNode.h:927
static void doVisit(NodeT &, VisitorOp &)
Definition: InternalNode.h:2775
NodeMaskType mValueMask
Definition: InternalNode.h:801
void load(std::istream &is)
Definition: NodeMasks.h:555
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:1236
Index32 Index
Definition: Types.h:58
const OtherInternalNode * s
Definition: InternalNode.h:925
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:1134
ChildOnIter beginChildOn()
Definition: InternalNode.h:249
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:3033
void operator()(const tbb::blocked_range< Index > &r) const
Definition: InternalNode.h:951
ChildOffIter beginChildOff()
Definition: InternalNode.h:250
ValueIter< const InternalNode, const ValueType, MaskOffIterator, ChildOff > ChildOffCIter
Definition: InternalNode.h:232
void readBuffers(std::istream &, bool fromHalf=false)
Definition: InternalNode.h:2913
InternalNode * t
Definition: InternalNode.h:2450
void visitActiveBBox(BBoxOp &) const
Calls the templated functor BBoxOp with bounding box information for all active tiles and leaf nodes ...
Definition: InternalNode.h:2731
ChildOffCIter beginChildOff() const
Definition: InternalNode.h:247
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:2182
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:1772
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:1311
ValueOnIter beginValueOn()
Definition: InternalNode.h:261
UnionType mNodes[NUM_VALUES]
Definition: InternalNode.h:798
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:1092
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 operator()(const tbb::blocked_range< Index > &r) const
Definition: InternalNode.h:870
ValueIter< const InternalNode, const ValueType, MaskOffIterator, ValueOff > ValueOffCIter
Definition: InternalNode.h:239
void setChildNode(Index i, ChildNodeType *child)
Definition: InternalNode.h:3107
Definition: InternalNode.h:2372
static void doVisit2Node(NodeT &, OtherNodeT &, VisitorOp &)
Definition: InternalNode.h:2818
ValueIter< InternalNode, const ValueType, MaskOffIterator, ValueAll > ValueAllIter
Definition: InternalNode.h:240
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:1826
ChildIter(const MaskIterT &iter, NodeT *parent)
Definition: InternalNode.h:156
Index64 onLeafVoxelCount() const
Definition: InternalNode.h:1045
Index64 offLeafVoxelCount() const
Definition: InternalNode.h:1057
bool isExactlyEqual(const T0 &a, const T1 &b)
Return true if a is exactly equal to b.
Definition: Math.h:407
ValueIter< const InternalNode, const ValueType, MaskOnIterator, ValueOn > ValueOnCIter
Definition: InternalNode.h:237
void setValueOnlyAndCache(const Coord &xyz, const ValueType &value, AccessorT &)
Definition: InternalNode.h:1751
Definition: InternalNode.h:794
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...
bool resultIsActive() const
Definition: Types.h:353
void setValueOn(const Coord &xyz)
Mark the voxel at the given coordinates as active but don't change its value.
Definition: InternalNode.h:1629
Bit mask for the internal and leaf nodes of VDB. This is a 64-bit implementation. ...
Definition: NodeMasks.h:304
ValueOffCIter beginValueOff() const
Definition: InternalNode.h:259
Definition: NodeMasks.h:205
void writeCompressedValues(std::ostream &os, ValueT *srcBuf, Index srcCount, const MaskT &valueMask, const MaskT &childMask, bool toHalf)
Definition: Compression.h:431
const Coord & origin() const
Return the grid index coordinates of this node's local origin.
Definition: InternalNode.h:281
Definition: NodeMasks.h:236
ChildIter< InternalNode, ChildNodeType, MaskOnIterator, ChildOn > ChildOnIter
Definition: InternalNode.h:229
static const Index DIM
Definition: InternalNode.h:78
void setValueAndCache(const Coord &xyz, const ValueType &value, AccessorT &)
Definition: InternalNode.h:1710
Coord mOrigin
Global grid index coordinates (x,y,z) of the local origin of this node.
Definition: InternalNode.h:803
TopologyCopy1(const OtherInternalNode *source, InternalNode *target, const ValueType &background)
Definition: InternalNode.h:910
uint32_t Index32
Definition: Types.h:56
void operator()(const tbb::blocked_range< Index > &r) const
Definition: InternalNode.h:2488
static const Index LEVEL
Definition: InternalNode.h:80
ValueIter< InternalNode, const ValueType, MaskOffIterator, ChildOff > ChildOffIter
Definition: InternalNode.h:231
const OtherInternalNode * s
Definition: InternalNode.h:879
ValueIter< const InternalNode, const ValueType, MaskOffIterator, ValueAll > ValueAllCIter
Definition: InternalNode.h:241
TopologyIntersection(const OtherInternalNode *source, InternalNode *target, const ValueType &background)
Definition: InternalNode.h:2421
bool probeValueAndCache(const Coord &xyz, ValueType &value, AccessorT &) const
Definition: InternalNode.h:1598
bool isValueMaskOff() const
Definition: InternalNode.h:747
ChildNodeType::LeafNodeType LeafNodeType
Definition: InternalNode.h:70
Definition: InternalNode.h:146
void toggle(Index32 n)
Toggle the state of the nth bit.
Definition: NodeMasks.h:480
InternalNode()
Definition: InternalNode.h:102
void operator()(W &tC, const W &sC, const W &sV, const W &tV) const
Definition: InternalNode.h:2468
void negate()
Definition: InternalNode.h:2202
boost::remove_const< UnsetItemT >::type NonConstValueType
Definition: Iterator.h:217
bool isEmpty() const
Definition: InternalNode.h:306
NodeMaskType getValueOffMask() const
Definition: InternalNode.h:753
util::NodeMask< Log2Dim > NodeMaskType
Definition: InternalNode.h:73
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
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:1563
bool isValueOnAndCache(const Coord &xyz, AccessorT &) const
Definition: InternalNode.h:1529
const OtherInternalNode * s
Definition: InternalNode.h:2449
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:1262
ValueIter()
Definition: InternalNode.h:175
void combine(InternalNode &other, CombineOp &)
Definition: InternalNode.h:2528
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:1854
DenseIter()
Definition: InternalNode.h:199
void clip(const CoordBBox &, const ValueType &background)
Set all voxels that lie outside the given axis-aligned box to the background.
Definition: InternalNode.h:1942
const NodeMaskType & getValueMask() const
Definition: InternalNode.h:751
void setValueOff(const Coord &xyz)
Mark the voxel at the given coordinates as inactive but don't change its value.
Definition: InternalNode.h:1613
InternalNode * t
Definition: InternalNode.h:2402
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:2615
void operator()(W &tC, const W &sC, const W &sV, const W &tV) const
Definition: InternalNode.h:2418
NodeMaskType::Word W
Definition: InternalNode.h:2417
void operator()(W &tV, const W &sV, const W &tC) const
Definition: InternalNode.h:2372
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...
TopologyUnion(const OtherInternalNode *source, InternalNode *target)
Definition: InternalNode.h:2375
ChildAllCIter cbeginChildAll() const
Definition: InternalNode.h:245
Definition: InternalNode.h:146
Index64 memUsage() const
Return the total amount of memory in bytes occupied by this node and its children.
Definition: InternalNode.h:1079
static Index getChildDim()
Definition: InternalNode.h:270
ChildIter< const InternalNode, const ChildNodeType, MaskOnIterator, ChildOn > ChildOnCIter
Definition: InternalNode.h:230
Definition: InternalNode.h:145
ValueOffCIter cbeginValueOff() const
Definition: InternalNode.h:255
void writeBuffers(std::ostream &, bool toHalf=false) const
Definition: InternalNode.h:2903
void setValueOffAndCache(const Coord &xyz, const ValueType &value, AccessorT &)
Definition: InternalNode.h:1665
Vec2< T > minComponent(const Vec2< T > &v1, const Vec2< T > &v2)
Return component-wise minimum of the two vectors.
Definition: Vec2.h:511
bool isOn(Index32 n) const
Return true if the nth bit is on.
Definition: NodeMasks.h:499
virtual ~InternalNode()
Definition: InternalNode.h:982
SameConfiguration<OtherNodeType>::value is true if and only if OtherNodeType is the type of an Intern...
Definition: InternalNode.h:96
void setOrigin(const Coord &origin)
Set the grid index coordinates of this node's local origin.
Definition: InternalNode.h:283
Definition: version.h:110
ChildAllCIter beginChildAll() const
Definition: InternalNode.h:248
void getNodes(ArrayT &array)
Adds all nodes of a certain type to a container with the following API:
Definition: InternalNode.h:2992
NodeType * probeNode(const Coord &xyz)
Return a pointer to the node that contains voxel (x, y, z). If no such node exists, return NULL.
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:1386
LeafNodeType * touchLeafAndCache(const Coord &xyz, AccessorT &)
Same as touchLeaf() except, if necessary, update the accessor with pointers to the nodes along the pa...
void makeChildNodeEmpty(Index n, const ValueType &value)
Definition: InternalNode.h:3134
Definition: InternalNode.h:145
ValueAllIter beginValueAll()
Definition: InternalNode.h:264
Definition: InternalNode.h:172
void setItem(Index pos, const ValueT &v) const
Definition: InternalNode.h:182
bool isValueMaskOff(Index n) const
Definition: InternalNode.h:746
DenseIter< const InternalNode, const ChildNodeType, ValueType, ChildAll > ChildAllCIter
Definition: InternalNode.h:234
#define OPENVDB_VERSION_NAME
Definition: version.h:43
OPENVDB_API uint32_t getFormatVersion(std::ios_base &)
Return the file format version number associated with the given input stream.
ChildOffCIter cbeginChildOff() const
Definition: InternalNode.h:244
InternalNode * t
Definition: InternalNode.h:926
const ValueT & getItem(Index pos) const
Definition: InternalNode.h:179
InternalNode< typename ChildNodeType::template ValueConverter< OtherValueType >::Type, Log2Dim > Type
Definition: InternalNode.h:89
void visit(VisitorOp &)
Definition: InternalNode.h:2757
void readCompressedValues(std::istream &is, ValueT *destBuf, Index destCount, const MaskT &valueMask, bool fromHalf)
Definition: Compression.h:329
CombineArgs & setARef(const AValueType &a)
Redirect the A value to a new external source.
Definition: Types.h:342
Index64 Word
Definition: NodeMasks.h:313
static Index32 memUsage()
Return the byte size of this NodeMask.
Definition: NodeMasks.h:438
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:1354
DeepCopy(const OtherInternalNode *source, InternalNode *target)
Definition: InternalNode.h:866
void readTopology(std::istream &, bool fromHalf=false)
Definition: InternalNode.h:2113
Definition: InternalNode.h:152
void set(Index32 n, bool On)
Set the nth bit to the specified state.
Definition: NodeMasks.h:459
Definition: Exceptions.h:39
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:1422
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:1734
ValueOnCIter cbeginValueOn() const
Definition: InternalNode.h:253
bool isOff(Index32 n) const
Return true if the nth bit is off.
Definition: NodeMasks.h:505
void voxelizeActiveTiles()
Densify active tiles, i.e., replace them with leaf-level active voxels.
Definition: InternalNode.h:2217
Index32 countOn() const
Return the total number of on bits.
Definition: NodeMasks.h:440
TopologyCopy2(const OtherInternalNode *source, InternalNode *target, const ValueType &offValue, const ValueType &onValue)
Definition: InternalNode.h:946
bool hasActiveTiles() const
Return true if this node or any of its child nodes have any active tiles.
Definition: InternalNode.h:1504
Definition: InternalNode.h:2471
static Index dim()
Definition: InternalNode.h:267
bool isValueMaskOn() const
Definition: InternalNode.h:745
void unsetItem(Index pos, const ValueT &value) const
Definition: InternalNode.h:221
void setItem(Index pos, const ChildT &c) const
Definition: InternalNode.h:166
NodeMaskType::Word W
Definition: InternalNode.h:2371
void writeTopology(std::ostream &, bool toHalf=false) const
Definition: InternalNode.h:2089
void fill(const CoordBBox &bbox, const ValueType &, bool active=true)
Set all voxels within an axis-aligned box to a constant value. (The min and max coordinates are inclu...
Definition: InternalNode.h:1992
Base class for dense iterators over internal and leaf nodes.
Definition: Iterator.h:211
DenseIteratorBase< MaskDenseIterator, DenseIter, NodeT, ChildT, ValueT > BaseT
Definition: InternalNode.h:196
static void doVisit2(NodeT &, OtherChildAllIterT &, VisitorOp &, bool otherIsLHS)
Definition: InternalNode.h:2878
ValueAllCIter beginValueAll() const
Definition: InternalNode.h:260
static void getNodeLog2Dims(std::vector< Index > &dims)
Definition: InternalNode.h:2948
void modifyValueAndActiveStateAndCache(const Coord &xyz, const ModifyOp &op, AccessorT &)
Definition: InternalNode.h:1911
const OtherInternalNode * s
Definition: InternalNode.h:961
bool isChildMaskOff(Index n) const
Definition: InternalNode.h:749
void operator()(const tbb::blocked_range< Index > &r) const
Definition: InternalNode.h:915
ChildAllIter beginChildAll()
Definition: InternalNode.h:251
void setOff(Index32 n)
Set the nth bit off.
Definition: NodeMasks.h:454
Definition: InternalNode.h:798
ValueConverter<T>::Type is the type of an InternalNode having the same child hierarchy and dimensions...
Definition: InternalNode.h:87
ValueIter< InternalNode, const ValueType, MaskOffIterator, ValueOff > ValueOffIter
Definition: InternalNode.h:238
ValueIter< InternalNode, const ValueType, MaskOnIterator, ValueOn > ValueOnIter
Definition: InternalNode.h:236
Definition: NodeMasks.h:267
NodeMaskType mChildMask
Definition: InternalNode.h:801
Definition: InternalNode.h:2418
ChildIter()
Definition: InternalNode.h:155
const AValueType & result() const
Get the output value.
Definition: Types.h:334
Definition: InternalNode.h:793
const OtherInternalNode * s
Definition: InternalNode.h:2401
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:3079
Base class for sparse iterators over internal and leaf nodes.
Definition: Iterator.h:148
NodeMaskType::Word W
Definition: InternalNode.h:2467
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:2046
void operator()(const tbb::blocked_range< Index > &r) const
Definition: InternalNode.h:2385
bool isChildMaskOff() const
Definition: InternalNode.h:750
bool probeValue(const Coord &xyz, ValueType &value) const
Definition: InternalNode.h:1585
bool isValueOn(Index offset) const
Return true if the voxel at the given offset is active.
Definition: InternalNode.h:339
ChildOnCIter cbeginChildOn() const
Definition: InternalNode.h:243
InternalNode * t
Definition: InternalNode.h:880
Index64 onTileCount() const
Definition: InternalNode.h:1068
ChildNodeType * unsetChildNode(Index i, const ValueType &value)
Definition: InternalNode.h:3119
bool getItem(Index pos, ChildT *&child, NonConstValueT &value) const
Definition: InternalNode.h:203
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:1110
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:2190
void visit2(IterT &otherIter, VisitorOp &, bool otherIsLHS=false)
This struct collects both input and output arguments to "grid combiner" functors used with the tree::...
Definition: Types.h:304
void setItem(Index pos, ChildT *child) const
Definition: InternalNode.h:215
NodeMaskType::OffIterator MaskOffIterator
Definition: InternalNode.h:141
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:1282
void setOn(Index32 n)
Set the nth bit on.
Definition: NodeMasks.h:449
bool isValueMaskOn(Index n) const
Definition: InternalNode.h:744
bool isConstant(ValueType &constValue, bool &state, const ValueType &tolerance=zeroVal< ValueType >()) const
Definition: InternalNode.h:1455
int32_t Int32
Definition: Types.h:60
const ValueType & getValueAndCache(const Coord &xyz, AccessorT &) const
void modifyItem(Index pos, const ModifyOp &op) const
Definition: InternalNode.h:186
void modifyValueAndActiveState(const Coord &xyz, const ModifyOp &op)
Apply a functor to the voxel at the given coordinates.
Definition: InternalNode.h:1888
uint64_t Index64
Definition: Types.h:57
Index64 onVoxelCount() const
Definition: InternalNode.h:1021
InternalNode * t
Definition: InternalNode.h:2509
Definition: InternalNode.h:2468
Definition: InternalNode.h:66
DenseIter< InternalNode, ChildNodeType, ValueType, ChildAll > ChildAllIter
Definition: InternalNode.h:233
Definition: InternalNode.h:796
ValueAllCIter cbeginValueAll() const
Definition: InternalNode.h:256
void resetChildNode(Index i, ChildNodeType *child)
Definition: InternalNode.h:3093
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...
ChildNodeType::ValueType ValueType
Definition: InternalNode.h:71
DenseIter(const MaskDenseIterator &iter, NodeT *parent)
Definition: InternalNode.h:200
Index32 nonLeafCount() const
Definition: InternalNode.h:1008
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...
const OtherInternalNode * s
Definition: InternalNode.h:2508
bool isInactive() const
Return true if this node has no children and only contains inactive values.
Definition: InternalNode.h:334
static Index getLevel()
Definition: InternalNode.h:268
NodeMaskType::OnIterator MaskOnIterator
Definition: InternalNode.h:140
Definition: InternalNode.h:62
void setActiveStateAndCache(const Coord &xyz, bool on, AccessorT &)
Definition: InternalNode.h:1791
BaseT::NonConstValueType NonConstValueT
Definition: InternalNode.h:197
ChildOnCIter beginChildOn() const
Definition: InternalNode.h:246
void operator()(W &tV, const W &sC, const W &sV, const W &tC) const
Definition: InternalNode.h:2471
const UnionType * getTable() const
Definition: InternalNode.h:760
ValueOnCIter beginValueOn() const
Definition: InternalNode.h:257
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h:71
ValueIter(const MaskIterT &iter, NodeT *parent)
Definition: InternalNode.h:176
InternalNode * t
Definition: InternalNode.h:962
void operator()(const tbb::blocked_range< Index > &r) const
Definition: InternalNode.h:2433
const ValueType & onV
Definition: InternalNode.h:963
Definition: InternalNode.h:146
Coord offsetToGlobalCoord(Index n) const
Return the global coordinates for a linear table offset.
Definition: InternalNode.h:2979
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:2957
static const Index NUM_VALUES
Definition: InternalNode.h:79
Definition: version.h:101
const ValueType & b
Definition: InternalNode.h:2451
TopologyDifference(const OtherInternalNode *source, InternalNode *target, const ValueType &background)
Definition: InternalNode.h:2474
const ValueType & b
Definition: InternalNode.h:2510
Base class for iterators over internal and leaf nodes.
Definition: Iterator.h:58
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:2232
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:3059
NodeType * probeNodeAndCache(const Coord &xyz, AccessorT &)
Same as probeNode() except, if necessary, update the accessor with pointers to the nodes along the pa...
_ChildNodeType ChildNodeType
Definition: InternalNode.h:69
bool isValueOn(const Coord &xyz) const
Return true if the voxel at the given coordinates is active.
Definition: InternalNode.h:1519
Definition: InternalNode.h:795
Definition: InternalNode.h:145
Index32 leafCount() const
Definition: InternalNode.h:995
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:304
NodeMaskType::DenseIterator MaskDenseIterator
Definition: InternalNode.h:142
void visit2Node(OtherNodeType &other, VisitorOp &)
Definition: InternalNode.h:2793
void save(std::ostream &os) const
Definition: NodeMasks.h:551
Index64 offVoxelCount() const
Definition: InternalNode.h:1033
void setValuesOn()
Mark all values (both tiles and voxels) as active.
Definition: InternalNode.h:1814
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.
NodeUnion< ValueType, ChildNodeType > UnionType
Definition: InternalNode.h:72
Definition: InternalNode.h:193
Definition: InternalNode.h:797
ValueOffIter beginValueOff()
Definition: InternalNode.h:263
static Index coordToOffset(const Coord &xyz)
Return the linear table offset of the given global or local coordinates.
Definition: InternalNode.h:2969