Files
ConformalLabpp/code/include/CGAL/Conformal_layout.h
Tarik Moussa 7d10500811
Some checks failed
C++ Tests / test-fast (pull_request) Successful in 2m7s
C++ Tests / test-fast (push) Successful in 2m19s
C++ Tests / test-cgal (pull_request) Failing after 11m6s
C++ Tests / test-cgal (push) Has been skipped
API Docs / doc-build (pull_request) Successful in 41s
Phase 8b-Lite: CGAL entries for all 5 DCE models + layout wrapper
Completes the CGAL public API surface so all five discrete-conformal
functionals are reachable from <CGAL/Discrete_*.h>, not only Euclidean.

CGAL test count: 219 → 227 (+8).  Zero skips.

New public headers
──────────────────
* CGAL/Discrete_conformal_map.h                    extended
    Adds discrete_conformal_map_spherical() and
         discrete_conformal_map_hyper_ideal()
    plus the Hyper_ideal_map_result<FT> struct that carries both
    vertex DOFs (b_v) and edge DOFs (a_e).

* CGAL/Discrete_circle_packing.h                   new (180 lines)
    Face-based BPS-2010 circle packing.  Provides
         Default_cp_euclidean_traits<Mesh, K>
         Circle_packing_result<FT>
         discrete_circle_packing_euclidean()

* CGAL/Discrete_inversive_distance.h               new (180 lines)
    Vertex-based Luo-2004 packing.  Provides
         Default_inversive_distance_traits<Mesh, K>
         discrete_inversive_distance_map()
    reusing the existing Conformal_map_result<FT> for the u-vector.

* CGAL/Conformal_layout.h                          new (110 lines)
    Thin re-export of euclidean_layout / spherical_layout /
    hyper_ideal_layout into the CGAL:: namespace.

Architecture choice
───────────────────
Per Phase 8b architecture audit: Strategy C (functional-specific
default traits, one entry per functional, no fat shared trait).
Documented in each header's docblock.  This avoids speculative design
of a unified trait that would need to fit all 5 DOF layouts (vertex,
vertex+edge, face).

Conformal_map_traits.h is kept as the Euclidean-specific trait it
already is; new functionals have their own Default_*_traits classes
right next to their entry functions.

Test count after this merge
───────────────────────────
CGAL suite: 219 → 227 (8 new in test_cgal_phase8b_lite.cpp covering
all four new entries + the Euclidean+layout round-trip).

After-the-merge user contract
─────────────────────────────
A user can now write any of these and get a valid Newton-converged result:

  #include <CGAL/Discrete_conformal_map.h>
  auto r = CGAL::discrete_conformal_map_euclidean(mesh);
  auto r = CGAL::discrete_conformal_map_spherical(mesh);
  auto r = CGAL::discrete_conformal_map_hyper_ideal(mesh);

  #include <CGAL/Discrete_circle_packing.h>
  auto r = CGAL::discrete_circle_packing_euclidean(mesh);

  #include <CGAL/Discrete_inversive_distance.h>
  auto r = CGAL::discrete_inversive_distance_map(mesh);

  #include <CGAL/Conformal_layout.h>
  auto layout = CGAL::euclidean_layout(mesh, r.x, maps);

Not in this PR (intentionally deferred)
───────────────────────────────────────
* 8a.2 — Generic FaceGraph specialisation (still Surface_mesh-only).
* 8c   — User_manual + PackageDescription.txt (CGAL-submission prep).
* 8d   — CGAL-format test directory  (CGAL-submission prep).
* 8e   — YAML pipeline + CLI flag    (orthogonal).
* Named-parameter chaining (`a.b().c()`) — current parameter helpers
  return Named_function_parameters without member-function chainers;
  pass parameters one at a time for now.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-21 21:24:26 +02:00

112 lines
3.9 KiB
C++

