diff --git a/src/OpenMesh/Core/Mesh/CirculatorsT.hh b/src/OpenMesh/Core/Mesh/CirculatorsT.hh index 6e6e31e5..750528ee 100644 --- a/src/OpenMesh/Core/Mesh/CirculatorsT.hh +++ b/src/OpenMesh/Core/Mesh/CirculatorsT.hh @@ -94,6 +94,28 @@ class GenericCirculator_CenterEntityFnsT { } }; +template +class GenericCirculator_DereferenciabilityCheckT { + public: + //inline static bool isDereferenciable(const Mesh *mesh, const typename Mesh::HalfedgeHandle &heh, const typename Mesh::HalfedgeHandle &start, const int &lap_counter); +}; + +template +class GenericCirculator_DereferenciabilityCheckT { + public: + inline static bool isDereferenciable(const Mesh *mesh, const typename Mesh::HalfedgeHandle &heh, const typename Mesh::HalfedgeHandle &start, const int &lap_counter) { + return mesh->face_handle(mesh->opposite_halfedge_handle(heh)).is_valid(); + } +}; + +template +class GenericCirculator_DereferenciabilityCheckT { + public: + inline static bool isDereferenciable(const Mesh *mesh, const typename Mesh::HalfedgeHandle &heh, const typename Mesh::HalfedgeHandle &start, const int &lap_counter) { + return mesh->face_handle(heh).is_valid(); + } +}; + template class GenericCirculator_ValueHandleFnsT { public: @@ -112,22 +134,24 @@ class GenericCirculator_ValueHandleFnsT { template class GenericCirculator_ValueHandleFnsT { public: + typedef GenericCirculator_DereferenciabilityCheckT GenericCirculator_DereferenciabilityCheck; + 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()) + if (heh.is_valid() && !GenericCirculator_DereferenciabilityCheck::isDereferenciable(mesh, heh, start, lap_counter) && lap_counter == 0) 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()); + } while (is_valid(mesh, heh, start, lap_counter) && !GenericCirculator_DereferenciabilityCheck::isDereferenciable(mesh, heh, start, lap_counter)); } 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()); + } while (is_valid(mesh, heh, start, lap_counter) && !GenericCirculator_DereferenciabilityCheck::isDereferenciable(mesh, heh, start, lap_counter)); } }; @@ -150,6 +174,10 @@ class GenericCirculatorBaseT { return mesh_->face_handle(heh_); } + inline typename Mesh::FaceHandle toOppositeFaceHandle() const { + return mesh_->face_handle(toOppositeHalfedgeHandle()); + } + inline typename Mesh::EdgeHandle toEdgeHandle() const { return mesh_->edge_handle(heh_); } @@ -189,8 +217,6 @@ class GenericCirculatorBaseT { }; template::*Increment)(), -// void (GenericCirculatorBaseT::*Decrement)(), ValueHandle (GenericCirculatorBaseT::*Handle2Value)() const> class GenericCirculatorT : protected GenericCirculatorBaseT { public: @@ -247,12 +273,19 @@ class GenericCirculatorT : protected GenericCirculatorBaseT { /// Standard dereferencing operator. value_type operator*() const { +#ifndef NDEBUG + assert(this->heh_.is_valid()); + value_type res = (this->*Handle2Value)(); + assert(res.is_valid()); + return res; +#else return (this->*Handle2Value)(); +#endif } /// Standard pointer operator. value_type operator->() const { - return (this->*Handle2Value)(); + return **this; } GenericCirculatorT &operator=(const GenericCirculatorT &rhs) { @@ -277,7 +310,7 @@ class GenericCirculatorT : protected GenericCirculatorBaseT { return this->heh_; } - DEPRECATED("Do not use this error prone implicit cast. Compare to end-iterator, instead.") + DEPRECATED("Do not use this error prone implicit cast. Compare to end-iterator or use is_valid(), instead.") operator bool() const { return is_valid(); } @@ -295,1569 +328,7 @@ class GenericCirculatorT : protected GenericCirculatorBaseT { } }; -//== FORWARD DECLARATIONS ===================================================== - -template class FaceVertexIterT; -template class FaceHalfedgeIterT; -template class FaceEdgeIterT; -template class FaceFaceIterT; - -template class ConstFaceVertexIterT; -template class ConstFaceHalfedgeIterT; -template class ConstFaceEdgeIterT; -template class ConstFaceFaceIterT; - -//== CLASS DEFINITION ========================================================= - - -/** \class FaceVertexIterT CirculatorsT.hh - Circulator. -*/ - -template -class FaceVertexIterT -{ - 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 - FaceVertexIterT() : mesh_(0), lap_counter_(false) {} - - - /// Construct with mesh and a typename Mesh::FaceHandle - FaceVertexIterT(mesh_ref _mesh, typename Mesh::FaceHandle _start, bool _end = false) : - mesh_(&_mesh), - start_(_mesh.halfedge_handle(_start)), - heh_(start_), - lap_counter_(_end) - { ; } - - - /// Construct with mesh and start halfedge - FaceVertexIterT(mesh_ref _mesh, HalfedgeHandle _heh, bool _end = false) : - mesh_(&_mesh), - start_(_heh), - heh_(_heh), - lap_counter_(_end) - { ; } - - - /// Copy constructor - FaceVertexIterT(const FaceVertexIterT& _rhs) : - mesh_(_rhs.mesh_), - start_(_rhs.start_), - heh_(_rhs.heh_), - lap_counter_(_rhs.lap_counter_) - { ; } - - - /// Assignment operator - FaceVertexIterT& operator=(const FaceVertexIterT& _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 - FaceVertexIterT(const FaceVertexIterT& _rhs) : - mesh_(_rhs.mesh_), - start_(_rhs.start_), - heh_(_rhs.heh_), - lap_counter_(_rhs.lap_counter_) - { ; } - - - /// assign from non-const circulator - FaceVertexIterT& operator=(const FaceVertexIterT& _rhs) - { - mesh_ = _rhs.mesh_; - start_ = _rhs.start_; - heh_ = _rhs.heh_; - lap_counter_ = _rhs.lap_counter_; - return *this; - } -#else - friend class ConstFaceVertexIterT; -#endif - - - /// Equal ? - bool operator==(const FaceVertexIterT& _rhs) const { - return ((mesh_ == _rhs.mesh_) && - (start_ == _rhs.start_) && - (heh_ == _rhs.heh_) && - (lap_counter_ == _rhs.lap_counter_)); - } - - - /// Not equal ? - bool operator!=(const FaceVertexIterT& _rhs) const { - return !operator==(_rhs); - } - - - /// Pre-Increment (next cw target) - FaceVertexIterT& operator++() { - assert(mesh_); - heh_=mesh_->next_halfedge_handle(heh_); - if(heh_ == start_) lap_counter_++; - return *this; - } - - - /// Pre-Decrement (next ccw target) - FaceVertexIterT& operator--() { - assert(mesh_); - if(heh_ == start_) lap_counter_--; - heh_=mesh_->prev_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 ConstFaceVertexIterT CirculatorsT.hh - Circulator. -*/ - -template -class ConstFaceVertexIterT -{ - 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 - ConstFaceVertexIterT() : mesh_(0), lap_counter_(false) {} - - - /// Construct with mesh and a typename Mesh::FaceHandle - ConstFaceVertexIterT(mesh_ref _mesh, typename Mesh::FaceHandle _start, bool _end = false) : - mesh_(&_mesh), - start_(_mesh.halfedge_handle(_start)), - heh_(start_), - lap_counter_(_end) - { ; } - - - /// Construct with mesh and start halfedge - ConstFaceVertexIterT(mesh_ref _mesh, HalfedgeHandle _heh, bool _end = false) : - mesh_(&_mesh), - start_(_heh), - heh_(_heh), - lap_counter_(_end) - { ; } - - - /// Copy constructor - ConstFaceVertexIterT(const ConstFaceVertexIterT& _rhs) : - mesh_(_rhs.mesh_), - start_(_rhs.start_), - heh_(_rhs.heh_), - lap_counter_(_rhs.lap_counter_) - { ; } - - - /// Assignment operator - ConstFaceVertexIterT& operator=(const ConstFaceVertexIterT& _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 - ConstFaceVertexIterT(const FaceVertexIterT& _rhs) : - mesh_(_rhs.mesh_), - start_(_rhs.start_), - heh_(_rhs.heh_), - lap_counter_(_rhs.lap_counter_) - { ; } - - - /// assign from non-const circulator - ConstFaceVertexIterT& operator=(const FaceVertexIterT& _rhs) - { - mesh_ = _rhs.mesh_; - start_ = _rhs.start_; - heh_ = _rhs.heh_; - lap_counter_ = _rhs.lap_counter_; - return *this; - } -#else - friend class ConstFaceVertexIterT; -#endif - - - /// Equal ? - bool operator==(const ConstFaceVertexIterT& _rhs) const { - return ((mesh_ == _rhs.mesh_) && - (start_ == _rhs.start_) && - (heh_ == _rhs.heh_) && - (lap_counter_ == _rhs.lap_counter_)); - } - - - /// Not equal ? - bool operator!=(const ConstFaceVertexIterT& _rhs) const { - return !operator==(_rhs); - } - - - /// Pre-Increment (next cw target) - ConstFaceVertexIterT& operator++() { - assert(mesh_); - heh_=mesh_->next_halfedge_handle(heh_); - if(heh_ == start_) lap_counter_++; - return *this; - } - - - /// Pre-Decrement (next ccw target) - ConstFaceVertexIterT& operator--() { - assert(mesh_); - if(heh_ == start_) lap_counter_--; - heh_=mesh_->prev_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 FaceHalfedgeIterT CirculatorsT.hh - Circulator. -*/ - -template -class FaceHalfedgeIterT -{ - 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 - FaceHalfedgeIterT() : mesh_(0), lap_counter_(false) {} - - - /// Construct with mesh and a typename Mesh::FaceHandle - FaceHalfedgeIterT(mesh_ref _mesh, typename Mesh::FaceHandle _start, bool _end = false) : - mesh_(&_mesh), - start_(_mesh.halfedge_handle(_start)), - heh_(start_), - lap_counter_(_end) - { ; } - - - /// Construct with mesh and start halfedge - FaceHalfedgeIterT(mesh_ref _mesh, HalfedgeHandle _heh, bool _end = false) : - mesh_(&_mesh), - start_(_heh), - heh_(_heh), - lap_counter_(_end) - { ; } - - - /// Copy constructor - FaceHalfedgeIterT(const FaceHalfedgeIterT& _rhs) : - mesh_(_rhs.mesh_), - start_(_rhs.start_), - heh_(_rhs.heh_), - lap_counter_(_rhs.lap_counter_) - { ; } - - - /// Assignment operator - FaceHalfedgeIterT& operator=(const FaceHalfedgeIterT& _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 - FaceHalfedgeIterT(const FaceHalfedgeIterT& _rhs) : - mesh_(_rhs.mesh_), - start_(_rhs.start_), - heh_(_rhs.heh_), - lap_counter_(_rhs.lap_counter_) - { ; } - - - /// assign from non-const circulator - FaceHalfedgeIterT& operator=(const FaceHalfedgeIterT& _rhs) - { - mesh_ = _rhs.mesh_; - start_ = _rhs.start_; - heh_ = _rhs.heh_; - lap_counter_ = _rhs.lap_counter_; - return *this; - } -#else - friend class ConstFaceHalfedgeIterT; -#endif - - - /// Equal ? - bool operator==(const FaceHalfedgeIterT& _rhs) const { - return ((mesh_ == _rhs.mesh_) && - (start_ == _rhs.start_) && - (heh_ == _rhs.heh_) && - (lap_counter_ == _rhs.lap_counter_)); - } - - - /// Not equal ? - bool operator!=(const FaceHalfedgeIterT& _rhs) const { - return !operator==(_rhs); - } - - - /// Pre-Increment (next cw target) - FaceHalfedgeIterT& operator++() { - assert(mesh_); - heh_=mesh_->next_halfedge_handle(heh_); - if(heh_ == start_) lap_counter_++; - return *this; - } - - - /// Pre-Decrement (next ccw target) - FaceHalfedgeIterT& operator--() { - assert(mesh_); - if(heh_ == start_) lap_counter_--; - heh_=mesh_->prev_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 ConstFaceHalfedgeIterT CirculatorsT.hh - Circulator. -*/ - -template -class ConstFaceHalfedgeIterT -{ - 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 - ConstFaceHalfedgeIterT() : mesh_(0), lap_counter_(false) {} - - - /// Construct with mesh and a typename Mesh::FaceHandle - ConstFaceHalfedgeIterT(mesh_ref _mesh, typename Mesh::FaceHandle _start, bool _end = false) : - mesh_(&_mesh), - start_(_mesh.halfedge_handle(_start)), - heh_(start_), - lap_counter_(_end) - { ; } - - - /// Construct with mesh and start halfedge - ConstFaceHalfedgeIterT(mesh_ref _mesh, HalfedgeHandle _heh, bool _end = false) : - mesh_(&_mesh), - start_(_heh), - heh_(_heh), - lap_counter_(_end) - { ; } - - - /// Copy constructor - ConstFaceHalfedgeIterT(const ConstFaceHalfedgeIterT& _rhs) : - mesh_(_rhs.mesh_), - start_(_rhs.start_), - heh_(_rhs.heh_), - lap_counter_(_rhs.lap_counter_) - { ; } - - - /// Assignment operator - ConstFaceHalfedgeIterT& operator=(const ConstFaceHalfedgeIterT& _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 - ConstFaceHalfedgeIterT(const FaceHalfedgeIterT& _rhs) : - mesh_(_rhs.mesh_), - start_(_rhs.start_), - heh_(_rhs.heh_), - lap_counter_(_rhs.lap_counter_) - { ; } - - - /// assign from non-const circulator - ConstFaceHalfedgeIterT& operator=(const FaceHalfedgeIterT& _rhs) - { - mesh_ = _rhs.mesh_; - start_ = _rhs.start_; - heh_ = _rhs.heh_; - lap_counter_ = _rhs.lap_counter_; - return *this; - } -#else - friend class ConstFaceHalfedgeIterT; -#endif - - - /// Equal ? - bool operator==(const ConstFaceHalfedgeIterT& _rhs) const { - return ((mesh_ == _rhs.mesh_) && - (start_ == _rhs.start_) && - (heh_ == _rhs.heh_) && - (lap_counter_ == _rhs.lap_counter_)); - } - - - /// Not equal ? - bool operator!=(const ConstFaceHalfedgeIterT& _rhs) const { - return !operator==(_rhs); - } - - - /// Pre-Increment (next cw target) - ConstFaceHalfedgeIterT& operator++() { - assert(mesh_); - heh_=mesh_->next_halfedge_handle(heh_); - if(heh_ == start_) lap_counter_++; - return *this; - } - - - /// Pre-Decrement (next ccw target) - ConstFaceHalfedgeIterT& operator--() { - assert(mesh_); - if(heh_ == start_) lap_counter_--; - heh_=mesh_->prev_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 FaceEdgeIterT CirculatorsT.hh - Circulator. -*/ - -template -class FaceEdgeIterT -{ - 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 - FaceEdgeIterT() : mesh_(0), lap_counter_(false) {} - - - /// Construct with mesh and a typename Mesh::FaceHandle - FaceEdgeIterT(mesh_ref _mesh, typename Mesh::FaceHandle _start, bool _end = false) : - mesh_(&_mesh), - start_(_mesh.halfedge_handle(_start)), - heh_(start_), - lap_counter_(_end) - { ; } - - - /// Construct with mesh and start halfedge - FaceEdgeIterT(mesh_ref _mesh, HalfedgeHandle _heh, bool _end = false) : - mesh_(&_mesh), - start_(_heh), - heh_(_heh), - lap_counter_(_end) - { ; } - - - /// Copy constructor - FaceEdgeIterT(const FaceEdgeIterT& _rhs) : - mesh_(_rhs.mesh_), - start_(_rhs.start_), - heh_(_rhs.heh_), - lap_counter_(_rhs.lap_counter_) - { ; } - - - /// Assignment operator - FaceEdgeIterT& operator=(const FaceEdgeIterT& _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 - FaceEdgeIterT(const FaceEdgeIterT& _rhs) : - mesh_(_rhs.mesh_), - start_(_rhs.start_), - heh_(_rhs.heh_), - lap_counter_(_rhs.lap_counter_) - { ; } - - - /// assign from non-const circulator - FaceEdgeIterT& operator=(const FaceEdgeIterT& _rhs) - { - mesh_ = _rhs.mesh_; - start_ = _rhs.start_; - heh_ = _rhs.heh_; - lap_counter_ = _rhs.lap_counter_; - return *this; - } -#else - friend class ConstFaceEdgeIterT; -#endif - - - /// Equal ? - bool operator==(const FaceEdgeIterT& _rhs) const { - return ((mesh_ == _rhs.mesh_) && - (start_ == _rhs.start_) && - (heh_ == _rhs.heh_) && - (lap_counter_ == _rhs.lap_counter_)); - } - - - /// Not equal ? - bool operator!=(const FaceEdgeIterT& _rhs) const { - return !operator==(_rhs); - } - - - /// Pre-Increment (next cw target) - FaceEdgeIterT& operator++() { - assert(mesh_); - heh_=mesh_->next_halfedge_handle(heh_); - if(heh_ == start_) lap_counter_++; - return *this; - } - - - /// Pre-Decrement (next ccw target) - FaceEdgeIterT& operator--() { - assert(mesh_); - if(heh_ == start_) lap_counter_--; - heh_=mesh_->prev_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 ConstFaceEdgeIterT CirculatorsT.hh - Circulator. -*/ - -template -class ConstFaceEdgeIterT -{ - 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 - ConstFaceEdgeIterT() : mesh_(0), lap_counter_(false) {} - - - /// Construct with mesh and a typename Mesh::FaceHandle - ConstFaceEdgeIterT(mesh_ref _mesh, typename Mesh::FaceHandle _start, bool _end = false) : - mesh_(&_mesh), - start_(_mesh.halfedge_handle(_start)), - heh_(start_), - lap_counter_(_end) - { ; } - - - /// Construct with mesh and start halfedge - ConstFaceEdgeIterT(mesh_ref _mesh, HalfedgeHandle _heh, bool _end = false) : - mesh_(&_mesh), - start_(_heh), - heh_(_heh), - lap_counter_(_end) - { ; } - - - /// Copy constructor - ConstFaceEdgeIterT(const ConstFaceEdgeIterT& _rhs) : - mesh_(_rhs.mesh_), - start_(_rhs.start_), - heh_(_rhs.heh_), - lap_counter_(_rhs.lap_counter_) - { ; } - - - /// Assignment operator - ConstFaceEdgeIterT& operator=(const ConstFaceEdgeIterT& _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 - ConstFaceEdgeIterT(const FaceEdgeIterT& _rhs) : - mesh_(_rhs.mesh_), - start_(_rhs.start_), - heh_(_rhs.heh_), - lap_counter_(_rhs.lap_counter_) - { ; } - - - /// assign from non-const circulator - ConstFaceEdgeIterT& operator=(const FaceEdgeIterT& _rhs) - { - mesh_ = _rhs.mesh_; - start_ = _rhs.start_; - heh_ = _rhs.heh_; - lap_counter_ = _rhs.lap_counter_; - return *this; - } -#else - friend class ConstFaceEdgeIterT; -#endif - - - /// Equal ? - bool operator==(const ConstFaceEdgeIterT& _rhs) const { - return ((mesh_ == _rhs.mesh_) && - (start_ == _rhs.start_) && - (heh_ == _rhs.heh_) && - (lap_counter_ == _rhs.lap_counter_)); - } - - - /// Not equal ? - bool operator!=(const ConstFaceEdgeIterT& _rhs) const { - return !operator==(_rhs); - } - - - /// Pre-Increment (next cw target) - ConstFaceEdgeIterT& operator++() { - assert(mesh_); - heh_=mesh_->next_halfedge_handle(heh_); - if(heh_ == start_) lap_counter_++; - return *this; - } - - - /// Pre-Decrement (next ccw target) - ConstFaceEdgeIterT& operator--() { - assert(mesh_); - if(heh_ == start_) lap_counter_--; - heh_=mesh_->prev_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 FaceFaceIterT CirculatorsT.hh - Circulator. -*/ - -template -class FaceFaceIterT -{ - 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 - FaceFaceIterT() : mesh_(0), lap_counter_(false) {} - - - /// Construct with mesh and a typename Mesh::FaceHandle - FaceFaceIterT(mesh_ref _mesh, typename Mesh::FaceHandle _start, bool _end = false) : - mesh_(&_mesh), - start_(_mesh.halfedge_handle(_start)), - heh_(start_), - lap_counter_(_end) - { if (heh_.is_valid() && !handle().is_valid()) operator++();; } - - - /// Construct with mesh and start halfedge - FaceFaceIterT(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 - FaceFaceIterT(const FaceFaceIterT& _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 - FaceFaceIterT& operator=(const FaceFaceIterT& _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 - FaceFaceIterT(const FaceFaceIterT& _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 - FaceFaceIterT& operator=(const FaceFaceIterT& _rhs) - { - mesh_ = _rhs.mesh_; - start_ = _rhs.start_; - heh_ = _rhs.heh_; - lap_counter_ = _rhs.lap_counter_; - return *this; - } -#else - friend class ConstFaceFaceIterT; -#endif - - - /// Equal ? - bool operator==(const FaceFaceIterT& _rhs) const { - return ((mesh_ == _rhs.mesh_) && - (start_ == _rhs.start_) && - (heh_ == _rhs.heh_) && - (lap_counter_ == _rhs.lap_counter_)); - } - - - /// Not equal ? - bool operator!=(const FaceFaceIterT& _rhs) const { - return !operator==(_rhs); - } - - - /// Pre-Increment (next cw target) - FaceFaceIterT& operator++() { - assert(mesh_); - do { heh_=mesh_->next_halfedge_handle(heh_); if(heh_ == start_) lap_counter_++; } while ((*this) && (!handle().is_valid())); - return *this; - } - - - /// Pre-Decrement (next ccw target) - FaceFaceIterT& operator--() { - assert(mesh_); - do { if(heh_ == start_) lap_counter_--; heh_=mesh_->prev_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(mesh_->opposite_halfedge_handle(heh_)); - } - - - /// Cast to the handle of the current target. - operator typename Mesh::FaceHandle() const { - assert(mesh_); - return mesh_->face_handle(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 ConstFaceFaceIterT CirculatorsT.hh - Circulator. -*/ - -template -class ConstFaceFaceIterT -{ - 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 - ConstFaceFaceIterT() : mesh_(0), lap_counter_(false) {} - - - /// Construct with mesh and a typename Mesh::FaceHandle - ConstFaceFaceIterT(mesh_ref _mesh, typename Mesh::FaceHandle _start, bool _end = false) : - mesh_(&_mesh), - start_(_mesh.halfedge_handle(_start)), - heh_(start_), - lap_counter_(_end) - { if (heh_.is_valid() && !handle().is_valid()) operator++();; } - - - /// Construct with mesh and start halfedge - ConstFaceFaceIterT(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 - ConstFaceFaceIterT(const ConstFaceFaceIterT& _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 - ConstFaceFaceIterT& operator=(const ConstFaceFaceIterT& _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 - ConstFaceFaceIterT(const FaceFaceIterT& _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 - ConstFaceFaceIterT& operator=(const FaceFaceIterT& _rhs) - { - mesh_ = _rhs.mesh_; - start_ = _rhs.start_; - heh_ = _rhs.heh_; - lap_counter_ = _rhs.lap_counter_; - return *this; - } -#else - friend class ConstFaceFaceIterT; -#endif - - - /// Equal ? - bool operator==(const ConstFaceFaceIterT& _rhs) const { - return ((mesh_ == _rhs.mesh_) && - (start_ == _rhs.start_) && - (heh_ == _rhs.heh_) && - (lap_counter_ == _rhs.lap_counter_)); - } - - - /// Not equal ? - bool operator!=(const ConstFaceFaceIterT& _rhs) const { - return !operator==(_rhs); - } - - - /// Pre-Increment (next cw target) - ConstFaceFaceIterT& operator++() { - assert(mesh_); - do { heh_=mesh_->next_halfedge_handle(heh_); if(heh_ == start_) lap_counter_++; } while ((*this) && (!handle().is_valid()));; - return *this; - } - - - /// Pre-Decrement (next ccw target) - ConstFaceFaceIterT& operator--() { - assert(mesh_); - do { if(heh_ == start_) lap_counter_--; heh_=mesh_->prev_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(mesh_->opposite_halfedge_handle(heh_)); - } - - - /// Cast to the handle of the current target. - operator typename Mesh::FaceHandle() const { - assert(mesh_); - return mesh_->face_handle(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_; -}; - - - -//============================================================================= } // namespace Iterators } // namespace OpenMesh -//============================================================================= + #endif -//============================================================================= diff --git a/src/OpenMesh/Core/Mesh/PolyConnectivity.hh b/src/OpenMesh/Core/Mesh/PolyConnectivity.hh index 54e61d8d..d8b63e51 100644 --- a/src/OpenMesh/Core/Mesh/PolyConnectivity.hh +++ b/src/OpenMesh/Core/Mesh/PolyConnectivity.hh @@ -94,7 +94,10 @@ public: for documentation. */ //@{ - /// Circulator + + /* + * Vertex-centered circulators + */ typedef Iterators::GenericCirculatorT::toVertexHandle> VertexVertexIter; @@ -121,15 +124,29 @@ public: typedef VertexFaceIter ConstVertexFaceIter; typedef VertexEdgeIter ConstVertexEdgeIter; - typedef Iterators::FaceVertexIterT FaceVertexIter; - typedef Iterators::FaceHalfedgeIterT FaceHalfedgeIter; - typedef Iterators::FaceEdgeIterT FaceEdgeIter; - typedef Iterators::FaceFaceIterT FaceFaceIter; + /* + * Face-centered circulators + */ + typedef Iterators::GenericCirculatorT::toVertexHandle> + FaceVertexIter; - typedef Iterators::ConstFaceVertexIterT ConstFaceVertexIter; - typedef Iterators::ConstFaceHalfedgeIterT ConstFaceHalfedgeIter; - typedef Iterators::ConstFaceEdgeIterT ConstFaceEdgeIter; - typedef Iterators::ConstFaceFaceIterT ConstFaceFaceIter; + typedef Iterators::GenericCirculatorT::toHalfedgeHandle> + FaceHalfedgeIter; + + typedef Iterators::GenericCirculatorT::toEdgeHandle> + FaceEdgeIter; + + typedef Iterators::GenericCirculatorT::toOppositeFaceHandle> + FaceFaceIter; + + typedef FaceVertexIter ConstFaceVertexIter; + typedef FaceHalfedgeIter ConstFaceHalfedgeIter; + typedef FaceEdgeIter ConstFaceEdgeIter; + typedef FaceFaceIter ConstFaceFaceIter; //@} // --- shortcuts diff --git a/src/Unittests/unittests_trimesh_circulator_face_face.hh b/src/Unittests/unittests_trimesh_circulator_face_face.hh index a7069636..155a6a2b 100644 --- a/src/Unittests/unittests_trimesh_circulator_face_face.hh +++ b/src/Unittests/unittests_trimesh_circulator_face_face.hh @@ -257,23 +257,10 @@ TEST_F(OpenMeshTrimeshCirculatorFaceFace, FaceFaceIteratorHandleConversion) { // Get the face via the handle - Mesh::FaceHandle faceHandle1 = mesh_.handle(*face_iter); + Mesh::FaceHandle faceHandle1 = *face_iter; const Mesh::Face& face1 = mesh_.face(faceHandle1); EXPECT_EQ(1, faceHandle1.idx() ) << "Wrong face handle index when getting from iterator via handle"; - - // Get the face via the face itself - const Mesh::Face& face = *face_iter; - Mesh::FaceHandle fh = mesh_.handle(face); - - - EXPECT_EQ(1, fh.idx() ) << "Wrong face handle index when getting from iterator via face"; - - bool correct = (&face == &face1); - - // Compare the faces - EXPECT_TRUE(correct) << "The faces are different although both ways should give the same one"; - } diff --git a/src/Unittests/unittests_trimesh_circulator_vertex_face.hh b/src/Unittests/unittests_trimesh_circulator_vertex_face.hh index b9fbcfc8..bc5f79c6 100644 --- a/src/Unittests/unittests_trimesh_circulator_vertex_face.hh +++ b/src/Unittests/unittests_trimesh_circulator_vertex_face.hh @@ -82,7 +82,7 @@ TEST_F(OpenMeshTrimeshCirculatorVertexFace, VertexFaceIterWithHolesIncrement) { EXPECT_EQ(1, vf_it.handle().idx() ) << "Index wrong in VertexFaceIter at step 1"; EXPECT_TRUE(vf_it) << "Iterator invalid in VertexFaceIter at step 1"; ++vf_it ; - EXPECT_EQ(-1, vf_it.handle().idx() ) << "Index wrong in VertexFaceIter at end"; + EXPECT_FALSE(vf_it.is_valid() ) << "Index wrong in VertexFaceIter at end"; EXPECT_FALSE(vf_it) << "Iterator not invalid in VertexFaceIter at end"; EXPECT_TRUE( vf_it == vf_end ) << "End iterator for VertexFaceIter not matching"; @@ -95,7 +95,7 @@ TEST_F(OpenMeshTrimeshCirculatorVertexFace, VertexFaceIterWithHolesIncrement) { EXPECT_EQ(1, cvf_it.handle().idx() ) << "Index wrong in ConstVertexFaceIter at step one"; EXPECT_TRUE(cvf_it) << "Iterator invalid in ConstVertexFaceIter at step one"; ++cvf_it ; - EXPECT_EQ(-1, cvf_it.handle().idx() ) << "Index wrong in ConstVertexFaceIter at end"; + EXPECT_FALSE(cvf_it.is_valid() ) << "Index wrong in ConstVertexFaceIter at end"; EXPECT_FALSE(cvf_it) << "Iterator not invalid in ConstVertexFaceIter at end"; EXPECT_TRUE( cvf_it == cvf_end ) << "End iterator for ConstVertexFaceIter not matching"; @@ -263,8 +263,7 @@ TEST_F(OpenMeshTrimeshCirculatorVertexFace, VertexFaceIterBoundaryIncrement) { EXPECT_EQ(0, vf_it.handle().idx() ) << "Index wrong in VertexFaceIter at step 1"; EXPECT_TRUE(vf_it) << "Iterator invalid in VertexFaceIter at step 1"; ++vf_it ; - EXPECT_EQ(-1, vf_it.handle().idx() ) << "Index wrong in VertexFaceIter at step 2"; - EXPECT_FALSE(vf_it) << "Iterator invalid in VertexFaceIter at step 2"; + EXPECT_FALSE(vf_it.is_valid()) << "Iterator invalid in VertexFaceIter at step 2"; EXPECT_TRUE( vf_it == vf_end ) << "End iterator for VertexFaceIter not matching"; }