Phase 8a MVP: CGAL traits + Discrete_conformal_map.h Euclidean entry
Some checks failed
C++ Tests / test-fast (push) Successful in 2m42s
C++ Tests / test-fast (pull_request) Successful in 3m44s
C++ Tests / test-cgal (push) Has been skipped
C++ Tests / test-cgal (pull_request) Failing after 4m28s

First step of the Phase 8 Hybrid MVP. Adds a thin CGAL-conformant public
API layer over the existing implementation, validated by 7 acceptance
tests.  Total CGAL test count: 183 (was 176), 0 skipped.

New public headers
──────────────────
* code/include/CGAL/Conformal_map_traits.h
    - ConformalMapTraits concept documentation
    - Default_conformal_map_traits<Surface_mesh<P>, K> specialisation
    - Static property-map accessors: vertex_points, theta_map,
      vertex_index_map, lambda0_map

* code/include/CGAL/Discrete_conformal_map.h
    - User-facing entry: discrete_conformal_map_euclidean(mesh, np)
    - Conformal_map_result<FT> struct (u, iter, ‖G‖, converged flags)
    - Natural-theta default: x = 0 is the equilibrium when no Θ supplied
    - Honours user-provided Θ via vertex_curvature_map named parameter

* code/include/CGAL/Conformal_map/internal/parameters.h
    - 4 named-parameter tags in CGAL::Conformal_map::internal_np:
        vertex_curvature_map, gradient_tolerance,
        max_iterations,       fixed_vertex_map
    - User-facing helpers in CGAL::parameters::*

Tests (test_cgal_traits_mvp.cpp, 7 cases)
─────────────────────────────────────────
* DefaultTraitsTypes:       compile-time type sanity (static_assert)
* AccessorsReuseExistingMaps: traits accessors return identical pmaps
* SingleTriangleConverges,
  QuadStripConverges:       end-to-end Euclidean wrapper passes
* MaxIterationsTakesEffect: named parameter is read
* GradientToleranceTakesEffect: tolerance override changes Newton end-state
* WrapperMatchesLegacyAPI:  cross-API result equality at 1e-10

Architecture
────────────
3-layer wrapper as designed (doc/api/cgal-package.md):
  Layer 1: code/include/*.hpp           (existing algorithms, unchanged)
  Layer 2: CGAL/Conformal_map/internal/ (adapter, parameter tags)
  Layer 3: CGAL/Conformal_map_traits.h, CGAL/Discrete_conformal_map.h
                                         (user-facing)

No algorithm duplication.  Existing 176 + 36 tests untouched.

Next: Phase 9a (Inversive-Distance) as the second client of this API —
the real acceptance test for the trait design.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Tarik Moussa
2026-05-19 22:07:15 +02:00
parent e429539c9b
commit a1e74c1370
5 changed files with 771 additions and 0 deletions

View File

@@ -0,0 +1,127 @@
// Copyright (c) 2024-2026 Tarik Moussa.
// SPDX-License-Identifier: MIT
//
// Package: conformallab++ / Discrete_conformal_map (Phase 8 MVP, 2026-05-19)
/*!
\file CGAL/Conformal_map/internal/parameters.h
\internal
\ingroup PkgConformalMapRef
Named-parameter tag definitions specific to the Discrete_conformal_map
package. These tags extend the CGAL named-parameter mechanism
(see `<CGAL/Named_function_parameters.h>`).
Usage from a user perspective is in `CGAL::parameters::*`; the tags
themselves live in `CGAL::Conformal_map::internal_np`.
This is an internal header — users should not include it directly.
*/
#ifndef CGAL_CONFORMAL_MAP_INTERNAL_PARAMETERS_H
#define CGAL_CONFORMAL_MAP_INTERNAL_PARAMETERS_H
#include <CGAL/Named_function_parameters.h>
namespace CGAL {
namespace Conformal_map {
/// \internal
/// Parameter tags for the conformal-map package. Each tag is an
/// `enum` whose name ends in `_t` and a value whose name does not.
/// The pattern follows CGAL convention so that the existing
/// `choose_parameter` / `get_parameter` machinery works directly.
namespace internal_np {
// ─── Target curvature (Θᵥ) ──────────────────────────────────────────────────
/// Property-map: vertex_descriptor → FT (target cone angle Θᵥ in radians).
/// Default: 2π at every interior vertex, π at every boundary vertex.
enum vertex_curvature_map_t { vertex_curvature_map };
// ─── Newton solver tolerances ───────────────────────────────────────────────
/// Convergence threshold for the Newton solver: ‖G(u)‖∞ < tol.
/// Type: FT. Default: 1e-10.
enum gradient_tolerance_t { gradient_tolerance };
/// Maximum number of Newton iterations.
/// Type: int. Default: 200.
/// (Reuses the CGAL `number_of_iterations` tag where appropriate; this
/// alias is provided for vocabulary continuity within the package.)
enum max_iterations_t { max_iterations };
// ─── DOF / gauge fixing ─────────────────────────────────────────────────────
/// Property-map: vertex_descriptor → bool. `true` ⇒ vertex is pinned
/// (u_v = 0, removed from the Newton DOF vector).
/// Default: first vertex is pinned, all others are variable.
enum fixed_vertex_map_t { fixed_vertex_map };
} // namespace internal_np
} // namespace Conformal_map
namespace parameters {
/*!
\addtogroup PkgConformalMapNamedParameters
\{
*/
/// \name Discrete conformal map — package-specific named parameters
/// \{
/// `vertex_curvature_map(pmap)` — target cone angle Θᵥ per vertex.
/// Type: model of `ReadablePropertyMap` with key = `vertex_descriptor`,
/// value = `FT`. If omitted, the package uses 2π at interior vertices
/// and π at boundary vertices (the natural GaussBonnet target for an
/// open disk or closed flat surface).
template <typename PropertyMap>
auto vertex_curvature_map(const PropertyMap& pmap)
{
return CGAL::Named_function_parameters<
PropertyMap,
Conformal_map::internal_np::vertex_curvature_map_t,
CGAL::internal_np::No_property
>(pmap);
}
/// `gradient_tolerance(eps)` — Newton stopping criterion ‖G‖∞ < eps.
template <typename FT>
auto gradient_tolerance(FT eps)
{
return CGAL::Named_function_parameters<
FT,
Conformal_map::internal_np::gradient_tolerance_t,
CGAL::internal_np::No_property
>(eps);
}
/// `max_iterations(n)` — Newton iteration limit.
inline auto max_iterations(int n)
{
return CGAL::Named_function_parameters<
int,
Conformal_map::internal_np::max_iterations_t,
CGAL::internal_np::No_property
>(n);
}
/// `fixed_vertex_map(pmap)` — which vertices are pinned for gauge-fixing.
/// Type: model of `ReadablePropertyMap` with key = `vertex_descriptor`,
/// value = `bool`. If omitted, the first vertex in the mesh is pinned
/// (compatible with the existing legacy API).
template <typename PropertyMap>
auto fixed_vertex_map(const PropertyMap& pmap)
{
return CGAL::Named_function_parameters<
PropertyMap,
Conformal_map::internal_np::fixed_vertex_map_t,
CGAL::internal_np::No_property
>(pmap);
}
/// \}
/// \}
} // namespace parameters
} // namespace CGAL
#endif // CGAL_CONFORMAL_MAP_INTERNAL_PARAMETERS_H