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 VertexPointer Vo() 00107 { 00108 if(!direction) 00109 return he->HVp(); 00110 else 00111 return he->HOp()->HVp(); 00112 } 00113 00117 HEdgePointer HE() 00118 { 00119 return he; 00120 } 00121 00125 EdgePointer E() 00126 { 00127 return he->HEp(); 00128 } 00129 00133 FacePointer F() 00134 { 00135 return he->HFp(); 00136 } 00137 00141 inline bool operator == ( Pos const & p ) const 00142 { 00143 return (he == p.he && direction == p.direction); 00144 } 00145 00149 inline bool operator != ( Pos const & p ) const 00150 { 00151 return (he != p.he || direction != p.direction); 00152 } 00153 00154 }; 00155 00156 } 00157 } 00158 00159 #endif // VCG_HEDGE_POS 00160