From 3ee9667060d69dcaa236e1392ed50a24d575aeca Mon Sep 17 00:00:00 2001 From: cignoni Date: Tue, 20 Apr 2010 00:56:08 +0000 Subject: [PATCH] added two helper functions used for the self intersection tests --- vcg/simplex/face/topology.h | 57 ++++++++++++++++++++++++++++++++++++- 1 file changed, 56 insertions(+), 1 deletion(-) diff --git a/vcg/simplex/face/topology.h b/vcg/simplex/face/topology.h index d1275124..27bafeae 100644 --- a/vcg/simplex/face/topology.h +++ b/vcg/simplex/face/topology.h @@ -529,9 +529,64 @@ void VVStarVF( typename FaceType::VertexType* vp, std::vector::iterator new_end = std::unique(starVec.begin(),starVec.end()); starVec.resize(new_end-starVec.begin()); - } +/*! +* Check if two faces share and edge through the FF topology. +* \param f0,f1 the two face to be checked +* \param i0,i1 the index of the shared edge; +*/ + +template +bool ShareEdgeFF(FaceType *f0,FaceType *f1, int *i0=0, int *i1=0) +{ + assert((!f0->IsD())&&(!f1->IsD())); + for (int i=0;i<3;i++) + if (f0->FFp(i)==f1) + { + if((i0!=0) && (i1!=0)) { + *i0=i; + *i1=f0->FFi(i); + } + return true; + } + return false; +} + +/*! +* Count the number of vertices shared between two faces. +* \param f0,f1 the two face to be checked +* ; +*/ +template +int CountSharedVertex(FaceType *f0,FaceType *f1) +{ + int sharedCnt=0; + for (int i=0;i<3;i++) + for (int j=0;j<3;j++) + if (f0->V(i)==f1->V(j)) { + sharedCnt++; + } + return sharedCnt; +} + +/*! +* find the first shared vertex between two faces. +* \param f0,f1 the two face to be checked +* \param i,j the indexes of the shared vertex in the two faces. Meaningful only if there is one single shared vertex +* ; +*/ +template +bool SharedVertex(FaceType *f0,FaceType *f1, int &i, int &j) +{ + for (i=0;i<3;i++) + for (j=0;j<3;j++) + if (f0->V(i)==f1->V(j)) return true; + + return false; +} + + /*@}*/ } // end namespace } // end namespace