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> 43 #include <openvdb/version.h> 44 #include <openvdb/Types.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);
335 Index pos(
Index lvl)
const {
return (lvl == Level) ? mIter.pos() : mNext.pos(lvl); }
338 bool test(
Index lvl)
const {
return (lvl == Level) ? mIter.test() : mNext.test(lvl); }
341 bool next(
Index lvl) {
return (lvl == Level) ? mIter.next() : mNext.next(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));
614 bool test(
Index lvl)
const {
return (lvl == Level) ? mIter.test() :
false; }
616 bool next(
Index lvl) {
return (lvl == Level) ? mIter.next() :
false; }
620 if (lvl == Level && mPrev !=
nullptr && mIter) {
621 if (
ChildT* child = ITraits::template getChild<ChildT>(mIter)) {
622 mPrev->setIter(PrevItemT::ITraits::begin(*child));
633 bool isValueOn(
Index lvl)
const {
return (lvl == Level) ? mIter.isValueOn() :
false; }
637 assert(lvl == Level);
639 return mIter.getValue();
643 void setValueOn(
Index lvl,
bool on =
true)
const {
if (lvl == Level) mIter.setValueOn(on); }
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);
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;
833 template<
typename TreeT,
typename ValueIterT>
838 if (
int(mLevel) > mMaxLevel) this->
next();
842 template<
typename TreeT,
typename ValueIterT>
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)) {
932 mChildIterList.
next(mLevel);
933 dontIncrement =
true;
941 template<
typename TreeT,
typename ValueIterT>
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";
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)) {
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>
1084 template<
typename TreeT,
typename RootChildOnIterT>
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>
1134 if (
int(mLevel) > mMaxLevel) this->
next();
1138 template<
typename TreeT,
typename RootChildOnIterT>
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)) {
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>
1187 return root ? root->getMinIndex() :
Coord::min();
1191 template<
typename TreeT,
typename RootChildOnIterT>
1198 if (root ==
nullptr) {
1202 root->getIndexRange(bbox);
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";
1220 ostr <<
" c" << mIterList.
pos(lvl);
1221 if (lvl >
int(mLevel)) ostr <<
" / ";
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();
1264 mIterList.updateBackPointers();
1268 if (&other !=
this) {
1269 mTree = other.mTree;
1270 mIterList = other.mIterList;
1281 mIterList.getNode(LEAF_LEVEL, n);
1288 bool test()
const {
return mIterList.test(LEAF_PARENT_LEVEL); }
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);
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(); }
1375 bool test()
const {
return !this->empty(); }
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 bool next()
Advance the iterator to the next item.
Definition: TreeIterator.h:1388
Index getChildDim(Index lvl) const
Definition: TreeIterator.h:502
static IterT begin(const NodeT &node)
Definition: TreeIterator.h:153
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:163
Axis-aligned bounding box of signed integer coordinates.
Definition: Coord.h:264
typename InvertedTree< typename HeadT::ChildNodeType, HeadLevel-1 >::Type SubtreeT
Definition: TreeIterator.h:82
static Coord min()
Return the smallest possible coordinate.
Definition: Coord.h:70
IterListItem & operator=(const IterListItem &other)
Definition: TreeIterator.h:452
typename RootIterT::NonConstNodeType NCRootNodeT
Definition: TreeIterator.h:990
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
typename IterT::NonConstNodeType NCNodeT
The type of the node with const qualifiers removed ("Non-Const")
Definition: TreeIterator.h:441
Index pos(Index lvl) const
Definition: TreeIterator.h:612
void setValueOff(Index lvl) const
Definition: TreeIterator.h:531
IterListItem(PrevItemT *prev)
Definition: TreeIterator.h:287
typename CopyConstness< NCNodeT, typename NCNodeT::ChildNodeType >::Type NCChildT
NodeT's child node type with const qualifiers removed.
Definition: TreeIterator.h:573
typename PrevItemT::IterT PrevIterT
The type of iterator stored in the previous list item.
Definition: TreeIterator.h:431
void initLevel(Index lvl, OtherIterListItemT &otherListItem)
Definition: TreeIterator.h:603
RootChildOnIterT RootIterT
Definition: TreeIterator.h:988
bool test(Index lvl) const
Definition: TreeIterator.h:614
typename IterT::NonConstValueType NCValueT
The type of value (with const qualifiers removed) to which the iterator points.
Definition: TreeIterator.h:569
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
IterListItem & operator=(const IterListItem &other)
Definition: TreeIterator.h:291
const NCValueT & getValue(Index lvl) const
Return the value to which the iterator at level lvl of the tree points.
Definition: TreeIterator.h:379
typename NodeT::ValueOnIter IterT
Definition: TreeIterator.h:190
typename boost::mpl::front< InvTreeT >::type NCLeafNodeT
Definition: TreeIterator.h:1243
bool next(Index lvl)
Definition: TreeIterator.h:494
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
IterListItem(PrevItemT *)
Definition: TreeIterator.h:448
bool isValueOn() const
Return true if the value to which this iterator is currently pointing is active.
Definition: TreeIterator.h:737
typename CopyConstness< RootNodeT, NCLeafNodeT >::Type LeafNodeT
Definition: TreeIterator.h:1244
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 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
static IterT begin(const NodeT &node)
Definition: TreeIterator.h:201
void setValueOff(Index lvl) const
Definition: TreeIterator.h:644
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
_ValueIterT ValueIterT
Definition: TreeIterator.h:669
void setValue(Index lvl, const NCValueT &val) const
Definition: TreeIterator.h:642
Base class for tree-traversal iterators over all nodes.
Definition: TreeIterator.h:984
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 const Index ROOT_DEPTH
Definition: TreeIterator.h:675
static Index getLeafDepth()
Definition: TreeIterator.h:1033
static ChildT * getChild(const IterT &iter)
Definition: TreeIterator.h:178
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
const Coord & min() const
Definition: Coord.h:337
Signed (x, y, z) 32-bit integer coordinates.
Definition: Coord.h:51
typename OtherNodeT::ChildOffIter Type
Definition: TreeIterator.h:145
static const Index ROOT_LEVEL
Definition: TreeIterator.h:991
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
const ValueT & operator*() const
Return the tile or voxel value to which this iterator is currently pointing.
Definition: TreeIterator.h:742
static const Index ROOT_LEVEL
Definition: TreeIterator.h:673
bool isVoxelValue() const
Return true if this iterator is currently pointing to a (leaf) voxel value.
Definition: TreeIterator.h:735
void getNode(Index lvl, OtherNodeT *&node) const
Return the node over which one of the following list elements' iterator iterates. ...
Definition: TreeIterator.h:314
typename NodeT::ChildOnCIter ChildOnIterT
Definition: TreeIterator.h:672
Definition: TreeIterator.h:108
Index getMinDepth() const
Return the depth of the highest level of the tree to which this iterator ascends. ...
Definition: TreeIterator.h:1006
static ChildT * getChild(const IterT &iter)
Definition: TreeIterator.h:118
static IterT begin(NodeT &node)
Definition: TreeIterator.h:211
static const Index LEAF_DEPTH
Definition: TreeIterator.h:675
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
bool isTileValue() const
Return true if this iterator is currently pointing to a (non-leaf) tile value.
Definition: TreeIterator.h:733
TreeT * getTree() const
Definition: TreeIterator.h:1300
bool next()
Advance the iterator to the next leaf node.
Definition: TreeIterator.h:1315
static const Index LEAF_LEVEL
Definition: TreeIterator.h:993
Index64 getVoxelCount(Index lvl) const
Definition: TreeIterator.h:507
Level
Message severity level.
Definition: logging.h:58
void increment(Index n)
Increment the iterator n times.
Definition: TreeIterator.h:1025
typename RootIterT::NonConstNodeType NCRootNodeT
Definition: TreeIterator.h:1240
typename NodeT::ValueAllCIter IterT
Definition: TreeIterator.h:240
typename OtherNodeT::ValueOffIter Type
Definition: TreeIterator.h:213
bool test(Index lvl) const
Definition: TreeIterator.h:492
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 ChildT * getChild(const IterT &)
Definition: TreeIterator.h:110
LeafIteratorBase(TreeT &tree)
Definition: TreeIterator.h:1251
void initLevel(Index lvl, OtherIterListItemT &otherListItem)
Definition: TreeIterator.h:479
bool empty() const
Definition: TreeIterator.h:1374
Index getMaxDepth() const
Return the depth of the lowest level of the tree to which this iterator ascends.
Definition: TreeIterator.h:1010
static IterT begin(const NodeT &node)
Definition: TreeIterator.h:177
void setIter(const IterT &iter)
Definition: TreeIterator.h:467
static IterT begin(NodeT &node)
Definition: TreeIterator.h:143
IteratorRange & operator++()
Advance the iterator to the next item.
Definition: TreeIterator.h:1385
typename OtherNodeT::ValueAllIter Type
Definition: TreeIterator.h:233
typename OtherNodeT::ChildAllCIter Type
Definition: TreeIterator.h:183
typename IterT::NonConstNodeType NCNodeT
The type of the node with const qualifiers removed ("Non-Const")
Definition: TreeIterator.h:567
bool test() const
Return true if this iterator is not yet exhausted.
Definition: TreeIterator.h:1014
typename std::remove_const< ToType >::type Type
Definition: TreeIterator.h:68
typename OtherNodeT::ChildAllIter Type
Definition: TreeIterator.h:169
void getNode(Index lvl, NodeT *&node) const
Definition: TreeIterator.h:471
LeafIteratorBase(const LeafIteratorBase &other)
Definition: TreeIterator.h:1262
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
static Index getLeafDepth()
Definition: TreeIterator.h:709
bool next(Index lvl)
Definition: TreeIterator.h:616
bool test() const
Return true if this iterator is not yet exhausted.
Definition: TreeIterator.h:693
const NCValueT & getValue(Index lvl) const
Definition: TreeIterator.h:635
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
bool next()
Advance to the next tile or voxel value. Return true if this iterator is not yet exhausted.
Definition: TreeIterator.h:854
Coord getCoord(Index lvl) const
Definition: TreeIterator.h:498
IterListItem(const IterListItem &other)
Definition: TreeIterator.h:289
typename boost::mpl::front< NodeVecT >::type _NodeT
Definition: TreeIterator.h:557
void increment(Index n=1)
Advance the iterator n times.
Definition: TreeIterator.h:1383
bool down(Index lvl)
Definition: TreeIterator.h:618
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
Coord getCoord(Index lvl) const
Definition: TreeIterator.h:629
void setIter(const OtherIterT &iter)
Definition: TreeIterator.h:305
void updateBackPointers(PrevItemT *prev)
Definition: TreeIterator.h:301
Base class for tree-traversal iterators over tile and voxel values.
Definition: TreeIterator.h:665
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
IteratorRange(IteratorRange &other, tbb::split)
Definition: TreeIterator.h:1361
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
typename PrevItem ::IterT PrevIterT
The type of iterator stored in the previous list item.
Definition: TreeIterator.h:266
typename RootIterT::NodeType RootNodeT
Definition: TreeIterator.h:1239
typename iter::InvertedTree< NCRootNodeT, ROOT_LEVEL >::Type InvTreeT
Definition: TreeIterator.h:992
Index64 getVoxelCount(Index lvl) const
Return the number of (virtual) voxels spanned by a tile value or child node.
Definition: TreeIterator.h:367
typename NodeT::ChildOnCIter IterT
Definition: TreeIterator.h:129
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
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition: version.h:136
void getNode(Index lvl, NodeT *&node) const
Definition: TreeIterator.h:597
IterListItem(PrevItemT *prev)
Definition: TreeIterator.h:578
Index pos(Index lvl) const
Return The table offset of the iterator at level lvl of the tree.
Definition: TreeIterator.h:335
typename OtherNodeT::ChildOnCIter Type
Definition: TreeIterator.h:135
TreeT * getTree() const
Return a pointer to the tree over which this iterator is iterating.
Definition: TreeIterator.h:764
Definition: TreeIterator.h:81
typename IterT::NodeType NodeT
The type of node (const or non-const) over which IterT iterates (e.g., const RootNode<...>)
Definition: TreeIterator.h:274
Index getMinDepth() const
Return the depth of the highest level of the tree to which this iterator ascends. ...
Definition: TreeIterator.h:685
LeafNodeT & operator*() const
Return the leaf node to which the iterator is pointing.
Definition: TreeIterator.h:1284
void getNode(Index lvl, NodeT *&node) const
Return the node over which this list element's iterator iterates.
Definition: TreeIterator.h:308
IterListItem & operator=(const IterListItem &other)
Definition: TreeIterator.h:581
void setIter(const IterT &iter)
Definition: TreeIterator.h:595
NodeIteratorBase & operator++()
Definition: TreeIterator.h:1023
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
void updateBackPointers(PrevItemT *prev)
Definition: TreeIterator.h:590
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
TreeValueIteratorBase(TreeT &)
Definition: TreeIterator.h:786
typename NodeT::ValueOnCIter IterT
Definition: TreeIterator.h:200
Index64 getVoxelCount(Index lvl) const
Definition: TreeIterator.h:631
static IterT begin(const NodeT &node)
Definition: TreeIterator.h:241
const ToType Type
Definition: TreeIterator.h:71
void setValue(Index lvl, const NCValueT &val) const
Definition: TreeIterator.h:523
bool down(Index lvl)
Definition: TreeIterator.h:496
typename iter::InvertedTree< NCRootNodeT, ROOT_LEVEL >::Type InvTreeT
Definition: TreeIterator.h:1242
typename boost::mpl::vector< typename HeadT::ChildNodeType, HeadT >::type Type
Definition: TreeIterator.h:87
Index getChildDim(Index lvl) const
Definition: TreeIterator.h:630
typename IterT::NonConstValueType NCValueT
The type of value (with const qualifiers removed) to which the iterator points.
Definition: TreeIterator.h:278
Definition: Exceptions.h:40
static ChildT * getChild(const IterT &iter)
Definition: TreeIterator.h:164
bool test() const
Definition: TreeIterator.h:1375
Base class for tree-traversal iterators over all leaf nodes (but not leaf voxels) ...
Definition: TreeIterator.h:1235
Coord offsetBy(Int32 dx, Int32 dy, Int32 dz) const
Definition: Coord.h:118
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
static IterT begin(NodeT &node)
Definition: TreeIterator.h:231
bool test() const
Definition: TreeIterator.h:1288
void updateBackPointers(PrevItemT *=nullptr)
Definition: TreeIterator.h:462
bool next()
Advance to the next tile or voxel value.
Definition: TreeIterator.h:1150
typename NodeT::ChildOffCIter IterT
Definition: TreeIterator.h:152
NodeIteratorBase()
Definition: TreeIterator.h:1073
Index32 Index
Definition: Types.h:61
typename NodeT::ChildOnIter IterT
Definition: TreeIterator.h:116
typename ValueIterT::NonConstValueType ValueT
Definition: TreeIterator.h:671
typename OtherNodeT::ValueAllCIter Type
Definition: TreeIterator.h:243
_TreeT TreeT
Definition: TreeIterator.h:987
An IterListItem is an element of a compile-time linked list of iterators to nodes of different types...
Definition: TreeIterator.h:262
IterListItem(const IterListItem &other)
Definition: TreeIterator.h:450
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
typename RootIterT::NodeType RootNodeT
Definition: TreeIterator.h:989
uint64_t Index64
Definition: Types.h:60
Index64 getVoxelCount() const
Return the number of (virtual) voxels corresponding to the value.
Definition: TreeIterator.h:730
typename NodeT::ChildAllCIter IterT
Definition: TreeIterator.h:176
TreeT * getTree() const
Definition: TreeIterator.h:1056
void modifyValue(Index lvl, const ModifyOp &op) const
Apply a functor to the item to which this iterator is pointing.
Definition: TreeIterator.h:410
typename IterT::NonConstNodeType NCNodeT
The type of the node with const qualifiers removed ("Non-Const")
Definition: TreeIterator.h:276
RootChildOnIterT RootIterT
Definition: TreeIterator.h:1238
bool isValueOn(Index lvl) const
Definition: TreeIterator.h:512
void setIter(const IterT &iter)
Definition: TreeIterator.h:303
Coord getCoord() const
Return the global coordinates of the voxel or tile to which this iterator is currently pointing...
Definition: TreeIterator.h:720
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
typename OtherNodeT::ValueOnCIter Type
Definition: TreeIterator.h:203
Definition: TreeIterator.h:1351
static IterT begin(const NodeT &node)
Definition: TreeIterator.h:130
static IterT begin(const NodeT &node)
Definition: TreeIterator.h:221
static IterT begin(NodeT &node)
Definition: TreeIterator.h:191
const NCValueT & getValue(Index lvl) const
Definition: TreeIterator.h:517
Index getChildDim(Index lvl) const
Definition: TreeIterator.h:362
bool next(Index lvl)
Increment the iterator at level lvl of the tree.
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:835
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
void setIter(const OtherIterT &iter)
Definition: TreeIterator.h:469
void modifyValue(Index lvl, const ModifyOp &op) const
Definition: TreeIterator.h:537
void getNode(Index lvl, OtherNodeT *&node) const
Definition: TreeIterator.h:476
NodeIteratorBase & operator=(const NodeIteratorBase &other)
Definition: TreeIterator.h:1114
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
IteratorRange(const IterT &iter, size_t grainSize=8)
Definition: TreeIterator.h:1354
LeafIteratorBase & operator++()
Advance the iterator to the next leaf node.
Definition: TreeIterator.h:1295
const Coord & max() const
Definition: Coord.h:338
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
TreeValueIteratorBase & operator++()
Advance to the next tile or voxel value.
Definition: TreeIterator.h:701
typename IterT::NodeType NodeT
The type of node (const or non-const) over which IterT iterates (e.g., const RootNode<...>)
Definition: TreeIterator.h:439
TreeValueIteratorBase & operator=(const TreeValueIteratorBase &other)
Definition: TreeIterator.h:817
bool isValueOn(Index lvl) const
Definition: TreeIterator.h:633
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
_TreeT TreeT
Definition: TreeIterator.h:668
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h:188
typename boost::mpl::push_back< SubtreeT, HeadT >::type Type
Definition: TreeIterator.h:83
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:1022
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
static const ChildT * getChild(const IterT &iter)
Definition: TreeIterator.h:131
std::string summary() const
Definition: TreeIterator.h:1213
std::string summary() const
Return a string (for debugging, mainly) describing this iterator's current state. ...
Definition: TreeIterator.h:957
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
void increment()
Advance the iterator to the next leaf node.
Definition: TreeIterator.h:1294
void setValueOn(Index lvl, bool on=true) const
Definition: TreeIterator.h:643
typename OtherNodeT::ValueOffCIter Type
Definition: TreeIterator.h:223
Coord getCoord() const
Return the global coordinates of the voxel or tile to which this iterator is currently pointing...
Definition: TreeIterator.h:1182
LeafIteratorBase()
Definition: TreeIterator.h:1249
const ValueT * operator->() const
Return the tile or voxel value to which this iterator is currently pointing.
Definition: TreeIterator.h:743
LeafNodeT * operator->() const
Return the leaf node to which the iterator is pointing.
Definition: TreeIterator.h:1285
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
typename OtherNodeT::ChildOffCIter Type
Definition: TreeIterator.h:155
Index pos(Index lvl) const
Definition: TreeIterator.h:490
typename PrevItemT::IterT PrevIterT
The type of iterator stored in the previous list item.
Definition: TreeIterator.h:559
LeafIteratorBase & operator=(const LeafIteratorBase &other)
Definition: TreeIterator.h:1266
Definition: TreeIterator.h:67
Index getMaxDepth() const
Return the depth of the lowest level of the tree to which this iterator ascends.
Definition: TreeIterator.h:689
typename NodeT::ValueOffIter IterT
Definition: TreeIterator.h:210
typename NodeT::ValueOffCIter IterT
Definition: TreeIterator.h:220
typename OtherNodeT::ChildOnIter Type
Definition: TreeIterator.h:122
typename ValueIterT::NodeType NodeT
Definition: TreeIterator.h:670
typename IterT::NodeType NodeT
The type of node over which IterT iterates (e.g., const RootNode<...>)
Definition: TreeIterator.h:565
typename NodeT::ChildAllIter IterT
Definition: TreeIterator.h:162
void getNode(const NodeT *&node) const
Return the node to which the iterator is pointing.
Definition: TreeIterator.h:1053
void modifyValue(Index lvl, const ModifyOp &op) const
Definition: TreeIterator.h:647
IterListItem(const IterListItem &other)
Definition: TreeIterator.h:580
static IterT begin(NodeT &node)
Definition: TreeIterator.h:117
void setValueOn(Index lvl, bool on=true) const
Definition: TreeIterator.h:527
typename OtherNodeT::ValueOnIter Type
Definition: TreeIterator.h:193
typename CopyConstness< NCNodeT, typename NCNodeT::ChildNodeType >::Type NCChildT
NodeT's child node type with const qualifiers removed.
Definition: TreeIterator.h:282
static const Index LEAF_LEVEL
Definition: TreeIterator.h:675
void setValueOff() const
Mark the tile or voxel value to which this iterator is currently pointing as inactive.
Definition: TreeIterator.h:753
typename NodeT::ValueAllIter IterT
Definition: TreeIterator.h:230
typename NodeT::ChildOffIter IterT
Definition: TreeIterator.h:142
const IterT & iterator() const
Return a reference to this range's iterator.
Definition: TreeIterator.h:1372
typename IterT::NonConstValueType NCValueT
The type of value (with const qualifiers removed) to which the iterator points.
Definition: TreeIterator.h:443