Consolidated iterator code. Functionally equivalent but way cleaner than before.
git-svn-id: http://www.openmesh.org/svnrepo/OpenMesh/trunk@548 fdac6126-5c0c-442c-9429-916003d36597
This commit is contained in:
@@ -77,23 +77,12 @@ template <class Mesh> class ConstFaceIterT;
|
|||||||
template <class Mesh> class FaceIterT;
|
template <class Mesh> class FaceIterT;
|
||||||
|
|
||||||
|
|
||||||
|
template <class Mesh, class ValueHandle>
|
||||||
|
class GenericIteratorT {
|
||||||
//== CLASS DEFINITION =========================================================
|
public:
|
||||||
|
|
||||||
/** \class VertexIterT IteratorsT.hh <OpenMesh/Mesh/Iterators/IteratorsT.hh>
|
|
||||||
Linear iterator.
|
|
||||||
*/
|
|
||||||
|
|
||||||
template <class Mesh>
|
|
||||||
class ConstVertexIterT
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
|
|
||||||
|
|
||||||
//--- Typedefs ---
|
//--- Typedefs ---
|
||||||
|
|
||||||
typedef typename Mesh::VertexHandle value_handle;
|
typedef ValueHandle value_handle;
|
||||||
typedef value_handle value_type;
|
typedef value_handle value_type;
|
||||||
typedef std::bidirectional_iterator_tag iterator_category;
|
typedef std::bidirectional_iterator_tag iterator_category;
|
||||||
typedef std::ptrdiff_t difference_type;
|
typedef std::ptrdiff_t difference_type;
|
||||||
@@ -103,13 +92,12 @@ public:
|
|||||||
typedef const Mesh& mesh_ref;
|
typedef const Mesh& mesh_ref;
|
||||||
|
|
||||||
/// Default constructor.
|
/// Default constructor.
|
||||||
ConstVertexIterT()
|
GenericIteratorT()
|
||||||
: mesh_(0), skip_bits_(0)
|
: mesh_(0), skip_bits_(0)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
/// Construct with mesh and a target handle.
|
/// Construct with mesh and a target handle.
|
||||||
ConstVertexIterT(mesh_ref _mesh, value_handle _hnd, bool _skip=false)
|
GenericIteratorT(mesh_ref _mesh, value_handle _hnd, bool _skip=false)
|
||||||
: mesh_(&_mesh), hnd_(_hnd), skip_bits_(0)
|
: mesh_(&_mesh), hnd_(_hnd), skip_bits_(0)
|
||||||
{
|
{
|
||||||
if (_skip) enable_skipping();
|
if (_skip) enable_skipping();
|
||||||
@@ -119,483 +107,89 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Standard dereferencing operator.
|
/// Standard dereferencing operator.
|
||||||
reference operator*() const { return hnd_; }
|
reference operator*() const {
|
||||||
|
return hnd_;
|
||||||
|
}
|
||||||
|
|
||||||
/// Standard pointer operator.
|
/// Standard pointer operator.
|
||||||
pointer operator->() const { return &hnd_; }
|
pointer operator->() const {
|
||||||
|
return &hnd_;
|
||||||
|
}
|
||||||
|
|
||||||
/// Get the handle of the item the iterator refers to.
|
/// Get the handle of the item the iterator refers to.
|
||||||
value_handle handle() const { return hnd_; }
|
value_handle handle() const {
|
||||||
|
return hnd_;
|
||||||
|
}
|
||||||
|
|
||||||
/// Cast to the handle of the item the iterator refers to.
|
/// Cast to the handle of the item the iterator refers to.
|
||||||
operator value_handle() const { return hnd_; }
|
operator value_handle() const {
|
||||||
|
return hnd_;
|
||||||
|
}
|
||||||
|
|
||||||
/// Are two iterators equal? Only valid if they refer to the same mesh!
|
/// Are two iterators equal? Only valid if they refer to the same mesh!
|
||||||
bool operator==(const ConstVertexIterT& _rhs) const
|
bool operator==(const GenericIteratorT& _rhs) const {
|
||||||
{ return ((mesh_ == _rhs.mesh_) && (hnd_ == _rhs.hnd_)); }
|
return ((mesh_ == _rhs.mesh_) && (hnd_ == _rhs.hnd_));
|
||||||
|
}
|
||||||
|
|
||||||
/// Not equal?
|
/// Not equal?
|
||||||
bool operator!=(const ConstVertexIterT& _rhs) const
|
bool operator!=(const GenericIteratorT& _rhs) const {
|
||||||
{ return !operator==(_rhs); }
|
return !operator==(_rhs);
|
||||||
|
}
|
||||||
|
|
||||||
/// Standard pre-increment operator
|
/// Standard pre-increment operator
|
||||||
ConstVertexIterT& operator++()
|
GenericIteratorT& operator++() {
|
||||||
{ hnd_.__increment(); if (skip_bits_) skip_fwd(); return *this; }
|
hnd_.__increment();
|
||||||
|
if (skip_bits_)
|
||||||
|
skip_fwd();
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
/// Standard pre-decrement operator
|
/// Standard pre-decrement operator
|
||||||
ConstVertexIterT& operator--()
|
GenericIteratorT& operator--() {
|
||||||
{ hnd_.__decrement(); if (skip_bits_) skip_bwd(); return *this; }
|
hnd_.__decrement();
|
||||||
|
if (skip_bits_)
|
||||||
|
skip_bwd();
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
/// Turn on skipping: automatically skip deleted/hidden elements
|
/// Turn on skipping: automatically skip deleted/hidden elements
|
||||||
void enable_skipping()
|
void enable_skipping() {
|
||||||
{
|
if (mesh_ && mesh_->has_vertex_status()) {
|
||||||
if (mesh_ && mesh_->has_vertex_status())
|
|
||||||
{
|
|
||||||
Attributes::StatusInfo status;
|
Attributes::StatusInfo status;
|
||||||
status.set_deleted(true);
|
status.set_deleted(true);
|
||||||
status.set_hidden(true);
|
status.set_hidden(true);
|
||||||
skip_bits_ = status.bits();
|
skip_bits_ = status.bits();
|
||||||
skip_fwd();
|
skip_fwd();
|
||||||
|
} else
|
||||||
|
skip_bits_ = 0;
|
||||||
}
|
}
|
||||||
else skip_bits_ = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/// Turn on skipping: automatically skip deleted/hidden elements
|
/// Turn on skipping: automatically skip deleted/hidden elements
|
||||||
void disable_skipping() { skip_bits_ = 0; }
|
void disable_skipping() {
|
||||||
|
skip_bits_ = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
void skip_fwd() {
|
||||||
private:
|
|
||||||
|
|
||||||
void skip_fwd()
|
|
||||||
{
|
|
||||||
assert(mesh_ && skip_bits_);
|
assert(mesh_ && skip_bits_);
|
||||||
while ((hnd_.idx() < (signed) mesh_->n_vertices()) &&
|
while ((hnd_.idx() < (signed) mesh_->n_vertices())
|
||||||
(mesh_->status(hnd_).bits() & skip_bits_))
|
&& (mesh_->status(hnd_).bits() & skip_bits_))
|
||||||
hnd_.__increment();
|
hnd_.__increment();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void skip_bwd() {
|
||||||
void skip_bwd()
|
|
||||||
{
|
|
||||||
assert(mesh_ && skip_bits_);
|
assert(mesh_ && skip_bits_);
|
||||||
while ((hnd_.idx() >= 0) &&
|
while ((hnd_.idx() >= 0) && (mesh_->status(hnd_).bits() & skip_bits_))
|
||||||
(mesh_->status(hnd_).bits() & skip_bits_))
|
|
||||||
hnd_.__decrement();
|
hnd_.__decrement();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
protected:
|
|
||||||
mesh_ptr mesh_;
|
mesh_ptr mesh_;
|
||||||
value_handle hnd_;
|
value_handle hnd_;
|
||||||
unsigned int skip_bits_;
|
unsigned int skip_bits_;
|
||||||
};
|
};
|
||||||
|
|
||||||
// We would prefer a templated typedef here but that's C++11.
|
|
||||||
template<class Mesh>
|
|
||||||
class VertexIterT: public ConstVertexIterT<Mesh> {
|
|
||||||
public:
|
|
||||||
VertexIterT() {}
|
|
||||||
VertexIterT(typename ConstVertexIterT<Mesh>::mesh_ref _mesh,
|
|
||||||
typename ConstVertexIterT<Mesh>::value_handle _hnd, bool _skip = false) :
|
|
||||||
ConstVertexIterT<Mesh>(_mesh, _hnd, _skip) {}
|
|
||||||
};
|
|
||||||
|
|
||||||
//== CLASS DEFINITION =========================================================
|
|
||||||
|
|
||||||
|
|
||||||
/** \class HalfedgeIterT IteratorsT.hh <OpenMesh/Mesh/Iterators/IteratorsT.hh>
|
|
||||||
Linear iterator.
|
|
||||||
*/
|
|
||||||
|
|
||||||
template <class Mesh>
|
|
||||||
class ConstHalfedgeIterT
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
|
|
||||||
|
|
||||||
//--- Typedefs ---
|
|
||||||
|
|
||||||
typedef typename Mesh::HalfedgeHandle value_handle;
|
|
||||||
typedef value_handle value_type;
|
|
||||||
|
|
||||||
typedef std::bidirectional_iterator_tag iterator_category;
|
|
||||||
typedef std::ptrdiff_t difference_type;
|
|
||||||
typedef const value_type& reference;
|
|
||||||
typedef const value_type* pointer;
|
|
||||||
typedef const Mesh* mesh_ptr;
|
|
||||||
typedef const Mesh& mesh_ref;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// Default constructor.
|
|
||||||
ConstHalfedgeIterT()
|
|
||||||
: mesh_(0), skip_bits_(0)
|
|
||||||
{}
|
|
||||||
|
|
||||||
|
|
||||||
/// Construct with mesh and a target handle.
|
|
||||||
ConstHalfedgeIterT(mesh_ref _mesh, value_handle _hnd, bool _skip=false)
|
|
||||||
: mesh_(&_mesh), hnd_(_hnd), skip_bits_(0)
|
|
||||||
{
|
|
||||||
if (_skip) enable_skipping();
|
|
||||||
|
|
||||||
// Set halfedge handle invalid if the mesh contains no edge
|
|
||||||
if(_mesh.n_edges() == 0) hnd_ = value_handle(-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Standard dereferencing operator.
|
|
||||||
reference operator*() const { return hnd_; }
|
|
||||||
|
|
||||||
/// Standard pointer operator.
|
|
||||||
pointer operator->() const { return &hnd_; }
|
|
||||||
|
|
||||||
/// Get the handle of the item the iterator refers to.
|
|
||||||
value_handle handle() const { return hnd_; }
|
|
||||||
|
|
||||||
/// Cast to the handle of the item the iterator refers to.
|
|
||||||
operator value_handle() const { return hnd_; }
|
|
||||||
|
|
||||||
/// Are two iterators equal? Only valid if they refer to the same mesh!
|
|
||||||
bool operator==(const ConstHalfedgeIterT& _rhs) const
|
|
||||||
{ return ((mesh_ == _rhs.mesh_) && (hnd_ == _rhs.hnd_)); }
|
|
||||||
|
|
||||||
/// Not equal?
|
|
||||||
bool operator!=(const ConstHalfedgeIterT& _rhs) const
|
|
||||||
{ return !operator==(_rhs); }
|
|
||||||
|
|
||||||
/// Standard pre-increment operator
|
|
||||||
ConstHalfedgeIterT& operator++()
|
|
||||||
{ hnd_.__increment(); if (skip_bits_) skip_fwd(); return *this; }
|
|
||||||
|
|
||||||
/// Standard pre-decrement operator
|
|
||||||
ConstHalfedgeIterT& operator--()
|
|
||||||
{ hnd_.__decrement(); if (skip_bits_) skip_bwd(); return *this; }
|
|
||||||
|
|
||||||
|
|
||||||
/// Turn on skipping: automatically skip deleted/hidden elements
|
|
||||||
void enable_skipping()
|
|
||||||
{
|
|
||||||
if (mesh_ && mesh_->has_halfedge_status())
|
|
||||||
{
|
|
||||||
Attributes::StatusInfo status;
|
|
||||||
status.set_deleted(true);
|
|
||||||
status.set_hidden(true);
|
|
||||||
skip_bits_ = status.bits();
|
|
||||||
skip_fwd();
|
|
||||||
}
|
|
||||||
else skip_bits_ = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/// Turn on skipping: automatically skip deleted/hidden elements
|
|
||||||
void disable_skipping() { skip_bits_ = 0; }
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
void skip_fwd()
|
|
||||||
{
|
|
||||||
assert(mesh_ && skip_bits_);
|
|
||||||
while ((hnd_.idx() < (signed) mesh_->n_halfedges()) &&
|
|
||||||
(mesh_->status(hnd_).bits() & skip_bits_))
|
|
||||||
hnd_.__increment();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void skip_bwd()
|
|
||||||
{
|
|
||||||
assert(mesh_ && skip_bits_);
|
|
||||||
while ((hnd_.idx() >= 0) &&
|
|
||||||
(mesh_->status(hnd_).bits() & skip_bits_))
|
|
||||||
hnd_.__decrement();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
|
||||||
mesh_ptr mesh_;
|
|
||||||
value_handle hnd_;
|
|
||||||
unsigned int skip_bits_;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
// We would prefer a templated typedef here but that's C++11.
|
|
||||||
template<class Mesh>
|
|
||||||
class HalfedgeIterT: public ConstHalfedgeIterT<Mesh> {
|
|
||||||
public:
|
|
||||||
HalfedgeIterT() {}
|
|
||||||
|
|
||||||
HalfedgeIterT(typename ConstHalfedgeIterT<Mesh>::mesh_ref _mesh,
|
|
||||||
typename ConstHalfedgeIterT<Mesh>::value_handle _hnd, bool _skip = false) :
|
|
||||||
ConstHalfedgeIterT<Mesh>(_mesh, _hnd, _skip) {}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
//== CLASS DEFINITION =========================================================
|
|
||||||
|
|
||||||
|
|
||||||
/** \class EdgeIterT IteratorsT.hh <OpenMesh/Mesh/Iterators/IteratorsT.hh>
|
|
||||||
Linear iterator.
|
|
||||||
*/
|
|
||||||
|
|
||||||
template <class Mesh>
|
|
||||||
class ConstEdgeIterT
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
|
|
||||||
|
|
||||||
//--- Typedefs ---
|
|
||||||
|
|
||||||
typedef typename Mesh::EdgeHandle value_handle;
|
|
||||||
typedef value_handle value_type;
|
|
||||||
|
|
||||||
typedef std::bidirectional_iterator_tag iterator_category;
|
|
||||||
typedef std::ptrdiff_t difference_type;
|
|
||||||
typedef const value_type& reference;
|
|
||||||
typedef const value_type* pointer;
|
|
||||||
typedef const Mesh* mesh_ptr;
|
|
||||||
typedef const Mesh& mesh_ref;
|
|
||||||
|
|
||||||
/// Default constructor.
|
|
||||||
ConstEdgeIterT()
|
|
||||||
: mesh_(0), skip_bits_(0)
|
|
||||||
{}
|
|
||||||
|
|
||||||
|
|
||||||
/// Construct with mesh and a target handle.
|
|
||||||
ConstEdgeIterT(mesh_ref _mesh, value_handle _hnd, bool _skip=false)
|
|
||||||
: mesh_(&_mesh), hnd_(_hnd), skip_bits_(0)
|
|
||||||
{
|
|
||||||
if (_skip) enable_skipping();
|
|
||||||
|
|
||||||
// Set halfedge handle invalid if the mesh contains no edge
|
|
||||||
if(_mesh.n_edges() == 0) hnd_ = value_handle(-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/// Standard dereferencing operator.
|
|
||||||
reference operator*() const { return hnd_; }
|
|
||||||
|
|
||||||
/// Standard pointer operator.
|
|
||||||
pointer operator->() const { return &hnd_; }
|
|
||||||
|
|
||||||
/// Get the handle of the item the iterator refers to.
|
|
||||||
value_handle handle() const { return hnd_; }
|
|
||||||
|
|
||||||
/// Cast to the handle of the item the iterator refers to.
|
|
||||||
operator value_handle() const { return hnd_; }
|
|
||||||
|
|
||||||
/// Are two iterators equal? Only valid if they refer to the same mesh!
|
|
||||||
bool operator==(const ConstEdgeIterT& _rhs) const
|
|
||||||
{ return ((mesh_ == _rhs.mesh_) && (hnd_ == _rhs.hnd_)); }
|
|
||||||
|
|
||||||
/// Not equal?
|
|
||||||
bool operator!=(const ConstEdgeIterT& _rhs) const
|
|
||||||
{ return !operator==(_rhs); }
|
|
||||||
|
|
||||||
/// Standard pre-increment operator
|
|
||||||
ConstEdgeIterT& operator++()
|
|
||||||
{ hnd_.__increment(); if (skip_bits_) skip_fwd(); return *this; }
|
|
||||||
|
|
||||||
/// Standard pre-decrement operator
|
|
||||||
ConstEdgeIterT& operator--()
|
|
||||||
{ hnd_.__decrement(); if (skip_bits_) skip_bwd(); return *this; }
|
|
||||||
|
|
||||||
|
|
||||||
/// Turn on skipping: automatically skip deleted/hidden elements
|
|
||||||
void enable_skipping()
|
|
||||||
{
|
|
||||||
if (mesh_ && mesh_->has_edge_status())
|
|
||||||
{
|
|
||||||
Attributes::StatusInfo status;
|
|
||||||
status.set_deleted(true);
|
|
||||||
status.set_hidden(true);
|
|
||||||
skip_bits_ = status.bits();
|
|
||||||
skip_fwd();
|
|
||||||
}
|
|
||||||
else skip_bits_ = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/// Turn on skipping: automatically skip deleted/hidden elements
|
|
||||||
void disable_skipping() { skip_bits_ = 0; }
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
void skip_fwd()
|
|
||||||
{
|
|
||||||
assert(mesh_ && skip_bits_);
|
|
||||||
while ((hnd_.idx() < (signed) mesh_->n_edges()) &&
|
|
||||||
(mesh_->status(hnd_).bits() & skip_bits_))
|
|
||||||
hnd_.__increment();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void skip_bwd()
|
|
||||||
{
|
|
||||||
assert(mesh_ && skip_bits_);
|
|
||||||
while ((hnd_.idx() >= 0) &&
|
|
||||||
(mesh_->status(hnd_).bits() & skip_bits_))
|
|
||||||
hnd_.__decrement();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
|
||||||
mesh_ptr mesh_;
|
|
||||||
value_handle hnd_;
|
|
||||||
unsigned int skip_bits_;
|
|
||||||
};
|
|
||||||
|
|
||||||
// We would prefer a templated typedef here but that's C++11.
|
|
||||||
template<class Mesh>
|
|
||||||
class EdgeIterT: public ConstEdgeIterT<Mesh> {
|
|
||||||
public:
|
|
||||||
EdgeIterT() {}
|
|
||||||
|
|
||||||
EdgeIterT(typename ConstEdgeIterT<Mesh>::mesh_ref _mesh,
|
|
||||||
typename ConstEdgeIterT<Mesh>::value_handle _hnd, bool _skip = false) :
|
|
||||||
ConstEdgeIterT<Mesh>(_mesh, _hnd, _skip) {}
|
|
||||||
};
|
|
||||||
|
|
||||||
//== CLASS DEFINITION =========================================================
|
|
||||||
|
|
||||||
|
|
||||||
/** \class FaceIterT IteratorsT.hh <OpenMesh/Mesh/Iterators/IteratorsT.hh>
|
|
||||||
Linear iterator.
|
|
||||||
*/
|
|
||||||
|
|
||||||
template <class Mesh>
|
|
||||||
class ConstFaceIterT
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
|
|
||||||
|
|
||||||
//--- Typedefs ---
|
|
||||||
|
|
||||||
typedef typename Mesh::FaceHandle value_handle;
|
|
||||||
typedef value_handle value_type;
|
|
||||||
|
|
||||||
typedef std::bidirectional_iterator_tag iterator_category;
|
|
||||||
typedef std::ptrdiff_t difference_type;
|
|
||||||
typedef const value_type& reference;
|
|
||||||
typedef const value_type* pointer;
|
|
||||||
typedef const Mesh* mesh_ptr;
|
|
||||||
typedef const Mesh& mesh_ref;
|
|
||||||
|
|
||||||
|
|
||||||
/// Default constructor.
|
|
||||||
ConstFaceIterT()
|
|
||||||
: mesh_(0), skip_bits_(0)
|
|
||||||
{}
|
|
||||||
|
|
||||||
|
|
||||||
/// Construct with mesh and a target handle.
|
|
||||||
ConstFaceIterT(mesh_ref _mesh, value_handle _hnd, bool _skip=false)
|
|
||||||
: mesh_(&_mesh), hnd_(_hnd), skip_bits_(0)
|
|
||||||
{
|
|
||||||
if (_skip) enable_skipping();
|
|
||||||
|
|
||||||
// Set face handle invalid if the mesh contains no faces
|
|
||||||
if(_mesh.n_faces() == 0) hnd_ = value_handle(-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/// Standard dereferencing operator.
|
|
||||||
reference operator*() const { return hnd_; }
|
|
||||||
|
|
||||||
/// Standard pointer operator.
|
|
||||||
pointer operator->() const { return &hnd_; }
|
|
||||||
|
|
||||||
/// Get the handle of the item the iterator refers to.
|
|
||||||
value_handle handle() const { return hnd_; }
|
|
||||||
|
|
||||||
/// Cast to the handle of the item the iterator refers to.
|
|
||||||
operator value_handle() const { return hnd_; }
|
|
||||||
|
|
||||||
/// Are two iterators equal? Only valid if they refer to the same mesh!
|
|
||||||
bool operator==(const ConstFaceIterT& _rhs) const
|
|
||||||
{ return ((mesh_ == _rhs.mesh_) && (hnd_ == _rhs.hnd_)); }
|
|
||||||
|
|
||||||
/// Not equal?
|
|
||||||
bool operator!=(const ConstFaceIterT& _rhs) const
|
|
||||||
{ return !operator==(_rhs); }
|
|
||||||
|
|
||||||
/// Standard pre-increment operator
|
|
||||||
ConstFaceIterT& operator++()
|
|
||||||
{ hnd_.__increment(); if (skip_bits_) skip_fwd(); return *this; }
|
|
||||||
|
|
||||||
/// Standard pre-decrement operator
|
|
||||||
ConstFaceIterT& operator--()
|
|
||||||
{ hnd_.__decrement(); if (skip_bits_) skip_bwd(); return *this; }
|
|
||||||
|
|
||||||
|
|
||||||
/// Turn on skipping: automatically skip deleted/hidden elements
|
|
||||||
void enable_skipping()
|
|
||||||
{
|
|
||||||
if (mesh_ && mesh_->has_face_status())
|
|
||||||
{
|
|
||||||
Attributes::StatusInfo status;
|
|
||||||
status.set_deleted(true);
|
|
||||||
status.set_hidden(true);
|
|
||||||
skip_bits_ = status.bits();
|
|
||||||
skip_fwd();
|
|
||||||
}
|
|
||||||
else skip_bits_ = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/// Turn on skipping: automatically skip deleted/hidden elements
|
|
||||||
void disable_skipping() { skip_bits_ = 0; }
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
void skip_fwd()
|
|
||||||
{
|
|
||||||
assert(mesh_ && skip_bits_);
|
|
||||||
while ((hnd_.idx() < (signed) mesh_->n_faces()) &&
|
|
||||||
(mesh_->status(hnd_).bits() & skip_bits_))
|
|
||||||
hnd_.__increment();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void skip_bwd()
|
|
||||||
{
|
|
||||||
assert(mesh_ && skip_bits_);
|
|
||||||
while ((hnd_.idx() >= 0) &&
|
|
||||||
(mesh_->status(hnd_).bits() & skip_bits_))
|
|
||||||
hnd_.__decrement();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
|
||||||
mesh_ptr mesh_;
|
|
||||||
value_handle hnd_;
|
|
||||||
unsigned int skip_bits_;
|
|
||||||
};
|
|
||||||
|
|
||||||
// We would prefer a templated typedef here but that's C++11.
|
|
||||||
template<class Mesh>
|
|
||||||
class FaceIterT: public ConstFaceIterT<Mesh> {
|
|
||||||
public:
|
|
||||||
FaceIterT() {}
|
|
||||||
|
|
||||||
FaceIterT(typename ConstFaceIterT<Mesh>::mesh_ref _mesh,
|
|
||||||
typename ConstFaceIterT<Mesh>::value_handle _hnd, bool _skip = false) :
|
|
||||||
ConstFaceIterT<Mesh>(_mesh, _hnd, _skip) {}
|
|
||||||
};
|
|
||||||
|
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
} // namespace Iterators
|
} // namespace Iterators
|
||||||
} // namespace OpenMesh
|
} // namespace OpenMesh
|
||||||
|
|||||||
@@ -76,15 +76,15 @@ public:
|
|||||||
*/
|
*/
|
||||||
//@{
|
//@{
|
||||||
/// Linear iterator
|
/// Linear iterator
|
||||||
typedef Iterators::VertexIterT<This> VertexIter;
|
typedef Iterators::GenericIteratorT<This, This::VertexHandle> VertexIter;
|
||||||
typedef Iterators::HalfedgeIterT<This> HalfedgeIter;
|
typedef Iterators::GenericIteratorT<This, This::HalfedgeHandle> HalfedgeIter;
|
||||||
typedef Iterators::EdgeIterT<This> EdgeIter;
|
typedef Iterators::GenericIteratorT<This, This::EdgeHandle> EdgeIter;
|
||||||
typedef Iterators::FaceIterT<This> FaceIter;
|
typedef Iterators::GenericIteratorT<This, This::FaceHandle> FaceIter;
|
||||||
|
|
||||||
typedef Iterators::ConstVertexIterT<This> ConstVertexIter;
|
typedef VertexIter ConstVertexIter;
|
||||||
typedef Iterators::ConstHalfedgeIterT<This> ConstHalfedgeIter;
|
typedef HalfedgeIter ConstHalfedgeIter;
|
||||||
typedef Iterators::ConstEdgeIterT<This> ConstEdgeIter;
|
typedef EdgeIter ConstEdgeIter;
|
||||||
typedef Iterators::ConstFaceIterT<This> ConstFaceIter;
|
typedef FaceIter ConstFaceIter;
|
||||||
//@}
|
//@}
|
||||||
|
|
||||||
//--- circulators ---
|
//--- circulators ---
|
||||||
|
|||||||
Reference in New Issue
Block a user