10 #ifndef OPENVDB_POINTS_INDEX_ITERATOR_HAS_BEEN_INCLUDED 11 #define OPENVDB_POINTS_INDEX_ITERATOR_HAS_BEEN_INCLUDED 13 #include <openvdb/version.h> 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(); }
194 inline Coord
getCoord()
const { assert(mIter);
return mIter.getCoord(); }
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(); }
313 template <
typename IterT>
317 for (IterT newIter(iter); newIter; ++newIter, ++size) { }
329 #endif // OPENVDB_POINTS_INDEX_ITERATOR_HAS_BEEN_INCLUDED void reset(const LeafT &)
Definition: IndexIterator.h:58
Index32 operator*() const
Definition: IndexIterator.h:261
bool next()
Advance to the next (valid) item.
Definition: IndexIterator.h:190
A no-op filter that can be used when iterating over all indices.
Definition: IndexIterator.h:50
ValueVoxelCIter(const ValueVoxelCIter &other)
Definition: IndexIterator.h:81
Coord getCoord() const
Return the coordinates of the item to which the value iterator is pointing.
Definition: IndexIterator.h:194
#define OPENVDB_THROW(exception, message)
Definition: Exceptions.h:74
bool operator==(const ValueVoxelCIter &other) const
Equality operators.
Definition: IndexIterator.h:115
ValueIndexIter(const ValueIndexIter &other)
Definition: IndexIterator.h:157
Definition: IndexIterator.h:41
bool increment()
Definition: IndexIterator.h:287
IndexIter(const IteratorT &iterator, const FilterT &filter)
Definition: IndexIterator.h:215
Parent & parent()
Definition: IndexIterator.h:97
bool operator==(const IndexIter &other) const
Equality operators.
Definition: IndexIterator.h:301
IndexIter & operator++()
Advance to the next (valid) item (prefix).
Definition: IndexIterator.h:268
static bool valid(const IterT &)
Definition: IndexIterator.h:59
void reset(Index32 item, Index32 end)
Definition: IndexIterator.h:166
Parent(Index32 offset)
Definition: IndexIterator.h:70
Index32 end() const
Definition: IndexIterator.h:93
bool operator==(const ValueIndexIter &other) const
Equality operators.
Definition: IndexIterator.h:205
bool test() const
Definition: IndexIterator.h:265
bool isValueOn() const
Return true if this iterator is pointing to an active value.
Definition: IndexIterator.h:199
bool operator!=(const IndexIter &other) const
Definition: IndexIterator.h:302
Index32 end() const
Definition: IndexIterator.h:249
Index32 operator*()
Returns the item to which this iterator is currently pointing.
Definition: IndexIterator.h:260
State
Definition: IndexIterator.h:39
IndexIter(const IndexIter &other)
Definition: IndexIterator.h:227
static index::State state()
Definition: IndexIterator.h:54
static index::State state(const LeafT &)
Definition: IndexIterator.h:56
Index32 offset()
Definition: IndexIterator.h:98
A forward iterator over array indices in a single voxel.
Definition: IndexIterator.h:64
ValueIndexIter(const IteratorT &iter)
Definition: IndexIterator.h:146
uint64_t Index64
Definition: Types.h:53
Index32 operator*() const
Definition: IndexIterator.h:173
void reset(Index32, Index32)
Definition: IndexIterator.h:95
Definition: Exceptions.h:13
Definition: IndexIterator.h:67
Definition: Exceptions.h:63
Coord getCoord() const
Return the coordinates of the item to which the value iterator is pointing.
Definition: IndexIterator.h:293
bool next()
Advance to the next (valid) item.
Definition: IndexIterator.h:286
A forward iterator over array indices with filtering IteratorT can be either IndexIter or ValueIndexI...
Definition: IndexIterator.h:139
Definition: IndexIterator.h:43
ValueIndexIter & operator++()
Advance to the next (valid) item (prefix).
Definition: IndexIterator.h:180
bool isValueOn() const
Return true if the value iterator is pointing to an active value.
Definition: IndexIterator.h:298
IndexIter & operator=(const IndexIter &other)
Definition: IndexIterator.h:236
bool operator!=(const ValueVoxelCIter &other) const
Equality operators.
Definition: IndexIterator.h:116
Index32 operator*() const
Definition: IndexIterator.h:86
IndexIter operator++(int)
Advance to the next (valid) item (postfix).
Definition: IndexIterator.h:279
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(Index32 prevOffset, Index32 offset)
Definition: IndexIterator.h:79
bool test() const
Definition: IndexIterator.h:92
ValueVoxelCIter & operator++()
Advance to the next (valid) item (prefix).
Definition: IndexIterator.h:89
const FilterT & filter() const
Return the const filter.
Definition: IndexIterator.h:290
Index64 iterCount(const IterT &iter)
Count up the number of times the iterator can iterate.
Definition: IndexIterator.h:314
void getCoord(Coord &xyz) const
Return in xyz the coordinates of the item to which the value iterator is pointing.
Definition: IndexIterator.h:196
A forward iterator over array indices from a value iterator (such as ValueOnCIter) ...
Definition: IndexIterator.h:143
void reset(Index32 begin, Index32 end)
Reset the begining and end of the iterator.
Definition: IndexIterator.h:252
bool operator!=(const ValueIndexIter &other) const
Definition: IndexIterator.h:206
bool next()
Definition: IndexIterator.h:99
Index32 operator*()
Return the item to which this iterator is currently pointing.
Definition: IndexIterator.h:85
uint32_t Index32
Definition: Types.h:52
Index32 end() const
Definition: IndexIterator.h:164
static bool initialized()
Definition: IndexIterator.h:53
const IteratorT & valueIter() const
Return the const value iterator.
Definition: IndexIterator.h:202
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition: version.h.in:116
bool test() const
Definition: IndexIterator.h:177
bool operator==(const Vec3< T0 > &v0, const Vec3< T1 > &v1)
Equality operator, does exact floating point comparisons.
Definition: Vec3.h:477
Index32 getValue(unsigned) const
Definition: IndexIterator.h:71
bool increment()
Definition: IndexIterator.h:191
Index32 operator*()
Returns the item to which this iterator is currently pointing.
Definition: IndexIterator.h:172
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h.in:202
Definition: IndexIterator.h:42