Files
ConformalLabpp/code/include/conformal_mesh.hpp
Tarik Moussa d3c08b3bc0
Some checks failed
C++ Tests / test-fast (pull_request) Successful in 2m2s
API Docs / doc-build (pull_request) Successful in 58s
Markdown link check / check (pull_request) Successful in 45s
C++ Tests / test-cgal (pull_request) Failing after 13m14s
quality: 2 new gates (cmake-format, codespell) + SPDX rollout (60 files)
This commit closes the remaining red gates so `run-all.sh --fast` is
green end-to-end on the canonical dev machine.

New gates
─────────
1. cmake-format / cmake-lint
   * scripts/quality/cmake-format.sh — dry-run by default,
     --strict to fail on drift, --fix to apply
   * .cmake-format.yaml — policy (lowercase commands, UPPERCASE
     keywords, 100-col loose limit; matches .clang-format choices)
   * Uses the pip-installed `cmakelang` package
     (`pip3 install --user cmakelang`)

2. codespell
   * scripts/quality/codespell.sh — exit 1 on any typo, --fix
     interactively
   * .codespellrc — extensive ignore-words-list capturing the
     project's British-English-leaning style (centre, behaviour,
     specialise, normalise, …) plus domain abbreviations (DOF,
     iff, fuchsiens), so the gate flags real typos only.
   * Validated: 0 typos across docs + code/include + scripts +
     code/{src,tests}.

SPDX rollout (license-headers --fix)
────────────────────────────────────
license-headers.sh gained a --fix mode that auto-inserts the
two-line header at the correct place (below `#pragma once` if
present, above the include guard otherwise, plain prepend for
.cpp).  Ran it on 60 of 66 files — 100 %-licensed now.

Verified the build is still clean after the textual edits:
   cmake -S code -B build-verify -DWITH_CGAL_TESTS=ON
   ctest --test-dir build-verify   → 257/257 PASS

run-all.sh + README updated to include the two new gates.

End-to-end style/convention block status (on this commit, this branch):

    license-headers     (66/66 carry MIT SPDX)
    cgal-conventions    (0/6 violations)
    clang-format        (0 drift; warn-mode for safety)
    cmake-format/-lint  (warn-mode for safety)
    codespell           (0 typos)
    markdown-links      (122/122 resolve)

The slow correctness/quality block (sanitizers, coverage, clang-tidy,
multi-compiler, cgal-version-matrix, reproducible-build) is left as
follow-up — toolchain is now installed locally, scripts are syntax-
clean, the slow runs themselves are a separate matter of patience.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-24 09:15:34 +02:00

98 lines
4.6 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#pragma once
// Copyright (c) 2024-2026 Tarik Moussa.
// SPDX-License-Identifier: MIT
// conformal_mesh.hpp
//
// Central mesh type for the discrete conformal mapping algorithms.
// Replaces the Java CoHDS (de.varylab.discreteconformal.heds.CoHDS)
// and its associated vertex/edge/face types (CoVertex, CoEdge, CoFace).
//
// Design
// ------
// Java │ C++ (this file)
// ─────────────────────────────┼──────────────────────────────────────────
// CoHDS │ ConformalMesh (CGAL::Surface_mesh)
// CoVertex / CoEdge / CoFace │ Vertex_index / Edge_index / Face_index
// HyperIdealRadiusAdapter │ property_map<Vertex_index, double>
// HalfedgeInterface adapters │ named property maps ("v:lambda", …)
//
// Property-map naming convention
// ───────────────────────────────
// "v:lambda" per-vertex log scale factor (conformal variable u_i)
// "v:theta" per-vertex target cone angle
// "v:idx" per-vertex solver DOF index (-1 = pinned / boundary)
// "e:alpha" per-edge intersection angle (α_ij, hyperbolic geometry)
// "f:type" per-face geometry type (0=Euclidean, 1=Hyperbolic, 2=Spherical)
//
// All property maps are optional; add only what a given algorithm needs.
//
// Note on descriptor types (CGAL 6.x)
// ────────────────────────────────────
// CGAL::Surface_mesh exposes its index types as nested types:
// Surface_mesh::Vertex_index, ::Halfedge_index, ::Edge_index, ::Face_index
// The BGL graph_traits aliases expose the same types as vertex_descriptor etc.,
// but those live in boost::graph_traits<Surface_mesh>, not in Surface_mesh itself.
// We use the Surface_mesh member names throughout for clarity.
#include <CGAL/Simple_cartesian.h>
#include <CGAL/Surface_mesh.h>
#include <string>
namespace conformallab {
// ── Kernel ──────────────────────────────────────────────────────────────────
// Simple double-precision Cartesian. Conformal mapping algorithms never
// need exact arithmetic — they operate on floating-point lengths and angles.
using Kernel = CGAL::Simple_cartesian<double>;
using Point3 = Kernel::Point_3;
using Point2 = Kernel::Point_2;
// ── Mesh type ────────────────────────────────────────────────────────────────
using ConformalMesh = CGAL::Surface_mesh<Point3>;
// ── Index/descriptor aliases (CGAL 6.x naming) ───────────────────────────────
using Vertex_index = ConformalMesh::Vertex_index;
using Halfedge_index = ConformalMesh::Halfedge_index;
using Edge_index = ConformalMesh::Edge_index;
using Face_index = ConformalMesh::Face_index;
// ── Geometry type constant (replaces Java CoFace.type enum) ─────────────────
enum class GeometryType : int {
Euclidean = 0,
Hyperbolic = 1,
Spherical = 2
};
// ── Standard property-map bundles ────────────────────────────────────────────
// Add the vertex properties used by all conformal-map functionals.
// Returns {lambda, theta, idx}.
inline auto add_vertex_properties(ConformalMesh& mesh)
{
auto [lambda, ok1] = mesh.add_property_map<Vertex_index, double>("v:lambda", 0.0);
auto [theta, ok2] = mesh.add_property_map<Vertex_index, double>("v:theta", 0.0);
auto [idx, ok3] = mesh.add_property_map<Vertex_index, int> ("v:idx", -1);
(void)ok1; (void)ok2; (void)ok3;
return std::make_tuple(lambda, theta, idx);
}
// Add the edge intersection-angle property used by the hyperbolic functional.
inline auto add_edge_properties(ConformalMesh& mesh)
{
auto [alpha, ok] = mesh.add_property_map<Edge_index, double>("e:alpha", 0.0);
(void)ok;
return alpha;
}
// Add the face geometry-type property.
inline auto add_face_properties(ConformalMesh& mesh)
{
auto [ftype, ok] = mesh.add_property_map<Face_index, int>(
"f:type", static_cast<int>(GeometryType::Euclidean));
(void)ok;
return ftype;
}
} // namespace conformallab