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 <boost/static_assert.hpp> 42 #include <boost/type_traits/remove_const.hpp> 43 #include <tbb/blocked_range.h> 44 #include <tbb/parallel_for.h> 45 #include <openvdb/version.h> 46 #include <openvdb/Types.h> 51 #define ENABLE_TREE_VALUE_DEPTH_BOUND_OPTIMIZATION 66 typedef typename boost::remove_const<ToType>::type
Type;
68 template<
typename FromType,
typename ToType>
struct CopyConstness<const FromType, ToType> {
78 template<
typename HeadT,
int HeadLevel>
81 typedef typename boost::mpl::push_back<SubtreeT, HeadT>::type
Type;
83 template<
typename HeadT>
85 typedef typename boost::mpl::vector<typename HeadT::ChildNodeType, HeadT>::type
Type;
105 template<
typename NodeT,
typename IterT>
108 template<
typename ChildT>
static ChildT*
getChild(
const IterT&) {
return NULL; }
111 template<
typename NodeT>
114 typedef typename NodeT::ChildOnIter
IterT;
115 static IterT
begin(NodeT& node) {
return node.beginChildOn(); }
116 template<
typename ChildT>
static ChildT*
getChild(
const IterT& iter) {
117 return &iter.getValue();
119 template<
typename OtherNodeT>
struct NodeConverter {
120 typedef typename OtherNodeT::ChildOnIter
Type;
124 template<
typename NodeT>
127 typedef typename NodeT::ChildOnCIter
IterT;
128 static IterT
begin(
const NodeT& node) {
return node.cbeginChildOn(); }
129 template<
typename ChildT>
static const ChildT*
getChild(
const IterT& iter) {
130 return &iter.getValue();
132 template<
typename OtherNodeT>
struct NodeConverter {
133 typedef typename OtherNodeT::ChildOnCIter
Type;
137 template<
typename NodeT>
140 typedef typename NodeT::ChildOffIter
IterT;
141 static IterT
begin(NodeT& node) {
return node.beginChildOff(); }
142 template<
typename OtherNodeT>
struct NodeConverter {
143 typedef typename OtherNodeT::ChildOffIter
Type;
147 template<
typename NodeT>
150 typedef typename NodeT::ChildOffCIter
IterT;
151 static IterT
begin(
const NodeT& node) {
return node.cbeginChildOff(); }
152 template<
typename OtherNodeT>
struct NodeConverter {
153 typedef typename OtherNodeT::ChildOffCIter
Type;
157 template<
typename NodeT>
160 typedef typename NodeT::ChildAllIter
IterT;
161 static IterT
begin(NodeT& node) {
return node.beginChildAll(); }
162 template<
typename ChildT>
static ChildT*
getChild(
const IterT& iter) {
163 typename IterT::NonConstValueType val;
164 return iter.probeChild(val);
166 template<
typename OtherNodeT>
struct NodeConverter {
167 typedef typename OtherNodeT::ChildAllIter
Type;
171 template<
typename NodeT>
174 typedef typename NodeT::ChildAllCIter
IterT;
175 static IterT
begin(
const NodeT& node) {
return node.cbeginChildAll(); }
176 template<
typename ChildT>
static ChildT*
getChild(
const IterT& iter) {
177 typename IterT::NonConstValueType val;
178 return iter.probeChild(val);
180 template<
typename OtherNodeT>
struct NodeConverter {
181 typedef typename OtherNodeT::ChildAllCIter
Type;
185 template<
typename NodeT>
188 typedef typename NodeT::ValueOnIter
IterT;
189 static IterT
begin(NodeT& node) {
return node.beginValueOn(); }
190 template<
typename OtherNodeT>
struct NodeConverter {
191 typedef typename OtherNodeT::ValueOnIter
Type;
195 template<
typename NodeT>
198 typedef typename NodeT::ValueOnCIter
IterT;
199 static IterT
begin(
const NodeT& node) {
return node.cbeginValueOn(); }
200 template<
typename OtherNodeT>
struct NodeConverter {
201 typedef typename OtherNodeT::ValueOnCIter
Type;
205 template<
typename NodeT>
208 typedef typename NodeT::ValueOffIter
IterT;
209 static IterT
begin(NodeT& node) {
return node.beginValueOff(); }
210 template<
typename OtherNodeT>
struct NodeConverter {
211 typedef typename OtherNodeT::ValueOffIter
Type;
215 template<
typename NodeT>
218 typedef typename NodeT::ValueOffCIter
IterT;
219 static IterT
begin(
const NodeT& node) {
return node.cbeginValueOff(); }
220 template<
typename OtherNodeT>
struct NodeConverter {
221 typedef typename OtherNodeT::ValueOffCIter
Type;
225 template<
typename NodeT>
228 typedef typename NodeT::ValueAllIter
IterT;
229 static IterT
begin(NodeT& node) {
return node.beginValueAll(); }
230 template<
typename OtherNodeT>
struct NodeConverter {
231 typedef typename OtherNodeT::ValueAllIter
Type;
235 template<
typename NodeT>
238 typedef typename NodeT::ValueAllCIter
IterT;
239 static IterT
begin(
const NodeT& node) {
return node.cbeginValueAll(); }
240 template<
typename OtherNodeT>
struct NodeConverter {
241 typedef typename OtherNodeT::ValueAllCIter
Type;
259 template<
typename PrevItemT,
typename NodeVecT,
size_t VecSize, Index _Level>
266 typedef typename boost::mpl::front<NodeVecT>::type
_NodeT;
272 typedef typename IterT::NodeType
NodeT;
274 typedef typename IterT::NonConstNodeType
NCNodeT;
276 typedef typename IterT::NonConstValueType
NCValueT;
290 if (&other !=
this) {
300 void setIter(
const IterT& iter) { mIter = iter; }
301 template<
typename OtherIterT>
302 void setIter(
const OtherIterT& iter) { mNext.setIter(iter); }
307 node = (lvl <= Level) ? mIter.getParentNode() : NULL;
310 template<
typename OtherNodeT>
311 void getNode(
Index lvl, OtherNodeT*& node)
const { mNext.getNode(lvl, node); }
318 template<
typename OtherIterListItemT>
322 const NodeT* node = NULL;
323 otherListItem.getNode(lvl, node);
324 mIter = (node == NULL) ? IterT() : ITraits::begin(*const_cast<NodeT*>(node));
327 mNext.initLevel(lvl, otherListItem);
332 Index pos(
Index lvl)
const {
return (lvl == Level) ? mIter.pos() : mNext.pos(lvl); }
335 bool test(
Index lvl)
const {
return (lvl == Level) ? mIter.test() : mNext.test(lvl); }
338 bool next(
Index lvl) {
return (lvl == Level) ? mIter.next() : mNext.next(lvl); }
344 if (lvl == Level && mPrev != NULL && mIter) {
345 if (ChildT* child = ITraits::template getChild<ChildT>(mIter)) {
346 mPrev->setIter(PrevItemT::ITraits::begin(*child));
350 return (lvl > Level) ? mNext.down(lvl) :
false;
357 return (lvl == Level) ? mIter.getCoord() : mNext.getCoord(lvl);
361 return (lvl == Level) ? NodeT::getChildDim() : mNext.getChildDim(lvl);
366 return (lvl == Level) ? ChildT::NUM_VOXELS : mNext.getVoxelCount(lvl);
372 return (lvl == Level) ? mIter.isValueOn() : mNext.isValueOn(lvl);
378 if (lvl == Level)
return mIter.getValue();
379 return mNext.getValue(lvl);
387 if (lvl == Level) mIter.setValue(val);
else mNext.setValue(lvl, val);
394 if (lvl == Level) mIter.setValueOn(on);
else mNext.setValueOn(lvl, on);
401 if (lvl == Level) mIter.setValueOff();
else mNext.setValueOff(lvl);
406 template<
typename ModifyOp>
409 if (lvl == Level) mIter.modifyValue(op);
else mNext.modifyValue(lvl, op);
413 typedef typename boost::mpl::pop_front<NodeVecT>::type RestT;
423 template<
typename PrevItemT,
typename NodeVecT,
size_t VecSize>
430 typedef typename boost::mpl::front<NodeVecT>::type
_NodeT;
436 typedef typename IterT::NodeType
NodeT;
438 typedef typename IterT::NonConstNodeType
NCNodeT;
440 typedef typename IterT::NonConstValueType
NCValueT;
450 if (&other !=
this) {
460 void setIter(
const IterT& iter) { mIter = iter; }
461 template<
typename OtherIterT>
462 void setIter(
const OtherIterT& iter) { mNext.setIter(iter); }
466 node = (lvl == 0) ? mIter.getParentNode() : NULL;
468 template<
typename OtherNodeT>
469 void getNode(
Index lvl, OtherNodeT*& node)
const { mNext.getNode(lvl, node); }
471 template<
typename OtherIterListItemT>
475 const NodeT* node = NULL;
476 otherListItem.getNode(lvl, node);
477 mIter = (node == NULL) ? IterT() : ITraits::begin(*const_cast<NodeT*>(node));
479 mNext.initLevel(lvl, otherListItem);
483 Index pos(
Index lvl)
const {
return (lvl == 0) ? mIter.pos() : mNext.pos(lvl); }
485 bool test(
Index lvl)
const {
return (lvl == 0) ? mIter.test() : mNext.test(lvl); }
487 bool next(
Index lvl) {
return (lvl == 0) ? mIter.next() : mNext.next(lvl); }
489 bool down(
Index lvl) {
return (lvl == 0) ?
false : mNext.down(lvl); }
493 return (lvl == 0) ? mIter.getCoord() : mNext.getCoord(lvl);
497 return (lvl == 0) ? NodeT::getChildDim() : mNext.getChildDim(lvl);
502 return (lvl == 0) ? 1 : mNext.getVoxelCount(lvl);
507 return (lvl == 0) ? mIter.isValueOn() : mNext.isValueOn(lvl);
512 if (lvl == 0)
return mIter.getValue();
513 return mNext.getValue(lvl);
518 if (lvl == 0) mIter.setValue(val);
else mNext.setValue(lvl, val);
522 if (lvl == 0) mIter.setValueOn(on);
else mNext.setValueOn(lvl, on);
526 if (lvl == 0) mIter.setValueOff();
else mNext.setValueOff(lvl);
529 template<
typename ModifyOp>
532 if (lvl == 0) mIter.modifyValue(op);
else mNext.modifyValue(lvl, op);
536 typedef typename boost::mpl::pop_front<NodeVecT>::type RestT;
546 template<
typename PrevItemT,
typename NodeVecT, Index _Level>
550 typedef typename boost::mpl::front<NodeVecT>::type
_NodeT;
558 typedef typename IterT::NodeType
NodeT;
560 typedef typename IterT::NonConstNodeType
NCNodeT;
562 typedef typename IterT::NonConstValueType
NCValueT;
576 if (&other !=
this) {
588 void setIter(
const IterT& iter) { mIter = iter; }
592 node = (lvl <= Level) ? mIter.getParentNode() : NULL;
595 template<
typename OtherIterListItemT>
599 const NodeT* node = NULL;
600 otherListItem.getNode(lvl, node);
601 mIter = (node == NULL) ? IterT() : ITraits::begin(*const_cast<NodeT*>(node));
607 bool test(
Index lvl)
const {
return (lvl == Level) ? mIter.test() :
false; }
609 bool next(
Index lvl) {
return (lvl == Level) ? mIter.next() :
false; }
613 if (lvl == Level && mPrev != NULL && mIter) {
614 if (ChildT* child = ITraits::template getChild<ChildT>(mIter)) {
615 mPrev->setIter(PrevItemT::ITraits::begin(*child));
626 bool isValueOn(
Index lvl)
const {
return (lvl == Level) ? mIter.isValueOn() :
false; }
630 assert(lvl == Level);
632 return mIter.getValue();
635 void setValue(
Index lvl,
const NCValueT& val)
const {
if (lvl == Level) mIter.setValue(val); }
636 void setValueOn(
Index lvl,
bool on =
true)
const {
if (lvl == Level) mIter.setValueOn(on); }
639 template<
typename ModifyOp>
642 if (lvl == Level) mIter.modifyValue(op);
657 template<
typename _TreeT,
typename _ValueIterT>
663 typedef typename ValueIterT::NodeType
NodeT;
664 typedef typename ValueIterT::NonConstValueType
ValueT;
666 static const Index ROOT_LEVEL = NodeT::LEVEL;
667 BOOST_STATIC_ASSERT(ValueIterT::NodeType::LEVEL == ROOT_LEVEL);
668 static const Index LEAF_LEVEL = 0, ROOT_DEPTH = 0, LEAF_DEPTH = ROOT_LEVEL;
676 void setMinDepth(
Index minDepth);
680 void setMaxDepth(
Index maxDepth);
685 bool test()
const {
return mValueIterList.test(mLevel); }
687 operator bool()
const {
return this->test(); }
708 template<
typename NodeType>
709 void getNode(NodeType*& node)
const { mValueIterList.getNode(mLevel, node); }
730 bool isValueOn()
const {
return mValueIterList.isValueOn(mLevel); }
733 const ValueT& getValue()
const {
return mValueIterList.getValue(mLevel); }
735 const ValueT&
operator*()
const {
return this->getValue(); }
741 void setValue(
const ValueT& val)
const { mValueIterList.setValue(mLevel, val); }
753 template<
typename ModifyOp>
754 void modifyValue(
const ModifyOp& op)
const { mValueIterList.modifyValue(mLevel, op); }
760 std::string summary()
const;
763 bool advance(
bool dontIncrement =
false);
766 struct PrevChildItem {
typedef ChildOnIterT IterT; };
767 struct PrevValueItem {
typedef ValueIterT IterT; };
769 IterListItem<PrevChildItem, InvTreeT, ROOT_LEVEL+1, 0> mChildIterList;
770 IterListItem<PrevValueItem, InvTreeT, ROOT_LEVEL+1, 0> mValueIterList;
772 int mMinLevel, mMaxLevel;
777 template<
typename TreeT,
typename ValueIterT>
780 mChildIterList(NULL),
781 mValueIterList(NULL),
783 mMinLevel(int(LEAF_LEVEL)),
784 mMaxLevel(int(ROOT_LEVEL)),
793 template<
typename TreeT,
typename ValueIterT>
796 mChildIterList(other.mChildIterList),
797 mValueIterList(other.mValueIterList),
798 mLevel(other.mLevel),
799 mMinLevel(other.mMinLevel),
800 mMaxLevel(other.mMaxLevel),
808 template<
typename TreeT,
typename ValueIterT>
812 if (&other !=
this) {
813 mChildIterList = other.mChildIterList;
814 mValueIterList = other.mValueIterList;
815 mLevel = other.mLevel;
816 mMinLevel = other.mMinLevel;
817 mMaxLevel = other.mMaxLevel;
826 template<
typename TreeT,
typename ValueIterT>
831 if (
int(mLevel) > mMaxLevel) this->
next();
835 template<
typename TreeT,
typename ValueIterT>
841 if (
int(mLevel) < mMinLevel) this->
next();
845 template<
typename TreeT,
typename ValueIterT>
850 if (!this->advance())
return false;
851 }
while (
int(mLevel) < mMinLevel ||
int(mLevel) > mMaxLevel);
856 template<
typename TreeT,
typename ValueIterT>
860 bool recurse =
false;
864 vPos = mValueIterList.
pos(mLevel),
865 cPos = mChildIterList.
pos(mLevel);
866 if (vPos == cPos && mChildIterList.
test(mLevel)) {
868 mValueIterList.
next(mLevel);
869 vPos = mValueIterList.
pos(mLevel);
872 if (dontIncrement)
return true;
873 if (mValueIterList.
next(mLevel)) {
874 if (mValueIterList.
pos(mLevel) == cPos && mChildIterList.
test(mLevel)) {
877 mValueIterList.
next(mLevel);
880 if (mValueIterList.
pos(mLevel) < cPos)
return true;
884 if (!dontIncrement) mChildIterList.
next(mLevel);
886 #ifdef DEBUG_TREE_VALUE_ITERATOR 887 std::cout <<
"\n" << this->
summary() << std::flush;
891 while (mChildIterList.
pos(mLevel) < mValueIterList.
pos(mLevel)) {
892 #ifdef ENABLE_TREE_VALUE_DEPTH_BOUND_OPTIMIZATION 893 if (
int(mLevel) == mMinLevel) {
896 mChildIterList.
next(mLevel);
897 if (mValueIterList.
pos(mLevel) == mChildIterList.
pos(mLevel)
898 && mChildIterList.
test(mLevel))
902 mValueIterList.
next(mLevel);
906 if (mChildIterList.
down(mLevel)) {
908 mValueIterList.
initLevel(mLevel, mChildIterList);
909 if (mValueIterList.
pos(mLevel) == mChildIterList.
pos(mLevel)
910 && mChildIterList.
test(mLevel))
914 mValueIterList.
next(mLevel);
917 #ifdef DEBUG_TREE_VALUE_ITERATOR 918 std::cout <<
"\n" << this->
summary() << std::flush;
922 while (!mChildIterList.
test(mLevel) && !mValueIterList.
test(mLevel)) {
925 mChildIterList.
next(mLevel);
926 dontIncrement =
true;
934 template<
typename TreeT,
typename ValueIterT>
948 template<
typename TreeT,
typename ValueIterT>
952 std::ostringstream ostr;
953 for (
int lvl =
int(
ROOT_LEVEL); lvl >= 0 && lvl >= int(mLevel); --lvl) {
954 if (lvl == 0) ostr <<
"leaf";
955 else if (lvl ==
int(
ROOT_LEVEL)) ostr <<
"root";
957 ostr <<
" v" << mValueIterList.
pos(lvl)
958 <<
" c" << mChildIterList.
pos(lvl);
959 if (lvl >
int(mLevel)) ostr <<
" / ";
961 if (this->
test() && mValueIterList.
pos(mLevel) < mChildIterList.
pos(mLevel)) {
976 template<
typename _TreeT,
typename RootChildOnIterT>
1006 bool test()
const {
return !mDone; }
1008 operator bool()
const {
return this->
test(); }
1040 template<
typename NodeT>
1044 void getNode(
NodeT*& node)
const { node = NULL; mIterList.getNode(mLevel, node); }
1045 template<
typename NodeT>
1046 void getNode(
const NodeT*& node)
const { node = NULL; mIterList.getNode(mLevel, node); }
1054 struct PrevItem {
typedef RootIterT IterT; };
1056 IterListItem<PrevItem, InvTreeT, ROOT_LEVEL+1, LEAF_LEVEL> mIterList;
1058 int mMinLevel, mMaxLevel;
1064 template<
typename TreeT,
typename RootChildOnIterT>
1077 template<
typename TreeT,
typename RootChildOnIterT>
1087 mIterList.
setIter(RootIterTraits::begin(tree.root()));
1091 template<
typename TreeT,
typename RootChildOnIterT>
1094 mIterList(other.mIterList),
1095 mLevel(other.mLevel),
1096 mMinLevel(other.mMinLevel),
1097 mMaxLevel(other.mMaxLevel),
1105 template<
typename TreeT,
typename RootChildOnIterT>
1109 if (&other !=
this) {
1110 mLevel = other.mLevel;
1111 mMinLevel = other.mMinLevel;
1112 mMaxLevel = other.mMaxLevel;
1113 mDone = other.mDone;
1114 mTree = other.mTree;
1115 mIterList = other.mIterList;
1122 template<
typename TreeT,
typename RootChildOnIterT>
1127 if (
int(mLevel) > mMaxLevel) this->
next();
1131 template<
typename TreeT,
typename RootChildOnIterT>
1137 if (
int(mLevel) < mMinLevel) this->
next();
1141 template<
typename TreeT,
typename RootChildOnIterT>
1146 if (mDone)
return false;
1150 if (
int(mLevel) > mMinLevel && mIterList.
test(mLevel)) {
1151 if (!mIterList.
down(mLevel))
return false;
1155 while (!mIterList.
test(mLevel)) {
1162 mIterList.
next(mLevel);
1165 if (!mIterList.
down(mLevel))
return false;
1168 }
while (
int(mLevel) < mMinLevel || int(mLevel) > mMaxLevel);
1173 template<
typename TreeT,
typename RootChildOnIterT>
1180 return root ? root->getMinIndex() :
Coord::min();
1184 template<
typename TreeT,
typename RootChildOnIterT>
1195 root->getIndexRange(bbox);
1204 template<
typename TreeT,
typename RootChildOnIterT>
1208 std::ostringstream ostr;
1209 for (
int lvl =
int(
ROOT_LEVEL); lvl >= 0 && lvl >= int(mLevel); --lvl) {
1210 if (lvl == 0) ostr <<
"leaf";
1211 else if (lvl ==
int(
ROOT_LEVEL)) ostr <<
"root";
1213 ostr <<
" c" << mIterList.
pos(lvl);
1214 if (lvl >
int(mLevel)) ostr <<
" / ";
1218 ostr <<
" " << bbox;
1227 template<
typename TreeT,
typename RootChildOnIterT>
1247 mIterList.setIter(RootIterTraits::begin(tree.root()));
1250 for ( ; lvl > 0 && mIterList.down(lvl); --lvl) {}
1252 if (lvl > 0) this->
next();
1257 mIterList.updateBackPointers();
1261 if (&other !=
this) {
1262 mTree = other.mTree;
1263 mIterList = other.mIterList;
1270 LeafNodeT* getLeaf()
const { LeafNodeT* n = NULL; mIterList.getNode(LEAF_LEVEL, n);
return n; }
1276 bool test()
const {
return mIterList.test(LEAF_PARENT_LEVEL); }
1277 operator bool()
const {
return this->
test(); }
1291 struct PrevItem {
typedef RootIterT IterT; };
1301 template<
typename TreeT,
typename RootChildOnIterT>
1307 if (mIterList.test(LEAF_PARENT_LEVEL) && mIterList.next(LEAF_PARENT_LEVEL)) {
1308 mIterList.down(LEAF_PARENT_LEVEL);
1312 Index lvl = LEAF_PARENT_LEVEL;
1313 while (!mIterList.test(LEAF_PARENT_LEVEL)) {
1314 if (mIterList.test(lvl)) {
1315 mIterList.next(lvl);
1322 if (mIterList.test(lvl)) mIterList.next(lvl);
1323 }
while (!mIterList.test(lvl));
1326 while (lvl > LEAF_PARENT_LEVEL && mIterList.down(lvl)) --lvl;
1328 mIterList.down(LEAF_PARENT_LEVEL);
1338 template<
typename IterT>
1344 mGrainSize(grainSize),
1347 mSize = this->size();
1351 mGrainSize(other.mGrainSize),
1352 mSize(other.mSize >> 1)
1362 bool empty()
const {
return mSize == 0 || !mIter.test(); }
1363 bool test()
const {
return !this->empty(); }
1364 operator bool()
const {
return !this->empty(); }
1371 void increment(
Index n = 1) {
for ( ; n > 0 && mSize > 0; --n, --mSize, ++mIter) {} }
1379 Index size()
const {
Index n = 0;
for (IterT it(mIter); it.test(); ++n, ++it) {}
return n; }
1401 #endif // OPENVDB_TREE_TREEITERATOR_HAS_BEEN_INCLUDED OtherNodeT::ChildOnCIter Type
Definition: TreeIterator.h:133
bool down(Index lvl)
Definition: TreeIterator.h:489
PrevItemT::IterT PrevIterT
The type of iterator stored in the previous list item.
Definition: TreeIterator.h:552
void modifyValue(Index lvl, const ModifyOp &op) const
Apply a functor to the item to which this iterator is pointing.
Definition: TreeIterator.h:407
CopyConstness< NCNodeT, typename NCNodeT::ChildNodeType >::Type NCChildT
NodeT's child node type with const qualifiers removed.
Definition: TreeIterator.h:280
ValueIterT::NonConstValueType ValueT
Definition: TreeIterator.h:664
NodeT::ChildOnIter IterT
Definition: TreeIterator.h:114
void setIter(const OtherIterT &iter)
Definition: TreeIterator.h:462
NodeT::ChildOnCIter ChildOnIterT
Definition: TreeIterator.h:665
InvertedTree< typename HeadT::ChildNodeType, HeadLevel-1 >::Type SubtreeT
Definition: TreeIterator.h:80
void updateBackPointers(PrevItemT *prev)
Definition: TreeIterator.h:298
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:335
NodeIteratorBase & operator++()
Definition: TreeIterator.h:1016
bool next(Index lvl)
Definition: TreeIterator.h:487
NodeIteratorBase & operator=(const NodeIteratorBase &other)
Definition: TreeIterator.h:1107
OtherNodeT::ChildAllIter Type
Definition: TreeIterator.h:167
Index64 getVoxelCount(Index lvl) const
Definition: TreeIterator.h:500
void setValue(Index lvl, const NCValueT &val) const
Definition: TreeIterator.h:516
void setMaxDepth(Index maxDepth)
Specify the depth of the lowest level of the tree to which to descend (depth 0 = root).
Definition: TreeIterator.h:837
CoordBBox getBoundingBox() const
Return the axis-aligned bounding box of the voxel or tile to which this iterator is currently pointin...
Definition: TreeIterator.h:1037
IteratorRange & operator++()
Advance the iterator to the next item.
Definition: TreeIterator.h:1373
IterTraits< NCNodeT, IterT > ITraits
Definition: TreeIterator.h:281
static IterT begin(const NodeT &node)
Definition: TreeIterator.h:128
bool test(Index lvl) const
Definition: TreeIterator.h:607
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:744
TreeValueIteratorBase & operator++()
Advance to the next tile or voxel value.
Definition: TreeIterator.h:694
static IterT begin(NodeT &node)
Definition: TreeIterator.h:229
NodeT::ValueOffCIter IterT
Definition: TreeIterator.h:218
IterT::NonConstNodeType NCNodeT
The type of the node with const qualifiers removed ("Non-Const")
Definition: TreeIterator.h:560
OtherNodeT::ValueOnCIter Type
Definition: TreeIterator.h:201
TreeT * getTree() const
Definition: TreeIterator.h:1049
std::string summary() const
Definition: TreeIterator.h:1206
Coord getCoord() const
Return the global coordinates of the voxel or tile to which this iterator is currently pointing...
Definition: TreeIterator.h:1175
void getNode(NodeT *&node) const
Return the node to which the iterator is pointing.
Definition: TreeIterator.h:1044
LeafIteratorBase & operator++()
Advance the iterator to the next leaf node.
Definition: TreeIterator.h:1283
ValueIterT::NodeType NodeT
Definition: TreeIterator.h:663
Index getLevel() const
Return the level in the tree (0 = leaf) of the node to which this iterator is currently pointing...
Definition: TreeIterator.h:1022
OtherNodeT::ValueOnIter Type
Definition: TreeIterator.h:191
Coord getCoord() const
Return the global coordinates of the voxel or tile to which this iterator is currently pointing...
Definition: TreeIterator.h:713
NodeT::ValueOffIter IterT
Definition: TreeIterator.h:208
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:433
Base class for tree-traversal iterators over all nodes.
Definition: TreeIterator.h:977
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:385
void setMaxDepth(Index maxDepth)
Specify the depth of the lowest level of the tree to which to descend (depth 0 = root).
Definition: TreeIterator.h:1133
IterListItem(PrevItemT *prev)
Definition: TreeIterator.h:285
static ChildT * getChild(const IterT &)
Definition: TreeIterator.h:108
IterT::NonConstNodeType NCNodeT
The type of the node with const qualifiers removed ("Non-Const")
Definition: TreeIterator.h:438
_TreeT TreeT
Definition: TreeIterator.h:661
RootChildOnIterT RootIterT
Definition: TreeIterator.h:1231
CopyConstness< NodeT, typename NodeT::ChildNodeType >::Type ChildT
NodeT's child node type, with the same constness (e.g., const InternalNode<...>)
Definition: TreeIterator.h:278
Signed (x, y, z) 32-bit integer coordinates.
Definition: Coord.h:47
Mat3< typename promote< T0, T1 >::type > operator*(const Mat3< T0 > &m0, const Mat3< T1 > &m1)
Matrix multiplication.
Definition: Mat3.h:658
OtherNodeT::ValueAllIter Type
Definition: TreeIterator.h:231
Index64 getVoxelCount(Index lvl) const
Return the number of (virtual) voxels spanned by a tile value or child node.
Definition: TreeIterator.h:364
IterT::NodeType NodeT
The type of node (const or non-const) over which IterT iterates (e.g., const RootNode<...>)
Definition: TreeIterator.h:272
Index getLevel() const
Return the level in the tree (0 = leaf) of the node to which this iterator is currently pointing...
Definition: TreeIterator.h:698
static IterT begin(const NodeT &node)
Definition: TreeIterator.h:151
IterListItem & operator=(const IterListItem &other)
Definition: TreeIterator.h:574
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:392
boost::remove_const< ToType >::type Type
Definition: TreeIterator.h:66
Base class for tree-traversal iterators over tile and voxel values.
Definition: TreeIterator.h:658
static const Index LEAF_LEVEL
Definition: TreeIterator.h:986
const ValueT & operator*() const
Return the tile or voxel value to which this iterator is currently pointing.
Definition: TreeIterator.h:735
Index getChildDim(Index lvl) const
Definition: TreeIterator.h:495
IterTraits< NCRootNodeT, RootIterT > RootIterTraits
Definition: TreeIterator.h:1240
NodeT::ValueAllCIter IterT
Definition: TreeIterator.h:238
bool next(Index lvl)
Increment the iterator at level lvl of the tree.
Definition: TreeIterator.h:338
IterT::NonConstValueType NCValueT
The type of value (with const qualifiers removed) to which the iterator points.
Definition: TreeIterator.h:276
Index pos(Index lvl) const
Definition: TreeIterator.h:605
bool down(Index lvl)
Definition: TreeIterator.h:611
NodeT::ValueAllIter IterT
Definition: TreeIterator.h:228
_TreeT TreeT
Definition: TreeIterator.h:980
Coord getCoord(Index lvl) const
Definition: TreeIterator.h:622
static IterT begin(const NodeT &node)
Definition: TreeIterator.h:239
OtherNodeT::ValueOffIter Type
Definition: TreeIterator.h:211
static ChildT * getChild(const IterT &iter)
Definition: TreeIterator.h:176
const NCValueT & getValue(Index lvl) const
Definition: TreeIterator.h:510
static const Index LEAF_DEPTH
Definition: TreeIterator.h:668
void modifyValue(Index lvl, const ModifyOp &op) const
Definition: TreeIterator.h:640
LeafIteratorBase & operator=(const LeafIteratorBase &other)
Definition: TreeIterator.h:1259
void getNode(Index lvl, NodeT *&node) const
Definition: TreeIterator.h:464
void updateBackPointers(PrevItemT *=NULL)
Definition: TreeIterator.h:458
static IterT begin(const NodeT &node)
Definition: TreeIterator.h:199
static IterT begin(NodeT &node)
Definition: TreeIterator.h:189
OtherNodeT::ValueAllCIter Type
Definition: TreeIterator.h:241
IterTraits< NCNodeT, IterT > ITraits
Definition: TreeIterator.h:567
IterT::NonConstValueType NCValueT
The type of value (with const qualifiers removed) to which the iterator points.
Definition: TreeIterator.h:562
RootIterT::NonConstNodeType NCRootNodeT
Definition: TreeIterator.h:983
Index getChildDim(Index lvl) const
Definition: TreeIterator.h:359
Index32 Index
Definition: Types.h:58
OtherNodeT::ChildOffIter Type
Definition: TreeIterator.h:143
IterT::NonConstValueType NCValueT
The type of value (with const qualifiers removed) to which the iterator points.
Definition: TreeIterator.h:440
Index getChildDim(Index lvl) const
Definition: TreeIterator.h:623
bool test() const
Definition: TreeIterator.h:1276
NodeT::ChildOffCIter IterT
Definition: TreeIterator.h:150
static IterT begin(NodeT &node)
Definition: TreeIterator.h:209
uint64_t Index64
Definition: Types.h:57
static IterT begin(NodeT &node)
Definition: TreeIterator.h:115
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:754
CopyConstness< RootNodeT, NCLeafNodeT >::Type LeafNodeT
Definition: TreeIterator.h:1237
NodeT::ValueOnIter IterT
Definition: TreeIterator.h:188
IterListItem(PrevItemT *)
Definition: TreeIterator.h:445
LeafNodeT & operator*() const
Return the leaf node to which the iterator is pointing.
Definition: TreeIterator.h:1272
#define OPENVDB_VERSION_NAME
Definition: version.h:43
static const ChildT * getChild(const IterT &iter)
Definition: TreeIterator.h:129
PrevItemT::IterT PrevIterT
The type of iterator stored in the previous list item.
Definition: TreeIterator.h:264
TreeT * getTree() const
Return a pointer to the tree over which this iterator is iterating.
Definition: TreeIterator.h:757
Index pos(Index lvl) const
Definition: TreeIterator.h:483
Index pos(Index lvl) const
Return The table offset of the iterator at level lvl of the tree.
Definition: TreeIterator.h:332
RootChildOnIterT RootIterT
Definition: TreeIterator.h:981
IterTraits< NCNodeT, IterT > ITraits
Definition: TreeIterator.h:441
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:319
void getNode(const NodeT *&node) const
Return the node to which the iterator is pointing.
Definition: TreeIterator.h:1046
bool next()
Advance the iterator to the next leaf node.
Definition: TreeIterator.h:1303
Index getMaxDepth() const
Return the depth of the lowest level of the tree to which this iterator ascends.
Definition: TreeIterator.h:1003
bool test() const
Return true if this iterator is not yet exhausted.
Definition: TreeIterator.h:686
An IterListItem is an element of a compile-time linked list of iterators to nodes of different types...
Definition: TreeIterator.h:260
Definition: TreeIterator.h:1339
IterListItem(const IterListItem &other)
Definition: TreeIterator.h:573
bool test() const
Return true if this iterator is not yet exhausted.
Definition: TreeIterator.h:1007
static IterT begin(NodeT &node)
Definition: TreeIterator.h:161
static const Index ROOT_LEVEL
Definition: TreeIterator.h:984
static ChildT * getChild(const IterT &iter)
Definition: TreeIterator.h:162
_ValueIterT ValueIterT
Definition: TreeIterator.h:662
CopyConstness< NodeT, typename NodeT::ChildNodeType >::Type ChildT
NodeT's child node type, with the same constness (e.g., const InternalNode<...>)
Definition: TreeIterator.h:564
IterT::NodeType NodeT
The type of node over which IterT iterates (e.g., const RootNode<...>)
Definition: TreeIterator.h:558
bool next()
Advance to the next tile or voxel value.
Definition: TreeIterator.h:1143
LeafIteratorBase(TreeT &tree)
Definition: TreeIterator.h:1244
boost::mpl::front< NodeVecT >::type _NodeT
The type of node (non-const) whose iterator is stored in this list item.
Definition: TreeIterator.h:430
Coord offsetBy(Int32 dx, Int32 dy, Int32 dz) const
Definition: Coord.h:111
const NCValueT & getValue(Index lvl) const
Return the value to which the iterator at level lvl of the tree points.
Definition: TreeIterator.h:376
void setValueOn(Index lvl, bool on=true) const
Definition: TreeIterator.h:636
void setIter(const IterT &iter)
Definition: TreeIterator.h:588
Definition: Exceptions.h:39
OtherNodeT::ValueOffCIter Type
Definition: TreeIterator.h:221
RootIterT::NonConstNodeType NCRootNodeT
Definition: TreeIterator.h:1233
void getNode(Index lvl, OtherNodeT *&node) const
Definition: TreeIterator.h:469
boost::mpl::vector< typename HeadT::ChildNodeType, HeadT >::type Type
Definition: TreeIterator.h:85
bool isValueOn(Index lvl) const
Return true if the iterator at level lvl of the tree points to an active value.
Definition: TreeIterator.h:370
Index getMinDepth() const
Return the depth of the highest level of the tree to which this iterator ascends. ...
Definition: TreeIterator.h:678
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:741
OtherNodeT::ChildOnIter Type
Definition: TreeIterator.h:120
Index64 getVoxelCount(Index lvl) const
Definition: TreeIterator.h:624
void setValue(Index lvl, const NCValueT &val) const
Definition: TreeIterator.h:635
void increment()
Advance the iterator to the next leaf node.
Definition: TreeIterator.h:1282
void setValueOff(Index lvl) const
Mark the value to which the iterator at level lvl of the tree points as inactive. ...
Definition: TreeIterator.h:399
static IterT begin(NodeT &node)
Definition: TreeIterator.h:141
Definition: TreeIterator.h:79
IteratorRange(IteratorRange &other, tbb::split)
Definition: TreeIterator.h:1349
Base class for tree-traversal iterators over all leaf nodes (but not leaf voxels) ...
Definition: TreeIterator.h:1228
Definition: TreeIterator.h:106
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:355
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:342
Index getMinDepth() const
Return the depth of the highest level of the tree to which this iterator ascends. ...
Definition: TreeIterator.h:999
void setIter(const IterT &iter)
Definition: TreeIterator.h:300
void setValueOn(Index lvl, bool on=true) const
Definition: TreeIterator.h:520
const IterT & iterator() const
Return a reference to this range's iterator.
Definition: TreeIterator.h:1360
static const Index LEAF_LEVEL
Definition: TreeIterator.h:668
Index getMaxDepth() const
Return the depth of the lowest level of the tree to which this iterator ascends.
Definition: TreeIterator.h:682
Coord getCoord(Index lvl) const
Definition: TreeIterator.h:491
const Coord & min() const
Definition: Coord.h:332
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:269
bool isValueOn(Index lvl) const
Definition: TreeIterator.h:505
void setValueOff() const
Mark the tile or voxel value to which this iterator is currently pointing as inactive.
Definition: TreeIterator.h:746
NodeT::ChildOnCIter IterT
Definition: TreeIterator.h:127
bool isVoxelValue() const
Return true if this iterator is currently pointing to a (leaf) voxel value.
Definition: TreeIterator.h:728
OtherNodeT::ChildAllCIter Type
Definition: TreeIterator.h:181
std::string summary() const
Return a string (for debugging, mainly) describing this iterator's current state. ...
Definition: TreeIterator.h:950
static const Index ROOT_DEPTH
Definition: TreeIterator.h:668
static IterT begin(const NodeT &node)
Definition: TreeIterator.h:219
static const Index ROOT_LEVEL
Definition: TreeIterator.h:666
OtherNodeT::ChildOffCIter Type
Definition: TreeIterator.h:153
static Coord min()
Return the smallest possible coordinate.
Definition: Coord.h:69
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:709
void increment(Index n)
Increment the iterator n times.
Definition: TreeIterator.h:1018
Index getDepth() const
Return the depth in the tree (0 = root) of the node to which this iterator is currently pointing...
Definition: TreeIterator.h:701
const Coord & max() const
Definition: Coord.h:333
void getNode(Index lvl, NodeT *&node) const
Return the node over which this list element's iterator iterates.
Definition: TreeIterator.h:305
NodeIteratorBase()
Definition: TreeIterator.h:1066
LeafNodeT * operator->() const
Return the leaf node to which the iterator is pointing.
Definition: TreeIterator.h:1273
Axis-aligned bounding box of signed integer coordinates.
Definition: Coord.h:259
bool test(Index lvl) const
Definition: TreeIterator.h:485
static ChildT * getChild(const IterT &iter)
Definition: TreeIterator.h:116
TreeT * getTree() const
Definition: TreeIterator.h:1288
Index getDepth() const
Return the depth in the tree (0 = root) of the node to which this iterator is currently pointing...
Definition: TreeIterator.h:1025
bool next()
Advance to the next tile or voxel value. Return true if this iterator is not yet exhausted.
Definition: TreeIterator.h:847
LeafIteratorBase(const LeafIteratorBase &other)
Definition: TreeIterator.h:1255
RootIterT::NodeType RootNodeT
Definition: TreeIterator.h:982
const NCValueT & getValue(Index lvl) const
Definition: TreeIterator.h:628
boost::mpl::front< NodeVecT >::type _NodeT
Definition: TreeIterator.h:550
void getNode(Index lvl, OtherNodeT *&node) const
Return the node over which one of the following list elements' iterator iterates. ...
Definition: TreeIterator.h:311
TreeValueIteratorBase(TreeT &)
Definition: TreeIterator.h:779
void initLevel(Index lvl, OtherIterListItemT &otherListItem)
Definition: TreeIterator.h:472
boost::mpl::front< InvTreeT >::type NCLeafNodeT
Definition: TreeIterator.h:1236
bool empty() const
Definition: TreeIterator.h:1362
NodeT::ValueOnCIter IterT
Definition: TreeIterator.h:198
IterT::NonConstNodeType NCNodeT
The type of the node with const qualifiers removed ("Non-Const")
Definition: TreeIterator.h:274
iter::InvertedTree< NCRootNodeT, ROOT_LEVEL >::Type InvTreeT
Definition: TreeIterator.h:985
boost::mpl::push_back< SubtreeT, HeadT >::type Type
Definition: TreeIterator.h:81
CoordBBox getBoundingBox() const
Return the axis-aligned bounding box of the voxel or tile to which this iterator is currently pointin...
Definition: TreeIterator.h:720
void increment()
Advance the iterator to the next leaf node.
Definition: TreeIterator.h:1015
void initLevel(Index lvl, OtherIterListItemT &otherListItem)
Definition: TreeIterator.h:596
bool isTileValue() const
Return true if this iterator is currently pointing to a (non-leaf) tile value.
Definition: TreeIterator.h:726
const ToType Type
Definition: TreeIterator.h:69
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:555
RootIterT::NodeType RootNodeT
Definition: TreeIterator.h:1232
static Index getLeafDepth()
Definition: TreeIterator.h:702
iter::InvertedTree< NCRootNodeT, ROOT_LEVEL >::Type InvTreeT
Definition: TreeIterator.h:1235
bool next()
Advance the iterator to the next item.
Definition: TreeIterator.h:1376
bool next(Index lvl)
Definition: TreeIterator.h:609
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:1368
bool isValueOn(Index lvl) const
Definition: TreeIterator.h:626
Definition: TreeIterator.h:65
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h:71
void setMinDepth(Index minDepth)
Specify the depth of the highest level of the tree to which to ascend (depth 0 = root).
Definition: TreeIterator.h:1124
NodeT::ChildOffIter IterT
Definition: TreeIterator.h:140
static Index getLeafDepth()
Definition: TreeIterator.h:1026
void setValueOff(Index lvl) const
Definition: TreeIterator.h:524
PrevItemT::IterT PrevIterT
The type of iterator stored in the previous list item.
Definition: TreeIterator.h:428
void modifyValue(Index lvl, const ModifyOp &op) const
Definition: TreeIterator.h:530
TreeValueIteratorBase & operator=(const TreeValueIteratorBase &other)
Definition: TreeIterator.h:810
void increment(Index n=1)
Advance the iterator n times.
Definition: TreeIterator.h:1371
IteratorRange(const IterT &iter, size_t grainSize=8)
Definition: TreeIterator.h:1342
void setValueOff(Index lvl) const
Definition: TreeIterator.h:637
Index64 getVoxelCount() const
Return the number of (virtual) voxels corresponding to the value.
Definition: TreeIterator.h:723
IterListItem & operator=(const IterListItem &other)
Definition: TreeIterator.h:448
void getNode(Index lvl, NodeT *&node) const
Definition: TreeIterator.h:590
const ValueT * operator->() const
Return the tile or voxel value to which this iterator is currently pointing.
Definition: TreeIterator.h:736
IterListItem(PrevItemT *prev)
Definition: TreeIterator.h:571
IterListItem(const IterListItem &other)
Definition: TreeIterator.h:287
void setIter(const IterT &iter)
Definition: TreeIterator.h:460
bool test() const
Definition: TreeIterator.h:1363
LeafIteratorBase()
Definition: TreeIterator.h:1242
NodeT::ChildAllIter IterT
Definition: TreeIterator.h:160
void updateBackPointers(PrevItemT *prev)
Definition: TreeIterator.h:583
IterListItem & operator=(const IterListItem &other)
Definition: TreeIterator.h:288
boost::mpl::front< NodeVecT >::type _NodeT
The type of node (non-const) whose iterator is stored in this list item.
Definition: TreeIterator.h:266
IterListItem(const IterListItem &other)
Definition: TreeIterator.h:447
void setIter(const OtherIterT &iter)
Definition: TreeIterator.h:302
CopyConstness< NCNodeT, typename NCNodeT::ChildNodeType >::Type NCChildT
NodeT's child node type with const qualifiers removed.
Definition: TreeIterator.h:566
NodeT::ChildAllCIter IterT
Definition: TreeIterator.h:174
IterTraits< NCRootNodeT, RootIterT > RootIterTraits
Definition: TreeIterator.h:988
void setMinDepth(Index minDepth)
Specify the depth of the highest level of the tree to which to ascend (depth 0 = root).
Definition: TreeIterator.h:828
IterT::NodeType NodeT
The type of node (const or non-const) over which IterT iterates (e.g., const RootNode<...>)
Definition: TreeIterator.h:436
static IterT begin(const NodeT &node)
Definition: TreeIterator.h:175
bool isValueOn() const
Return true if the value to which this iterator is currently pointing is active.
Definition: TreeIterator.h:730