00001 00009 #ifndef _MESHLIB_HALFEDGE_H_ 00010 #define _MESHLIB_HALFEDGE_H_ 00011 00012 #include <assert.h> 00013 #include <math.h> 00014 #include <string> 00015 #include "Edge.h" 00016 00017 namespace MeshLib{ 00018 00019 class CVertex; 00020 class CEdge; 00021 class CFace; 00022 00026 class CHalfEdge 00027 { 00028 public: 00029 00032 CHalfEdge(){ m_edge = NULL; m_vertex = NULL; m_prev = NULL; m_next = NULL; m_face = NULL; }; 00035 ~CHalfEdge(){}; 00036 00038 CEdge * & edge() { return m_edge; }; 00040 CVertex * & vertex() { return m_vertex; }; 00042 CVertex * & target() { return m_vertex; }; 00044 CVertex * & source() { return m_prev->vertex();}; 00046 CHalfEdge * & he_prev() { return m_prev;}; 00048 CHalfEdge * & he_next() { return m_next;}; 00050 CHalfEdge * & he_sym() { return m_edge->other( this ); }; 00052 CFace * & face() { return m_face;}; 00056 CHalfEdge * ccw_rotate_about_target(); 00060 CHalfEdge * clw_rotate_about_target(); 00064 CHalfEdge * ccw_rotate_about_source(); 00068 CHalfEdge * clw_rotate_about_source(); 00070 std::string & string() { return m_string; }; 00072 void _to_string() {}; 00074 void _from_string() {}; 00075 00076 protected: 00078 CEdge * m_edge; 00080 CFace * m_face; 00082 CVertex * m_vertex; //target vertex 00084 CHalfEdge * m_prev; 00086 CHalfEdge * m_next; 00088 std::string m_string; 00089 }; 00090 00091 //roate the halfedge about its target vertex CCWly 00092 00093 inline CHalfEdge * CHalfEdge::ccw_rotate_about_target() 00094 { 00095 CHalfEdge * he_dual = he_sym(); 00096 if( he_dual == NULL ) return NULL; 00097 00098 return he_dual->he_prev(); 00099 }; 00100 00101 //roate the halfedge about its target vertex CLWly 00102 00103 inline CHalfEdge * CHalfEdge::clw_rotate_about_target() 00104 { 00105 CHalfEdge * he = he_next()->he_sym(); 00106 return he; 00107 }; 00108 00109 //roate the halfedge about its source vertex CCWly 00110 00111 00112 inline CHalfEdge * CHalfEdge::ccw_rotate_about_source() 00113 { 00114 00115 CHalfEdge * he = he_prev()->he_sym(); 00116 return he; 00117 }; 00118 00119 //roate the halfedge about its source vertex CLWly 00120 00121 inline CHalfEdge * CHalfEdge::clw_rotate_about_source() 00122 { 00123 CHalfEdge * he = he_sym(); 00124 if( he == NULL ) return NULL; 00125 return he->he_next(); 00126 }; 00127 00128 }//namespace MeshLib 00129 00130 #endif //_MESHLIB_HALFEDGE_H_ defined