diff --git a/code/include/CGAL/Discrete_conformal_map.h b/code/include/CGAL/Discrete_conformal_map.h index 64a0773..64de271 100644 --- a/code/include/CGAL/Discrete_conformal_map.h +++ b/code/include/CGAL/Discrete_conformal_map.h @@ -52,8 +52,10 @@ auto result = CGAL::discrete_conformal_map_euclidean( #include #include +#include #include #include +#include // Existing implementation headers (Layer 1 — unchanged). #include "../euclidean_functional.hpp" @@ -147,9 +149,21 @@ auto discrete_conformal_map_euclidean( TriangleMesh& mesh, const CGAL_NP_CLASS& np = parameters::default_values()) { - using Traits = Default_conformal_map_traits>; - using FT = typename Traits::FT; - using Vertex_descriptor = typename Traits::Vertex_descriptor; + // ── Type plumbing ────────────────────────────────────────────────────── + // + // Deduce the kernel from the mesh's Point_3 type rather than hard-coding + // Simple_cartesian. This lets the wrapper work with any + // Surface_mesh

whose P is a CGAL kernel point. The user can override + // the entire traits class via the `geom_traits(...)` named parameter + // (Phase 8b.2 extension; default below covers the common case). + using Point_type = typename TriangleMesh::Point; + using Default_kernel = typename CGAL::Kernel_traits::Kernel; + using Default_traits = Default_conformal_map_traits; + using Traits = typename internal_np::Lookup_named_param_def< + internal_np::geom_traits_t, + CGAL_NP_CLASS, + Default_traits>::type; + using FT = typename Traits::FT; Conformal_map_result result; diff --git a/code/tests/cgal/test_cgal_traits_mvp.cpp b/code/tests/cgal/test_cgal_traits_mvp.cpp index ba6859b..4d2f1dc 100644 --- a/code/tests/cgal/test_cgal_traits_mvp.cpp +++ b/code/tests/cgal/test_cgal_traits_mvp.cpp @@ -17,6 +17,7 @@ #include #include +#include #include "mesh_builder.hpp" // make_triangle, make_quad_strip, make_tetrahedron #include "euclidean_functional.hpp" @@ -169,6 +170,36 @@ TEST(CGALDiscreteConformalMap, GradientToleranceTakesEffect) // match what newton_euclidean produces directly. // ════════════════════════════════════════════════════════════════════════════ +// ════════════════════════════════════════════════════════════════════════════ +// 6. Kernel deduction: the wrapper must NOT hard-code Simple_cartesian +// +// Regression guard: the wrapper deduces its kernel from the mesh point type +// via `CGAL::Kernel_traits`. If anyone re-introduces a hard-coded +// `Simple_cartesian` in the wrapper, the static_asserts here still +// pass (the legacy ConformalMesh uses that kernel) — but Phase 9a or any +// user with a different kernel-backed Surface_mesh would fail to compile. +// This test pins the deduction *contract* explicitly. +// ════════════════════════════════════════════════════════════════════════════ + +TEST(CGALDiscreteConformalMap, KernelIsDeducedFromMeshPointType) +{ + using Mesh = ConformalMesh; + using P = typename Mesh::Point; + + using DeducedKernel = typename CGAL::Kernel_traits

::Kernel; + using DeducedTraits = CGAL::Default_conformal_map_traits; + + static_assert(std::is_same_v>, + "ConformalMesh point type must deduce to Simple_cartesian"); + static_assert(std::is_same_v); + static_assert(std::is_same_v); + + // Run-time sanity: the wrapper accepts the deduced-kernel mesh end-to-end. + auto mesh = make_quad_strip(); + auto result = CGAL::discrete_conformal_map_euclidean(mesh); + EXPECT_TRUE(result.converged); +} + TEST(CGALDiscreteConformalMap, WrapperMatchesLegacyAPI) { auto mesh = make_quad_strip();