35 #ifndef OPENVDB_TREE_ITERATOR_HAS_BEEN_INCLUDED 36 #define OPENVDB_TREE_ITERATOR_HAS_BEEN_INCLUDED 39 #include <type_traits> 55 template<
typename MaskIterT,
typename NodeT>
60 IteratorBase(
const MaskIterT& iter, NodeT* parent): mParentNode(parent), mMaskIter(iter) {}
66 return (mParentNode == other.mParentNode) && (mMaskIter == other.mMaskIter);
70 return !(*
this == other);
87 Index pos()
const {
return mMaskIter.offset(); }
90 bool test()
const {
return mMaskIter.test(); }
92 operator bool()
const {
return this->test(); }
95 bool next() {
return mMaskIter.next(); }
105 bool isValueOn()
const {
return parent().isValueMaskOn(this->pos()); }
108 void setValueOn(
bool on =
true)
const { parent().setValueMask(this->pos(), on); }
113 void setValueOff()
const { parent().mValueMask.setOff(this->pos()); }
116 Coord getCoord()
const {
return parent().offsetToGlobalCoord(this->pos()); }
127 mutable NodeT* mParentNode;
147 static const bool IsSparseIterator =
true, IsDenseIterator =
false;
155 ItemT& getItem(
Index)
const;
158 void setItem(
Index,
const ItemT&)
const;
168 return static_cast<const IterT*>(
this)->getItem(this->pos());
174 static_assert(!std::is_const<NodeT>::value,
"setValue() not allowed for const iterators");
175 static_cast<const IterT*>(
this)->setItem(this->pos(), value);
182 template<
typename ModifyOp>
185 static_assert(!std::is_const<NodeT>::value,
186 "modifyValue() not allowed for const iterators");
187 static_cast<const IterT*>(
this)->modifyItem(this->pos(), op);
213 static const bool IsSparseIterator =
false, IsDenseIterator =
true;
223 bool getItem(
Index, SetItemT*& child, NonConstValueType& value)
const;
226 void setItem(
Index, SetItemT*)
const;
229 void unsetItem(
Index,
const UnsetItemT&)
const;
232 bool isChildNode()
const {
return this->parent().isChildMaskOn(this->pos()); }
238 SetItemT* child =
nullptr;
239 static_cast<const IterT*>(
this)->getItem(this->pos(), child, value);
247 child = probeChild(value);
248 return (child !=
nullptr);
255 SetItemT* child =
nullptr;
256 const bool isChild = static_cast<const IterT*>(
this)->
257 getItem(this->pos(), child, value);
265 static_cast<const IterT*>(
this)->setItem(this->pos(), child);
272 static_cast<const IterT*>(
this)->unsetItem(this->pos(), value);
280 #endif // OPENVDB_TREE_ITERATOR_HAS_BEEN_INCLUDED bool operator!=(const IteratorBase &other) const
Definition: Iterator.h:68
SetItemT * probeChild(NonConstValueType &value) const
If this iterator is pointing to a child node, return a pointer to the node. Otherwise,...
Definition: Iterator.h:236
typename std::remove_const< ValueT >::type NonConstValueType
Definition: Iterator.h:211
bool isChildNode() const
Return true if this iterator is pointing to a child node.
Definition: Iterator.h:232
IteratorBase(const MaskIterT &iter, NodeT *parent)
Definition: Iterator.h:60
IteratorBase()
Definition: Iterator.h:59
Base class for iterators over internal and leaf nodes.
Definition: Iterator.h:56
Index32 Index
Definition: Types.h:61
bool next()
Advance to the next item in the parent node's table.
Definition: Iterator.h:95
typename std::remove_const< NodeT >::type NonConstNodeType
Definition: Iterator.h:145
Base class for dense iterators over internal and leaf nodes.
Definition: Iterator.h:205
ItemT & getValue() const
Return the item to which this iterator is pointing.
Definition: Iterator.h:166
#define OPENVDB_THROW(exception, message)
Definition: Exceptions.h:109
Base class for sparse iterators over internal and leaf nodes.
Definition: Iterator.h:141
ValueT ValueType
Definition: Iterator.h:144
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:172
typename std::remove_const< ChildT >::type NonConstChildNodeType
Definition: Iterator.h:212
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:108
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:645
Signed (x, y, z) 32-bit integer coordinates.
Definition: Coord.h:51
NodeT NodeType
Definition: Iterator.h:207
DenseIteratorBase(const MaskIterT &iter, NodeT *parent)
Definition: Iterator.h:216
IteratorBase & operator++()
Advance to the next item in the parent node's table.
Definition: Iterator.h:99
NodeT NodeType
Definition: Iterator.h:143
typename std::remove_const< ValueT >::type NonConstValueType
Definition: Iterator.h:146
Index pos() const
Identical to offset.
Definition: Iterator.h:87
bool test() const
Return true if this iterator is not yet exhausted.
Definition: Iterator.h:90
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition: version.h:136
typename std::remove_const< NodeT >::type NonConstNodeType
Definition: Iterator.h:210
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:105
bool probeValue(NonConstValueType &value) const
Return true if this iterator is pointing to a value and return the value in value....
Definition: Iterator.h:253
Definition: Exceptions.h:40
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:270
Index offset() const
Return this iterator's position as an index into the parent node's table.
Definition: Iterator.h:84
bool operator==(const IteratorBase &other) const
Definition: Iterator.h:64
ValueT ValueType
Definition: Iterator.h:208
DenseIteratorBase()
Definition: Iterator.h:215
Coord getCoord() const
Return the coordinates of the item to which this iterator is pointing.
Definition: Iterator.h:116
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:183
ItemT * operator->() const
Return a pointer to the item to which this iterator is pointing.
Definition: Iterator.h:163
NodeT & parent() const
Return a reference to the node over which this iterator is iterating.
Definition: Iterator.h:77
ChildT ChildNodeType
Definition: Iterator.h:209
void setValueOff() const
If this iterator is pointing to a value, mark the value as inactive.
Definition: Iterator.h:113
void increment()
Advance to the next item in the parent node's table.
Definition: Iterator.h:97
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:263
Definition: Exceptions.h:92
SparseIteratorBase(const MaskIterT &iter, NodeT *parent)
Definition: Iterator.h:150
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h:188
NodeT * getParentNode() const
Return a pointer to the node (if any) over which this iterator is iterating.
Definition: Iterator.h:74
SparseIteratorBase()
Definition: Iterator.h:149
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:245
void getCoord(Coord &xyz) const
Return in xyz the coordinates of the item to which this iterator is pointing.
Definition: Iterator.h:118
void increment(Index n)
Advance n items in the parent node's table.
Definition: Iterator.h:101