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 68 using Type =
typename std::remove_const<ToType>::type;
70 template<
typename FromType,
typename ToType>
struct CopyConstness<const FromType, ToType> {
80 template<
typename HeadT,
int HeadLevel>
83 using Type =
typename boost::mpl::push_back<SubtreeT, HeadT>::type;
85 template<
typename HeadT>
87 using Type =
typename boost::mpl::vector<typename HeadT::ChildNodeType, HeadT>::type;
107 template<
typename NodeT,
typename IterT>
110 template<
typename ChildT>
static ChildT*
getChild(
const IterT&) {
return nullptr; }
113 template<
typename NodeT>
116 using IterT =
typename NodeT::ChildOnIter;
117 static IterT begin(NodeT& node) {
return node.beginChildOn(); }
119 return &iter.getValue();
121 template<
typename OtherNodeT>
struct NodeConverter {
122 using Type =
typename OtherNodeT::ChildOnIter;
126 template<
typename NodeT>
129 using IterT =
typename NodeT::ChildOnCIter;
130 static IterT begin(
const NodeT& node) {
return node.cbeginChildOn(); }
131 template<
typename ChildT>
static const ChildT*
getChild(
const IterT& iter) {
132 return &iter.getValue();
134 template<
typename OtherNodeT>
struct NodeConverter {
135 using Type =
typename OtherNodeT::ChildOnCIter;
139 template<
typename NodeT>
142 using IterT =
typename NodeT::ChildOffIter;
143 static IterT begin(NodeT& node) {
return node.beginChildOff(); }
144 template<
typename OtherNodeT>
struct NodeConverter {
145 using Type =
typename OtherNodeT::ChildOffIter;
149 template<
typename NodeT>
152 using IterT =
typename NodeT::ChildOffCIter;
153 static IterT begin(
const NodeT& node) {
return node.cbeginChildOff(); }
154 template<
typename OtherNodeT>
struct NodeConverter {
155 using Type =
typename OtherNodeT::ChildOffCIter;
159 template<
typename NodeT>
162 using IterT =
typename NodeT::ChildAllIter;
163 static IterT begin(NodeT& node) {
return node.beginChildAll(); }
165 typename IterT::NonConstValueType val;
166 return iter.probeChild(val);
168 template<
typename OtherNodeT>
struct NodeConverter {
169 using Type =
typename OtherNodeT::ChildAllIter;
173 template<
typename NodeT>
176 using IterT =
typename NodeT::ChildAllCIter;
177 static IterT begin(
const NodeT& node) {
return node.cbeginChildAll(); }
179 typename IterT::NonConstValueType val;
180 return iter.probeChild(val);
182 template<
typename OtherNodeT>
struct NodeConverter {
183 using Type =
typename OtherNodeT::ChildAllCIter;
187 template<
typename NodeT>
190 using IterT =
typename NodeT::ValueOnIter;
191 static IterT begin(NodeT& node) {
return node.beginValueOn(); }
192 template<
typename OtherNodeT>
struct NodeConverter {
193 using Type =
typename OtherNodeT::ValueOnIter;
197 template<
typename NodeT>
200 using IterT =
typename NodeT::ValueOnCIter;
201 static IterT begin(
const NodeT& node) {
return node.cbeginValueOn(); }
202 template<
typename OtherNodeT>
struct NodeConverter {
203 using Type =
typename OtherNodeT::ValueOnCIter;
207 template<
typename NodeT>
210 using IterT =
typename NodeT::ValueOffIter;
211 static IterT begin(NodeT& node) {
return node.beginValueOff(); }
212 template<
typename OtherNodeT>
struct NodeConverter {
213 using Type =
typename OtherNodeT::ValueOffIter;
217 template<
typename NodeT>
220 using IterT =
typename NodeT::ValueOffCIter;
221 static IterT begin(
const NodeT& node) {
return node.cbeginValueOff(); }
222 template<
typename OtherNodeT>
struct NodeConverter {
223 using Type =
typename OtherNodeT::ValueOffCIter;
227 template<
typename NodeT>
230 using IterT =
typename NodeT::ValueAllIter;
231 static IterT begin(NodeT& node) {
return node.beginValueAll(); }
232 template<
typename OtherNodeT>
struct NodeConverter {
233 using Type =
typename OtherNodeT::ValueAllIter;
237 template<
typename NodeT>
240 using IterT =
typename NodeT::ValueAllCIter;
241 static IterT begin(
const NodeT& node) {
return node.cbeginValueAll(); }
242 template<
typename OtherNodeT>
struct NodeConverter {
243 using Type =
typename OtherNodeT::ValueAllCIter;
261 template<
typename PrevItemT,
typename NodeVecT,
size_t VecSize, Index _Level>
268 using _NodeT =
typename boost::mpl::front<NodeVecT>::type;
271 NodeConverter<_NodeT>::Type;
274 using NodeT =
typename IterT::NodeType;
276 using NCNodeT =
typename IterT::NonConstNodeType;
278 using NCValueT =
typename IterT::NonConstValueType;
290 mIter(other.mIter), mNext(other.mNext), mPrev(nullptr) {}
293 if (&other !=
this) {
304 template<
typename OtherIterT>
305 void setIter(
const OtherIterT& iter) { mNext.setIter(iter); }
310 node = (lvl <=
Level) ? mIter.getParentNode() :
nullptr;
313 template<
typename OtherNodeT>
314 void getNode(
Index lvl, OtherNodeT*& node)
const { mNext.getNode(lvl, node); }
321 template<
typename OtherIterListItemT>
325 const NodeT* node =
nullptr;
326 otherListItem.getNode(lvl, node);
327 mIter = (node ==
nullptr) ?
IterT() : ITraits::begin(*const_cast<NodeT*>(node));
330 mNext.initLevel(lvl, otherListItem);
338 bool test(
Index lvl)
const {
return (lvl ==
Level) ? mIter.test() : mNext.test(lvl); }
347 if (lvl ==
Level && mPrev !=
nullptr && mIter) {
348 if (
ChildT* child = ITraits::template getChild<ChildT>(mIter)) {
349 mPrev->setIter(PrevItemT::ITraits::begin(*child));
353 return (lvl >
Level) ? mNext.down(lvl) :
false;
360 return (lvl ==
Level) ? mIter.getCoord() : mNext.getCoord(lvl);
364 return (lvl ==
Level) ? NodeT::getChildDim() : mNext.getChildDim(lvl);
369 return (lvl ==
Level) ? ChildT::NUM_VOXELS : mNext.getVoxelCount(lvl);
375 return (lvl ==
Level) ? mIter.isValueOn() : mNext.isValueOn(lvl);
381 if (lvl ==
Level)
return mIter.getValue();
382 return mNext.getValue(lvl);
390 if (lvl ==
Level) mIter.setValue(val);
else mNext.setValue(lvl, val);
397 if (lvl ==
Level) mIter.setValueOn(on);
else mNext.setValueOn(lvl, on);
404 if (lvl ==
Level) mIter.setValueOff();
else mNext.setValueOff(lvl);
409 template<
typename ModifyOp>
412 if (lvl ==
Level) mIter.modifyValue(op);
else mNext.modifyValue(lvl, op);
416 using RestT =
typename boost::mpl::pop_front<NodeVecT>::type;
426 template<
typename PrevItemT,
typename NodeVecT,
size_t VecSize>
433 using _NodeT =
typename boost::mpl::front<NodeVecT>::type;
436 NodeConverter<_NodeT>::Type;
439 using NodeT =
typename IterT::NodeType;
441 using NCNodeT =
typename IterT::NonConstNodeType;
443 using NCValueT =
typename IterT::NonConstValueType;
451 mIter(other.mIter), mNext(other.mNext), mPrev(nullptr) {}
454 if (&other !=
this) {
464 mPrev =
nullptr; mNext.updateBackPointers(
this);
468 template<
typename OtherIterT>
469 void setIter(
const OtherIterT& iter) { mNext.setIter(iter); }
473 node = (lvl == 0) ? mIter.getParentNode() :
nullptr;
475 template<
typename OtherNodeT>
476 void getNode(
Index lvl, OtherNodeT*& node)
const { mNext.getNode(lvl, node); }
478 template<
typename OtherIterListItemT>
482 const NodeT* node =
nullptr;
483 otherListItem.getNode(lvl, node);
484 mIter = (node ==
nullptr) ?
IterT() : ITraits::begin(*const_cast<NodeT*>(node));
486 mNext.initLevel(lvl, otherListItem);
490 Index pos(
Index lvl)
const {
return (lvl == 0) ? mIter.pos() : mNext.pos(lvl); }
492 bool test(
Index lvl)
const {
return (lvl == 0) ? mIter.test() : mNext.test(lvl); }
494 bool next(
Index lvl) {
return (lvl == 0) ? mIter.next() : mNext.next(lvl); }
496 bool down(
Index lvl) {
return (lvl == 0) ? false : mNext.down(lvl); }
500 return (lvl == 0) ? mIter.getCoord() : mNext.getCoord(lvl);
504 return (lvl == 0) ? NodeT::getChildDim() : mNext.getChildDim(lvl);
509 return (lvl == 0) ? 1 : mNext.getVoxelCount(lvl);
514 return (lvl == 0) ? mIter.isValueOn() : mNext.isValueOn(lvl);
519 if (lvl == 0)
return mIter.getValue();
520 return mNext.getValue(lvl);
525 if (lvl == 0) mIter.setValue(val);
else mNext.setValue(lvl, val);
529 if (lvl == 0) mIter.setValueOn(on);
else mNext.setValueOn(lvl, on);
533 if (lvl == 0) mIter.setValueOff();
else mNext.setValueOff(lvl);
536 template<
typename ModifyOp>
539 if (lvl == 0) mIter.modifyValue(op);
else mNext.modifyValue(lvl, op);
543 using RestT =
typename boost::mpl::pop_front<NodeVecT>::type;
553 template<
typename PrevItemT,
typename NodeVecT, Index _Level>
557 using _NodeT =
typename boost::mpl::front<NodeVecT>::type;
562 NodeConverter<_NodeT>::Type;
565 using NodeT =
typename IterT::NodeType;
567 using NCNodeT =
typename IterT::NonConstNodeType;
569 using NCValueT =
typename IterT::NonConstValueType;
583 if (&other !=
this) {
599 node = (lvl <=
Level) ? mIter.getParentNode() :
nullptr;
602 template<
typename OtherIterListItemT>
606 const NodeT* node =
nullptr;
607 otherListItem.getNode(lvl, node);
608 mIter = (node ==
nullptr) ?
IterT() : ITraits::begin(*const_cast<NodeT*>(node));
620 if (lvl ==
Level && mPrev !=
nullptr && mIter) {
621 if (
ChildT* child = ITraits::template getChild<ChildT>(mIter)) {
622 mPrev->setIter(PrevItemT::ITraits::begin(*child));
637 assert(lvl ==
Level);
639 return mIter.getValue();
646 template<
typename ModifyOp>
649 if (lvl ==
Level) mIter.modifyValue(op);
664 template<
typename _TreeT,
typename _ValueIterT>
670 using NodeT =
typename ValueIterT::NodeType;
671 using ValueT =
typename ValueIterT::NonConstValueType;
673 static const Index ROOT_LEVEL = NodeT::LEVEL;
674 static_assert(ValueIterT::NodeType::LEVEL == ROOT_LEVEL,
"invalid value iterator node type");
675 static const Index LEAF_LEVEL = 0, ROOT_DEPTH = 0, LEAF_DEPTH = ROOT_LEVEL;
683 void setMinDepth(
Index minDepth);
687 void setMaxDepth(
Index maxDepth);
692 bool test()
const {
return mValueIterList.test(mLevel); }
694 operator bool()
const {
return this->test(); }
715 template<
typename NodeType>
716 void getNode(NodeType*& node)
const { mValueIterList.getNode(mLevel, node); }
737 bool isValueOn()
const {
return mValueIterList.isValueOn(mLevel); }
740 const ValueT& getValue()
const {
return mValueIterList.getValue(mLevel); }
760 template<
typename ModifyOp>
761 void modifyValue(
const ModifyOp& op)
const { mValueIterList.modifyValue(mLevel, op); }
767 std::string summary()
const;
770 bool advance(
bool dontIncrement =
false);
773 struct PrevChildItem {
using IterT = ChildOnIterT; };
774 struct PrevValueItem {
using IterT = ValueIterT; };
776 IterListItem<PrevChildItem, InvTreeT, ROOT_LEVEL+1, 0> mChildIterList;
777 IterListItem<PrevValueItem, InvTreeT, ROOT_LEVEL+1, 0> mValueIterList;
779 int mMinLevel, mMaxLevel;
784 template<
typename TreeT,
typename ValueIterT>
787 mChildIterList(nullptr),
788 mValueIterList(nullptr),
790 mMinLevel(int(LEAF_LEVEL)),
791 mMaxLevel(int(ROOT_LEVEL)),
800 template<
typename TreeT,
typename ValueIterT>
803 mChildIterList(other.mChildIterList),
804 mValueIterList(other.mValueIterList),
805 mLevel(other.mLevel),
806 mMinLevel(other.mMinLevel),
807 mMaxLevel(other.mMaxLevel),
815 template<
typename TreeT,
typename ValueIterT>
819 if (&other !=
this) {
820 mChildIterList = other.mChildIterList;
821 mValueIterList = other.mValueIterList;
822 mLevel = other.mLevel;
823 mMinLevel = other.mMinLevel;
824 mMaxLevel = other.mMaxLevel;
826 mChildIterList.updateBackPointers();
827 mValueIterList.updateBackPointers();
833 template<
typename TreeT,
typename ValueIterT>
837 mMaxLevel = int(ROOT_LEVEL - minDepth);
838 if (
int(mLevel) > mMaxLevel) this->next();
842 template<
typename TreeT,
typename ValueIterT>
847 mMinLevel = int(ROOT_LEVEL -
std::min(maxDepth, this->getLeafDepth()));
848 if (
int(mLevel) < mMinLevel) this->next();
852 template<
typename TreeT,
typename ValueIterT>
857 if (!this->advance())
return false;
858 }
while (
int(mLevel) < mMinLevel ||
int(mLevel) > mMaxLevel);
863 template<
typename TreeT,
typename ValueIterT>
867 bool recurse =
false;
871 vPos = mValueIterList.pos(mLevel),
872 cPos = mChildIterList.pos(mLevel);
873 if (vPos == cPos && mChildIterList.test(mLevel)) {
875 mValueIterList.
next(mLevel);
876 vPos = mValueIterList.pos(mLevel);
879 if (dontIncrement)
return true;
880 if (mValueIterList.next(mLevel)) {
881 if (mValueIterList.pos(mLevel) == cPos && mChildIterList.test(mLevel)) {
884 mValueIterList.next(mLevel);
887 if (mValueIterList.pos(mLevel) < cPos)
return true;
891 if (!dontIncrement) mChildIterList.next(mLevel);
893 #ifdef DEBUG_TREE_VALUE_ITERATOR 894 std::cout <<
"\n" << this->summary() << std::flush;
898 while (mChildIterList.pos(mLevel) < mValueIterList.pos(mLevel)) {
899 #ifdef ENABLE_TREE_VALUE_DEPTH_BOUND_OPTIMIZATION 900 if (
int(mLevel) == mMinLevel) {
903 mChildIterList.next(mLevel);
904 if (mValueIterList.pos(mLevel) == mChildIterList.pos(mLevel)
905 && mChildIterList.test(mLevel))
909 mValueIterList.next(mLevel);
913 if (mChildIterList.down(mLevel)) {
915 mValueIterList.initLevel(mLevel, mChildIterList);
916 if (mValueIterList.pos(mLevel) == mChildIterList.pos(mLevel)
917 && mChildIterList.test(mLevel))
921 mValueIterList.next(mLevel);
924 #ifdef DEBUG_TREE_VALUE_ITERATOR 925 std::cout <<
"\n" << this->summary() << std::flush;
929 while (!mChildIterList.test(mLevel) && !mValueIterList.test(mLevel)) {
930 if (mLevel == ROOT_LEVEL)
return false;
932 mChildIterList.next(mLevel);
933 dontIncrement =
true;
941 template<
typename TreeT,
typename ValueIterT>
949 bbox.
min() = mValueIterList.getCoord(mLevel);
950 bbox.
max() = bbox.
min().
offsetBy(mValueIterList.getChildDim(mLevel) - 1);
955 template<
typename TreeT,
typename ValueIterT>
959 std::ostringstream ostr;
960 for (
int lvl =
int(ROOT_LEVEL); lvl >= 0 && lvl >= int(mLevel); --lvl) {
961 if (lvl == 0) ostr <<
"leaf";
962 else if (lvl ==
int(ROOT_LEVEL)) ostr <<
"root";
963 else ostr <<
"int" << (ROOT_LEVEL - lvl);
964 ostr <<
" v" << mValueIterList.pos(lvl)
965 <<
" c" << mChildIterList.pos(lvl);
966 if (lvl >
int(mLevel)) ostr <<
" / ";
968 if (this->test() && mValueIterList.pos(mLevel) < mChildIterList.pos(mLevel)) {
970 ostr <<
" " << this->getCoord();
972 ostr <<
" " << this->getBoundingBox();
983 template<
typename _TreeT,
typename RootChildOnIterT>
1013 bool test()
const {
return !mDone; }
1015 operator bool()
const {
return this->
test(); }
1047 template<
typename NodeT>
1051 void getNode(NodeT*& node)
const { node =
nullptr; mIterList.
getNode(mLevel, node); }
1052 template<
typename NodeT>
1053 void getNode(
const NodeT*& node)
const { node =
nullptr; mIterList.
getNode(mLevel, node); }
1061 struct PrevItem {
using IterT =
RootIterT; };
1065 int mMinLevel, mMaxLevel;
1071 template<
typename TreeT,
typename RootChildOnIterT>
1076 mMinLevel(int(LEAF_LEVEL)),
1077 mMaxLevel(int(ROOT_LEVEL)),
1084 template<
typename TreeT,
typename RootChildOnIterT>
1089 mMinLevel(int(LEAF_LEVEL)),
1090 mMaxLevel(int(ROOT_LEVEL)),
1094 mIterList.
setIter(RootIterTraits::begin(tree.root()));
1098 template<
typename TreeT,
typename RootChildOnIterT>
1101 mIterList(other.mIterList),
1102 mLevel(other.mLevel),
1103 mMinLevel(other.mMinLevel),
1104 mMaxLevel(other.mMaxLevel),
1112 template<
typename TreeT,
typename RootChildOnIterT>
1116 if (&other !=
this) {
1117 mLevel = other.mLevel;
1118 mMinLevel = other.mMinLevel;
1119 mMaxLevel = other.mMaxLevel;
1120 mDone = other.mDone;
1121 mTree = other.mTree;
1122 mIterList = other.mIterList;
1129 template<
typename TreeT,
typename RootChildOnIterT>
1133 mMaxLevel = int(ROOT_LEVEL - minDepth);
1134 if (
int(mLevel) > mMaxLevel) this->next();
1138 template<
typename TreeT,
typename RootChildOnIterT>
1143 mMinLevel = int(ROOT_LEVEL -
std::min(maxDepth, this->getLeafDepth()));
1144 if (
int(mLevel) < mMinLevel) this->next();
1148 template<
typename TreeT,
typename RootChildOnIterT>
1153 if (mDone)
return false;
1157 if (
int(mLevel) > mMinLevel && mIterList.test(mLevel)) {
1158 if (!mIterList.down(mLevel))
return false;
1162 while (!mIterList.test(mLevel)) {
1163 if (mLevel == ROOT_LEVEL) {
1169 mIterList.next(mLevel);
1172 if (!mIterList.down(mLevel))
return false;
1175 }
while (
int(mLevel) < mMinLevel || int(mLevel) > mMaxLevel);
1180 template<
typename TreeT,
typename RootChildOnIterT>
1184 if (mLevel != ROOT_LEVEL)
return mIterList.getCoord(mLevel + 1);
1186 this->getNode(root);
1187 return root ? root->getMinIndex() :
Coord::min();
1191 template<
typename TreeT,
typename RootChildOnIterT>
1195 if (mLevel == ROOT_LEVEL) {
1197 this->getNode(root);
1198 if (root ==
nullptr) {
1202 root->getIndexRange(bbox);
1205 bbox.
min() = mIterList.getCoord(mLevel + 1);
1206 bbox.
max() = bbox.
min().
offsetBy(mIterList.getChildDim(mLevel + 1) - 1);
1211 template<
typename TreeT,
typename RootChildOnIterT>
1215 std::ostringstream ostr;
1216 for (
int lvl =
int(ROOT_LEVEL); lvl >= 0 && lvl >= int(mLevel); --lvl) {
1217 if (lvl == 0) ostr <<
"leaf";
1218 else if (lvl ==
int(ROOT_LEVEL)) ostr <<
"root";
1219 else ostr <<
"int" << (ROOT_LEVEL - lvl);
1220 ostr <<
" c" << mIterList.pos(lvl);
1221 if (lvl >
int(mLevel)) ostr <<
" / ";
1224 this->getBoundingBox(bbox);
1225 ostr <<
" " << bbox;
1234 template<
typename TreeT,
typename RootChildOnIterT>
1254 mIterList.
setIter(RootIterTraits::begin(tree.root()));
1257 for ( ; lvl > 0 && mIterList.
down(lvl); --lvl) {}
1259 if (lvl > 0) this->
next();
1268 if (&other !=
this) {
1269 mTree = other.mTree;
1270 mIterList = other.mIterList;
1289 operator bool()
const {
return this->
test(); }
1303 struct PrevItem {
using IterT =
RootIterT; };
1313 template<
typename TreeT,
typename RootChildOnIterT>
1319 if (mIterList.test(LEAF_PARENT_LEVEL) && mIterList.next(LEAF_PARENT_LEVEL)) {
1320 mIterList.down(LEAF_PARENT_LEVEL);
1324 Index lvl = LEAF_PARENT_LEVEL;
1325 while (!mIterList.test(LEAF_PARENT_LEVEL)) {
1326 if (mIterList.test(lvl)) {
1327 mIterList.next(lvl);
1332 if (lvl == ROOT_LEVEL)
return false;
1334 if (mIterList.test(lvl)) mIterList.next(lvl);
1335 }
while (!mIterList.test(lvl));
1338 while (lvl > LEAF_PARENT_LEVEL && mIterList.down(lvl)) --lvl;
1340 mIterList.down(LEAF_PARENT_LEVEL);
1350 template<
typename IterT>
1356 mGrainSize(grainSize),
1359 mSize = this->size();
1363 mGrainSize(other.mGrainSize),
1364 mSize(other.mSize >> 1)
1374 bool empty()
const {
return mSize == 0 || !mIter.test(); }
1376 operator bool()
const {
return !this->
empty(); }
1383 void increment(
Index n = 1) {
for ( ; n > 0 && mSize > 0; --n, --mSize, ++mIter) {} }
1391 Index size()
const {
Index n = 0;
for (IterT it(mIter); it.test(); ++n, ++it) {}
return n; }
1413 #endif // OPENVDB_TREE_TREEITERATOR_HAS_BEEN_INCLUDED Base class for tree-traversal iterators over all nodes.
Definition: TreeIterator.h:984
An IterListItem is an element of a compile-time linked list of iterators to nodes of different types.
Definition: TreeIterator.h:262
typename RootIterT::NonConstNodeType NCRootNodeT
Definition: TreeIterator.h:990
std::string summary() const
Return a string (for debugging, mainly) describing this iterator's current state.
Definition: TreeIterator.h:957
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:345
void setIter(const IterT &iter)
Definition: TreeIterator.h:595
static ChildT * getChild(const IterT &iter)
Definition: TreeIterator.h:178
IterListItem & operator=(const IterListItem &other)
Definition: TreeIterator.h:452
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:338
bool next(Index lvl)
Definition: TreeIterator.h:494
void increment(Index n)
Increment the iterator n times.
Definition: TreeIterator.h:1025
void setIter(const OtherIterT &iter)
Definition: TreeIterator.h:305
typename OtherNodeT::ChildAllIter Type
Definition: TreeIterator.h:169
bool isValueOn(Index lvl) const
Definition: TreeIterator.h:633
CoordBBox getBoundingBox() const
Return the axis-aligned bounding box of the voxel or tile to which this iterator is currently pointin...
Definition: TreeIterator.h:1044
typename IterT::NonConstNodeType NCNodeT
The type of the node with const qualifiers removed ("Non-Const")
Definition: TreeIterator.h:441
void setValueOff(Index lvl) const
Definition: TreeIterator.h:531
void increment(Index n=1)
Advance the iterator n times.
Definition: TreeIterator.h:1383
Index32 Index
Definition: Types.h:61
LeafNodeT & operator *() const
Return the leaf node to which the iterator is pointing.
Definition: TreeIterator.h:1284
static IterT begin(const NodeT &node)
Definition: TreeIterator.h:221
typename iter::InvertedTree< NCRootNodeT, ROOT_LEVEL >::Type InvTreeT
Definition: TreeIterator.h:1242
Index getDepth() const
Return the depth in the tree (0 = root) of the node to which this iterator is currently pointing.
Definition: TreeIterator.h:1032
uint64_t Index64
Definition: Types.h:60
Definition: TreeIterator.h:1351
typename NodeT::ChildOffCIter IterT
Definition: TreeIterator.h:152
Index pos(Index lvl) const
Definition: TreeIterator.h:612
Base class for tree-traversal iterators over all leaf nodes (but not leaf voxels)
Definition: TreeIterator.h:1235
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:748
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:436
typename NodeT::ChildOnCIter ChildOnIterT
Definition: TreeIterator.h:672
typename boost::mpl::front< NodeVecT >::type _NodeT
The type of node (non-const) whose iterator is stored in this list item.
Definition: TreeIterator.h:433
Index getLevel() const
Return the level in the tree (0 = leaf) of the node to which this iterator is currently pointing.
Definition: TreeIterator.h:705
std::string summary() const
Definition: TreeIterator.h:1213
bool isValueOn(Index lvl) const
Definition: TreeIterator.h:512
Base class for tree-traversal iterators over tile and voxel values.
Definition: TreeIterator.h:665
bool test() const
Definition: TreeIterator.h:1288
TreeT * getTree() const
Return a pointer to the tree over which this iterator is iterating.
Definition: TreeIterator.h:764
bool down(Index lvl)
Definition: TreeIterator.h:618
typename PrevItemT::IterT PrevIterT
The type of iterator stored in the previous list item.
Definition: TreeIterator.h:431
CoordBBox getBoundingBox() const
Return the axis-aligned bounding box of the voxel or tile to which this iterator is currently pointin...
Definition: TreeIterator.h:727
typename NodeT::ChildOnIter IterT
Definition: TreeIterator.h:116
Index64 getVoxelCount(Index lvl) const
Return the number of (virtual) voxels spanned by a tile value or child node.
Definition: TreeIterator.h:367
Index64 getVoxelCount(Index lvl) const
Definition: TreeIterator.h:507
typename boost::mpl::vector< typename HeadT::ChildNodeType, HeadT >::type Type
Definition: TreeIterator.h:87
bool test() const
Return true if this iterator is not yet exhausted.
Definition: TreeIterator.h:1014
Index getMaxDepth() const
Return the depth of the lowest level of the tree to which this iterator ascends.
Definition: TreeIterator.h:689
static const Index LEAF_LEVEL
Definition: TreeIterator.h:1245
bool next(Index lvl)
Increment the iterator at level lvl of the tree.
Definition: TreeIterator.h:341
bool isValueOn() const
Return true if the value to which this iterator is currently pointing is active.
Definition: TreeIterator.h:737
IterListItem(PrevItemT *prev)
Definition: TreeIterator.h:578
typename OtherNodeT::ValueAllIter Type
Definition: TreeIterator.h:233
const Coord & max() const
Definition: Coord.h:338
typename OtherNodeT::ChildOnIter Type
Definition: TreeIterator.h:122
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:271
void setIter(const OtherIterT &iter)
Definition: TreeIterator.h:469
void initLevel(Index lvl, OtherIterListItemT &otherListItem)
Definition: TreeIterator.h:603
const ValueT * operator->() const
Return the tile or voxel value to which this iterator is currently pointing.
Definition: TreeIterator.h:743
bool empty() const
Definition: TreeIterator.h:1374
static const Index LEAF_LEVEL
Definition: TreeIterator.h:993
void modifyValue(Index lvl, const ModifyOp &op) const
Definition: TreeIterator.h:537
RootChildOnIterT RootIterT
Definition: TreeIterator.h:1238
NodeIteratorBase()
Definition: TreeIterator.h:1073
typename IterT::NonConstNodeType NCNodeT
The type of the node with const qualifiers removed ("Non-Const")
Definition: TreeIterator.h:276
LeafIteratorBase & operator++()
Advance the iterator to the next leaf node.
Definition: TreeIterator.h:1295
typename CopyConstness< NCNodeT, typename NCNodeT::ChildNodeType >::Type NCChildT
NodeT's child node type with const qualifiers removed.
Definition: TreeIterator.h:282
bool test() const
Definition: TreeIterator.h:1375
typename CopyConstness< NodeT, typename NodeT::ChildNodeType >::Type ChildT
NodeT's child node type, with the same constness (e.g., const InternalNode<...>)
Definition: TreeIterator.h:571
void modifyValue(Index lvl, const ModifyOp &op) const
Definition: TreeIterator.h:647
typename IterT::NodeType NodeT
The type of node over which IterT iterates (e.g., const RootNode<...>)
Definition: TreeIterator.h:565
IteratorRange & operator++()
Advance the iterator to the next item.
Definition: TreeIterator.h:1385
void getNode(NodeT *&node) const
Return the node to which the iterator is pointing.
Definition: TreeIterator.h:1051
static IterT begin(NodeT &node)
Definition: TreeIterator.h:191
Index getMinDepth() const
Return the depth of the highest level of the tree to which this iterator ascends.
Definition: TreeIterator.h:1006
void setValueOff() const
Mark the tile or voxel value to which this iterator is currently pointing as inactive.
Definition: TreeIterator.h:753
static const Index LEAF_DEPTH
Definition: TreeIterator.h:993
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
typename NodeT::ChildAllIter IterT
Definition: TreeIterator.h:162
Signed (x, y, z) 32-bit integer coordinates.
Definition: Coord.h:51
void setValueOff(Index lvl) const
Definition: TreeIterator.h:644
static const Index LEAF_PARENT_LEVEL
Definition: TreeIterator.h:1245
IteratorRange(const IterT &iter, size_t grainSize=8)
Definition: TreeIterator.h:1354
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:1380
IteratorRange(IteratorRange &other, tbb::split)
Definition: TreeIterator.h:1361
void initLevel(Index lvl, OtherIterListItemT &otherListItem)
Definition: TreeIterator.h:479
Coord getCoord(Index lvl) const
Definition: TreeIterator.h:629
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:388
void increment()
Advance the iterator to the next leaf node.
Definition: TreeIterator.h:1294
bool next()
Advance the iterator to the next item.
Definition: TreeIterator.h:1388
bool isTileValue() const
Return true if this iterator is currently pointing to a (non-leaf) tile value.
Definition: TreeIterator.h:733
typename InvertedTree< typename HeadT::ChildNodeType, HeadLevel-1 >::Type SubtreeT
Definition: TreeIterator.h:82
LeafIteratorBase()
Definition: TreeIterator.h:1249
LeafNodeT * operator->() const
Return the leaf node to which the iterator is pointing.
Definition: TreeIterator.h:1285
static const ChildT * getChild(const IterT &iter)
Definition: TreeIterator.h:131
Index getDepth() const
Return the depth in the tree (0 = root) of the node to which this iterator is currently pointing.
Definition: TreeIterator.h:708
void getNode(Index lvl, NodeT *&node) const
Return the node over which this list element's iterator iterates.
Definition: TreeIterator.h:308
LeafIteratorBase & operator=(const LeafIteratorBase &other)
Definition: TreeIterator.h:1266
static const Index ROOT_LEVEL
Definition: TreeIterator.h:991
typename OtherNodeT::ChildOnCIter Type
Definition: TreeIterator.h:135
typename NodeT::ChildOnCIter IterT
Definition: TreeIterator.h:129
typename boost::mpl::front< NodeVecT >::type _NodeT
Definition: TreeIterator.h:557
Coord getCoord() const
Return the global coordinates of the voxel or tile to which this iterator is currently pointing.
Definition: TreeIterator.h:720
Index getLevel() const
Return the level in the tree (0 = leaf) of the node to which this iterator is currently pointing.
Definition: TreeIterator.h:1029
void getNode(Index lvl, NodeT *&node) const
Definition: TreeIterator.h:597
static ChildT * getChild(const IterT &iter)
Definition: TreeIterator.h:164
typename NodeT::ValueOnCIter IterT
Definition: TreeIterator.h:200
typename OtherNodeT::ChildOffCIter Type
Definition: TreeIterator.h:155
void setValueOff(Index lvl) const
Mark the value to which the iterator at level lvl of the tree points as inactive.
Definition: TreeIterator.h:402
static ChildT * getChild(const IterT &iter)
Definition: TreeIterator.h:118
typename std::remove_const< ToType >::type Type
Definition: TreeIterator.h:68
typename ValueIterT::NodeType NodeT
Definition: TreeIterator.h:670
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:716
void updateBackPointers(PrevItemT *prev)
Definition: TreeIterator.h:590
void setValue(Index lvl, const NCValueT &val) const
Definition: TreeIterator.h:523
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition: version.h:136
TreeValueIteratorBase(TreeT &)
Definition: TreeIterator.h:786
typename OtherNodeT::ValueOffIter Type
Definition: TreeIterator.h:213
_ValueIterT ValueIterT
Definition: TreeIterator.h:669
Index pos(Index lvl) const
Definition: TreeIterator.h:490
typename IterT::NonConstNodeType NCNodeT
The type of the node with const qualifiers removed ("Non-Const")
Definition: TreeIterator.h:567
Index getChildDim(Index lvl) const
Definition: TreeIterator.h:362
typename RootIterT::NodeType RootNodeT
Definition: TreeIterator.h:989
Index getChildDim(Index lvl) const
Definition: TreeIterator.h:630
typename OtherNodeT::ChildAllCIter Type
Definition: TreeIterator.h:183
typename NodeT::ValueOffCIter IterT
Definition: TreeIterator.h:220
IterListItem(PrevItemT *)
Definition: TreeIterator.h:448
TreeValueIteratorBase & operator++()
Advance to the next tile or voxel value.
Definition: TreeIterator.h:701
typename iter::InvertedTree< NCRootNodeT, ROOT_LEVEL >::Type InvTreeT
Definition: TreeIterator.h:992
IterListItem & operator=(const IterListItem &other)
Definition: TreeIterator.h:581
typename boost::mpl::front< InvTreeT >::type _NodeT
The type of node (non-const) whose iterator is stored in this list item.
Definition: TreeIterator.h:268
static const Index ROOT_LEVEL
Definition: TreeIterator.h:1241
static IterT begin(NodeT &node)
Definition: TreeIterator.h:117
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:395
const Coord & min() const
Definition: Coord.h:337
Definition: TreeIterator.h:108
typename IterT::NonConstValueType NCValueT
The type of value (with const qualifiers removed) to which the iterator points.
Definition: TreeIterator.h:443
Definition: TreeIterator.h:81
typename ValueIterT::NonConstValueType ValueT
Definition: TreeIterator.h:671
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:761
bool next()
Advance to the next tile or voxel value.
Definition: TreeIterator.h:1150
Definition: Exceptions.h:40
const NCValueT & getValue(Index lvl) const
Return the value to which the iterator at level lvl of the tree points.
Definition: TreeIterator.h:379
Axis-aligned bounding box of signed integer coordinates.
Definition: Coord.h:264
IterListItem(const IterListItem &other)
Definition: TreeIterator.h:289
Level
Message severity level.
Definition: logging.h:58
typename OtherNodeT::ChildOffIter Type
Definition: TreeIterator.h:145
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:358
typename IterT::NonConstValueType NCValueT
The type of value (with const qualifiers removed) to which the iterator points.
Definition: TreeIterator.h:569
typename CopyConstness< RootNodeT, NCLeafNodeT >::Type LeafNodeT
Definition: TreeIterator.h:1244
typename OtherNodeT::ValueOnIter Type
Definition: TreeIterator.h:193
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:562
bool test(Index lvl) const
Definition: TreeIterator.h:614
void setMinDepth(Index minDepth)
Specify the depth of the highest level of the tree to which to ascend (depth 0 = root).
Definition: TreeIterator.h:1131
void updateBackPointers(PrevItemT *=nullptr)
Definition: TreeIterator.h:462
void setValueOn(Index lvl, bool on=true) const
Definition: TreeIterator.h:527
void setIter(const IterT &iter)
Definition: TreeIterator.h:303
IterListItem(PrevItemT *prev)
Definition: TreeIterator.h:287
bool next(Index lvl)
Definition: TreeIterator.h:616
typename CopyConstness< NodeT, typename NodeT::ChildNodeType >::Type ChildT
NodeT's child node type, with the same constness (e.g., const InternalNode<...>)
Definition: TreeIterator.h:280
NodeIteratorBase & operator=(const NodeIteratorBase &other)
Definition: TreeIterator.h:1114
typename IterT::NonConstValueType NCValueT
The type of value (with const qualifiers removed) to which the iterator points.
Definition: TreeIterator.h:278
void setValue(Index lvl, const NCValueT &val) const
Definition: TreeIterator.h:642
typename NodeT::ChildAllCIter IterT
Definition: TreeIterator.h:176
typename NodeT::ValueOnIter IterT
Definition: TreeIterator.h:190
IterListItem(const IterListItem &other)
Definition: TreeIterator.h:450
static IterT begin(NodeT &node)
Definition: TreeIterator.h:143
Library and file format version numbers.
typename boost::mpl::front< InvTreeT >::type NCLeafNodeT
Definition: TreeIterator.h:1243
typename boost::mpl::push_back< SubtreeT, HeadT >::type Type
Definition: TreeIterator.h:83
NodeIteratorBase & operator++()
Definition: TreeIterator.h:1023
static IterT begin(const NodeT &node)
Definition: TreeIterator.h:177
void getNode(Index lvl, OtherNodeT *&node) const
Return the node over which one of the following list elements' iterator iterates.
Definition: TreeIterator.h:314
bool next()
Advance to the next tile or voxel value. Return true if this iterator is not yet exhausted.
Definition: TreeIterator.h:854
typename OtherNodeT::ValueOnCIter Type
Definition: TreeIterator.h:203
static Index getLeafDepth()
Definition: TreeIterator.h:709
void getNode(Index lvl, OtherNodeT *&node) const
Definition: TreeIterator.h:476
void setIter(const IterT &iter)
Definition: TreeIterator.h:467
void modifyValue(Index lvl, const ModifyOp &op) const
Apply a functor to the item to which this iterator is pointing.
Definition: TreeIterator.h:410
Definition: TreeIterator.h:67
bool isVoxelValue() const
Return true if this iterator is currently pointing to a (leaf) voxel value.
Definition: TreeIterator.h:735
RootChildOnIterT RootIterT
Definition: TreeIterator.h:988
TreeT * getTree() const
Definition: TreeIterator.h:1056
bool next()
Advance the iterator to the next leaf node.
Definition: TreeIterator.h:1315
Index64 getVoxelCount(Index lvl) const
Definition: TreeIterator.h:631
typename IterT::NodeType NodeT
The type of node (const or non-const) over which IterT iterates (e.g., const RootNode<....
Definition: TreeIterator.h:439
static Coord min()
Return the smallest possible coordinate.
Definition: Coord.h:70
static IterT begin(NodeT &node)
Definition: TreeIterator.h:231
Coord getCoord() const
Return the global coordinates of the voxel or tile to which this iterator is currently pointing.
Definition: TreeIterator.h:1182
const NCValueT & getValue(Index lvl) const
Definition: TreeIterator.h:517
typename CopyConstness< NCNodeT, typename NCNodeT::ChildNodeType >::Type NCChildT
NodeT's child node type with const qualifiers removed.
Definition: TreeIterator.h:573
const IterT & iterator() const
Return a reference to this range's iterator.
Definition: TreeIterator.h:1372
typename RootIterT::NonConstNodeType NCRootNodeT
Definition: TreeIterator.h:1240
static IterT begin(const NodeT &node)
Definition: TreeIterator.h:153
_TreeT TreeT
Definition: TreeIterator.h:668
void getNode(const NodeT *&node) const
Return the node to which the iterator is pointing.
Definition: TreeIterator.h:1053
Index getMinDepth() const
Return the depth of the highest level of the tree to which this iterator ascends.
Definition: TreeIterator.h:685
Index64 getVoxelCount() const
Return the number of (virtual) voxels corresponding to the value.
Definition: TreeIterator.h:730
Index getMaxDepth() const
Return the depth of the lowest level of the tree to which this iterator ascends.
Definition: TreeIterator.h:1010
_TreeT TreeT
Definition: TreeIterator.h:987
bool isValueOn(Index lvl) const
Return true if the iterator at level lvl of the tree points to an active value.
Definition: TreeIterator.h:373
static Index getLeafDepth()
Definition: TreeIterator.h:1033
TreeT * getTree() const
Definition: TreeIterator.h:1300
void increment()
Advance the iterator to the next leaf node.
Definition: TreeIterator.h:1022
static IterT begin(const NodeT &node)
Definition: TreeIterator.h:130
void getNode(Index lvl, NodeT *&node) const
Definition: TreeIterator.h:471
typename NodeT::ValueAllIter IterT
Definition: TreeIterator.h:230
typename IterT::NodeType NodeT
The type of node (const or non-const) over which IterT iterates (e.g., const RootNode<....
Definition: TreeIterator.h:274
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:751
void setMinDepth(Index minDepth)
Specify the depth of the highest level of the tree to which to ascend (depth 0 = root).
Definition: TreeIterator.h:835
Index pos(Index lvl) const
Return The table offset of the iterator at level lvl of the tree.
Definition: TreeIterator.h:335
typename PrevItemT::IterT PrevIterT
The type of iterator stored in the previous list item.
Definition: TreeIterator.h:559
bool test(Index lvl) const
Definition: TreeIterator.h:492
typename OtherNodeT::ValueAllCIter Type
Definition: TreeIterator.h:243
static IterT begin(NodeT &node)
Definition: TreeIterator.h:163
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h:188
LeafIteratorBase(TreeT &tree)
Definition: TreeIterator.h:1251
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:322
static IterT begin(const NodeT &node)
Definition: TreeIterator.h:241
static IterT begin(const NodeT &node)
Definition: TreeIterator.h:201
LeafNodeT * getLeaf() const
Return the leaf node to which the iterator is pointing.
Definition: TreeIterator.h:1278
void setMaxDepth(Index maxDepth)
Specify the depth of the lowest level of the tree to which to descend (depth 0 = root).
Definition: TreeIterator.h:1140
bool down(Index lvl)
Definition: TreeIterator.h:496
typename NodeT::ValueAllCIter IterT
Definition: TreeIterator.h:240
const NCValueT & getValue(Index lvl) const
Definition: TreeIterator.h:635
Index getChildDim(Index lvl) const
Definition: TreeIterator.h:502
typename NodeT::ChildOffIter IterT
Definition: TreeIterator.h:142
LeafIteratorBase(const LeafIteratorBase &other)
Definition: TreeIterator.h:1262
Coord getCoord(Index lvl) const
Definition: TreeIterator.h:498
const ToType Type
Definition: TreeIterator.h:71
static const Index ROOT_DEPTH
Definition: TreeIterator.h:993
IterListItem & operator=(const IterListItem &other)
Definition: TreeIterator.h:291
typename NodeT::ValueOffIter IterT
Definition: TreeIterator.h:210
TreeValueIteratorBase & operator=(const TreeValueIteratorBase &other)
Definition: TreeIterator.h:817
static IterT begin(NodeT &node)
Definition: TreeIterator.h:211
IterListItem(const IterListItem &other)
Definition: TreeIterator.h:580
void updateBackPointers(PrevItemT *prev)
Definition: TreeIterator.h:301
typename PrevItem ::IterT PrevIterT
The type of iterator stored in the previous list item.
Definition: TreeIterator.h:266
static ChildT * getChild(const IterT &)
Definition: TreeIterator.h:110
typename RootIterT::NodeType RootNodeT
Definition: TreeIterator.h:1239
void setValueOn(Index lvl, bool on=true) const
Definition: TreeIterator.h:643
typename OtherNodeT::ValueOffCIter Type
Definition: TreeIterator.h:223
Coord offsetBy(Int32 dx, Int32 dy, Int32 dz) const
Definition: Coord.h:118
void setMaxDepth(Index maxDepth)
Specify the depth of the lowest level of the tree to which to descend (depth 0 = root).
Definition: TreeIterator.h:844