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