35 #ifndef OPENVDB_TREE_ITERATOR_HAS_BEEN_INCLUDED
36 #define OPENVDB_TREE_ITERATOR_HAS_BEEN_INCLUDED
39 #include <boost/type_traits/remove_const.hpp>
40 #include <openvdb/util/NodeMasks.h>
41 #include <openvdb/Exceptions.h>
55 template<
typename MaskIterT,
typename NodeT>
61 mParentNode(parent), mMaskIter(iter) {}
65 mParentNode = other.mParentNode;
66 mMaskIter = other.mMaskIter;
71 return (mParentNode == other.mParentNode) && (mMaskIter == other.mMaskIter);
75 return !(*
this == other);
95 Index pos()
const {
return mMaskIter.offset(); }
98 bool test()
const {
return mMaskIter.test(); }
100 operator bool()
const {
return this->test(); }
103 bool next() {
return mMaskIter.next(); }
113 bool isValueOn()
const {
return parent().isValueMaskOn(this->pos()); }
116 void setValueOn(
bool on =
true)
const { parent().setValueMask(this->pos(), on); }
121 void setValueOff()
const { parent().mValueMask.setOff(this->pos()); }
135 mutable NodeT* mParentNode;
155 static const bool IsSparseIterator =
true, IsDenseIterator =
false;
163 ItemT& getItem(
Index)
const;
166 void setItem(
Index,
const ItemT&)
const;
174 ItemT& getValue()
const
176 return static_cast<const IterT*
>(
this)->getItem(this->pos());
180 void setValue(
const ItemT& value)
const
182 static_cast<const IterT*
>(
this)->setItem(this->pos(), value);
208 static const bool IsSparseIterator =
false, IsDenseIterator =
true;
218 bool getItem(
Index, SetItemT*& child, NonConstValueType& value)
const;
221 void setItem(
Index, SetItemT*)
const;
224 void unsetItem(
Index,
const UnsetItemT&)
const;
227 bool isChildNode()
const {
return this->parent().isChildMaskOn(this->pos()); }
233 SetItemT* child = NULL;
234 static_cast<const IterT*
>(
this)->getItem(this->pos(), child, value);
242 child = probeChild(value);
243 return (child != NULL);
250 SetItemT* child = NULL;
251 const bool isChild =
static_cast<const IterT*
>(
this)->
252 getItem(this->pos(), child, value);
258 void setChild(SetItemT* child)
const
260 static_cast<const IterT*
>(
this)->setItem(this->pos(), child);
265 void setValue(
const UnsetItemT& value)
const
267 static_cast<const IterT*
>(
this)->unsetItem(this->pos(), value);
275 #endif // OPENVDB_TREE_ITERATOR_HAS_BEEN_INCLUDED