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>
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>
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>
262 node = (lvl <=
Level) ? mIter.getParentNode() :
nullptr;
265 template<
typename OtherNodeT>
273 template<
typename OtherIterListItemT>
277 const NodeT* node =
nullptr;
278 otherListItem.getNode(lvl, node);
299 if (lvl ==
Level && mPrev !=
nullptr && mIter) {
300 if (
ChildT* child = ITraits::template getChild<ChildT>(mIter)) {
305 return (lvl >
Level) ? mNext.
down(lvl) :
false;
312 return (lvl ==
Level) ? mIter.getCoord() : mNext.
getCoord(lvl);
333 if (lvl ==
Level)
return mIter.getValue();
342 if (lvl ==
Level) mIter.setValue(val);
else mNext.
setValue(lvl, val);
349 if (lvl ==
Level) mIter.setValueOn(on);
else mNext.
setValueOn(lvl, on);
361 template<
typename ModifyOp>
368 using RestT =
typename NodeVecT::PopFront;
378 template<
typename PrevItemT,
typename NodeVecT,
size_t VecSize>
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) {
420 template<
typename OtherIterT>
425 node = (lvl == 0) ? mIter.getParentNode() :
nullptr;
427 template<
typename OtherNodeT>
430 template<
typename OtherIterListItemT>
434 const NodeT* node =
nullptr;
435 otherListItem.getNode(lvl, node);
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); }
452 return (lvl == 0) ? mIter.getCoord() : mNext.
getCoord(lvl);
456 return (lvl == 0) ? NodeT::getChildDim() : mNext.
getChildDim(lvl);
466 return (lvl == 0) ? mIter.isValueOn() : mNext.
isValueOn(lvl);
471 if (lvl == 0)
return mIter.getValue();
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>
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);
572 if (lvl ==
Level && mPrev !=
nullptr && mIter) {
573 if (
ChildT* child = ITraits::template getChild<ChildT>(mIter)) {
591 return mIter.getValue();
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");
645 bool test()
const {
return mValueIterList.
test(mLevel); }
667 template<
typename NodeType>
712 template<
typename ModifyOp>
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;
778 mChildIterList.updateBackPointers();
779 mValueIterList.updateBackPointers();
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)) {
922 ostr <<
" " << this->getCoord();
924 ostr <<
" " << this->getBoundingBox();
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>
1028 mMinLevel(
int(LEAF_LEVEL)),
1036 template<
typename TreeT,
typename RootChildOnIterT>
1041 mMinLevel(
int(LEAF_LEVEL)),
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>
1136 if (mLevel !=
ROOT_LEVEL)
return mIterList.getCoord(mLevel + 1);
1138 this->getNode(root);
1139 return root ? root->getMinIndex() :
Coord::min();
1143 template<
typename TreeT,
typename RootChildOnIterT>
1149 this->getNode(root);
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 <<
" / ";
1176 this->getBoundingBox(bbox);
1177 ostr <<
" " << bbox;
1186 template<
typename TreeT,
typename RootChildOnIterT>
1209 for ( ; lvl > 0 && mIterList.
down(lvl); --lvl) {}
1211 if (lvl > 0) this->
next();
1220 if (&other !=
this) {
1221 mTree = other.mTree;
1222 mIterList = other.mIterList;
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
Index getMaxDepth() const
Return the depth of the lowest level of the tree to which this iterator ascends.
Coord getCoord() const
Return the global coordinates of the voxel or tile to which this iterator is currently pointing...
std::string summary() const
Return a string (for debugging, mainly) describing this iterator's current state. ...
const NCValueT & getValue(Index lvl) const
Return the value to which the iterator at level lvl of the tree points.
Index getMinDepth() const
Return the depth of the highest level of the tree to which this iterator ascends. ...
IterListItem & operator=(const IterListItem &other)
Index getDepth() const
Return the depth in the tree (0 = root) of the node to which this iterator is currently pointing...
typedef int(APIENTRYP RE_PFNGLXSWAPINTERVALSGIPROC)(int)
typename OtherNodeT::ChildOffIter Type
cvex test(vector P=0;int unbound=3;export float s=0;export vector Cf=0;)
NodeIteratorBase & operator++()
static IterT begin(NodeT &node)
const IterT & iterator() const
Return a reference to this range's iterator.
bool down(Index lvl)
If the iterator at level lvl of the tree points to a child node, initialize the next iterator in this...
IterListItem & operator=(const IterListItem &other)
void setIter(const OtherIterT &iter)
static Index getLeafDepth()
typename ValueIterT::NodeType NodeT
static IterT begin(const NodeT &node)
void initLevel(Index lvl, OtherIterListItemT &otherListItem)
typename iter::InvertedTree< NCRootNodeT, ROOT_LEVEL >::Type InvTreeT
bool is_divisible() const
Return true if this range is splittable (i.e., if the iterator can be advanced more than mGrainSize t...
static const Index ROOT_LEVEL
bool next()
Advance to the next tile or voxel value. Return true if this iterator is not yet exhausted.
void getNode(Index lvl, NodeT *&node) const
typename OtherNodeT::ChildOffCIter Type
void getNode(const NodeT *&node) const
Return the node to which the iterator is pointing.
Index getLevel() const
Return the level in the tree (0 = leaf) of the node to which this iterator is currently pointing...
LeafNodeT & operator*() const
Return the leaf node to which the iterator is pointing.
typename SubtreeT::template Append< HeadT > Type
void setValueOff() const
Mark the tile or voxel value to which this iterator is currently pointing as inactive.
Index getMinDepth() const
Return the depth of the highest level of the tree to which this iterator ascends. ...
typename CopyConstness< NCNodeT, typename NCNodeT::ChildNodeType >::Type NCChildT
NodeT's child node type with const qualifiers removed.
void updateBackPointers(PrevItemT *prev)
Base class for tree-traversal iterators over all nodes.
static const Index ROOT_LEVEL
void setValueOn(Index lvl, bool on=true) const
static Index getLeafDepth()
static ChildT * getChild(const IterT &iter)
typename RootIterT::NodeType RootNodeT
#define OPENVDB_USE_VERSION_NAMESPACE
typename OtherNodeT::ValueOnCIter Type
bool isValueOn(Index lvl) const
IterListItem(const IterListItem &other)
ImageBuf OIIO_API min(Image_or_Const A, Image_or_Const B, ROI roi={}, int nthreads=0)
**But if you need a or simply need to know when the task has note that the like this
LeafIteratorBase(TreeT &tree)
IterListItem(PrevItemT *prev)
Coord getCoord() const
Return the global coordinates of the voxel or tile to which this iterator is currently pointing...
void updateBackPointers(PrevItemT *prev)
typename CopyConstness< NCNodeT, typename NCNodeT::ChildNodeType >::Type NCChildT
NodeT's child node type with const qualifiers removed.
bool isValueOn(Index lvl) const
Return true if the iterator at level lvl of the tree points to an active value.
void increment()
Advance the iterator to the next leaf node.
static const Index LEAF_LEVEL
void getNode(Index lvl, NodeT *&node) const
Return the node over which this list element's iterator iterates.
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 ...
LeafIteratorBase(const LeafIteratorBase &other)
typename OtherNodeT::ChildAllIter Type
bool isValueOn() const
Return true if the value to which this iterator is currently pointing is active.
bool test(Index lvl) const
typename IterT::NonConstNodeType NCNodeT
The type of the node with const qualifiers removed ("Non-Const")
typename IterT::NonConstNodeType NCNodeT
The type of the node with const qualifiers removed ("Non-Const")
void setActiveState(bool on) const
Change the active/inactive state of the tile or voxel value to which this iterator is currently point...
std::string summary() const
void updateBackPointers(PrevItemT *=nullptr)
static IterT begin(const NodeT &node)
void setIter(const IterT &iter)
void setIter(const IterT &iter)
bool test(Index lvl) const
Return true if the iterator at level lvl of the tree has not yet reached its end. ...
void modifyValue(Index lvl, const ModifyOp &op) const
static ChildT * getChild(const IterT &iter)
typename NodeT::ValueAllIter IterT
TreeValueIteratorBase & operator++()
Advance to the next tile or voxel value.
typename IterT::NonConstValueType NCValueT
The type of value (with const qualifiers removed) to which the iterator points.
static IterT begin(NodeT &node)
const NCValueT & getValue(Index lvl) const
typename IterT::NodeType NodeT
The type of node (const or non-const) over which IterT iterates (e.g., const RootNode<...>)
void setMinDepth(Index minDepth)
Specify the depth of the highest level of the tree to which to ascend (depth 0 = root).
static const Index ROOT_LEVEL
#define OPENVDB_ASSERT(X)
typename InvTreeT::Front NCLeafNodeT
typename IterT::NonConstNodeType NCNodeT
The type of the node with const qualifiers removed ("Non-Const")
void initLevel(Index lvl, OtherIterListItemT &otherListItem)
Initialize the iterator for level lvl of the tree with the node over which the corresponding iterator...
typename OtherNodeT::ValueOnIter Type
typename OtherNodeT::ValueAllCIter Type
typename NodeT::ChildOnCIter ChildOnIterT
const ValueT & operator*() const
Return the tile or voxel value to which this iterator is currently pointing.
void increment(Index n)
Increment the iterator n times.
NodeIteratorBase & operator=(const NodeIteratorBase &other)
Index pos(Index lvl) const
Coord getCoord(Index lvl) const
void setIter(const OtherIterT &iter)
Index64 getVoxelCount(Index lvl) const
Index64 getVoxelCount(Index lvl) const
Return the number of (virtual) voxels spanned by a tile value or child node.
bool next()
Advance the iterator to the next item.
typename iter::InvertedTree< NCRootNodeT, ROOT_LEVEL >::Type InvTreeT
typename RootIterT::NonConstNodeType NCRootNodeT
typename NodeT::ChildOnIter IterT
CoordBBox getBoundingBox() const
Return the axis-aligned bounding box of the voxel or tile to which this iterator is currently pointin...
bool isValueOn(Index lvl) const
typename NodeT::ChildOnCIter IterT
void setValueOn(Index lvl, bool on=true) const
typename NodeT::ChildAllCIter IterT
static IterT begin(NodeT &node)
const ValueT & getValue() const
Return the tile or voxel value to which this iterator is currently pointing.
void getNode(Index lvl, NodeT *&node) const
RootChildOnIterT RootIterT
void setValue(Index lvl, const NCValueT &val) const
TreeValueIteratorBase & operator=(const TreeValueIteratorBase &other)
typename OtherNodeT::ChildAllCIter Type
static IterT begin(const NodeT &node)
bool test() const
Return true if this iterator is not yet exhausted.
typename std::remove_const< ToType >::type Type
void setValueOff(Index lvl) const
const ValueT * operator->() const
Return the tile or voxel value to which this iterator is currently pointing.
typename NodeT::ValueOffIter IterT
typename OtherNodeT::ChildOnIter Type
static ChildT * getChild(const IterT &iter)
typename OtherNodeT::ValueOffCIter Type
bool test() const
Return true if this iterator is not yet exhausted.
static const Index LEAF_LEVEL
Coord getCoord(Index lvl) const
typename IterTraits< typename PrevIterT::NonConstNodeType, PrevIterT >::template NodeConverter< _NodeT >::Type IterT
The type of iterator stored in this list item (e.g., InternalNode::ValueOnCIter)
typename IterT::NodeType NodeT
The type of node over which IterT iterates (e.g., const RootNode<...>)
typename IterT::NodeType NodeT
The type of node (const or non-const) over which IterT iterates (e.g., const RootNode<...>)
Index getChildDim(Index lvl) const
static const Index ROOT_DEPTH
typename CopyConstness< NodeT, typename NodeT::ChildNodeType >::Type ChildT
NodeT's child node type, with the same constness (e.g., const InternalNode<...>)
static IterT begin(NodeT &node)
Index pos(Index lvl) const
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...
void setMaxDepth(Index maxDepth)
Specify the depth of the lowest level of the tree to which to descend (depth 0 = root).
typename OtherNodeT::ValueOffIter Type
typename InvertedTree< typename HeadT::ChildNodeType, HeadLevel-1 >::Type SubtreeT
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...
static const Index LEAF_LEVEL
GLboolean GLboolean GLboolean b
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...
static const Index LEAF_PARENT_LEVEL
typename PrevItemT::IterT PrevIterT
The type of iterator stored in the previous list item.
typename ValueIterT::NonConstValueType ValueT
typename OtherNodeT::ValueAllIter Type
IterListItem & operator=(const IterListItem &other)
typename NodeT::ChildOffIter IterT
typename NodeVecT::Front _NodeT
The type of node (non-const) whose iterator is stored in this list item.
void getNode(NodeT *&node) const
Return the node to which the iterator is pointing.
TreeValueIteratorBase(TreeT &)
Index64 getVoxelCount() const
Return the number of (virtual) voxels corresponding to the value.
typename IterTraits< typename PrevIterT::NonConstNodeType, PrevIterT >::template NodeConverter< _NodeT >::Type IterT
The type of iterator stored in this list item (e.g., RootNode::ValueOnCIter)
LeafNodeT * operator->() const
Return the leaf node to which the iterator is pointing.
bool isVoxelValue() const
Return true if this iterator is currently pointing to a (leaf) voxel value.
void getNode(Index lvl, OtherNodeT *&node) const
Return the node over which one of the following list elements' iterator iterates. ...
typename NodeVecT::Front _NodeT
LeafIteratorBase & operator++()
Advance the iterator to the next leaf node.
typename PrevItemT::IterT PrevIterT
The type of iterator stored in the previous list item.
LeafIteratorBase & operator=(const LeafIteratorBase &other)
typename NodeT::ChildAllIter IterT
typename IterT::NonConstValueType NCValueT
The type of value (with const qualifiers removed) to which the iterator points.
Index getChildDim(Index lvl) const
Library and file format version numbers.
typename IterTraits< typename PrevIterT::NonConstNodeType, PrevIterT >::template NodeConverter< _NodeT >::Type IterT
The type of iterator stored in this list item (e.g., InternalNode::ValueOnCIter)
static IterT begin(NodeT &node)
Index pos(Index lvl) const
Return The table offset of the iterator at level lvl of the tree.
bool next(Index lvl)
Increment the iterator at level lvl of the tree.
static const Index ROOT_DEPTH
IteratorRange(const IterT &iter, size_t grainSize=8)
Constructor from iterator and grain size.
void increment()
Advance the iterator to the next leaf node.
void getNode(Index lvl, OtherNodeT *&node) const
void setMaxDepth(Index maxDepth)
Specify the depth of the lowest level of the tree to which to descend (depth 0 = root).
RootChildOnIterT RootIterT
bool next()
Advance to the next tile or voxel value.
typename RootIterT::NodeType RootNodeT
void initLevel(Index lvl, OtherIterListItemT &otherListItem)
Index getChildDim(Index lvl) const
Base class for tree-traversal iterators over tile and voxel values.
bool isTileValue() const
Return true if this iterator is currently pointing to a (non-leaf) tile value.
bool next()
Advance the iterator to the next leaf node.
IterListItem(const IterListItem &other)
void modifyValue(const ModifyOp &op) const
Apply a functor to the item to which this iterator is pointing. (Not valid for const iterators...
void setValue(Index lvl, const NCValueT &val) const
IteratorRange & operator++()
Advance the iterator to the next item.
typename PrevItem::IterT PrevIterT
The type of iterator stored in the previous list item.
IterListItem(PrevItemT *)
Index64 getVoxelCount(Index lvl) const
static const Index LEAF_DEPTH
typename NodeT::ChildOffCIter IterT
typename CopyConstness< RootNodeT, NCLeafNodeT >::Type LeafNodeT
CoordBBox getBoundingBox() const
Return the axis-aligned bounding box of the voxel or tile to which this iterator is currently pointin...
static IterT begin(const NodeT &node)
static const Index LEAF_DEPTH
typename NodeT::ValueOnIter IterT
static IterT begin(const NodeT &node)
IterListItem(const IterListItem &other)
IteratorRange(IteratorRange &other, tbb::split)
Split constructor used by tbb (should rarely be called directly)
IterListItem(PrevItemT *prev)
void setValue(const ValueT &val) const
Change the tile or voxel value to which this iterator is currently pointing and mark it as active...
void increment(size_t n=1)
Advance the iterator n times.
void modifyValue(Index lvl, const ModifyOp &op) const
Apply a functor to the item to which this iterator is pointing.
static IterT begin(const NodeT &node)
static const ChildT * getChild(const IterT &iter)
typename IterT::NonConstValueType NCValueT
The type of value (with const qualifiers removed) to which the iterator points.
void OIIO_UTIL_API split(string_view str, std::vector< string_view > &result, string_view sep=string_view(), int maxsplit=-1)
typename OtherNodeT::ChildOnCIter Type
void increment(Index n)
Increment the iterator n times.
typename NodeT::ValueOffCIter IterT
const NCValueT & getValue(Index lvl) const
An IterListItem is an element of a compile-time linked list of iterators to nodes of different types...
typename RootIterT::NonConstNodeType NCRootNodeT
typename CopyConstness< NodeT, typename NodeT::ChildNodeType >::Type ChildT
NodeT's child node type, with the same constness (e.g., const InternalNode<...>)
LeafNodeT * getLeaf() const
Return the leaf node to which the iterator is pointing.
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
TreeT * getTree() const
Return a pointer to the tree over which this iterator is iterating.
A list of types (not necessarily unique)
static const Index Level
NodeT's level in its tree (0 = LeafNode)
void setIter(const IterT &iter)
typename InvTreeT::Front _NodeT
The type of node (non-const) whose iterator is stored in this list item.
bool test(Index lvl) const
static ChildT * getChild(const IterT &)
void setMinDepth(Index minDepth)
Specify the depth of the highest level of the tree to which to ascend (depth 0 = root).
static IterT begin(NodeT &node)
Index getLevel() const
Return the level in the tree (0 = leaf) of the node to which this iterator is currently pointing...
void modifyValue(Index lvl, const ModifyOp &op) const
typename NodeT::ValueOnCIter IterT
typename NodeT::ValueAllCIter IterT
Base class for tree-traversal iterators over all leaf nodes (but not leaf voxels) ...
void setValueOff(Index lvl) const
Mark the value to which the iterator at level lvl of the tree points as inactive. ...
Index getDepth() const
Return the depth in the tree (0 = root) of the node to which this iterator is currently pointing...
Index getMaxDepth() const
Return the depth of the lowest level of the tree to which this iterator ascends.
void setValueOff(Index lvl) const
PcpNodeRef_ChildrenIterator begin(const PcpNodeRef::child_const_range &r)
Support for range-based for loops for PcpNodeRef children ranges.