10#ifndef OPENVDB_POINTS_INDEX_ITERATOR_HAS_BEEN_INCLUDED
11#define OPENVDB_POINTS_INDEX_ITERATOR_HAS_BEEN_INCLUDED
13#include <openvdb/version.h>
28template <
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; }
123 mutable bool mValid =
true;
139template <
typename IteratorT,
typename FilterT>
148 : mIter(iter), mParent(&mIter.parent())
152 Index32 start = (mIter.offset() > 0 ?
154 this->
reset(start, *mIter);
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);
203 inline const IteratorT&
valueIter()
const {
return mIter; }
213 const typename IteratorT::NodeType* mParent;
217 : mIterator(iterator)
220 if (!mFilter.initialized()) {
221 OPENVDB_THROW(RuntimeError,
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()) {
233 OPENVDB_THROW(RuntimeError,
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)) {
291 inline const FilterT&
filter()
const {
return mFilter; }
306 ValueIndexIter mIterator;
314template <
typename IterT>
318 for (IterT newIter(iter); newIter; ++newIter, ++size) { }
#define OPENVDB_ASSERT(X)
Definition Assert.h:41
Definition Exceptions.h:63
Signed (x, y, z) 32-bit integer coordinates.
Definition Coord.h:26
bool increment()
Definition IndexIterator.h:192
ValueIndexIter(const IteratorT &iter)
Definition IndexIterator.h:147
bool isValueOn() const
Return true if this iterator is pointing to an active value.
Definition IndexIterator.h:200
bool operator==(const ValueIndexIter &other) const
Equality operators.
Definition IndexIterator.h:206
Coord getCoord() const
Return the coordinates of the item to which the value iterator is pointing.
Definition IndexIterator.h:195
bool test() const
Definition IndexIterator.h:178
bool operator!=(const ValueIndexIter &other) const
Definition IndexIterator.h:207
Index32 end() const
Definition IndexIterator.h:165
ValueIndexIter & operator++()
Advance to the next (valid) item (prefix).
Definition IndexIterator.h:181
Index32 operator*()
Returns the item to which this iterator is currently pointing.
Definition IndexIterator.h:173
bool next()
Advance to the next (valid) item.
Definition IndexIterator.h:191
void getCoord(Coord &xyz) const
Return in xyz the coordinates of the item to which the value iterator is pointing.
Definition IndexIterator.h:197
const IteratorT & valueIter() const
Return the const value iterator.
Definition IndexIterator.h:203
ValueIndexIter(const ValueIndexIter &other)
Definition IndexIterator.h:158
void reset(Index32 item, Index32 end)
Definition IndexIterator.h:167
Index32 operator*() const
Definition IndexIterator.h:174
ValueIndexIter & operator=(const ValueIndexIter &)=default
IndexIter(const IndexIter &other)
Definition IndexIterator.h:228
bool increment()
Definition IndexIterator.h:288
bool isValueOn() const
Return true if the value iterator is pointing to an active value.
Definition IndexIterator.h:299
Coord getCoord() const
Return the coordinates of the item to which the value iterator is pointing.
Definition IndexIterator.h:294
bool operator==(const IndexIter &other) const
Equality operators.
Definition IndexIterator.h:302
bool test() const
Definition IndexIterator.h:266
bool operator!=(const IndexIter &other) const
Definition IndexIterator.h:303
IndexIter operator++(int)
Advance to the next (valid) item (postfix).
Definition IndexIterator.h:280
IndexIter & operator++()
Advance to the next (valid) item (prefix).
Definition IndexIterator.h:269
void reset(Index32 begin, Index32 end)
Definition IndexIterator.h:253
Index32 end() const
Definition IndexIterator.h:250
Index32 operator*()
Returns the item to which this iterator is currently pointing.
Definition IndexIterator.h:261
bool next()
Advance to the next (valid) item.
Definition IndexIterator.h:287
IndexIter(const IteratorT &iterator, const FilterT &filter)
Definition IndexIterator.h:216
IndexIter & operator=(const IndexIter &other)
Definition IndexIterator.h:237
void getCoord(Coord &xyz) const
Return in xyz the coordinates of the item to which the value iterator is pointing.
Definition IndexIterator.h:296
const NullFilter & filter() const
Definition IndexIterator.h:291
Index32 operator*() const
Definition IndexIterator.h:262
A no-op filter that can be used when iterating over all indices.
Definition IndexIterator.h:52
static index::State state()
Definition IndexIterator.h:55
static index::State state(const LeafT &)
Definition IndexIterator.h:57
static bool initialized()
Definition IndexIterator.h:54
static bool valid(const IterT &)
Definition IndexIterator.h:60
void reset(const LeafT &)
Definition IndexIterator.h:59
ValueVoxelCIter()=default
bool operator==(const ValueVoxelCIter &other) const
Equality operators.
Definition IndexIterator.h:116
bool isValueOn() const
Definition IndexIterator.h:110
ValueVoxelCIter(Index32 prevOffset, Index32 offset)
Definition IndexIterator.h:80
Coord getCoord() const
For efficiency, Coord and active state assumed to be readily available when iterating over indices of...
Definition IndexIterator.h:104
bool test() const
Definition IndexIterator.h:93
ValueVoxelCIter(const ValueVoxelCIter &other)
Definition IndexIterator.h:82
Index32 end() const
Definition IndexIterator.h:94
Index32 operator*()
Return the item to which this iterator is currently pointing.
Definition IndexIterator.h:86
Index32 offset()
Definition IndexIterator.h:99
ValueVoxelCIter & operator++()
Advance to the next (valid) item (prefix).
Definition IndexIterator.h:90
bool next()
Definition IndexIterator.h:100
bool operator!=(const ValueVoxelCIter &other) const
Equality operators.
Definition IndexIterator.h:117
Parent NodeType
Definition IndexIterator.h:77
Parent & parent()
Definition IndexIterator.h:98
void reset(Index32, Index32)
Definition IndexIterator.h:96
Index32 operator*() const
Definition IndexIterator.h:87
Definition IndexIterator.h:35
State
Definition IndexIterator.h:41
@ PARTIAL
Definition IndexIterator.h:42
@ ALL
Definition IndexIterator.h:44
@ NONE
Definition IndexIterator.h:43
Index64 iterCount(const IterT &iter)
Count up the number of times the iterator can iterate.
Definition IndexIterator.h:315
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:69
Index32 getValue(unsigned) const
Definition IndexIterator.h:72
Parent(Index32 offset)
Definition IndexIterator.h:71
#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:218