Go to the documentation of this file.
10 #ifndef OPENVDB_POINTS_INDEX_ITERATOR_HAS_BEEN_INCLUDED
11 #define OPENVDB_POINTS_INDEX_ITERATOR_HAS_BEEN_INCLUDED
27 template <
typename IterT>
55 template <
typename LeafT>
58 template <
typename LeafT>
void reset(
const LeafT&) { }
59 template <
typename IterT>
static bool valid(
const IterT&) {
return true; }
80 : mOffset(offset), mParent(prevOffset) {}
82 : mOffset(other.mOffset), mParent(other.mParent), mValid(other.mValid) {}
91 operator bool()
const {
return mValid; }
92 bool test()
const {
return mValid; }
99 inline bool next() { this->operator++();
return this->test(); }
103 Coord getCoord [[noreturn]] ()
const {
106 void getCoord [[noreturn]] (
Coord& )
const {
109 bool isValueOn [[noreturn]] ()
const {
122 mutable bool mValid =
true;
138 template <
typename IteratorT,
typename FilterT>
147 : mIter(iter), mParent(&mIter.parent())
151 Index32 start = (mIter.offset() > 0 ?
153 this->reset(start, *mIter);
154 if (mItem >= mEnd) this->operator++();
158 : mEnd(other.mEnd), mItem(other.mItem), mIter(other.mIter), mParent(other.mParent)
176 inline operator bool()
const {
return mIter; }
177 inline bool test()
const {
return mIter; }
182 while (mItem >= mEnd && mIter.next()) {
184 this->reset(mParent->getValue(mIter.offset() - 1), *mIter);
190 inline bool next() { this->operator++();
return this->test(); }
191 inline bool increment() { this->next();
return this->test(); }
196 inline void getCoord(
Coord& xyz)
const { assert(mIter); xyz = mIter.getCoord(); }
199 inline bool isValueOn()
const { assert(mIter);
return mIter.isValueOn(); }
202 inline const IteratorT&
valueIter()
const {
return mIter; }
212 const typename IteratorT::NodeType* mParent;
215 IndexIter(
const IteratorT& iterator,
const FilterT& filter)
216 : mIterator(iterator)
219 if (!mFilter.initialized()) {
221 "Filter needs to be initialized before constructing the iterator.");
224 this->reset(*mIterator, mIterator.end());
228 : mIterator(other.mIterator)
229 , mFilter(other.mFilter)
231 if (!mFilter.initialized()) {
233 "Filter needs to be initialized before constructing the iterator.");
238 if (&other !=
this) {
239 mIterator = other.mIterator;
240 mFilter = other.mFilter;
241 if (!mFilter.initialized()) {
243 "Filter needs to be initialized before constructing the iterator.");
253 mIterator.reset(begin, end);
254 while (mIterator.test() && !mFilter.template valid<ValueIndexIter>(mIterator)) {
264 operator bool()
const {
return mIterator.test(); }
265 bool test()
const {
return mIterator.test(); }
271 if (!mIterator.test() || mFilter.template valid<ValueIndexIter>(mIterator)) {
286 bool next() { this->operator++();
return this->test(); }
290 inline const FilterT&
filter()
const {
return mFilter; }
293 inline Coord getCoord()
const { assert(mIterator);
return mIterator.getCoord(); }
295 inline void getCoord(
Coord& xyz)
const { assert(mIterator); xyz = mIterator.getCoord(); }
298 inline bool isValueOn()
const { assert(mIterator);
return mIterator.valueIter().isValueOn(); }
305 ValueIndexIter mIterator;
313 template <
typename IterT>
317 for (IterT newIter(iter); newIter; ++newIter, ++size) { }
329 #endif // OPENVDB_POINTS_INDEX_ITERATOR_HAS_BEEN_INCLUDED
bool next()
Advance to the next (valid) item.
Definition: IndexIterator.h:286
bool operator==(const IndexIter &other) const
Equality operators.
Definition: IndexIterator.h:301
IndexIter(const IndexIter &other)
Definition: IndexIterator.h:227
Signed (x, y, z) 32-bit integer coordinates.
Definition: Coord.h:26
ValueIndexIter & operator++()
Advance to the next (valid) item (prefix).
Definition: IndexIterator.h:180
bool test() const
Definition: IndexIterator.h:92
static bool valid(const IterT &)
Definition: IndexIterator.h:59
Index32 operator*() const
Definition: IndexIterator.h:86
void getCoord(Coord &xyz) const
Return in xyz the coordinates of the item to which the value iterator is pointing.
Definition: IndexIterator.h:295
ValueVoxelCIter()=default
A no-op filter that can be used when iterating over all indices.
Definition: IndexIterator.h:51
Parent(Index32 offset)
Definition: IndexIterator.h:70
bool next()
Definition: IndexIterator.h:99
Coord getCoord() const
Return the coordinates of the item to which the value iterator is pointing.
Definition: IndexIterator.h:194
void reset(Index32 item, Index32 end)
Definition: IndexIterator.h:166
void getCoord(Coord &xyz) const
Return in xyz the coordinates of the item to which the value iterator is pointing.
Definition: IndexIterator.h:196
void reset(Index32 begin, Index32 end)
Reset the begining and end of the iterator.
Definition: IndexIterator.h:252
static index::State state()
Definition: IndexIterator.h:54
@ NONE
Definition: IndexIterator.h:42
static index::State state(const LeafT &)
Definition: IndexIterator.h:56
void reset(const LeafT &)
Definition: IndexIterator.h:58
Library and file format version numbers.
Index32 operator*() const
Definition: IndexIterator.h:261
Index32 end() const
Definition: IndexIterator.h:164
Index32 end() const
Definition: IndexIterator.h:93
IndexIter operator++(int)
Advance to the next (valid) item (postfix).
Definition: IndexIterator.h:279
ValueVoxelCIter(const ValueVoxelCIter &other)
Definition: IndexIterator.h:81
#define OPENVDB_THROW(exception, message)
Definition: openvdb/Exceptions.h:82
@ PARTIAL
Definition: IndexIterator.h:41
Index32 getValue(unsigned) const
Definition: IndexIterator.h:71
uint32_t Index32
Definition: openvdb/Types.h:30
bool test() const
Definition: IndexIterator.h:265
const FilterT & filter() const
Return the const filter.
Definition: IndexIterator.h:290
State
Definition: IndexIterator.h:40
const IteratorT & valueIter() const
Return the const value iterator.
Definition: IndexIterator.h:202
bool operator!=(const ValueVoxelCIter &other) const
Equality operators.
Definition: IndexIterator.h:116
uint64_t Index64
Definition: openvdb/Types.h:31
ValueIndexIter(const IteratorT &iter)
Definition: IndexIterator.h:146
bool next()
Advance to the next (valid) item.
Definition: IndexIterator.h:190
Index32 end() const
Definition: IndexIterator.h:249
Index32 offset()
Definition: IndexIterator.h:98
Index64 iterCount(const IterT &iter)
Count up the number of times the iterator can iterate.
Definition: IndexIterator.h:314
bool operator==(const Vec3< T0 > &v0, const Vec3< T1 > &v1)
Equality operator, does exact floating point comparisons.
Definition: Vec3.h:471
bool isValueOn() const
Return true if this iterator is pointing to an active value.
Definition: IndexIterator.h:199
ValueIndexIter(const ValueIndexIter &other)
Definition: IndexIterator.h:157
IndexIter & operator=(const IndexIter &other)
Definition: IndexIterator.h:236
IndexIter & operator++()
Advance to the next (valid) item (prefix).
Definition: IndexIterator.h:268
bool test() const
Definition: IndexIterator.h:177
Index32 operator*()
Returns the item to which this iterator is currently pointing.
Definition: IndexIterator.h:172
ValueVoxelCIter & operator++()
Advance to the next (valid) item (prefix).
Definition: IndexIterator.h:89
void reset(Index32, Index32)
Definition: IndexIterator.h:95
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h:147
bool operator!=(const IndexIter &other) const
Definition: IndexIterator.h:302
bool operator!=(const ValueIndexIter &other) const
Definition: IndexIterator.h:206
bool increment()
Definition: IndexIterator.h:191
ValueIndexIter & operator=(const ValueIndexIter &)=default
A forward iterator over array indices with filtering IteratorT can be either IndexIter or ValueIndexI...
Definition: IndexIterator.h:140
static bool initialized()
Definition: IndexIterator.h:53
bool isValueOn() const
Return true if the value iterator is pointing to an active value.
Definition: IndexIterator.h:298
A forward iterator over array indices in a single voxel.
Definition: IndexIterator.h:65
Index32 operator*()
Return the item to which this iterator is currently pointing.
Definition: IndexIterator.h:85
@ ALL
Definition: IndexIterator.h:43
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition: version.h:95
Definition: openvdb/Exceptions.h:63
Definition: IndexIterator.h:68
bool operator==(const ValueIndexIter &other) const
Equality operators.
Definition: IndexIterator.h:205
bool operator==(const ValueVoxelCIter &other) const
Equality operators.
Definition: IndexIterator.h:115
Index32 operator*()
Returns the item to which this iterator is currently pointing.
Definition: IndexIterator.h:260
Index32 operator*() const
Definition: IndexIterator.h:173
bool increment()
Definition: IndexIterator.h:287
Definition: openvdb/Exceptions.h:13
IndexIter(const IteratorT &iterator, const FilterT &filter)
Definition: IndexIterator.h:215
ValueVoxelCIter(Index32 prevOffset, Index32 offset)
Definition: IndexIterator.h:79
Parent & parent()
Definition: IndexIterator.h:97
Coord getCoord() const
Return the coordinates of the item to which the value iterator is pointing.
Definition: IndexIterator.h:293
A forward iterator over array indices from a value iterator (such as ValueOnCIter)
Definition: IndexIterator.h:144