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);
92 Index pos()
const {
return mMaskIter.offset(); }
95 bool test()
const {
return mMaskIter.test(); }
97 operator bool()
const {
return this->test(); }
100 bool next() {
return mMaskIter.next(); }
110 bool isValueOn()
const {
return parent().isValueMaskOn(this->pos()); }
113 void setValueOn(
bool on =
true)
const { parent().setValueMask(this->pos(), on); }
118 void setValueOff()
const { parent().mValueMask.setOff(this->pos()); }
132 mutable NodeT* mParentNode;
152 static const bool IsSparseIterator =
true, IsDenseIterator =
false;
160 ItemT& getItem(
Index)
const;
163 void setItem(
Index,
const ItemT&)
const;
171 ItemT& getValue()
const
173 return static_cast<const IterT*
>(
this)->getItem(this->pos());
177 void setValue(
const ItemT& value)
const
179 static_cast<const IterT*
>(
this)->setItem(this->pos(), value);
205 static const bool IsSparseIterator =
false, IsDenseIterator =
true;
215 bool getItem(
Index, SetItemT*& child, NonConstValueType& value)
const;
218 void setItem(
Index, SetItemT*)
const;
221 void unsetItem(
Index,
const UnsetItemT&)
const;
224 bool isChildNode()
const {
return this->parent().isChildMaskOn(this->pos()); }
230 SetItemT* child = NULL;
231 static_cast<const IterT*
>(
this)->getItem(this->pos(), child, value);
239 child = probeChild(value);
240 return (child != NULL);
247 SetItemT* child = NULL;
248 const bool isChild =
static_cast<const IterT*
>(
this)->
249 getItem(this->pos(), child, value);
255 void setChild(SetItemT* child)
const
257 static_cast<const IterT*
>(
this)->setItem(this->pos(), child);
262 void setValue(
const UnsetItemT& value)
const
264 static_cast<const IterT*
>(
this)->unsetItem(this->pos(), value);
272 #endif // OPENVDB_TREE_ITERATOR_HAS_BEEN_INCLUDED