6 #ifndef OPENVDB_TREE_TREEITERATOR_HAS_BEEN_INCLUDED 7 #define OPENVDB_TREE_TREEITERATOR_HAS_BEEN_INCLUDED 9 #include <tbb/blocked_range.h> 10 #include <tbb/parallel_for.h> 11 #include <openvdb/version.h> 16 #include <type_traits> 21 #define ENABLE_TREE_VALUE_DEPTH_BOUND_OPTIMIZATION 31 template<
typename HeadT,
int HeadLevel>
34 using Type =
typename SubtreeT::template Append<HeadT>;
36 template<
typename HeadT>
58 template<
typename NodeT,
typename IterT>
61 template<
typename ChildT>
static ChildT*
getChild(
const IterT&) {
return nullptr; }
64 template<
typename NodeT>
67 using IterT =
typename NodeT::ChildOnIter;
68 static IterT begin(NodeT& node) {
return node.beginChildOn(); }
70 return &iter.getValue();
72 template<
typename OtherNodeT>
struct NodeConverter {
73 using Type =
typename OtherNodeT::ChildOnIter;
77 template<
typename NodeT>
80 using IterT =
typename NodeT::ChildOnCIter;
81 static IterT begin(
const NodeT& node) {
return node.cbeginChildOn(); }
82 template<
typename ChildT>
static const ChildT*
getChild(
const IterT& iter) {
83 return &iter.getValue();
85 template<
typename OtherNodeT>
struct NodeConverter {
86 using Type =
typename OtherNodeT::ChildOnCIter;
90 template<
typename NodeT>
93 using IterT =
typename NodeT::ChildOffIter;
94 static IterT begin(NodeT& node) {
return node.beginChildOff(); }
95 template<
typename OtherNodeT>
struct NodeConverter {
96 using Type =
typename OtherNodeT::ChildOffIter;
100 template<
typename NodeT>
103 using IterT =
typename NodeT::ChildOffCIter;
104 static IterT begin(
const NodeT& node) {
return node.cbeginChildOff(); }
105 template<
typename OtherNodeT>
struct NodeConverter {
106 using Type =
typename OtherNodeT::ChildOffCIter;
110 template<
typename NodeT>
113 using IterT =
typename NodeT::ChildAllIter;
114 static IterT begin(NodeT& node) {
return node.beginChildAll(); }
116 typename IterT::NonConstValueType val;
117 return iter.probeChild(val);
119 template<
typename OtherNodeT>
struct NodeConverter {
120 using Type =
typename OtherNodeT::ChildAllIter;
124 template<
typename NodeT>
127 using IterT =
typename NodeT::ChildAllCIter;
128 static IterT begin(
const NodeT& node) {
return node.cbeginChildAll(); }
130 typename IterT::NonConstValueType val;
131 return iter.probeChild(val);
133 template<
typename OtherNodeT>
struct NodeConverter {
134 using Type =
typename OtherNodeT::ChildAllCIter;
138 template<
typename NodeT>
141 using IterT =
typename NodeT::ValueOnIter;
142 static IterT begin(NodeT& node) {
return node.beginValueOn(); }
143 template<
typename OtherNodeT>
struct NodeConverter {
144 using Type =
typename OtherNodeT::ValueOnIter;
148 template<
typename NodeT>
151 using IterT =
typename NodeT::ValueOnCIter;
152 static IterT begin(
const NodeT& node) {
return node.cbeginValueOn(); }
153 template<
typename OtherNodeT>
struct NodeConverter {
154 using Type =
typename OtherNodeT::ValueOnCIter;
158 template<
typename NodeT>
161 using IterT =
typename NodeT::ValueOffIter;
162 static IterT begin(NodeT& node) {
return node.beginValueOff(); }
163 template<
typename OtherNodeT>
struct NodeConverter {
164 using Type =
typename OtherNodeT::ValueOffIter;
168 template<
typename NodeT>
171 using IterT =
typename NodeT::ValueOffCIter;
172 static IterT begin(
const NodeT& node) {
return node.cbeginValueOff(); }
173 template<
typename OtherNodeT>
struct NodeConverter {
174 using Type =
typename OtherNodeT::ValueOffCIter;
178 template<
typename NodeT>
181 using IterT =
typename NodeT::ValueAllIter;
182 static IterT begin(NodeT& node) {
return node.beginValueAll(); }
183 template<
typename OtherNodeT>
struct NodeConverter {
184 using Type =
typename OtherNodeT::ValueAllIter;
188 template<
typename NodeT>
191 using IterT =
typename NodeT::ValueAllCIter;
192 static IterT begin(
const NodeT& node) {
return node.cbeginValueAll(); }
193 template<
typename OtherNodeT>
struct NodeConverter {
194 using Type =
typename OtherNodeT::ValueAllCIter;
212 template<
typename PrevItemT,
typename NodeVecT,
size_t VecSize, Index _Level>
222 NodeConverter<_NodeT>::Type;
225 using NodeT =
typename IterT::NodeType;
227 using NCNodeT =
typename IterT::NonConstNodeType;
229 using NCValueT =
typename IterT::NonConstValueType;
241 mIter(other.mIter), mNext(other.mNext), mPrev(nullptr) {}
244 if (&other !=
this) {
255 template<
typename OtherIterT>
256 void setIter(
const OtherIterT& iter) { mNext.setIter(iter); }
261 node = (lvl <=
Level) ? mIter.getParentNode() :
nullptr;
264 template<
typename OtherNodeT>
265 void getNode(
Index lvl, OtherNodeT*& node)
const { mNext.getNode(lvl, node); }
272 template<
typename OtherIterListItemT>
276 const NodeT* node =
nullptr;
277 otherListItem.getNode(lvl, node);
278 mIter = (node ==
nullptr) ?
IterT() : ITraits::begin(*const_cast<NodeT*>(node));
281 mNext.initLevel(lvl, otherListItem);
286 Index pos(
Index lvl)
const {
return (lvl == Level) ? mIter.pos() : mNext.pos(lvl); }
289 bool test(
Index lvl)
const {
return (lvl == Level) ? mIter.test() : mNext.test(lvl); }
292 bool next(
Index lvl) {
return (lvl == Level) ? mIter.next() : mNext.next(lvl); }
298 if (lvl == Level && mPrev !=
nullptr && mIter) {
299 if (
ChildT*
child = ITraits::template getChild<ChildT>(mIter)) {
300 mPrev->setIter(PrevItemT::ITraits::begin(*
child));
304 return (lvl > Level) ? mNext.down(lvl) :
false;
311 return (lvl == Level) ? mIter.getCoord() : mNext.getCoord(lvl);
315 return (lvl == Level) ? NodeT::getChildDim() : mNext.getChildDim(lvl);
320 return (lvl == Level) ? ChildT::NUM_VOXELS : mNext.getVoxelCount(lvl);
326 return (lvl == Level) ? mIter.isValueOn() : mNext.isValueOn(lvl);
332 if (lvl == Level)
return mIter.getValue();
333 return mNext.getValue(lvl);
341 if (lvl == Level) mIter.setValue(val);
else mNext.setValue(lvl, val);
348 if (lvl == Level) mIter.setValueOn(on);
else mNext.setValueOn(lvl, on);
355 if (lvl == Level) mIter.setValueOff();
else mNext.setValueOff(lvl);
360 template<
typename ModifyOp>
363 if (lvl == Level) mIter.modifyValue(op);
else mNext.modifyValue(lvl, op);
367 using RestT =
typename NodeVecT::PopFront;
377 template<
typename PrevItemT,
typename NodeVecT,
size_t VecSize>
387 NodeConverter<_NodeT>::Type;
390 using NodeT =
typename IterT::NodeType;
392 using NCNodeT =
typename IterT::NonConstNodeType;
394 using NCValueT =
typename IterT::NonConstValueType;
402 mIter(other.mIter), mNext(other.mNext), mPrev(nullptr) {}
405 if (&other !=
this) {
415 mPrev =
nullptr; mNext.updateBackPointers(
this);
419 template<
typename OtherIterT>
420 void setIter(
const OtherIterT& iter) { mNext.setIter(iter); }
424 node = (lvl == 0) ? mIter.getParentNode() :
nullptr;
426 template<
typename OtherNodeT>
427 void getNode(
Index lvl, OtherNodeT*& node)
const { mNext.getNode(lvl, node); }
429 template<
typename OtherIterListItemT>
433 const NodeT* node =
nullptr;
434 otherListItem.getNode(lvl, node);
435 mIter = (node ==
nullptr) ?
IterT() : ITraits::begin(*const_cast<NodeT*>(node));
437 mNext.initLevel(lvl, otherListItem);
441 Index pos(
Index lvl)
const {
return (lvl == 0) ? mIter.pos() : mNext.pos(lvl); }
443 bool test(
Index lvl)
const {
return (lvl == 0) ? mIter.test() : mNext.test(lvl); }
445 bool next(
Index lvl) {
return (lvl == 0) ? mIter.next() : mNext.next(lvl); }
447 bool down(
Index lvl) {
return (lvl == 0) ?
false : mNext.down(lvl); }
451 return (lvl == 0) ? mIter.getCoord() : mNext.getCoord(lvl);
455 return (lvl == 0) ? NodeT::getChildDim() : mNext.getChildDim(lvl);
460 return (lvl == 0) ? 1 : mNext.getVoxelCount(lvl);
465 return (lvl == 0) ? mIter.isValueOn() : mNext.isValueOn(lvl);
470 if (lvl == 0)
return mIter.getValue();
471 return mNext.getValue(lvl);
476 if (lvl == 0) mIter.setValue(val);
else mNext.setValue(lvl, val);
480 if (lvl == 0) mIter.setValueOn(on);
else mNext.setValueOn(lvl, on);
484 if (lvl == 0) mIter.setValueOff();
else mNext.setValueOff(lvl);
487 template<
typename ModifyOp>
490 if (lvl == 0) mIter.modifyValue(op);
else mNext.modifyValue(lvl, op);
494 using RestT =
typename NodeVecT::PopFront;
504 template<
typename PrevItemT,
typename NodeVecT, Index _Level>
513 NodeConverter<_NodeT>::Type;
516 using NodeT =
typename IterT::NodeType;
518 using NCNodeT =
typename IterT::NonConstNodeType;
520 using NCValueT =
typename IterT::NonConstValueType;
534 if (&other !=
this) {
550 node = (lvl <=
Level) ? mIter.getParentNode() :
nullptr;
553 template<
typename OtherIterListItemT>
557 const NodeT* node =
nullptr;
558 otherListItem.getNode(lvl, node);
559 mIter = (node ==
nullptr) ?
IterT() : ITraits::begin(*const_cast<NodeT*>(node));
565 bool test(
Index lvl)
const {
return (lvl == Level) ? mIter.test() :
false; }
567 bool next(
Index lvl) {
return (lvl == Level) ? mIter.next() :
false; }
571 if (lvl == Level && mPrev !=
nullptr && mIter) {
572 if (
ChildT*
child = ITraits::template getChild<ChildT>(mIter)) {
573 mPrev->setIter(PrevItemT::ITraits::begin(*
child));
580 Coord
getCoord(
Index lvl)
const {
return (lvl == Level) ? mIter.getCoord() : Coord(); }
584 bool isValueOn(
Index lvl)
const {
return (lvl == Level) ? mIter.isValueOn() :
false; }
588 assert(lvl == Level);
590 return mIter.getValue();
594 void setValueOn(
Index lvl,
bool on =
true)
const {
if (lvl == Level) mIter.setValueOn(on); }
597 template<
typename ModifyOp>
600 if (lvl == Level) mIter.modifyValue(op);
615 template<
typename _TreeT,
typename _ValueIterT>
621 using NodeT =
typename ValueIterT::NodeType;
622 using ValueT =
typename ValueIterT::NonConstValueType;
625 static_assert(ValueIterT::NodeType::LEVEL == ROOT_LEVEL,
"invalid value iterator node type");
634 void setMinDepth(
Index minDepth);
638 void setMaxDepth(
Index maxDepth);
644 bool test()
const {
return mValueIterList.test(mLevel); }
645 operator bool()
const {
return this->test(); }
666 template<
typename NodeType>
667 void getNode(NodeType*& node)
const { mValueIterList.getNode(mLevel, node); }
671 Coord
getCoord()
const {
return mValueIterList.getCoord(mLevel); }
688 bool isValueOn()
const {
return mValueIterList.isValueOn(mLevel); }
711 template<
typename ModifyOp>
712 void modifyValue(
const ModifyOp& op)
const { mValueIterList.modifyValue(mLevel, op); }
718 std::string summary()
const;
721 bool advance(
bool dontIncrement =
false);
725 struct PrevValueItem {
using IterT =
ValueIterT; };
727 IterListItem<PrevChildItem, InvTreeT, ROOT_LEVEL+1, 0> mChildIterList;
728 IterListItem<PrevValueItem, InvTreeT, ROOT_LEVEL+1, 0> mValueIterList;
730 int mMinLevel, mMaxLevel;
735 template<
typename TreeT,
typename ValueIterT>
738 mChildIterList(nullptr),
739 mValueIterList(nullptr),
741 mMinLevel(int(LEAF_LEVEL)),
751 template<
typename TreeT,
typename ValueIterT>
754 mChildIterList(other.mChildIterList),
755 mValueIterList(other.mValueIterList),
756 mLevel(other.mLevel),
757 mMinLevel(other.mMinLevel),
758 mMaxLevel(other.mMaxLevel),
766 template<
typename TreeT,
typename ValueIterT>
770 if (&other !=
this) {
771 mChildIterList = other.mChildIterList;
772 mValueIterList = other.mValueIterList;
773 mLevel = other.mLevel;
774 mMinLevel = other.mMinLevel;
775 mMaxLevel = other.mMaxLevel;
784 template<
typename TreeT,
typename ValueIterT>
789 if (
int(mLevel) > mMaxLevel) this->
next();
793 template<
typename TreeT,
typename ValueIterT>
799 if (
int(mLevel) < mMinLevel) this->
next();
803 template<
typename TreeT,
typename ValueIterT>
808 if (!this->advance())
return false;
809 }
while (
int(mLevel) < mMinLevel ||
int(mLevel) > mMaxLevel);
814 template<
typename TreeT,
typename ValueIterT>
818 bool recurse =
false;
822 vPos = mValueIterList.
pos(mLevel),
823 cPos = mChildIterList.
pos(mLevel);
824 if (vPos == cPos && mChildIterList.
test(mLevel)) {
826 mValueIterList.
next(mLevel);
827 vPos = mValueIterList.
pos(mLevel);
830 if (dontIncrement)
return true;
831 if (mValueIterList.
next(mLevel)) {
832 if (mValueIterList.
pos(mLevel) == cPos && mChildIterList.
test(mLevel)) {
835 mValueIterList.
next(mLevel);
838 if (mValueIterList.
pos(mLevel) < cPos)
return true;
842 if (!dontIncrement) mChildIterList.
next(mLevel);
844 #ifdef DEBUG_TREE_VALUE_ITERATOR 845 std::cout <<
"\n" << this->
summary() << std::flush;
849 while (mChildIterList.
pos(mLevel) < mValueIterList.
pos(mLevel)) {
850 #ifdef ENABLE_TREE_VALUE_DEPTH_BOUND_OPTIMIZATION 851 if (
int(mLevel) == mMinLevel) {
854 mChildIterList.
next(mLevel);
855 if (mValueIterList.
pos(mLevel) == mChildIterList.
pos(mLevel)
856 && mChildIterList.
test(mLevel))
860 mValueIterList.
next(mLevel);
864 if (mChildIterList.
down(mLevel)) {
866 mValueIterList.
initLevel(mLevel, mChildIterList);
867 if (mValueIterList.
pos(mLevel) == mChildIterList.
pos(mLevel)
868 && mChildIterList.
test(mLevel))
872 mValueIterList.
next(mLevel);
875 #ifdef DEBUG_TREE_VALUE_ITERATOR 876 std::cout <<
"\n" << this->
summary() << std::flush;
880 while (!mChildIterList.
test(mLevel) && !mValueIterList.
test(mLevel)) {
883 mChildIterList.
next(mLevel);
884 dontIncrement =
true;
892 template<
typename TreeT,
typename ValueIterT>
900 bbox.min() = mValueIterList.
getCoord(mLevel);
901 bbox.max() = bbox.min().offsetBy(mValueIterList.
getChildDim(mLevel) - 1);
906 template<
typename TreeT,
typename ValueIterT>
910 std::ostringstream ostr;
911 for (
int lvl =
int(
ROOT_LEVEL); lvl >= 0 && lvl >= int(mLevel); --lvl) {
912 if (lvl == 0) ostr <<
"leaf";
913 else if (lvl ==
int(
ROOT_LEVEL)) ostr <<
"root";
915 ostr <<
" v" << mValueIterList.
pos(lvl)
916 <<
" c" << mChildIterList.
pos(lvl);
917 if (lvl >
int(mLevel)) ostr <<
" / ";
919 if (this->
test() && mValueIterList.
pos(mLevel) < mChildIterList.
pos(mLevel)) {
934 template<
typename _TreeT,
typename RootChildOnIterT>
965 bool test()
const {
return !mDone; }
966 operator bool()
const {
return this->
test(); }
1001 template<
typename NodeT>
1002 void getNode(
NodeT*& node)
const { node =
nullptr; mIterList.getNode(mLevel, node); }
1003 template<
typename NodeT>
1004 void getNode(
const NodeT*& node)
const { node =
nullptr; mIterList.getNode(mLevel, node); }
1012 struct PrevItem {
using IterT =
RootIterT; };
1016 int mMinLevel, mMaxLevel;
1022 template<
typename TreeT,
typename RootChildOnIterT>
1035 template<
typename TreeT,
typename RootChildOnIterT>
1045 mIterList.
setIter(RootIterTraits::begin(tree.root()));
1049 template<
typename TreeT,
typename RootChildOnIterT>
1052 mIterList(other.mIterList),
1053 mLevel(other.mLevel),
1054 mMinLevel(other.mMinLevel),
1055 mMaxLevel(other.mMaxLevel),
1063 template<
typename TreeT,
typename RootChildOnIterT>
1067 if (&other !=
this) {
1068 mLevel = other.mLevel;
1069 mMinLevel = other.mMinLevel;
1070 mMaxLevel = other.mMaxLevel;
1071 mDone = other.mDone;
1072 mTree = other.mTree;
1073 mIterList = other.mIterList;
1080 template<
typename TreeT,
typename RootChildOnIterT>
1085 if (
int(mLevel) > mMaxLevel) this->
next();
1089 template<
typename TreeT,
typename RootChildOnIterT>
1095 if (
int(mLevel) < mMinLevel) this->
next();
1099 template<
typename TreeT,
typename RootChildOnIterT>
1104 if (mDone)
return false;
1108 if (
int(mLevel) > mMinLevel && mIterList.
test(mLevel)) {
1109 if (!mIterList.
down(mLevel))
return false;
1113 while (!mIterList.
test(mLevel)) {
1120 mIterList.
next(mLevel);
1123 if (!mIterList.
down(mLevel))
return false;
1126 }
while (
int(mLevel) < mMinLevel || int(mLevel) > mMaxLevel);
1131 template<
typename TreeT,
typename RootChildOnIterT>
1138 return root ? root->getMinIndex() :
Coord::min();
1142 template<
typename TreeT,
typename RootChildOnIterT>
1149 if (root ==
nullptr) {
1153 root->getIndexRange(bbox);
1156 bbox.min() = mIterList.
getCoord(mLevel + 1);
1157 bbox.max() = bbox.min().offsetBy(mIterList.
getChildDim(mLevel + 1) - 1);
1162 template<
typename TreeT,
typename RootChildOnIterT>
1166 std::ostringstream ostr;
1167 for (
int lvl =
int(
ROOT_LEVEL); lvl >= 0 && lvl >= int(mLevel); --lvl) {
1168 if (lvl == 0) ostr <<
"leaf";
1169 else if (lvl ==
int(
ROOT_LEVEL)) ostr <<
"root";
1171 ostr <<
" c" << mIterList.
pos(lvl);
1172 if (lvl >
int(mLevel)) ostr <<
" / ";
1176 ostr <<
" " << bbox;
1185 template<
typename TreeT,
typename RootChildOnIterT>
1205 mIterList.setIter(RootIterTraits::begin(tree.root()));
1208 for ( ; lvl > 0 && mIterList.down(lvl); --lvl) {}
1210 if (lvl > 0) this->
next();
1215 mIterList.updateBackPointers();
1219 if (&other !=
this) {
1220 mTree = other.mTree;
1221 mIterList = other.mIterList;
1232 mIterList.getNode(LEAF_LEVEL, n);
1239 bool test()
const {
return mIterList.test(LEAF_PARENT_LEVEL); }
1240 operator bool()
const {
return this->
test(); }
1254 struct PrevItem {
using IterT =
RootIterT; };
1264 template<
typename TreeT,
typename RootChildOnIterT>
1270 if (mIterList.test(LEAF_PARENT_LEVEL) && mIterList.next(LEAF_PARENT_LEVEL)) {
1271 mIterList.down(LEAF_PARENT_LEVEL);
1275 Index lvl = LEAF_PARENT_LEVEL;
1276 while (!mIterList.test(LEAF_PARENT_LEVEL)) {
1277 if (mIterList.test(lvl)) {
1278 mIterList.next(lvl);
1285 if (mIterList.test(lvl)) mIterList.next(lvl);
1286 }
while (!mIterList.test(lvl));
1289 while (lvl > LEAF_PARENT_LEVEL && mIterList.down(lvl)) --lvl;
1291 mIterList.down(LEAF_PARENT_LEVEL);
1301 template<
typename IterT>
1307 mGrainSize(grainSize),
1310 mSize = this->size();
1314 mGrainSize(other.mGrainSize),
1315 mSize(other.mSize >> 1)
1325 bool empty()
const {
return mSize == 0 || !mIter.test(); }
1326 bool test()
const {
return !this->empty(); }
1327 operator bool()
const {
return !this->empty(); }
1334 void increment(
Index n = 1) {
for ( ; n > 0 && mSize > 0; --n, --mSize, ++mIter) {} }
1342 Index size()
const {
Index n = 0;
for (IterT it(mIter); it.test(); ++n, ++it) {}
return n; }
1364 #endif // OPENVDB_TREE_TREEITERATOR_HAS_BEEN_INCLUDED LeafIteratorBase & operator++()
Advance the iterator to the next leaf node.
Definition: TreeIterator.h:1246
IterListItem(const IterListItem &other)
Definition: TreeIterator.h:240
Index getChildDim(Index lvl) const
Definition: TreeIterator.h:313
bool test() const
Definition: TreeIterator.h:1239
Index getMaxDepth() const
Return the depth of the lowest level of the tree to which this iterator ascends.
Definition: TreeIterator.h:640
static const Index ROOT_LEVEL
Definition: TreeIterator.h:624
ChildT * child
Definition: GridBuilder.h:1286
void setValue(Index lvl, const NCValueT &val) const
Definition: TreeIterator.h:474
typename IterT::NodeType NodeT
The type of node over which IterT iterates (e.g., const RootNode<...>)
Definition: TreeIterator.h:516
typename OtherNodeT::ChildOnIter Type
Definition: TreeIterator.h:73
void setIter(const IterT &iter)
Definition: TreeIterator.h:418
typename ValueIterT::NonConstValueType ValueT
Definition: TreeIterator.h:622
void getNode(const NodeT *&node) const
Return the node to which the iterator is pointing.
Definition: TreeIterator.h:1004
const ValueT * operator->() const
Return the tile or voxel value to which this iterator is currently pointing.
Definition: TreeIterator.h:694
bool down(Index lvl)
Definition: TreeIterator.h:569
std::string summary() const
Definition: TreeIterator.h:1164
Coord getCoord() const
Return the global coordinates of the voxel or tile to which this iterator is currently pointing...
Definition: TreeIterator.h:1133
IterListItem(PrevItemT *prev)
Definition: TreeIterator.h:238
void increment(Index n=1)
Advance the iterator n times.
Definition: TreeIterator.h:1334
void getNode(Index lvl, OtherNodeT *&node) const
Definition: TreeIterator.h:427
typename NodeVecT::Front _NodeT
Definition: TreeIterator.h:508
Mat3< typename promote< T0, T1 >::type > operator*(const Mat3< T0 > &m0, const Mat3< T1 > &m1)
Multiply m0 by m1 and return the resulting matrix.
Definition: Mat3.h:611
_TreeT TreeT
Definition: TreeIterator.h:619
void getNode(Index lvl, NodeT *&node) const
Definition: TreeIterator.h:548
void increment(Index n)
Increment the iterator n times.
Definition: TreeIterator.h:976
void increment()
Advance the iterator to the next leaf node.
Definition: TreeIterator.h:1245
typename RootIterT::NonConstNodeType NCRootNodeT
Definition: TreeIterator.h:1191
typename OtherNodeT::ChildAllIter Type
Definition: TreeIterator.h:120
LeafIteratorBase(TreeT &tree)
Definition: TreeIterator.h:1202
static ChildT * getChild(const IterT &)
Definition: TreeIterator.h:61
CoordBBox getBoundingBox() const
Return the axis-aligned bounding box of the voxel or tile to which this iterator is currently pointin...
Definition: TreeIterator.h:995
void setValue(Index lvl, const NCValueT &val) const
Definition: TreeIterator.h:593
bool test(Index lvl) const
Definition: TreeIterator.h:565
Coord getCoord(Index lvl) const
Definition: TreeIterator.h:449
static IterT begin(const NodeT &node)
Definition: TreeIterator.h:172
bool isTileValue() const
Return true if this iterator is currently pointing to a (non-leaf) tile value.
Definition: TreeIterator.h:684
void setIter(const IterT &iter)
Definition: TreeIterator.h:254
Index64 getVoxelCount() const
Return the number of (virtual) voxels corresponding to the value.
Definition: TreeIterator.h:681
void setMinDepth(Index minDepth)
Specify the depth of the highest level of the tree to which to ascend (depth 0 = root).
Definition: TreeIterator.h:786
static const Index LEAF_DEPTH
Definition: TreeIterator.h:626
typename CopyConstness< NodeT, typename NodeT::ChildNodeType >::Type ChildT
NodeT's child node type, with the same constness (e.g., const InternalNode<...>)
Definition: TreeIterator.h:522
typename CopyConstness< NodeT, typename NodeT::ChildNodeType >::Type ChildT
NodeT's child node type, with the same constness (e.g., const InternalNode<...>)
Definition: TreeIterator.h:231
static IterT begin(NodeT &node)
Definition: TreeIterator.h:114
typename OtherNodeT::ChildAllCIter Type
Definition: TreeIterator.h:134
IterListItem(const IterListItem &other)
Definition: TreeIterator.h:531
typename IterT::NonConstValueType NCValueT
The type of value (with const qualifiers removed) to which the iterator points.
Definition: TreeIterator.h:229
const IterT & iterator() const
Return a reference to this range's iterator.
Definition: TreeIterator.h:1323
bool isValueOn(Index lvl) const
Definition: TreeIterator.h:584
void setMinDepth(Index minDepth)
Specify the depth of the highest level of the tree to which to ascend (depth 0 = root).
Definition: TreeIterator.h:1082
typename OtherNodeT::ValueAllIter Type
Definition: TreeIterator.h:184
typename iter::InvertedTree< NCRootNodeT, ROOT_LEVEL >::Type InvTreeT
Definition: TreeIterator.h:943
typename RootIterT::NonConstNodeType NCRootNodeT
Definition: TreeIterator.h:941
TreeValueIteratorBase & operator=(const TreeValueIteratorBase &other)
Definition: TreeIterator.h:768
IterListItem & operator=(const IterListItem &other)
Definition: TreeIterator.h:532
IteratorRange & operator++()
Advance the iterator to the next item.
Definition: TreeIterator.h:1336
Index getMaxDepth() const
Return the depth of the lowest level of the tree to which this iterator ascends.
Definition: TreeIterator.h:961
static IterT begin(const NodeT &node)
Definition: TreeIterator.h:152
NodeIteratorBase & operator++()
Definition: TreeIterator.h:974
IteratorRange(const IterT &iter, size_t grainSize=8)
Definition: TreeIterator.h:1305
void getNode(Index lvl, OtherNodeT *&node) const
Return the node over which one of the following list elements' iterator iterates. ...
Definition: TreeIterator.h:265
void setValueOn(Index lvl, bool on=true) const
Set the value (to val) to which the iterator at level lvl of the tree points and mark the value as ac...
Definition: TreeIterator.h:346
Index getChildDim(Index lvl) const
Definition: TreeIterator.h:581
IterListItem(PrevItemT *prev)
Definition: TreeIterator.h:529
static IterT begin(NodeT &node)
Definition: TreeIterator.h:182
IterListItem(const IterListItem &other)
Definition: TreeIterator.h:401
IteratorRange(IteratorRange &other, tbb::split)
Definition: TreeIterator.h:1312
void initLevel(Index lvl, OtherIterListItemT &otherListItem)
Initialize the iterator for level lvl of the tree with the node over which the corresponding iterator...
Definition: TreeIterator.h:273
void getNode(Index lvl, NodeT *&node) const
Return the node over which this list element's iterator iterates.
Definition: TreeIterator.h:259
static IterT begin(const NodeT &node)
Definition: TreeIterator.h:104
void initLevel(Index lvl, OtherIterListItemT &otherListItem)
Definition: TreeIterator.h:554
typename CopyConstness< RootNodeT, NCLeafNodeT >::Type LeafNodeT
Definition: TreeIterator.h:1195
bool next()
Advance the iterator to the next item.
Definition: TreeIterator.h:1339
void setActiveState(bool on) const
Change the active/inactive state of the tile or voxel value to which this iterator is currently point...
Definition: TreeIterator.h:702
typename NodeT::ValueOffIter IterT
Definition: TreeIterator.h:161
void setValueOn(Index lvl, bool on=true) const
Definition: TreeIterator.h:594
typename NodeT::ChildOffIter IterT
Definition: TreeIterator.h:93
typename NodeT::ChildOnCIter IterT
Definition: TreeIterator.h:80
static const Index LEAF_LEVEL
Definition: TreeIterator.h:626
typename IterTraits< typename PrevIterT::NonConstNodeType, PrevIterT >::template NodeConverter< _NodeT >::Type IterT
The type of iterator stored in this list item (e.g., RootNode::ValueOnCIter)
Definition: TreeIterator.h:513
typename IterT::NonConstNodeType NCNodeT
The type of the node with const qualifiers removed ("Non-Const")
Definition: TreeIterator.h:392
static Index getLeafDepth()
Definition: TreeIterator.h:660
typename OtherNodeT::ChildOnCIter Type
Definition: TreeIterator.h:86
static ChildT * getChild(const IterT &iter)
Definition: TreeIterator.h:129
static const Index ROOT_DEPTH
Definition: TreeIterator.h:626
TreeT * getTree() const
Definition: TreeIterator.h:1251
BBox< Coord > CoordBBox
Definition: NanoVDB.h:1658
static Index getLeafDepth()
Definition: TreeIterator.h:984
typename IterT::NodeType NodeT
The type of node (const or non-const) over which IterT iterates (e.g., const RootNode<...>)
Definition: TreeIterator.h:225
bool test(Index lvl) const
Definition: TreeIterator.h:443
typename OtherNodeT::ChildOffCIter Type
Definition: TreeIterator.h:106
typename OtherNodeT::ValueOffIter Type
Definition: TreeIterator.h:164
Index64 getVoxelCount(Index lvl) const
Definition: TreeIterator.h:582
typename NodeT::ChildAllCIter IterT
Definition: TreeIterator.h:127
static const Index ROOT_LEVEL
Definition: TreeIterator.h:942
void updateBackPointers(PrevItemT *prev)
Definition: TreeIterator.h:252
bool next()
Advance to the next tile or voxel value.
Definition: TreeIterator.h:1101
typename PrevItem::IterT PrevIterT
The type of iterator stored in the previous list item.
Definition: TreeIterator.h:217
IterListItem & operator=(const IterListItem &other)
Definition: TreeIterator.h:403
NodeIteratorBase()
Definition: TreeIterator.h:1024
bool next(Index lvl)
Definition: TreeIterator.h:445
typename NodeT::ChildOffCIter IterT
Definition: TreeIterator.h:103
TreeT * getTree() const
Definition: TreeIterator.h:1007
static ChildT * getChild(const IterT &iter)
Definition: TreeIterator.h:69
typename IterT::NodeType NodeT
The type of node (const or non-const) over which IterT iterates (e.g., const RootNode<...>)
Definition: TreeIterator.h:390
Coord getCoord(Index lvl) const
Definition: TreeIterator.h:580
CoordBBox getBoundingBox() const
Return the axis-aligned bounding box of the voxel or tile to which this iterator is currently pointin...
Definition: TreeIterator.h:678
bool next()
Advance to the next tile or voxel value. Return true if this iterator is not yet exhausted.
Definition: TreeIterator.h:805
static ChildT * getChild(const IterT &iter)
Definition: TreeIterator.h:115
bool empty() const
Definition: TreeIterator.h:1325
bool next()
Advance the iterator to the next leaf node.
Definition: TreeIterator.h:1266
void modifyValue(Index lvl, const ModifyOp &op) const
Definition: TreeIterator.h:598
typename RootIterT::NodeType RootNodeT
Definition: TreeIterator.h:940
static const Index LEAF_LEVEL
Definition: TreeIterator.h:944
static IterT begin(NodeT &node)
Definition: TreeIterator.h:94
IterListItem & operator=(const IterListItem &other)
Definition: TreeIterator.h:242
typename IterT::NonConstValueType NCValueT
The type of value (with const qualifiers removed) to which the iterator points.
Definition: TreeIterator.h:520
typename InvertedTree< typename HeadT::ChildNodeType, HeadLevel-1 >::Type SubtreeT
Definition: TreeIterator.h:33
void increment(Index n)
Increment the iterator n times.
Definition: TreeIterator.h:1249
void setIter(const OtherIterT &iter)
Definition: TreeIterator.h:256
void setMaxDepth(Index maxDepth)
Specify the depth of the lowest level of the tree to which to descend (depth 0 = root).
Definition: TreeIterator.h:795
void getNode(NodeT *&node) const
Return the node to which the iterator is pointing.
Definition: TreeIterator.h:1002
void setValue(const ValueT &val) const
Change the tile or voxel value to which this iterator is currently pointing and mark it as active...
Definition: TreeIterator.h:699
Definition: TreeIterator.h:59
Base class for tree-traversal iterators over tile and voxel values.
Definition: TreeIterator.h:616
#define ROOT_LEVEL
Definition: CNanoVDB.h:53
bool test(Index lvl) const
Return true if the iterator at level lvl of the tree has not yet reached its end. ...
Definition: TreeIterator.h:289
typename NodeT::ValueOffCIter IterT
Definition: TreeIterator.h:171
static IterT begin(NodeT &node)
Definition: TreeIterator.h:162
bool is_divisible() const
Return true if this range is splittable (i.e., if the iterator can be advanced more than mGrainSize t...
Definition: TreeIterator.h:1331
void getNode(Index lvl, NodeT *&node) const
Definition: TreeIterator.h:422
static const ChildT * getChild(const IterT &iter)
Definition: TreeIterator.h:82
uint64_t Index64
Definition: Types.h:53
Base class for tree-traversal iterators over all nodes.
Definition: TreeIterator.h:935
typename OtherNodeT::ChildOffIter Type
Definition: TreeIterator.h:96
Definition: Exceptions.h:13
static IterT begin(NodeT &node)
Definition: TreeIterator.h:142
void setValueOff() const
Mark the tile or voxel value to which this iterator is currently pointing as inactive.
Definition: TreeIterator.h:704
bool down(Index lvl)
If the iterator at level lvl of the tree points to a child node, initialize the next iterator in this...
Definition: TreeIterator.h:296
LeafIteratorBase(const LeafIteratorBase &other)
Definition: TreeIterator.h:1213
void setMaxDepth(Index maxDepth)
Specify the depth of the lowest level of the tree to which to descend (depth 0 = root).
Definition: TreeIterator.h:1091
Base class for tree-traversal iterators over all leaf nodes (but not leaf voxels) ...
Definition: TreeIterator.h:1186
Index pos(Index lvl) const
Return The table offset of the iterator at level lvl of the tree.
Definition: TreeIterator.h:286
typename IterT::NonConstNodeType NCNodeT
The type of the node with const qualifiers removed ("Non-Const")
Definition: TreeIterator.h:518
NodeIteratorBase & operator=(const NodeIteratorBase &other)
Definition: TreeIterator.h:1065
typename NodeT::ValueAllIter IterT
Definition: TreeIterator.h:181
void setValueOff(Index lvl) const
Definition: TreeIterator.h:482
const ValueT & getValue() const
Return the tile or voxel value to which this iterator is currently pointing.
Definition: TreeIterator.h:692
const ValueT & operator*() const
Return the tile or voxel value to which this iterator is currently pointing.
Definition: TreeIterator.h:693
typename OtherNodeT::ValueOnCIter Type
Definition: TreeIterator.h:154
typename OtherNodeT::ValueOnIter Type
Definition: TreeIterator.h:144
typename RootIterT::NodeType RootNodeT
Definition: TreeIterator.h:1190
void initLevel(Index lvl, OtherIterListItemT &otherListItem)
Definition: TreeIterator.h:430
Index32 Index
Definition: Types.h:54
Index getMinDepth() const
Return the depth of the highest level of the tree to which this iterator ascends. ...
Definition: TreeIterator.h:957
typename SubtreeT::template Append< HeadT > Type
Definition: TreeIterator.h:34
static IterT begin(const NodeT &node)
Definition: TreeIterator.h:128
void setValue(Index lvl, const NCValueT &val) const
Set the value (to val) to which the iterator at level lvl of the tree points and mark the value as ac...
Definition: TreeIterator.h:339
bool isValueOn(Index lvl) const
Return true if the iterator at level lvl of the tree points to an active value.
Definition: TreeIterator.h:324
void modifyValue(Index lvl, const ModifyOp &op) const
Apply a functor to the item to which this iterator is pointing.
Definition: TreeIterator.h:361
const NCValueT & getValue(Index lvl) const
Definition: TreeIterator.h:586
Index64 getVoxelCount(Index lvl) const
Return the number of (virtual) voxels spanned by a tile value or child node.
Definition: TreeIterator.h:318
bool down(Index lvl)
Definition: TreeIterator.h:447
Index pos(Index lvl) const
Definition: TreeIterator.h:563
Definition: TreeIterator.h:32
typename OtherNodeT::ValueOffCIter Type
Definition: TreeIterator.h:174
void increment()
Advance the iterator to the next leaf node.
Definition: TreeIterator.h:973
void updateBackPointers(PrevItemT *prev)
Definition: TreeIterator.h:541
LeafNodeT * getLeaf() const
Return the leaf node to which the iterator is pointing.
Definition: TreeIterator.h:1229
typename IterT::NonConstNodeType NCNodeT
The type of the node with const qualifiers removed ("Non-Const")
Definition: TreeIterator.h:227
bool isValueOn(Index lvl) const
Definition: TreeIterator.h:463
typename CopyConstness< NCNodeT, typename NCNodeT::ChildNodeType >::Type NCChildT
NodeT's child node type with const qualifiers removed.
Definition: TreeIterator.h:233
bool test() const
Return true if this iterator is not yet exhausted.
Definition: TreeIterator.h:644
void getNode(NodeType *&node) const
Return in node a pointer to the node over which this iterator is currently iterating or one of that n...
Definition: TreeIterator.h:667
LeafIteratorBase()
Definition: TreeIterator.h:1200
bool test() const
Return true if this iterator is not yet exhausted.
Definition: TreeIterator.h:965
void modifyValue(const ModifyOp &op) const
Apply a functor to the item to which this iterator is pointing. (Not valid for const iterators...
Definition: TreeIterator.h:712
LeafIteratorBase & operator=(const LeafIteratorBase &other)
Definition: TreeIterator.h:1217
typename iter::InvertedTree< NCRootNodeT, ROOT_LEVEL >::Type InvTreeT
Definition: TreeIterator.h:1193
Coord getCoord() const
Return the global coordinates of the voxel or tile to which this iterator is currently pointing...
Definition: TreeIterator.h:671
typename NodeVecT::Front _NodeT
The type of node (non-const) whose iterator is stored in this list item.
Definition: TreeIterator.h:384
bool next(Index lvl)
Increment the iterator at level lvl of the tree.
Definition: TreeIterator.h:292
const NCValueT & getValue(Index lvl) const
Definition: TreeIterator.h:468
void setValueOff(Index lvl) const
Definition: TreeIterator.h:595
typename IterTraits< typename PrevIterT::NonConstNodeType, PrevIterT >::template NodeConverter< _NodeT >::Type IterT
The type of iterator stored in this list item (e.g., InternalNode::ValueOnCIter)
Definition: TreeIterator.h:222
void setIter(const IterT &iter)
Definition: TreeIterator.h:546
typename NodeT::ChildAllIter IterT
Definition: TreeIterator.h:113
Index getChildDim(Index lvl) const
Definition: TreeIterator.h:453
Index getDepth() const
Return the depth in the tree (0 = root) of the node to which this iterator is currently pointing...
Definition: TreeIterator.h:659
bool next(Index lvl)
Definition: TreeIterator.h:567
IterListItem(PrevItemT *)
Definition: TreeIterator.h:399
bool isValueOn() const
Return true if the value to which this iterator is currently pointing is active.
Definition: TreeIterator.h:688
typename NodeT::ChildOnIter IterT
Definition: TreeIterator.h:67
typename NodeT::ValueOnCIter IterT
Definition: TreeIterator.h:151
LeafNodeT * operator->() const
Return the leaf node to which the iterator is pointing.
Definition: TreeIterator.h:1236
void setIter(const OtherIterT &iter)
Definition: TreeIterator.h:420
void setValueOff(Index lvl) const
Mark the value to which the iterator at level lvl of the tree points as inactive. ...
Definition: TreeIterator.h:353
Index getDepth() const
Return the depth in the tree (0 = root) of the node to which this iterator is currently pointing...
Definition: TreeIterator.h:983
typename NodeT::ValueOnIter IterT
Definition: TreeIterator.h:141
typename CopyConstness< NCNodeT, typename NCNodeT::ChildNodeType >::Type NCChildT
NodeT's child node type with const qualifiers removed.
Definition: TreeIterator.h:524
Index getLevel() const
Return the level in the tree (0 = leaf) of the node to which this iterator is currently pointing...
Definition: TreeIterator.h:980
_TreeT TreeT
Definition: TreeIterator.h:938
Coord getCoord(Index lvl) const
Return the global coordinates of the voxel or tile to which the iterator at level lvl of the tree is ...
Definition: TreeIterator.h:309
typename PrevItemT::IterT PrevIterT
The type of iterator stored in the previous list item.
Definition: TreeIterator.h:382
typename std::remove_const< ToType >::type Type
Definition: Types.h:400
Definition: TreeIterator.h:1302
Index pos(Index lvl) const
Definition: TreeIterator.h:441
typename IterTraits< typename PrevIterT::NonConstNodeType, PrevIterT >::template NodeConverter< _NodeT >::Type IterT
The type of iterator stored in this list item (e.g., InternalNode::ValueOnCIter)
Definition: TreeIterator.h:387
typename IterT::NonConstValueType NCValueT
The type of value (with const qualifiers removed) to which the iterator points.
Definition: TreeIterator.h:394
RootChildOnIterT RootIterT
Definition: TreeIterator.h:939
RootChildOnIterT RootIterT
Definition: TreeIterator.h:1189
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition: version.h.in:116
bool test() const
Definition: TreeIterator.h:1326
typename NodeT::ChildOnCIter ChildOnIterT
Definition: TreeIterator.h:623
LeafNodeT & operator*() const
Return the leaf node to which the iterator is pointing.
Definition: TreeIterator.h:1235
Index64 getVoxelCount(Index lvl) const
Definition: TreeIterator.h:458
static IterT begin(const NodeT &node)
Definition: TreeIterator.h:81
bool isVoxelValue() const
Return true if this iterator is currently pointing to a (leaf) voxel value.
Definition: TreeIterator.h:686
static IterT begin(const NodeT &node)
Definition: TreeIterator.h:192
Index getLevel() const
Return the level in the tree (0 = leaf) of the node to which this iterator is currently pointing...
Definition: TreeIterator.h:656
A list of types (not necessarily unique)
Definition: TypeList.h:365
typename InvTreeT::Front NCLeafNodeT
Definition: TreeIterator.h:1194
void modifyValue(Index lvl, const ModifyOp &op) const
Definition: TreeIterator.h:488
typename ValueIterT::NodeType NodeT
Definition: TreeIterator.h:621
void updateBackPointers(PrevItemT *=nullptr)
Definition: TreeIterator.h:413
const NCValueT & getValue(Index lvl) const
Return the value to which the iterator at level lvl of the tree points.
Definition: TreeIterator.h:330
typename PrevItemT::IterT PrevIterT
The type of iterator stored in the previous list item.
Definition: TreeIterator.h:510
TreeT * getTree() const
Return a pointer to the tree over which this iterator is iterating.
Definition: TreeIterator.h:715
TreeValueIteratorBase(TreeT &)
Definition: TreeIterator.h:737
_ValueIterT ValueIterT
Definition: TreeIterator.h:620
typename InvTreeT::Front _NodeT
The type of node (non-const) whose iterator is stored in this list item.
Definition: TreeIterator.h:219
typename NodeT::ValueAllCIter IterT
Definition: TreeIterator.h:191
static IterT begin(NodeT &node)
Definition: TreeIterator.h:68
An IterListItem is an element of a compile-time linked list of iterators to nodes of different types...
Definition: TreeIterator.h:213
std::string summary() const
Return a string (for debugging, mainly) describing this iterator's current state. ...
Definition: TreeIterator.h:908
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h.in:202
void setValueOn(Index lvl, bool on=true) const
Definition: TreeIterator.h:478
Index getMinDepth() const
Return the depth of the highest level of the tree to which this iterator ascends. ...
Definition: TreeIterator.h:636
typename OtherNodeT::ValueAllCIter Type
Definition: TreeIterator.h:194
TreeValueIteratorBase & operator++()
Advance to the next tile or voxel value.
Definition: TreeIterator.h:652
Level
Message severity level.
Definition: logging.h:31