From 258179a707d143f8ffcd62ed83bfd0a4b21faeee Mon Sep 17 00:00:00 2001 From: Simon Giraudot Date: Tue, 30 Apr 2019 11:23:47 +0200 Subject: [PATCH] Prevent construction of line with NaN coordinates --- .../CGAL/Intersections_3/intersection_3_1_impl.h | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Intersections_3/include/CGAL/Intersections_3/intersection_3_1_impl.h b/Intersections_3/include/CGAL/Intersections_3/intersection_3_1_impl.h index 9f65b83e86e..0526ffe257d 100644 --- a/Intersections_3/include/CGAL/Intersections_3/intersection_3_1_impl.h +++ b/Intersections_3/include/CGAL/Intersections_3/intersection_3_1_impl.h @@ -29,6 +29,7 @@ #include #include #include +#include namespace CGAL { @@ -424,10 +425,13 @@ intersection(const typename K::Line_3 &l1, const Point_3 p4 = p2 + v2; if(!K().coplanar_3_object()(p1,p2,p3,p4)) return intersection_return(); const Vector_3 v3 = p3 - p1; - const Vector_3 v3v2 = cross_product(v3,v2); + const Vector_3 v3v2 = cross_product(v3,v2); const Vector_3 v1v2 = cross_product(v1,v2); - const FT t = ((v3v2.x()*v1v2.x()) + (v3v2.y()*v1v2.y()) + (v3v2.z()*v1v2.z())) / - (v1v2.squared_length()); + const FT sl = v1v2.squared_length(); + if(certainly(sl == FT(0))) + return intersection_return(); + const FT t = ((v3v2.x()*v1v2.x()) + (v3v2.y()*v1v2.y()) + (v3v2.z()*v1v2.z())) / sl; + return intersection_return(p1 + (v1 * t)); }