From c3e3c0eb31bc0f05fc121872d29ab900fcbefca3 Mon Sep 17 00:00:00 2001 From: Sven Oesau Date: Wed, 23 Jul 2025 10:22:18 +0200 Subject: [PATCH 1/2] checking sign before using squared cos angle --- .../Polygon_mesh/Least_squares_plane_fit_region.h | 4 ++++ 1 file changed, 4 insertions(+) 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 2c8801ea5e6..e1262ab9059 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 = From 547e2a3c0fcc6a402c5fed927f24c371990c5451 Mon Sep 17 00:00:00 2001 From: Sven Oesau Date: Wed, 23 Jul 2025 10:37:04 +0200 Subject: [PATCH 2/2] checking sign before using squared cos angle --- .../Region_growing/Point_set/Least_squares_line_fit_region.h | 4 ++++ .../Segment_set/Least_squares_line_fit_region.h | 4 ++++ 2 files changed, 8 insertions(+) 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 8111ac2f599..de37f3226dc 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/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 1ba03dfcb59..cd0d384631b 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 =