diff --git a/Intersections_3/include/CGAL/Intersections_3/internal/Plane_3_Plane_3_Plane_3_intersection.h b/Intersections_3/include/CGAL/Intersections_3/internal/Plane_3_Plane_3_Plane_3_intersection.h index 2aa4e9b0bcb..2f4b6e75906 100644 --- a/Intersections_3/include/CGAL/Intersections_3/internal/Plane_3_Plane_3_Plane_3_intersection.h +++ b/Intersections_3/include/CGAL/Intersections_3/internal/Plane_3_Plane_3_Plane_3_intersection.h @@ -27,7 +27,7 @@ namespace internal { // triple plane intersection template -typename K::Point_3 +boost::optional intersection_point(const typename K::Plane_3& plane1, const typename K::Plane_3& plane2, const typename K::Plane_3& plane3, @@ -55,6 +55,10 @@ intersection_point(const typename K::Plane_3& plane1, const FT den = minor_0*m22 - minor_1*m12 + minor_2*m02; // determinant of M + if(is_zero(den)){ + return boost::none; + } + const FT num3 = minor_0*b2 - minor_1*b1 + minor_2*b0; // determinant of M with M[x:2] swapped with [b0,b1,b2] // Minors common to two determinants @@ -66,7 +70,7 @@ intersection_point(const typename K::Plane_3& plane1, const FT num1 = - minor_3*m21 + minor_4*m11 - minor_5*m01; // determinant of M with M[x:0] swapped with [b0,b1,b2] const FT num2 = minor_3*m20 - minor_4*m10 + minor_5*m00; // determinant of M with M[x:1] swapped with [b0,b1,b2] - return typename K::Point_3(num1/den, num2/den, num3/den); + return boost::make_optional(typename K::Point_3(num1/den, num2/den, num3/den)); } template @@ -83,12 +87,9 @@ intersection(const typename K::Plane_3& plane1, typedef typename K::Line_3 Line_3; typedef typename K::Plane_3 Plane_3; - if(!is_zero(determinant(plane1.a(), plane1.b(), plane1.c(), - plane2.a(), plane2.b(), plane2.c(), - plane3.a(), plane3.b(), plane3.c()))) - { - return result_type(intersection_point(plane1,plane2,plane3, k)); - } + auto res = intersection_point(plane1,plane2,plane3, k); + if (res != boost::none) + return result_type(*res); // Intersection between plane1 and plane2 can either be // a line, a plane, or empty.