Vertex.h

Go to the documentation of this file.
00001 
00009 #ifndef  _MESHLIB_VERTEX_H_
00010 #define  _MESHLIB_VERTEX_H_
00011 
00012 #include <stdlib.h>
00013 #include <string>
00014 #include "../Geometry/Point.h"
00015 #include "../Geometry/Point2.h"
00016 #include "HalfEdge.h"
00017 
00018 namespace MeshLib{
00019 
00020   class CHalfEdge;
00021 
00026   class CVertex
00027   {
00028   public:
00032       CVertex(){ m_halfedge = NULL; m_boundary = false; };
00036     ~CVertex(){};
00037 
00040     CPoint & point()    { return m_point;};
00043     CPoint & normal()   { return m_normal; };
00046         CPoint2 & uv()       { return m_uv; };
00047 
00050     CHalfEdge * most_ccw_out_halfedge();
00053     CHalfEdge * most_clw_out_halfedge();
00056     CHalfEdge * most_ccw_in_halfedge();
00059     CHalfEdge * most_clw_in_halfedge();
00060 
00063     CHalfEdge * & halfedge() { return m_halfedge; };
00066         std::string & string() { return m_string;};
00069     int  & id() { return m_id; };
00072     bool & boundary() { return m_boundary;};
00075         void _to_string()   {};
00078         void _from_string() {};
00079 
00080   protected:
00081 
00084     int    m_id ;
00087     CPoint m_point;
00090     CPoint m_normal;
00093         CPoint2 m_uv;
00096     CHalfEdge *     m_halfedge;
00099     bool            m_boundary;
00102         std::string     m_string;
00103 
00104   }; //class CVertex
00105 
00106 
00110 inline CHalfEdge *  CVertex::most_ccw_in_halfedge()  
00111 { 
00112         //for interior vertex
00113         if( !m_boundary )
00114         {
00115                 return m_halfedge; //current half edge is the most ccw in halfedge 
00116         }
00117 
00118         //for boundary vertex
00119         CHalfEdge * he = m_halfedge->ccw_rotate_about_target();
00120         //rotate to the most ccw in halfedge
00121         while( he != NULL )
00122         {
00123                 m_halfedge = he;
00124                 he = m_halfedge->ccw_rotate_about_target();
00125         }
00126         // the halfedge of the vertex becomes the most ccw in halfedge
00127         return m_halfedge;
00128 };
00129 
00130 //most clockwise in halfedge
00131 
00132 inline CHalfEdge *  CVertex::most_clw_in_halfedge()  
00133 { 
00134         //for interior vertex 
00135         if( !m_boundary )
00136         {
00137                 return most_ccw_in_halfedge()->ccw_rotate_about_target(); //the most ccw in halfedge rotate ccwly once to get the most clw in halfedge
00138         }
00139         //for boundary vertex
00140         CHalfEdge * he = m_halfedge->clw_rotate_about_target();
00141         //rotate to the most clw in halfedge
00142         while( he != NULL )
00143         {
00144                 m_halfedge = he;
00145                 he = m_halfedge->clw_rotate_about_target();
00146         }
00147 
00148         return m_halfedge;
00149 };
00150 
00151 //most counter clockwise out halfedge
00152 
00153 inline CHalfEdge *  CVertex::most_ccw_out_halfedge()  
00154 { 
00155         //for interior vertex
00156         if( !m_boundary )
00157         {
00158                 return most_ccw_in_halfedge()->he_sym(); //most ccw out halfedge is the dual of the most ccw in halfedge
00159         }
00160 
00161         //for boundary vertex
00162         CHalfEdge * he = m_halfedge->he_next();
00163         //get the out halfedge which is the next halfedge of the most ccw in halfedge
00164         CHalfEdge * ne = he->ccw_rotate_about_source();
00165         //rotate ccwly around the source vertex
00166         while( ne != NULL )
00167         {
00168                 he = ne;
00169                 ne = he->ccw_rotate_about_source();
00170         }
00171 
00172         return he;
00173 };
00174 
00175 //most clockwise out halfedge
00176 
00177 inline CHalfEdge * CVertex::most_clw_out_halfedge()  
00178 { 
00179         //for interior vertex
00180         if( !m_boundary )
00181         {
00182                 return most_ccw_out_halfedge()->ccw_rotate_about_source();  //most ccw out halfedge rotate ccwly once about the source
00183         }
00184         //get one out halfedge
00185         CHalfEdge * he = m_halfedge->he_next();
00186         //rotate the out halfedge clwly about the source
00187         CHalfEdge * ne = he->clw_rotate_about_source();
00188         
00189         while( ne != NULL )
00190         {
00191                 he = ne;
00192                 ne = he->clw_rotate_about_source();
00193         }
00194 
00195         return he;
00196 };
00197 
00198 
00199 
00200 }//name space MeshLib
00201 
00202 #endif //_MESHLIB_VERTEX_H_defined
 All Classes Namespaces Files Functions Variables Typedefs Enumerator Defines