docs(examples): use gauge-vertex overload everywhere (U6)

Finding-U6 from doc/reviewer/usability-audit-2026-05-31.md.

The Finding-D fix (external-audit-2026-05-30) added a clean one-call
gauge-vertex overload:
  assign_euclidean_vertex_dof_indices(mesh, maps, gauge_vertex)

But all user-facing code still showed the old verbose manual loop:
  auto vit = mesh.vertices().begin();
  maps.v_idx[*vit++] = -1;
  int idx = 0;
  for (; vit != mesh.vertices().end(); ++vit) maps.v_idx[*vit] = idx++;

Replaced in three places:
  README.md 'Minimal usage' code block
  example_euclidean.cpp Step 3
  example_layout.cpp  pin_first() helper

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Tarik Moussa
2026-05-31 01:49:05 +02:00
parent d1399ca82f
commit ccbfd852b2
4 changed files with 14 additions and 20 deletions

View File

@@ -109,14 +109,12 @@ ConformalMesh mesh = load_mesh("input.off");
EuclideanMaps maps = setup_euclidean_maps(mesh);
compute_euclidean_lambda0_from_mesh(mesh, maps);
// Assign DOFs — pin first vertex (gauge fix)
auto vit = mesh.vertices().begin();
maps.v_idx[*vit++] = -1;
int idx = 0;
for (; vit != mesh.vertices().end(); ++vit) maps.v_idx[*vit] = idx++;
// Assign DOFs — pin first vertex as gauge fix, index the rest 0..n-1
auto gauge = *mesh.vertices().begin();
int n = assign_euclidean_vertex_dof_indices(mesh, maps, gauge);
// Natural equilibrium target: x* = 0 by construction
std::vector<double> x0(idx, 0.0);
std::vector<double> x0(static_cast<std::size_t>(n), 0.0);
auto G0 = euclidean_gradient(mesh, x0, maps);
for (auto v : mesh.vertices())
if (maps.v_idx[v] >= 0) maps.theta_v[v] -= G0[maps.v_idx[v]];

View File

@@ -59,13 +59,10 @@ int main(int argc, char* argv[])
compute_euclidean_lambda0_from_mesh(mesh, maps);
// ── Step 3: pin the first vertex (gauge fix) ──────────────────────────
auto vit = mesh.vertices().begin();
Vertex_index v_pinned = *vit++;
maps.v_idx[v_pinned] = -1; // pinned: u[v_pinned] = 0 (fixed)
int idx = 0;
for (; vit != mesh.vertices().end(); ++vit)
maps.v_idx[*vit] = idx++;
const int n = idx;
// The gauge-vertex overload pins the chosen vertex (v_idx = -1) and
// assigns sequential indices 0..n-1 to the rest in a single call.
Vertex_index v_pinned = *mesh.vertices().begin();
const int n = assign_euclidean_vertex_dof_indices(mesh, maps, v_pinned);
std::cout << "[example_euclidean] DOFs: " << n << " (1 vertex pinned).\n";

View File

@@ -54,14 +54,13 @@ static void set_natural_theta(ConformalMesh& mesh, EuclideanMaps& maps, int n)
}
// ── Helper: pin vertex 0, assign DOF indices 0..n-1 to the rest ──────────────
// Uses the gauge-vertex overload introduced in external-audit Finding-D:
// assign_euclidean_vertex_dof_indices(mesh, maps, gauge) pins the chosen
// vertex and assigns sequential indices in a single pass.
static int pin_first(ConformalMesh& mesh, EuclideanMaps& maps)
{
auto vit = mesh.vertices().begin();
maps.v_idx[*vit++] = -1; // pinned
int idx = 0;
for (; vit != mesh.vertices().end(); ++vit)
maps.v_idx[*vit] = idx++;
return idx;
return assign_euclidean_vertex_dof_indices(
mesh, maps, *mesh.vertices().begin());
}
// ── Main ─────────────────────────────────────────────────────────────────────

View File

@@ -541,7 +541,7 @@ exposed via the CGAL public API, but a CLI user cannot reach them.
| U3 | `contracts.md:16` | Doc error | 🟡 Medium | ✅ Fixed 2026-05-31 |
| U4 | `README.md:17` | Stale | 🟡 Medium | ✅ Fixed 2026-05-31 |
| U5 | `Discrete_conformal_map.h:14` | Stale | 🟡 Medium | ✅ Fixed 2026-05-31 |
| U6 | README + 2 examples | Stale | 🟡 Medium | 🟡 Open |
| U6 | README + 2 examples | Stale | 🟡 Medium | ✅ Fixed 2026-05-31 |
| U7 | `getting-started.md` | Missing | 🟠 Minor | ✅ Fixed 2026-05-31 |
| U8 | `README.md` | Missing | 🟠 Minor | ✅ Fixed 2026-05-31 |
| U9 | `layout.hpp` + example | Missing | 🟠 Minor | 🟡 Open |