8 #ifndef OPENVDB_TREE_ITERATOR_HAS_BEEN_INCLUDED
9 #define OPENVDB_TREE_ITERATOR_HAS_BEEN_INCLUDED
12 #include <type_traits>
28 template<
typename MaskIterT,
typename NodeT>
39 return (mParentNode == other.mParentNode) && (mMaskIter == other.mMaskIter);
43 return !(*
this == other);
52 if (!mParentNode)
OPENVDB_THROW(ValueError,
"iterator references a null node");
60 Index pos()
const {
return mMaskIter.offset(); }
63 bool test()
const {
return mMaskIter.test(); }
65 operator bool()
const {
return this->
test(); }
68 bool next() {
return mMaskIter.next(); }
100 mutable NodeT* mParentNode;
141 return static_cast<const IterT*
>(
this)->
getItem(this->
pos());
155 template<
typename ModifyOp>
159 "modifyValue() not allowed for const iterators");
160 static_cast<const IterT*
>(
this)->modifyItem(this->
pos(), op);
211 SetItemT* child =
nullptr;
221 return (child !=
nullptr);
228 SetItemT* child =
nullptr;
229 const bool isChild =
static_cast<const IterT*
>(
this)->
238 static_cast<const IterT*
>(
this)->
setItem(this->
pos(), child);
253 #endif // OPENVDB_TREE_ITERATOR_HAS_BEEN_INCLUDED
typename std::remove_const< ValueT >::type NonConstValueType
Coord getCoord() const
Return the coordinates of the item to which this iterator is pointing.
IteratorBase & operator++()
Advance to the next item in the parent node's table.
typename std::remove_const< NodeT >::type NonConstNodeType
bool isValueOn() const
Return true if this iterator is pointing to an active value. Return false if it is pointing to either...
IteratorBase & operator=(const IteratorBase &)=default
GLsizei const GLfloat * value
Index pos() const
Identical to offset.
void increment()
Advance to the next item in the parent node's table.
#define OPENVDB_USE_VERSION_NAMESPACE
Base class for iterators over internal and leaf nodes.
void setItem(Index, SetItemT *) const
Set the value of the item at the given index in the parent node's table.
NodeT & parent() const
Return a reference to the node over which this iterator is iterating.
void modifyValue(const ModifyOp &op) const
Apply a functor to the item to which this iterator is pointing. (Not valid for const iterators...
typename std::remove_const< ChildT >::type NonConstChildNodeType
SetItemT * probeChild(NonConstValueType &value) const
If this iterator is pointing to a child node, return a pointer to the node. Otherwise, return nullptr and, in value, the value to which this iterator is pointing.
bool probeValue(NonConstValueType &value) const
Return true if this iterator is pointing to a value and return the value in value. Otherwise, return false.
IteratorBase(const MaskIterT &iter, NodeT *parent)
void unsetItem(Index, const UnsetItemT &) const
"Unset" the value of the item at the given index in the parent node's table.
bool probeChild(SetItemT *&child, NonConstValueType &value) const
If this iterator is pointing to a child node, return true and return a pointer to the child node in c...
void setItem(Index, const ItemT &) const
Set the value of the item at the given index in the parent node's table.
typename std::remove_const< ValueT >::type NonConstValueType
bool test() const
Return true if this iterator is not yet exhausted.
void setValueOn(bool on=true) const
If this iterator is pointing to a value, set the value's active state. Otherwise, do nothing...
Index offset() const
Return this iterator's position as an index into the parent node's table.
bool getItem(Index, SetItemT *&child, NonConstValueType &value) const
Return true if the item at the given index in the parent node's table is a set value and return eithe...
static const bool IsSparseIterator
Base class for sparse iterators over internal and leaf nodes.
bool operator!=(const IteratorBase &other) const
DenseIteratorBase(const MaskIterT &iter, NodeT *parent)
ItemT * operator->() const
Return a pointer to the item to which this iterator is pointing.
Base class for dense iterators over internal and leaf nodes.
void increment(Index n)
Advance n items in the parent node's table.
bool isChildNode() const
Return true if this iterator is pointing to a child node.
static const bool IsSparseIterator
void getCoord(Coord &xyz) const
Return in xyz the coordinates of the item to which this iterator is pointing.
void setChild(SetItemT *child) const
Replace with the given child node the item in the parent node's table to which this iterator is point...
NodeT * getParentNode() const
Return a pointer to the node (if any) over which this iterator is iterating.
void setValue(const UnsetItemT &value) const
Replace with the given value the item in the parent node's table to which this iterator is pointing...
void setValue(const ItemT &value) const
Set the value of the item to which this iterator is pointing. (Not valid for const iterators...
bool operator==(const IteratorBase &other) const
void setValueOff() const
If this iterator is pointing to a value, mark the value as inactive.
bool next()
Advance to the next item in the parent node's table.
typename std::remove_const< NodeT >::type NonConstNodeType
ItemT & getValue() const
Return the item to which this iterator is pointing.
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
ItemT & operator*() const
Return a reference to the item to which this iterator is pointing.
static const bool IsDenseIterator
ItemT & getItem(Index) const
Return the item at the given index in the parent node's table.
#define OPENVDB_THROW(exception, message)
SparseIteratorBase(const MaskIterT &iter, NodeT *parent)
static const bool IsDenseIterator