49 #ifndef OPENMESH_ITERATORS_HH
50 #define OPENMESH_ITERATORS_HH
63 #include <OpenMesh/Core/Mesh/Status.hh>
88 template <
class Mesh,
class ValueHandle,
class MemberOwner,
bool (MemberOwner::*PrimitiveStatusMember)() const,
size_t (MemberOwner::*PrimitiveCountMember)() const>
93 typedef ValueHandle value_handle;
94 typedef value_handle value_type;
95 typedef std::bidirectional_iterator_tag iterator_category;
96 typedef std::ptrdiff_t difference_type;
97 typedef const value_type& reference;
98 typedef const value_type* pointer;
104 : mesh_(0), skip_bits_(0)
109 : mesh_(&_mesh), hnd_(_hnd), skip_bits_(0)
114 if((mesh_->*PrimitiveCountMember)() == 0) hnd_ = value_handle(-1);
132 DEPRECATED(
"This function clutters your code. Use dereferencing operators -> and * instead.")
143 DEPRECATED(
"Implicit casts of iterators are unsafe. Use dereferencing operators -> and * instead.")
144 operator value_handle()
const {
150 return ((mesh_ == _rhs.mesh_) && (hnd_ == _rhs.hnd_));
173 #if (_MSC_VER >= 1900 || __cplusplus > 199711L || defined(__GXX_EXPERIMENTAL_CXX0X__)) && !defined(OPENMESH_VECTOR_LEGACY)
174 template<
class T = value_handle>
175 auto operator+=(
int amount) ->
176 typename std::enable_if<
177 sizeof(decltype(std::declval<T>().__increment(amount))) >= 0,
179 static_assert(std::is_same<T, value_handle>::value,
180 "Template parameter must not deviate from default.");
182 throw std::logic_error(
"Skipping iterators do not support "
184 hnd_.__increment(amount);
188 template<
class T = value_handle>
189 auto operator+(
int rhs) ->
190 typename std::enable_if<
191 sizeof(decltype(std::declval<T>().__increment(rhs),
void (),
int {})) >= 0,
193 static_assert(std::is_same<T, value_handle>::value,
194 "Template parameter must not deviate from default.");
196 throw std::logic_error(
"Skipping iterators do not support "
199 result.hnd_.__increment(rhs);
221 if (mesh_ && (mesh_->*PrimitiveStatusMember)()) {
225 skip_bits_ = status.
bits();
239 assert(mesh_ && skip_bits_);
240 while ((hnd_.idx() < (signed) (mesh_->*PrimitiveCountMember)())
241 && (mesh_->status(hnd_).bits() & skip_bits_))
246 assert(mesh_ && skip_bits_);
247 while ((hnd_.idx() >= 0) && (mesh_->status(hnd_).bits() & skip_bits_))
254 unsigned int skip_bits_;
void disable_skipping()
Turn on skipping: automatically skip deleted/hidden elements.
void set_hidden(bool _b)
set hidden
void set_deleted(bool _b)
set deleted
GenericIteratorT(mesh_ref _mesh, value_handle _hnd, bool _skip=false)
Construct with mesh and a target handle.
bool operator==(const GenericIteratorT &_rhs) const
Are two iterators equal? Only valid if they refer to the same mesh!
GenericIteratorT operator++(int)
Standard post-increment operator.
value_handle handle() const
Get the handle of the item the iterator refers to.
pointer operator->() const
Standard pointer operator.
GenericIteratorT & operator++()
Standard pre-increment operator.
reference operator*() const
Standard dereferencing operator.
unsigned int bits() const
return whole status
GenericIteratorT()
Default constructor.
void enable_skipping()
Turn on skipping: automatically skip deleted/hidden elements.
bool operator!=(const GenericIteratorT &_rhs) const
Not equal?
GenericIteratorT operator--(int)
Standard post-decrement operator.
GenericIteratorT & operator--()
Standard pre-decrement operator.