diff --git a/Shape_detection/include/CGAL/Shape_detection/Region_growing/Point_set/Least_squares_line_fit_region.h b/Shape_detection/include/CGAL/Shape_detection/Region_growing/Point_set/Least_squares_line_fit_region.h index d61ecad6b1d..fcf4bd653bf 100644 --- a/Shape_detection/include/CGAL/Shape_detection/Region_growing/Point_set/Least_squares_line_fit_region.h +++ b/Shape_detection/include/CGAL/Shape_detection/Region_growing/Point_set/Least_squares_line_fit_region.h @@ -241,6 +241,10 @@ namespace Point_set { const FT cos_value = m_scalar_product_2(query_normal, m_normal_of_best_fit); + + if (cos_value < 0) + return false; + const FT squared_cos_value = cos_value * cos_value; FT squared_cos_value_threshold = diff --git a/Shape_detection/include/CGAL/Shape_detection/Region_growing/Polygon_mesh/Least_squares_plane_fit_region.h b/Shape_detection/include/CGAL/Shape_detection/Region_growing/Polygon_mesh/Least_squares_plane_fit_region.h index 3ac12c3dea7..613859165ee 100644 --- a/Shape_detection/include/CGAL/Shape_detection/Region_growing/Polygon_mesh/Least_squares_plane_fit_region.h +++ b/Shape_detection/include/CGAL/Shape_detection/Region_growing/Polygon_mesh/Least_squares_plane_fit_region.h @@ -287,6 +287,10 @@ namespace Polygon_mesh { const Vector_3 face_normal = get(m_face_normals, query); const FT cos_value = m_scalar_product_3(face_normal, m_normal_of_best_fit); + + if (cos_value < 0) + return false; + const FT squared_cos_value = cos_value * cos_value; FT squared_cos_value_threshold = diff --git a/Shape_detection/include/CGAL/Shape_detection/Region_growing/Segment_set/Least_squares_line_fit_region.h b/Shape_detection/include/CGAL/Shape_detection/Region_growing/Segment_set/Least_squares_line_fit_region.h index 702cbaa0fb9..73f3d9cd4d5 100644 --- a/Shape_detection/include/CGAL/Shape_detection/Region_growing/Segment_set/Least_squares_line_fit_region.h +++ b/Shape_detection/include/CGAL/Shape_detection/Region_growing/Segment_set/Least_squares_line_fit_region.h @@ -244,6 +244,10 @@ namespace Segment_set { const FT cos_value = m_scalar_product(query_direction, m_direction_of_best_fit); + + if (cos_value < 0) + return false; + const FT squared_cos_value = cos_value * cos_value; FT squared_cos_value_threshold =