Go to the documentation of this file.
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>
33 IteratorBase(
const MaskIterT& iter, NodeT* parent): mParentNode(parent), mMaskIter(iter) {}
39 return (mParentNode == other.mParentNode) && (mMaskIter == other.mMaskIter);
43 return !(*
this == other);
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(); }
78 bool isValueOn()
const {
return parent().isValueMaskOn(this->pos()); }
81 void setValueOn(
bool on =
true)
const { parent().setValueMask(this->pos(), on); }
86 void setValueOff()
const { parent().mValueMask.setOff(this->pos()); }
89 Coord getCoord()
const {
return parent().offsetToGlobalCoord(this->pos()); }
100 mutable NodeT* mParentNode;
120 static const bool IsSparseIterator =
true, IsDenseIterator =
false;
141 return static_cast<const IterT*
>(
this)->getItem(this->pos());
147 static_assert(!std::is_const<NodeT>::value,
"setValue() not allowed for const iterators");
148 static_cast<const IterT*
>(
this)->setItem(this->pos(), value);
155 template<
typename ModifyOp>
158 static_assert(!std::is_const<NodeT>::value,
159 "modifyValue() not allowed for const iterators");
160 static_cast<const IterT*
>(
this)->modifyItem(this->pos(), op);
186 static const bool IsSparseIterator =
false, IsDenseIterator =
true;
205 bool isChildNode()
const {
return this->parent().isChildMaskOn(this->pos()); }
211 SetItemT* child =
nullptr;
212 static_cast<const IterT*
>(
this)->getItem(this->pos(), child, value);
220 child = probeChild(value);
221 return (child !=
nullptr);
228 SetItemT* child =
nullptr;
229 const bool isChild =
static_cast<const IterT*
>(
this)->
230 getItem(this->pos(), child, value);
238 static_cast<const IterT*
>(
this)->setItem(this->pos(), child);
245 static_cast<const IterT*
>(
this)->unsetItem(this->pos(), value);
253 #endif // OPENVDB_TREE_ITERATOR_HAS_BEEN_INCLUDED
void setValueOff() const
If this iterator is pointing to a value, mark the value as inactive.
Definition: Iterator.h:86
ItemT & getValue() const
Return the item to which this iterator is pointing.
Definition: Iterator.h:139
NodeT & parent() const
Return a reference to the node over which this iterator is iterating.
Definition: Iterator.h:50
IteratorBase & operator=(const IteratorBase &)=default
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...
bool next()
Advance to the next item in the parent node's table.
Definition: Iterator.h:68
Index pos() const
Identical to offset.
Definition: Iterator.h:60
void setValue(const ItemT &value) const
Set the value of the item to which this iterator is pointing. (Not valid for const iterators....
Definition: Iterator.h:145
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...
Definition: Iterator.h:236
Index32 Index
Definition: Types.h:31
SparseIteratorBase()
Definition: Iterator.h:122
ChildT ChildNodeType
Definition: Iterator.h:182
Base class for sparse iterators over internal and leaf nodes.
Definition: Iterator.h:115
DenseIteratorBase(const MaskIterT &iter, NodeT *parent)
Definition: Iterator.h:189
Base class for iterators over internal and leaf nodes.
Definition: Iterator.h:30
bool isValueOn() const
Return true if this iterator is pointing to an active value. Return false if it is pointing to either...
Definition: Iterator.h:78
void modifyValue(const ModifyOp &op) const
Apply a functor to the item to which this iterator is pointing. (Not valid for const iterators....
Definition: Iterator.h:156
void unsetItem(Index, const UnsetItemT &) const
"Unset" the value of the item at the given index in the parent node's table.
bool operator!=(const IteratorBase &other) const
Definition: Iterator.h:41
void setItem(Index, const ItemT &) const
Set the value of the item at the given index in the parent node's table.
Base class for dense iterators over internal and leaf nodes.
Definition: Iterator.h:179
NodeT * getParentNode() const
Return a pointer to the node (if any) over which this iterator is iterating.
Definition: Iterator.h:47
ValueT ValueType
Definition: Iterator.h:181
NodeT NodeType
Definition: Iterator.h:180
bool probeValue(NonConstValueType &value) const
Return true if this iterator is pointing to a value and return the value in value....
Definition: Iterator.h:226
const Name const NamePair & type
Definition: PointAttribute.h:545
ItemT & getItem(Index) const
Return the item at the given index in the parent node's table.
typename std::remove_const< ValueT >::type NonConstValueType
Definition: Iterator.h:184
ItemT * operator->() const
Return a pointer to the item to which this iterator is pointing.
Definition: Iterator.h:136
IteratorBase()
Definition: Iterator.h:32
IteratorBase(const IteratorBase &)=default
bool test() const
Return true if this iterator is not yet exhausted.
Definition: Iterator.h:63
void increment(Index n)
Advance n items in the parent node's table.
Definition: Iterator.h:74
NodeT NodeType
Definition: Iterator.h:116
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.
Definition: Iterator.h:243
Signed (x, y, z) 32-bit integer coordinates.
Definition: Coord.h:26
ItemT & operator*() const
Return a reference to the item to which this iterator is pointing.
Definition: Iterator.h:134
SetItemT * probeChild(NonConstValueType &value) const
If this iterator is pointing to a child node, return a pointer to the node. Otherwise,...
Definition: Iterator.h:209
bool isChildNode() const
Return true if this iterator is pointing to a child node.
Definition: Iterator.h:205
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h:146
DenseIteratorBase()
Definition: Iterator.h:188
typename std::remove_const< ChildT >::type NonConstChildNodeType
Definition: Iterator.h:185
typename std::remove_const< NodeT >::type NonConstNodeType
Definition: Iterator.h:183
void increment()
Advance to the next item in the parent node's table.
Definition: Iterator.h:70
void getCoord(Coord &xyz) const
Return in xyz the coordinates of the item to which this iterator is pointing.
Definition: Iterator.h:91
void setItem(Index, SetItemT *) const
Set the value of the item at the given index in the parent node's table.
Coord getCoord() const
Return the coordinates of the item to which this iterator is pointing.
Definition: Iterator.h:89
typename std::remove_const< NodeT >::type NonConstNodeType
Definition: Iterator.h:118
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition: version.h:94
typename std::remove_const< ValueT >::type NonConstValueType
Definition: Iterator.h:119
void setValueOn(bool on=true) const
If this iterator is pointing to a value, set the value's active state. Otherwise, do nothing.
Definition: Iterator.h:81
bool operator==(const IteratorBase &other) const
Definition: Iterator.h:37
Index offset() const
Return this iterator's position as an index into the parent node's table.
Definition: Iterator.h:57
IteratorBase(const MaskIterT &iter, NodeT *parent)
Definition: Iterator.h:33
Definition: Exceptions.h:65
IteratorBase & operator++()
Advance to the next item in the parent node's table.
Definition: Iterator.h:72
ValueT ValueType
Definition: Iterator.h:117
Definition: Exceptions.h:13
Mat3< typename promote< T0, T1 >::type > operator*(const Mat3< T0 > &m0, const Mat3< T1 > &m1)
Multiply m0 by m1 and return the resulting matrix.
Definition: Mat3.h:618
#define OPENVDB_THROW(exception, message)
Definition: Exceptions.h:82
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...
Definition: Iterator.h:218
SparseIteratorBase(const MaskIterT &iter, NodeT *parent)
Definition: Iterator.h:123