Go to the documentation of this file.00001 #ifndef OPENTISSUE_CORE_CONTAINERS_MESH_POLYMESH_CIRCULATORS_POLYMESH_VERTEX_HALFEDGE_CIRCULATOR_H
00002 #define OPENTISSUE_CORE_CONTAINERS_MESH_POLYMESH_CIRCULATORS_POLYMESH_VERTEX_HALFEDGE_CIRCULATOR_H
00003
00004
00005
00006
00007
00008
00009
00010 #include <OpenTissue/configuration.h>
00011
00012 namespace OpenTissue
00013 {
00014 namespace polymesh
00015 {
00016
00017 template< typename PolyMesh, class Value >
00018 class PolyMeshVertexHalfedgeCirculator
00019 {
00020 private:
00021
00022 typedef typename PolyMesh::opt_halfedge_iter iterator_t;
00023
00024 typename PolyMesh::kernel_type * m_kernel;
00025 iterator_t m_first;
00026 iterator_t m_cur;
00027 bool m_active;
00028
00029 private:
00030
00043 static iterator_t init(typename PolyMesh::vertex_type const & v)
00044 {
00045 if ( v.get_outgoing_halfedge_handle().is_null() )
00046 return iterator_t();
00047 else
00048 return v.get_outgoing_halfedge_iterator();
00049 }
00050
00051 public:
00052
00053 PolyMeshVertexHalfedgeCirculator()
00054 : m_kernel(0)
00055 , m_first ()
00056 , m_cur ()
00057 , m_active(false)
00058 { }
00059
00060 explicit PolyMeshVertexHalfedgeCirculator( typename PolyMesh::vertex_type const & v)
00061 : m_kernel( v.get_owner() )
00062 , m_first ( init(v) )
00063 , m_cur ( init(v) )
00064 , m_active( false )
00065 {}
00066
00067 template <class OtherValue>
00068 PolyMeshVertexHalfedgeCirculator( PolyMeshVertexHalfedgeCirculator<PolyMesh,OtherValue> const& other )
00069 : m_kernel( other.m_kernel )
00070 , m_first ( other.m_first )
00071 , m_cur ( other.m_cur )
00072 , m_active( other.m_active )
00073 {}
00074
00075 template <class OtherValue>
00076 bool operator==(PolyMeshVertexHalfedgeCirculator<PolyMesh,OtherValue> const& ) const
00077 {
00078 if( !m_kernel || 0==m_cur )
00079 return true;
00080 return (m_active && m_first == m_cur);
00081 }
00082
00083 template <class OtherValue>
00084 bool operator!=(PolyMeshVertexHalfedgeCirculator<PolyMesh,OtherValue> const& other) const
00085 {
00086 return !( (*this)==other );
00087 }
00088
00089 PolyMeshVertexHalfedgeCirculator & operator++()
00090 {
00091 m_active = true;
00092
00093 if( !m_kernel || 0==m_cur)
00094 return *this;
00095
00096 m_cur = m_cur.get()->get_twin_iterator()->get_next_iterator();
00097 return *this;
00098 }
00099
00100 PolyMeshVertexHalfedgeCirculator & operator--()
00101 {
00102 m_active = true;
00103
00104 if( !m_kernel || 0==m_cur)
00105 return *this;
00106
00107 m_cur = m_cur.get()->get_prev_iterator()->get_twin_iterator();
00108 return *this;
00109 }
00110
00111 Value& operator*() const
00112 {
00113 return *( m_cur.get() );
00114 }
00115 Value * operator->() const
00116 {
00117 return &( *( m_cur.get() ) );
00118 }
00119
00120 };
00121
00122 }
00123 }
00124
00125
00126 #endif