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> 
   22#define ENABLE_TREE_VALUE_DEPTH_BOUND_OPTIMIZATION 
   32template<
typename HeadT, 
int HeadLevel>
 
   35    using Type = 
typename SubtreeT::template Append<HeadT>;
 
 
   37template<
typename HeadT>
 
 
   59template<
typename NodeT, 
typename IterT>
 
   62    template<
typename ChildT> 
static ChildT* 
getChild(
const IterT&) { 
return nullptr; }
 
 
   65template<
typename NodeT>
 
   68    using IterT = 
typename NodeT::ChildOnIter;
 
   69    static IterT begin(NodeT& node) { 
return node.beginChildOn(); }
 
   71        return &
iter.getValue();
 
 
   74        using Type = 
typename OtherNodeT::ChildOnIter;
 
 
 
   78template<
typename NodeT>
 
   81    using IterT = 
typename NodeT::ChildOnCIter;
 
   82    static IterT begin(
const NodeT& node) { 
return node.cbeginChildOn(); }
 
   84        return &
iter.getValue();
 
 
   87        using Type = 
typename OtherNodeT::ChildOnCIter;
 
 
 
   91template<
typename NodeT>
 
   94    using IterT = 
typename NodeT::ChildOffIter;
 
   95    static IterT begin(NodeT& node) { 
return node.beginChildOff(); }
 
   97        using Type = 
typename OtherNodeT::ChildOffIter;
 
 
 
  101template<
typename NodeT>
 
  104    using IterT = 
typename NodeT::ChildOffCIter;
 
  105    static IterT begin(
const NodeT& node) { 
return node.cbeginChildOff(); }
 
  107        using Type = 
typename OtherNodeT::ChildOffCIter;
 
 
 
  111template<
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);
 
 
  121        using Type = 
typename OtherNodeT::ChildAllIter;
 
 
 
  125template<
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);
 
 
  135        using Type = 
typename OtherNodeT::ChildAllCIter;
 
 
 
  139template<
typename NodeT>
 
  142    using IterT = 
typename NodeT::ValueOnIter;
 
  143    static IterT begin(NodeT& node) { 
return node.beginValueOn(); }
 
  145        using Type = 
typename OtherNodeT::ValueOnIter;
 
 
 
  149template<
typename NodeT>
 
  152    using IterT = 
typename NodeT::ValueOnCIter;
 
  153    static IterT begin(
const NodeT& node) { 
return node.cbeginValueOn(); }
 
  155        using Type = 
typename OtherNodeT::ValueOnCIter;
 
 
 
  159template<
typename NodeT>
 
  162    using IterT = 
typename NodeT::ValueOffIter;
 
  163    static IterT begin(NodeT& node) { 
return node.beginValueOff(); }
 
  165        using Type = 
typename OtherNodeT::ValueOffIter;
 
 
 
  169template<
typename NodeT>
 
  172    using IterT = 
typename NodeT::ValueOffCIter;
 
  173    static IterT begin(
const NodeT& node) { 
return node.cbeginValueOff(); }
 
  175        using Type = 
typename OtherNodeT::ValueOffCIter;
 
 
 
  179template<
typename NodeT>
 
  182    using IterT = 
typename NodeT::ValueAllIter;
 
  183    static IterT begin(NodeT& node) { 
return node.beginValueAll(); }
 
  185        using Type = 
typename OtherNodeT::ValueAllIter;
 
 
 
  189template<
typename NodeT>
 
  192    using IterT = 
typename NodeT::ValueAllCIter;
 
  193    static IterT begin(
const NodeT& node) { 
return node.cbeginValueAll(); }
 
  195        using Type = 
typename OtherNodeT::ValueAllCIter;
 
 
 
  213template<
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>
 
  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);
 
 
  290    bool test(
Index lvl)
 const { 
return (lvl == 
Level) ? mIter.test() : mNext.test(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; 
 
 
  378template<
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>
 
  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; 
 
 
  505template<
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));
 
 
  572        if (lvl == 
Level && mPrev != 
nullptr && mIter) {
 
  573            if (
ChildT* child = ITraits::template getChild<ChildT>(mIter)) {
 
  574                mPrev->setIter(PrevItemT::ITraits::begin(*child));
 
 
  591        return mIter.getValue();
 
 
  598    template<
typename ModifyOp>
 
  601        if (lvl == 
Level) mIter.modifyValue(op);
 
 
 
  616template<
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); }
 
  646    operator bool()
 const { 
return this->
test(); }
 
  667    template<
