37 #ifndef OPENVDB_POINTS_INDEX_ITERATOR_HAS_BEEN_INCLUDED 38 #define OPENVDB_POINTS_INDEX_ITERATOR_HAS_BEEN_INCLUDED 40 #include <openvdb/version.h> 41 #include <openvdb/Types.h> 54 template <
typename IterT>
82 template <
typename LeafT>
85 template <
typename LeafT>
void reset(
const LeafT&) { }
86 template <
typename IterT>
static bool valid(
const IterT&) {
return true; }
107 : mOffset(offset), mParent(prevOffset) {}
109 : mOffset(other.mOffset), mParent(other.mParent), mValid(other.mValid) {}
118 operator bool()
const {
return mValid; }
119 bool test()
const {
return mValid; }
126 inline bool next() { this->operator++();
return this->test(); }
130 Coord getCoord [[noreturn]] ()
const {
133 void getCoord [[noreturn]] (
Coord& )
const {
136 bool isValueOn [[noreturn]] ()
const {
149 mutable bool mValid =
true;
165 template <
typename IteratorT,
typename FilterT>
174 : mIter(iter), mParent(&mIter.parent())
178 Index32 start = (mIter.offset() > 0 ?
180 this->reset(start, *mIter);
181 if (mItem >= mEnd) this->operator++();
185 : mEnd(other.mEnd), mItem(other.mItem), mIter(other.mIter), mParent(other.mParent)
203 inline operator bool()
const {
return mIter; }
204 inline bool test()
const {
return mIter; }
209 while (mItem >= mEnd && mIter.next()) {
211 this->reset(mParent->getValue(mIter.offset() - 1), *mIter);
217 inline bool next() { this->operator++();
return this->test(); }
218 inline bool increment() { this->next();
return this->test(); }
223 inline void getCoord(
Coord& xyz)
const { assert(mIter); xyz = mIter.getCoord(); }
226 inline bool isValueOn()
const { assert(mIter);
return mIter.isValueOn(); }
229 inline const IteratorT&
valueIter()
const {
return mIter; }
239 const typename IteratorT::NodeType* mParent;
242 IndexIter(
const IteratorT& iterator,
const FilterT& filter)
243 : mIterator(iterator)
246 if (!mFilter.initialized()) {
248 "Filter needs to be initialized before constructing the iterator.");
251 this->reset(*mIterator, mIterator.end());
255 : mIterator(other.mIterator)
256 , mFilter(other.mFilter)
258 if (!mFilter.initialized()) {
260 "Filter needs to be initialized before constructing the iterator.");
265 if (&other !=
this) {
266 mIterator = other.mIterator;
267 mFilter = other.mFilter;
268 if (!mFilter.initialized()) {
270 "Filter needs to be initialized before constructing the iterator.");
280 mIterator.reset(begin, end);
281 while (mIterator.test() && !mFilter.template valid<ValueIndexIter>(mIterator)) {
291 operator bool()
const {
return mIterator.test(); }
292 bool test()
const {
return mIterator.test(); }
298 if (!mIterator.test() || mFilter.template valid<ValueIndexIter>(mIterator)) {
313 bool next() { this->operator++();
return this->test(); }
317 inline const FilterT&
filter()
const {
return mFilter; }
320 inline Coord getCoord()
const { assert(mIterator);
return mIterator.getCoord(); }
322 inline void getCoord(
Coord& xyz)
const { assert(mIterator); xyz = mIterator.getCoord(); }
325 inline bool isValueOn()
const { assert(mIterator);
return mIterator.valueIter().isValueOn(); }
340 template <
typename IterT>
344 for (IterT newIter(iter); newIter; ++newIter, ++size) { }
356 #endif // OPENVDB_POINTS_INDEX_ITERATOR_HAS_BEEN_INCLUDED Index32 end() const
Definition: IndexIterator.h:191
bool test() const
Definition: IndexIterator.h:204
bool operator!=(const ValueIndexIter &other) const
Definition: IndexIterator.h:233
Index32 operator*()
Returns the item to which this iterator is currently pointing.
Definition: IndexIterator.h:287
Index32 operator*() const
Definition: IndexIterator.h:200
static index::State state()
Definition: IndexIterator.h:81
bool operator==(const ValueIndexIter &other) const
Equality operators.
Definition: IndexIterator.h:232
Definition: IndexIterator.h:94
ValueIndexIter(const ValueIndexIter &other)
Definition: IndexIterator.h:184
IndexIter(const IteratorT &iterator, const FilterT &filter)
Definition: IndexIterator.h:242
static index::State state(const LeafT &)
Definition: IndexIterator.h:83
Parent(Index32 offset)
Definition: IndexIterator.h:97
IndexIter(const IndexIter &other)
Definition: IndexIterator.h:254
void reset(Index32 item, Index32 end)
Definition: IndexIterator.h:193
ValueVoxelCIter(const ValueVoxelCIter &other)
Definition: IndexIterator.h:108
Coord getCoord() const
Return the coordinates of the item to which the value iterator is pointing.
Definition: IndexIterator.h:320
#define OPENVDB_THROW(exception, message)
Definition: Exceptions.h:109
Signed (x, y, z) 32-bit integer coordinates.
Definition: Coord.h:51
const IteratorT & valueIter() const
Return the const value iterator.
Definition: IndexIterator.h:229
Parent & parent()
Definition: IndexIterator.h:124
ValueIndexIter(const IteratorT &iter)
Definition: IndexIterator.h:173
Definition: IndexIterator.h:68
bool isValueOn() const
Return true if this iterator is pointing to an active value.
Definition: IndexIterator.h:226
Definition: IndexIterator.h:69
bool next()
Advance to the next (valid) item.
Definition: IndexIterator.h:313
Index32 offset()
Definition: IndexIterator.h:125
ValueIndexIter & operator++()
Advance to the next (valid) item (prefix).
Definition: IndexIterator.h:207
bool operator==(const IndexIter &other) const
Equality operators.
Definition: IndexIterator.h:328
Index32 end() const
Definition: IndexIterator.h:276
Definition: IndexIterator.h:70
void getCoord(Coord &xyz) const
Return in xyz the coordinates of the item to which the value iterator is pointing.
Definition: IndexIterator.h:223
IndexIter & operator++()
Advance to the next (valid) item (prefix).
Definition: IndexIterator.h:295
IndexIter operator++(int)
Advance to the next (valid) item (postfix).
Definition: IndexIterator.h:306
bool next()
Advance to the next (valid) item.
Definition: IndexIterator.h:217
A forward iterator over array indices in a single voxel.
Definition: IndexIterator.h:91
void getCoord(Coord &xyz) const
Return in xyz the coordinates of the item to which the value iterator is pointing.
Definition: IndexIterator.h:322
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition: version.h:136
Index32 getValue(unsigned) const
Definition: IndexIterator.h:98
bool isValueOn() const
Return true if the value iterator is pointing to an active value.
Definition: IndexIterator.h:325
const FilterT & filter() const
Return the const filter.
Definition: IndexIterator.h:317
ValueVoxelCIter & operator++()
Advance to the next (valid) item (prefix).
Definition: IndexIterator.h:116
Index64 iterCount(const IterT &iter)
Count up the number of times the iterator can iterate.
Definition: IndexIterator.h:341
void reset(Index32 begin, Index32 end)
Reset the begining and end of the iterator.
Definition: IndexIterator.h:279
Coord getCoord() const
Return the coordinates of the item to which the value iterator is pointing.
Definition: IndexIterator.h:221
Definition: Exceptions.h:40
Definition: Exceptions.h:90
bool test() const
Definition: IndexIterator.h:292
A no-op filter that can be used when iterating over all indices.
Definition: IndexIterator.h:77
Index32 operator*() const
Definition: IndexIterator.h:113
Index32 operator*()
Returns the item to which this iterator is currently pointing.
Definition: IndexIterator.h:199
Index32 operator*() const
Definition: IndexIterator.h:288
Index32 operator*()
Return the item to which this iterator is currently pointing.
Definition: IndexIterator.h:112
uint64_t Index64
Definition: Types.h:60
Index32 end() const
Definition: IndexIterator.h:120
bool operator==(const Vec3< T0 > &v0, const Vec3< T1 > &v1)
Equality operator, does exact floating point comparisons.
Definition: Vec3.h:488
bool operator!=(const ValueVoxelCIter &other) const
Equality operators.
Definition: IndexIterator.h:143
A forward iterator over array indices with filtering IteratorT can be either IndexIter or ValueIndexI...
Definition: IndexIterator.h:166
void reset(Index32, Index32)
Definition: IndexIterator.h:122
bool operator==(const ValueVoxelCIter &other) const
Equality operators.
Definition: IndexIterator.h:142
IndexIter & operator=(const IndexIter &other)
Definition: IndexIterator.h:263
static bool valid(const IterT &)
Definition: IndexIterator.h:86
A forward iterator over array indices from a value iterator (such as ValueOnCIter) ...
Definition: IndexIterator.h:170
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h:188
static bool initialized()
Definition: IndexIterator.h:80
ValueVoxelCIter(Index32 prevOffset, Index32 offset)
Definition: IndexIterator.h:106
bool operator!=(const IndexIter &other) const
Definition: IndexIterator.h:329
bool next()
Definition: IndexIterator.h:126
bool test() const
Definition: IndexIterator.h:119
State
Definition: IndexIterator.h:66
uint32_t Index32
Definition: Types.h:59
bool increment()
Definition: IndexIterator.h:218
void reset(const LeafT &)
Definition: IndexIterator.h:85
bool increment()
Definition: IndexIterator.h:314