6 #ifndef OPENVDB_TREE_TREEITERATOR_HAS_BEEN_INCLUDED 7 #define OPENVDB_TREE_TREEITERATOR_HAS_BEEN_INCLUDED 9 #include <boost/mpl/front.hpp> 10 #include <boost/mpl/pop_front.hpp> 11 #include <boost/mpl/push_back.hpp> 12 #include <boost/mpl/size.hpp> 13 #include <boost/mpl/vector.hpp> 14 #include <tbb/blocked_range.h> 15 #include <tbb/parallel_for.h> 21 #include <type_traits> 26 #define ENABLE_TREE_VALUE_DEPTH_BOUND_OPTIMIZATION 36 template<
typename HeadT,
int HeadLevel>
39 using Type =
typename boost::mpl::push_back<SubtreeT, HeadT>::type;
41 template<
typename HeadT>
43 using Type =
typename boost::mpl::vector<typename HeadT::ChildNodeType, HeadT>::type;
63 template<
typename NodeT,
typename IterT>
66 template<
typename ChildT>
static ChildT*
getChild(
const IterT&) {
return nullptr; }
69 template<
typename NodeT>
72 using IterT =
typename NodeT::ChildOnIter;
73 static IterT begin(NodeT& node) {
return node.beginChildOn(); }
75 return &iter.getValue();
77 template<
typename OtherNodeT>
struct NodeConverter {
78 using Type =
typename OtherNodeT::ChildOnIter;
82 template<
typename NodeT>
85 using IterT =
typename NodeT::ChildOnCIter;
86 static IterT begin(
const NodeT& node) {
return node.cbeginChildOn(); }
87 template<
typename ChildT>
static const ChildT*
getChild(
const IterT& iter) {
88 return &iter.getValue();
90 template<
typename OtherNodeT>
struct NodeConverter {
91 using Type =
typename OtherNodeT::ChildOnCIter;
95 template<
typename NodeT>
98 using IterT =
typename NodeT::ChildOffIter;
99 static IterT begin(NodeT& node) {
return node.beginChildOff(); }
100 template<
typename OtherNodeT>
struct NodeConverter {
101 using Type =
typename OtherNodeT::ChildOffIter;
105 template<
typename NodeT>
108 using IterT =
typename NodeT::ChildOffCIter;
109 static IterT begin(
const NodeT& node) {
return node.cbeginChildOff(); }
110 template<
typename OtherNodeT>
struct NodeConverter {
111 using Type =
typename OtherNodeT::ChildOffCIter;
115 template<
typename NodeT>
118 using IterT =
typename NodeT::ChildAllIter;
119 static IterT begin(NodeT& node) {
return node.beginChildAll(); }
121 typename IterT::NonConstValueType val;
122 return iter.probeChild(val);
124 template<
typename OtherNodeT>
struct NodeConverter {
125 using Type =
typename OtherNodeT::ChildAllIter;
129 template<
typename NodeT>
132 using IterT =
typename NodeT::ChildAllCIter;
133 static IterT begin(
const NodeT& node) {
return node.cbeginChildAll(); }
135 typename IterT::NonConstValueType val;
136 return iter.probeChild(val);
138 template<
typename OtherNodeT>
struct NodeConverter {
139 using Type =
typename OtherNodeT::ChildAllCIter;
143 template<
typename NodeT>
146 using IterT =
typename NodeT::ValueOnIter;
147 static IterT begin(NodeT& node) {
return node.beginValueOn(); }
148 template<
typename OtherNodeT>
struct NodeConverter {
149 using Type =
typename OtherNodeT::ValueOnIter;
153 template<
typename NodeT>
156 using IterT =
typename NodeT::ValueOnCIter;
157 static IterT begin(
const NodeT& node) {
return node.cbeginValueOn(); }
158 template<
typename OtherNodeT>
struct NodeConverter {
159 using Type =
typename OtherNodeT::ValueOnCIter;
163 template<
typename NodeT>
166 using IterT =
typename NodeT::ValueOffIter;
167 static IterT begin(NodeT& node) {
return node.beginValueOff(); }
168 template<
typename OtherNodeT>
struct NodeConverter {
169 using Type =
typename OtherNodeT::ValueOffIter;
173 template<
typename NodeT>
176 using IterT =
typename NodeT::ValueOffCIter;
177 static IterT begin(
const NodeT& node) {
return node.cbeginValueOff(); }
178 template<
typename OtherNodeT>
struct NodeConverter {
179 using Type =
typename OtherNodeT::ValueOffCIter;
183 template<
typename NodeT>
186 using IterT =
typename NodeT::ValueAllIter;
187 static IterT begin(NodeT& node) {
return node.beginValueAll(); }
188 template<
typename OtherNodeT>
struct NodeConverter {
189 using Type =
typename OtherNodeT::ValueAllIter;
193 template<
typename NodeT>
196 using IterT =
typename NodeT::ValueAllCIter;
197 static IterT begin(
const NodeT& node) {
return node.cbeginValueAll(); }
198 template<
typename OtherNodeT>
struct NodeConverter {
199 using Type =
typename OtherNodeT::ValueAllCIter;
217 template<
typename PrevItemT,
typename NodeVecT,
size_t VecSize, Index _Level>
224 using _NodeT =
typename boost::mpl::front<NodeVecT>::type;
227 NodeConverter<_NodeT>::Type;
230 using NodeT =
typename IterT::NodeType;
232 using NCNodeT =
typename IterT::NonConstNodeType;
234 using NCValueT =
typename IterT::NonConstValueType;
246 mIter(other.mIter), mNext(other.mNext), mPrev(nullptr) {}
249 if (&other !=
this) {
260 template<
typename OtherIterT>
261 void setIter(
const OtherIterT& iter) { mNext.setIter(iter); }
266 node = (lvl <=
Level) ? mIter.getParentNode() :
nullptr;
269 template<
typename OtherNodeT>
270 void getNode(
Index lvl, OtherNodeT*& node)
const { mNext.getNode(lvl, node); }
277 template<
typename OtherIterListItemT>
281 const NodeT* node =
nullptr;
282 otherListItem.getNode(lvl, node);
283 mIter = (node ==
nullptr) ?
IterT() : ITraits::begin(*const_cast<NodeT*>(node));
286 mNext.initLevel(lvl, otherListItem);
294 bool test(
Index lvl)
const {
return (lvl ==
Level) ? mIter.test() : mNext.test(lvl); }
303 if (lvl ==
Level && mPrev !=
nullptr && mIter) {
304 if (
ChildT* child = ITraits::template getChild<ChildT>(mIter)) {
305 mPrev->setIter(PrevItemT::ITraits::begin(*child));
309 return (lvl >
Level) ? mNext.down(lvl) :
false;
316 return (lvl ==
Level) ? mIter.getCoord() : mNext.getCoord(lvl);
320 return (lvl ==
Level) ? NodeT::getChildDim() : mNext.getChildDim(lvl);
325 return (lvl ==
Level) ? ChildT::NUM_VOXELS : mNext.getVoxelCount(lvl);
331 return (lvl ==
Level) ? mIter.isValueOn() : mNext.isValueOn(lvl);
337 if (lvl ==
Level)
return mIter.getValue();
338 return mNext.getValue(lvl);
346 if (lvl ==
Level) mIter.setValue(val);
else mNext.setValue(lvl, val);
353 if (lvl ==
Level) mIter.setValueOn(on);
else mNext.setValueOn(lvl, on);
360 if (lvl ==
Level) mIter.setValueOff();
else mNext.setValueOff(lvl);
365 template<
typename ModifyOp>
368 if (lvl ==
Level) mIter.modifyValue(op);
else mNext.modifyValue(lvl, op);
372 using RestT =
typename boost::mpl::pop_front<NodeVecT>::type;
382 template<
typename PrevItemT,
typename NodeVecT,
size_t VecSize>
389 using _NodeT =
typename boost::mpl::front<NodeVecT>::type;
392 NodeConverter<_NodeT>::Type;
395 using NodeT =
typename IterT::NodeType;
397 using NCNodeT =
typename IterT::NonConstNodeType;
399 using NCValueT =
typename IterT::NonConstValueType;
407 mIter(other.mIter), mNext(other.mNext), mPrev(nullptr) {}
410 if (&other !=
this) {
420 mPrev =
nullptr; mNext.updateBackPointers(
this);
424 template<
typename OtherIterT>
425 void setIter(
const OtherIterT& iter) { mNext.setIter(iter); }
429 node = (lvl == 0) ? mIter.getParentNode() :
nullptr;
431 template<
typename OtherNodeT>
432 void getNode(
Index lvl, OtherNodeT*& node)
const { mNext.getNode(lvl, node); }
434 template<
typename OtherIterListItemT>
438 const NodeT* node =
nullptr;
439 otherListItem.getNode(lvl, node);
440 mIter = (node ==
nullptr) ?
IterT() : ITraits::begin(*const_cast<NodeT*>(node));
442 mNext.initLevel(lvl, otherListItem);
446 Index pos(
Index lvl)
const {
return (lvl == 0) ? mIter.pos() : mNext.pos(lvl); }
448 bool test(
Index lvl)
const {
return (lvl == 0) ? mIter.test() : mNext.test(lvl); }
450 bool next(
Index lvl) {
return (lvl == 0) ? mIter.next() : mNext.next(lvl); }
452 bool down(
Index lvl) {
return (lvl == 0) ? false : mNext.down(lvl); }
456 return (lvl == 0) ? mIter.getCoord() : mNext.getCoord(lvl);
460 return (lvl == 0) ? NodeT::getChildDim() : mNext.getChildDim(lvl);
465 return (lvl == 0) ? 1 : mNext.getVoxelCount(lvl);
470 return (lvl == 0) ? mIter.isValueOn() : mNext.isValueOn(lvl);
475 if (lvl == 0)
return mIter.getValue();
476 return mNext.getValue(lvl);
481 if (lvl == 0) mIter.setValue(val);
else mNext.setValue(lvl, val);
485 if (lvl == 0) mIter.setValueOn(on);
else mNext.setValueOn(lvl, on);
489 if (lvl == 0) mIter.setValueOff();
else mNext.setValueOff(lvl);
492 template<
typename ModifyOp>
495 if (lvl == 0) mIter.modifyValue(op);
else mNext.modifyValue(lvl, op);
499 using RestT =
typename boost::mpl::pop_front<NodeVecT>::type;
509 template<
typename PrevItemT,
typename NodeVecT, Index _Level>
513 using _NodeT =
typename boost::mpl::front<NodeVecT>::type;
518 NodeConverter<_NodeT>::Type;
521 using NodeT =
typename IterT::NodeType;
523 using NCNodeT =
typename IterT::NonConstNodeType;
525 using NCValueT =
typename IterT::NonConstValueType;
539 if (&other !=
this) {
555 node = (lvl <=
Level) ? mIter.getParentNode() :
nullptr;
558 template<
typename OtherIterListItemT>
562 const NodeT* node =
nullptr;
563 otherListItem.getNode(lvl, node);
564 mIter = (node ==
nullptr) ?
IterT() : ITraits::begin(*const_cast<NodeT*>(node));
576 if (lvl ==
Level && mPrev !=
nullptr && mIter) {
577 if (
ChildT* child = ITraits::template getChild<ChildT>(mIter)) {
578 mPrev->setIter(PrevItemT::ITraits::begin(*child));
593 assert(lvl ==
Level);
595 return mIter.getValue();
602 template<
typename ModifyOp>
605 if (lvl ==
Level) mIter.modifyValue(op);
620 template<
typename _TreeT,
typename _ValueIterT>
626 using NodeT =
typename ValueIterT::NodeType;
627 using ValueT =
typename ValueIterT::NonConstValueType;
629 static const Index ROOT_LEVEL = NodeT::LEVEL;
630 static_assert(ValueIterT::NodeType::LEVEL == ROOT_LEVEL,
"invalid value iterator node type");
631 static const Index LEAF_LEVEL = 0, ROOT_DEPTH = 0, LEAF_DEPTH = ROOT_LEVEL;
639 void setMinDepth(
Index minDepth);
643 void setMaxDepth(
Index maxDepth);
648 bool test()
const {
return mValueIterList.test(mLevel); }
650 operator bool()
const {
return this->test(); }
671 template<
typename NodeType>
672 void getNode(NodeType*& node)
const { mValueIterList.getNode(mLevel, node); }
693 bool isValueOn()
const {
return mValueIterList.isValueOn(mLevel); }
696 const ValueT& getValue()
const {
return mValueIterList.getValue(mLevel); }
716 template<
typename ModifyOp>
717 void modifyValue(
const ModifyOp& op)
const { mValueIterList.modifyValue(mLevel, op); }
723 std::string summary()
const;
726 bool advance(
bool dontIncrement =
false);
729 struct PrevChildItem {
using IterT = ChildOnIterT; };
730 struct PrevValueItem {
using IterT = ValueIterT; };
732 IterListItem<PrevChildItem, InvTreeT, ROOT_LEVEL+1, 0> mChildIterList;
733 IterListItem<PrevValueItem, InvTreeT, ROOT_LEVEL+1, 0> mValueIterList;
735 int mMinLevel, mMaxLevel;
740 template<
typename TreeT,
typename ValueIterT>
743 mChildIterList(nullptr),
744 mValueIterList(nullptr),
746 mMinLevel(int(LEAF_LEVEL)),
747 mMaxLevel(int(ROOT_LEVEL)),
756 template<
typename TreeT,
typename ValueIterT>
759 mChildIterList(other.mChildIterList),
760 mValueIterList(other.mValueIterList),
761 mLevel(other.mLevel),
762 mMinLevel(other.mMinLevel),
763 mMaxLevel(other.mMaxLevel),
771 template<
typename TreeT,
typename ValueIterT>
775 if (&other !=
this) {
776 mChildIterList = other.mChildIterList;
777 mValueIterList = other.mValueIterList;
778 mLevel = other.mLevel;
779 mMinLevel = other.mMinLevel;
780 mMaxLevel = other.mMaxLevel;
782 mChildIterList.updateBackPointers();
783 mValueIterList.updateBackPointers();
789 template<
typename TreeT,
typename ValueIterT>
793 mMaxLevel = int(ROOT_LEVEL - minDepth);
794 if (
int(mLevel) > mMaxLevel) this->next();
798 template<
typename TreeT,
typename ValueIterT>
803 mMinLevel = int(ROOT_LEVEL -
std::min(maxDepth, this->getLeafDepth()));
804 if (
int(mLevel) < mMinLevel) this->next();
808 template<
typename TreeT,
typename ValueIterT>
813 if (!this->advance())
return false;
814 }
while (
int(mLevel) < mMinLevel ||
int(mLevel) > mMaxLevel);
819 template<
typename TreeT,
typename ValueIterT>
823 bool recurse =
false;
827 vPos = mValueIterList.pos(mLevel),
828 cPos = mChildIterList.pos(mLevel);
829 if (vPos == cPos && mChildIterList.test(mLevel)) {
831 mValueIterList.
next(mLevel);
832 vPos = mValueIterList.pos(mLevel);
835 if (dontIncrement)
return true;
836 if (mValueIterList.next(mLevel)) {
837 if (mValueIterList.pos(mLevel) == cPos && mChildIterList.test(mLevel)) {
840 mValueIterList.next(mLevel);
843 if (mValueIterList.pos(mLevel) < cPos)
return true;
847 if (!dontIncrement) mChildIterList.next(mLevel);
849 #ifdef DEBUG_TREE_VALUE_ITERATOR 850 std::cout <<
"\n" << this->summary() << std::flush;
854 while (mChildIterList.pos(mLevel) < mValueIterList.pos(mLevel)) {
855 #ifdef ENABLE_TREE_VALUE_DEPTH_BOUND_OPTIMIZATION 856 if (
int(mLevel) == mMinLevel) {
859 mChildIterList.next(mLevel);
860 if (mValueIterList.pos(mLevel) == mChildIterList.pos(mLevel)
861 && mChildIterList.test(mLevel))
865 mValueIterList.next(mLevel);
869 if (mChildIterList.down(mLevel)) {
871 mValueIterList.initLevel(mLevel, mChildIterList);
872 if (mValueIterList.pos(mLevel) == mChildIterList.pos(mLevel)
873 && mChildIterList.test(mLevel))
877 mValueIterList.next(mLevel);
880 #ifdef DEBUG_TREE_VALUE_ITERATOR 881 std::cout <<
"\n" << this->summary() << std::flush;
885 while (!mChildIterList.test(mLevel) && !mValueIterList.test(mLevel)) {
886 if (mLevel == ROOT_LEVEL)
return false;
888 mChildIterList.next(mLevel);
889 dontIncrement =
true;
897 template<
typename TreeT,
typename ValueIterT>
905 bbox.
min() = mValueIterList.getCoord(mLevel);
906 bbox.
max() = bbox.
min().
offsetBy(mValueIterList.getChildDim(mLevel) - 1);
911 template<
typename TreeT,
typename ValueIterT>
915 std::ostringstream ostr;
916 for (
int lvl =
int(ROOT_LEVEL); lvl >= 0 && lvl >= int(mLevel); --lvl) {
917 if (lvl == 0) ostr <<
"leaf";
918 else if (lvl ==
int(ROOT_LEVEL)) ostr <<
"root";
919 else ostr <<
"int" << (ROOT_LEVEL - lvl);
920 ostr <<
" v" << mValueIterList.pos(lvl)
921 <<
" c" << mChildIterList.pos(lvl);
922 if (lvl >
int(mLevel)) ostr <<
" / ";
924 if (this->test() && mValueIterList.pos(mLevel) < mChildIterList.pos(mLevel)) {
926 ostr <<
" " << this->getCoord();
928 ostr <<
" " << this->getBoundingBox();
939 template<
typename _TreeT,
typename RootChildOnIterT>
969 bool test()
const {
return !mDone; }
971 operator bool()
const {
return this->
test(); }
1003 template<
typename NodeT>
1007 void getNode(NodeT*& node)
const { node =
nullptr; mIterList.
getNode(mLevel, node); }
1008 template<
typename NodeT>
1009 void getNode(
const NodeT*& node)
const { node =
nullptr; mIterList.
getNode(mLevel, node); }
1017 struct PrevItem {
using IterT =
RootIterT; };
1021 int mMinLevel, mMaxLevel;
1027 template<
typename TreeT,
typename RootChildOnIterT>
1032 mMinLevel(int(LEAF_LEVEL)),
1033 mMaxLevel(int(ROOT_LEVEL)),
1040 template<
typename TreeT,
typename RootChildOnIterT>
1045 mMinLevel(int(LEAF_LEVEL)),
1046 mMaxLevel(int(ROOT_LEVEL)),
1050 mIterList.
setIter(RootIterTraits::begin(tree.root()));
1054 template<
typename TreeT,
typename RootChildOnIterT>
1057 mIterList(other.mIterList),
1058 mLevel(other.mLevel),
1059 mMinLevel(other.mMinLevel),
1060 mMaxLevel(other.mMaxLevel),
1068 template<
typename TreeT,
typename RootChildOnIterT>
1072 if (&other !=
this) {
1073 mLevel = other.mLevel;
1074 mMinLevel = other.mMinLevel;
1075 mMaxLevel = other.mMaxLevel;
1076 mDone = other.mDone;
1077 mTree = other.mTree;
1078 mIterList = other.mIterList;
1085 template<
typename TreeT,
typename RootChildOnIterT>
1089 mMaxLevel = int(ROOT_LEVEL - minDepth);
1090 if (
int(mLevel) > mMaxLevel) this->next();
1094 template<
typename TreeT,
typename RootChildOnIterT>
1099 mMinLevel = int(ROOT_LEVEL -
std::min(maxDepth, this->getLeafDepth()));
1100 if (
int(mLevel) < mMinLevel) this->next();
1104 template<
typename TreeT,
typename RootChildOnIterT>
1109 if (mDone)
return false;
1113 if (
int(mLevel) > mMinLevel && mIterList.test(mLevel)) {
1114 if (!mIterList.down(mLevel))
return false;
1118 while (!mIterList.test(mLevel)) {
1119 if (mLevel == ROOT_LEVEL) {
1125 mIterList.next(mLevel);
1128 if (!mIterList.down(mLevel))
return false;
1131 }
while (
int(mLevel) < mMinLevel || int(mLevel) > mMaxLevel);
1136 template<
typename TreeT,
typename RootChildOnIterT>
1140 if (mLevel != ROOT_LEVEL)
return mIterList.getCoord(mLevel + 1);
1142 this->getNode(root);
1143 return root ? root->getMinIndex() :
Coord::min();
1147 template<
typename TreeT,
typename RootChildOnIterT>
1151 if (mLevel == ROOT_LEVEL) {
1153 this->getNode(root);
1154 if (root ==
nullptr) {
1158 root->getIndexRange(bbox);
1161 bbox.
min() = mIterList.getCoord(mLevel + 1);
1162 bbox.
max() = bbox.
min().
offsetBy(mIterList.getChildDim(mLevel + 1) - 1);
1167 template<
typename TreeT,
typename RootChildOnIterT>
1171 std::ostringstream ostr;
1172 for (
int lvl =
int(ROOT_LEVEL); lvl >= 0 && lvl >= int(mLevel); --lvl) {
1173 if (lvl == 0) ostr <<
"leaf";
1174 else if (lvl ==
int(ROOT_LEVEL)) ostr <<
"root";
1175 else ostr <<
"int" << (ROOT_LEVEL - lvl);
1176 ostr <<
" c" << mIterList.pos(lvl);
1177 if (lvl >
int(mLevel)) ostr <<
" / ";
1180 this->getBoundingBox(bbox);
1181 ostr <<
" " << bbox;
1190 template<
typename TreeT,
typename RootChildOnIterT>
1210 mIterList.
setIter(RootIterTraits::begin(tree.root()));
1213 for ( ; lvl > 0 && mIterList.
down(lvl); --lvl) {}
1215 if (lvl > 0) this->
next();
1224 if (&other !=
this) {
1225 mTree = other.mTree;
1226 mIterList = other.mIterList;
1245 operator bool()
const {
return this->
test(); }
1259 struct PrevItem {
using IterT =
RootIterT; };
1269 template<
typename TreeT,
typename RootChildOnIterT>
1275 if (mIterList.test(LEAF_PARENT_LEVEL) && mIterList.next(LEAF_PARENT_LEVEL)) {
1276 mIterList.down(LEAF_PARENT_LEVEL);
1280 Index lvl = LEAF_PARENT_LEVEL;
1281 while (!mIterList.test(LEAF_PARENT_LEVEL)) {
1282 if (mIterList.test(lvl)) {
1283 mIterList.next(lvl);
1288 if (lvl == ROOT_LEVEL)
return false;
1290 if (mIterList.test(lvl)) mIterList.next(lvl);
1291 }
while (!mIterList.test(lvl));
1294 while (lvl > LEAF_PARENT_LEVEL && mIterList.down(lvl)) --lvl;
1296 mIterList.down(LEAF_PARENT_LEVEL);
1306 template<
typename IterT>
1312 mGrainSize(grainSize),
1315 mSize = this->size();
1319 mGrainSize(other.mGrainSize),
1320 mSize(other.mSize >> 1)
1330 bool empty()
const {
return mSize == 0 || !mIter.test(); }
1332 operator bool()
const {
return !this->
empty(); }
1339 void increment(
Index n = 1) {
for ( ; n > 0 && mSize > 0; --n, --mSize, ++mIter) {} }
1347 Index size()
const {
Index n = 0;
for (IterT it(mIter); it.test(); ++n, ++it) {}
return n; }
1369 #endif // OPENVDB_TREE_TREEITERATOR_HAS_BEEN_INCLUDED static ChildT * getChild(const IterT &iter)
Definition: TreeIterator.h:120
typename OtherNodeT::ChildOffCIter Type
Definition: TreeIterator.h:111
IterListItem(PrevItemT *prev)
Definition: TreeIterator.h:534
LeafIteratorBase(TreeT &tree)
Definition: TreeIterator.h:1207
static IterT begin(NodeT &node)
Definition: TreeIterator.h:73
std::string summary() const
Definition: TreeIterator.h:1169
An IterListItem is an element of a compile-time linked list of iterators to nodes of different types.
Definition: TreeIterator.h:218
static IterT begin(const NodeT &node)
Definition: TreeIterator.h:197
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:672
CoordBBox getBoundingBox() const
Return the axis-aligned bounding box of the voxel or tile to which this iterator is currently pointin...
Definition: TreeIterator.h:683
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:278
bool isTileValue() const
Return true if this iterator is currently pointing to a (non-leaf) tile value.
Definition: TreeIterator.h:689
typename OtherNodeT::ChildOnIter Type
Definition: TreeIterator.h:78
static const Index ROOT_DEPTH
Definition: TreeIterator.h:949
void modifyValue(Index lvl, const ModifyOp &op) const
Apply a functor to the item to which this iterator is pointing.
Definition: TreeIterator.h:366
typename IterT::NonConstValueType NCValueT
The type of value (with const qualifiers removed) to which the iterator points.
Definition: TreeIterator.h:525
const ValueT & operator*() const
Return the tile or voxel value to which this iterator is currently pointing.
Definition: TreeIterator.h:698
void setIter(const IterT &iter)
Definition: TreeIterator.h:259
typename NodeT::ValueAllCIter IterT
Definition: TreeIterator.h:196
typename NodeT::ChildAllIter IterT
Definition: TreeIterator.h:118
typename OtherNodeT::ChildAllIter Type
Definition: TreeIterator.h:125
void increment(Index n=1)
Advance the iterator n times.
Definition: TreeIterator.h:1339
CoordBBox getBoundingBox() const
Return the axis-aligned bounding box of the voxel or tile to which this iterator is currently pointin...
Definition: TreeIterator.h:1000
Base class for tree-traversal iterators over tile and voxel values.
Definition: TreeIterator.h:621
bool test() const
Return true if this iterator is not yet exhausted.
Definition: TreeIterator.h:970
typename CopyConstness< NodeT, typename NodeT::ChildNodeType >::Type ChildT
NodeT's child node type, with the same constness (e.g., const InternalNode<...>)
Definition: TreeIterator.h:236
TreeValueIteratorBase & operator=(const TreeValueIteratorBase &other)
Definition: TreeIterator.h:773
typename NodeT::ChildOnCIter ChildOnIterT
Definition: TreeIterator.h:628
static IterT begin(const NodeT &node)
Definition: TreeIterator.h:86
Index getMinDepth() const
Return the depth of the highest level of the tree to which this iterator ascends.
Definition: TreeIterator.h:641
typename ValueIterT::NodeType NodeT
Definition: TreeIterator.h:626
void getNode(Index lvl, OtherNodeT *&node) const
Return the node over which one of the following list elements' iterator iterates.
Definition: TreeIterator.h:270
_ValueIterT ValueIterT
Definition: TreeIterator.h:625
typename NodeT::ValueAllIter IterT
Definition: TreeIterator.h:186
bool isValueOn(Index lvl) const
Definition: TreeIterator.h:589
void setValueOff() const
Mark the tile or voxel value to which this iterator is currently pointing as inactive.
Definition: TreeIterator.h:709
void increment(Index n)
Increment the iterator n times.
Definition: TreeIterator.h:981
void setValueOff(Index lvl) const
Mark the value to which the iterator at level lvl of the tree points as inactive.
Definition: TreeIterator.h:358
void getNode(NodeT *&node) const
Return the node to which the iterator is pointing.
Definition: TreeIterator.h:1007
typename NodeT::ChildOffIter IterT
Definition: TreeIterator.h:98
TreeValueIteratorBase & operator++()
Advance to the next tile or voxel value.
Definition: TreeIterator.h:657
Index64 getVoxelCount(Index lvl) const
Definition: TreeIterator.h:587
LeafNodeT & operator*() const
Return the leaf node to which the iterator is pointing.
Definition: TreeIterator.h:1240
static IterT begin(const NodeT &node)
Definition: TreeIterator.h:157
typename RootIterT::NonConstNodeType NCRootNodeT
Definition: TreeIterator.h:1196
bool isVoxelValue() const
Return true if this iterator is currently pointing to a (leaf) voxel value.
Definition: TreeIterator.h:691
Index getDepth() const
Return the depth in the tree (0 = root) of the node to which this iterator is currently pointing.
Definition: TreeIterator.h:988
Index getChildDim(Index lvl) const
Definition: TreeIterator.h:458
typename ValueIterT::NonConstValueType ValueT
Definition: TreeIterator.h:627
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:314
IterListItem(const IterListItem &other)
Definition: TreeIterator.h:406
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:717
typename OtherNodeT::ValueOffIter Type
Definition: TreeIterator.h:169
bool empty() const
Definition: TreeIterator.h:1330
Index getDepth() const
Return the depth in the tree (0 = root) of the node to which this iterator is currently pointing.
Definition: TreeIterator.h:664
typename CopyConstness< RootNodeT, NCLeafNodeT >::Type LeafNodeT
Definition: TreeIterator.h:1200
static IterT begin(const NodeT &node)
Definition: TreeIterator.h:177
LeafNodeT * getLeaf() const
Return the leaf node to which the iterator is pointing.
Definition: TreeIterator.h:1234
typename boost::mpl::front< InvTreeT >::type _NodeT
The type of node (non-const) whose iterator is stored in this list item.
Definition: TreeIterator.h:224
typename boost::mpl::vector< typename HeadT::ChildNodeType, HeadT >::type Type
Definition: TreeIterator.h:43
void updateBackPointers(PrevItemT *prev)
Definition: TreeIterator.h:546
bool test(Index lvl) const
Definition: TreeIterator.h:448
bool test() const
Definition: TreeIterator.h:1331
NodeIteratorBase()
Definition: TreeIterator.h:1029
_TreeT TreeT
Definition: TreeIterator.h:624
static ChildT * getChild(const IterT &iter)
Definition: TreeIterator.h:134
IteratorRange & operator++()
Advance the iterator to the next item.
Definition: TreeIterator.h:1341
bool next()
Advance to the next tile or voxel value. Return true if this iterator is not yet exhausted.
Definition: TreeIterator.h:810
void setValue(Index lvl, const NCValueT &val) const
Definition: TreeIterator.h:598
typename NodeT::ValueOnCIter IterT
Definition: TreeIterator.h:156
Index getLevel() const
Return the level in the tree (0 = leaf) of the node to which this iterator is currently pointing.
Definition: TreeIterator.h:985
typename IterT::NonConstNodeType NCNodeT
The type of the node with const qualifiers removed ("Non-Const")
Definition: TreeIterator.h:523
static IterT begin(NodeT &node)
Definition: TreeIterator.h:99
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:294
Signed (x, y, z) 32-bit integer coordinates.
Definition: Coord.h:25
Index pos(Index lvl) const
Return The table offset of the iterator at level lvl of the tree.
Definition: TreeIterator.h:291
Index pos(Index lvl) const
Definition: TreeIterator.h:568
IterListItem(const IterListItem &other)
Definition: TreeIterator.h:245
Index getMinDepth() const
Return the depth of the highest level of the tree to which this iterator ascends.
Definition: TreeIterator.h:962
IteratorRange(const IterT &iter, size_t grainSize=8)
Definition: TreeIterator.h:1310
static const Index LEAF_DEPTH
Definition: TreeIterator.h:949
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:1336
typename OtherNodeT::ChildOnCIter Type
Definition: TreeIterator.h:91
IterListItem & operator=(const IterListItem &other)
Definition: TreeIterator.h:408
IteratorRange(IteratorRange &other, tbb::split)
Definition: TreeIterator.h:1317
typename NodeT::ChildOffCIter IterT
Definition: TreeIterator.h:108
void setMinDepth(Index minDepth)
Specify the depth of the highest level of the tree to which to ascend (depth 0 = root).
Definition: TreeIterator.h:791
Coord offsetBy(Int32 dx, Int32 dy, Int32 dz) const
Definition: Coord.h:92
bool next()
Advance the iterator to the next item.
Definition: TreeIterator.h:1344
static const Index LEAF_LEVEL
Definition: TreeIterator.h:949
const NCValueT & getValue(Index lvl) const
Definition: TreeIterator.h:473
bool isValueOn() const
Return true if the value to which this iterator is currently pointing is active.
Definition: TreeIterator.h:693
bool down(Index lvl)
Definition: TreeIterator.h:574
void setValueOn(Index lvl, bool on=true) const
Definition: TreeIterator.h:599
bool isValueOn(Index lvl) const
Return true if the iterator at level lvl of the tree points to an active value.
Definition: TreeIterator.h:329
TreeT * getTree() const
Definition: TreeIterator.h:1256
bool next()
Advance the iterator to the next leaf node.
Definition: TreeIterator.h:1271
typename RootIterT::NodeType RootNodeT
Definition: TreeIterator.h:945
void modifyValue(Index lvl, const ModifyOp &op) const
Definition: TreeIterator.h:603
const NCValueT & getValue(Index lvl) const
Definition: TreeIterator.h:591
typename PrevItemT::IterT PrevIterT
The type of iterator stored in the previous list item.
Definition: TreeIterator.h:515
typename iter::InvertedTree< NCRootNodeT, ROOT_LEVEL >::Type InvTreeT
Definition: TreeIterator.h:948
void modifyValue(Index lvl, const ModifyOp &op) const
Definition: TreeIterator.h:493
typename boost::mpl::push_back< SubtreeT, HeadT >::type Type
Definition: TreeIterator.h:39
IterListItem & operator=(const IterListItem &other)
Definition: TreeIterator.h:247
const NCValueT & getValue(Index lvl) const
Return the value to which the iterator at level lvl of the tree points.
Definition: TreeIterator.h:335
static IterT begin(NodeT &node)
Definition: TreeIterator.h:187
typename IterT::NonConstNodeType NCNodeT
The type of the node with const qualifiers removed ("Non-Const")
Definition: TreeIterator.h:232
typename boost::mpl::front< InvTreeT >::type NCLeafNodeT
Definition: TreeIterator.h:1199
std::string summary() const
Return a string (for debugging, mainly) describing this iterator's current state.
Definition: TreeIterator.h:913
typename CopyConstness< NCNodeT, typename NCNodeT::ChildNodeType >::Type NCChildT
NodeT's child node type with const qualifiers removed.
Definition: TreeIterator.h:238
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:707
static IterT begin(const NodeT &node)
Definition: TreeIterator.h:109
typename std::remove_const< ToType >::type Type
Definition: Types.h:298
typename NodeT::ValueOffCIter IterT
Definition: TreeIterator.h:176
Index64 getVoxelCount(Index lvl) const
Return the number of (virtual) voxels spanned by a tile value or child node.
Definition: TreeIterator.h:323
const Coord & max() const
Definition: Coord.h:322
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition: version.h:102
static IterT begin(NodeT &node)
Definition: TreeIterator.h:119
typename IterT::NonConstNodeType NCNodeT
The type of the node with const qualifiers removed ("Non-Const")
Definition: TreeIterator.h:397
typename CopyConstness< NodeT, typename NodeT::ChildNodeType >::Type ChildT
NodeT's child node type, with the same constness (e.g., const InternalNode<...>)
Definition: TreeIterator.h:527
LeafIteratorBase(const LeafIteratorBase &other)
Definition: TreeIterator.h:1218
bool next(Index lvl)
Increment the iterator at level lvl of the tree.
Definition: TreeIterator.h:297
typename IterT::NodeType NodeT
The type of node (const or non-const) over which IterT iterates (e.g., const RootNode<....
Definition: TreeIterator.h:230
const Coord & min() const
Definition: Coord.h:321
void setIter(const IterT &iter)
Definition: TreeIterator.h:551
typename boost::mpl::front< NodeVecT >::type _NodeT
Definition: TreeIterator.h:513
static ChildT * getChild(const IterT &iter)
Definition: TreeIterator.h:74
typename OtherNodeT::ChildOffIter Type
Definition: TreeIterator.h:101
void updateBackPointers(PrevItemT *prev)
Definition: TreeIterator.h:257
static const Index ROOT_LEVEL
Definition: TreeIterator.h:947
bool test(Index lvl) const
Definition: TreeIterator.h:570
static Coord min()
Return the smallest possible coordinate.
Definition: Coord.h:44
bool next(Index lvl)
Definition: TreeIterator.h:450
bool next(Index lvl)
Definition: TreeIterator.h:572
typename RootIterT::NodeType RootNodeT
Definition: TreeIterator.h:1195
void getNode(Index lvl, NodeT *&node) const
Definition: TreeIterator.h:427
typename NodeT::ChildOnCIter IterT
Definition: TreeIterator.h:85
typename InvertedTree< typename HeadT::ChildNodeType, HeadLevel-1 >::Type SubtreeT
Definition: TreeIterator.h:38
typename CopyConstness< NCNodeT, typename NCNodeT::ChildNodeType >::Type NCChildT
NodeT's child node type with const qualifiers removed.
Definition: TreeIterator.h:529
typename IterT::NodeType NodeT
The type of node (const or non-const) over which IterT iterates (e.g., const RootNode<....
Definition: TreeIterator.h:395
Index getLevel() const
Return the level in the tree (0 = leaf) of the node to which this iterator is currently pointing.
Definition: TreeIterator.h:661
static Index getLeafDepth()
Definition: TreeIterator.h:665
Definition: Exceptions.h:13
void setValueOff(Index lvl) const
Definition: TreeIterator.h:487
Level
Message severity level.
Definition: logging.h:31
Definition: TreeIterator.h:37
Definition: TreeIterator.h:64
static IterT begin(NodeT &node)
Definition: TreeIterator.h:147
typename OtherNodeT::ValueOnIter Type
Definition: TreeIterator.h:149
Coord getCoord() const
Return the global coordinates of the voxel or tile to which this iterator is currently pointing.
Definition: TreeIterator.h:1138
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:704
static IterT begin(NodeT &node)
Definition: TreeIterator.h:167
Index64 getVoxelCount(Index lvl) const
Definition: TreeIterator.h:463
const ValueT * operator->() const
Return the tile or voxel value to which this iterator is currently pointing.
Definition: TreeIterator.h:699
Index64 getVoxelCount() const
Return the number of (virtual) voxels corresponding to the value.
Definition: TreeIterator.h:686
NodeIteratorBase & operator++()
Definition: TreeIterator.h:979
NodeIteratorBase & operator=(const NodeIteratorBase &other)
Definition: TreeIterator.h:1070
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:301
static const Index LEAF_LEVEL
Definition: TreeIterator.h:1201
Library and file format version numbers.
void getNode(const NodeT *&node) const
Return the node to which the iterator is pointing.
Definition: TreeIterator.h:1009
Base class for tree-traversal iterators over all leaf nodes (but not leaf voxels)
Definition: TreeIterator.h:1191
bool next()
Advance to the next tile or voxel value.
Definition: TreeIterator.h:1106
Index getMaxDepth() const
Return the depth of the lowest level of the tree to which this iterator ascends.
Definition: TreeIterator.h:966
void setValueOff(Index lvl) const
Definition: TreeIterator.h:600
void setMaxDepth(Index maxDepth)
Specify the depth of the lowest level of the tree to which to descend (depth 0 = root).
Definition: TreeIterator.h:800
Definition: TreeIterator.h:1307
static Index getLeafDepth()
Definition: TreeIterator.h:989
typename NodeT::ChildAllCIter IterT
Definition: TreeIterator.h:132
Index pos(Index lvl) const
Definition: TreeIterator.h:446
typename boost::mpl::front< NodeVecT >::type _NodeT
The type of node (non-const) whose iterator is stored in this list item.
Definition: TreeIterator.h:389
typename PrevItem ::IterT PrevIterT
The type of iterator stored in the previous list item.
Definition: TreeIterator.h:222
IterListItem(PrevItemT *)
Definition: TreeIterator.h:404
void setValue(Index lvl, const NCValueT &val) const
Definition: TreeIterator.h:479
void initLevel(Index lvl, OtherIterListItemT &otherListItem)
Definition: TreeIterator.h:435
void setMinDepth(Index minDepth)
Specify the depth of the highest level of the tree to which to ascend (depth 0 = root).
Definition: TreeIterator.h:1087
static const ChildT * getChild(const IterT &iter)
Definition: TreeIterator.h:87
Index32 Index
Definition: Types.h:31
RootChildOnIterT RootIterT
Definition: TreeIterator.h:944
TreeT * getTree() const
Definition: TreeIterator.h:1012
void setIter(const OtherIterT &iter)
Definition: TreeIterator.h:425
static IterT begin(const NodeT &node)
Definition: TreeIterator.h:133
const IterT & iterator() const
Return a reference to this range's iterator.
Definition: TreeIterator.h:1328
typename IterT::NodeType NodeT
The type of node over which IterT iterates (e.g., const RootNode<...>)
Definition: TreeIterator.h:521
TreeT * getTree() const
Return a pointer to the tree over which this iterator is iterating.
Definition: TreeIterator.h:720
bool down(Index lvl)
Definition: TreeIterator.h:452
IterListItem(const IterListItem &other)
Definition: TreeIterator.h:536
typename PrevItemT::IterT PrevIterT
The type of iterator stored in the previous list item.
Definition: TreeIterator.h:387
void initLevel(Index lvl, OtherIterListItemT &otherListItem)
Definition: TreeIterator.h:559
TreeValueIteratorBase(TreeT &)
Definition: TreeIterator.h:742
Axis-aligned bounding box of signed integer coordinates.
Definition: Coord.h:248
void getNode(Index lvl, NodeT *&node) const
Definition: TreeIterator.h:553
IterListItem(PrevItemT *prev)
Definition: TreeIterator.h:243
void setIter(const OtherIterT &iter)
Definition: TreeIterator.h:261
typename NodeT::ValueOnIter IterT
Definition: TreeIterator.h:146
_TreeT TreeT
Definition: TreeIterator.h:943
Coord getCoord(Index lvl) const
Definition: TreeIterator.h:454
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:618
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:518
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:344
typename NodeT::ValueOffIter IterT
Definition: TreeIterator.h:166
typename OtherNodeT::ChildAllCIter Type
Definition: TreeIterator.h:139
typename OtherNodeT::ValueAllCIter Type
Definition: TreeIterator.h:199
void setValueOn(Index lvl, bool on=true) const
Definition: TreeIterator.h:483
static ChildT * getChild(const IterT &)
Definition: TreeIterator.h:66
LeafIteratorBase()
Definition: TreeIterator.h:1205
LeafNodeT * operator->() const
Return the leaf node to which the iterator is pointing.
Definition: TreeIterator.h:1241
uint64_t Index64
Definition: Types.h:30
LeafIteratorBase & operator=(const LeafIteratorBase &other)
Definition: TreeIterator.h:1222
typename iter::InvertedTree< NCRootNodeT, ROOT_LEVEL >::Type InvTreeT
Definition: TreeIterator.h:1198
void updateBackPointers(PrevItemT *=nullptr)
Definition: TreeIterator.h:418
static const Index LEAF_PARENT_LEVEL
Definition: TreeIterator.h:1201
typename OtherNodeT::ValueOffCIter Type
Definition: TreeIterator.h:179
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h:154
typename OtherNodeT::ValueOnCIter Type
Definition: TreeIterator.h:159
typename NodeT::ChildOnIter IterT
Definition: TreeIterator.h:72
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:351
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:227
Base class for tree-traversal iterators over all nodes.
Definition: TreeIterator.h:940
void setMaxDepth(Index maxDepth)
Specify the depth of the lowest level of the tree to which to descend (depth 0 = root).
Definition: TreeIterator.h:1096
bool isValueOn(Index lvl) const
Definition: TreeIterator.h:468
Index getMaxDepth() const
Return the depth of the lowest level of the tree to which this iterator ascends.
Definition: TreeIterator.h:645
Coord getCoord() const
Return the global coordinates of the voxel or tile to which this iterator is currently pointing.
Definition: TreeIterator.h:676
bool test() const
Definition: TreeIterator.h:1244
LeafIteratorBase & operator++()
Advance the iterator to the next leaf node.
Definition: TreeIterator.h:1251
typename IterT::NonConstValueType NCValueT
The type of value (with const qualifiers removed) to which the iterator points.
Definition: TreeIterator.h:234
Index getChildDim(Index lvl) const
Definition: TreeIterator.h:318
void getNode(Index lvl, NodeT *&node) const
Return the node over which this list element's iterator iterates.
Definition: TreeIterator.h:264
void increment()
Advance the iterator to the next leaf node.
Definition: TreeIterator.h:978
void setIter(const IterT &iter)
Definition: TreeIterator.h:423
Coord getCoord(Index lvl) const
Definition: TreeIterator.h:585
Index getChildDim(Index lvl) const
Definition: TreeIterator.h:586
static const Index ROOT_LEVEL
Definition: TreeIterator.h:1197
IterListItem & operator=(const IterListItem &other)
Definition: TreeIterator.h:537
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:392
typename IterT::NonConstValueType NCValueT
The type of value (with const qualifiers removed) to which the iterator points.
Definition: TreeIterator.h:399
void getNode(Index lvl, OtherNodeT *&node) const
Definition: TreeIterator.h:432
typename OtherNodeT::ValueAllIter Type
Definition: TreeIterator.h:189
RootChildOnIterT RootIterT
Definition: TreeIterator.h:1194
typename RootIterT::NonConstNodeType NCRootNodeT
Definition: TreeIterator.h:946
void increment()
Advance the iterator to the next leaf node.
Definition: TreeIterator.h:1250