// Copyright (c) 2024-2026 Tarik Moussa.
// SPDX-License-Identifier: MIT
//
// Package: conformallab++ / Discrete_conformal_map (Phase 8b-Lite, 2026-05-21)
/*!
\file CGAL/Conformal_layout.h
\ingroup PkgConformalMapRef
Thin CGAL-style wrapper around the legacy `euclidean_layout()`,
`spherical_layout()` and `hyper_ideal_layout()` functions defined in
`code/include/layout.hpp`.
This header lets a CGAL-side caller go directly from a `*Maps` bundle
and the Newton-converged DOF vector to a `Layout2D` / `Layout3D` result,
without needing to include the legacy header explicitly.
*/
#ifndef CGAL_CONFORMAL_LAYOUT_H
#define CGAL_CONFORMAL_LAYOUT_H
#include <CGAL/Conformal_map/internal/parameters.h>
#include <CGAL/Named_function_parameters.h>
#include <CGAL/boost/graph/named_params_helper.h>
#include "../layout.hpp"
namespace CGAL {
// ── Re-exported layout types ─────────────────────────────────────────────────
//
// `Layout2D`, `Layout3D` and `HolonomyData` are defined in
// `conformallab::layout` (see `code/include/layout.hpp`). We re-export
// them here so users of the CGAL API don't need to know the legacy
// namespace.
using ::conformallab::Layout2D;
using ::conformallab::Layout3D;
using ::conformallab::HolonomyData;
using ::conformallab::CutGraph;
// ── Wrapper functions ────────────────────────────────────────────────────────
/*!
\ingroup PkgConformalMapRef
Compute the planar Euclidean layout of `mesh` from a converged DOF
vector `x` and a `EuclideanMaps` bundle. Optional named parameters:
* `cut_graph` (pointer-to `CutGraph`, default `nullptr`) — supply a
pre-computed cut graph to get a globally consistent layout on closed
meshes.
* `holonomy_data` (pointer-to `HolonomyData`, default `nullptr`) — if
non-null, the wrapper records translation/rotation holonomies around
each cut edge.
* `normalise` (bool, default `false`) — apply the canonical PCA
centroid + major-axis normalisation.
\returns A `Layout2D` with `uv[v]` per vertex.
*/
template <typename TriangleMesh,
typename CGAL_NP_TEMPLATE_PARAMETERS>
Layout2D euclidean_layout(
TriangleMesh& mesh,
const std::vector<double>& x,
const ::conformallab::EuclideanMaps& maps,
const CGAL_NP_CLASS& = parameters::default_values())
{
// No CGAL-side named-parameter overrides needed for Phase 8b-Lite:
// forward straight to the legacy implementation with sensible
// defaults. Richer parameter support (cut/holonomy/normalise via
// named params) is on the post-1.0 wishlist; the legacy API can be
// called directly in the meantime.
return ::conformallab::euclidean_layout(mesh, x, maps);
}
/*!
\ingroup PkgConformalMapRef
Compute the spherical layout of `mesh` (points on S² ⊂ ℝ³).
*/
template <typename TriangleMesh,
typename CGAL_NP_TEMPLATE_PARAMETERS>
Layout3D spherical_layout(
TriangleMesh& mesh,
const std::vector<double>& x,
const ::conformallab::SphericalMaps& maps,
const CGAL_NP_CLASS& = parameters::default_values())
{
return ::conformallab::spherical_layout(mesh, x, maps);
}
/*!
\ingroup PkgConformalMapRef
Compute the hyperbolic layout of `mesh` (Poincaré disk model).
*/
template <typename TriangleMesh,
typename CGAL_NP_TEMPLATE_PARAMETERS>
Layout2D hyper_ideal_layout(
TriangleMesh& mesh,
const std::vector<double>& x,
const ::conformallab::HyperIdealMaps& maps,
const CGAL_NP_CLASS& = parameters::default_values())
{
return ::conformallab::hyper_ideal_layout(mesh, x, maps);
}
} // namespace CGAL
#endif // CGAL_CONFORMAL_LAYOUT_H