6 #ifndef OPENVDB_TREE_TREEITERATOR_HAS_BEEN_INCLUDED 7 #define OPENVDB_TREE_TREEITERATOR_HAS_BEEN_INCLUDED 9 #include <tbb/blocked_range.h> 10 #include <tbb/parallel_for.h> 11 #include <openvdb/version.h> 17 #include <type_traits> 22 #define ENABLE_TREE_VALUE_DEPTH_BOUND_OPTIMIZATION 32 template<
typename HeadT,
int HeadLevel>
35 using Type =
typename SubtreeT::template Append<HeadT>;
37 template<
typename HeadT>
59 template<
typename NodeT,
typename IterT>
62 template<
typename ChildT>
static ChildT*
getChild(
const IterT&) {
return nullptr; }
65 template<
typename NodeT>
68 using IterT =
typename NodeT::ChildOnIter;
69 static IterT begin(NodeT& node) {
return node.beginChildOn(); }
71 return &iter.getValue();
73 template<
typename OtherNodeT>
struct NodeConverter {
74 using Type =
typename OtherNodeT::ChildOnIter;
78 template<
typename NodeT>
81 using IterT =
typename NodeT::ChildOnCIter;
82 static IterT begin(
const NodeT& node) {
return node.cbeginChildOn(); }
83 template<
typename ChildT>
static const ChildT*
getChild(
const IterT& iter) {
84 return &iter.getValue();
86 template<
typename OtherNodeT>
struct NodeConverter {
87 using Type =
typename OtherNodeT::ChildOnCIter;
91 template<
typename NodeT>
94 using IterT =
typename NodeT::ChildOffIter;
95 static IterT begin(NodeT& node) {
return node.beginChildOff(); }
96 template<
typename OtherNodeT>
struct NodeConverter {
97 using Type =
typename OtherNodeT::ChildOffIter;
101 template<
typename NodeT>
104 using IterT =
typename NodeT::ChildOffCIter;
105 static IterT begin(
const NodeT& node) {
return node.cbeginChildOff(); }
106 template<
typename OtherNodeT>
struct NodeConverter {
107 using Type =
typename OtherNodeT::ChildOffCIter;
111 template<
typename NodeT>
114 using IterT =
typename NodeT::ChildAllIter;
115 static IterT begin(NodeT& node) {
return node.beginChildAll(); }
117 typename IterT::NonConstValueType val;
118 return iter.probeChild(val);
120 template<
typename OtherNodeT>
struct NodeConverter {
121 using Type =
typename OtherNodeT::ChildAllIter;
125 template<
typename NodeT>
128 using IterT =
typename NodeT::ChildAllCIter;
129 static IterT begin(
const NodeT& node) {
return node.cbeginChildAll(); }
131 typename IterT::NonConstValueType val;
132 return iter.probeChild(val);
134 template<
typename OtherNodeT>
struct NodeConverter {
135 using Type =
typename OtherNodeT::ChildAllCIter;
139 template<
typename NodeT>
142 using IterT =
typename NodeT::ValueOnIter;
143 static IterT begin(NodeT& node) {
return node.beginValueOn(); }
144 template<
typename OtherNodeT>
struct NodeConverter {
145 using Type =
typename OtherNodeT::ValueOnIter;
149 template<
typename NodeT>
152 using IterT =
typename NodeT::ValueOnCIter;
153 static IterT begin(
const NodeT& node) {
return node.cbeginValueOn(); }
154 template<
typename OtherNodeT>
struct NodeConverter {
155 using Type =
typename OtherNodeT::ValueOnCIter;
159 template<
typename NodeT>
162 using IterT =
typename NodeT::ValueOffIter;
163 static IterT begin(NodeT& node) {
return node.beginValueOff(); }
164 template<
typename OtherNodeT>
struct NodeConverter {
165 using Type =
typename OtherNodeT::ValueOffIter;
169 template<
typename NodeT>
172 using IterT =
typename NodeT::ValueOffCIter;
173 static IterT begin(
const NodeT& node) {
return node.cbeginValueOff(); }
174 template<
typename OtherNodeT>
struct NodeConverter {
175 using Type =
typename OtherNodeT::ValueOffCIter;
179 template<
typename NodeT>
182 using IterT =
typename NodeT::ValueAllIter;
183 static IterT begin(NodeT& node) {
return node.beginValueAll(); }
184 template<
typename OtherNodeT>
struct NodeConverter {
185 using Type =
typename OtherNodeT::ValueAllIter;
189 template<
typename NodeT>
192 using IterT =
typename NodeT::ValueAllCIter;
193 static IterT begin(
const NodeT& node) {
return node.cbeginValueAll(); }
194 template<
typename OtherNodeT>
struct NodeConverter {
195 using Type =
typename OtherNodeT::ValueAllCIter;
213 template<
typename PrevItemT,
typename NodeVecT,
size_t VecSize, Index _Level>
223 NodeConverter<_NodeT>::Type;
226 using NodeT =
typename IterT::NodeType;
228 using NCNodeT =
typename IterT::NonConstNodeType;
230 using NCValueT =
typename IterT::NonConstValueType;
242 mIter(other.mIter), mNext(other.mNext), mPrev(nullptr) {}
245 if (&other !=
this) {
256 template<
typename OtherIterT>
257 void setIter(
const OtherIterT& iter) { mNext.setIter(iter); }
262 node = (lvl <=
Level) ? mIter.getParentNode() :
nullptr;
265 template<
typename OtherNodeT>
266 void getNode(
Index lvl, OtherNodeT*& node)
const { mNext.getNode(lvl, node); }
273 template<
typename OtherIterListItemT>
277 const NodeT* node =
nullptr;
278 otherListItem.getNode(lvl, node);
279 mIter = (node ==
nullptr) ?
IterT() : ITraits::begin(*const_cast<NodeT*>(node));
282 mNext.initLevel(lvl, otherListItem);
287 Index pos(
Index lvl)
const {
return (lvl == Level) ? mIter.pos() : mNext.pos(lvl); }
290 bool test(
Index lvl)
const {
return (lvl == Level) ? mIter.test() : mNext.test(lvl); }
293 bool next(
Index lvl) {
return (lvl == Level) ? mIter.next() : mNext.next(lvl); }
299 if (lvl == Level && mPrev !=
nullptr && mIter) {
300 if (
ChildT* child = ITraits::template getChild<ChildT>(mIter)) {
301 mPrev->setIter(PrevItemT::ITraits::begin(*child));
305 return (lvl > Level) ? mNext.down(lvl) :
false;
312 return (lvl == Level) ? mIter.getCoord() : mNext.getCoord(lvl);
316 return (lvl == Level) ? NodeT::getChildDim() : mNext.getChildDim(lvl);
321 return (lvl == Level) ? ChildT::NUM_VOXELS : mNext.getVoxelCount(lvl);
327 return (lvl == Level) ? mIter.isValueOn() : mNext.isValueOn(lvl);
333 if (lvl == Level)
return mIter.getValue();
334 return mNext.getValue(lvl);
342 if (lvl == Level) mIter.setValue(val);
else mNext.setValue(lvl, val);
349 if (lvl == Level) mIter.setValueOn(on);
else mNext.setValueOn(lvl, on);
356 if (lvl == Level) mIter.setValueOff();
else mNext.setValueOff(lvl);
361 template<
typename ModifyOp>
364 if (lvl == Level) mIter.modifyValue(op);
else mNext.modifyValue(lvl, op);
368 using RestT =
typename NodeVecT::PopFront;
378 template<
typename PrevItemT,
typename NodeVecT,
size_t VecSize>
388 NodeConverter<_NodeT>::Type;
391 using NodeT =
typename IterT::NodeType;
393 using NCNodeT =
typename IterT::NonConstNodeType;
395 using NCValueT =
typename IterT::NonConstValueType;
403 mIter(other.mIter), mNext(other.mNext), mPrev(nullptr) {}
406 if (&other !=
this) {
416 mPrev =
nullptr; mNext.updateBackPointers(
this);
420 template<
typename OtherIterT>
421 void setIter(
const OtherIterT& iter) { mNext.setIter(iter); }
425 node = (lvl == 0) ? mIter.getParentNode() :
nullptr;
427 template<
typename OtherNodeT>
428 void getNode(
Index lvl, OtherNodeT*& node)
const { mNext.getNode(lvl, node); }
430 template<
typename OtherIterListItemT>
434 const NodeT* node =
nullptr;
435 otherListItem.getNode(lvl, node);
436 mIter = (node ==
nullptr) ?
IterT() : ITraits::begin(*const_cast<NodeT*>(node));
438 mNext.initLevel(lvl, otherListItem);
442 Index pos(
Index lvl)
const {
return (lvl == 0) ? mIter.pos() : mNext.pos(lvl); }
444 bool test(
Index lvl)
const {
return (lvl == 0) ? mIter.test() : mNext.test(lvl); }
446 bool next(
Index lvl) {
return (lvl == 0) ? mIter.next() : mNext.next(lvl); }
448 bool down(
Index lvl) {
return (lvl == 0) ?
false : mNext.down(lvl); }
452 return (lvl == 0) ? mIter.getCoord() : mNext.getCoord(lvl);
456 return (lvl == 0) ? NodeT::getChildDim() : mNext.getChildDim(lvl);
461 return (lvl == 0) ? 1 : mNext.getVoxelCount(lvl);
466 return (lvl == 0) ? mIter.isValueOn() : mNext.isValueOn(lvl);
471 if (lvl == 0)
return mIter.getValue();
472 return mNext.getValue(lvl);
477 if (lvl == 0) mIter.setValue(val);
else mNext.setValue(lvl, val);
481 if (lvl == 0) mIter.setValueOn(on);
else mNext.setValueOn(lvl, on);
485 if (lvl == 0) mIter.setValueOff();
else mNext.setValueOff(lvl);
488 template<
typename ModifyOp>
491 if (lvl == 0) mIter.modifyValue(op);
else mNext.modifyValue(lvl, op);
495 using RestT =
typename NodeVecT::PopFront;
505 template<
typename PrevItemT,
typename NodeVecT, Index _Level>
514 NodeConverter<_NodeT>::Type;
517 using NodeT =
typename IterT::NodeType;
519 using NCNodeT =
typename IterT::NonConstNodeType;
521 using NCValueT =
typename IterT::NonConstValueType;
535 if (&other !=
this) {
551 node = (lvl <=
Level) ? mIter.getParentNode() :
nullptr;
554 template<
typename OtherIterListItemT>
558 const NodeT* node =
nullptr;
559 otherListItem.getNode(lvl, node);
560 mIter = (node ==
nullptr) ?
IterT() : ITraits::begin(*const_cast<NodeT*>(node));
566 bool test(
Index lvl)
const {
return (lvl == Level) ? mIter.test() :
false; }
568 bool next(
Index lvl) {
return (lvl == Level) ? mIter.next() :
false; }
572 if (lvl == Level && mPrev !=
nullptr && mIter) {
573 if (
ChildT* child = ITraits::template getChild<ChildT>(mIter)) {
574 mPrev->setIter(PrevItemT::ITraits::begin(*child));
581 Coord
getCoord(
Index lvl)
const {
return (lvl == Level) ? mIter.getCoord() : Coord(); }
585 bool isValueOn(
Index lvl)
const {
return (lvl == Level) ? mIter.isValueOn() :
false; }
591 return mIter.getValue();
595 void setValueOn(
Index lvl,
bool on =
true)
const {
if (lvl == Level) mIter.setValueOn(on); }
598 template<
typename ModifyOp>
601 if (lvl == Level) mIter.modifyValue(op);
616 template<
typename _TreeT,
typename _ValueIterT>
622 using NodeT =
typename ValueIterT::NodeType;
623 using ValueT =
typename ValueIterT::NonConstValueType;
626 static_assert(ValueIterT::NodeType::LEVEL == ROOT_LEVEL,
"invalid value iterator node type");
635 void setMinDepth(
Index minDepth);
639 void setMaxDepth(
Index maxDepth);
645 bool test()
const {
return mValueIterList.test(mLevel); }
646 operator bool()
const {
return this->test(); }
667 template<
typename NodeType>
668 void getNode(NodeType*& node)
const { mValueIterList.getNode(mLevel, node); }
672 Coord
getCoord()
const {
return mValueIterList.getCoord(mLevel); }
676 bool getBoundingBox(CoordBBox&)
const;
689 bool isValueOn()
const {
return mValueIterList.isValueOn(mLevel); }
712 template<
typename ModifyOp>
713 void modifyValue(
const ModifyOp&
op)
const { mValueIterList.modifyValue(mLevel, op); }
719 std::string summary()
const;
722 bool advance(
bool dontIncrement =
false);
726 struct PrevValueItem {
using IterT =
ValueIterT; };
728 IterListItem<PrevChildItem, InvTreeT, ROOT_LEVEL+1, 0> mChildIterList;
729 IterListItem<PrevValueItem, InvTreeT, ROOT_LEVEL+1, 0> mValueIterList;
731 int mMinLevel, mMaxLevel;
736 template<
typename TreeT,
typename ValueIterT>
739 mChildIterList(nullptr),
740 mValueIterList(nullptr),
742 mMinLevel(int(LEAF_LEVEL)),
752 template<
typename TreeT,
typename ValueIterT>
755 mChildIterList(other.mChildIterList),
756 mValueIterList(other.mValueIterList),
757 mLevel(other.mLevel),
758 mMinLevel(other.mMinLevel),
759 mMaxLevel(other.mMaxLevel),
767 template<
typename TreeT,
typename ValueIterT>
771 if (&other !=
this) {
772 mChildIterList = other.mChildIterList;
773 mValueIterList = other.mValueIterList;
774 mLevel = other.mLevel;
775 mMinLevel = other.mMinLevel;
776 mMaxLevel = other.mMaxLevel;
785 template<
typename TreeT,
typename ValueIterT>
790 if (
int(mLevel) > mMaxLevel) this->
next();
794 template<
typename TreeT,
typename ValueIterT>
800 if (
int(mLevel) < mMinLevel) this->
next();
804 template<
typename TreeT,
typename ValueIterT>
809 if (!this->advance())
return false;
810 }
while (
int(mLevel) < mMinLevel ||
int(mLevel) > mMaxLevel);
815 template<
typename TreeT,
typename ValueIterT>
819 bool recurse =
false;
823 vPos = mValueIterList.
pos(mLevel),
824 cPos = mChildIterList.
pos(mLevel);
825 if (vPos == cPos && mChildIterList.
test(mLevel)) {
827 mValueIterList.
next(mLevel);
828 vPos = mValueIterList.
pos(mLevel);
831 if (dontIncrement)
return true;
832 if (mValueIterList.
next(mLevel)) {
833 if (mValueIterList.
pos(mLevel) == cPos && mChildIterList.
test(mLevel)) {
836 mValueIterList.
next(mLevel);
839 if (mValueIterList.
pos(mLevel) < cPos)
return true;
843 if (!dontIncrement) mChildIterList.
next(mLevel);
845 #ifdef DEBUG_TREE_VALUE_ITERATOR 846 std::cout <<
"\n" << this->
summary() << std::flush;
850 while (mChildIterList.
pos(mLevel) < mValueIterList.
pos(mLevel)) {
851 #ifdef ENABLE_TREE_VALUE_DEPTH_BOUND_OPTIMIZATION 852 if (
int(mLevel) == mMinLevel) {
855 mChildIterList.
next(mLevel);
856 if (mValueIterList.
pos(mLevel) == mChildIterList.
pos(mLevel)
857 && mChildIterList.
test(mLevel))
861 mValueIterList.
next(mLevel);
865 if (mChildIterList.
down(mLevel)) {
867 mValueIterList.
initLevel(mLevel, mChildIterList);
868 if (mValueIterList.
pos(mLevel) == mChildIterList.
pos(mLevel)
869 && mChildIterList.
test(mLevel))
873 mValueIterList.
next(mLevel);
876 #ifdef DEBUG_TREE_VALUE_ITERATOR 877 std::cout <<
"\n" << this->
summary() << std::flush;
881 while (!mChildIterList.
test(mLevel) && !mValueIterList.
test(mLevel)) {
884 mChildIterList.
next(mLevel);
885 dontIncrement =
true;
893 template<
typename TreeT,
typename ValueIterT>
901 bbox.min() = mValueIterList.
getCoord(mLevel);
902 bbox.max() = bbox.min().offsetBy(mValueIterList.
getChildDim(mLevel) - 1);
907 template<
typename TreeT,
typename ValueIterT>
911 std::ostringstream ostr;
912 for (
int lvl =
int(
ROOT_LEVEL); lvl >= 0 && lvl >= int(mLevel); --lvl) {
913 if (lvl == 0) ostr <<
"leaf";
914 else if (lvl ==
int(
ROOT_LEVEL)) ostr <<
"root";
916 ostr <<
" v" << mValueIterList.
pos(lvl)
917 <<
" c" << mChildIterList.
pos(lvl);
918 if (lvl >
int(mLevel)) ostr <<
" / ";
920 if (this->
test() && mValueIterList.
pos(mLevel) < mChildIterList.
pos(mLevel)) {
935 template<
typename _TreeT,
typename RootChildOnIterT>
966 bool test()
const {
return !mDone; }
1002 template<
typename NodeT>
1003 void getNode(
NodeT*& node)
const { node =
nullptr; mIterList.getNode(mLevel, node); }
1004 template<
typename NodeT>
1005 void getNode(
const NodeT*& node)
const { node =
nullptr; mIterList.getNode(mLevel, node); }
1013 struct PrevItem {
using IterT =
RootIterT; };
1017 int mMinLevel, mMaxLevel;
1023 template<
typename TreeT,
typename RootChildOnIterT>
1036 template<
typename TreeT,
typename RootChildOnIterT>
1046 mIterList.
setIter(RootIterTraits::begin(tree.root()));
1050 template<
typename TreeT,
typename RootChildOnIterT>
1053 mIterList(other.mIterList),
1054 mLevel(other.mLevel),
1055 mMinLevel(other.mMinLevel),
1056 mMaxLevel(other.mMaxLevel),
1064 template<
typename TreeT,
typename RootChildOnIterT>
1068 if (&other !=
this) {
1069 mLevel = other.mLevel;
1070 mMinLevel = other.mMinLevel;
1071 mMaxLevel = other.mMaxLevel;
1072 mDone = other.mDone;
1073 mTree = other.mTree;
1074 mIterList = other.mIterList;
1081 template<
typename TreeT,
typename RootChildOnIterT>
1086 if (
int(mLevel) > mMaxLevel) this->
next();
1090 template<
typename TreeT,
typename RootChildOnIterT>
1096 if (
int(mLevel) < mMinLevel) this->
next();
1100 template<
typename TreeT,
typename RootChildOnIterT>
1105 if (mDone)
return false;
1109 if (
int(mLevel) > mMinLevel && mIterList.
test(mLevel)) {
1110 if (!mIterList.
down(mLevel))
return false;
1114 while (!mIterList.
test(mLevel)) {
1121 mIterList.
next(mLevel);
1124 if (!mIterList.
down(mLevel))
return false;
1127 }
while (
int(mLevel) < mMinLevel || int(mLevel) > mMaxLevel);
1132 template<
typename TreeT,
typename RootChildOnIterT>
1139 return root ? root->getMinIndex() :
Coord::min();
1143 template<
typename TreeT,
typename RootChildOnIterT>
1150 if (root ==
nullptr) {
1154 root->getIndexRange(bbox);
1157 bbox.min() = mIterList.
getCoord(mLevel + 1);
1158 bbox.max() = bbox.min().offsetBy(mIterList.
getChildDim(mLevel + 1) - 1);
1163 template<
typename TreeT,
typename RootChildOnIterT>
1167 std::ostringstream ostr;
1168 for (
int lvl =
int(
ROOT_LEVEL); lvl >= 0 && lvl >= int(mLevel); --lvl) {
1169 if (lvl == 0) ostr <<
"leaf";
1170 else if (lvl ==
int(
ROOT_LEVEL)) ostr <<
"root";
1172 ostr <<
" c" << mIterList.
pos(lvl);
1173 if (lvl >
int(mLevel)) ostr <<
" / ";
1177 ostr <<
" " << bbox;
1186 template<
typename TreeT,
typename RootChildOnIterT>
1206 mIterList.setIter(RootIterTraits::begin(tree.root()));
1209 for ( ; lvl > 0 && mIterList.down(lvl); --lvl) {}
1211 if (lvl > 0) this->
next();
1216 mIterList.updateBackPointers();
1220 if (&other !=
this) {
1221 mTree = other.mTree;
1222 mIterList = other.mIterList;
1233 mIterList.getNode(LEAF_LEVEL, n);
1240 bool test()
const {
return mIterList.test(LEAF_PARENT_LEVEL); }
1255 struct PrevItem {
using IterT =
RootIterT; };
1265 template<
typename TreeT,
typename RootChildOnIterT>
1271 if (mIterList.test(LEAF_PARENT_LEVEL) && mIterList.next(LEAF_PARENT_LEVEL)) {
1272 mIterList.down(LEAF_PARENT_LEVEL);
1276 Index lvl = LEAF_PARENT_LEVEL;
1277 while (!mIterList.test(LEAF_PARENT_LEVEL)) {
1278 if (mIterList.test(lvl)) {
1279 mIterList.next(lvl);
1286 if (mIterList.test(lvl)) mIterList.next(lvl);
1287 }
while (!mIterList.test(lvl));
1290 while (lvl > LEAF_PARENT_LEVEL && mIterList.down(lvl)) --lvl;
1292 mIterList.down(LEAF_PARENT_LEVEL);
1302 template<
typename IterT>
1311 mGrainSize(grainSize),
1314 mSize = this->size();
1322 mGrainSize(other.mGrainSize),
1323 mSize(other.mSize >> 1)
1333 bool empty()
const {
return mSize == 0 || !mIter.test(); }
1342 void increment(
size_t n = 1) {
for ( ; n > 0 && mSize > 0; --n, --mSize, ++mIter) {} }
1350 size_t size()
const {
size_t n = 0;
for (IterT it(mIter); it.test(); ++n, ++it) {}
return n; }
1353 size_t mGrainSize, mSize;
1371 #endif // OPENVDB_TREE_TREEITERATOR_HAS_BEEN_INCLUDED typename NodeT::ChildAllIter IterT
Definition: TreeIterator.h:114
LeafNodeT * getLeaf() const
Return the leaf node to which the iterator is pointing.
Definition: TreeIterator.h:1230
static IterT begin(NodeT &node)
Definition: TreeIterator.h:115
Index getLevel() const
Return the level in the tree (0 = leaf) of the node to which this iterator is currently pointing...
Definition: TreeIterator.h:981
const NCValueT & getValue(Index lvl) const
Definition: TreeIterator.h:469
void getNode(Index lvl, OtherNodeT *&node) const
Definition: TreeIterator.h:428
const ValueT & operator*() const
Return the tile or voxel value to which this iterator is currently pointing.
Definition: TreeIterator.h:694
static const Index ROOT_LEVEL
Definition: TreeIterator.h:625
RootChildOnIterT RootIterT
Definition: TreeIterator.h:1190
typename ValueIterT::NodeType NodeT
Definition: TreeIterator.h:622
Coord getCoord() const
Return the global coordinates of the voxel or tile to which this iterator is currently pointing...
Definition: TreeIterator.h:672
void increment(Index n)
Increment the iterator n times.
Definition: TreeIterator.h:1250
static IterT begin(NodeT &node)
Definition: TreeIterator.h:143
void setMaxDepth(Index maxDepth)
Specify the depth of the lowest level of the tree to which to descend (depth 0 = root).
Definition: TreeIterator.h:1092
typename IterT::NonConstNodeType NCNodeT
The type of the node with const qualifiers removed ("Non-Const")
Definition: TreeIterator.h:519
typename SubtreeT::template Append< HeadT > Type
Definition: TreeIterator.h:35
void setValueOn(Index lvl, bool on=true) const
Definition: TreeIterator.h:595
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:297
std::string summary() const
Definition: TreeIterator.h:1165
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:310
LeafIteratorBase & operator++()
Advance the iterator to the next leaf node.
Definition: TreeIterator.h:1247
void setMinDepth(Index minDepth)
Specify the depth of the highest level of the tree to which to ascend (depth 0 = root).
Definition: TreeIterator.h:1083
typename IterT::NodeType NodeT
The type of node over which IterT iterates (e.g., const RootNode<...>)
Definition: TreeIterator.h:517
bool next()
Advance to the next tile or voxel value. Return true if this iterator is not yet exhausted.
Definition: TreeIterator.h:806
void increment()
Advance the iterator to the next leaf node.
Definition: TreeIterator.h:1246
typename iter::InvertedTree< NCRootNodeT, ROOT_LEVEL >::Type InvTreeT
Definition: TreeIterator.h:1194
typename RootIterT::NodeType RootNodeT
Definition: TreeIterator.h:941
IterListItem(PrevItemT *prev)
Definition: TreeIterator.h:239
static ChildT * getChild(const IterT &)
Definition: TreeIterator.h:62
void setIter(const IterT &iter)
Definition: TreeIterator.h:547
Base class for tree-traversal iterators over tile and voxel values.
Definition: TreeIterator.h:617
static IterT begin(NodeT &node)
Definition: TreeIterator.h:69
Index pos(Index lvl) const
Return The table offset of the iterator at level lvl of the tree.
Definition: TreeIterator.h:287
IterListItem & operator=(const IterListItem &other)
Definition: TreeIterator.h:533
IterListItem(PrevItemT *prev)
Definition: TreeIterator.h:530
typename IterT::NonConstValueType NCValueT
The type of value (with const qualifiers removed) to which the iterator points.
Definition: TreeIterator.h:395
_TreeT TreeT
Definition: TreeIterator.h:620
typename OtherNodeT::ChildAllIter Type
Definition: TreeIterator.h:121
IteratorRange & operator++()
Advance the iterator to the next item.
Definition: TreeIterator.h:1344
Index getMinDepth() const
Return the depth of the highest level of the tree to which this iterator ascends. ...
Definition: TreeIterator.h:958
IterListItem(const IterListItem &other)
Definition: TreeIterator.h:241
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:668
uint64_t Index64
Definition: Types.h:53
bool next()
Advance to the next tile or voxel value.
Definition: TreeIterator.h:1102
Index64 getVoxelCount(Index lvl) const
Definition: TreeIterator.h:459
typename OtherNodeT::ChildAllCIter Type
Definition: TreeIterator.h:135
typename NodeT::ChildOffCIter IterT
Definition: TreeIterator.h:104
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:340
typename OtherNodeT::ChildOffIter Type
Definition: TreeIterator.h:97
IterListItem & operator=(const IterListItem &other)
Definition: TreeIterator.h:243
IteratorRange(IteratorRange &other, tbb::split)
Split constructor used by tbb (should rarely be called directly)
Definition: TreeIterator.h:1320
typename PrevItem::IterT PrevIterT
The type of iterator stored in the previous list item.
Definition: TreeIterator.h:218
typename NodeT::ChildAllCIter IterT
Definition: TreeIterator.h:128
void modifyValue(Index lvl, const ModifyOp &op) const
Definition: TreeIterator.h:489
IterListItem(const IterListItem &other)
Definition: TreeIterator.h:532
A list of types (not necessarily unique)
Definition: TypeList.h:577
void setValue(Index lvl, const NCValueT &val) const
Definition: TreeIterator.h:594
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:290
static ChildT * getChild(const IterT &iter)
Definition: TreeIterator.h:130
void setValueOff(Index lvl) const
Definition: TreeIterator.h:596
bool next(Index lvl)
Definition: TreeIterator.h:568
typename std::remove_const< ToType >::type Type
Definition: Types.h:439
bool test() const
Return true if this iterator is not yet exhausted.
Definition: TreeIterator.h:966
typename InvTreeT::Front _NodeT
The type of node (non-const) whose iterator is stored in this list item.
Definition: TreeIterator.h:220
Index getMinDepth() const
Return the depth of the highest level of the tree to which this iterator ascends. ...
Definition: TreeIterator.h:637
void updateBackPointers(PrevItemT *prev)
Definition: TreeIterator.h:253
IterListItem & operator=(const IterListItem &other)
Definition: TreeIterator.h:404
An IterListItem is an element of a compile-time linked list of iterators to nodes of different types...
Definition: TreeIterator.h:214
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:713
static Index getLeafDepth()
Definition: TreeIterator.h:985
Coord getCoord() const
Return the global coordinates of the voxel or tile to which this iterator is currently pointing...
Definition: TreeIterator.h:1134
_ValueIterT ValueIterT
Definition: TreeIterator.h:621
bool isValueOn(Index lvl) const
Definition: TreeIterator.h:585
LeafNodeT & operator*() const
Return the leaf node to which the iterator is pointing.
Definition: TreeIterator.h:1236
static ChildT * getChild(const IterT &iter)
Definition: TreeIterator.h:116
typename CopyConstness< NodeT, typename NodeT::ChildNodeType >::Type ChildT
NodeT's child node type, with the same constness (e.g., const InternalNode<...>)
Definition: TreeIterator.h:232
void setValueOff(Index lvl) const
Mark the value to which the iterator at level lvl of the tree points as inactive. ...
Definition: TreeIterator.h:354
const NCValueT & getValue(Index lvl) const
Definition: TreeIterator.h:587
typename OtherNodeT::ChildOffCIter Type
Definition: TreeIterator.h:107
static IterT begin(const NodeT &node)
Definition: TreeIterator.h:105
bool test() const
Return true if this iterator is not yet exhausted.
Definition: TreeIterator.h:645
typename NodeVecT::Front _NodeT
The type of node (non-const) whose iterator is stored in this list item.
Definition: TreeIterator.h:385
static const Index LEAF_LEVEL
Definition: TreeIterator.h:627
Index32 Index
Definition: Types.h:54
typename OtherNodeT::ValueAllCIter Type
Definition: TreeIterator.h:195
static Index getLeafDepth()
Definition: TreeIterator.h:661
Index getMaxDepth() const
Return the depth of the lowest level of the tree to which this iterator ascends.
Definition: TreeIterator.h:641
LeafNodeT * operator->() const
Return the leaf node to which the iterator is pointing.
Definition: TreeIterator.h:1237
void setValueOff(Index lvl) const
Definition: TreeIterator.h:483
Index64 getVoxelCount(Index lvl) const
Return the number of (virtual) voxels spanned by a tile value or child node.
Definition: TreeIterator.h:319
void setValueOff() const
Mark the tile or voxel value to which this iterator is currently pointing as inactive.
Definition: TreeIterator.h:705
Index64 getVoxelCount(Index lvl) const
Definition: TreeIterator.h:583
bool isValueOn(Index lvl) const
Definition: TreeIterator.h:464
Definition: TreeIterator.h:1303
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:597
CoordBBox getBoundingBox() const
Return the axis-aligned bounding box of the voxel or tile to which this iterator is currently pointin...
Definition: TreeIterator.h:996
typename InvertedTree< typename HeadT::ChildNodeType, HeadLevel-1 >::Type SubtreeT
Definition: TreeIterator.h:34
Base class for tree-traversal iterators over all leaf nodes (but not leaf voxels) ...
Definition: TreeIterator.h:1187
static IterT begin(const NodeT &node)
Definition: TreeIterator.h:193
void setIter(const OtherIterT &iter)
Definition: TreeIterator.h:257
void split(ContainerT &out, const std::string &in, const char delim)
Definition: Name.h:43
typename PrevItemT::IterT PrevIterT
The type of iterator stored in the previous list item.
Definition: TreeIterator.h:511
typename NodeT::ChildOnCIter ChildOnIterT
Definition: TreeIterator.h:624
IterListItem(PrevItemT *)
Definition: TreeIterator.h:400
void updateBackPointers(PrevItemT *prev)
Definition: TreeIterator.h:542
void getNode(NodeT *&node) const
Return the node to which the iterator is pointing.
Definition: TreeIterator.h:1003
typename OtherNodeT::ValueOnCIter Type
Definition: TreeIterator.h:155
bool down(Index lvl)
Definition: TreeIterator.h:448
typename NodeT::ValueOnCIter IterT
Definition: TreeIterator.h:152
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:1339
static IterT begin(NodeT &node)
Definition: TreeIterator.h:95
RootChildOnIterT RootIterT
Definition: TreeIterator.h:940
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:223
typename OtherNodeT::ChildOnIter Type
Definition: TreeIterator.h:74
Base class for tree-traversal iterators over all nodes.
Definition: TreeIterator.h:936
#define OPENVDB_ASSERT(X)
Definition: Assert.h:41
bool next(Index lvl)
Increment the iterator at level lvl of the tree.
Definition: TreeIterator.h:293
typename NodeT::ChildOnCIter IterT
Definition: TreeIterator.h:81
bool test(Index lvl) const
Definition: TreeIterator.h:566
typename InvTreeT::Front NCLeafNodeT
Definition: TreeIterator.h:1195
static const ChildT * getChild(const IterT &iter)
Definition: TreeIterator.h:83
static const Index ROOT_DEPTH
Definition: TreeIterator.h:627
typename OtherNodeT::ValueOnIter Type
Definition: TreeIterator.h:145
void increment(size_t n=1)
Advance the iterator n times.
Definition: TreeIterator.h:1342
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:347
#define ROOT_LEVEL
Definition: CNanoVDB.h:53
typename NodeT::ValueAllIter IterT
Definition: TreeIterator.h:182
typename RootIterT::NonConstNodeType NCRootNodeT
Definition: TreeIterator.h:942
typename OtherNodeT::ValueOffCIter Type
Definition: TreeIterator.h:175
Index getChildDim(Index lvl) const
Definition: TreeIterator.h:314
void setMinDepth(Index minDepth)
Specify the depth of the highest level of the tree to which to ascend (depth 0 = root).
Definition: TreeIterator.h:787
NodeIteratorBase()
Definition: TreeIterator.h:1025
void modifyValue(Index lvl, const ModifyOp &op) const
Definition: TreeIterator.h:599
bool down(Index lvl)
Definition: TreeIterator.h:570
bool empty(const char *str)
tests if a c-string str is empty, that is its first value is '\0'
Definition: Util.h:144
typename CopyConstness< RootNodeT, NCLeafNodeT >::Type LeafNodeT
Definition: TreeIterator.h:1196
void getNode(Index lvl, NodeT *&node) const
Definition: TreeIterator.h:549
Definition: Exceptions.h:13
bool isValueOn() const
Return true if the value to which this iterator is currently pointing is active.
Definition: TreeIterator.h:689
TreeT * getTree() const
Definition: TreeIterator.h:1008
bool isTileValue() const
Return true if this iterator is currently pointing to a (non-leaf) tile value.
Definition: TreeIterator.h:685
Coord getCoord(Index lvl) const
Definition: TreeIterator.h:450
void modifyValue(Index lvl, const ModifyOp &op) const
Apply a functor to the item to which this iterator is pointing.
Definition: TreeIterator.h:362
static IterT begin(const NodeT &node)
Definition: TreeIterator.h:82
typename NodeT::ValueOnIter IterT
Definition: TreeIterator.h:142
Level
Message severity level.
Definition: logging.h:31
typename NodeT::ChildOnIter IterT
Definition: TreeIterator.h:68
TreeValueIteratorBase & operator++()
Advance to the next tile or voxel value.
Definition: TreeIterator.h:653
const IterT & iterator() const
Return a reference to this range's iterator.
Definition: TreeIterator.h:1331
Coord getCoord(Index lvl) const
Definition: TreeIterator.h:581
IterListItem(const IterListItem &other)
Definition: TreeIterator.h:402
typename NodeT::ValueOffIter IterT
Definition: TreeIterator.h:162
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:388
LeafIteratorBase(TreeT &tree)
Definition: TreeIterator.h:1203
typename RootIterT::NonConstNodeType NCRootNodeT
Definition: TreeIterator.h:1192
LeafIteratorBase & operator=(const LeafIteratorBase &other)
Definition: TreeIterator.h:1218
void setValueOn(Index lvl, bool on=true) const
Definition: TreeIterator.h:479
NodeIteratorBase & operator=(const NodeIteratorBase &other)
Definition: TreeIterator.h:1066
Definition: TreeIterator.h:60
void setMaxDepth(Index maxDepth)
Specify the depth of the lowest level of the tree to which to descend (depth 0 = root).
Definition: TreeIterator.h:796
typename ValueIterT::NonConstValueType ValueT
Definition: TreeIterator.h:623
typename NodeT::ValueAllCIter IterT
Definition: TreeIterator.h:192
typename IterT::NonConstValueType NCValueT
The type of value (with const qualifiers removed) to which the iterator points.
Definition: TreeIterator.h:230
typename OtherNodeT::ValueAllIter Type
Definition: TreeIterator.h:185
const ValueT & getValue() const
Return the tile or voxel value to which this iterator is currently pointing.
Definition: TreeIterator.h:693
void increment()
Advance the iterator to the next leaf node.
Definition: TreeIterator.h:974
static IterT begin(NodeT &node)
Definition: TreeIterator.h:183
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:274
bool isValueOn(Index lvl) const
Return true if the iterator at level lvl of the tree points to an active value.
Definition: TreeIterator.h:325
Index pos(Index lvl) const
Definition: TreeIterator.h:442
Definition: TreeIterator.h:33
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:700
TreeValueIteratorBase(TreeT &)
Definition: TreeIterator.h:738
typename IterT::NonConstNodeType NCNodeT
The type of the node with const qualifiers removed ("Non-Const")
Definition: TreeIterator.h:393
typename RootIterT::NodeType RootNodeT
Definition: TreeIterator.h:1191
void setIter(const IterT &iter)
Definition: TreeIterator.h:419
bool empty() const
Definition: TreeIterator.h:1333
Index getLevel() const
Return the level in the tree (0 = leaf) of the node to which this iterator is currently pointing...
Definition: TreeIterator.h:657
bool test(Index lvl) const
Definition: TreeIterator.h:444
bool next(Index lvl)
Definition: TreeIterator.h:446
typename CopyConstness< NCNodeT, typename NCNodeT::ChildNodeType >::Type NCChildT
NodeT's child node type with const qualifiers removed.
Definition: TreeIterator.h:525
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:514
Index getChildDim(Index lvl) const
Definition: TreeIterator.h:582
void setValue(Index lvl, const NCValueT &val) const
Definition: TreeIterator.h:475
void initLevel(Index lvl, OtherIterListItemT &otherListItem)
Definition: TreeIterator.h:431
NodeIteratorBase & operator++()
Definition: TreeIterator.h:975
static IterT begin(const NodeT &node)
Definition: TreeIterator.h:153
typename iter::InvertedTree< NCRootNodeT, ROOT_LEVEL >::Type InvTreeT
Definition: TreeIterator.h:944
void getNode(Index lvl, NodeT *&node) const
Definition: TreeIterator.h:423
Index getDepth() const
Return the depth in the tree (0 = root) of the node to which this iterator is currently pointing...
Definition: TreeIterator.h:984
typename IterT::NonConstNodeType NCNodeT
The type of the node with const qualifiers removed ("Non-Const")
Definition: TreeIterator.h:228
static const Index ROOT_LEVEL
Definition: TreeIterator.h:943
void initLevel(Index lvl, OtherIterListItemT &otherListItem)
Definition: TreeIterator.h:555
static IterT begin(const NodeT &node)
Definition: TreeIterator.h:129
TreeT * getTree() const
Definition: TreeIterator.h:1252
const ValueT * operator->() const
Return the tile or voxel value to which this iterator is currently pointing.
Definition: TreeIterator.h:695
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:703
IteratorRange(const IterT &iter, size_t grainSize=8)
Constructor from iterator and grain size.
Definition: TreeIterator.h:1309
typename PrevItemT::IterT PrevIterT
The type of iterator stored in the previous list item.
Definition: TreeIterator.h:383
_TreeT TreeT
Definition: TreeIterator.h:939
typename CopyConstness< NodeT, typename NodeT::ChildNodeType >::Type ChildT
NodeT's child node type, with the same constness (e.g., const InternalNode<...>)
Definition: TreeIterator.h:523
typename OtherNodeT::ValueOffIter Type
Definition: TreeIterator.h:165
bool test() const
Definition: TreeIterator.h:1334
void getNode(const NodeT *&node) const
Return the node to which the iterator is pointing.
Definition: TreeIterator.h:1005
void setIter(const IterT &iter)
Definition: TreeIterator.h:255
typename IterT::NodeType NodeT
The type of node (const or non-const) over which IterT iterates (e.g., const RootNode<...>)
Definition: TreeIterator.h:391
Index64 getVoxelCount() const
Return the number of (virtual) voxels corresponding to the value.
Definition: TreeIterator.h:682
typename NodeT::ValueOffCIter IterT
Definition: TreeIterator.h:172
void increment(Index n)
Increment the iterator n times.
Definition: TreeIterator.h:977
bool next()
Advance the iterator to the next item.
Definition: TreeIterator.h:1347
typename OtherNodeT::ChildOnCIter Type
Definition: TreeIterator.h:87
bool test() const
Definition: TreeIterator.h:1240
typename CopyConstness< NCNodeT, typename NCNodeT::ChildNodeType >::Type NCChildT
NodeT's child node type with const qualifiers removed.
Definition: TreeIterator.h:234
void setIter(const OtherIterT &iter)
Definition: TreeIterator.h:421
Index getChildDim(Index lvl) const
Definition: TreeIterator.h:454
typename IterT::NonConstValueType NCValueT
The type of value (with const qualifiers removed) to which the iterator points.
Definition: TreeIterator.h:521
std::string summary() const
Return a string (for debugging, mainly) describing this iterator's current state. ...
Definition: TreeIterator.h:909
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition: version.h.in:121
TreeT * getTree() const
Return a pointer to the tree over which this iterator is iterating.
Definition: TreeIterator.h:716
Index getMaxDepth() const
Return the depth of the lowest level of the tree to which this iterator ascends.
Definition: TreeIterator.h:962
typename NodeVecT::Front _NodeT
Definition: TreeIterator.h:509
void getNode(Index lvl, NodeT *&node) const
Return the node over which this list element's iterator iterates.
Definition: TreeIterator.h:260
bool isVoxelValue() const
Return true if this iterator is currently pointing to a (leaf) voxel value.
Definition: TreeIterator.h:687
void updateBackPointers(PrevItemT *=nullptr)
Definition: TreeIterator.h:414
static IterT begin(NodeT &node)
Definition: TreeIterator.h:163
LeafIteratorBase(const LeafIteratorBase &other)
Definition: TreeIterator.h:1214
TreeValueIteratorBase & operator=(const TreeValueIteratorBase &other)
Definition: TreeIterator.h:769
Index pos(Index lvl) const
Definition: TreeIterator.h:564
static const Index LEAF_DEPTH
Definition: TreeIterator.h:627
bool next()
Advance the iterator to the next leaf node.
Definition: TreeIterator.h:1267
Index getDepth() const
Return the depth in the tree (0 = root) of the node to which this iterator is currently pointing...
Definition: TreeIterator.h:660
CoordBBox getBoundingBox() const
Return the axis-aligned bounding box of the voxel or tile to which this iterator is currently pointin...
Definition: TreeIterator.h:679
static IterT begin(const NodeT &node)
Definition: TreeIterator.h:173
typename NodeT::ChildOffIter IterT
Definition: TreeIterator.h:94
const NCValueT & getValue(Index lvl) const
Return the value to which the iterator at level lvl of the tree points.
Definition: TreeIterator.h:331
static ChildT * getChild(const IterT &iter)
Definition: TreeIterator.h:70
typename IterT::NodeType NodeT
The type of node (const or non-const) over which IterT iterates (e.g., const RootNode<...>)
Definition: TreeIterator.h:226
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h.in:218
LeafIteratorBase()
Definition: TreeIterator.h:1201
static const Index LEAF_LEVEL
Definition: TreeIterator.h:945
void getNode(Index lvl, OtherNodeT *&node) const
Return the node over which one of the following list elements' iterator iterates. ...
Definition: TreeIterator.h:266