typename NodeType>
 
  668    void getNode(NodeType*& node)
 const { mValueIterList.getNode(mLevel, node); }
 
  689    bool isValueOn()
 const { 
return mValueIterList.isValueOn(mLevel); }
 
  712    template<
typename ModifyOp>
 
  713    void modifyValue(
const ModifyOp& op)
 const { mValueIterList.modifyValue(mLevel, op); }
 
  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;
 
 
  736template<
typename TreeT, 
typename ValueIterT>
 
  739    mChildIterList(nullptr),
 
  740    mValueIterList(nullptr),
 
 
  752template<
typename TreeT, 
typename ValueIterT>
 
  755    mChildIterList(other.mChildIterList),
 
  756    mValueIterList(other.mValueIterList),
 
  757    mLevel(other.mLevel),
 
  758    mMinLevel(other.mMinLevel),
 
  759    mMaxLevel(other.mMaxLevel),
 
  762    mChildIterList.updateBackPointers();
 
  763    mValueIterList.updateBackPointers();
 
 
  767template<
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();
 
 
  785template<
typename TreeT, 
typename ValueIterT>
 
  790    if (
int(mLevel) > mMaxLevel) this->
next();
 
 
  794template<
typename TreeT, 
typename ValueIterT>
 
  800    if (
int(mLevel) < mMinLevel) this->
next();
 
 
  804template<
typename TreeT, 
typename ValueIterT>
 
  809        if (!this->advance()) 
return false;
 
  810    } 
while (
int(mLevel) < mMinLevel || 
int(mLevel) > mMaxLevel);
 
 
  815template<
typename TreeT, 
typename ValueIterT>
 
  817TreeValueIteratorBase<TreeT, ValueIterT>::advance(
bool dontIncrement)
 
  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;
 
  893template<
typename TreeT, 
typename ValueIterT>
 
  901    bbox.
min() = mValueIterList.getCoord(mLevel);
 
  902    bbox.
max() = bbox.
min().
offsetBy(mValueIterList.getChildDim(mLevel) - 1);
 
 
  907template<
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)) {
 
 
  935template<
typename _TreeT, 
typename RootChildOnIterT>
 
  966    bool test()
 const { 
return !mDone; }
 
  967    operator bool()
 const { 
return this->
test(); }
 
 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;
 
 
 1023template<
typename TreeT, 
typename RootChildOnIterT>
 
 1036template<
typename TreeT, 
typename RootChildOnIterT>
 
 1046    mIterList.setIter(RootIterTraits::begin(
tree.root()));
 
 
 1050template<
typename TreeT, 
typename RootChildOnIterT>
 
 1053    mIterList(other.mIterList),
 
 1054    mLevel(other.mLevel),
 
 1055    mMinLevel(other.mMinLevel),
 
 1056    mMaxLevel(other.mMaxLevel),
 
 1060    mIterList.updateBackPointers();
 
 
 1064template<
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;
 
 
 1081template<
typename TreeT, 
typename RootChildOnIterT>
 
 1086    if (
int(mLevel) > mMaxLevel) this->
next();
 
 
 1090template<
typename TreeT, 
typename RootChildOnIterT>
 
 1096    if (
int(mLevel) < mMinLevel) this->
next();
 
 
 1100template<
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);
 
 
 1132template<
typename TreeT, 
typename RootChildOnIterT>
 
 1136    if (mLevel != 
ROOT_LEVEL) 
return  mIterList.getCoord(mLevel + 1);
 
 1139    return root ? root->getMinIndex() : 
Coord::min();
 
 
 1143template<
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);
 
 
 1163template<
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;
 
 
 1186template<
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;
 
 
 1241    operator bool()
 const { 
return this->
test(); }
 
 1255    struct PrevItem { 
using IterT = 
RootIterT; };
 
 
 1265template<
typename TreeT, 
typename RootChildOnIterT>
 
 1278        if (mIterList.test(lvl)) {
 
 1279            mIterList.next(lvl);
 
 1286                if (mIterList.test(lvl)) mIterList.next(lvl);
 
 1287            } 
while (!mIterList.test(lvl));
 
 
 1302template<
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(); }
 
 1335    operator bool()
 const { 
return !this->
empty(); }
 
 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;
 
 
