diff --git a/src/OpenMesh/Core/Mesh/CirculatorsT.hh b/src/OpenMesh/Core/Mesh/CirculatorsT.hh index c3beb711..6e6e31e5 100644 --- a/src/OpenMesh/Core/Mesh/CirculatorsT.hh +++ b/src/OpenMesh/Core/Mesh/CirculatorsT.hh @@ -61,22 +61,242 @@ namespace OpenMesh { namespace Iterators { +template +class GenericCirculator_CenterEntityFnsT { + public: + static void increment(const Mesh *mesh, typename Mesh::HalfedgeHandle &heh, typename Mesh::HalfedgeHandle &start, int &lap_counter); + static void decrement(const Mesh *mesh, typename Mesh::HalfedgeHandle &heh, typename Mesh::HalfedgeHandle &start, int &lap_counter); +}; + +template +class GenericCirculator_CenterEntityFnsT { + public: + inline static void increment(const Mesh *mesh, typename Mesh::HalfedgeHandle &heh, typename Mesh::HalfedgeHandle &start, int &lap_counter) { + heh = mesh->cw_rotated_halfedge_handle(heh); + if (heh == start) ++lap_counter; + } + inline static void decrement(const Mesh *mesh, typename Mesh::HalfedgeHandle &heh, typename Mesh::HalfedgeHandle &start, int &lap_counter) { + if (heh == start) --lap_counter; + heh = mesh->ccw_rotated_halfedge_handle(heh); + } +}; + +template +class GenericCirculator_CenterEntityFnsT { + public: + inline static void increment(const Mesh *mesh, typename Mesh::HalfedgeHandle &heh, typename Mesh::HalfedgeHandle &start, int &lap_counter) { + heh = mesh->next_halfedge_handle(heh); + if (heh == start) ++lap_counter; + } + inline static void decrement(const Mesh *mesh, typename Mesh::HalfedgeHandle &heh, typename Mesh::HalfedgeHandle &start, int &lap_counter) { + if (heh == start) --lap_counter; + heh = mesh->prev_halfedge_handle(heh); + } +}; + +template +class GenericCirculator_ValueHandleFnsT { + public: + inline static bool is_valid(const Mesh *mesh, const typename Mesh::HalfedgeHandle &heh, const typename Mesh::HalfedgeHandle &start, const int &lap_counter) { + return heh.is_valid() && ((start != heh) || (lap_counter == 0)); + } + inline static void init(const Mesh *mesh, typename Mesh::HalfedgeHandle &heh, typename Mesh::HalfedgeHandle &start, int &lap_counter) {}; + inline static void increment(const Mesh *mesh, typename Mesh::HalfedgeHandle &heh, typename Mesh::HalfedgeHandle &start, int &lap_counter) { + GenericCirculator_CenterEntityFnsT::increment(mesh, heh, start, lap_counter); + } + inline static void decrement(const Mesh *mesh, typename Mesh::HalfedgeHandle &heh, typename Mesh::HalfedgeHandle &start, int &lap_counter) { + GenericCirculator_CenterEntityFnsT::decrement(mesh, heh, start, lap_counter); + } +}; + +template +class GenericCirculator_ValueHandleFnsT { + public: + inline static bool is_valid(const Mesh *mesh, const typename Mesh::HalfedgeHandle &heh, const typename Mesh::HalfedgeHandle &start, const int &lap_counter) { + return heh.is_valid() && ((start != heh) || (lap_counter == 0)); + } + inline static void init(const Mesh *mesh, typename Mesh::HalfedgeHandle &heh, typename Mesh::HalfedgeHandle &start, int &lap_counter) { + if (is_valid(mesh, heh, start, lap_counter) && !mesh->face_handle(heh).is_valid()) + increment(mesh, heh, start, lap_counter); + }; + inline static void increment(const Mesh *mesh, typename Mesh::HalfedgeHandle &heh, typename Mesh::HalfedgeHandle &start, int &lap_counter) { + do { + GenericCirculator_CenterEntityFnsT::increment(mesh, heh, start, lap_counter); + } while (is_valid(mesh, heh, start, lap_counter) && !mesh->face_handle(heh).is_valid()); + } + inline static void decrement(const Mesh *mesh, typename Mesh::HalfedgeHandle &heh, typename Mesh::HalfedgeHandle &start, int &lap_counter) { + do { + GenericCirculator_CenterEntityFnsT::decrement(mesh, heh, start, lap_counter); + } while (is_valid(mesh, heh, start, lap_counter) && !mesh->face_handle(heh).is_valid()); + } +}; + +template +class GenericCirculatorBaseT { + public: + typedef const Mesh* mesh_ptr; + typedef const Mesh& mesh_ref; + + public: + GenericCirculatorBaseT() : mesh_(0), lap_counter_(0) {} + + GenericCirculatorBaseT(mesh_ref mesh, HalfedgeHandle heh, bool end = false) : + mesh_(&mesh), start_(heh), heh_(heh), lap_counter_(static_cast(end)) {} + + GenericCirculatorBaseT(const GenericCirculatorBaseT &rhs) : + mesh_(rhs.mesh_), start_(rhs.start_), heh_(rhs.heh_), lap_counter_(rhs.lap_counter_) {} + + inline typename Mesh::FaceHandle toFaceHandle() const { + return mesh_->face_handle(heh_); + } + + inline typename Mesh::EdgeHandle toEdgeHandle() const { + return mesh_->edge_handle(heh_); + } + + inline typename Mesh::HalfedgeHandle toHalfedgeHandle() const { + return heh_; + } + + inline typename Mesh::HalfedgeHandle toOppositeHalfedgeHandle() const { + return mesh_->opposite_halfedge_handle(heh_); + } + + inline typename Mesh::VertexHandle toVertexHandle() const { + return mesh_->to_vertex_handle(heh_); + } + + inline GenericCirculatorBaseT &operator=(const GenericCirculatorBaseT &rhs) { + mesh_ = rhs.mesh_; + start_ = rhs.start_; + heh_ = rhs.heh_; + lap_counter_ = rhs.lap_counter_; + return *this; + } + + inline bool operator==(const GenericCirculatorBaseT &rhs) const { + return mesh_ == rhs.mesh_ && start_ == rhs.start_ && heh_ == rhs.heh_ && lap_counter_ == rhs.lap_counter_; + } + + inline bool operator!=(const GenericCirculatorBaseT &rhs) const { + return !operator==(rhs); + } + + protected: + mesh_ptr mesh_; + typename Mesh::HalfedgeHandle start_, heh_; + int lap_counter_; +}; + +template::*Increment)(), +// void (GenericCirculatorBaseT::*Decrement)(), + ValueHandle (GenericCirculatorBaseT::*Handle2Value)() const> +class GenericCirculatorT : protected GenericCirculatorBaseT { + public: + typedef std::ptrdiff_t difference_type; + typedef ValueHandle value_type; + typedef const value_type& reference; + typedef const value_type* pointer; + typedef std::bidirectional_iterator_tag iterator_category; + + typedef typename GenericCirculatorBaseT::mesh_ptr mesh_ptr; + typedef typename GenericCirculatorBaseT::mesh_ref mesh_ref; + typedef GenericCirculator_ValueHandleFnsT GenericCirculator_ValueHandleFns; + + public: + GenericCirculatorT() {} + GenericCirculatorT(mesh_ref mesh, CenterEntityHandle start, bool end = false) : + GenericCirculatorBaseT(mesh, mesh.halfedge_handle(start), end) { + + GenericCirculator_ValueHandleFns::init(this->mesh_, this->heh_, this->start_, this->lap_counter_); + } + GenericCirculatorT(mesh_ref mesh, HalfedgeHandle heh, bool end = false) : + GenericCirculatorBaseT(mesh, heh, end) { + + GenericCirculator_ValueHandleFns::init(this->mesh_, this->heh_, this->start_, this->lap_counter_); + } + GenericCirculatorT(const GenericCirculatorT &rhs) : GenericCirculatorBaseT(rhs) {} + + GenericCirculatorT& operator++() { + assert(this->mesh_); + GenericCirculator_ValueHandleFns::increment(this->mesh_, this->heh_, this->start_, this->lap_counter_); + return *this; + } + GenericCirculatorT& operator--() { + assert(this->mesh_); + GenericCirculator_ValueHandleFns::decrement(this->mesh_, this->heh_, this->start_, this->lap_counter_); + return *this; + } + + /// Post-increment + GenericCirculatorT operator++(int) { + assert(this->mesh_); + GenericCirculatorT cpy(*this); + ++(*this); + return cpy; + } + + /// Post-decrement + GenericCirculatorT operator--(int) { + assert(this->mesh_); + GenericCirculatorT cpy(*this); + --(*this); + return cpy; + } + + /// Standard dereferencing operator. + value_type operator*() const { + return (this->*Handle2Value)(); + } + + /// Standard pointer operator. + value_type operator->() const { + return (this->*Handle2Value)(); + } + + GenericCirculatorT &operator=(const GenericCirculatorT &rhs) { + GenericCirculatorBaseT::operator=(rhs); + return *this; + }; + + bool operator==(const GenericCirculatorT &rhs) const { + return GenericCirculatorBaseT::operator==(rhs); + } + + bool operator!=(const GenericCirculatorT &rhs) const { + return GenericCirculatorBaseT::operator!=(rhs); + } + + bool is_valid() const { + return GenericCirculator_ValueHandleFns::is_valid(this->mesh_, this->heh_, this->start_, this->lap_counter_); + } + + DEPRECATED("current_halfedge_handle() is an implementation detail and should not be accessed from outside the iterator class.") + const HalfedgeHandle ¤t_halfedge_handle() const { + return this->heh_; + } + + DEPRECATED("Do not use this error prone implicit cast. Compare to end-iterator, instead.") + operator bool() const { + return is_valid(); + } + + /// Return the handle of the current target. + DEPRECATED("This function clutters your code. Use dereferencing operators -> and * instead.") + value_type handle() const { + return **this; + } + + /// Cast to the handle of the current target. + DEPRECATED("Implicit casts of iterators are unsafe. Use dereferencing operators -> and * instead.") + operator value_type() const { + return **this; + } +}; //== FORWARD DECLARATIONS ===================================================== - -template class VertexVertexIterT; -template class VertexIHalfedgeIterT; -template class VertexOHalfedgeIterT; -template class VertexEdgeIterT; -template class VertexFaceIterT; - -template class ConstVertexVertexIterT; -template class ConstVertexIHalfedgeIterT; -template class ConstVertexOHalfedgeIterT; -template class ConstVertexEdgeIterT; -template class ConstVertexFaceIterT; - template class FaceVertexIterT; template class FaceHalfedgeIterT; template class FaceEdgeIterT; @@ -87,1944 +307,6 @@ template class ConstFaceHalfedgeIterT; template class ConstFaceEdgeIterT; template class ConstFaceFaceIterT; - - -//== CLASS DEFINITION ========================================================= - - -/** \class VertexVertexIterT CirculatorsT.hh - Circulator. -*/ - -template -class VertexVertexIterT -{ - public: - - - //--- Typedefs --- - - typedef typename Mesh::HalfedgeHandle HalfedgeHandle; - - typedef typename Mesh::Vertex value_type; - typedef typename Mesh::VertexHandle value_handle; - -#if 0 - typedef std::bidirectional_iterator_tag iterator_category; - typedef std::ptrdiff_t difference_type; - typedef const Mesh& mesh_ref; - typedef const Mesh* mesh_ptr; - typedef const typename Mesh::Vertex& reference; - typedef const typename Mesh::Vertex* pointer; -#else - typedef std::bidirectional_iterator_tag iterator_category; - typedef std::ptrdiff_t difference_type; - typedef Mesh& mesh_ref; - typedef Mesh* mesh_ptr; - typedef typename Mesh::Vertex& reference; - typedef typename Mesh::Vertex* pointer; -#endif - - - - /// Default constructor - VertexVertexIterT() : mesh_(0), lap_counter_(0) {} - - - /// Construct with mesh and a typename Mesh::VertexHandle - VertexVertexIterT(mesh_ref _mesh, typename Mesh::VertexHandle _start, bool _end = false) : - mesh_(&_mesh), - start_(_mesh.halfedge_handle(_start)), - heh_(start_), - lap_counter_(_end) - { ; } - - - /// Construct with mesh and start halfedge - VertexVertexIterT(mesh_ref _mesh, HalfedgeHandle _heh, bool _end = false) : - mesh_(&_mesh), - start_(_heh), - heh_(_heh), - lap_counter_(_end) - { ; } - - - /// Copy constructor - VertexVertexIterT(const VertexVertexIterT& _rhs) : - mesh_(_rhs.mesh_), - start_(_rhs.start_), - heh_(_rhs.heh_), - lap_counter_(_rhs.lap_counter_) - { ; } - - - /// Assignment operator - VertexVertexIterT& operator=(const VertexVertexIterT& _rhs) - { - mesh_ = _rhs.mesh_; - start_ = _rhs.start_; - heh_ = _rhs.heh_; - lap_counter_ = _rhs.lap_counter_; - return *this; - } - - -#if 0 - /// construct from non-const circulator type - VertexVertexIterT(const VertexVertexIterT& _rhs) : - mesh_(_rhs.mesh_), - start_(_rhs.start_), - heh_(_rhs.heh_), - lap_counter_(_rhs.lap_counter_) - { ; } - - - /// assign from non-const circulator - VertexVertexIterT& operator=(const VertexVertexIterT& _rhs) - { - mesh_ = _rhs.mesh_; - start_ = _rhs.start_; - heh_ = _rhs.heh_; - lap_counter_ = _rhs.lap_counter_; - return *this; - } -#else - friend class ConstVertexVertexIterT; -#endif - - - /// Equal ? - bool operator==(const VertexVertexIterT& _rhs) const { - return ((mesh_ == _rhs.mesh_) && - (start_ == _rhs.start_) && - (heh_ == _rhs.heh_) && - (lap_counter_ == _rhs.lap_counter_)); - } - - - /// Not equal ? - bool operator!=(const VertexVertexIterT& _rhs) const { - return !operator==(_rhs); - } - - - /// Pre-Increment (next cw target) - VertexVertexIterT& operator++() { - assert(mesh_); - heh_=mesh_->cw_rotated_halfedge_handle(heh_); - if(heh_ == start_) lap_counter_++; - return *this; - } - - - /// Pre-Decrement (next ccw target) - VertexVertexIterT& operator--() { - assert(mesh_); - if(heh_ == start_) lap_counter_--; - 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_) || (lap_counter_ == 0)); - } - - -protected: - - mesh_ptr mesh_; - HalfedgeHandle start_, heh_; - int lap_counter_; -}; - - - -//== CLASS DEFINITION ========================================================= - - -/** \class ConstVertexVertexIterT CirculatorsT.hh - Circulator. -*/ - -template -class ConstVertexVertexIterT -{ - public: - - - //--- Typedefs --- - - typedef typename Mesh::HalfedgeHandle HalfedgeHandle; - - typedef typename Mesh::Vertex value_type; - typedef typename Mesh::VertexHandle value_handle; - -#if 1 - typedef std::bidirectional_iterator_tag iterator_category; - typedef std::ptrdiff_t difference_type; - typedef const Mesh& mesh_ref; - typedef const Mesh* mesh_ptr; - typedef const typename Mesh::Vertex& reference; - typedef const typename Mesh::Vertex* pointer; -#else - typedef std::bidirectional_iterator_tag iterator_category; - typedef std::ptrdiff_t difference_type; - typedef Mesh& mesh_ref; - typedef Mesh* mesh_ptr; - typedef typename Mesh::Vertex& reference; - typedef typename Mesh::Vertex* pointer; -#endif - - - - /// Default constructor - ConstVertexVertexIterT() : mesh_(0), lap_counter_(0) {} - - - /// Construct with mesh and a typename Mesh::VertexHandle - ConstVertexVertexIterT(mesh_ref _mesh, typename Mesh::VertexHandle _start, bool _end = false) : - mesh_(&_mesh), - start_(_mesh.halfedge_handle(_start)), - heh_(start_), - lap_counter_(_end) - { ; } - - - /// Construct with mesh and start halfedge - ConstVertexVertexIterT(mesh_ref _mesh, HalfedgeHandle _heh, bool _end = false) : - mesh_(&_mesh), - start_(_heh), - heh_(_heh), - lap_counter_(_end) - { ; } - - - /// Copy constructor - ConstVertexVertexIterT(const ConstVertexVertexIterT& _rhs) : - mesh_(_rhs.mesh_), - start_(_rhs.start_), - heh_(_rhs.heh_), - lap_counter_(_rhs.lap_counter_) - { ; } - - - /// Assignment operator - ConstVertexVertexIterT& operator=(const ConstVertexVertexIterT& _rhs) - { - mesh_ = _rhs.mesh_; - start_ = _rhs.start_; - heh_ = _rhs.heh_; - lap_counter_ = _rhs.lap_counter_; - return *this; - } - - -#if 1 - /// construct from non-const circulator type - ConstVertexVertexIterT(const VertexVertexIterT& _rhs) : - mesh_(_rhs.mesh_), - start_(_rhs.start_), - heh_(_rhs.heh_), - lap_counter_(_rhs.lap_counter_) - { ; } - - - /// assign from non-const circulator - ConstVertexVertexIterT& operator=(const VertexVertexIterT& _rhs) - { - mesh_ = _rhs.mesh_; - start_ = _rhs.start_; - heh_ = _rhs.heh_; - lap_counter_ = _rhs.lap_counter_; - return *this; - } -#else - friend class ConstVertexVertexIterT; -#endif - - - /// Equal ? - bool operator==(const ConstVertexVertexIterT& _rhs) const { - return ((mesh_ == _rhs.mesh_) && - (start_ == _rhs.start_) && - (heh_ == _rhs.heh_) && - (lap_counter_ == _rhs.lap_counter_)); - } - - - /// Not equal ? - bool operator!=(const ConstVertexVertexIterT& _rhs) const { - return !operator==(_rhs); - } - - - /// Pre-Increment (next cw target) - ConstVertexVertexIterT& operator++() { - assert(mesh_); - heh_=mesh_->cw_rotated_halfedge_handle(heh_); - if(heh_ == start_) lap_counter_++; - return *this; - } - - - /// Pre-Decrement (next ccw target) - ConstVertexVertexIterT& operator--() { - assert(mesh_); - if(heh_ == start_) lap_counter_--; - 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_) || (lap_counter_ == 0)); - } - - -protected: - - mesh_ptr mesh_; - HalfedgeHandle start_, heh_; - int lap_counter_; -}; - - - -//== CLASS DEFINITION ========================================================= - - -/** \class VertexOHalfedgeIterT CirculatorsT.hh - Circulator. -*/ - -template -class VertexOHalfedgeIterT -{ - public: - - - //--- Typedefs --- - - typedef typename Mesh::HalfedgeHandle HalfedgeHandle; - - typedef typename Mesh::Halfedge value_type; - typedef typename Mesh::HalfedgeHandle value_handle; - -#if 0 - typedef std::bidirectional_iterator_tag iterator_category; - typedef std::ptrdiff_t difference_type; - typedef const Mesh& mesh_ref; - typedef const Mesh* mesh_ptr; - typedef const typename Mesh::Halfedge& reference; - typedef const typename Mesh::Halfedge* pointer; -#else - typedef std::bidirectional_iterator_tag iterator_category; - typedef std::ptrdiff_t difference_type; - typedef Mesh& mesh_ref; - typedef Mesh* mesh_ptr; - typedef typename Mesh::Halfedge& reference; - typedef typename Mesh::Halfedge* pointer; -#endif - - - - /// Default constructor - VertexOHalfedgeIterT() : mesh_(0), lap_counter_(false) {} - - - /// Construct with mesh and a typename Mesh::VertexHandle - VertexOHalfedgeIterT(mesh_ref _mesh, typename Mesh::VertexHandle _start, bool _end = false) : - mesh_(&_mesh), - start_(_mesh.halfedge_handle(_start)), - heh_(start_), - lap_counter_(_end) - { ; } - - - /// Construct with mesh and start halfedge - VertexOHalfedgeIterT(mesh_ref _mesh, HalfedgeHandle _heh, bool _end = false) : - mesh_(&_mesh), - start_(_heh), - heh_(_heh), - lap_counter_(_end) - { ; } - - - /// Copy constructor - VertexOHalfedgeIterT(const VertexOHalfedgeIterT& _rhs) : - mesh_(_rhs.mesh_), - start_(_rhs.start_), - heh_(_rhs.heh_), - lap_counter_(_rhs.lap_counter_) - { ; } - - - /// Assignment operator - VertexOHalfedgeIterT& operator=(const VertexOHalfedgeIterT& _rhs) - { - mesh_ = _rhs.mesh_; - start_ = _rhs.start_; - heh_ = _rhs.heh_; - lap_counter_ = _rhs.lap_counter_; - return *this; - } - - -#if 0 - /// construct from non-const circulator type - VertexOHalfedgeIterT(const VertexOHalfedgeIterT& _rhs) : - mesh_(_rhs.mesh_), - start_(_rhs.start_), - heh_(_rhs.heh_), - lap_counter_(_rhs.lap_counter_) - { ; } - - - /// assign from non-const circulator - VertexOHalfedgeIterT& operator=(const VertexOHalfedgeIterT& _rhs) - { - mesh_ = _rhs.mesh_; - start_ = _rhs.start_; - heh_ = _rhs.heh_; - lap_counter_ = _rhs.lap_counter_; - return *this; - } -#else - friend class ConstVertexOHalfedgeIterT; -#endif - - - /// Equal ? - bool operator==(const VertexOHalfedgeIterT& _rhs) const { - return ((mesh_ == _rhs.mesh_) && - (start_ == _rhs.start_) && - (heh_ == _rhs.heh_) && - (lap_counter_ == _rhs.lap_counter_)); - } - - - /// Not equal ? - bool operator!=(const VertexOHalfedgeIterT& _rhs) const { - return !operator==(_rhs); - } - - - /// Pre-Increment (next cw target) - VertexOHalfedgeIterT& operator++() { - assert(mesh_); - heh_=mesh_->cw_rotated_halfedge_handle(heh_); - if(heh_ == start_) lap_counter_++; - return *this; - } - - - /// Pre-Decrement (next ccw target) - VertexOHalfedgeIterT& operator--() { - assert(mesh_); - if(heh_ == start_) lap_counter_--; - 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::HalfedgeHandle handle() const { - assert(mesh_); - return heh_; - } - - - /// Cast to the handle of the current target. - operator typename Mesh::HalfedgeHandle() const { - assert(mesh_); - return 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_) || (lap_counter_ == 0)); - } - - -protected: - - mesh_ptr mesh_; - HalfedgeHandle start_, heh_; - int lap_counter_; -}; - - - -//== CLASS DEFINITION ========================================================= - - -/** \class ConstVertexOHalfedgeIterT CirculatorsT.hh - Circulator. -*/ - -template -class ConstVertexOHalfedgeIterT -{ - public: - - - //--- Typedefs --- - - typedef typename Mesh::HalfedgeHandle HalfedgeHandle; - - typedef typename Mesh::Halfedge value_type; - typedef typename Mesh::HalfedgeHandle value_handle; - -#if 1 - typedef std::bidirectional_iterator_tag iterator_category; - typedef std::ptrdiff_t difference_type; - typedef const Mesh& mesh_ref; - typedef const Mesh* mesh_ptr; - typedef const typename Mesh::Halfedge& reference; - typedef const typename Mesh::Halfedge* pointer; -#else - typedef std::bidirectional_iterator_tag iterator_category; - typedef std::ptrdiff_t difference_type; - typedef Mesh& mesh_ref; - typedef Mesh* mesh_ptr; - typedef typename Mesh::Halfedge& reference; - typedef typename Mesh::Halfedge* pointer; -#endif - - - - /// Default constructor - ConstVertexOHalfedgeIterT() : mesh_(0), lap_counter_(false) {} - - - /// Construct with mesh and a typename Mesh::VertexHandle - ConstVertexOHalfedgeIterT(mesh_ref _mesh, typename Mesh::VertexHandle _start, bool _end = false) : - mesh_(&_mesh), - start_(_mesh.halfedge_handle(_start)), - heh_(start_), - lap_counter_(_end) - { ; } - - - /// Construct with mesh and start halfedge - ConstVertexOHalfedgeIterT(mesh_ref _mesh, HalfedgeHandle _heh, bool _end = false) : - mesh_(&_mesh), - start_(_heh), - heh_(_heh), - lap_counter_(_end) - { ; } - - - /// Copy constructor - ConstVertexOHalfedgeIterT(const ConstVertexOHalfedgeIterT& _rhs) : - mesh_(_rhs.mesh_), - start_(_rhs.start_), - heh_(_rhs.heh_), - lap_counter_(_rhs.lap_counter_) - { ; } - - - /// Assignment operator - ConstVertexOHalfedgeIterT& operator=(const ConstVertexOHalfedgeIterT& _rhs) - { - mesh_ = _rhs.mesh_; - start_ = _rhs.start_; - heh_ = _rhs.heh_; - lap_counter_ = _rhs.lap_counter_; - return *this; - } - - -#if 1 - /// construct from non-const circulator type - ConstVertexOHalfedgeIterT(const VertexOHalfedgeIterT& _rhs) : - mesh_(_rhs.mesh_), - start_(_rhs.start_), - heh_(_rhs.heh_), - lap_counter_(_rhs.lap_counter_) - { ; } - - - /// assign from non-const circulator - ConstVertexOHalfedgeIterT& operator=(const VertexOHalfedgeIterT& _rhs) - { - mesh_ = _rhs.mesh_; - start_ = _rhs.start_; - heh_ = _rhs.heh_; - lap_counter_ = _rhs.lap_counter_; - return *this; - } -#else - friend class ConstVertexOHalfedgeIterT; -#endif - - - /// Equal ? - bool operator==(const ConstVertexOHalfedgeIterT& _rhs) const { - return ((mesh_ == _rhs.mesh_) && - (start_ == _rhs.start_) && - (heh_ == _rhs.heh_) && - (lap_counter_ == _rhs.lap_counter_)); - } - - - /// Not equal ? - bool operator!=(const ConstVertexOHalfedgeIterT& _rhs) const { - return !operator==(_rhs); - } - - - /// Pre-Increment (next cw target) - ConstVertexOHalfedgeIterT& operator++() { - assert(mesh_); - heh_=mesh_->cw_rotated_halfedge_handle(heh_); - if(heh_ == start_) lap_counter_++; - return *this; - } - - - /// Pre-Decrement (next ccw target) - ConstVertexOHalfedgeIterT& operator--() { - assert(mesh_); - if(heh_ == start_) lap_counter_--; - 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::HalfedgeHandle handle() const { - assert(mesh_); - return heh_; - } - - - /// Cast to the handle of the current target. - operator typename Mesh::HalfedgeHandle() const { - assert(mesh_); - return 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_) || (lap_counter_ == 0)); - } - - -protected: - - mesh_ptr mesh_; - HalfedgeHandle start_, heh_; - int lap_counter_; -}; - - - -//== CLASS DEFINITION ========================================================= - - -/** \class VertexIHalfedgeIterT CirculatorsT.hh - Circulator. -*/ - -template -class VertexIHalfedgeIterT -{ - public: - - - //--- Typedefs --- - - typedef typename Mesh::HalfedgeHandle HalfedgeHandle; - - typedef typename Mesh::Halfedge value_type; - typedef typename Mesh::HalfedgeHandle value_handle; - -#if 0 - typedef std::bidirectional_iterator_tag iterator_category; - typedef std::ptrdiff_t difference_type; - typedef const Mesh& mesh_ref; - typedef const Mesh* mesh_ptr; - typedef const typename Mesh::Halfedge& reference; - typedef const typename Mesh::Halfedge* pointer; -#else - typedef std::bidirectional_iterator_tag iterator_category; - typedef std::ptrdiff_t difference_type; - typedef Mesh& mesh_ref; - typedef Mesh* mesh_ptr; - typedef typename Mesh::Halfedge& reference; - typedef typename Mesh::Halfedge* pointer; -#endif - - - - /// Default constructor - VertexIHalfedgeIterT() : mesh_(0), lap_counter_(false) {} - - - /// Construct with mesh and a typename Mesh::VertexHandle - VertexIHalfedgeIterT(mesh_ref _mesh, typename Mesh::VertexHandle _start, bool _end = false) : - mesh_(&_mesh), - start_(_mesh.halfedge_handle(_start)), - heh_(start_), - lap_counter_(_end) - { ; } - - - /// Construct with mesh and start halfedge - VertexIHalfedgeIterT(mesh_ref _mesh, HalfedgeHandle _heh, bool _end = false) : - mesh_(&_mesh), - start_(_heh), - heh_(_heh), - lap_counter_(_end) - { ; } - - - /// Copy constructor - VertexIHalfedgeIterT(const VertexIHalfedgeIterT& _rhs) : - mesh_(_rhs.mesh_), - start_(_rhs.start_), - heh_(_rhs.heh_), - lap_counter_(_rhs.lap_counter_) - { ; } - - - /// Assignment operator - VertexIHalfedgeIterT& operator=(const VertexIHalfedgeIterT& _rhs) - { - mesh_ = _rhs.mesh_; - start_ = _rhs.start_; - heh_ = _rhs.heh_; - lap_counter_ = _rhs.lap_counter_; - return *this; - } - - -#if 0 - /// construct from non-const circulator type - VertexIHalfedgeIterT(const VertexIHalfedgeIterT& _rhs) : - mesh_(_rhs.mesh_), - start_(_rhs.start_), - heh_(_rhs.heh_), - lap_counter_(_rhs.lap_counter_) - { ; } - - - /// assign from non-const circulator - VertexIHalfedgeIterT& operator=(const VertexIHalfedgeIterT& _rhs) - { - mesh_ = _rhs.mesh_; - start_ = _rhs.start_; - heh_ = _rhs.heh_; - lap_counter_ = _rhs.lap_counter_; - return *this; - } -#else - friend class ConstVertexIHalfedgeIterT; -#endif - - - /// Equal ? - bool operator==(const VertexIHalfedgeIterT& _rhs) const { - return ((mesh_ == _rhs.mesh_) && - (start_ == _rhs.start_) && - (heh_ == _rhs.heh_) && - (lap_counter_ == _rhs.lap_counter_)); - } - - - /// Not equal ? - bool operator!=(const VertexIHalfedgeIterT& _rhs) const { - return !operator==(_rhs); - } - - - /// Pre-Increment (next cw target) - VertexIHalfedgeIterT& operator++() { - assert(mesh_); - heh_=mesh_->cw_rotated_halfedge_handle(heh_); - if(heh_ == start_) lap_counter_++; - return *this; - } - - - /// Pre-Decrement (next ccw target) - VertexIHalfedgeIterT& operator--() { - assert(mesh_); - if(heh_ == start_) lap_counter_--; - 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::HalfedgeHandle handle() const { - assert(mesh_); - return mesh_->opposite_halfedge_handle(heh_); - } - - - /// Cast to the handle of the current target. - operator typename Mesh::HalfedgeHandle() const { - assert(mesh_); - return mesh_->opposite_halfedge_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_) || (lap_counter_ == 0)); - } - - -protected: - - mesh_ptr mesh_; - HalfedgeHandle start_, heh_; - int lap_counter_; -}; - - - -//== CLASS DEFINITION ========================================================= - - -/** \class ConstVertexIHalfedgeIterT CirculatorsT.hh - Circulator. -*/ - -template -class ConstVertexIHalfedgeIterT -{ - public: - - - //--- Typedefs --- - - typedef typename Mesh::HalfedgeHandle HalfedgeHandle; - - typedef typename Mesh::Halfedge value_type; - typedef typename Mesh::HalfedgeHandle value_handle; - -#if 1 - typedef std::bidirectional_iterator_tag iterator_category; - typedef std::ptrdiff_t difference_type; - typedef const Mesh& mesh_ref; - typedef const Mesh* mesh_ptr; - typedef const typename Mesh::Halfedge& reference; - typedef const typename Mesh::Halfedge* pointer; -#else - typedef std::bidirectional_iterator_tag iterator_category; - typedef std::ptrdiff_t difference_type; - typedef Mesh& mesh_ref; - typedef Mesh* mesh_ptr; - typedef typename Mesh::Halfedge& reference; - typedef typename Mesh::Halfedge* pointer; -#endif - - - - /// Default constructor - ConstVertexIHalfedgeIterT() : mesh_(0), lap_counter_(false) {} - - - /// Construct with mesh and a typename Mesh::VertexHandle - ConstVertexIHalfedgeIterT(mesh_ref _mesh, typename Mesh::VertexHandle _start, bool _end = false) : - mesh_(&_mesh), - start_(_mesh.halfedge_handle(_start)), - heh_(start_), - lap_counter_(_end) - { ; } - - - /// Construct with mesh and start halfedge - ConstVertexIHalfedgeIterT(mesh_ref _mesh, HalfedgeHandle _heh, bool _end = false) : - mesh_(&_mesh), - start_(_heh), - heh_(_heh), - lap_counter_(_end) - { ; } - - - /// Copy constructor - ConstVertexIHalfedgeIterT(const ConstVertexIHalfedgeIterT& _rhs) : - mesh_(_rhs.mesh_), - start_(_rhs.start_), - heh_(_rhs.heh_), - lap_counter_(_rhs.lap_counter_) - { ; } - - - /// Assignment operator - ConstVertexIHalfedgeIterT& operator=(const ConstVertexIHalfedgeIterT& _rhs) - { - mesh_ = _rhs.mesh_; - start_ = _rhs.start_; - heh_ = _rhs.heh_; - lap_counter_ = _rhs.lap_counter_; - return *this; - } - - -#if 1 - /// construct from non-const circulator type - ConstVertexIHalfedgeIterT(const VertexIHalfedgeIterT& _rhs) : - mesh_(_rhs.mesh_), - start_(_rhs.start_), - heh_(_rhs.heh_), - lap_counter_(_rhs.lap_counter_) - { ; } - - - /// assign from non-const circulator - ConstVertexIHalfedgeIterT& operator=(const VertexIHalfedgeIterT& _rhs) - { - mesh_ = _rhs.mesh_; - start_ = _rhs.start_; - heh_ = _rhs.heh_; - lap_counter_ = _rhs.lap_counter_; - return *this; - } -#else - friend class ConstVertexIHalfedgeIterT; -#endif - - - /// Equal ? - bool operator==(const ConstVertexIHalfedgeIterT& _rhs) const { - return ((mesh_ == _rhs.mesh_) && - (start_ == _rhs.start_) && - (heh_ == _rhs.heh_) && - (lap_counter_ == _rhs.lap_counter_)); - } - - - /// Not equal ? - bool operator!=(const ConstVertexIHalfedgeIterT& _rhs) const { - return !operator==(_rhs); - } - - - /// Pre-Increment (next cw target) - ConstVertexIHalfedgeIterT& operator++() { - assert(mesh_); - heh_=mesh_->cw_rotated_halfedge_handle(heh_); - if(heh_ == start_) lap_counter_++; - return *this; - } - - - /// Pre-Decrement (next ccw target) - ConstVertexIHalfedgeIterT& operator--() { - assert(mesh_); - if(heh_ == start_) lap_counter_--; - 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::HalfedgeHandle handle() const { - assert(mesh_); - return mesh_->opposite_halfedge_handle(heh_); - } - - - /// Cast to the handle of the current target. - operator typename Mesh::HalfedgeHandle() const { - assert(mesh_); - return mesh_->opposite_halfedge_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_) || (lap_counter_ == 0)); - } - - -protected: - - mesh_ptr mesh_; - HalfedgeHandle start_, heh_; - int lap_counter_; -}; - - - -//== CLASS DEFINITION ========================================================= - - -/** \class VertexEdgeIterT CirculatorsT.hh - Circulator. -*/ - -template -class VertexEdgeIterT -{ - public: - - - //--- Typedefs --- - - typedef typename Mesh::HalfedgeHandle HalfedgeHandle; - - typedef typename Mesh::Edge value_type; - typedef typename Mesh::EdgeHandle value_handle; - -#if 0 - typedef std::bidirectional_iterator_tag iterator_category; - typedef std::ptrdiff_t difference_type; - typedef const Mesh& mesh_ref; - typedef const Mesh* mesh_ptr; - typedef const typename Mesh::Edge& reference; - typedef const typename Mesh::Edge* pointer; -#else - typedef std::bidirectional_iterator_tag iterator_category; - typedef std::ptrdiff_t difference_type; - typedef Mesh& mesh_ref; - typedef Mesh* mesh_ptr; - typedef typename Mesh::Edge& reference; - typedef typename Mesh::Edge* pointer; -#endif - - - - /// Default constructor - VertexEdgeIterT() : mesh_(0), lap_counter_(false) {} - - - /// Construct with mesh and a typename Mesh::VertexHandle - VertexEdgeIterT(mesh_ref _mesh, typename Mesh::VertexHandle _start, bool _end = false) : - mesh_(&_mesh), - start_(_mesh.halfedge_handle(_start)), - heh_(start_), - lap_counter_(_end) - { ; } - - - /// Construct with mesh and start halfedge - VertexEdgeIterT(mesh_ref _mesh, HalfedgeHandle _heh, bool _end = false) : - mesh_(&_mesh), - start_(_heh), - heh_(_heh), - lap_counter_(_end) - { ; } - - - /// Copy constructor - VertexEdgeIterT(const VertexEdgeIterT& _rhs) : - mesh_(_rhs.mesh_), - start_(_rhs.start_), - heh_(_rhs.heh_), - lap_counter_(_rhs.lap_counter_) - { ; } - - - /// Assignment operator - VertexEdgeIterT& operator=(const VertexEdgeIterT& _rhs) - { - mesh_ = _rhs.mesh_; - start_ = _rhs.start_; - heh_ = _rhs.heh_; - lap_counter_ = _rhs.lap_counter_; - return *this; - } - - -#if 0 - /// construct from non-const circulator type - VertexEdgeIterT(const VertexEdgeIterT& _rhs) : - mesh_(_rhs.mesh_), - start_(_rhs.start_), - heh_(_rhs.heh_), - lap_counter_(_rhs.lap_counter_) - { ; } - - - /// assign from non-const circulator - VertexEdgeIterT& operator=(const VertexEdgeIterT& _rhs) - { - mesh_ = _rhs.mesh_; - start_ = _rhs.start_; - heh_ = _rhs.heh_; - lap_counter_ = _rhs.lap_counter_; - return *this; - } -#else - friend class ConstVertexEdgeIterT; -#endif - - - /// Equal ? - bool operator==(const VertexEdgeIterT& _rhs) const { - return ((mesh_ == _rhs.mesh_) && - (start_ == _rhs.start_) && - (heh_ == _rhs.heh_) && - (lap_counter_ == _rhs.lap_counter_)); - } - - - /// Not equal ? - bool operator!=(const VertexEdgeIterT& _rhs) const { - return !operator==(_rhs); - } - - - /// Pre-Increment (next cw target) - VertexEdgeIterT& operator++() { - assert(mesh_); - heh_=mesh_->cw_rotated_halfedge_handle(heh_); - if(heh_ == start_) lap_counter_++; - return *this; - } - - - /// Pre-Decrement (next ccw target) - VertexEdgeIterT& operator--() { - assert(mesh_); - if(heh_ == start_) lap_counter_--; - 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::EdgeHandle handle() const { - assert(mesh_); - return mesh_->edge_handle(heh_); - } - - - /// Cast to the handle of the current target. - operator typename Mesh::EdgeHandle() const { - assert(mesh_); - return mesh_->edge_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_) || (lap_counter_ == 0)); - } - - -protected: - - mesh_ptr mesh_; - HalfedgeHandle start_, heh_; - int lap_counter_; -}; - - - -//== CLASS DEFINITION ========================================================= - - -/** \class ConstVertexEdgeIterT CirculatorsT.hh - Circulator. -*/ - -template -class ConstVertexEdgeIterT -{ - public: - - - //--- Typedefs --- - - typedef typename Mesh::HalfedgeHandle HalfedgeHandle; - - typedef typename Mesh::Edge value_type; - typedef typename Mesh::EdgeHandle value_handle; - -#if 1 - typedef std::bidirectional_iterator_tag iterator_category; - typedef std::ptrdiff_t difference_type; - typedef const Mesh& mesh_ref; - typedef const Mesh* mesh_ptr; - typedef const typename Mesh::Edge& reference; - typedef const typename Mesh::Edge* pointer; -#else - typedef std::bidirectional_iterator_tag iterator_category; - typedef std::ptrdiff_t difference_type; - typedef Mesh& mesh_ref; - typedef Mesh* mesh_ptr; - typedef typename Mesh::Edge& reference; - typedef typename Mesh::Edge* pointer; -#endif - - - - /// Default constructor - ConstVertexEdgeIterT() : mesh_(0), lap_counter_(false) {} - - - /// Construct with mesh and a typename Mesh::VertexHandle - ConstVertexEdgeIterT(mesh_ref _mesh, typename Mesh::VertexHandle _start, bool _end = false) : - mesh_(&_mesh), - start_(_mesh.halfedge_handle(_start)), - heh_(start_), - lap_counter_(_end) - { ; } - - - /// Construct with mesh and start halfedge - ConstVertexEdgeIterT(mesh_ref _mesh, HalfedgeHandle _heh, bool _end = false) : - mesh_(&_mesh), - start_(_heh), - heh_(_heh), - lap_counter_(_end) - { ; } - - - /// Copy constructor - ConstVertexEdgeIterT(const ConstVertexEdgeIterT& _rhs) : - mesh_(_rhs.mesh_), - start_(_rhs.start_), - heh_(_rhs.heh_), - lap_counter_(_rhs.lap_counter_) - { ; } - - - /// Assignment operator - ConstVertexEdgeIterT& operator=(const ConstVertexEdgeIterT& _rhs) - { - mesh_ = _rhs.mesh_; - start_ = _rhs.start_; - heh_ = _rhs.heh_; - lap_counter_ = _rhs.lap_counter_; - return *this; - } - - -#if 1 - /// construct from non-const circulator type - ConstVertexEdgeIterT(const VertexEdgeIterT& _rhs) : - mesh_(_rhs.mesh_), - start_(_rhs.start_), - heh_(_rhs.heh_), - lap_counter_(_rhs.lap_counter_) - { ; } - - - /// assign from non-const circulator - ConstVertexEdgeIterT& operator=(const VertexEdgeIterT& _rhs) - { - mesh_ = _rhs.mesh_; - start_ = _rhs.start_; - heh_ = _rhs.heh_; - lap_counter_ = _rhs.lap_counter_; - return *this; - } -#else - friend class ConstVertexEdgeIterT; -#endif - - - /// Equal ? - bool operator==(const ConstVertexEdgeIterT& _rhs) const { - return ((mesh_ == _rhs.mesh_) && - (start_ == _rhs.start_) && - (heh_ == _rhs.heh_) && - (lap_counter_ == _rhs.lap_counter_)); - } - - - /// Not equal ? - bool operator!=(const ConstVertexEdgeIterT& _rhs) const { - return !operator==(_rhs); - } - - - /// Pre-Increment (next cw target) - ConstVertexEdgeIterT& operator++() { - assert(mesh_); - heh_=mesh_->cw_rotated_halfedge_handle(heh_); - if(heh_ == start_) lap_counter_++; - return *this; - } - - - /// Pre-Decrement (next ccw target) - ConstVertexEdgeIterT& operator--() { - assert(mesh_); - if(heh_ == start_) lap_counter_--; - 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::EdgeHandle handle() const { - assert(mesh_); - return mesh_->edge_handle(heh_); - } - - - /// Cast to the handle of the current target. - operator typename Mesh::EdgeHandle() const { - assert(mesh_); - return mesh_->edge_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_) || (lap_counter_ == 0)); - } - - -protected: - - mesh_ptr mesh_; - HalfedgeHandle start_, heh_; - int lap_counter_; -}; - - - -//== CLASS DEFINITION ========================================================= - - -/** \class VertexFaceIterT CirculatorsT.hh - Circulator. -*/ - -template -class VertexFaceIterT -{ - public: - - - //--- Typedefs --- - - typedef typename Mesh::HalfedgeHandle HalfedgeHandle; - - typedef typename Mesh::Face value_type; - typedef typename Mesh::FaceHandle value_handle; - -#if 0 - typedef std::bidirectional_iterator_tag iterator_category; - typedef std::ptrdiff_t difference_type; - typedef const Mesh& mesh_ref; - typedef const Mesh* mesh_ptr; - typedef const typename Mesh::Face& reference; - typedef const typename Mesh::Face* pointer; -#else - typedef std::bidirectional_iterator_tag iterator_category; - typedef std::ptrdiff_t difference_type; - typedef Mesh& mesh_ref; - typedef Mesh* mesh_ptr; - typedef typename Mesh::Face& reference; - typedef typename Mesh::Face* pointer; -#endif - - - - /// Default constructor - VertexFaceIterT() : mesh_(0), lap_counter_(false) {} - - - /// Construct with mesh and a typename Mesh::VertexHandle - VertexFaceIterT(mesh_ref _mesh, typename Mesh::VertexHandle _start, bool _end = false) : - mesh_(&_mesh), - start_(_mesh.halfedge_handle(_start)), - heh_(start_), - lap_counter_(_end) - { if (heh_.is_valid() && !handle().is_valid() && !_end) operator++();; } - - - /// Construct with mesh and start halfedge - VertexFaceIterT(mesh_ref _mesh, HalfedgeHandle _heh, bool _end = false) : - mesh_(&_mesh), - start_(_heh), - heh_(_heh), - lap_counter_(_end) - { if (heh_.is_valid() && !handle().is_valid()) operator++();; } - - - /// Copy constructor - VertexFaceIterT(const VertexFaceIterT& _rhs) : - mesh_(_rhs.mesh_), - start_(_rhs.start_), - heh_(_rhs.heh_), - lap_counter_(_rhs.lap_counter_) - { if (heh_.is_valid() && !handle().is_valid()) operator++();; } - - - /// Assignment operator - VertexFaceIterT& operator=(const VertexFaceIterT& _rhs) - { - mesh_ = _rhs.mesh_; - start_ = _rhs.start_; - heh_ = _rhs.heh_; - lap_counter_ = _rhs.lap_counter_; - return *this; - } - - -#if 0 - /// construct from non-const circulator type - VertexFaceIterT(const VertexFaceIterT& _rhs) : - mesh_(_rhs.mesh_), - start_(_rhs.start_), - heh_(_rhs.heh_), - lap_counter_(_rhs.lap_counter_) - { if (heh_.is_valid() && !handle().is_valid()) operator++();; } - - - /// assign from non-const circulator - VertexFaceIterT& operator=(const VertexFaceIterT& _rhs) - { - mesh_ = _rhs.mesh_; - start_ = _rhs.start_; - heh_ = _rhs.heh_; - lap_counter_ = _rhs.lap_counter_; - return *this; - } -#else - friend class ConstVertexFaceIterT; -#endif - - - /// Equal ? - bool operator==(const VertexFaceIterT& _rhs) const { - return ((mesh_ == _rhs.mesh_) && - (start_ == _rhs.start_) && - (heh_ == _rhs.heh_) && - (lap_counter_ == _rhs.lap_counter_)); - } - - - /// Not equal ? - bool operator!=(const VertexFaceIterT& _rhs) const { - return !operator==(_rhs); - } - - - /// Pre-Increment (next cw target) - VertexFaceIterT& operator++() { - assert(mesh_); - do { heh_=mesh_->cw_rotated_halfedge_handle(heh_); if(heh_ == start_) lap_counter_++; } while ((*this) && (!handle().is_valid()));; - return *this; - } - - - /// Pre-Decrement (next ccw target) - VertexFaceIterT& operator--() { - assert(mesh_); - do { if(heh_ == start_) lap_counter_--; heh_=mesh_->ccw_rotated_halfedge_handle(heh_); } while ((*this) && (!handle().is_valid()));; - 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::FaceHandle handle() const { - assert(mesh_); - return mesh_->face_handle(heh_); - } - - - /// Cast to the handle of the current target. - operator typename Mesh::FaceHandle() const { - assert(mesh_); - return mesh_->face_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_) || (lap_counter_ == 0)); - } - - -protected: - - mesh_ptr mesh_; - HalfedgeHandle start_, heh_; - int lap_counter_; -}; - - - -//== CLASS DEFINITION ========================================================= - - -/** \class ConstVertexFaceIterT CirculatorsT.hh - Circulator. -*/ - -template -class ConstVertexFaceIterT -{ - public: - - - //--- Typedefs --- - - typedef typename Mesh::HalfedgeHandle HalfedgeHandle; - - typedef typename Mesh::Face value_type; - typedef typename Mesh::FaceHandle value_handle; - -#if 1 - typedef std::bidirectional_iterator_tag iterator_category; - typedef std::ptrdiff_t difference_type; - typedef const Mesh& mesh_ref; - typedef const Mesh* mesh_ptr; - typedef const typename Mesh::Face& reference; - typedef const typename Mesh::Face* pointer; -#else - typedef std::bidirectional_iterator_tag iterator_category; - typedef std::ptrdiff_t difference_type; - typedef Mesh& mesh_ref; - typedef Mesh* mesh_ptr; - typedef typename Mesh::Face& reference; - typedef typename Mesh::Face* pointer; -#endif - - - - /// Default constructor - ConstVertexFaceIterT() : mesh_(0), lap_counter_(false) {} - - - /// Construct with mesh and a typename Mesh::VertexHandle - ConstVertexFaceIterT(mesh_ref _mesh, typename Mesh::VertexHandle _start, bool _end = false) : - mesh_(&_mesh), - start_(_mesh.halfedge_handle(_start)), - heh_(start_), - lap_counter_(_end) - { if (heh_.is_valid() && !handle().is_valid() && !_end) operator++();; } - - - /// Construct with mesh and start halfedge - ConstVertexFaceIterT(mesh_ref _mesh, HalfedgeHandle _heh, bool _end = false) : - mesh_(&_mesh), - start_(_heh), - heh_(_heh), - lap_counter_(_end) - { if (heh_.is_valid() && !handle().is_valid()) operator++();; } - - - /// Copy constructor - ConstVertexFaceIterT(const ConstVertexFaceIterT& _rhs) : - mesh_(_rhs.mesh_), - start_(_rhs.start_), - heh_(_rhs.heh_), - lap_counter_(_rhs.lap_counter_) - { if (heh_.is_valid() && !handle().is_valid()) operator++();; } - - - /// Assignment operator - ConstVertexFaceIterT& operator=(const ConstVertexFaceIterT& _rhs) - { - mesh_ = _rhs.mesh_; - start_ = _rhs.start_; - heh_ = _rhs.heh_; - lap_counter_ = _rhs.lap_counter_; - return *this; - } - - -#if 1 - /// construct from non-const circulator type - ConstVertexFaceIterT(const VertexFaceIterT& _rhs) : - mesh_(_rhs.mesh_), - start_(_rhs.start_), - heh_(_rhs.heh_), - lap_counter_(_rhs.lap_counter_) - { if (heh_.is_valid() && !handle().is_valid()) operator++();; } - - - /// assign from non-const circulator - ConstVertexFaceIterT& operator=(const VertexFaceIterT& _rhs) - { - mesh_ = _rhs.mesh_; - start_ = _rhs.start_; - heh_ = _rhs.heh_; - lap_counter_ = _rhs.lap_counter_; - return *this; - } -#else - friend class ConstVertexFaceIterT; -#endif - - - /// Equal ? - bool operator==(const ConstVertexFaceIterT& _rhs) const { - return ((mesh_ == _rhs.mesh_) && - (start_ == _rhs.start_) && - (heh_ == _rhs.heh_) && - (lap_counter_ == _rhs.lap_counter_)); - } - - - /// Not equal ? - bool operator!=(const ConstVertexFaceIterT& _rhs) const { - return !operator==(_rhs); - } - - - /// Pre-Increment (next cw target) - ConstVertexFaceIterT& operator++() { - assert(mesh_); - do { heh_=mesh_->cw_rotated_halfedge_handle(heh_); if(heh_ == start_) lap_counter_++; } while ((*this) && (!handle().is_valid()));; - return *this; - } - - - /// Pre-Decrement (next ccw target) - ConstVertexFaceIterT& operator--() { - assert(mesh_); - do { if(heh_ == start_) lap_counter_--; heh_=mesh_->ccw_rotated_halfedge_handle(heh_); } while ((*this) && (!handle().is_valid()));; - 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::FaceHandle handle() const { - assert(mesh_); - return mesh_->face_handle(heh_); - } - - - /// Cast to the handle of the current target. - operator typename Mesh::FaceHandle() const { - assert(mesh_); - return mesh_->face_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_) || (lap_counter_ == 0)); - } - - -protected: - - mesh_ptr mesh_; - HalfedgeHandle start_, heh_; - int lap_counter_; -}; - - - //== CLASS DEFINITION ========================================================= diff --git a/src/OpenMesh/Core/Mesh/IteratorsT.hh b/src/OpenMesh/Core/Mesh/IteratorsT.hh index 9bfaf9fc..db09fde3 100644 --- a/src/OpenMesh/Core/Mesh/IteratorsT.hh +++ b/src/OpenMesh/Core/Mesh/IteratorsT.hh @@ -117,11 +117,13 @@ class GenericIteratorT { } /// Get the handle of the item the iterator refers to. + DEPRECATED("This function clutters your code. Use dereferencing operators -> and * instead.") value_handle handle() const { return hnd_; } /// Cast to the handle of the item the iterator refers to. + DEPRECATED("Implicit casts of iterators are unsafe. Use dereferencing operators -> and * instead.") operator value_handle() const { return hnd_; } @@ -144,6 +146,13 @@ class GenericIteratorT { return *this; } + /// Standard post-increment operator + GenericIteratorT operator++(int) { + GenericIteratorT cpy(*this); + ++(*this); + return cpy; + } + /// Standard pre-decrement operator GenericIteratorT& operator--() { hnd_.__decrement(); @@ -152,6 +161,13 @@ class GenericIteratorT { return *this; } + /// Standard post-decrement operator + GenericIteratorT operator--(int) { + GenericIteratorT cpy(*this); + --(*this); + return cpy; + } + /// Turn on skipping: automatically skip deleted/hidden elements void enable_skipping() { if (mesh_ && (mesh_->*PrimitiveStatusMember)()) { diff --git a/src/OpenMesh/Core/Mesh/PolyConnectivity.hh b/src/OpenMesh/Core/Mesh/PolyConnectivity.hh index 57503157..54e61d8d 100644 --- a/src/OpenMesh/Core/Mesh/PolyConnectivity.hh +++ b/src/OpenMesh/Core/Mesh/PolyConnectivity.hh @@ -95,21 +95,37 @@ public: */ //@{ /// Circulator - typedef Iterators::VertexVertexIterT VertexVertexIter; - typedef Iterators::VertexOHalfedgeIterT VertexOHalfedgeIter; - typedef Iterators::VertexIHalfedgeIterT VertexIHalfedgeIter; - typedef Iterators::VertexEdgeIterT VertexEdgeIter; - typedef Iterators::VertexFaceIterT VertexFaceIter; + typedef Iterators::GenericCirculatorT::toVertexHandle> + VertexVertexIter; + + typedef Iterators::GenericCirculatorT::toHalfedgeHandle> + VertexOHalfedgeIter; + + typedef Iterators::GenericCirculatorT::toOppositeHalfedgeHandle> + VertexIHalfedgeIter; + + typedef Iterators::GenericCirculatorT::toFaceHandle> + VertexFaceIter; + + typedef Iterators::GenericCirculatorT::toEdgeHandle> + VertexEdgeIter; + + typedef VertexVertexIter ConstVertexVertexIter; + typedef VertexOHalfedgeIter ConstVertexOHalfedgeIter; + typedef VertexIHalfedgeIter ConstVertexIHalfedgeIter; + typedef VertexFaceIter ConstVertexFaceIter; + typedef VertexEdgeIter ConstVertexEdgeIter; + typedef Iterators::FaceVertexIterT FaceVertexIter; typedef Iterators::FaceHalfedgeIterT FaceHalfedgeIter; typedef Iterators::FaceEdgeIterT FaceEdgeIter; typedef Iterators::FaceFaceIterT FaceFaceIter; - typedef Iterators::ConstVertexVertexIterT ConstVertexVertexIter; - typedef Iterators::ConstVertexOHalfedgeIterT ConstVertexOHalfedgeIter; - typedef Iterators::ConstVertexIHalfedgeIterT ConstVertexIHalfedgeIter; - typedef Iterators::ConstVertexEdgeIterT ConstVertexEdgeIter; - typedef Iterators::ConstVertexFaceIterT ConstVertexFaceIter; typedef Iterators::ConstFaceVertexIterT ConstFaceVertexIter; typedef Iterators::ConstFaceHalfedgeIterT ConstFaceHalfedgeIter; typedef Iterators::ConstFaceEdgeIterT ConstFaceEdgeIter; diff --git a/src/OpenMesh/Core/System/config.h b/src/OpenMesh/Core/System/config.h index 364dbf0f..d4523fd5 100644 --- a/src/OpenMesh/Core/System/config.h +++ b/src/OpenMesh/Core/System/config.h @@ -77,6 +77,14 @@ # endif #endif +#if defined(_MSCVER) +#define DEPRECATED(msg) __declspec(deprecated(msg)) +#elif defined(__GNUC__) or defined(__clang__) +#define DEPRECATED(msg) __attribute__ ((deprecated(msg))) +#else +#define DEPRECATED(msg) +#endif + typedef unsigned int uint; //============================================================================= #endif // OPENMESH_CONFIG_H defined