Go to the documentation of this file.
33 #ifndef OPENVDB_TREE_TREEITERATOR_HAS_BEEN_INCLUDED
34 #define OPENVDB_TREE_TREEITERATOR_HAS_BEEN_INCLUDED
36 #include <boost/mpl/front.hpp>
37 #include <boost/mpl/pop_front.hpp>
38 #include <boost/mpl/push_back.hpp>
39 #include <boost/mpl/size.hpp>
40 #include <boost/mpl/vector.hpp>
41 #include <tbb/blocked_range.h>
42 #include <tbb/parallel_for.h>
48 #include <type_traits>
53 #define ENABLE_TREE_VALUE_DEPTH_BOUND_OPTIMIZATION
63 template<
typename HeadT,
int HeadLevel>
66 using Type =
typename boost::mpl::push_back<SubtreeT, HeadT>::type;
68 template<
typename HeadT>
70 using Type =
typename boost::mpl::vector<typename HeadT::ChildNodeType, HeadT>::type;
90 template<
typename NodeT,
typename IterT>
93 template<
typename ChildT>
static ChildT*
getChild(
const IterT&) {
return nullptr; }
96 template<
typename NodeT>
99 using IterT =
typename NodeT::ChildOnIter;
100 static IterT begin(NodeT& node) {
return node.beginChildOn(); }
102 return &iter.getValue();
104 template<
typename OtherNodeT>
struct NodeConverter {
105 using Type =
typename OtherNodeT::ChildOnIter;
109 template<
typename NodeT>
112 using IterT =
typename NodeT::ChildOnCIter;
113 static IterT begin(
const NodeT& node) {
return node.cbeginChildOn(); }
114 template<
typename ChildT>
static const ChildT*
getChild(
const IterT& iter) {
115 return &iter.getValue();
117 template<
typename OtherNodeT>
struct NodeConverter {
118 using Type =
typename OtherNodeT::ChildOnCIter;
122 template<
typename NodeT>
125 using IterT =
typename NodeT::ChildOffIter;
126 static IterT begin(NodeT& node) {
return node.beginChildOff(); }
127 template<
typename OtherNodeT>
struct NodeConverter {
128 using Type =
typename OtherNodeT::ChildOffIter;
132 template<
typename NodeT>
135 using IterT =
typename NodeT::ChildOffCIter;
136 static IterT begin(
const NodeT& node) {
return node.cbeginChildOff(); }
137 template<
typename OtherNodeT>
struct NodeConverter {
138 using Type =
typename OtherNodeT::ChildOffCIter;
142 template<
typename NodeT>
145 using IterT =
typename NodeT::ChildAllIter;
146 static IterT begin(NodeT& node) {
return node.beginChildAll(); }
148 typename IterT::NonConstValueType val;
149 return iter.probeChild(val);
151 template<
typename OtherNodeT>
struct NodeConverter {
152 using Type =
typename OtherNodeT::ChildAllIter;
156 template<
typename NodeT>
159 using IterT =
typename NodeT::ChildAllCIter;
160 static IterT begin(
const NodeT& node) {
return node.cbeginChildAll(); }
162 typename IterT::NonConstValueType val;
163 return iter.probeChild(val);
165 template<
typename OtherNodeT>
struct NodeConverter {
166 using Type =
typename OtherNodeT::ChildAllCIter;
170 template<
typename NodeT>
173 using IterT =
typename NodeT::ValueOnIter;
174 static IterT begin(NodeT& node) {
return node.beginValueOn(); }
175 template<
typename OtherNodeT>
struct NodeConverter {
176 using Type =
typename OtherNodeT::ValueOnIter;
180 template<
typename NodeT>
183 using IterT =
typename NodeT::ValueOnCIter;
184 static IterT begin(
const NodeT& node) {
return node.cbeginValueOn(); }
185 template<
typename OtherNodeT>
struct NodeConverter {
186 using Type =
typename OtherNodeT::ValueOnCIter;
190 template<
typename NodeT>
193 using IterT =
typename NodeT::ValueOffIter;
194 static IterT begin(NodeT& node) {
return node.beginValueOff(); }
195 template<
typename OtherNodeT>
struct NodeConverter {
196 using Type =
typename OtherNodeT::ValueOffIter;
200 template<
typename NodeT>
203 using IterT =
typename NodeT::ValueOffCIter;
204 static IterT begin(
const NodeT& node) {
return node.cbeginValueOff(); }
205 template<
typename OtherNodeT>
struct NodeConverter {
206 using Type =
typename OtherNodeT::ValueOffCIter;
210 template<
typename NodeT>
213 using IterT =
typename NodeT::ValueAllIter;
214 static IterT begin(NodeT& node) {
return node.beginValueAll(); }
215 template<
typename OtherNodeT>
struct NodeConverter {
216 using Type =
typename OtherNodeT::ValueAllIter;
220 template<
typename NodeT>
223 using IterT =
typename NodeT::ValueAllCIter;
224 static IterT begin(
const NodeT& node) {
return node.cbeginValueAll(); }
225 template<
typename OtherNodeT>
struct NodeConverter {
226 using Type =
typename OtherNodeT::ValueAllCIter;
244 template<
typename PrevItemT,
typename NodeVecT,
size_t VecSize, Index _Level>
251 using _NodeT =
typename boost::mpl::front<NodeVecT>::type;
254 NodeConverter<_NodeT>::Type;
257 using NodeT =
typename IterT::NodeType;
259 using NCNodeT =
typename IterT::NonConstNodeType;
261 using NCValueT =
typename IterT::NonConstValueType;
273 mIter(other.mIter), mNext(other.mNext), mPrev(nullptr) {}
276 if (&other !=
this) {
287 template<
typename OtherIterT>
288 void setIter(
const OtherIterT& iter) { mNext.setIter(iter); }
293 node = (lvl <=
Level) ? mIter.getParentNode() :
nullptr;
296 template<
typename OtherNodeT>
297 void getNode(
Index lvl, OtherNodeT*& node)
const { mNext.getNode(lvl, node); }
304 template<
typename OtherIterListItemT>
308 const NodeT* node =
nullptr;
309 otherListItem.getNode(lvl, node);
310 mIter = (node ==
nullptr) ?
IterT() : ITraits::begin(*
const_cast<NodeT*
>(node));
313 mNext.initLevel(lvl, otherListItem);
321 bool test(
Index lvl)
const {
return (lvl ==
Level) ? mIter.test() : mNext.test(lvl); }
330 if (lvl ==
Level && mPrev !=
nullptr && mIter) {
331 if (
ChildT* child = ITraits::template getChild<ChildT>(mIter)) {
332 mPrev->setIter(PrevItemT::ITraits::begin(*child));
336 return (lvl >
Level) ? mNext.down(lvl) :
false;
343 return (lvl ==
Level) ? mIter.getCoord() : mNext.getCoord(lvl);
347 return (lvl ==
Level) ? NodeT::getChildDim() : mNext.getChildDim(lvl);
352 return (lvl ==
Level) ? ChildT::NUM_VOXELS : mNext.getVoxelCount(lvl);
358 return (lvl ==
Level) ? mIter.isValueOn() : mNext.isValueOn(lvl);
364 if (lvl ==
Level)
return mIter.getValue();
365 return mNext.getValue(lvl);
373 if (lvl ==
Level) mIter.setValue(val);
else mNext.setValue(lvl, val);
380 if (lvl ==
Level) mIter.setValueOn(on);
else mNext.setValueOn(lvl, on);
387 if (lvl ==
Level) mIter.setValueOff();
else mNext.setValueOff(lvl);
392 template<
typename ModifyOp>
395 if (lvl ==
Level) mIter.modifyValue(op);
else mNext.modifyValue(lvl, op);
399 using RestT =
typename boost::mpl::pop_front<NodeVecT>::type;
409 template<
typename PrevItemT,
typename NodeVecT,
size_t VecSize>
416 using _NodeT =
typename boost::mpl::front<NodeVecT>::type;
419 NodeConverter<_NodeT>::Type;
422 using NodeT =
typename IterT::NodeType;
424 using NCNodeT =
typename IterT::NonConstNodeType;
426 using NCValueT =
typename IterT::NonConstValueType;
434 mIter(other.mIter), mNext(other.mNext), mPrev(nullptr) {}
437 if (&other !=
this) {
447 mPrev =
nullptr; mNext.updateBackPointers(
this);
451 template<
typename OtherIterT>
452 void setIter(
const OtherIterT& iter) { mNext.setIter(iter); }
456 node = (lvl == 0) ? mIter.getParentNode() :
nullptr;
458 template<
typename OtherNodeT>
459 void getNode(
Index lvl, OtherNodeT*& node)
const { mNext.getNode(lvl, node); }
461 template<
typename OtherIterListItemT>
465 const NodeT* node =
nullptr;
466 otherListItem.getNode(lvl, node);
467 mIter = (node ==
nullptr) ?
IterT() : ITraits::begin(*
const_cast<NodeT*
>(node));
469 mNext.initLevel(lvl, otherListItem);
473 Index pos(
Index lvl)
const {
return (lvl == 0) ? mIter.pos() : mNext.pos(lvl); }
475 bool test(
Index lvl)
const {
return (lvl == 0) ? mIter.test() : mNext.test(lvl); }
477 bool next(
Index lvl) {
return (lvl == 0) ? mIter.next() : mNext.next(lvl); }
479 bool down(
Index lvl) {
return (lvl == 0) ? false : mNext.down(lvl); }
483 return (lvl == 0) ? mIter.getCoord() : mNext.getCoord(lvl);
487 return (lvl == 0) ? NodeT::getChildDim() : mNext.getChildDim(lvl);
492 return (lvl == 0) ? 1 : mNext.getVoxelCount(lvl);
497 return (lvl == 0) ? mIter.isValueOn() : mNext.isValueOn(lvl);
502 if (lvl == 0)
return mIter.getValue();
503 return mNext.getValue(lvl);
508 if (lvl == 0) mIter.setValue(val);
else mNext.setValue(lvl, val);
512 if (lvl == 0) mIter.setValueOn(on);
else mNext.setValueOn(lvl, on);
516 if (lvl == 0) mIter.setValueOff();
else mNext.setValueOff(lvl);
519 template<
typename ModifyOp>
522 if (lvl == 0) mIter.modifyValue(op);
else mNext.modifyValue(lvl, op);
526 using RestT =
typename boost::mpl::pop_front<NodeVecT>::type;
536 template<
typename PrevItemT,
typename NodeVecT, Index _Level>
540 using _NodeT =
typename boost::mpl::front<NodeVecT>::type;
545 NodeConverter<_NodeT>::Type;
548 using NodeT =
typename IterT::NodeType;
550 using NCNodeT =
typename IterT::NonConstNodeType;
552 using NCValueT =
typename IterT::NonConstValueType;
566 if (&other !=
this) {
582 node = (lvl <=
Level) ? mIter.getParentNode() :
nullptr;
585 template<
typename OtherIterListItemT>
589 const NodeT* node =
nullptr;
590 otherListItem.getNode(lvl, node);
591 mIter = (node ==
nullptr) ?
IterT() : ITraits::begin(*
const_cast<NodeT*
>(node));
603 if (lvl ==
Level && mPrev !=
nullptr && mIter) {
604 if (
ChildT* child = ITraits::template getChild<ChildT>(mIter)) {
605 mPrev->setIter(PrevItemT::ITraits::begin(*child));
620 assert(lvl ==
Level);
622 return mIter.getValue();
629 template<
typename ModifyOp>
632 if (lvl ==
Level) mIter.modifyValue(op);
647 template<
typename _TreeT,
typename _ValueIterT>
653 using NodeT =
typename ValueIterT::NodeType;
654 using ValueT =
typename ValueIterT::NonConstValueType;
656 static const Index ROOT_LEVEL = NodeT::LEVEL;
657 static_assert(ValueIterT::NodeType::LEVEL == ROOT_LEVEL,
"invalid value iterator node type");
658 static const Index LEAF_LEVEL = 0, ROOT_DEPTH = 0, LEAF_DEPTH = ROOT_LEVEL;
666 void setMinDepth(
Index minDepth);
670 void setMaxDepth(
Index maxDepth);
675 bool test()
const {
return mValueIterList.test(mLevel); }
677 operator bool()
const {
return this->test(); }
698 template<
typename NodeType>
699 void getNode(NodeType*& node)
const { mValueIterList.getNode(mLevel, node); }
720 bool isValueOn()
const {
return mValueIterList.isValueOn(mLevel); }
723 const ValueT& getValue()
const {
return mValueIterList.getValue(mLevel); }
743 template<
typename ModifyOp>
744 void modifyValue(
const ModifyOp& op)
const { mValueIterList.modifyValue(mLevel, op); }
750 std::string summary()
const;
753 bool advance(
bool dontIncrement =
false);
756 struct PrevChildItem {
using IterT = ChildOnIterT; };
757 struct PrevValueItem {
using IterT = ValueIterT; };
759 IterListItem<PrevChildItem, InvTreeT, ROOT_LEVEL+1, 0> mChildIterList;
760 IterListItem<PrevValueItem, InvTreeT, ROOT_LEVEL+1, 0> mValueIterList;
762 int mMinLevel, mMaxLevel;
767 template<
typename TreeT,
typename ValueIterT>
770 mChildIterList(nullptr),
771 mValueIterList(nullptr),
773 mMinLevel(int(LEAF_LEVEL)),
774 mMaxLevel(int(ROOT_LEVEL)),
783 template<
typename TreeT,
typename ValueIterT>
786 mChildIterList(other.mChildIterList),
787 mValueIterList(other.mValueIterList),
788 mLevel(other.mLevel),
789 mMinLevel(other.mMinLevel),
790 mMaxLevel(other.mMaxLevel),
798 template<
typename TreeT,
typename ValueIterT>
802 if (&other !=
this) {
803 mChildIterList = other.mChildIterList;
804 mValueIterList = other.mValueIterList;
805 mLevel = other.mLevel;
806 mMinLevel = other.mMinLevel;
807 mMaxLevel = other.mMaxLevel;
809 mChildIterList.updateBackPointers();
810 mValueIterList.updateBackPointers();
816 template<
typename TreeT,
typename ValueIterT>
820 mMaxLevel = int(ROOT_LEVEL - minDepth);
821 if (
int(mLevel) > mMaxLevel) this->next();
825 template<
typename TreeT,
typename ValueIterT>
830 mMinLevel = int(ROOT_LEVEL -
std::min(maxDepth, this->getLeafDepth()));
831 if (
int(mLevel) < mMinLevel) this->next();
835 template<
typename TreeT,
typename ValueIterT>
840 if (!this->advance())
return false;
841 }
while (
int(mLevel) < mMinLevel ||
int(mLevel) > mMaxLevel);
846 template<
typename TreeT,
typename ValueIterT>
850 bool recurse =
false;
854 vPos = mValueIterList.pos(mLevel),
855 cPos = mChildIterList.pos(mLevel);
856 if (vPos == cPos && mChildIterList.test(mLevel)) {
858 mValueIterList.
next(mLevel);
859 vPos = mValueIterList.pos(mLevel);
862 if (dontIncrement)
return true;
863 if (mValueIterList.next(mLevel)) {
864 if (mValueIterList.pos(mLevel) == cPos && mChildIterList.test(mLevel)) {
867 mValueIterList.next(mLevel);
870 if (mValueIterList.pos(mLevel) < cPos)
return true;
874 if (!dontIncrement) mChildIterList.next(mLevel);
876 #ifdef DEBUG_TREE_VALUE_ITERATOR
877 std::cout <<
"\n" << this->summary() << std::flush;
881 while (mChildIterList.pos(mLevel) < mValueIterList.pos(mLevel)) {
882 #ifdef ENABLE_TREE_VALUE_DEPTH_BOUND_OPTIMIZATION
883 if (
int(mLevel) == mMinLevel) {
886 mChildIterList.next(mLevel);
887 if (mValueIterList.pos(mLevel) == mChildIterList.pos(mLevel)
888 && mChildIterList.test(mLevel))
892 mValueIterList.next(mLevel);
896 if (mChildIterList.down(mLevel)) {
898 mValueIterList.initLevel(mLevel, mChildIterList);
899 if (mValueIterList.pos(mLevel) == mChildIterList.pos(mLevel)
900 && mChildIterList.test(mLevel))
904 mValueIterList.next(mLevel);
907 #ifdef DEBUG_TREE_VALUE_ITERATOR
908 std::cout <<
"\n" << this->summary() << std::flush;
912 while (!mChildIterList.test(mLevel) && !mValueIterList.test(mLevel)) {
913 if (mLevel == ROOT_LEVEL)
return false;
915 mChildIterList.next(mLevel);
916 dontIncrement =
true;
924 template<
typename TreeT,
typename ValueIterT>
932 bbox.
min() = mValueIterList.getCoord(mLevel);
933 bbox.
max() = bbox.
min().
offsetBy(mValueIterList.getChildDim(mLevel) - 1);
938 template<
typename TreeT,
typename ValueIterT>
942 std::ostringstream ostr;
943 for (
int lvl =
int(ROOT_LEVEL); lvl >= 0 && lvl >= int(mLevel); --lvl) {
944 if (lvl == 0) ostr <<
"leaf";
945 else if (lvl ==
int(ROOT_LEVEL)) ostr <<
"root";
946 else ostr <<
"int" << (ROOT_LEVEL - lvl);
947 ostr <<
" v" << mValueIterList.pos(lvl)
948 <<
" c" << mChildIterList.pos(lvl);
949 if (lvl >
int(mLevel)) ostr <<
" / ";
951 if (this->test() && mValueIterList.pos(mLevel) < mChildIterList.pos(mLevel)) {
953 ostr <<
" " << this->getCoord();
955 ostr <<
" " << this->getBoundingBox();
966 template<
typename _TreeT,
typename RootChildOnIterT>
996 bool test()
const {
return !mDone; }
998 operator bool()
const {
return this->
test(); }
1030 template<
typename NodeT>
1034 void getNode(NodeT*& node)
const { node =
nullptr; mIterList.
getNode(mLevel, node); }
1035 template<
typename NodeT>
1036 void getNode(
const NodeT*& node)
const { node =
nullptr; mIterList.
getNode(mLevel, node); }
1044 struct PrevItem {
using IterT =
RootIterT; };
1048 int mMinLevel, mMaxLevel;
1054 template<
typename TreeT,
typename RootChildOnIterT>
1059 mMinLevel(int(LEAF_LEVEL)),
1060 mMaxLevel(int(ROOT_LEVEL)),
1067 template<
typename TreeT,
typename RootChildOnIterT>
1072 mMinLevel(int(LEAF_LEVEL)),
1073 mMaxLevel(int(ROOT_LEVEL)),
1077 mIterList.
setIter(RootIterTraits::begin(tree.root()));
1081 template<
typename TreeT,
typename RootChildOnIterT>
1084 mIterList(other.mIterList),
1085 mLevel(other.mLevel),
1086 mMinLevel(other.mMinLevel),
1087 mMaxLevel(other.mMaxLevel),
1095 template<
typename TreeT,
typename RootChildOnIterT>
1099 if (&other !=
this) {
1100 mLevel = other.mLevel;
1101 mMinLevel = other.mMinLevel;
1102 mMaxLevel = other.mMaxLevel;
1103 mDone = other.mDone;
1104 mTree = other.mTree;
1105 mIterList = other.mIterList;
1112 template<
typename TreeT,
typename RootChildOnIterT>
1116 mMaxLevel = int(ROOT_LEVEL - minDepth);
1117 if (
int(mLevel) > mMaxLevel) this->next();
1121 template<
typename TreeT,
typename RootChildOnIterT>
1126 mMinLevel = int(ROOT_LEVEL -
std::min(maxDepth, this->getLeafDepth()));
1127 if (
int(mLevel) < mMinLevel) this->next();
1131 template<
typename TreeT,
typename RootChildOnIterT>
1136 if (mDone)
return false;
1140 if (
int(mLevel) > mMinLevel && mIterList.test(mLevel)) {
1141 if (!mIterList.down(mLevel))
return false;
1145 while (!mIterList.test(mLevel)) {
1146 if (mLevel == ROOT_LEVEL) {
1152 mIterList.next(mLevel);
1155 if (!mIterList.down(mLevel))
return false;
1158 }
while (
int(mLevel) < mMinLevel ||
int(mLevel) > mMaxLevel);
1163 template<
typename TreeT,
typename RootChildOnIterT>
1167 if (mLevel != ROOT_LEVEL)
return mIterList.getCoord(mLevel + 1);
1169 this->getNode(root);
1170 return root ? root->getMinIndex() :
Coord::min();
1174 template<
typename TreeT,
typename RootChildOnIterT>
1178 if (mLevel == ROOT_LEVEL) {
1180 this->getNode(root);
1181 if (root ==
nullptr) {
1185 root->getIndexRange(bbox);
1188 bbox.
min() = mIterList.getCoord(mLevel + 1);
1189 bbox.
max() = bbox.
min().
offsetBy(mIterList.getChildDim(mLevel + 1) - 1);
1194 template<
typename TreeT,
typename RootChildOnIterT>
1198 std::ostringstream ostr;
1199 for (
int lvl =
int(ROOT_LEVEL); lvl >= 0 && lvl >= int(mLevel); --lvl) {
1200 if (lvl == 0) ostr <<
"leaf";
1201 else if (lvl ==
int(ROOT_LEVEL)) ostr <<
"root";
1202 else ostr <<
"int" << (ROOT_LEVEL - lvl);
1203 ostr <<
" c" << mIterList.pos(lvl);
1204 if (lvl >
int(mLevel)) ostr <<
" / ";
1207 this->getBoundingBox(bbox);
1208 ostr <<
" " << bbox;
1217 template<
typename TreeT,
typename RootChildOnIterT>
1237 mIterList.
setIter(RootIterTraits::begin(tree.root()));
1240 for ( ; lvl > 0 && mIterList.
down(lvl); --lvl) {}
1242 if (lvl > 0) this->
next();
1251 if (&other !=
this) {
1252 mTree = other.mTree;
1253 mIterList = other.mIterList;
1272 operator bool()
const {
return this->
test(); }
1286 struct PrevItem {
using IterT =
RootIterT; };
1296 template<
typename TreeT,
typename RootChildOnIterT>
1302 if (mIterList.test(LEAF_PARENT_LEVEL) && mIterList.next(LEAF_PARENT_LEVEL)) {
1303 mIterList.down(LEAF_PARENT_LEVEL);
1307 Index lvl = LEAF_PARENT_LEVEL;
1308 while (!mIterList.test(LEAF_PARENT_LEVEL)) {
1309 if (mIterList.test(lvl)) {
1310 mIterList.next(lvl);
1315 if (lvl == ROOT_LEVEL)
return false;
1317 if (mIterList.test(lvl)) mIterList.next(lvl);
1318 }
while (!mIterList.test(lvl));
1321 while (lvl > LEAF_PARENT_LEVEL && mIterList.down(lvl)) --lvl;
1323 mIterList.down(LEAF_PARENT_LEVEL);
1333 template<
typename IterT>
1339 mGrainSize(grainSize),
1342 mSize = this->size();
1346 mGrainSize(other.mGrainSize),
1347 mSize(other.mSize >> 1)
1357 bool empty()
const {
return mSize == 0 || !mIter.test(); }
1359 operator bool()
const {
return !this->
empty(); }
1366 void increment(
Index n = 1) {
for ( ; n > 0 && mSize > 0; --n, --mSize, ++mIter) {} }
1374 Index size()
const {
Index n = 0;
for (IterT it(mIter); it.test(); ++n, ++it) {}
return n; }
1396 #endif // OPENVDB_TREE_TREEITERATOR_HAS_BEEN_INCLUDED
LeafNodeT & operator*() const
Definition: TreeIterator.h:1267
typename iter::InvertedTree< NCRootNodeT, ROOT_LEVEL >::Type InvTreeT
Definition: TreeIterator.h:1225
RootChildOnIterT RootIterT
Definition: TreeIterator.h:1221
static ChildT * getChild(const IterT &iter)
Definition: TreeIterator.h:101
bool isValueOn(Index lvl) const
Definition: TreeIterator.h:495
static IterT begin(const NodeT &node)
Definition: TreeIterator.h:136
Signed (x, y, z) 32-bit integer coordinates.
Definition: Coord.h:52
LeafIteratorBase(TreeT &tree)
Definition: TreeIterator.h:1234
bool next()
Advance the iterator to the next item.
Definition: TreeIterator.h:1371
bool isTileValue() const
Return true if this iterator is currently pointing to a (non-leaf) tile value.
Definition: TreeIterator.h:716
Base class for tree-traversal iterators over all nodes.
Definition: TreeIterator.h:967
bool next(Index lvl)
Increment the iterator at level lvl of the tree.
Definition: TreeIterator.h:324
void setIter(const IterT &iter)
Definition: TreeIterator.h:450
const ValueT * operator->() const
Definition: TreeIterator.h:726
NodeIteratorBase()
Definition: TreeIterator.h:1056
typename ValueIterT::NonConstValueType ValueT
Definition: TreeIterator.h:654
IterListItem(const IterListItem &other)
Definition: TreeIterator.h:272
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:419
void setValueOn(Index lvl, bool on=true) const
Definition: TreeIterator.h:626
Index64 getVoxelCount(Index lvl) const
Definition: TreeIterator.h:614
bool next(Index lvl)
Definition: TreeIterator.h:599
static IterT begin(const NodeT &node)
Definition: TreeIterator.h:224
typename OtherNodeT::ChildAllIter Type
Definition: TreeIterator.h:152
typename NodeT::ChildOnIter IterT
Definition: TreeIterator.h:99
IterListItem(const IterListItem &other)
Definition: TreeIterator.h:563
const NCValueT & getValue(Index lvl) const
Definition: TreeIterator.h:500
_TreeT TreeT
Definition: TreeIterator.h:970
typename PrevItem ::IterT PrevIterT
The type of iterator stored in the previous list item.
Definition: TreeIterator.h:249
typename NodeT::ValueOffCIter IterT
Definition: TreeIterator.h:203
TreeT * getTree() const
Definition: TreeIterator.h:1283
bool next()
Advance the iterator to the next leaf node.
Definition: TreeIterator.h:1298
typename RootIterT::NodeType RootNodeT
Definition: TreeIterator.h:972
typename CopyConstness< RootNodeT, NCLeafNodeT >::Type LeafNodeT
Definition: TreeIterator.h:1227
LeafNodeT * getLeaf() const
Return the leaf node to which the iterator is pointing.
Definition: TreeIterator.h:1261
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:645
static IterT begin(NodeT &node)
Definition: TreeIterator.h:126
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:1363
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:254
void increment(Index n=1)
Advance the iterator n times.
Definition: TreeIterator.h:1366
typename IterT::NonConstNodeType NCNodeT
The type of the node with const qualifiers removed ("Non-Const")
Definition: TreeIterator.h:259
typename NodeT::ChildOffIter IterT
Definition: TreeIterator.h:125
typename OtherNodeT::ChildAllCIter Type
Definition: TreeIterator.h:166
Index getChildDim(Index lvl) const
Definition: TreeIterator.h:345
static IterT begin(const NodeT &node)
Definition: TreeIterator.h:113
NodeIteratorBase & operator=(const NodeIteratorBase &other)
Definition: TreeIterator.h:1097
bool empty() const
Definition: TreeIterator.h:1357
typename OtherNodeT::ValueAllCIter Type
Definition: TreeIterator.h:226
static IterT begin(NodeT &node)
Definition: TreeIterator.h:214
IterListItem(PrevItemT *prev)
Definition: TreeIterator.h:561
bool next()
Advance to the next tile or voxel value.
Definition: TreeIterator.h:1133
typename PrevItemT::IterT PrevIterT
The type of iterator stored in the previous list item.
Definition: TreeIterator.h:542
LeafIteratorBase(const LeafIteratorBase &other)
Definition: TreeIterator.h:1245
Library and file format version numbers.
Index32 Index
Definition: Types.h:61
bool isVoxelValue() const
Return true if this iterator is currently pointing to a (leaf) voxel value.
Definition: TreeIterator.h:718
bool isValueOn(Index lvl) const
Definition: TreeIterator.h:616
typename boost::mpl::push_back< SubtreeT, HeadT >::type Type
Definition: TreeIterator.h:66
typename OtherNodeT::ValueOnCIter Type
Definition: TreeIterator.h:186
void setValueOff() const
Mark the tile or voxel value to which this iterator is currently pointing as inactive.
Definition: TreeIterator.h:736
static IterT begin(const NodeT &node)
Definition: TreeIterator.h:204
typename OtherNodeT::ValueOffCIter Type
Definition: TreeIterator.h:206
void getNode(NodeT *&node) const
Return the node to which the iterator is pointing.
Definition: TreeIterator.h:1034
Index getDepth() const
Return the depth in the tree (0 = root) of the node to which this iterator is currently pointing.
Definition: TreeIterator.h:691
typename IterT::NonConstValueType NCValueT
The type of value (with const qualifiers removed) to which the iterator points.
Definition: TreeIterator.h:426
void getNode(Index lvl, OtherNodeT *&node) const
Definition: TreeIterator.h:459
TreeT * getTree() const
Definition: TreeIterator.h:1039
An IterListItem is an element of a compile-time linked list of iterators to nodes of different types.
Definition: TreeIterator.h:245
void getNode(Index lvl, NodeT *&node) const
Definition: TreeIterator.h:454
typename boost::mpl::vector< typename HeadT::ChildNodeType, HeadT >::type Type
Definition: TreeIterator.h:70
static const ChildT * getChild(const IterT &iter)
Definition: TreeIterator.h:114
IterListItem(PrevItemT *)
Definition: TreeIterator.h:431
Index getLevel() const
Return the level in the tree (0 = leaf) of the node to which this iterator is currently pointing.
Definition: TreeIterator.h:688
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:371
typename RootIterT::NonConstNodeType NCRootNodeT
Definition: TreeIterator.h:1223
typename RootIterT::NonConstNodeType NCRootNodeT
Definition: TreeIterator.h:973
void modifyValue(Index lvl, const ModifyOp &op) const
Apply a functor to the item to which this iterator is pointing.
Definition: TreeIterator.h:393
Index getDepth() const
Return the depth in the tree (0 = root) of the node to which this iterator is currently pointing.
Definition: TreeIterator.h:1015
IteratorRange & operator++()
Advance the iterator to the next item.
Definition: TreeIterator.h:1368
void setIter(const IterT &iter)
Definition: TreeIterator.h:286
typename OtherNodeT::ValueAllIter Type
Definition: TreeIterator.h:216
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:545
std::string summary() const
Definition: TreeIterator.h:1196
void modifyValue(Index lvl, const ModifyOp &op) const
Definition: TreeIterator.h:630
CoordBBox getBoundingBox() const
Return the axis-aligned bounding box of the voxel or tile to which this iterator is currently pointin...
Definition: TreeIterator.h:710
typename ValueIterT::NodeType NodeT
Definition: TreeIterator.h:653
bool test() const
Definition: TreeIterator.h:1358
static Coord min()
Return the smallest possible coordinate.
Definition: Coord.h:71
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:699
Coord getCoord() const
Return the global coordinates of the voxel or tile to which this iterator is currently pointing.
Definition: TreeIterator.h:1165
typename NodeT::ValueOnCIter IterT
Definition: TreeIterator.h:183
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:734
CoordBBox getBoundingBox() const
Return the axis-aligned bounding box of the voxel or tile to which this iterator is currently pointin...
Definition: TreeIterator.h:1027
typename IterT::NodeType NodeT
The type of node (const or non-const) over which IterT iterates (e.g., const RootNode<....
Definition: TreeIterator.h:422
Index getLevel() const
Return the level in the tree (0 = leaf) of the node to which this iterator is currently pointing.
Definition: TreeIterator.h:1012
Coord getCoord(Index lvl) const
Definition: TreeIterator.h:481
Definition: TreeIterator.h:91
Index getChildDim(Index lvl) const
Definition: TreeIterator.h:485
void getNode(const NodeT *&node) const
Definition: TreeIterator.h:1036
typename CopyConstness< NCNodeT, typename NCNodeT::ChildNodeType >::Type NCChildT
NodeT's child node type with const qualifiers removed.
Definition: TreeIterator.h:265
static ChildT * getChild(const IterT &iter)
Definition: TreeIterator.h:161
static IterT begin(const NodeT &node)
Definition: TreeIterator.h:184
static Index getLeafDepth()
Definition: TreeIterator.h:1016
void modifyValue(Index lvl, const ModifyOp &op) const
Definition: TreeIterator.h:520
bool test(Index lvl) const
Definition: TreeIterator.h:475
Index64 getVoxelCount(Index lvl) const
Definition: TreeIterator.h:490
Axis-aligned bounding box of signed integer coordinates.
Definition: Coord.h:275
void increment()
Advance the iterator to the next leaf node.
Definition: TreeIterator.h:1005
RootChildOnIterT RootIterT
Definition: TreeIterator.h:971
_ValueIterT ValueIterT
Definition: TreeIterator.h:652
const Coord & min() const
Definition: Coord.h:348
IterListItem(PrevItemT *prev)
Definition: TreeIterator.h:270
const NCValueT & getValue(Index lvl) const
Return the value to which the iterator at level lvl of the tree points.
Definition: TreeIterator.h:362
Index pos(Index lvl) const
Definition: TreeIterator.h:473
typename boost::mpl::front< NodeVecT >::type _NodeT
The type of node (non-const) whose iterator is stored in this list item.
Definition: TreeIterator.h:416
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:378
typename OtherNodeT::ChildOffCIter Type
Definition: TreeIterator.h:138
typename NodeT::ChildOnCIter IterT
Definition: TreeIterator.h:112
void setValue(Index lvl, const NCValueT &val) const
Definition: TreeIterator.h:625
IteratorRange(IteratorRange &other, tbb::split)
Definition: TreeIterator.h:1344
std::string summary() const
Return a string (for debugging, mainly) describing this iterator's current state.
Definition: TreeIterator.h:940
Base class for tree-traversal iterators over tile and voxel values.
Definition: TreeIterator.h:648
typename boost::mpl::front< InvTreeT >::type NCLeafNodeT
Definition: TreeIterator.h:1226
IterListItem(const IterListItem &other)
Definition: TreeIterator.h:433
typename NodeT::ValueAllIter IterT
Definition: TreeIterator.h:213
void setValueOff(Index lvl) const
Definition: TreeIterator.h:627
Coord getCoord() const
Return the global coordinates of the voxel or tile to which this iterator is currently pointing.
Definition: TreeIterator.h:703
typename CopyConstness< NodeT, typename NodeT::ChildNodeType >::Type ChildT
NodeT's child node type, with the same constness (e.g., const InternalNode<...>)
Definition: TreeIterator.h:263
typename PrevItemT::IterT PrevIterT
The type of iterator stored in the previous list item.
Definition: TreeIterator.h:414
typename OtherNodeT::ChildOnCIter Type
Definition: TreeIterator.h:118
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:305
typename NodeT::ValueOffIter IterT
Definition: TreeIterator.h:193
typename IterT::NonConstNodeType NCNodeT
The type of the node with const qualifiers removed ("Non-Const")
Definition: TreeIterator.h:424
LeafNodeT * operator->() const
Definition: TreeIterator.h:1268
void setIter(const OtherIterT &iter)
Definition: TreeIterator.h:452
static Index getLeafDepth()
Definition: TreeIterator.h:692
bool next(Index lvl)
Definition: TreeIterator.h:477
Index pos(Index lvl) const
Definition: TreeIterator.h:595
Coord offsetBy(Int32 dx, Int32 dy, Int32 dz) const
Definition: Coord.h:119
typename CopyConstness< NCNodeT, typename NCNodeT::ChildNodeType >::Type NCChildT
NodeT's child node type with const qualifiers removed.
Definition: TreeIterator.h:556
typename NodeT::ChildOnCIter ChildOnIterT
Definition: TreeIterator.h:655
void setValueOn(Index lvl, bool on=true) const
Definition: TreeIterator.h:510
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h:180
static const Index LEAF_PARENT_LEVEL
Definition: TreeIterator.h:1228
typename NodeT::ChildOffCIter IterT
Definition: TreeIterator.h:135
static const Index ROOT_LEVEL
Definition: TreeIterator.h:974
void setValue(Index lvl, const NCValueT &val) const
Definition: TreeIterator.h:506
void initLevel(Index lvl, OtherIterListItemT &otherListItem)
Definition: TreeIterator.h:462
static IterT begin(NodeT &node)
Definition: TreeIterator.h:194
bool test() const
Return true if this iterator is not yet exhausted.
Definition: TreeIterator.h:997
void setValueOff(Index lvl) const
Mark the value to which the iterator at level lvl of the tree points as inactive.
Definition: TreeIterator.h:385
bool next()
Advance to the next tile or voxel value. Return true if this iterator is not yet exhausted.
Definition: TreeIterator.h:837
bool isValueOn(Index lvl) const
Return true if the iterator at level lvl of the tree points to an active value.
Definition: TreeIterator.h:356
Index getMinDepth() const
Return the depth of the highest level of the tree to which this iterator ascends.
Definition: TreeIterator.h:989
static const Index LEAF_LEVEL
Definition: TreeIterator.h:1228
typename OtherNodeT::ValueOffIter Type
Definition: TreeIterator.h:196
typename RootIterT::NodeType RootNodeT
Definition: TreeIterator.h:1222
static ChildT * getChild(const IterT &)
Definition: TreeIterator.h:93
void setMaxDepth(Index maxDepth)
Specify the depth of the lowest level of the tree to which to descend (depth 0 = root).
Definition: TreeIterator.h:1123
uint64_t Index64
Definition: Types.h:60
const Coord & max() const
Definition: Coord.h:349
bool test(Index lvl) const
Definition: TreeIterator.h:597
LeafIteratorBase & operator++()
Definition: TreeIterator.h:1278
_TreeT TreeT
Definition: TreeIterator.h:651
const ValueT & operator*() const
Definition: TreeIterator.h:725
static IterT begin(NodeT &node)
Definition: TreeIterator.h:100
void getNode(Index lvl, OtherNodeT *&node) const
Return the node over which one of the following list elements' iterator iterates.
Definition: TreeIterator.h:297
void getNode(Index lvl, NodeT *&node) const
Return the node over which this list element's iterator iterates.
Definition: TreeIterator.h:291
static const Index LEAF_LEVEL
Definition: TreeIterator.h:976
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:328
void updateBackPointers(PrevItemT *prev)
Definition: TreeIterator.h:284
Definition: TreeIterator.h:64
typename NodeT::ChildAllIter IterT
Definition: TreeIterator.h:145
IteratorRange(const IterT &iter, size_t grainSize=8)
Definition: TreeIterator.h:1337
typename OtherNodeT::ChildOffIter Type
Definition: TreeIterator.h:128
static ChildT * getChild(const IterT &iter)
Definition: TreeIterator.h:147
void updateBackPointers(PrevItemT *=nullptr)
Definition: TreeIterator.h:445
void increment(Index n)
Increment the iterator n times.
Definition: TreeIterator.h:1008
typename IterT::NodeType NodeT
The type of node over which IterT iterates (e.g., const RootNode<...>)
Definition: TreeIterator.h:548
const NCValueT & getValue(Index lvl) const
Definition: TreeIterator.h:618
typename iter::InvertedTree< NCRootNodeT, ROOT_LEVEL >::Type InvTreeT
Definition: TreeIterator.h:975
typename IterT::NonConstValueType NCValueT
The type of value (with const qualifiers removed) to which the iterator points.
Definition: TreeIterator.h:552
typename NodeT::ValueOnIter IterT
Definition: TreeIterator.h:173
Level
Message severity level.
Definition: logging.h:58
typename OtherNodeT::ValueOnIter Type
Definition: TreeIterator.h:176
IterListItem & operator=(const IterListItem &other)
Definition: TreeIterator.h:435
LeafIteratorBase()
Definition: TreeIterator.h:1232
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:744
static const Index ROOT_LEVEL
Definition: TreeIterator.h:1224
typename boost::mpl::front< NodeVecT >::type _NodeT
Definition: TreeIterator.h:540
bool down(Index lvl)
Definition: TreeIterator.h:479
typename std::remove_const< ToType >::type Type
Definition: Types.h:348
static IterT begin(NodeT &node)
Definition: TreeIterator.h:174
#define OPENVDB_VERSION_NAME
Definition: version.h:134
Index getMinDepth() const
Return the depth of the highest level of the tree to which this iterator ascends.
Definition: TreeIterator.h:668
typename IterT::NonConstValueType NCValueT
The type of value (with const qualifiers removed) to which the iterator points.
Definition: TreeIterator.h:261
NodeIteratorBase & operator++()
Definition: TreeIterator.h:1006
void increment()
Definition: TreeIterator.h:1277
TreeValueIteratorBase(TreeT &)
Definition: TreeIterator.h:769
const IterT & iterator() const
Return a reference to this range's iterator.
Definition: TreeIterator.h:1355
void initLevel(Index lvl, OtherIterListItemT &otherListItem)
Definition: TreeIterator.h:586
IterListItem & operator=(const IterListItem &other)
Definition: TreeIterator.h:564
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:731
typename CopyConstness< NodeT, typename NodeT::ChildNodeType >::Type ChildT
NodeT's child node type, with the same constness (e.g., const InternalNode<...>)
Definition: TreeIterator.h:554
Index getMaxDepth() const
Return the depth of the lowest level of the tree to which this iterator ascends.
Definition: TreeIterator.h:993
void setIter(const OtherIterT &iter)
Definition: TreeIterator.h:288
bool test() const
Definition: TreeIterator.h:1271
Index getMaxDepth() const
Return the depth of the lowest level of the tree to which this iterator ascends.
Definition: TreeIterator.h:672
void setMinDepth(Index minDepth)
Specify the depth of the highest level of the tree to which to ascend (depth 0 = root).
Definition: TreeIterator.h:818
IterListItem & operator=(const IterListItem &other)
Definition: TreeIterator.h:274
TreeT * getTree() const
Return a pointer to the tree over which this iterator is iterating.
Definition: TreeIterator.h:747
static const Index ROOT_DEPTH
Definition: TreeIterator.h:976
Base class for tree-traversal iterators over all leaf nodes (but not leaf voxels)
Definition: TreeIterator.h:1218
LeafIteratorBase & operator=(const LeafIteratorBase &other)
Definition: TreeIterator.h:1249
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:341
void setMinDepth(Index minDepth)
Specify the depth of the highest level of the tree to which to ascend (depth 0 = root).
Definition: TreeIterator.h:1114
void updateBackPointers(PrevItemT *prev)
Definition: TreeIterator.h:573
Definition: Exceptions.h:40
typename IterT::NonConstNodeType NCNodeT
The type of the node with const qualifiers removed ("Non-Const")
Definition: TreeIterator.h:550
typename OtherNodeT::ChildOnIter Type
Definition: TreeIterator.h:105
typename NodeT::ValueAllCIter IterT
Definition: TreeIterator.h:223
Index pos(Index lvl) const
Return The table offset of the iterator at level lvl of the tree.
Definition: TreeIterator.h:318
void setIter(const IterT &iter)
Definition: TreeIterator.h:578
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:321
typename boost::mpl::front< InvTreeT >::type _NodeT
The type of node (non-const) whose iterator is stored in this list item.
Definition: TreeIterator.h:251
static const Index LEAF_DEPTH
Definition: TreeIterator.h:976
void getNode(Index lvl, NodeT *&node) const
Definition: TreeIterator.h:580
TreeValueIteratorBase & operator=(const TreeValueIteratorBase &other)
Definition: TreeIterator.h:800
void setValueOff(Index lvl) const
Definition: TreeIterator.h:514
static IterT begin(const NodeT &node)
Definition: TreeIterator.h:160
Index64 getVoxelCount() const
Return the number of (virtual) voxels corresponding to the value.
Definition: TreeIterator.h:713
void setMaxDepth(Index maxDepth)
Specify the depth of the lowest level of the tree to which to descend (depth 0 = root).
Definition: TreeIterator.h:827
bool isValueOn() const
Return true if the value to which this iterator is currently pointing is active.
Definition: TreeIterator.h:720
Index64 getVoxelCount(Index lvl) const
Return the number of (virtual) voxels spanned by a tile value or child node.
Definition: TreeIterator.h:350
Index getChildDim(Index lvl) const
Definition: TreeIterator.h:613
TreeValueIteratorBase & operator++()
Advance to the next tile or voxel value.
Definition: TreeIterator.h:684
typename IterT::NodeType NodeT
The type of node (const or non-const) over which IterT iterates (e.g., const RootNode<....
Definition: TreeIterator.h:257
bool down(Index lvl)
Definition: TreeIterator.h:601
static IterT begin(NodeT &node)
Definition: TreeIterator.h:146
Definition: TreeIterator.h:1334
typename InvertedTree< typename HeadT::ChildNodeType, HeadLevel-1 >::Type SubtreeT
Definition: TreeIterator.h:65
typename NodeT::ChildAllCIter IterT
Definition: TreeIterator.h:159
Coord getCoord(Index lvl) const
Definition: TreeIterator.h:612