Go to the documentation of this file.00001 #ifndef OPENTISSUE_CORE_CONTAINERS_MESH_POLYMESH_CIRCULATORS_POLYMESH_FACE_HALFEDGE_CIRCULATOR_H
00002 #define OPENTISSUE_CORE_CONTAINERS_MESH_POLYMESH_CIRCULATORS_POLYMESH_FACE_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 PolyMeshFaceHalfedgeCirculator
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::face_type const & f)
00044 {
00045 if ( f.get_border_halfedge_handle().is_null() )
00046 return iterator_t();
00047 else
00048 return f.get_border_halfedge_iterator();
00049 }
00050
00051 public:
00052
00053 PolyMeshFaceHalfedgeCirculator()
00054 : m_kernel(0)
00055 , m_first ()
00056 , m_cur ()
00057 , m_active(false)
00058 {}
00059
00060 explicit PolyMeshFaceHalfedgeCirculator( typename PolyMesh::face_type const & f)
00061 : m_kernel( f.get_owner() )
00062 , m_first ( init(f) )
00063 , m_cur ( init(f) )
00064 , m_active( false )
00065 {}
00066
00067 template <class OtherValue>
00068 PolyMeshFaceHalfedgeCirculator( PolyMeshFaceHalfedgeCirculator<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 public:
00076
00077 template <class OtherValue>
00078 bool operator==(PolyMeshFaceHalfedgeCirculator<PolyMesh,OtherValue> const& ) const
00079 {
00080 if(!m_kernel || 0==m_cur)
00081 return true;
00082 return (m_active && m_first == m_cur);
00083 }
00084
00085 template <class OtherValue>
00086 bool operator!=(PolyMeshFaceHalfedgeCirculator<PolyMesh,OtherValue> const& other) const
00087 {
00088 return !((*this)==other);
00089 }
00090
00091 PolyMeshFaceHalfedgeCirculator & operator++()
00092 {
00093 m_active = true;
00094
00095 if(!m_kernel || 0==m_cur)
00096 return *this;
00097
00098 m_cur = m_cur.get()->get_next_iterator();
00099 return *this;
00100 }
00101
00102 PolyMeshFaceHalfedgeCirculator & operator--()
00103 {
00104 m_active = true;
00105
00106 if(!m_kernel || 0==m_cur)
00107 return *this;
00108
00109 m_cur = m_cur.get()->get_prev_iterator();
00110 return *this;
00111 }
00112
00113 Value & operator*() const
00114 {
00115 return *( m_cur.get() );
00116 }
00117 Value * operator->() const
00118 {
00119 return &( *( m_cur.get() ) );
00120 }
00121
00122 };
00123
00124 }
00125 }
00126
00127
00128 #endif