Phase 8b-Lite extension: output_uv_map named parameter for integrated layout
Some checks failed
C++ Tests / test-fast (push) Successful in 2m8s
C++ Tests / test-fast (pull_request) Successful in 2m20s
API Docs / doc-build (pull_request) Successful in 47s
C++ Tests / test-cgal (push) Has been skipped
C++ Tests / test-cgal (pull_request) Failing after 10m45s

Closes the UX gap identified in the Phase-8b-Lite design discussion:
the four classical-DCE CGAL entries now optionally run their `*_layout()`
step internally if the caller supplies `CGAL::parameters::output_uv_map(pmap)`.

Before this PR, the workflow was:

    auto res = CGAL::discrete_conformal_map_euclidean(mesh);
    // ... user has to re-set up maps, re-pin vertex, then ...
    auto layout = euclidean_layout(mesh, res.x, maps);
    // ... and copy coordinates into a property map manually.

After this PR:

    auto uv = mesh.add_property_map<Vertex_index, K::Point_2>("uv", ...).first;
    CGAL::discrete_conformal_map_euclidean(
        mesh, CGAL::parameters::output_uv_map(uv));
    // ... uv now populated for every vertex.

Coverage
────────
* `discrete_conformal_map_euclidean`  — `Point_2` per vertex.
* `discrete_conformal_map_spherical`  — `Point_3` per vertex (on S²).
* `discrete_conformal_map_hyper_ideal` — `Point_2` per vertex (Poincaré disk).

CP-Euclidean and Inversive-Distance entries do not yet support
`output_uv_map` — face-based packing has no per-vertex UV concept, and
inversive-distance needs a dedicated layout routine that uses Luo's
edge-length formula (planned follow-up).

New named parameters (`code/include/CGAL/Conformal_map/internal/parameters.h`)
─────────────────────────────────────────────────────────────────────────────
* `output_uv_map(pmap)` — write coordinates into pmap after layout.
* `normalise_layout(bool)` — apply post-layout canonical normalisation
  (PCA centroid for Euclidean, north-pole alignment for Spherical,
  Möbius centring for Hyper-ideal).

Both follow the existing Phase-8a-MVP named-parameter convention.
Chained syntax (`.output_uv_map(...).normalise_layout(true)`) is not
yet supported — pass them one at a time.

Tests (5 new in test_cgal_phase8b_lite.cpp)
───────────────────────────────────────────
* `OutputUvMap_Euclidean_PopulatesPmap`         — UVs are finite + non-trivial.
* `OutputUvMap_Spherical_PopulatesXyz`          — every output on unit S².
* `OutputUvMap_HyperIdeal_PointsInPoincareDisk` — |p|² ≤ 1 if converged.
* `OutputUvMap_Absent_DoesNotRunLayout`         — no parameter ⇒ no layout.
* `OutputUvMap_NormaliseLayout_TakesEffect`     — both raw + norm calls
  return finite UVs (named-parameter chaining limitation documented).

All five pass.  Full CGAL suite: 232/232, 0 skipped (was 227).

doc/api/tests.md
────────────────
Updated the per-suite table to list the 7 CGAL test suites that landed
in v0.9.0 (8a MVP + 9a + 9b + 8b-Lite) but had not yet been added to the
canonical table.  Total: 227 → 232.  This brings the doc back in sync
with `ctest` output and unblocks future `scripts/check-test-counts.sh`
runs.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Tarik Moussa
2026-05-22 08:40:37 +02:00
parent e67ccd6b9d
commit 15f6baa00b
4 changed files with 266 additions and 1 deletions

View File

@@ -55,6 +55,23 @@ enum max_iterations_t { max_iterations };
/// Default: first vertex is pinned, all others are variable.
enum fixed_vertex_map_t { fixed_vertex_map };
// ─── Layout output (Phase 8b-Lite extension) ────────────────────────────────
/// Property-map: vertex_descriptor → 2-D / 3-D coordinate. If provided,
/// the entry function calls the appropriate `*_layout()` after Newton
/// convergence and writes the per-vertex coordinates into this map:
/// - Euclidean / Hyper-ideal / Inversive-Distance: `Point_2` (UV in ℝ²)
/// - Spherical: `Point_3` (point on S² ⊂ ℝ³)
/// If the parameter is absent, no layout step is performed. Callers
/// who need finer control should run `*_layout()` directly on
/// `result.x` plus the maps from `setup_*_maps()`.
enum output_uv_map_t { output_uv_map };
/// Boolean flag: if `true`, apply the canonical post-layout
/// normalisation (`normalise_euclidean` PCA centroid + axis,
/// `normalise_spherical` Rodrigues to north pole, …) before writing
/// into `output_uv_map`. Default: `false`.
enum normalise_layout_t { normalise_layout };
} // namespace internal_np
} // namespace Conformal_map
@@ -118,6 +135,40 @@ auto fixed_vertex_map(const PropertyMap& pmap)
>(pmap);
}
/// `output_uv_map(pmap)` — write the per-vertex layout coordinates
/// into `pmap` after Newton converges.
///
/// Type: model of `WritablePropertyMap` with key = `vertex_descriptor`
/// and value either `Point_2` (Euclidean / Hyper-ideal / Inversive-
/// Distance entries) or `Point_3` (Spherical entry).
///
/// Implementation: the entry function runs the appropriate
/// `*_layout()` from `code/include/layout.hpp` after Newton, then
/// writes one coordinate per vertex into `pmap`. If omitted, no
/// layout is performed.
template <typename PropertyMap>
auto output_uv_map(const PropertyMap& pmap)
{
return CGAL::Named_function_parameters<
PropertyMap,
Conformal_map::internal_np::output_uv_map_t,
CGAL::internal_np::No_property
>(pmap);
}
/// `normalise_layout(flag)` — apply the canonical post-layout
/// normalisation (PCA centroid for Euclidean; north-pole alignment
/// for Spherical; Möbius centring for Hyper-ideal). Default: `false`.
/// Only meaningful in combination with `output_uv_map`.
inline auto normalise_layout(bool flag)
{
return CGAL::Named_function_parameters<
bool,
Conformal_map::internal_np::normalise_layout_t,
CGAL::internal_np::No_property
>(flag);
}
/// \}
/// \}