#define OPENVDB_ASSERT(X)
Definition Assert.h:41
#define ROOT_LEVEL
Definition CNanoVDB.h:53
static Coord min()
Return the smallest possible coordinate.
Definition Coord.h:44
Axis-aligned bounding box of signed integer coordinates.
Definition Coord.h:252
const Coord & min() const
Definition Coord.h:324
const Coord & max() const
Definition Coord.h:325
Signed (x, y, z) 32-bit integer coordinates.
Definition Coord.h:26
Coord offsetBy(Int32 dx, Int32 dy, Int32 dz) const
Definition Coord.h:92
void setValueOff(Index lvl) const
Definition TreeIterator.h:596
IterListItem(PrevItemT *prev)
Definition TreeIterator.h:530
Index pos(Index lvl) const
Definition TreeIterator.h:564
typename IterT::NonConstNodeType NCNodeT
The type of the node with const qualifiers removed ("Non-Const")
Definition TreeIterator.h:519
bool down(Index lvl)
Definition TreeIterator.h:570
bool isValueOn(Index lvl) const
Definition TreeIterator.h:585
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 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
typename NodeVecT::Front _NodeT
Definition TreeIterator.h:509
typename IterT::NonConstValueType NCValueT
The type of value (with const qualifiers removed) to which the iterator points.
Definition TreeIterator.h:521
bool next(Index lvl)
Definition TreeIterator.h:568
bool test(Index lvl) const
Definition TreeIterator.h:566
void initLevel(Index lvl, OtherIterListItemT &otherListItem)
Definition TreeIterator.h:555
typename IterT::NodeType NodeT
The type of node over which IterT iterates (e.g., const RootNode<...>)
Definition TreeIterator.h:517
static const Index Level
NodeT's level in its tree (0 = LeafNode)
Definition TreeIterator.h:528
IterTraits< NCNodeT, IterT > ITraits
Definition TreeIterator.h:526
void modifyValue(Index lvl, const ModifyOp &op) const
Definition TreeIterator.h:599
void updateBackPointers(PrevItemT *prev)
Definition TreeIterator.h:542
typename CopyConstness< NCNodeT, typename NCNodeT::ChildNodeType >::Type NCChildT
NodeT's child node type with const qualifiers removed.
Definition TreeIterator.h:525
Coord getCoord(Index lvl) const
Definition TreeIterator.h:581
void getNode(Index lvl, NodeT *&node) const
Definition TreeIterator.h:549
IterListItem & operator=(const IterListItem &other)
Definition TreeIterator.h:533
void setIter(const IterT &iter)
Definition TreeIterator.h:547
Index64 getVoxelCount(Index lvl) const
Definition TreeIterator.h:583
const NCValueT & getValue(Index lvl) const
Definition TreeIterator.h:587
void setValueOn(Index lvl, bool on=true) const
Definition TreeIterator.h:595
void setValue(Index lvl, const NCValueT &val) const
Definition TreeIterator.h:594
typename PrevItemT::IterT PrevIterT
The type of iterator stored in the previous list item.
Definition TreeIterator.h:511
Index getChildDim(Index lvl) const
Definition TreeIterator.h:582
IterListItem(const IterListItem &other)
Definition TreeIterator.h:532
void setValueOff(Index lvl) const
Definition TreeIterator.h:483
Index pos(Index lvl) const
Definition TreeIterator.h:442
typename IterT::NonConstNodeType NCNodeT
The type of the node with const qualifiers removed ("Non-Const")
Definition TreeIterator.h:393
bool down(Index lvl)
Definition TreeIterator.h:448
bool isValueOn(Index lvl) const
Definition TreeIterator.h:464
void setIter(const OtherIterT &iter)
Definition TreeIterator.h:421
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
typename NodeVecT::Front _NodeT
The type of node (non-const) whose iterator is stored in this list item.
Definition TreeIterator.h:385
typename IterT::NonConstValueType NCValueT
The type of value (with const qualifiers removed) to which the iterator points.
Definition TreeIterator.h:395
bool next(Index lvl)
Definition TreeIterator.h:446
bool test(Index lvl) const
Definition TreeIterator.h:444
void initLevel(Index lvl, OtherIterListItemT &otherListItem)
Definition TreeIterator.h:431
typename IterT::NodeType NodeT
The type of node (const or non-const) over which IterT iterates (e.g., const RootNode<....
Definition TreeIterator.h:391
static const Index Level
NodeT's level in its tree (0 = LeafNode)
Definition TreeIterator.h:398
IterTraits< NCNodeT, IterT > ITraits
Definition TreeIterator.h:396
void updateBackPointers(PrevItemT *=nullptr)
Definition TreeIterator.h:414
void modifyValue(Index lvl, const ModifyOp &op) const
Definition TreeIterator.h:489
Coord getCoord(Index lvl) const
Definition TreeIterator.h:450
void getNode(Index lvl, NodeT *&node) const
Definition TreeIterator.h:423
IterListItem & operator=(const IterListItem &other)
Definition TreeIterator.h:404
void setIter(const IterT &iter)
Definition TreeIterator.h:419
void getNode(Index lvl, OtherNodeT *&node) const
Definition TreeIterator.h:428
Index64 getVoxelCount(Index lvl) const
Definition TreeIterator.h:459
const NCValueT & getValue(Index lvl) const
Definition TreeIterator.h:469
void setValueOn(Index lvl, bool on=true) const
Definition TreeIterator.h:479
IterListItem(PrevItemT *)
Definition TreeIterator.h:400
void setValue(Index lvl, const NCValueT &val) const
Definition TreeIterator.h:475
typename PrevItemT::IterT PrevIterT
The type of iterator stored in the previous list item.
Definition TreeIterator.h:383
Index getChildDim(Index lvl) const
Definition TreeIterator.h:454
IterListItem(const IterListItem &other)
Definition TreeIterator.h:402
An IterListItem is an element of a compile-time linked list of iterators to nodes of different types.
Definition TreeIterator.h:215
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
IterListItem(PrevItemT *prev)
Definition TreeIterator.h:239
Index pos(Index lvl) const
Return The table offset of the iterator at level lvl of the tree.
Definition TreeIterator.h:287
typename IterT::NonConstNodeType NCNodeT
The type of the node with const qualifiers removed ("Non-Const")
Definition TreeIterator.h:228
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
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
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 setIter(const OtherIterT &iter)
Definition TreeIterator.h:257
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
typename NodeVecT::Front _NodeT
The type of node (non-const) whose iterator is stored in this list item.
Definition TreeIterator.h:220
typename IterT::NonConstValueType NCValueT
The type of value (with const qualifiers removed) to which the iterator points.
Definition TreeIterator.h:230
bool next(Index lvl)
Increment the iterator at level lvl of the tree.
Definition TreeIterator.h:293
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
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
typename IterT::NodeType NodeT
The type of node (const or non-const) over which IterT iterates (e.g., const RootNode<....
Definition TreeIterator.h:226
static const Index Level
Definition TreeIterator.h:237
IterTraits< NCNodeT, IterT > ITraits
Definition TreeIterator.h:235
void modifyValue(Index lvl, const ModifyOp &op) const
Apply a functor to the item to which this iterator is pointing.
Definition TreeIterator.h:362
void updateBackPointers(PrevItemT *prev)
Definition TreeIterator.h:253
typename CopyConstness< NCNodeT, typename NCNodeT::ChildNodeType >::Type NCChildT
NodeT's child node type with const qualifiers removed.
Definition TreeIterator.h:234
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
void getNode(Index lvl, NodeT *&node) const
Return the node over which this list element's iterator iterates.
Definition TreeIterator.h:260
IterListItem & operator=(const IterListItem &other)
Definition TreeIterator.h:243
void setIter(const IterT &iter)
Definition TreeIterator.h:255
void getNode(Index lvl, OtherNodeT *&node) const
Return the node over which one of the following list elements' iterator iterates.
Definition TreeIterator.h:266
Index64 getVoxelCount(Index lvl) const
Return the number of (virtual) voxels spanned by a tile value or child node.
Definition TreeIterator.h:319
const NCValueT & getValue(Index lvl) const
Return the value to which the iterator at level lvl of the tree points.
Definition TreeIterator.h:331
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
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 PrevItemT::IterT PrevIterT
The type of iterator stored in the previous list item.
Definition TreeIterator.h:218
Index getChildDim(Index lvl) const
Definition TreeIterator.h:314
IterListItem(const IterListItem &other)
Definition TreeIterator.h:241
IteratorRange & operator++()
Advance the iterator to the next item.
Definition TreeIterator.h:1344
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
IteratorRange(const IterT &iter, size_t grainSize=8)
Constructor from iterator and grain size.
Definition TreeIterator.h:1309
bool test() const
Definition TreeIterator.h:1334
bool empty() const
Definition TreeIterator.h:1333
bool next()
Advance the iterator to the next item.
Definition TreeIterator.h:1347
const IterT & iterator() const
Return a reference to this range's iterator.
Definition TreeIterator.h:1331
void increment(size_t n=1)
Advance the iterator n times.
Definition TreeIterator.h:1342
IteratorRange(IteratorRange &other, tbb::split)
Split constructor used by tbb (should rarely be called directly)
Definition TreeIterator.h:1320
static const Index LEAF_PARENT_LEVEL
Definition TreeIterator.h:1197
static const Index LEAF_LEVEL
Definition TreeIterator.h:1197
bool test() const
Definition TreeIterator.h:1240
LeafIteratorBase()
Definition TreeIterator.h:1201
typename RootIterT::NonConstNodeType NCRootNodeT
Definition TreeIterator.h:1192
LeafIteratorBase(const LeafIteratorBase &other)
Definition TreeIterator.h:1214
typename InvTreeT::Front NCLeafNodeT
Definition TreeIterator.h:1195
LeafNodeT & operator*() const
Definition TreeIterator.h:1236
LeafIteratorBase & operator=(const LeafIteratorBase &other)
Definition TreeIterator.h:1218
bool next()
Advance the iterator to the next leaf node.
Definition TreeIterator.h:1267
LeafIteratorBase & operator++()
Definition TreeIterator.h:1247
typename iter::InvertedTree< NCRootNodeT, ROOT_LEVEL >::Type InvTreeT
Definition TreeIterator.h:1194
IterTraits< NCRootNodeT, RootIterT > RootIterTraits
Definition TreeIterator.h:1199
LeafIteratorBase(TreeT &tree)
Definition TreeIterator.h:1203
static const Index ROOT_LEVEL
Definition TreeIterator.h:1193
typename CopyConstness< RootNodeT, NCLeafNodeT >::Type LeafNodeT
Definition TreeIterator.h:1196
typename RootNodeType::ChildOnIter RootIterT
Definition TreeIterator.h:1190
LeafNodeT * getLeaf() const
Return the leaf node to which the iterator is pointing.
Definition TreeIterator.h:1230
typename RootIterT::NodeType RootNodeT
Definition TreeIterator.h:1191
void increment(Index n)
Increment the iterator n times.
Definition TreeIterator.h:1250
void increment()
Definition TreeIterator.h:1246
TreeT * getTree() const
Definition TreeIterator.h:1252
LeafNodeT * operator->() const
Definition TreeIterator.h:1237
Base class for tree-traversal iterators over all nodes.
Definition TreeIterator.h:937
Index getMaxDepth() const
Return the depth of the lowest level of the tree to which this iterator ascends.
Definition TreeIterator.h:962
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
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
static const Index ROOT_DEPTH
Definition TreeIterator.h:945
Index getMinDepth() const
Return the depth of the highest level of the tree to which this iterator ascends.
Definition TreeIterator.h:958
Coord getCoord() const
Return the global coordinates of the voxel or tile to which this iterator is currently pointing.
Definition TreeIterator.h:1134
static const Index LEAF_LEVEL
Definition TreeIterator.h:945
bool getBoundingBox(CoordBBox &bbox) const
Return in bbox the axis-aligned bounding box of the voxel or tile to which this iterator is currently...
Definition TreeIterator.h:1145
bool test() const
Return true if this iterator is not yet exhausted.
Definition TreeIterator.h:966
NodeIteratorBase & operator=(const NodeIteratorBase &other)
Definition TreeIterator.h:1066
typename RootIterT::NonConstNodeType NCRootNodeT
Definition TreeIterator.h:942
NodeIteratorBase()
Definition TreeIterator.h:1025
static Index getLeafDepth()
Definition TreeIterator.h:985
bool next()
Advance to the next tile or voxel value.
Definition TreeIterator.h:1102
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
void getNode(const NodeT *&node) const
Definition TreeIterator.h:1005
typename iter::InvertedTree< NCRootNodeT, ROOT_LEVEL >::Type InvTreeT
Definition TreeIterator.h:944
NodeIteratorBase & operator++()
Definition TreeIterator.h:975
void getNode(NodeT *&node) const
Return the node to which the iterator is pointing.
Definition TreeIterator.h:1003
IterTraits< NCRootNodeT, RootIterT > RootIterTraits
Definition TreeIterator.h:947
Tree TreeT
Definition TreeIterator.h:939
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
std::string summary() const
Definition TreeIterator.h:1165
NodeIteratorBase(TreeT &)
Definition TreeIterator.h:1038
NodeIteratorBase(const NodeIteratorBase &other)
Definition TreeIterator.h:1052
static const Index ROOT_LEVEL
Definition TreeIterator.h:943
typename RootNodeType::ChildOnIter RootIterT
Definition TreeIterator.h:940
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
static const Index LEAF_DEPTH
Definition TreeIterator.h:945
typename RootIterT::NodeType RootNodeT
Definition TreeIterator.h:941
void increment(Index n)
Increment the iterator n times.
Definition TreeIterator.h:977
void increment()
Advance the iterator to the next leaf node.
Definition TreeIterator.h:974
TreeT * getTree() const
Definition TreeIterator.h:1008
Base class for tree-traversal iterators over tile and voxel values.
Definition TreeIterator.h:618
bool isVoxelValue() const
Return true if this iterator is currently pointing to a (leaf) voxel value.
Definition TreeIterator.h:687
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
Index getMaxDepth() const
Return the depth of the lowest level of the tree to which this iterator ascends.
Definition TreeIterator.h:641
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
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
typename ValueIterT::NonConstValueType ValueT
Definition TreeIterator.h:623
bool isValueOn() const
Return true if the value to which this iterator is currently pointing is active.
Definition TreeIterator.h:689
static const Index ROOT_DEPTH
Definition TreeIterator.h:627
Index getMinDepth() const
Return the depth of the highest level of the tree to which this iterator ascends.
Definition TreeIterator.h:637
const ValueT & getValue() const
Return the tile or voxel value to which this iterator is currently pointing.
Definition TreeIterator.h:693
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
Coord getCoord() const
Return the global coordinates of the voxel or tile to which this iterator is currently pointing.
Definition TreeIterator.h:672
static const Index LEAF_LEVEL
Definition TreeIterator.h:627
bool test() const
Return true if this iterator is not yet exhausted.
Definition TreeIterator.h:645
typename RootNodeType::ValueAllIter ValueIterT
Definition TreeIterator.h:621
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
bool isTileValue() const
Return true if this iterator is currently pointing to a (non-leaf) tile value.
Definition TreeIterator.h:685
typename NodeT::ChildOnCIter ChildOnIterT
Definition TreeIterator.h:624
void setValueOff() const
Mark the tile or voxel value to which this iterator is currently pointing as inactive.
Definition TreeIterator.h:705
static Index getLeafDepth()
Definition TreeIterator.h:661
bool next()
Advance to the next tile or voxel value. Return true if this iterator is not yet exhausted.
Definition TreeIterator.h:806
TreeValueIteratorBase & operator=(const TreeValueIteratorBase &other)
Definition TreeIterator.h:769
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
Index64 getVoxelCount() const
Return the number of (virtual) voxels corresponding to the value.
Definition TreeIterator.h:682
typename ValueIterT::NodeType NodeT
Definition TreeIterator.h:622
Tree TreeT
Definition TreeIterator.h:620
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
const ValueT & operator*() const
Definition TreeIterator.h:694
std::string summary() const
Return a string (for debugging, mainly) describing this iterator's current state.
Definition TreeIterator.h:909
static const Index ROOT_LEVEL
Definition TreeIterator.h:625
TreeValueIteratorBase(TreeT &)
Definition TreeIterator.h:738
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
const ValueT * operator->() const
Definition TreeIterator.h:695
static const Index LEAF_DEPTH
Definition TreeIterator.h:627
TreeValueIteratorBase & operator++()
Advance to the next tile or voxel value.
Definition TreeIterator.h:653
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
TreeT * getTree() const
Return a pointer to the tree over which this iterator is iterating.
Definition TreeIterator.h:716
bool getBoundingBox(CoordBBox &) const
Return in bbox the axis-aligned bounding box of the voxel or tile to which this iterator is currently...
Definition TreeIterator.h:895
TreeValueIteratorBase(const TreeValueIteratorBase &other)
Definition TreeIterator.h:754
Definition TreeIterator.h:30
Definition PointDataGrid.h:170
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:439
A list of types (not necessarily unique)
Definition TypeList.h:578
Definition TreeIterator.h:134
typename OtherNodeT::ChildAllCIter Type
Definition TreeIterator.h:135
static IterT begin(const NodeT &node)
Definition TreeIterator.h:129
typename NodeT::ChildAllCIter IterT
Definition TreeIterator.h:128
static ChildT * getChild(const IterT &iter)
Definition TreeIterator.h:130
Definition TreeIterator.h:120
typename OtherNodeT::ChildAllIter Type
Definition TreeIterator.h:121
typename NodeT::ChildAllIter IterT
Definition TreeIterator.h:114
static IterT begin(NodeT &node)
Definition TreeIterator.h:115
static ChildT * getChild(const IterT &iter)
Definition TreeIterator.h:116
Definition TreeIterator.h:106
typename OtherNodeT::ChildOffCIter Type
Definition TreeIterator.h:107
static IterT begin(const NodeT &node)
Definition TreeIterator.h:105
typename NodeT::ChildOffCIter IterT
Definition TreeIterator.h:104
Definition TreeIterator.h:96
typename OtherNodeT::ChildOffIter Type
Definition TreeIterator.h:97
static IterT begin(NodeT &node)
Definition TreeIterator.h:95
typename NodeT::ChildOffIter IterT
Definition TreeIterator.h:94
Definition TreeIterator.h:86
typename OtherNodeT::ChildOnCIter Type
Definition TreeIterator.h:87
static IterT begin(const NodeT &node)
Definition TreeIterator.h:82
static const ChildT * getChild(const IterT &iter)
Definition TreeIterator.h:83
typename NodeT::ChildOnCIter IterT
Definition TreeIterator.h:81
Definition TreeIterator.h:73
typename OtherNodeT::ChildOnIter Type
Definition TreeIterator.h:74
static IterT begin(NodeT &node)
Definition TreeIterator.h:69
typename NodeT::ChildOnIter IterT
Definition TreeIterator.h:68
static ChildT * getChild(const IterT &iter)
Definition TreeIterator.h:70
Definition TreeIterator.h:194
typename OtherNodeT::ValueAllCIter Type
Definition TreeIterator.h:195
static IterT begin(const NodeT &node)
Definition TreeIterator.h:193
typename NodeT::ValueAllCIter IterT
Definition TreeIterator.h:192
Definition TreeIterator.h:184
typename OtherNodeT::ValueAllIter Type
Definition TreeIterator.h:185
static IterT begin(NodeT &node)
Definition TreeIterator.h:183
typename NodeT::ValueAllIter IterT
Definition TreeIterator.h:182
Definition TreeIterator.h:174
typename OtherNodeT::ValueOffCIter Type
Definition TreeIterator.h:175
static IterT begin(const NodeT &node)
Definition TreeIterator.h:173
typename NodeT::ValueOffCIter IterT
Definition TreeIterator.h:172
Definition TreeIterator.h:164
typename OtherNodeT::ValueOffIter Type
Definition TreeIterator.h:165
static IterT begin(NodeT &node)
Definition TreeIterator.h:163
typename NodeT::ValueOffIter IterT
Definition TreeIterator.h:162
Definition TreeIterator.h:154
typename OtherNodeT::ValueOnCIter Type
Definition TreeIterator.h:155
static IterT begin(const NodeT &node)
Definition TreeIterator.h:153
typename NodeT::ValueOnCIter IterT
Definition TreeIterator.h:152
Definition TreeIterator.h:144
typename OtherNodeT::ValueOnIter Type
Definition TreeIterator.h:145
typename NodeT::ValueOnIter IterT
Definition TreeIterator.h:142
static IterT begin(NodeT &node)
Definition TreeIterator.h:143
Definition TreeIterator.h:61
static ChildT * getChild(const IterT &)
Definition TreeIterator.h:62
TypeList< typename HeadT::ChildNodeType, HeadT > Type
Definition TreeIterator.h:39
Definition TreeIterator.h:33
typename SubtreeT::template Append< HeadT > Type
Definition TreeIterator.h:35
typename InvertedTree< typename HeadT::ChildNodeType, HeadLevel-1 >::Type SubtreeT
Definition TreeIterator.h:34
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition version.h.in:121
#define OPENVDB_USE_VERSION_NAMESPACE
Definition version.h.in:218