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:
10
README.md
10
README.md
@@ -109,14 +109,12 @@ ConformalMesh mesh = load_mesh("input.off");
|
|||||||
EuclideanMaps maps = setup_euclidean_maps(mesh);
|
EuclideanMaps maps = setup_euclidean_maps(mesh);
|
||||||
compute_euclidean_lambda0_from_mesh(mesh, maps);
|
compute_euclidean_lambda0_from_mesh(mesh, maps);
|
||||||
|
|
||||||
// Assign DOFs — pin first vertex (gauge fix)
|
// Assign DOFs — pin first vertex as gauge fix, index the rest 0..n-1
|
||||||
auto vit = mesh.vertices().begin();
|
auto gauge = *mesh.vertices().begin();
|
||||||
maps.v_idx[*vit++] = -1;
|
int n = assign_euclidean_vertex_dof_indices(mesh, maps, gauge);
|
||||||
int idx = 0;
|
|
||||||
for (; vit != mesh.vertices().end(); ++vit) maps.v_idx[*vit] = idx++;
|
|
||||||
|
|
||||||
// Natural equilibrium target: x* = 0 by construction
|
// 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);
|
auto G0 = euclidean_gradient(mesh, x0, maps);
|
||||||
for (auto v : mesh.vertices())
|
for (auto v : mesh.vertices())
|
||||||
if (maps.v_idx[v] >= 0) maps.theta_v[v] -= G0[maps.v_idx[v]];
|
if (maps.v_idx[v] >= 0) maps.theta_v[v] -= G0[maps.v_idx[v]];
|
||||||
|
|||||||
@@ -59,13 +59,10 @@ int main(int argc, char* argv[])
|
|||||||
compute_euclidean_lambda0_from_mesh(mesh, maps);
|
compute_euclidean_lambda0_from_mesh(mesh, maps);
|
||||||
|
|
||||||
// ── Step 3: pin the first vertex (gauge fix) ──────────────────────────
|
// ── Step 3: pin the first vertex (gauge fix) ──────────────────────────
|
||||||
auto vit = mesh.vertices().begin();
|
// The gauge-vertex overload pins the chosen vertex (v_idx = -1) and
|
||||||
Vertex_index v_pinned = *vit++;
|
// assigns sequential indices 0..n-1 to the rest in a single call.
|
||||||
maps.v_idx[v_pinned] = -1; // pinned: u[v_pinned] = 0 (fixed)
|
Vertex_index v_pinned = *mesh.vertices().begin();
|
||||||
int idx = 0;
|
const int n = assign_euclidean_vertex_dof_indices(mesh, maps, v_pinned);
|
||||||
for (; vit != mesh.vertices().end(); ++vit)
|
|
||||||
maps.v_idx[*vit] = idx++;
|
|
||||||
const int n = idx;
|
|
||||||
|
|
||||||
std::cout << "[example_euclidean] DOFs: " << n << " (1 vertex pinned).\n";
|
std::cout << "[example_euclidean] DOFs: " << n << " (1 vertex pinned).\n";
|
||||||
|
|
||||||
|
|||||||
@@ -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 ──────────────
|
// ── 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)
|
static int pin_first(ConformalMesh& mesh, EuclideanMaps& maps)
|
||||||
{
|
{
|
||||||
auto vit = mesh.vertices().begin();
|
return assign_euclidean_vertex_dof_indices(
|
||||||
maps.v_idx[*vit++] = -1; // pinned
|
mesh, maps, *mesh.vertices().begin());
|
||||||
int idx = 0;
|
|
||||||
for (; vit != mesh.vertices().end(); ++vit)
|
|
||||||
maps.v_idx[*vit] = idx++;
|
|
||||||
return idx;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ── Main ─────────────────────────────────────────────────────────────────────
|
// ── Main ─────────────────────────────────────────────────────────────────────
|
||||||
|
|||||||
@@ -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 |
|
| U3 | `contracts.md:16` | Doc error | 🟡 Medium | ✅ Fixed 2026-05-31 |
|
||||||
| U4 | `README.md:17` | Stale | 🟡 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 |
|
| 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 |
|
| U7 | `getting-started.md` | Missing | 🟠 Minor | ✅ Fixed 2026-05-31 |
|
||||||
| U8 | `README.md` | Missing | 🟠 Minor | ✅ Fixed 2026-05-31 |
|
| U8 | `README.md` | Missing | 🟠 Minor | ✅ Fixed 2026-05-31 |
|
||||||
| U9 | `layout.hpp` + example | Missing | 🟠 Minor | 🟡 Open |
|
| U9 | `layout.hpp` + example | Missing | 🟠 Minor | 🟡 Open |
|
||||||
|
|||||||
Reference in New Issue
Block a user