37 #ifndef OPENVDB_POINTS_INDEX_ITERATOR_HAS_BEEN_INCLUDED 38 #define OPENVDB_POINTS_INDEX_ITERATOR_HAS_BEEN_INCLUDED 54 template <
typename IterT>
66 template <
typename LeafT>
void reset(
const LeafT&) { }
67 template <
typename IterT>
static bool valid(
const IterT&) {
return true; }
88 : mOffset(offset), mParent(prevOffset) {}
90 : mOffset(other.mOffset), mParent(other.mParent), mValid(other.mValid) {}
99 operator bool()
const {
return mValid; }
100 bool test()
const {
return mValid; }
107 inline bool next() { this->operator++();
return this->test(); }
111 Coord getCoord [[noreturn]] ()
const {
114 void getCoord [[noreturn]] (
Coord& )
const {
127 mutable bool mValid =
true;
143 template <
typename IteratorT,
typename FilterT>
152 : mIter(iter), mParent(&mIter.parent())
156 Index32 start = (mIter.offset() > 0 ?
158 this->reset(start, *mIter);
159 if (mItem >= mEnd) this->operator++();
163 : mEnd(other.mEnd), mItem(other.mItem), mIter(other.mIter), mParent(other.mParent)
181 inline operator bool()
const {
return mIter; }
182 inline bool test()
const {
return mIter; }
187 while (mItem >= mEnd && mIter.next()) {
189 this->reset(mParent->getValue(mIter.offset() - 1), *mIter);
195 inline bool next() { this->operator++();
return this->test(); }
196 inline bool increment() { this->next();
return this->test(); }
201 inline void getCoord(
Coord& xyz)
const { assert(mIter); xyz = mIter.getCoord(); }
204 inline const IteratorT&
valueIter()
const {
return mIter; }
214 const typename IteratorT::NodeType* mParent;
217 IndexIter(
const IteratorT& iterator,
const FilterT& filter)
218 : mIterator(iterator)
221 if (!mFilter.initialized()) {
223 "Filter needs to be initialized before constructing the iterator.");
226 this->reset(*mIterator, mIterator.end());
230 : mIterator(other.mIterator)
231 , mFilter(other.mFilter)
233 if (!mFilter.initialized()) {
235 "Filter needs to be initialized before constructing the iterator.");
240 if (&other !=
this) {
241 mIterator = other.mIterator;
242 mFilter = other.mFilter;
243 if (!mFilter.initialized()) {
245 "Filter needs to be initialized before constructing the iterator.");
255 mIterator.reset(begin, end);
256 while (mIterator.test() && !mFilter.template valid<ValueIndexIter>(mIterator)) {
266 operator bool()
const {
return mIterator.test(); }
267 bool test()
const {
return mIterator.test(); }
273 if (!mIterator.test() || mFilter.template valid<ValueIndexIter>(mIterator)) {
288 bool next() { this->operator++();
return this->test(); }
292 inline const FilterT&
filter()
const {
return mFilter; }
295 inline Coord getCoord()
const { assert(mIterator);
return mIterator.getCoord(); }
297 inline void getCoord(
Coord& xyz)
const { assert(mIterator); xyz = mIterator.getCoord(); }
312 template <
typename IterT>
316 for (IterT newIter(iter); newIter; ++newIter, ++
size) { }
328 #endif // OPENVDB_POINTS_INDEX_ITERATOR_HAS_BEEN_INCLUDED Parent & parent()
Definition: IndexIterator.h:105
Definition: IndexIterator.h:75
void getCoord(Coord &xyz) const
Return in xyz the coordinates of the item to which the value iterator is pointing.
Definition: IndexIterator.h:201
A forward iterator over array indices with filtering IteratorT can be either IndexIter or ValueIndexI...
Definition: IndexIterator.h:144
bool operator!=(const IndexIter &other) const
Definition: IndexIterator.h:301
ValueIndexIter(const ValueIndexIter &other)
Definition: IndexIterator.h:162
IndexIter & operator++()
Advance to the next (valid) item (prefix).
Definition: IndexIterator.h:270
const IteratorT & valueIter() const
Return the const value iterator.
Definition: IndexIterator.h:204
void reset(Index32 begin, Index32 end)
Reset the begining and end of the iterator.
Definition: IndexIterator.h:254
const FilterT & filter() const
Return the const filter.
Definition: IndexIterator.h:292
#define OPENVDB_THROW(exception, message)
Definition: Exceptions.h:101
uint32_t Index32
Definition: Types.h:55
Index32 getValue(unsigned) const
Definition: IndexIterator.h:79
A forward iterator over array indices in a single voxel.
Definition: IndexIterator.h:72
void reset(Index32 item, Index32 end)
Definition: IndexIterator.h:171
Index32 operator*() const
Definition: IndexIterator.h:178
Index32 operator*()
Return the item to which this iterator is currently pointing.
Definition: IndexIterator.h:93
ValueVoxelCIter(const ValueVoxelCIter &other)
Definition: IndexIterator.h:89
bool next()
Definition: IndexIterator.h:107
A no-op filter that can be used when iterating over all indices.
Definition: IndexIterator.h:62
ValueVoxelCIter(Index32 prevOffset, Index32 offset)
Definition: IndexIterator.h:87
bool test() const
Definition: IndexIterator.h:267
ValueIndexIter & operator++()
Advance to the next (valid) item (prefix).
Definition: IndexIterator.h:185
static bool initialized()
Definition: IndexIterator.h:65
ValueIndexIter(const IteratorT &iter)
Definition: IndexIterator.h:151
Index64 iterCount(const IterT &iter)
Count up the number of times the iterator can iterate.
Definition: IndexIterator.h:313
void reset(Index32, Index32)
Definition: IndexIterator.h:103
uint64_t Index64
Definition: Types.h:56
void reset(const LeafT &)
Definition: IndexIterator.h:66
bool increment()
Definition: IndexIterator.h:289
#define OPENVDB_VERSION_NAME
Definition: version.h:43
bool increment()
Definition: IndexIterator.h:196
A forward iterator over array indices from a value iterator (such as ValueOnCIter) ...
Definition: IndexIterator.h:148
Index32 operator*() const
Definition: IndexIterator.h:263
Index32 operator*()
Returns the item to which this iterator is currently pointing.
Definition: IndexIterator.h:262
ValueVoxelCIter & operator++()
Advance to the next (valid) item (prefix).
Definition: IndexIterator.h:97
bool operator==(const ValueIndexIter &other) const
Equality operators.
Definition: IndexIterator.h:207
Index32 end() const
Definition: IndexIterator.h:251
Definition: Exceptions.h:39
bool operator==(const Vec3< T0 > &v0, const Vec3< T1 > &v1)
Equality operator, does exact floating point comparisons.
Definition: Vec3.h:487
Parent(Index32 offset)
Definition: IndexIterator.h:78
Index32 end() const
Definition: IndexIterator.h:101
bool test() const
Definition: IndexIterator.h:182
Coord getCoord() const
Return the coordinates of the item to which the value iterator is pointing.
Definition: IndexIterator.h:199
bool operator==(const ValueVoxelCIter &other) const
Equality operators.
Definition: IndexIterator.h:120
Index32 offset()
Definition: IndexIterator.h:106
IndexIter(const IndexIter &other)
Definition: IndexIterator.h:229
Coord getCoord() const
Return the coordinates of the item to which the value iterator is pointing.
Definition: IndexIterator.h:295
static bool valid(const IterT &)
Definition: IndexIterator.h:67
void getCoord(Coord &xyz) const
Return in xyz the coordinates of the item to which the value iterator is pointing.
Definition: IndexIterator.h:297
bool next()
Advance to the next (valid) item.
Definition: IndexIterator.h:195
bool next()
Advance to the next (valid) item.
Definition: IndexIterator.h:288
Index32 operator*() const
Definition: IndexIterator.h:94
Signed (x, y, z) 32-bit integer coordinates.
Definition: Coord.h:48
IndexIter & operator=(const IndexIter &other)
Definition: IndexIterator.h:238
Definition: Exceptions.h:90
bool operator!=(const ValueVoxelCIter &other) const
Equality operators.
Definition: IndexIterator.h:121
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h:71
Index32 operator*()
Returns the item to which this iterator is currently pointing.
Definition: IndexIterator.h:177
bool test() const
Definition: IndexIterator.h:100
IndexIter operator++(int)
Advance to the next (valid) item (postfix).
Definition: IndexIterator.h:281
IndexIter(const IteratorT &iterator, const FilterT &filter)
Definition: IndexIterator.h:217
static constexpr size_t size
The size of a LeafBuffer when LeafBuffer::mOutOfCore is atomic.
Definition: LeafBuffer.h:85
Index32 end() const
Definition: IndexIterator.h:169
bool operator!=(const ValueIndexIter &other) const
Definition: IndexIterator.h:208
bool operator==(const IndexIter &other) const
Equality operators.
Definition: IndexIterator.h:300