examples: add real conformal-flattening + CGAL-API examples (U1+U2)
Finding-U1 and Finding-U2 from doc/reviewer/usability-audit-2026-05-31.md.
The existing examples (example_euclidean, example_layout, example_hyper_ideal)
all used the "natural theta" pattern which makes x*=0 trivially the
equilibrium — u_v ≈ 0 everywhere, no deformation. A new user following
these examples saw solver output but not conformal geometry.
New: example_flatten.cpp
- PRIMARY USE CASE: conformally flatten a mesh to the plane
- Sets Θ_v = 2π for all interior vertices (flat target)
- Pins boundary vertices (no Gauss-Bonnet check for open meshes)
- Demonstrates non-trivial u_v (cathead.obj: range ≈ 2.96, 5 Newton iters)
- Documents the difference from "natural theta" explicitly
New: example_cgal_api.cpp
- Demonstrates CGAL::discrete_conformal_map_euclidean (Discrete_conformal_map.h)
- First runnable CGAL public API example; contrast with internal API
- Documents the "natural theta" default behaviour and explains why u_v=0
- Explains when to use CGAL API vs internal API
Both examples registered in code/examples/CMakeLists.txt and compile
cleanly with -DWITH_CGAL=ON.
Updated:
- example_euclidean.cpp: prominent "TESTING CONVENTION" warning
- example_layout.cpp: same warning on set_natural_theta helper
- doc/getting-started.md: example_flatten is now the recommended
"start here" example; note on natural-theta behaviour added
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -117,13 +117,34 @@ After a full build (`-DWITH_CGAL=ON`):
|
||||
## Example programs
|
||||
|
||||
```bash
|
||||
# PRIMARY USE CASE: conformally flatten a mesh to the plane
|
||||
./build/examples/example_flatten code/data/obj/cathead.obj flat.off
|
||||
# → non-trivial u_v (e.g. range ≈ 2.96), real conformal deformation
|
||||
|
||||
# CGAL public API: one-call interface (natural theta by default)
|
||||
./build/examples/example_cgal_api [input.off]
|
||||
|
||||
# Full pipeline with JSON/XML serialisation and round-trip test
|
||||
./build/examples/example_layout [input.off] [layout.off] [result.json]
|
||||
|
||||
# Solver test (natural theta — u_v ≈ 0, used for pipeline validation)
|
||||
./build/examples/example_euclidean [input.off] [output.off]
|
||||
|
||||
# Hyper-ideal (hyperbolic) functional
|
||||
./build/examples/example_hyper_ideal [input.off] [output.off]
|
||||
./build/examples/example_viewer [input.off] # interactive, requires WITH_VIEWER
|
||||
|
||||
# Interactive viewer (requires WITH_VIEWER)
|
||||
./build/examples/example_viewer [input.off]
|
||||
```
|
||||
|
||||
`example_layout.cpp` is the best starting point — it shows the complete pipeline in ~120 lines.
|
||||
**Start here:** `example_flatten.cpp` shows the primary use case — real conformal
|
||||
flattening with `Θ_v = 2π`. `example_layout.cpp` adds JSON/XML serialisation.
|
||||
|
||||
> **Note on "natural theta":** `example_euclidean` and `example_layout` use the
|
||||
> "natural theta" testing trick (`Θ_v = actual angle sum at x=0`), which makes
|
||||
> `x* = 0` trivially the equilibrium. The output `u_v ≈ 0` is expected and
|
||||
> correct for a pipeline test, but means **no conformal deformation was applied**.
|
||||
> For real UV parameterisation, use `example_flatten.cpp`.
|
||||
|
||||
**Expected output of `example_euclidean` on the built-in quad-strip mesh:**
|
||||
```
|
||||
|
||||
@@ -438,8 +438,8 @@ auto& p = layout.uv[v.idx()];
|
||||
|
||||
| ID | File | Type | Severity | Status |
|
||||
|----|------|------|----------|--------|
|
||||
| U1 | README + 4 examples | Usability | 🔴 Critical | 🟡 Open |
|
||||
| U2 | examples/ (missing) | Usability | 🔴 Critical | 🟡 Open |
|
||||
| U1 | README + 4 examples | Usability | 🔴 Critical | ✅ Fixed 2026-05-31 |
|
||||
| U2 | examples/ (missing) | Usability | 🔴 Critical | ✅ Fixed 2026-05-31 |
|
||||
| U3 | `contracts.md:16` | Doc error | 🟡 Medium | 🟡 Open |
|
||||
| U4 | `README.md:17` | Stale | 🟡 Medium | 🟡 Open |
|
||||
| U5 | `Discrete_conformal_map.h:14` | Stale | 🟡 Medium | 🟡 Open |
|
||||
|
||||
Reference in New Issue
Block a user