From 5b2887240c87629cdb7261229fbee9121c1c733f Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Tue, 27 May 2025 23:44:34 +0200 Subject: [PATCH 1/5] fix a precondition MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit with a 80 bits floating points, it can be wrong when the two numbers are supposed to be equal. --- .../CGAL/Polygon_mesh_processing/distance.h | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/distance.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/distance.h index 86b73742fd6..1c3b0b4411e 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/distance.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/distance.h @@ -34,6 +34,7 @@ #include #include + #if defined(CGAL_METIS_ENABLED) #include #endif // CGAL_METIS_ENABLED @@ -42,14 +43,16 @@ #include #include #endif // CGAL_LINKED_WITH_TBB +#if defined(CGAL_LINKED_WITH_TBB) && defined(CGAL_METIS_ENABLED) && defined(USE_PARALLEL_BEHD) +# include +#endif -#include - -#include #include #include #include #include +#include +#include #ifdef CGAL_HAUSDORFF_DEBUG_PP #ifndef CGAL_HAUSDORFF_DEBUG @@ -1467,7 +1470,11 @@ bounded_error_squared_Hausdorff_distance_impl(const TriangleMesh1& tm1, using Candidate = Candidate_triangle; - CGAL_precondition(sq_initial_bound >= square(FT(error_bound))); + if constexpr(std::is_floating_point_v) { + CGAL_precondition(std::nextafter(sq_initial_bound, std::numeric_limits::max()) >= square(FT(error_bound))); + } else { + CGAL_precondition(sq_initial_bound >= square(FT(error_bound))); + } CGAL_precondition(sq_distance_bound != FT(0)); // value is -1 if unused CGAL_precondition(tm1_tree.size() > 0); CGAL_precondition(tm2_tree.size() > 0); From b66c3743ec71b0e19cc6773b775c5eadde8f4e66 Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Wed, 28 May 2025 00:52:20 +0200 Subject: [PATCH 2/5] fix FPU_get_cw with CGAL_ALWAYS_ROUND_TO_NEAREST --- Number_types/include/CGAL/FPU.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Number_types/include/CGAL/FPU.h b/Number_types/include/CGAL/FPU.h index ede509604d4..3cdcd682981 100644 --- a/Number_types/include/CGAL/FPU.h +++ b/Number_types/include/CGAL/FPU.h @@ -476,6 +476,9 @@ typedef int FPU_CW_t; #define CGAL_FE_DOWNWARD FE_DOWNWARD #endif +#define CGAL_FE_ROUNDING_MASK ((CGAL_FE_TONEAREST | CGAL_FE_TOWARDZERO | CGAL_FE_UPWARD | CGAL_FE_DOWNWARD) \ + & ~(CGAL_FE_TONEAREST & CGAL_FE_TOWARDZERO & CGAL_FE_UPWARD & CGAL_FE_DOWNWARD)) // mask for rounding bits + // User interface: inline @@ -484,8 +487,9 @@ FPU_get_cw (void) { #ifdef CGAL_ALWAYS_ROUND_TO_NEAREST CGAL_assertion_code(FPU_CW_t cw; CGAL_IA_GETFPCW(cw);) - CGAL_assertion(cw == CGAL_FE_TONEAREST); - return CGAL_FE_TONEAREST; + CGAL_assertion_code(FPU_CW_t mask = CGAL_FE_ROUNDING_MASK;) + CGAL_assertion((cw & mask) == (CGAL_FE_TONEAREST & mask)); + return cw; #else FPU_CW_t cw; CGAL_IA_GETFPCW(cw); From 4cfd48ba764964d5f82059dcf9d1ad831691009c Mon Sep 17 00:00:00 2001 From: Sebastien Loriot Date: Tue, 3 Jun 2025 18:29:59 +0200 Subject: [PATCH 3/5] fix warning --- .../include/CGAL/Polygon_mesh_processing/distance.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/distance.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/distance.h index 1c3b0b4411e..ebe68d43611 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/distance.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/distance.h @@ -1471,7 +1471,7 @@ bounded_error_squared_Hausdorff_distance_impl(const TriangleMesh1& tm1, using Candidate = Candidate_triangle; if constexpr(std::is_floating_point_v) { - CGAL_precondition(std::nextafter(sq_initial_bound, std::numeric_limits::max()) >= square(FT(error_bound))); + CGAL_precondition(std::nextafter(sq_initial_bound, (std::numeric_limits::max)()) >= square(FT(error_bound))); } else { CGAL_precondition(sq_initial_bound >= square(FT(error_bound))); } From ad20fa497a51451fc1d5de3019cd0eebc0e64fa7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Tue, 3 Jun 2025 18:44:59 +0200 Subject: [PATCH 4/5] always declare a value you are using --- Number_types/include/CGAL/FPU.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Number_types/include/CGAL/FPU.h b/Number_types/include/CGAL/FPU.h index 3cdcd682981..41f67f940dc 100644 --- a/Number_types/include/CGAL/FPU.h +++ b/Number_types/include/CGAL/FPU.h @@ -486,7 +486,8 @@ FPU_CW_t FPU_get_cw (void) { #ifdef CGAL_ALWAYS_ROUND_TO_NEAREST - CGAL_assertion_code(FPU_CW_t cw; CGAL_IA_GETFPCW(cw);) + FPU_CW_t cw; + CGAL_IA_GETFPCW(cw); CGAL_assertion_code(FPU_CW_t mask = CGAL_FE_ROUNDING_MASK;) CGAL_assertion((cw & mask) == (CGAL_FE_TONEAREST & mask)); return cw; From e187dc03cbc2e5067a0144969e4e0af55836bced Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Wed, 2 Jul 2025 15:45:22 +0200 Subject: [PATCH 5/5] fix --- Number_types/include/CGAL/FPU.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Number_types/include/CGAL/FPU.h b/Number_types/include/CGAL/FPU.h index 41f67f940dc..64b549f48da 100644 --- a/Number_types/include/CGAL/FPU.h +++ b/Number_types/include/CGAL/FPU.h @@ -486,11 +486,10 @@ FPU_CW_t FPU_get_cw (void) { #ifdef CGAL_ALWAYS_ROUND_TO_NEAREST - FPU_CW_t cw; - CGAL_IA_GETFPCW(cw); + CGAL_assertion_code(FPU_CW_t cw; CGAL_IA_GETFPCW(cw);) CGAL_assertion_code(FPU_CW_t mask = CGAL_FE_ROUNDING_MASK;) CGAL_assertion((cw & mask) == (CGAL_FE_TONEAREST & mask)); - return cw; + return CGAL_FE_TONEAREST; #else FPU_CW_t cw; CGAL_IA_GETFPCW(cw);