From af7b223c2561abc94ce1f3de0a93213fcf393d56 Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Mon, 10 Nov 2025 15:58:55 +0100 Subject: [PATCH] better use of .exact() --- .../CGAL/Conforming_Delaunay_triangulation_3.h | 15 ++++++++------- .../cdt_3_from_off.cpp | 8 ++++++-- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/Constrained_triangulation_3/include/CGAL/Conforming_Delaunay_triangulation_3.h b/Constrained_triangulation_3/include/CGAL/Conforming_Delaunay_triangulation_3.h index 06a445b0b90..40982b2068d 100644 --- a/Constrained_triangulation_3/include/CGAL/Conforming_Delaunay_triangulation_3.h +++ b/Constrained_triangulation_3/include/CGAL/Conforming_Delaunay_triangulation_3.h @@ -1008,10 +1008,11 @@ protected: static constexpr bool has_exact_member_function_v().exact())>> = true; template - static void exact(T&& obj) { + static decltype(auto) exact(T&& obj) { if constexpr (has_exact_member_function_v) { - std::forward(obj).exact(); + return std::forward(obj).exact(); } + return std::forward(obj); } // Helper to compute a projected point with optional exact kernel and custom threshold check @@ -1079,14 +1080,14 @@ protected: // Check threshold before computing projection if(use_midpoint_check(lambda, std::nullopt)) { - return midpoint_functor(midpoint_start, midpoint_end); + return exact(midpoint_functor(midpoint_start, midpoint_end)); } const auto vector_ab = vector_functor(start_pt, end_pt); const auto projected_pt = translate_functor(start_pt, scaled_vector_functor(vector_ab, lambda)); // Second threshold check with actual projected point if needed - return use_midpoint_check(lambda, projected_pt) ? midpoint_functor(midpoint_start, midpoint_end) : projected_pt; + return exact(use_midpoint_check(lambda, projected_pt) ? midpoint_functor(midpoint_start, midpoint_end) : projected_pt); } // Convenience wrapper for simple lambda-based threshold (lambda < 0.2 || lambda > 0.8) @@ -1122,7 +1123,7 @@ protected: if(this->dimension() < 2) { std::cerr << "dim < 2: midpoint\n"; - return {midpoint_functor(pa, pb), va->cell(), va}; + return {exact(midpoint_functor(pa, pb)), va->cell(), va}; } if(debug().encroaching_vertices()) { @@ -1184,7 +1185,7 @@ protected: #if CGAL_CDT_3_DEBUG_CONFORMING std::cerr << " -> Steiner point: " << result_point << '\n'; #endif // CGAL_CDT_3_DEBUG_CONFORMING - return {result_point, reference_vertex->cell(), reference_vertex}; + return {exact(result_point), reference_vertex->cell(), reference_vertex}; }; const auto length_orig_ab = CGAL::approximate_sqrt(sq_length_functor(vector_orig_ab)); @@ -1236,7 +1237,7 @@ protected: std::cerr << " lambda = " << lambda << '\n'; std::cerr << " -> Steiner point: " << result_point << '\n'; #endif // CGAL_CDT_3_DEBUG_CONFORMING - return {result_point, reference_vertex->cell(), reference_vertex}; + return {exact(result_point), reference_vertex->cell(), reference_vertex}; } protected: diff --git a/Constrained_triangulation_3/test/Constrained_triangulation_3/cdt_3_from_off.cpp b/Constrained_triangulation_3/test/Constrained_triangulation_3/cdt_3_from_off.cpp index 6752c673fae..ca1920d78b1 100644 --- a/Constrained_triangulation_3/test/Constrained_triangulation_3/cdt_3_from_off.cpp +++ b/Constrained_triangulation_3/test/Constrained_triangulation_3/cdt_3_from_off.cpp @@ -123,8 +123,8 @@ Usage: cdt_3_from_off [options] input.off output.off --debug-geometric-errors: debug geometric error handling --debug-polygon-insertion: debug polygon insertion process --use-finite-edges-map: use a hash map for finite edges (default: false) - --use-epeck-for-normals: use exact kernel for normal computations (default: false) - --use-epeck-for-Steiner-points: use exact kernel for Steiner point computations (default: false) + --use-epeck-for-normals/--no-use-epeck-for-normals: use exact kernel for normal computations (default: true) + --use-epeck-for-Steiner-points/--no-use-epeck-for-Steiner-points: use exact kernel for Steiner point computations (default: true) --verbose/-V: verbose (can be used several times) --quiet: do not print anything @@ -261,6 +261,10 @@ CDT_options::CDT_options(int argc, char* argv[]) { debug_polygon_insertion = true; } else if(arg == "--use-finite-edges-map"sv) { use_finite_edges_map = true; + } else if(arg == "--no-use-epeck-for-normals"sv) { + use_epeck_for_normals = false; + } else if(arg == "--no-use-epeck-for-Steiner-points"sv) { + use_epeck_for_Steiner_points = false; } else if(arg == "--use-epeck-for-normals"sv) { use_epeck_for_normals = true; } else if(arg == "--use-epeck-for-Steiner-points"sv) {