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>
21#define ENABLE_TREE_VALUE_DEPTH_BOUND_OPTIMIZATION
31template<
typename HeadT,
int HeadLevel>
34 using Type =
typename SubtreeT::template Append<HeadT>;
36template<
typename HeadT>
58template<
typename NodeT,
typename IterT>
61 template<
typename ChildT>
static ChildT*
getChild(
const IterT&) {
return nullptr; }
64template<
typename NodeT>
67 using IterT =
typename NodeT::ChildOnIter;
68 static IterT begin(NodeT& node) {
return node.beginChildOn(); }
70 return &iter.getValue();
72 template<
typename OtherNodeT>
struct NodeConverter {
73 using Type =
typename OtherNodeT::ChildOnIter;
77template<
typename NodeT>
80 using IterT =
typename NodeT::ChildOnCIter;
81 static IterT begin(
const NodeT& node) {
return node.cbeginChildOn(); }
82 template<
typename ChildT>
static const ChildT*
getChild(
const IterT& iter) {
83 return &iter.getValue();
85 template<
typename OtherNodeT>
struct NodeConverter {
86 using Type =
typename OtherNodeT::ChildOnCIter;
90template<
typename NodeT>
93 using IterT =
typename NodeT::ChildOffIter;
94 static IterT begin(NodeT& node) {
return node.beginChildOff(); }
95 template<
typename OtherNodeT>
struct NodeConverter {
96 using Type =
typename OtherNodeT::ChildOffIter;
100template<
typename NodeT>
103 using IterT =
typename NodeT::ChildOffCIter;
104 static IterT begin(
const NodeT& node) {
return node.cbeginChildOff(); }
105 template<
typename OtherNodeT>
struct NodeConverter {
106 using Type =
typename OtherNodeT::ChildOffCIter;
110template<
typename NodeT>
113 using IterT =
typename NodeT::ChildAllIter;
114 static IterT begin(NodeT& node) {
return node.beginChildAll(); }
116 typename IterT::NonConstValueType val;
117 return iter.probeChild(val);
119 template<
typename OtherNodeT>
struct NodeConverter {
120 using Type =
typename OtherNodeT::ChildAllIter;
124template<
typename NodeT>
127 using IterT =
typename NodeT::ChildAllCIter;
128 static IterT begin(
const NodeT& node) {
return node.cbeginChildAll(); }
130 typename IterT::NonConstValueType val;
131 return iter.probeChild(val);
133 template<
typename OtherNodeT>
struct NodeConverter {
134 using Type =
typename OtherNodeT::ChildAllCIter;
138template<
typename NodeT>
141 using IterT =
typename NodeT::ValueOnIter;
142 static IterT begin(NodeT& node) {
return node.beginValueOn(); }
143 template<
typename OtherNodeT>
struct NodeConverter {
144 using Type =
typename OtherNodeT::ValueOnIter;
148template<
typename NodeT>
151 using IterT =
typename NodeT::ValueOnCIter;
152 static IterT begin(
const NodeT& node) {
return node.cbeginValueOn(); }
153 template<
typename OtherNodeT>
struct NodeConverter {
154 using Type =
typename OtherNodeT::ValueOnCIter;
158template<
typename NodeT>
161 using IterT =
typename NodeT::ValueOffIter;
162 static IterT begin(NodeT& node) {
return node.beginValueOff(); }
163 template<
typename OtherNodeT>
struct NodeConverter {
164 using Type =
typename OtherNodeT::ValueOffIter;
168template<
typename NodeT>
171 using IterT =
typename NodeT::ValueOffCIter;
172 static IterT begin(
const NodeT& node) {
return node.cbeginValueOff(); }
173 template<
typename OtherNodeT>
struct NodeConverter {
174 using Type =
typename OtherNodeT::ValueOffCIter;
178template<
typename NodeT>
181 using IterT =
typename NodeT::ValueAllIter;
182 static IterT begin(NodeT& node) {
return node.beginValueAll(); }
183 template<
typename OtherNodeT>
struct NodeConverter {
184 using Type =
typename OtherNodeT::ValueAllIter;
188template<
typename NodeT>
191 using IterT =
typename NodeT::ValueAllCIter;
192 static IterT begin(
const NodeT& node) {
return node.cbeginValueAll(); }
193 template<
typename OtherNodeT>
struct NodeConverter {
194 using Type =
typename OtherNodeT::ValueAllCIter;
212template<
typename PrevItemT,
typename NodeVecT,
size_t VecSize, Index _Level>
222 NodeConverter<_NodeT>::Type;
225 using NodeT =
typename IterT::NodeType;
227 using NCNodeT =
typename IterT::NonConstNodeType;
229 using NCValueT =
typename IterT::NonConstValueType;
241 mIter(other.mIter), mNext(other.mNext), mPrev(nullptr) {}
244 if (&other !=
this) {
255 template<
typename OtherIterT>
256 void setIter(
const OtherIterT& iter) { mNext.setIter(iter); }
261 node = (lvl <=
Level) ? mIter.getParentNode() :
nullptr;
264 template<
typename OtherNodeT>
265 void getNode(
Index lvl, OtherNodeT*& node)
const { mNext.getNode(lvl, node); }
272 template<
typename OtherIterListItemT>
276 const NodeT* node =
nullptr;
277 otherListItem.getNode(lvl, node);
278 mIter = (node ==
nullptr) ?
IterT() : ITraits::begin(*
const_cast<NodeT*
>(node));
281 mNext.initLevel(lvl, otherListItem);
289 bool test(
Index lvl)
const {
return (lvl ==
Level) ? mIter.test() : mNext.test(lvl); }
298 if (lvl ==
Level && mPrev !=
nullptr && mIter) {
299 if (
ChildT*
child = ITraits::template getChild<ChildT>(mIter)) {
300 mPrev->setIter(PrevItemT::ITraits::begin(*
child));
304 return (lvl >
Level) ? mNext.down(lvl) :
false;
311 return (lvl ==
Level) ? mIter.getCoord() : mNext.getCoord(lvl);
315 return (lvl ==
Level) ? NodeT::getChildDim() : mNext.getChildDim(lvl);
320 return (lvl ==
Level) ? ChildT::NUM_VOXELS : mNext.getVoxelCount(lvl);
326 return (lvl ==
Level) ? mIter.isValueOn() : mNext.isValueOn(lvl);
332 if (lvl ==
Level)
return mIter.getValue();
333 return mNext.getValue(lvl);
341 if (lvl ==
Level) mIter.setValue(val);
else mNext.setValue(lvl, val);
348 if (lvl ==
Level) mIter.setValueOn(on);
else mNext.setValueOn(lvl, on);
355 if (lvl ==
Level) mIter.setValueOff();
else mNext.setValueOff(lvl);
360 template<
typename ModifyOp>
363 if (lvl ==
Level) mIter.modifyValue(op);
else mNext.modifyValue(lvl, op);
367 using RestT =
typename NodeVecT::PopFront;
377template<
typename PrevItemT,
typename NodeVecT,
size_t VecSize>
387 NodeConverter<_NodeT>::Type;
390 using NodeT =
typename IterT::NodeType;
392 using NCNodeT =
typename IterT::NonConstNodeType;
394 using NCValueT =
typename IterT::NonConstValueType;
402 mIter(other.mIter), mNext(other.mNext), mPrev(nullptr) {}
405 if (&other !=
this) {
415 mPrev =
nullptr; mNext.updateBackPointers(
this);
419 template<
typename OtherIterT>
420 void setIter(
const OtherIterT& iter) { mNext.setIter(iter); }
424 node = (lvl == 0) ? mIter.getParentNode() :
nullptr;
426 template<
typename OtherNodeT>
427 void getNode(
Index lvl, OtherNodeT*& node)
const { mNext.getNode(lvl, node); }
429 template<
typename OtherIterListItemT>
433 const NodeT* node =
nullptr;
434 otherListItem.getNode(lvl, node);
435 mIter = (node ==
nullptr) ?
IterT() : ITraits::begin(*
const_cast<NodeT*
>(node));
437 mNext.initLevel(lvl, otherListItem);
441 Index pos(
Index lvl)
const {
return (lvl == 0) ? mIter.pos() : mNext.pos(lvl); }
443 bool test(
Index lvl)
const {
return (lvl == 0) ? mIter.test() : mNext.test(lvl); }
445 bool next(
Index lvl) {
return (lvl == 0) ? mIter.next() : mNext.next(lvl); }
447 bool down(
Index lvl) {
return (lvl == 0) ? false : mNext.down(lvl); }
451 return (lvl == 0) ? mIter.getCoord() : mNext.getCoord(lvl);
455 return (lvl == 0) ? NodeT::getChildDim() : mNext.getChildDim(lvl);
460 return (lvl == 0) ? 1 : mNext.getVoxelCount(lvl);
465 return (lvl == 0) ? mIter.isValueOn() : mNext.isValueOn(lvl);
470 if (lvl == 0)
return mIter.getValue();
471 return mNext.getValue(lvl);
476 if (lvl == 0) mIter.setValue(val);
else mNext.setValue(lvl, val);
480 if (lvl == 0) mIter.setValueOn(on);
else mNext.setValueOn(lvl, on);
484 if (lvl == 0) mIter.setValueOff();
else mNext.setValueOff(lvl);
487 template<
typename ModifyOp>
490 if (lvl == 0) mIter.modifyValue(op);
else mNext.modifyValue(lvl, op);
494 using RestT =
typename NodeVecT::PopFront;
504template<
typename PrevItemT,
typename NodeVecT, Index _Level>
513 NodeConverter<_NodeT>::Type;
516 using NodeT =
typename IterT::NodeType;
518 using NCNodeT =
typename IterT::NonConstNodeType;
520 using NCValueT =
typename IterT::NonConstValueType;
534 if (&other !=
this) {
550 node = (lvl <=
Level) ? mIter.getParentNode() :
nullptr;
553 template<
typename OtherIterListItemT>
557 const NodeT* node =
nullptr;
558 otherListItem.getNode(lvl, node);
559 mIter = (node ==
nullptr) ?
IterT() : ITraits::begin(*
const_cast<NodeT*
>(node));
571 if (lvl ==
Level && mPrev !=
nullptr && mIter) {
572 if (
ChildT*
child = ITraits::template getChild<ChildT>(mIter)) {
573 mPrev->setIter(PrevItemT::ITraits::begin(*
child));
588 assert(lvl ==
Level);
590 return mIter.getValue();
597 template<
typename ModifyOp>
600 if (lvl ==
Level) mIter.modifyValue(op);
615template<
typename _TreeT,
typename _ValueIterT>
621 using NodeT =
typename ValueIterT::NodeType;
622 using ValueT =
typename ValueIterT::NonConstValueType;
625 static_assert(ValueIterT::NodeType::LEVEL ==
ROOT_LEVEL,
"invalid value iterator node type");
634 void setMinDepth(
Index minDepth);
638 void setMaxDepth(
Index maxDepth);
644 bool test()
const {
return mValueIterList.test(mLevel); }
645 operator bool()
const {
return this->test(); }
666 template<
typename NodeType>
667 void getNode(NodeType*& node)
const { mValueIterList.getNode(mLevel, node); }
688 bool isValueOn()
const {
return mValueIterList.isValueOn(mLevel); }
711 template<
typename ModifyOp>
712 void modifyValue(
const ModifyOp& op)
const { mValueIterList.modifyValue(mLevel, op); }
718 std::string summary()
const;
721 bool advance(
bool dontIncrement =
false);
724 struct PrevChildItem {
using IterT = ChildOnIterT; };
725 struct PrevValueItem {
using IterT = ValueIterT; };
727 IterListItem<PrevChildItem, InvTreeT,
ROOT_LEVEL+1, 0> mChildIterList;
728 IterListItem<PrevValueItem, InvTreeT,
ROOT_LEVEL+1, 0> mValueIterList;
730 int mMinLevel, mMaxLevel;
735template<
typename TreeT,
typename ValueIterT>
738 mChildIterList(nullptr),
739 mValueIterList(nullptr),
741 mMinLevel(int(LEAF_LEVEL)),
751template<
typename TreeT,
typename ValueIterT>
754 mChildIterList(other.mChildIterList),
755 mValueIterList(other.mValueIterList),
756 mLevel(other.mLevel),
757 mMinLevel(other.mMinLevel),
758 mMaxLevel(other.mMaxLevel),
761 mChildIterList.updateBackPointers();
762 mValueIterList.updateBackPointers();
766template<
typename TreeT,
typename ValueIterT>
770 if (&other !=
this) {
771 mChildIterList = other.mChildIterList;
772 mValueIterList = other.mValueIterList;
773 mLevel = other.mLevel;
774 mMinLevel = other.mMinLevel;
775 mMaxLevel = other.mMaxLevel;
777 mChildIterList.updateBackPointers();
778 mValueIterList.updateBackPointers();
784template<
typename TreeT,
typename ValueIterT>
789 if (
int(mLevel) > mMaxLevel) this->next();
793template<
typename TreeT,
typename ValueIterT>
799 if (
int(mLevel) < mMinLevel) this->next();
803template<
typename TreeT,
typename ValueIterT>
808 if (!this->advance())
return false;
809 }
while (
int(mLevel) < mMinLevel ||
int(mLevel) > mMaxLevel);
814template<
typename TreeT,
typename ValueIterT>
818 bool recurse =
false;
822 vPos = mValueIterList.pos(mLevel),
823 cPos = mChildIterList.pos(mLevel);
824 if (vPos == cPos && mChildIterList.test(mLevel)) {
826 mValueIterList.
next(mLevel);
827 vPos = mValueIterList.pos(mLevel);
830 if (dontIncrement)
return true;
831 if (mValueIterList.next(mLevel)) {
832 if (mValueIterList.pos(mLevel) == cPos && mChildIterList.test(mLevel)) {
835 mValueIterList.next(mLevel);
838 if (mValueIterList.pos(mLevel) < cPos)
return true;
842 if (!dontIncrement) mChildIterList.next(mLevel);
844#ifdef DEBUG_TREE_VALUE_ITERATOR
845 std::cout <<
"\n" << this->summary() << std::flush;
849 while (mChildIterList.pos(mLevel) < mValueIterList.pos(mLevel)) {
850#ifdef ENABLE_TREE_VALUE_DEPTH_BOUND_OPTIMIZATION
851 if (
int(mLevel) == mMinLevel) {
854 mChildIterList.next(mLevel);
855 if (mValueIterList.pos(mLevel) == mChildIterList.pos(mLevel)
856 && mChildIterList.test(mLevel))
860 mValueIterList.next(mLevel);
864 if (mChildIterList.down(mLevel)) {
866 mValueIterList.initLevel(mLevel, mChildIterList);
867 if (mValueIterList.pos(mLevel) == mChildIterList.pos(mLevel)
868 && mChildIterList.test(mLevel))
872 mValueIterList.next(mLevel);
875#ifdef DEBUG_TREE_VALUE_ITERATOR
876 std::cout <<
"\n" << this->summary() << std::flush;
880 while (!mChildIterList.test(mLevel) && !mValueIterList.test(mLevel)) {
883 mChildIterList.next(mLevel);
884 dontIncrement =
true;
892template<
typename TreeT,
typename ValueIterT>
900 bbox.
min() = mValueIterList.getCoord(mLevel);
901 bbox.
max() = bbox.
min().
offsetBy(mValueIterList.getChildDim(mLevel) - 1);
906template<
typename TreeT,
typename ValueIterT>
910 std::ostringstream ostr;
911 for (
int lvl =
int(
ROOT_LEVEL); lvl >= 0 && lvl >= int(mLevel); --lvl) {
912 if (lvl == 0) ostr <<
"leaf";
913 else if (lvl ==
int(
ROOT_LEVEL)) ostr <<
"root";
915 ostr <<
" v" << mValueIterList.pos(lvl)
916 <<
" c" << mChildIterList.pos(lvl);
917 if (lvl >
int(mLevel)) ostr <<
" / ";
919 if (this->test() && mValueIterList.pos(mLevel) < mChildIterList.pos(mLevel)) {
921 ostr <<
" " << this->getCoord();
923 ostr <<
" " << this->getBoundingBox();
934template<
typename _TreeT,
typename RootChildOnIterT>
965 bool test()
const {
return !mDone; }
966 operator bool()
const {
return this->
test(); }
1001 template<
typename NodeT>
1002 void getNode(NodeT*& node)
const { node =
nullptr; mIterList.getNode(mLevel, node); }
1003 template<
typename NodeT>
1004 void getNode(
const NodeT*& node)
const { node =
nullptr; mIterList.getNode(mLevel, node); }
1012 struct PrevItem {
using IterT =
RootIterT; };
1016 int mMinLevel, mMaxLevel;
1022template<
typename TreeT,
typename RootChildOnIterT>
1027 mMinLevel(int(LEAF_LEVEL)),
1035template<
typename TreeT,
typename RootChildOnIterT>
1040 mMinLevel(int(LEAF_LEVEL)),
1045 mIterList.setIter(RootIterTraits::begin(tree.root()));
1049template<
typename TreeT,
typename RootChildOnIterT>
1052 mIterList(other.mIterList),
1053 mLevel(other.mLevel),
1054 mMinLevel(other.mMinLevel),
1055 mMaxLevel(other.mMaxLevel),
1059 mIterList.updateBackPointers();
1063template<
typename TreeT,
typename RootChildOnIterT>
1067 if (&other !=
this) {
1068 mLevel = other.mLevel;
1069 mMinLevel = other.mMinLevel;
1070 mMaxLevel = other.mMaxLevel;
1071 mDone = other.mDone;
1072 mTree = other.mTree;
1073 mIterList = other.mIterList;
1074 mIterList.updateBackPointers();
1080template<
typename TreeT,
typename RootChildOnIterT>
1085 if (
int(mLevel) > mMaxLevel) this->next();
1089template<
typename TreeT,
typename RootChildOnIterT>
1095 if (
int(mLevel) < mMinLevel) this->next();
1099template<
typename TreeT,
typename RootChildOnIterT>
1104 if (mDone)
return false;
1108 if (
int(mLevel) > mMinLevel && mIterList.test(mLevel)) {
1109 if (!mIterList.down(mLevel))
return false;
1113 while (!mIterList.test(mLevel)) {
1120 mIterList.next(mLevel);
1123 if (!mIterList.down(mLevel))
return false;
1126 }
while (
int(mLevel) < mMinLevel ||
int(mLevel) > mMaxLevel);
1131template<
typename TreeT,
typename RootChildOnIterT>
1135 if (mLevel !=
ROOT_LEVEL)
return mIterList.getCoord(mLevel + 1);
1137 this->getNode(root);
1138 return root ? root->getMinIndex() :
Coord::min();
1142template<
typename TreeT,
typename RootChildOnIterT>
1148 this->getNode(root);
1149 if (root ==
nullptr) {
1153 root->getIndexRange(bbox);
1156 bbox.
min() = mIterList.getCoord(mLevel + 1);
1157 bbox.
max() = bbox.
min().
offsetBy(mIterList.getChildDim(mLevel + 1) - 1);
1162template<
typename TreeT,
typename RootChildOnIterT>
1166 std::ostringstream ostr;
1167 for (
int lvl =
int(
ROOT_LEVEL); lvl >= 0 && lvl >= int(mLevel); --lvl) {
1168 if (lvl == 0) ostr <<
"leaf";
1169 else if (lvl ==
int(
ROOT_LEVEL)) ostr <<
"root";
1171 ostr <<
" c" << mIterList.pos(lvl);
1172 if (lvl >
int(mLevel)) ostr <<
" / ";
1175 this->getBoundingBox(bbox);
1176 ostr <<
" " << bbox;
1185template<
typename TreeT,
typename RootChildOnIterT>
1205 mIterList.setIter(RootIterTraits::begin(tree.root()));
1208 for ( ; lvl > 0 && mIterList.down(lvl); --lvl) {}
1210 if (lvl > 0) this->
next();
1215 mIterList.updateBackPointers();
1219 if (&other !=
this) {
1220 mTree = other.mTree;
1221 mIterList = other.mIterList;
1222 mIterList.updateBackPointers();
1240 operator bool()
const {
return this->
test(); }
1254 struct PrevItem {
using IterT =
RootIterT; };
1264template<
typename TreeT,
typename RootChildOnIterT>
1270 if (mIterList.test(LEAF_PARENT_LEVEL) && mIterList.next(LEAF_PARENT_LEVEL)) {
1271 mIterList.down(LEAF_PARENT_LEVEL);
1275 Index lvl = LEAF_PARENT_LEVEL;
1276 while (!mIterList.test(LEAF_PARENT_LEVEL)) {
1277 if (mIterList.test(lvl)) {
1278 mIterList.next(lvl);
1285 if (mIterList.test(lvl)) mIterList.next(lvl);
1286 }
while (!mIterList.test(lvl));
1289 while (lvl > LEAF_PARENT_LEVEL && mIterList.down(lvl)) --lvl;
1291 mIterList.down(LEAF_PARENT_LEVEL);
1301template<
typename IterT>
1307 mGrainSize(grainSize),
1310 mSize = this->size();
1314 mGrainSize(other.mGrainSize),
1315 mSize(other.mSize >> 1)
1325 bool empty()
const {
return mSize == 0 || !mIter.test(); }
1327 operator bool()
const {
return !this->
empty(); }
1334 void increment(
Index n = 1) {
for ( ; n > 0 && mSize > 0; --n, --mSize, ++mIter) {} }
1342 Index size()
const {
Index n = 0;
for (IterT it(mIter); it.test(); ++n, ++it) {}
return n; }
#define ROOT_LEVEL
Definition: CNanoVDB.h:53
ChildT * child
Definition: GridBuilder.h:1286
Axis-aligned bounding box of signed integer coordinates.
Definition: Coord.h:248
const Coord & min() const
Definition: Coord.h:320
const Coord & max() const
Definition: Coord.h:321
Signed (x, y, z) 32-bit integer coordinates.
Definition: Coord.h:25
Coord offsetBy(Int32 dx, Int32 dy, Int32 dz) const
Definition: Coord.h:91
static Coord min()
Return the smallest possible coordinate.
Definition: Coord.h:43
void setValueOff(Index lvl) const
Definition: TreeIterator.h:595
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:513
IterListItem(PrevItemT *prev)
Definition: TreeIterator.h:529
Index pos(Index lvl) const
Definition: TreeIterator.h:563
typename IterT::NonConstNodeType NCNodeT
The type of the node with const qualifiers removed ("Non-Const")
Definition: TreeIterator.h:518
bool down(Index lvl)
Definition: TreeIterator.h:569
bool isValueOn(Index lvl) const
Definition: TreeIterator.h:584
typename CopyConstness< NodeT, typename NodeT::ChildNodeType >::Type ChildT
NodeT's child node type, with the same constness (e.g., const InternalNode<...>)
Definition: TreeIterator.h:522
typename NodeVecT::Front _NodeT
Definition: TreeIterator.h:508
typename IterT::NonConstValueType NCValueT
The type of value (with const qualifiers removed) to which the iterator points.
Definition: TreeIterator.h:520
bool next(Index lvl)
Definition: TreeIterator.h:567
bool test(Index lvl) const
Definition: TreeIterator.h:565
void initLevel(Index lvl, OtherIterListItemT &otherListItem)
Definition: TreeIterator.h:554
typename IterT::NodeType NodeT
The type of node over which IterT iterates (e.g., const RootNode<...>)
Definition: TreeIterator.h:516
void modifyValue(Index lvl, const ModifyOp &op) const
Definition: TreeIterator.h:598
void updateBackPointers(PrevItemT *prev)
Definition: TreeIterator.h:541
typename CopyConstness< NCNodeT, typename NCNodeT::ChildNodeType >::Type NCChildT
NodeT's child node type with const qualifiers removed.
Definition: TreeIterator.h:524
Coord getCoord(Index lvl) const
Definition: TreeIterator.h:580
void getNode(Index lvl, NodeT *&node) const
Definition: TreeIterator.h:548
IterListItem & operator=(const IterListItem &other)
Definition: TreeIterator.h:532
void setIter(const IterT &iter)
Definition: TreeIterator.h:546
Index64 getVoxelCount(Index lvl) const
Definition: TreeIterator.h:582
const NCValueT & getValue(Index lvl) const
Definition: TreeIterator.h:586
void setValueOn(Index lvl, bool on=true) const
Definition: TreeIterator.h:594
void setValue(Index lvl, const NCValueT &val) const
Definition: TreeIterator.h:593
typename PrevItemT::IterT PrevIterT
The type of iterator stored in the previous list item.
Definition: TreeIterator.h:510
Index getChildDim(Index lvl) const
Definition: TreeIterator.h:581
IterListItem(const IterListItem &other)
Definition: TreeIterator.h:531
void setValueOff(Index lvl) const
Definition: TreeIterator.h:482
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:387
Index pos(Index lvl) const
Definition: TreeIterator.h:441
typename IterT::NonConstNodeType NCNodeT
The type of the node with const qualifiers removed ("Non-Const")
Definition: TreeIterator.h:392
bool down(Index lvl)
Definition: TreeIterator.h:447
bool isValueOn(Index lvl) const
Definition: TreeIterator.h:463
void setIter(const OtherIterT &iter)
Definition: TreeIterator.h:420
typename NodeVecT::Front _NodeT
The type of node (non-const) whose iterator is stored in this list item.
Definition: TreeIterator.h:384
typename IterT::NonConstValueType NCValueT
The type of value (with const qualifiers removed) to which the iterator points.
Definition: TreeIterator.h:394
bool next(Index lvl)
Definition: TreeIterator.h:445
bool test(Index lvl) const
Definition: TreeIterator.h:443
void initLevel(Index lvl, OtherIterListItemT &otherListItem)
Definition: TreeIterator.h:430
typename IterT::NodeType NodeT
The type of node (const or non-const) over which IterT iterates (e.g., const RootNode<....
Definition: TreeIterator.h:390
void updateBackPointers(PrevItemT *=nullptr)
Definition: TreeIterator.h:413
void modifyValue(Index lvl, const ModifyOp &op) const
Definition: TreeIterator.h:488
Coord getCoord(Index lvl) const
Definition: TreeIterator.h:449
void getNode(Index lvl, NodeT *&node) const
Definition: TreeIterator.h:422
IterListItem & operator=(const IterListItem &other)
Definition: TreeIterator.h:403
void setIter(const IterT &iter)
Definition: TreeIterator.h:418
void getNode(Index lvl, OtherNodeT *&node) const
Definition: TreeIterator.h:427
Index64 getVoxelCount(Index lvl) const
Definition: TreeIterator.h:458
const NCValueT & getValue(Index lvl) const
Definition: TreeIterator.h:468
void setValueOn(Index lvl, bool on=true) const
Definition: TreeIterator.h:478
IterListItem(PrevItemT *)
Definition: TreeIterator.h:399
void setValue(Index lvl, const NCValueT &val) const
Definition: TreeIterator.h:474
typename PrevItemT::IterT PrevIterT
The type of iterator stored in the previous list item.
Definition: TreeIterator.h:382
Index getChildDim(Index lvl) const
Definition: TreeIterator.h:453
IterListItem(const IterListItem &other)
Definition: TreeIterator.h:401
An IterListItem is an element of a compile-time linked list of iterators to nodes of different types.
Definition: TreeIterator.h:214
void setValueOff(Index lvl) const
Mark the value to which the iterator at level lvl of the tree points as inactive.
Definition: TreeIterator.h:353
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:222
IterListItem(PrevItemT *prev)
Definition: TreeIterator.h:238
Index pos(Index lvl) const
Return The table offset of the iterator at level lvl of the tree.
Definition: TreeIterator.h:286
typename IterT::NonConstNodeType NCNodeT
The type of the node with const qualifiers removed ("Non-Const")
Definition: TreeIterator.h:227
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:296
bool isValueOn(Index lvl) const
Return true if the iterator at level lvl of the tree points to an active value.
Definition: TreeIterator.h:324
typename CopyConstness< NodeT, typename NodeT::ChildNodeType >::Type ChildT
NodeT's child node type, with the same constness (e.g., const InternalNode<...>)
Definition: TreeIterator.h:231
void setIter(const OtherIterT &iter)
Definition: TreeIterator.h:256
typename NodeVecT::Front _NodeT
The type of node (non-const) whose iterator is stored in this list item.
Definition: TreeIterator.h:219
typename IterT::NonConstValueType NCValueT
The type of value (with const qualifiers removed) to which the iterator points.
Definition: TreeIterator.h:229
bool next(Index lvl)
Increment the iterator at level lvl of the tree.
Definition: TreeIterator.h:292
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:289
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:273
typename IterT::NodeType NodeT
The type of node (const or non-const) over which IterT iterates (e.g., const RootNode<....
Definition: TreeIterator.h:225
void modifyValue(Index lvl, const ModifyOp &op) const
Apply a functor to the item to which this iterator is pointing.
Definition: TreeIterator.h:361
void updateBackPointers(PrevItemT *prev)
Definition: TreeIterator.h:252
typename CopyConstness< NCNodeT, typename NCNodeT::ChildNodeType >::Type NCChildT
NodeT's child node type with const qualifiers removed.
Definition: TreeIterator.h:233
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:309
void getNode(Index lvl, NodeT *&node) const
Return the node over which this list element's iterator iterates.
Definition: TreeIterator.h:259
IterListItem & operator=(const IterListItem &other)
Definition: TreeIterator.h:242
void setIter(const IterT &iter)
Definition: TreeIterator.h:254
void getNode(Index lvl, OtherNodeT *&node) const
Return the node over which one of the following list elements' iterator iterates.
Definition: TreeIterator.h:265
Index64 getVoxelCount(Index lvl) const
Return the number of (virtual) voxels spanned by a tile value or child node.
Definition: TreeIterator.h:318
const NCValueT & getValue(Index lvl) const
Return the value to which the iterator at level lvl of the tree points.
Definition: TreeIterator.h:330
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:346
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:339
typename PrevItemT::IterT PrevIterT
The type of iterator stored in the previous list item.
Definition: TreeIterator.h:217
Index getChildDim(Index lvl) const
Definition: TreeIterator.h:313
IterListItem(const IterListItem &other)
Definition: TreeIterator.h:240
Definition: TreeIterator.h:1303
IteratorRange & operator++()
Advance the iterator to the next item.
Definition: TreeIterator.h:1336
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:1331
IteratorRange(const IterT &iter, size_t grainSize=8)
Definition: TreeIterator.h:1305
bool test() const
Definition: TreeIterator.h:1326
bool empty() const
Definition: TreeIterator.h:1325
bool next()
Advance the iterator to the next item.
Definition: TreeIterator.h:1339
const IterT & iterator() const
Return a reference to this range's iterator.
Definition: TreeIterator.h:1323
IteratorRange(IteratorRange &other, tbb::split)
Definition: TreeIterator.h:1312
void increment(Index n=1)
Advance the iterator n times.
Definition: TreeIterator.h:1334
Base class for tree-traversal iterators over all leaf nodes (but not leaf voxels)
Definition: TreeIterator.h:1187
static const Index LEAF_PARENT_LEVEL
Definition: TreeIterator.h:1196
static const Index LEAF_LEVEL
Definition: TreeIterator.h:1196
bool test() const
Definition: TreeIterator.h:1239
LeafIteratorBase()
Definition: TreeIterator.h:1200
typename RootIterT::NonConstNodeType NCRootNodeT
Definition: TreeIterator.h:1191
LeafIteratorBase(const LeafIteratorBase &other)
Definition: TreeIterator.h:1213
typename InvTreeT::Front NCLeafNodeT
Definition: TreeIterator.h:1194
LeafNodeT & operator*() const
Definition: TreeIterator.h:1235
LeafIteratorBase & operator=(const LeafIteratorBase &other)
Definition: TreeIterator.h:1217
bool next()
Advance the iterator to the next leaf node.
Definition: TreeIterator.h:1266
LeafIteratorBase & operator++()
Definition: TreeIterator.h:1246
typename iter::InvertedTree< NCRootNodeT, ROOT_LEVEL >::Type InvTreeT
Definition: TreeIterator.h:1193
LeafIteratorBase(TreeT &tree)
Definition: TreeIterator.h:1202
static const Index ROOT_LEVEL
Definition: TreeIterator.h:1192
typename CopyConstness< RootNodeT, NCLeafNodeT >::Type LeafNodeT
Definition: TreeIterator.h:1195
RootChildOnIterT RootIterT
Definition: TreeIterator.h:1189
LeafNodeT * getLeaf() const
Return the leaf node to which the iterator is pointing.
Definition: TreeIterator.h:1229
typename RootIterT::NodeType RootNodeT
Definition: TreeIterator.h:1190
void increment(Index n)
Increment the iterator n times.
Definition: TreeIterator.h:1249
void increment()
Definition: TreeIterator.h:1245
TreeT * getTree() const
Definition: TreeIterator.h:1251
LeafNodeT * operator->() const
Definition: TreeIterator.h:1236
Base class for tree-traversal iterators over all nodes.
Definition: TreeIterator.h:936
Index getMaxDepth() const
Return the depth of the lowest level of the tree to which this iterator ascends.
Definition: TreeIterator.h:961
Index getDepth() const
Return the depth in the tree (0 = root) of the node to which this iterator is currently pointing.
Definition: TreeIterator.h:983
Index getLevel() const
Return the level in the tree (0 = leaf) of the node to which this iterator is currently pointing.
Definition: TreeIterator.h:980
static const Index ROOT_DEPTH
Definition: TreeIterator.h:944
Index getMinDepth() const
Return the depth of the highest level of the tree to which this iterator ascends.
Definition: TreeIterator.h:957
Coord getCoord() const
Return the global coordinates of the voxel or tile to which this iterator is currently pointing.
Definition: TreeIterator.h:1133
static const Index LEAF_LEVEL
Definition: TreeIterator.h:944
bool test() const
Return true if this iterator is not yet exhausted.
Definition: TreeIterator.h:965
NodeIteratorBase & operator=(const NodeIteratorBase &other)
Definition: TreeIterator.h:1065
typename RootIterT::NonConstNodeType NCRootNodeT
Definition: TreeIterator.h:941
NodeIteratorBase()
Definition: TreeIterator.h:1024
static Index getLeafDepth()
Definition: TreeIterator.h:984
bool next()
Advance to the next tile or voxel value.
Definition: TreeIterator.h:1101
void setMinDepth(Index minDepth)
Specify the depth of the highest level of the tree to which to ascend (depth 0 = root).
Definition: TreeIterator.h:1082
void getNode(const NodeT *&node) const
Definition: TreeIterator.h:1004
typename iter::InvertedTree< NCRootNodeT, ROOT_LEVEL >::Type InvTreeT
Definition: TreeIterator.h:943
NodeIteratorBase & operator++()
Definition: TreeIterator.h:974
void getNode(NodeT *&node) const
Return the node to which the iterator is pointing.
Definition: TreeIterator.h:1002
_TreeT TreeT
Definition: TreeIterator.h:938
void setMaxDepth(Index maxDepth)
Specify the depth of the lowest level of the tree to which to descend (depth 0 = root).
Definition: TreeIterator.h:1091
std::string summary() const
Definition: TreeIterator.h:1164
static const Index ROOT_LEVEL
Definition: TreeIterator.h:942
RootChildOnIterT RootIterT
Definition: TreeIterator.h:939
CoordBBox getBoundingBox() const
Return the axis-aligned bounding box of the voxel or tile to which this iterator is currently pointin...
Definition: TreeIterator.h:995
static const Index LEAF_DEPTH
Definition: TreeIterator.h:944
typename RootIterT::NodeType RootNodeT
Definition: TreeIterator.h:940
void increment(Index n)
Increment the iterator n times.
Definition: TreeIterator.h:976
void increment()
Advance the iterator to the next leaf node.
Definition: TreeIterator.h:973
TreeT * getTree() const
Definition: TreeIterator.h:1007
Base class for tree-traversal iterators over tile and voxel values.
Definition: TreeIterator.h:617
bool isVoxelValue() const
Return true if this iterator is currently pointing to a (leaf) voxel value.
Definition: TreeIterator.h:686
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:699
Index getMaxDepth() const
Return the depth of the lowest level of the tree to which this iterator ascends.
Definition: TreeIterator.h:640
Index getDepth() const
Return the depth in the tree (0 = root) of the node to which this iterator is currently pointing.
Definition: TreeIterator.h:659
Index getLevel() const
Return the level in the tree (0 = leaf) of the node to which this iterator is currently pointing.
Definition: TreeIterator.h:656
typename ValueIterT::NonConstValueType ValueT
Definition: TreeIterator.h:622
bool isValueOn() const
Return true if the value to which this iterator is currently pointing is active.
Definition: TreeIterator.h:688
Index getMinDepth() const
Return the depth of the highest level of the tree to which this iterator ascends.
Definition: TreeIterator.h:636
const ValueT & getValue() const
Return the tile or voxel value to which this iterator is currently pointing.
Definition: TreeIterator.h:692
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:712
Coord getCoord() const
Return the global coordinates of the voxel or tile to which this iterator is currently pointing.
Definition: TreeIterator.h:671
bool test() const
Return true if this iterator is not yet exhausted.
Definition: TreeIterator.h:644
_ValueIterT ValueIterT
Definition: TreeIterator.h:620
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:667
bool isTileValue() const
Return true if this iterator is currently pointing to a (non-leaf) tile value.
Definition: TreeIterator.h:684
typename NodeT::ChildOnCIter ChildOnIterT
Definition: TreeIterator.h:623
void setValueOff() const
Mark the tile or voxel value to which this iterator is currently pointing as inactive.
Definition: TreeIterator.h:704
static Index getLeafDepth()
Definition: TreeIterator.h:660
bool next()
Advance to the next tile or voxel value. Return true if this iterator is not yet exhausted.
Definition: TreeIterator.h:805
TreeValueIteratorBase & operator=(const TreeValueIteratorBase &other)
Definition: TreeIterator.h:768
void setMinDepth(Index minDepth)
Specify the depth of the highest level of the tree to which to ascend (depth 0 = root).
Definition: TreeIterator.h:786
Index64 getVoxelCount() const
Return the number of (virtual) voxels corresponding to the value.
Definition: TreeIterator.h:681
typename ValueIterT::NodeType NodeT
Definition: TreeIterator.h:621
_TreeT TreeT
Definition: TreeIterator.h:619
void setMaxDepth(Index maxDepth)
Specify the depth of the lowest level of the tree to which to descend (depth 0 = root).
Definition: TreeIterator.h:795
const ValueT & operator*() const
Definition: TreeIterator.h:693
std::string summary() const
Return a string (for debugging, mainly) describing this iterator's current state.
Definition: TreeIterator.h:908
TreeValueIteratorBase(TreeT &)
Definition: TreeIterator.h:737
CoordBBox getBoundingBox() const
Return the axis-aligned bounding box of the voxel or tile to which this iterator is currently pointin...
Definition: TreeIterator.h:678
const ValueT * operator->() const
Definition: TreeIterator.h:694
TreeValueIteratorBase & operator++()
Advance to the next tile or voxel value.
Definition: TreeIterator.h:652
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:702
TreeT * getTree() const
Return a pointer to the tree over which this iterator is iterating.
Definition: TreeIterator.h:715
Vec3< T2 > operator*(T1 scalar, const Vec3< T2 > &vec)
Definition: NanoVDB.h:1163
BBox< Coord > CoordBBox
Definition: NanoVDB.h:1658
Level
Message severity level.
Definition: logging.h:31
Index32 Index
Definition: Types.h:54
uint64_t Index64
Definition: Types.h:53
Definition: Exceptions.h:13
typename std::remove_const< ToType >::type Type
Definition: Types.h:321
A list of types (not necessarily unique)
Definition: TypeList.h:366
typename OtherNodeT::ChildAllCIter Type
Definition: TreeIterator.h:134
static IterT begin(const NodeT &node)
Definition: TreeIterator.h:128
typename NodeT::ChildAllCIter IterT
Definition: TreeIterator.h:127
static ChildT * getChild(const IterT &iter)
Definition: TreeIterator.h:129
typename OtherNodeT::ChildAllIter Type
Definition: TreeIterator.h:120
typename NodeT::ChildAllIter IterT
Definition: TreeIterator.h:113
static IterT begin(NodeT &node)
Definition: TreeIterator.h:114
static ChildT * getChild(const IterT &iter)
Definition: TreeIterator.h:115
typename OtherNodeT::ChildOffCIter Type
Definition: TreeIterator.h:106
static IterT begin(const NodeT &node)
Definition: TreeIterator.h:104
typename NodeT::ChildOffCIter IterT
Definition: TreeIterator.h:103
typename OtherNodeT::ChildOffIter Type
Definition: TreeIterator.h:96
static IterT begin(NodeT &node)
Definition: TreeIterator.h:94
typename NodeT::ChildOffIter IterT
Definition: TreeIterator.h:93
typename OtherNodeT::ChildOnCIter Type
Definition: TreeIterator.h:86
static IterT begin(const NodeT &node)
Definition: TreeIterator.h:81
static const ChildT * getChild(const IterT &iter)
Definition: TreeIterator.h:82
typename NodeT::ChildOnCIter IterT
Definition: TreeIterator.h:80
typename OtherNodeT::ChildOnIter Type
Definition: TreeIterator.h:73
static IterT begin(NodeT &node)
Definition: TreeIterator.h:68
typename NodeT::ChildOnIter IterT
Definition: TreeIterator.h:67
static ChildT * getChild(const IterT &iter)
Definition: TreeIterator.h:69
typename OtherNodeT::ValueAllCIter Type
Definition: TreeIterator.h:194
static IterT begin(const NodeT &node)
Definition: TreeIterator.h:192
typename NodeT::ValueAllCIter IterT
Definition: TreeIterator.h:191
typename OtherNodeT::ValueAllIter Type
Definition: TreeIterator.h:184
static IterT begin(NodeT &node)
Definition: TreeIterator.h:182
typename NodeT::ValueAllIter IterT
Definition: TreeIterator.h:181
typename OtherNodeT::ValueOffCIter Type
Definition: TreeIterator.h:174
static IterT begin(const NodeT &node)
Definition: TreeIterator.h:172
typename NodeT::ValueOffCIter IterT
Definition: TreeIterator.h:171
typename OtherNodeT::ValueOffIter Type
Definition: TreeIterator.h:164
static IterT begin(NodeT &node)
Definition: TreeIterator.h:162
typename NodeT::ValueOffIter IterT
Definition: TreeIterator.h:161
typename OtherNodeT::ValueOnCIter Type
Definition: TreeIterator.h:154
static IterT begin(const NodeT &node)
Definition: TreeIterator.h:152
typename NodeT::ValueOnCIter IterT
Definition: TreeIterator.h:151
typename OtherNodeT::ValueOnIter Type
Definition: TreeIterator.h:144
typename NodeT::ValueOnIter IterT
Definition: TreeIterator.h:141
static IterT begin(NodeT &node)
Definition: TreeIterator.h:142
Definition: TreeIterator.h:60
static ChildT * getChild(const IterT &)
Definition: TreeIterator.h:61
Definition: TreeIterator.h:32
typename SubtreeT::template Append< HeadT > Type
Definition: TreeIterator.h:34
typename InvertedTree< typename HeadT::ChildNodeType, HeadLevel-1 >::Type SubtreeT
Definition: TreeIterator.h:33
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition: version.h.in:116
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h.in:202