First checkin for OpenMesh 2.0
git-svn-id: http://www.openmesh.org/svnrepo/OpenMesh/trunk@2 fdac6126-5c0c-442c-9429-916003d36597
This commit is contained in:
73
Core/Mesh/gen/circulators_header.hh
Normal file
73
Core/Mesh/gen/circulators_header.hh
Normal file
@@ -0,0 +1,73 @@
|
||||
/*===========================================================================*\
|
||||
* *
|
||||
* OpenMesh *
|
||||
* Copyright (C) 2001-2003 by Computer Graphics Group, RWTH Aachen *
|
||||
* www.openmesh.org *
|
||||
* *
|
||||
*---------------------------------------------------------------------------*
|
||||
* *
|
||||
* License *
|
||||
* *
|
||||
* This library is free software; you can redistribute it and/or modify it *
|
||||
* under the terms of the GNU Lesser General Public License as published *
|
||||
* by the Free Software Foundation, version 2.1. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, but *
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
|
||||
* Lesser General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library; if not, write to the Free Software *
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
|
||||
* *
|
||||
\*===========================================================================*/
|
||||
#ifndef OPENMESH_CIRCULATORS_HH
|
||||
#define OPENMESH_CIRCULATORS_HH
|
||||
//=============================================================================
|
||||
//
|
||||
// Vertex and Face circulators for PolyMesh/TriMesh
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
|
||||
|
||||
//== INCLUDES =================================================================
|
||||
|
||||
#include <OpenMesh/Core/System/config.h>
|
||||
#include <assert.h>
|
||||
|
||||
|
||||
//== NAMESPACES ===============================================================
|
||||
|
||||
namespace OpenMesh {
|
||||
namespace Iterators {
|
||||
|
||||
|
||||
//== FORWARD DECLARATIONS =====================================================
|
||||
|
||||
|
||||
template <class Mesh> class VertexVertexIterT;
|
||||
template <class Mesh> class VertexIHalfedgeIterT;
|
||||
template <class Mesh> class VertexOHalfedgeIterT;
|
||||
template <class Mesh> class VertexEdgeIterT;
|
||||
template <class Mesh> class VertexFaceIterT;
|
||||
|
||||
template <class Mesh> class ConstVertexVertexIterT;
|
||||
template <class Mesh> class ConstVertexIHalfedgeIterT;
|
||||
template <class Mesh> class ConstVertexOHalfedgeIterT;
|
||||
template <class Mesh> class ConstVertexEdgeIterT;
|
||||
template <class Mesh> class ConstVertexFaceIterT;
|
||||
|
||||
template <class Mesh> class FaceVertexIterT;
|
||||
template <class Mesh> class FaceHalfedgeIterT;
|
||||
template <class Mesh> class FaceEdgeIterT;
|
||||
template <class Mesh> class FaceFaceIterT;
|
||||
|
||||
template <class Mesh> class ConstFaceVertexIterT;
|
||||
template <class Mesh> class ConstFaceHalfedgeIterT;
|
||||
template <class Mesh> class ConstFaceEdgeIterT;
|
||||
template <class Mesh> class ConstFaceFaceIterT;
|
||||
|
||||
|
||||
|
||||
190
Core/Mesh/gen/circulators_template.hh
Normal file
190
Core/Mesh/gen/circulators_template.hh
Normal file
@@ -0,0 +1,190 @@
|
||||
//== CLASS DEFINITION =========================================================
|
||||
|
||||
|
||||
/** \class CirculatorT CirculatorsT.hh <OpenMesh/Mesh/Iterators/CirculatorsT.hh>
|
||||
Circulator.
|
||||
*/
|
||||
|
||||
template <class Mesh>
|
||||
class CirculatorT
|
||||
{
|
||||
public:
|
||||
|
||||
|
||||
//--- Typedefs ---
|
||||
|
||||
typedef typename Mesh::HalfedgeHandle HalfedgeHandle;
|
||||
|
||||
typedef TargetType value_type;
|
||||
typedef TargetHandle value_handle;
|
||||
|
||||
#if IsConst
|
||||
typedef const Mesh& mesh_ref;
|
||||
typedef const Mesh* mesh_ptr;
|
||||
typedef const TargetType& reference;
|
||||
typedef const TargetType* pointer;
|
||||
#else
|
||||
typedef Mesh& mesh_ref;
|
||||
typedef Mesh* mesh_ptr;
|
||||
typedef TargetType& reference;
|
||||
typedef TargetType* pointer;
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/// Default constructor
|
||||
CirculatorT() : mesh_(0), active_(false) {}
|
||||
|
||||
|
||||
/// Construct with mesh and a SourceHandle
|
||||
CirculatorT(mesh_ref _mesh, SourceHandle _start) :
|
||||
mesh_(&_mesh),
|
||||
start_(_mesh.halfedge_handle(_start)),
|
||||
heh_(start_),
|
||||
active_(false)
|
||||
{ post_init; }
|
||||
|
||||
|
||||
/// Construct with mesh and start halfedge
|
||||
CirculatorT(mesh_ref _mesh, HalfedgeHandle _heh) :
|
||||
mesh_(&_mesh),
|
||||
start_(_heh),
|
||||
heh_(_heh),
|
||||
active_(false)
|
||||
{ post_init; }
|
||||
|
||||
|
||||
/// Copy constructor
|
||||
CirculatorT(const CirculatorT& _rhs) :
|
||||
mesh_(_rhs.mesh_),
|
||||
start_(_rhs.start_),
|
||||
heh_(_rhs.heh_),
|
||||
active_(_rhs.active_)
|
||||
{ post_init; }
|
||||
|
||||
|
||||
/// Assignment operator
|
||||
CirculatorT& operator=(const CirculatorT<Mesh>& _rhs)
|
||||
{
|
||||
mesh_ = _rhs.mesh_;
|
||||
start_ = _rhs.start_;
|
||||
heh_ = _rhs.heh_;
|
||||
active_ = _rhs.active_;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
#if IsConst
|
||||
/// construct from non-const circulator type
|
||||
CirculatorT(const NonConstCircT<Mesh>& _rhs) :
|
||||
mesh_(_rhs.mesh_),
|
||||
start_(_rhs.start_),
|
||||
heh_(_rhs.heh_),
|
||||
active_(_rhs.active_)
|
||||
{ post_init; }
|
||||
|
||||
|
||||
/// assign from non-const circulator
|
||||
CirculatorT& operator=(const NonConstCircT<Mesh>& _rhs)
|
||||
{
|
||||
mesh_ = _rhs.mesh_;
|
||||
start_ = _rhs.start_;
|
||||
heh_ = _rhs.heh_;
|
||||
active_ = _rhs.active_;
|
||||
return *this;
|
||||
}
|
||||
#else
|
||||
friend class ConstCircT<Mesh>;
|
||||
#endif
|
||||
|
||||
|
||||
/// Equal ?
|
||||
bool operator==(const CirculatorT& _rhs) const {
|
||||
return ((mesh_ == _rhs.mesh_) &&
|
||||
(start_ == _rhs.start_) &&
|
||||
(heh_ == _rhs.heh_) &&
|
||||
(active_ == _rhs.active_));
|
||||
}
|
||||
|
||||
|
||||
/// Not equal ?
|
||||
bool operator!=(const CirculatorT& _rhs) const {
|
||||
return !operator==(_rhs);
|
||||
}
|
||||
|
||||
|
||||
/// Pre-Increment (next cw target)
|
||||
CirculatorT& operator++() {
|
||||
assert(mesh_);
|
||||
active_ = true;
|
||||
increment;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
/// Pre-Decrement (next ccw target)
|
||||
CirculatorT& operator--() {
|
||||
assert(mesh_);
|
||||
active_ = true;
|
||||
decrement;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
/** Get the current halfedge. There are \c Vertex*Iters and \c
|
||||
Face*Iters. For both the current state is defined by the
|
||||
current halfedge. This is what this method returns.
|
||||
*/
|
||||
HalfedgeHandle current_halfedge_handle() const {
|
||||
return heh_;
|
||||
}
|
||||
|
||||
|
||||
/// Return the handle of the current target.
|
||||
TargetHandle handle() const {
|
||||
assert(mesh_);
|
||||
return get_handle;
|
||||
}
|
||||
|
||||
|
||||
/// Cast to the handle of the current target.
|
||||
operator TargetHandle() const {
|
||||
assert(mesh_);
|
||||
return get_handle;
|
||||
}
|
||||
|
||||
|
||||
/// Return a reference to the current target.
|
||||
reference operator*() const {
|
||||
assert(mesh_);
|
||||
return mesh_->deref(handle());
|
||||
}
|
||||
|
||||
|
||||
/// Return a pointer to the current target.
|
||||
pointer operator->() const {
|
||||
assert(mesh_);
|
||||
return &mesh_->deref(handle());
|
||||
}
|
||||
|
||||
|
||||
/** Returns whether the circulator is still valid.
|
||||
After one complete round around a vertex/face the circulator becomes
|
||||
invalid, i.e. this function will return \c false. Nevertheless you
|
||||
can continue circulating. This method just tells you whether you
|
||||
have completed the first round.
|
||||
*/
|
||||
operator bool() const {
|
||||
return heh_.is_valid() && ((start_ != heh_) || (!active_));
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
|
||||
mesh_ptr mesh_;
|
||||
HalfedgeHandle start_, heh_;
|
||||
bool active_;
|
||||
};
|
||||
|
||||
|
||||
|
||||
6
Core/Mesh/gen/footer.hh
Normal file
6
Core/Mesh/gen/footer.hh
Normal file
@@ -0,0 +1,6 @@
|
||||
//=============================================================================
|
||||
} // namespace Iterators
|
||||
} // namespace OpenMesh
|
||||
//=============================================================================
|
||||
#endif
|
||||
//=============================================================================
|
||||
175
Core/Mesh/gen/generate.sh
Normal file
175
Core/Mesh/gen/generate.sh
Normal file
@@ -0,0 +1,175 @@
|
||||
#!/bin/bash
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
|
||||
# generate_iterator( TargetType, n_elements, has_element_status )
|
||||
function generate_iterator
|
||||
{
|
||||
NonConstIter=$1"IterT"
|
||||
ConstIter="Const"$NonConstIter
|
||||
TargetType="typename Mesh::"$1
|
||||
TargetHandle="typename Mesh::"$1"Handle"
|
||||
|
||||
|
||||
cat iterators_template.hh \
|
||||
| sed -e "s/IteratorT/$NonConstIter/; s/IteratorT/$NonConstIter/;
|
||||
s/NonConstIterT/$NonConstIter/;
|
||||
s/ConstIterT/$ConstIter/;
|
||||
s/TargetType/$TargetType/;
|
||||
s/TargetHandle/$TargetHandle/;
|
||||
s/IsConst/0/;
|
||||
s/n_elements/$2/;
|
||||
s/has_element_status/$3/;"
|
||||
|
||||
|
||||
cat iterators_template.hh \
|
||||
| sed -e "s/IteratorT/$ConstIter/; s/IteratorT/$ConstIter/;
|
||||
s/NonConstIterT/$NonConstIter/;
|
||||
s/ConstIterT/$ConstIter/;
|
||||
s/TargetType/$TargetType/;
|
||||
s/TargetHandle/$TargetHandle/;
|
||||
s/IsConst/1/;
|
||||
s/n_elements/$2/;
|
||||
s/has_element_status/$3/;"
|
||||
}
|
||||
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
|
||||
# generate_circulator( NonConstName, SourceType, TargetType,
|
||||
# post_init,
|
||||
# increment, decrement,
|
||||
# get_handle,
|
||||
# [Name] )
|
||||
function generate_circulator
|
||||
{
|
||||
NonConstCirc=$1
|
||||
ConstCirc="Const"$NonConstCirc
|
||||
SourceHandle="typename Mesh::"$2"Handle"
|
||||
TargetHandle="typename Mesh::"$3"Handle"
|
||||
TargetType="typename Mesh::"$3
|
||||
|
||||
|
||||
cat circulators_template.hh \
|
||||
| sed -e "s/CirculatorT/$NonConstCirc/; s/CirculatorT/$NonConstCirc/;
|
||||
s/NonConstCircT/$NonConstCirc/;
|
||||
s/ConstCircT/$ConstCirc/;
|
||||
s/SourceHandle/$SourceHandle/;
|
||||
s/TargetHandle/$TargetHandle/;
|
||||
s/TargetType/$TargetType/;
|
||||
s/IsConst/0/;
|
||||
s/post_init/$4/;
|
||||
s/increment/$5/;
|
||||
s/decrement/$6/;
|
||||
s/get_handle/$7/;"
|
||||
|
||||
|
||||
cat circulators_template.hh \
|
||||
| sed -e "s/CirculatorT/$ConstCirc/; s/CirculatorT/$ConstCirc/;
|
||||
s/NonConstCircT/$NonConstCirc/;
|
||||
s/ConstCircT/$ConstCirc/;
|
||||
s/SourceHandle/$SourceHandle/;
|
||||
s/TargetHandle/$TargetHandle/;
|
||||
s/TargetType/$TargetType/;
|
||||
s/IsConst/1/;
|
||||
s/post_init/$4/;
|
||||
s/increment/$5/;
|
||||
s/decrement/$6/;
|
||||
s/get_handle/$7/;"
|
||||
}
|
||||
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
|
||||
### Generate IteratorsT.hh
|
||||
|
||||
cat iterators_header.hh > IteratorsT.hh
|
||||
|
||||
generate_iterator Vertex n_vertices has_vertex_status >> IteratorsT.hh
|
||||
generate_iterator Halfedge n_halfedges has_halfedge_status >> IteratorsT.hh
|
||||
generate_iterator Edge n_edges has_edge_status >> IteratorsT.hh
|
||||
generate_iterator Face n_faces has_face_status >> IteratorsT.hh
|
||||
|
||||
cat footer.hh >> IteratorsT.hh
|
||||
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
|
||||
### Generate CirculatorsT.hh
|
||||
|
||||
cat circulators_header.hh > CirculatorsT.hh
|
||||
|
||||
|
||||
generate_circulator VertexVertexIterT Vertex Vertex \
|
||||
" " \
|
||||
"heh_=mesh_->cw_rotated_halfedge_handle(heh_);" \
|
||||
"heh_=mesh_->ccw_rotated_halfedge_handle(heh_);" \
|
||||
"mesh_->to_vertex_handle(heh_);" \
|
||||
>> CirculatorsT.hh
|
||||
|
||||
generate_circulator VertexOHalfedgeIterT Vertex Halfedge \
|
||||
" " \
|
||||
"heh_=mesh_->cw_rotated_halfedge_handle(heh_);" \
|
||||
"heh_=mesh_->ccw_rotated_halfedge_handle(heh_);" \
|
||||
"heh_" \
|
||||
>> CirculatorsT.hh
|
||||
|
||||
generate_circulator VertexIHalfedgeIterT Vertex Halfedge \
|
||||
" " \
|
||||
"heh_=mesh_->cw_rotated_halfedge_handle(heh_);" \
|
||||
"heh_=mesh_->ccw_rotated_halfedge_handle(heh_);" \
|
||||
"mesh_->opposite_halfedge_handle(heh_)" \
|
||||
>> CirculatorsT.hh
|
||||
|
||||
generate_circulator VertexEdgeIterT Vertex Edge \
|
||||
" " \
|
||||
"heh_=mesh_->cw_rotated_halfedge_handle(heh_);" \
|
||||
"heh_=mesh_->ccw_rotated_halfedge_handle(heh_);" \
|
||||
"mesh_->edge_handle(heh_)" \
|
||||
>> CirculatorsT.hh
|
||||
|
||||
generate_circulator VertexFaceIterT Vertex Face \
|
||||
"if (heh_.is_valid() \&\& !handle().is_valid()) operator++();" \
|
||||
"do heh_=mesh_->cw_rotated_halfedge_handle(heh_); while ((*this) \&\& (!handle().is_valid()));" \
|
||||
"do heh_=mesh_->ccw_rotated_halfedge_handle(heh_); while ((*this) \&\& (!handle().is_valid()));" \
|
||||
"mesh_->face_handle(heh_)" \
|
||||
>> CirculatorsT.hh
|
||||
|
||||
|
||||
generate_circulator FaceVertexIterT Face Vertex \
|
||||
" " \
|
||||
"heh_=mesh_->next_halfedge_handle(heh_);" \
|
||||
"heh_=mesh_->prev_halfedge_handle(heh_);" \
|
||||
"mesh_->to_vertex_handle(heh_)" \
|
||||
>> CirculatorsT.hh
|
||||
|
||||
generate_circulator FaceHalfedgeIterT Face Halfedge \
|
||||
" " \
|
||||
"heh_=mesh_->next_halfedge_handle(heh_);" \
|
||||
"heh_=mesh_->prev_halfedge_handle(heh_);" \
|
||||
"heh_" \
|
||||
>> CirculatorsT.hh
|
||||
|
||||
generate_circulator FaceEdgeIterT Face Edge \
|
||||
" " \
|
||||
"heh_=mesh_->next_halfedge_handle(heh_);" \
|
||||
"heh_=mesh_->prev_halfedge_handle(heh_);" \
|
||||
"mesh_->edge_handle(heh_)" \
|
||||
>> CirculatorsT.hh
|
||||
|
||||
generate_circulator FaceFaceIterT Face Face \
|
||||
"if (heh_.is_valid() \&\& !handle().is_valid()) operator++();" \
|
||||
"do heh_=mesh_->next_halfedge_handle(heh_); while ((*this) \&\& (!handle().is_valid()));" \
|
||||
"do heh_=mesh_->prev_halfedge_handle(heh_); while ((*this) \&\& (!handle().is_valid()));" \
|
||||
"mesh_->face_handle(mesh_->opposite_halfedge_handle(heh_))" \
|
||||
>> CirculatorsT.hh
|
||||
|
||||
|
||||
cat footer.hh >> CirculatorsT.hh
|
||||
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
62
Core/Mesh/gen/iterators_header.hh
Normal file
62
Core/Mesh/gen/iterators_header.hh
Normal file
@@ -0,0 +1,62 @@
|
||||
/*===========================================================================*\
|
||||
* *
|
||||
* OpenMesh *
|
||||
* Copyright (C) 2001-2003 by Computer Graphics Group, RWTH Aachen *
|
||||
* www.openmesh.org *
|
||||
* *
|
||||
*---------------------------------------------------------------------------*
|
||||
* *
|
||||
* License *
|
||||
* *
|
||||
* This library is free software; you can redistribute it and/or modify it *
|
||||
* under the terms of the GNU Lesser General Public License as published *
|
||||
* by the Free Software Foundation, version 2.1. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, but *
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
|
||||
* Lesser General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with this library; if not, write to the Free Software *
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
|
||||
* *
|
||||
\*===========================================================================*/
|
||||
#ifndef OPENMESH_ITERATORS_HH
|
||||
#define OPENMESH_ITERATORS_HH
|
||||
//=============================================================================
|
||||
//
|
||||
// Iterators for PolyMesh/TriMesh
|
||||
//
|
||||
//=============================================================================
|
||||
|
||||
|
||||
|
||||
//== INCLUDES =================================================================
|
||||
|
||||
#include <OpenMesh/Core/System/config.h>
|
||||
#include <OpenMesh/Core/Attributes/Status.hh>
|
||||
#include <assert.h>
|
||||
|
||||
|
||||
//== NAMESPACES ===============================================================
|
||||
|
||||
namespace OpenMesh {
|
||||
namespace Iterators {
|
||||
|
||||
|
||||
//== FORWARD DECLARATIONS =====================================================
|
||||
|
||||
|
||||
template <class Mesh> class VertexIterT;
|
||||
template <class Mesh> class ConstVertexIterT;
|
||||
template <class Mesh> class HalfedgeIterT;
|
||||
template <class Mesh> class ConstHalfedgeIterT;
|
||||
template <class Mesh> class EdgeIterT;
|
||||
template <class Mesh> class ConstEdgeIterT;
|
||||
template <class Mesh> class FaceIterT;
|
||||
template <class Mesh> class ConstFaceIterT;
|
||||
|
||||
|
||||
|
||||
|
||||
162
Core/Mesh/gen/iterators_template.hh
Normal file
162
Core/Mesh/gen/iterators_template.hh
Normal file
@@ -0,0 +1,162 @@
|
||||
//== CLASS DEFINITION =========================================================
|
||||
|
||||
|
||||
/** \class IteratorT IteratorsT.hh <OpenMesh/Mesh/Iterators/IteratorsT.hh>
|
||||
Linear iterator.
|
||||
*/
|
||||
|
||||
template <class Mesh>
|
||||
class IteratorT
|
||||
{
|
||||
public:
|
||||
|
||||
|
||||
//--- Typedefs ---
|
||||
|
||||
typedef TargetType value_type;
|
||||
typedef TargetHandle value_handle;
|
||||
|
||||
#if IsConst
|
||||
typedef const value_type& reference;
|
||||
typedef const value_type* pointer;
|
||||
typedef const Mesh* mesh_ptr;
|
||||
typedef const Mesh& mesh_ref;
|
||||
#else
|
||||
typedef value_type& reference;
|
||||
typedef value_type* pointer;
|
||||
typedef Mesh* mesh_ptr;
|
||||
typedef Mesh& mesh_ref;
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
/// Default constructor.
|
||||
IteratorT()
|
||||
: mesh_(0), skip_bits_(0)
|
||||
{}
|
||||
|
||||
|
||||
/// Construct with mesh and a target handle.
|
||||
IteratorT(mesh_ref _mesh, value_handle _hnd, bool _skip=false)
|
||||
: mesh_(&_mesh), hnd_(_hnd), skip_bits_(0)
|
||||
{
|
||||
if (_skip) enable_skipping();
|
||||
}
|
||||
|
||||
|
||||
/// Copy constructor
|
||||
IteratorT(const IteratorT& _rhs)
|
||||
: mesh_(_rhs.mesh_), hnd_(_rhs.hnd_), skip_bits_(_rhs.skip_bits_)
|
||||
{}
|
||||
|
||||
|
||||
/// Assignment operator
|
||||
IteratorT& operator=(const IteratorT<Mesh>& _rhs)
|
||||
{
|
||||
mesh_ = _rhs.mesh_;
|
||||
hnd_ = _rhs.hnd_;
|
||||
skip_bits_ = _rhs.skip_bits_;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
#if IsConst
|
||||
|
||||
/// Construct from a non-const iterator
|
||||
IteratorT(const NonConstIterT<Mesh>& _rhs)
|
||||
: mesh_(_rhs.mesh_), hnd_(_rhs.hnd_), skip_bits_(_rhs.skip_bits_)
|
||||
{}
|
||||
|
||||
|
||||
/// Assignment from non-const iterator
|
||||
IteratorT& operator=(const NonConstIterT<Mesh>& _rhs)
|
||||
{
|
||||
mesh_ = _rhs.mesh_;
|
||||
hnd_ = _rhs.hnd_;
|
||||
skip_bits_ = _rhs.skip_bits_;
|
||||
return *this;
|
||||
}
|
||||
|
||||
#else
|
||||
friend class ConstIterT<Mesh>;
|
||||
#endif
|
||||
|
||||
|
||||
/// Standard dereferencing operator.
|
||||
reference operator*() const { return mesh_->deref(hnd_); }
|
||||
|
||||
/// Standard pointer operator.
|
||||
pointer operator->() const { return &(mesh_->deref(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 IteratorT& _rhs) const
|
||||
{ return ((mesh_ == _rhs.mesh_) && (hnd_ == _rhs.hnd_)); }
|
||||
|
||||
/// Not equal?
|
||||
bool operator!=(const IteratorT& _rhs) const
|
||||
{ return !operator==(_rhs); }
|
||||
|
||||
/// Standard pre-increment operator
|
||||
IteratorT& operator++()
|
||||
{ hnd_.__increment(); if (skip_bits_) skip_fwd(); return *this; }
|
||||
|
||||
/// Standard pre-decrement operator
|
||||
IteratorT& 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_element_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_elements()) &&
|
||||
(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_;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user