10 #ifndef OPENVDB_POINTS_INDEX_ITERATOR_HAS_BEEN_INCLUDED 11 #define OPENVDB_POINTS_INDEX_ITERATOR_HAS_BEEN_INCLUDED 13 #include <openvdb/version.h> 28 template <
typename IterT>
56 template <
typename LeafT>
59 template <
typename LeafT>
void reset(
const LeafT&) { }
60 template <
typename IterT>
static bool valid(
const IterT&) {
return true; }
81 : mOffset(offset), mParent(prevOffset) {}
83 : mOffset(other.mOffset), mParent(other.mParent), mValid(other.mValid) {}
92 operator bool()
const {
return mValid; }
93 bool test()
const {
return mValid; }
100 inline bool next() { this->operator++();
return this->test(); }
104 Coord getCoord [[noreturn]] ()
const {
107 void getCoord [[noreturn]] (Coord& )
const {
110 bool isValueOn [[noreturn]] ()
const {
123 mutable bool mValid =
true;
139 template <
typename IteratorT,
typename FilterT>
148 : mIter(iter), mParent(&mIter.parent())
152 Index32 start = (mIter.offset() > 0 ?
154 this->reset(start, *mIter);
155 if (mItem >= mEnd) this->operator++();
159 : mEnd(other.mEnd), mItem(other.mItem), mIter(other.mIter), mParent(other.mParent)
177 inline operator bool()
const {
return mIter; }
178 inline bool test()
const {
return mIter; }
183 while (mItem >= mEnd && mIter.next()) {
185 this->reset(mParent->getValue(mIter.offset() - 1), *mIter);
191 inline bool next() { this->operator++();
return this->test(); }
192 inline bool increment() { this->next();
return this->test(); }
203 inline const IteratorT&
valueIter()
const {
return mIter; }
213 const typename IteratorT::NodeType* mParent;
216 IndexIter(
const IteratorT& iterator,
const FilterT& filter)
217 : mIterator(iterator)
220 if (!mFilter.initialized()) {
222 "Filter needs to be initialized before constructing the iterator.");
225 this->reset(*mIterator, mIterator.end());
229 : mIterator(other.mIterator)
230 , mFilter(other.mFilter)
232 if (!mFilter.initialized()) {
234 "Filter needs to be initialized before constructing the iterator.");
239 if (&other !=
this) {
240 mIterator = other.mIterator;
241 mFilter = other.mFilter;
242 if (!mFilter.initialized()) {
244 "Filter needs to be initialized before constructing the iterator.");
254 mIterator.reset(begin, end);
255 while (mIterator.test() && !mFilter.template valid<ValueIndexIter>(mIterator)) {
265 operator bool()
const {
return mIterator.test(); }
266 bool test()
const {
return mIterator.test(); }
272 if (!mIterator.test() || mFilter.template valid<ValueIndexIter>(mIterator)) {
287 bool next() { this->operator++();
return this->test(); }
291 inline const FilterT&
filter()
const {
return mFilter; }
314 template <
typename IterT>
318 for (IterT newIter(iter); newIter; ++newIter, ++size) { }
330 #endif // OPENVDB_POINTS_INDEX_ITERATOR_HAS_BEEN_INCLUDED static index::State state(const LeafT &)
Definition: IndexIterator.h:57
Parent & parent()
Definition: IndexIterator.h:98
const IteratorT & valueIter() const
Return the const value iterator.
Definition: IndexIterator.h:203
#define OPENVDB_THROW(exception, message)
Definition: Exceptions.h:74
IndexIter & operator++()
Advance to the next (valid) item (prefix).
Definition: IndexIterator.h:269
bool test() const
Definition: IndexIterator.h:93
uint64_t Index64
Definition: Types.h:53
A forward iterator over array indices from a value iterator (such as ValueOnCIter) ...
Definition: IndexIterator.h:144
const FilterT & filter() const
Return the const filter.
Definition: IndexIterator.h:291
A forward iterator over array indices with filtering IteratorT can be either IndexIter or ValueIndexI...
Definition: IndexIterator.h:140
void getCoord(Coord &xyz) const
Return in xyz the coordinates of the item to which the value iterator is pointing.
Definition: IndexIterator.h:296
static index::State state()
Definition: IndexIterator.h:55
Index32 operator*()
Returns the item to which this iterator is currently pointing.
Definition: IndexIterator.h:261
bool operator!=(const IndexIter &other) const
Definition: IndexIterator.h:303
bool operator==(const ValueVoxelCIter &other) const
Equality operators.
Definition: IndexIterator.h:116
bool operator!=(const ValueVoxelCIter &other) const
Equality operators.
Definition: IndexIterator.h:117
static bool initialized()
Definition: IndexIterator.h:54
Parent(Index32 offset)
Definition: IndexIterator.h:71
bool isValueOn() const
Return true if the value iterator is pointing to an active value.
Definition: IndexIterator.h:299
Index32 end() const
Definition: IndexIterator.h:250
bool next()
Advance to the next (valid) item.
Definition: IndexIterator.h:191
ValueVoxelCIter(const ValueVoxelCIter &other)
Definition: IndexIterator.h:82
Definition: IndexIterator.h:44
Index64 iterCount(const IterT &iter)
Count up the number of times the iterator can iterate.
Definition: IndexIterator.h:315
bool operator==(const Vec3< T0 > &v0, const Vec3< T1 > &v1)
Equality operator, does exact floating point comparisons.
Definition: Vec3.h:474
Index32 offset()
Definition: IndexIterator.h:99
Index32 operator*()
Return the item to which this iterator is currently pointing.
Definition: IndexIterator.h:86
Definition: IndexIterator.h:43
Index32 end() const
Definition: IndexIterator.h:94
bool operator==(const ValueIndexIter &other) const
Equality operators.
Definition: IndexIterator.h:206
Index32 operator*()
Returns the item to which this iterator is currently pointing.
Definition: IndexIterator.h:173
#define OPENVDB_ASSERT(X)
Definition: Assert.h:41
static bool valid(const IterT &)
Definition: IndexIterator.h:60
void reset(Index32, Index32)
Definition: IndexIterator.h:96
Definition: IndexIterator.h:68
Definition: Exceptions.h:13
void getCoord(Coord &xyz) const
Return in xyz the coordinates of the item to which the value iterator is pointing.
Definition: IndexIterator.h:197
Index32 operator*() const
Definition: IndexIterator.h:262
bool test() const
Definition: IndexIterator.h:178
bool operator==(const IndexIter &other) const
Equality operators.
Definition: IndexIterator.h:302
bool operator!=(const ValueIndexIter &other) const
Definition: IndexIterator.h:207
State
Definition: IndexIterator.h:40
uint32_t Index32
Definition: Types.h:52
bool isValueOn() const
Return true if this iterator is pointing to an active value.
Definition: IndexIterator.h:200
bool next()
Definition: IndexIterator.h:100
void reset(Index32 item, Index32 end)
Definition: IndexIterator.h:167
A forward iterator over array indices in a single voxel.
Definition: IndexIterator.h:65
Coord getCoord() const
Return the coordinates of the item to which the value iterator is pointing.
Definition: IndexIterator.h:195
bool next()
Advance to the next (valid) item.
Definition: IndexIterator.h:287
Index32 operator*() const
Definition: IndexIterator.h:174
ValueVoxelCIter(Index32 prevOffset, Index32 offset)
Definition: IndexIterator.h:80
ValueIndexIter(const IteratorT &iter)
Definition: IndexIterator.h:147
IndexIter(const IndexIter &other)
Definition: IndexIterator.h:228
IndexIter operator++(int)
Advance to the next (valid) item (postfix).
Definition: IndexIterator.h:280
ValueIndexIter & operator++()
Advance to the next (valid) item (prefix).
Definition: IndexIterator.h:181
IndexIter & operator=(const IndexIter &other)
Definition: IndexIterator.h:237
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition: version.h.in:121
void reset(Index32 begin, Index32 end)
Reset the begining and end of the iterator.
Definition: IndexIterator.h:253
Definition: IndexIterator.h:42
bool increment()
Definition: IndexIterator.h:192
ValueIndexIter(const ValueIndexIter &other)
Definition: IndexIterator.h:158
Index32 getValue(unsigned) const
Definition: IndexIterator.h:72
IndexIter(const IteratorT &iterator, const FilterT &filter)
Definition: IndexIterator.h:216
Index32 end() const
Definition: IndexIterator.h:165
Coord getCoord() const
Return the coordinates of the item to which the value iterator is pointing.
Definition: IndexIterator.h:294
void reset(const LeafT &)
Definition: IndexIterator.h:59
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h.in:218
A no-op filter that can be used when iterating over all indices.
Definition: IndexIterator.h:51
bool test() const
Definition: IndexIterator.h:266
ValueVoxelCIter & operator++()
Advance to the next (valid) item (prefix).
Definition: IndexIterator.h:90
Index32 operator*() const
Definition: IndexIterator.h:87
bool increment()
Definition: IndexIterator.h:288
Definition: Exceptions.h:63