From 61dfe46ab97befe51779db672c80dedb5139499b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Thu, 28 Nov 2013 17:19:52 +0100 Subject: [PATCH] fix regression in the Triangle_3-Triangle_3 intersection computation this has been introduced when rewriting the code for the removal of Object --- .../CGAL/Triangle_3_Triangle_3_intersection.h | 20 ++++++++++++------- .../triangle_3_triangle_3_intersection.cpp | 6 ++++++ 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/Intersections_3/include/CGAL/Triangle_3_Triangle_3_intersection.h b/Intersections_3/include/CGAL/Triangle_3_Triangle_3_intersection.h index 1f15c6c0cc9..162813a490f 100644 --- a/Intersections_3/include/CGAL/Triangle_3_Triangle_3_intersection.h +++ b/Intersections_3/include/CGAL/Triangle_3_Triangle_3_intersection.h @@ -132,18 +132,24 @@ struct Triangle_Line_visitor { ::result_type result_type; result_type - operator()(const typename K::Point_3& p, const typename K::Segment_3&) const { - return intersection_return(p); + operator()(const typename K::Point_3& p, const typename K::Segment_3& s) const { + if ( s.has_on(p) ) + return intersection_return(p); + else + return result_type(); } result_type - operator()(const typename K::Segment_3&, const typename K::Point_3& p) const { - return intersection_return(p); + operator()(const typename K::Segment_3& s, const typename K::Point_3& p) const { + return operator()(p,s); } result_type - operator()(const typename K::Point_3& p1, const typename K::Point_3&) const { - return intersection_return(p1); + operator()(const typename K::Point_3& p1, const typename K::Point_3& p2) const { + if (p1==p2) + return intersection_return(p1); + else + return result_type(); } result_type @@ -158,7 +164,7 @@ struct Triangle_Line_visitor { return intersection_return(*p); } - return intersection_return(); + return result_type(); } }; diff --git a/Intersections_3/test/Intersections_3/triangle_3_triangle_3_intersection.cpp b/Intersections_3/test/Intersections_3/triangle_3_triangle_3_intersection.cpp index 9282a403e12..a809689492f 100644 --- a/Intersections_3/test/Intersections_3/triangle_3_triangle_3_intersection.cpp +++ b/Intersections_3/test/Intersections_3/triangle_3_triangle_3_intersection.cpp @@ -273,6 +273,12 @@ void test_non_coplanar_triangles() assert(obj.empty()); obj=CGAL::intersection(t2,t1); assert(obj.empty()); + t1=Triangle( Point( 0, 0, 0 ), Point( 0, 1, 1 ), Point( 0, 1, 0 ) ); + t2=Triangle( Point( -1, -1, 0 ),Point( 0, -1, 0 ),Point( -1, 0, 0 ) ); + obj=CGAL::intersection(t1,t2); + assert(obj.empty()); + obj=CGAL::intersection(t2,t1); + assert(obj.empty()); } int main()