00001 #ifndef VCG_HEDGE_POS 00002 #define VCG_HEDGE_POS 00003 00004 namespace vcg 00005 { 00006 namespace hedge 00007 { 00012 template <class MeshType> class Pos 00013 { 00014 00015 public: 00016 00017 typedef typename MeshType::VertexPointer VertexPointer; 00018 typedef typename MeshType::EdgePointer EdgePointer; 00019 typedef typename MeshType::HEdgePointer HEdgePointer; 00020 typedef typename MeshType::FacePointer FacePointer; 00021 00025 HEdgePointer he; 00026 00034 bool direction; 00035 00039 Pos(HEdgePointer hep, bool dir) 00040 { 00041 he = hep; 00042 direction = dir; 00043 } 00044 00048 Pos(HEdgePointer hep) 00049 { 00050 he = hep; 00051 direction = 1; 00052 } 00053 00057 void FlipV() 00058 { 00059 direction = !direction; 00060 } 00061 00065 void FlipE() 00066 { 00067 if(!direction) 00068 he = he->HNp(); 00069 else 00070 if(he->HasHPrevAdjacency()) 00071 he = he->HPp(); 00072 else 00073 { 00074 HEdgePointer aux = he; 00075 while(aux->HNp() != he) 00076 aux = aux->HNp(); 00077 he = aux; 00078 } 00079 00080 direction = !direction; 00081 } 00082 00086 void FlipF() 00087 { 00088 direction = !direction; 00089 he = he->HOp(); 00090 } 00091 00095 VertexPointer V() 00096 { 00097 if(direction) 00098 return he->HVp(); 00099 else 00100 return he->HOp()->HVp(); 00101 } 00102 00106 HEdgePointer HE() 00107 { 00108 return he; 00109 } 00110 00114 EdgePointer E() 00115 { 00116 return he->HEp(); 00117 } 00118 00122 FacePointer F() 00123 { 00124 return he->HFp(); 00125 } 00126 00130 inline bool operator == ( Pos const & p ) const 00131 { 00132 return (he == p.he && direction == p.direction); 00133 } 00134 00138 inline bool operator != ( Pos const & p ) const 00139 { 00140 return (he != p.he || direction != p.direction); 00141 } 00142 00143 }; 00144 00145 } 00146 } 00147 00148 #endif // VCG_HEDGE_POS 00149