From 1331ead487a4dcf9e6601be55267d221e7e7ca77 Mon Sep 17 00:00:00 2001 From: cignoni Date: Mon, 15 Oct 2012 09:26:15 +0000 Subject: [PATCH] Corrected a small bug in TestFaceFaceIntersection the case of two faces sharing an edge was not managed correctly in the case the two faces had the two edges opposite to the shared vertex lying on the same plane. --- vcg/complex/algorithms/clean.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/vcg/complex/algorithms/clean.h b/vcg/complex/algorithms/clean.h index b30c391f..69b5c5cd 100644 --- a/vcg/complex/algorithms/clean.h +++ b/vcg/complex/algorithms/clean.h @@ -1621,13 +1621,16 @@ private: int sv = face::CountSharedVertex(f0,f1); if(sv==3) return true; if(sv==0) return (vcg::IntersectionTriangleTriangle((*f0),(*f1))); - // if the faces share only a vertex, the opposite edge is tested against the face + // if the faces share only a vertex, the opposite edge (as a segment) is tested against the face + // to avoid degenerate cases where the two triangles have the opposite edge on a common plane + // we offset the segment to test toward the shared vertex if(sv==1) { int i0,i1; ScalarType a,b; face::FindSharedVertex(f0,f1,i0,i1); - if(vcg::IntersectionSegmentTriangle(Segment3((*f0).V1(i0)->P(),(*f0).V2(i0)->P()), *f1, a, b) ) return true; - if(vcg::IntersectionSegmentTriangle(Segment3((*f1).V1(i1)->P(),(*f1).V2(i1)->P()), *f0, a, b) ) return true; + Point3f shP = f0->V(i0)->P()*0.5; + if(vcg::IntersectionSegmentTriangle(Segment3((*f0).V1(i0)->P()*0.5+shP,(*f0).V2(i0)->P()*0.5+shP), *f1, a, b) ) return true; + if(vcg::IntersectionSegmentTriangle(Segment3((*f1).V1(i1)->P()*0.5+shP,(*f1).V2(i1)->P()*0.5+shP), *f0, a, b) ) return true; } return false; }