⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 circulatorst.hh

📁 penMesh is a generic and efficient data structure for representing and manipulating polygonal meshes
💻 HH
📖 第 1 页 / 共 5 页
字号:
/*===========================================================================*\ *                                                                           * *                               OpenMesh                                    * *      Copyright (C) 2001-2005 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 Library General Public License as published   * *  by the Free Software Foundation, version 2.                              * *                                                                           * *  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        * *  Library General Public License for more details.                         * *                                                                           * *  You should have received a copy of the GNU Library 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.hh>#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;//== CLASS DEFINITION =========================================================	      /** \class VertexVertexIterT CirculatorsT.hh <OpenMesh/Mesh/Iterators/CirculatorsT.hh>    Circulator.*/template <class Mesh>class VertexVertexIterT{ public:  //--- Typedefs ---  typedef typename Mesh::HalfedgeHandle   HalfedgeHandle;  typedef typename Mesh::Vertex           value_type;  typedef typename Mesh::VertexHandle         value_handle;#if 0  typedef const Mesh&         mesh_ref;  typedef const Mesh*         mesh_ptr;  typedef const typename Mesh::Vertex&   reference;  typedef const typename Mesh::Vertex*   pointer;#else  typedef Mesh&               mesh_ref;  typedef Mesh*               mesh_ptr;  typedef typename Mesh::Vertex&         reference;  typedef typename Mesh::Vertex*         pointer;#endif  /// Default constructor  VertexVertexIterT() : mesh_(0), active_(false) {}  /// Construct with mesh and a typename Mesh::VertexHandle  VertexVertexIterT(mesh_ref _mesh, typename Mesh::VertexHandle _start) :    mesh_(&_mesh),     start_(_mesh.halfedge_handle(_start)),    heh_(start_),    active_(false)  {  ; }  /// Construct with mesh and start halfedge  VertexVertexIterT(mesh_ref _mesh, HalfedgeHandle _heh) :    mesh_(&_mesh),    start_(_heh),    heh_(_heh),    active_(false)  {  ; }  /// Copy constructor  VertexVertexIterT(const VertexVertexIterT& _rhs) :    mesh_(_rhs.mesh_),    start_(_rhs.start_),    heh_(_rhs.heh_),    active_(_rhs.active_)  {  ; }  /// Assignment operator  VertexVertexIterT& operator=(const VertexVertexIterT<Mesh>& _rhs)  {    mesh_   = _rhs.mesh_;    start_  = _rhs.start_;    heh_    = _rhs.heh_;    active_ = _rhs.active_;    return *this;  }#if 0  /// construct from non-const circulator type  VertexVertexIterT(const VertexVertexIterT<Mesh>& _rhs) :    mesh_(_rhs.mesh_),    start_(_rhs.start_),    heh_(_rhs.heh_),    active_(_rhs.active_)  {  ; }  /// assign from non-const circulator  VertexVertexIterT& operator=(const VertexVertexIterT<Mesh>& _rhs)  {    mesh_   = _rhs.mesh_;    start_  = _rhs.start_;    heh_    = _rhs.heh_;    active_ = _rhs.active_;    return *this;  }#else  friend class ConstVertexVertexIterT<Mesh>;#endif    /// Equal ?  bool operator==(const VertexVertexIterT& _rhs) const {    return ((mesh_   == _rhs.mesh_) &&	    (start_  == _rhs.start_) &&	    (heh_    == _rhs.heh_) &&	    (active_ == _rhs.active_));  }  /// Not equal ?  bool operator!=(const VertexVertexIterT& _rhs) const {    return !operator==(_rhs);  }  /// Pre-Increment (next cw target)  VertexVertexIterT& operator++() {     assert(mesh_);    active_ = true;    heh_=mesh_->cw_rotated_halfedge_handle(heh_);;    return *this;  }  /// Pre-Decrement (next ccw target)  VertexVertexIterT& operator--() {     assert(mesh_);    active_ = true;    heh_=mesh_->ccw_rotated_halfedge_handle(heh_);;    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.  typename Mesh::VertexHandle handle() const {    assert(mesh_);    return mesh_->to_vertex_handle(heh_);;   }  /// Cast to the handle of the current target.  operator typename Mesh::VertexHandle() const {    assert(mesh_);    return mesh_->to_vertex_handle(heh_);;   }      ///  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_;};//== CLASS DEFINITION =========================================================	      /** \class ConstVertexVertexIterT CirculatorsT.hh <OpenMesh/Mesh/Iterators/CirculatorsT.hh>    Circulator.*/template <class Mesh>class ConstVertexVertexIterT{ public:  //--- Typedefs ---  typedef typename Mesh::HalfedgeHandle   HalfedgeHandle;  typedef typename Mesh::Vertex           value_type;  typedef typename Mesh::VertexHandle         value_handle;#if 1  typedef const Mesh&         mesh_ref;  typedef const Mesh*         mesh_ptr;  typedef const typename Mesh::Vertex&   reference;  typedef const typename Mesh::Vertex*   pointer;#else  typedef Mesh&               mesh_ref;  typedef Mesh*               mesh_ptr;  typedef typename Mesh::Vertex&         reference;  typedef typename Mesh::Vertex*         pointer;#endif  /// Default constructor  ConstVertexVertexIterT() : mesh_(0), active_(false) {}  /// Construct with mesh and a typename Mesh::VertexHandle  ConstVertexVertexIterT(mesh_ref _mesh, typename Mesh::VertexHandle _start) :    mesh_(&_mesh),     start_(_mesh.halfedge_handle(_start)),    heh_(start_),    active_(false)  {  ; }  /// Construct with mesh and start halfedge  ConstVertexVertexIterT(mesh_ref _mesh, HalfedgeHandle _heh) :    mesh_(&_mesh),    start_(_heh),    heh_(_heh),    active_(false)  {  ; }  /// Copy constructor  ConstVertexVertexIterT(const ConstVertexVertexIterT& _rhs) :    mesh_(_rhs.mesh_),    start_(_rhs.start_),    heh_(_rhs.heh_),    active_(_rhs.active_)  {  ; }  /// Assignment operator  ConstVertexVertexIterT& operator=(const ConstVertexVertexIterT<Mesh>& _rhs)  {    mesh_   = _rhs.mesh_;    start_  = _rhs.start_;    heh_    = _rhs.heh_;    active_ = _rhs.active_;    return *this;  }#if 1  /// construct from non-const circulator type  ConstVertexVertexIterT(const VertexVertexIterT<Mesh>& _rhs) :    mesh_(_rhs.mesh_),    start_(_rhs.start_),    heh_(_rhs.heh_),    active_(_rhs.active_)  {  ; }  /// assign from non-const circulator  ConstVertexVertexIterT& operator=(const VertexVertexIterT<Mesh>& _rhs)  {    mesh_   = _rhs.mesh_;    start_  = _rhs.start_;    heh_    = _rhs.heh_;    active_ = _rhs.active_;    return *this;  }#else  friend class ConstVertexVertexIterT<Mesh>;#endif    /// Equal ?  bool operator==(const ConstVertexVertexIterT& _rhs) const {    return ((mesh_   == _rhs.mesh_) &&	    (start_  == _rhs.start_) &&	    (heh_    == _rhs.heh_) &&	    (active_ == _rhs.active_));  }  /// Not equal ?  bool operator!=(const ConstVertexVertexIterT& _rhs) const {    return !operator==(_rhs);  }  /// Pre-Increment (next cw target)  ConstVertexVertexIterT& operator++() {     assert(mesh_);    active_ = true;    heh_=mesh_->cw_rotated_halfedge_handle(heh_);;    return *this;  }  /// Pre-Decrement (next ccw target)  ConstVertexVertexIterT& operator--() {     assert(mesh_);    active_ = true;    heh_=mesh_->ccw_rotated_halfedge_handle(heh_);;    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.  typename Mesh::VertexHandle handle() const {    assert(mesh_);    return mesh_->to_vertex_handle(heh_);;   }  /// Cast to the handle of the current target.  operator typename Mesh::VertexHandle() const {    assert(mesh_);    return mesh_->to_vertex_handle(heh_);;   }      ///  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_;};//== CLASS DEFINITION =========================================================	      /** \class VertexOHalfedgeIterT CirculatorsT.hh <OpenMesh/Mesh/Iterators/CirculatorsT.hh>    Circulator.*/template <class Mesh>class VertexOHalfedgeIterT{ public:  //--- Typedefs ---  typedef typename Mesh::HalfedgeHandle   HalfedgeHandle;  typedef typename Mesh::Halfedge           value_type;  typedef typename Mesh::HalfedgeHandle         value_handle;#if 0  typedef const Mesh&         mesh_ref;  typedef const Mesh*         mesh_ptr;  typedef const typename Mesh::Halfedge&   reference;  typedef const typename Mesh::Halfedge*   pointer;#else  typedef Mesh&               mesh_ref;  typedef Mesh*               mesh_ptr;  typedef typename Mesh::Halfedge&         reference;  typedef typename Mesh::Halfedge*         pointer;#endif  /// Default constructor  VertexOHalfedgeIterT() : mesh_(0), active_(false) {}  /// Construct with mesh and a typename Mesh::VertexHandle  VertexOHalfedgeIterT(mesh_ref _mesh, typename Mesh::VertexHandle _start) :    mesh_(&_mesh),     start_(_mesh.halfedge_handle(_start)),    heh_(start_),    active_(false)  {  ; }  /// Construct with mesh and start halfedge  VertexOHalfedgeIterT(mesh_ref _mesh, HalfedgeHandle _heh) :    mesh_(&_mesh),    start_(_heh),    heh_(_heh),    active_(false)  {  ; }  /// Copy constructor  VertexOHalfedgeIterT(const VertexOHalfedgeIterT& _rhs) :    mesh_(_rhs.mesh_),    start_(_rhs.start_),    heh_(_rhs.heh_),    active_(_rhs.active_)  {  ; }  /// Assignment operator  VertexOHalfedgeIterT& operator=(const VertexOHalfedgeIterT<Mesh>& _rhs)  {    mesh_   = _rhs.mesh_;    start_  = _rhs.start_;    heh_    = _rhs.heh_;    active_ = _rhs.active_;    return *this;  }#if 0  /// construct from non-const circulator type  VertexOHalfedgeIterT(const VertexOHalfedgeIterT<Mesh>& _rhs) :    mesh_(_rhs.mesh_),    start_(_rhs.start_),    heh_(_rhs.heh_),    active_(_rhs.active_)  {  ; }  /// assign from non-const circulator  VertexOHalfedgeIterT& operator=(const VertexOHalfedgeIterT<Mesh>& _rhs)  {    mesh_   = _rhs.mesh_;    start_  = _rhs.start_;    heh_    = _rhs.heh_;    active_ = _rhs.active_;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -