feat(phase4): HyperIdeal Newton solver, SparseQR fallback, examples, docs

Phase 4 complete — 87 CGAL tests pass, 2 skipped.

Newton solver (phase4a):
- hyper_ideal_hessian.hpp: symmetric FD Hessian (O(ε²), PSD by convexity)
- newton_hyper_ideal(): Newton + backtracking for the HyperIdeal functional
- detail::solve_with_fallback(): optional bool* fallback_used parameter
- solve_linear_system(): public API exposing LDLT→SparseQR fallback

SparseQR fallback tests (SparseQRFallback.*):
- FullRankSystem_CorrectSolution: LDLT path, fallback_used=false
- SingularMatrix_FallbackActivated: zero-pivot → QR activated, fallback_used=true
- Euclidean_ClosedMeshNoPinConverges: gauge-mode null space handled via QR

HyperIdeal Newton tests (NewtonSolver.HyperIdeal_*):
- ConvergesTriangleAllVariable, ResultFieldsConsistent,
  ConvergesTetrahedron, SparseQRFallbackNoCrash
- Natural-target base point (b=1.0, a=0.5) — x=0 is degenerate in log-space

Pipeline tests (test_pipeline.cpp):
- End-to-end: all three geometries, mesh I/O round-trip, solve+export

Example programs (code/examples/):
- example_euclidean.cpp:   headless Euclidean pipeline
- example_hyper_ideal.cpp: headless HyperIdeal pipeline
- example_viewer.cpp:      interactive libigl viewer with jet colour map

README:
- Mathematical scope table: C++ vs Java original (18 rows)
- "For mathematicians" section: mental model, step-by-step new-functional
  guide, half-edge traversal snippets, recommended reading

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Tarik Moussa
2026-05-13 00:11:25 +02:00
parent e70689d29f
commit 3f124eb071
12 changed files with 1798 additions and 165 deletions

View File

@@ -0,0 +1,49 @@
# examples/CMakeLists.txt
#
# Example programs for conformallab++.
# All examples require -DWITH_CGAL=ON.
# example_viewer additionally requires -DWITH_VIEWER=ON.
#
# Run after building:
# ./build/examples/example_euclidean [input.off] [output.off]
# ./build/examples/example_hyper_ideal [input.off] [output.off]
# ./build/examples/example_viewer [input.off] (requires WITH_VIEWER)
# ── Shared include paths for all examples ─────────────────────────────────────
set(EXAMPLE_INCLUDES
${CMAKE_SOURCE_DIR}/deps/eigen-3.4.0
${CMAKE_SOURCE_DIR}/deps/CGAL-6.1.1/include
${Boost_INCLUDE_DIRS}
)
set(EXAMPLE_PRIVATE_INCLUDES
${CMAKE_SOURCE_DIR}/include
)
set(EXAMPLE_DEFS
CGAL_DISABLE_GMP
CGAL_DISABLE_MPFR
)
# ── example_euclidean ─────────────────────────────────────────────────────────
add_executable(example_euclidean example_euclidean.cpp)
target_include_directories(example_euclidean SYSTEM PRIVATE ${EXAMPLE_INCLUDES})
target_include_directories(example_euclidean PRIVATE ${EXAMPLE_PRIVATE_INCLUDES})
target_compile_definitions(example_euclidean PRIVATE ${EXAMPLE_DEFS})
# ── example_hyper_ideal ───────────────────────────────────────────────────────
add_executable(example_hyper_ideal example_hyper_ideal.cpp)
target_include_directories(example_hyper_ideal SYSTEM PRIVATE ${EXAMPLE_INCLUDES})
target_include_directories(example_hyper_ideal PRIVATE ${EXAMPLE_PRIVATE_INCLUDES})
target_compile_definitions(example_hyper_ideal PRIVATE ${EXAMPLE_DEFS})
# ── example_viewer (requires WITH_VIEWER) ─────────────────────────────────────
if(WITH_VIEWER)
add_executable(example_viewer example_viewer.cpp)
target_include_directories(example_viewer SYSTEM PRIVATE
${EXAMPLE_INCLUDES}
${CMAKE_SOURCE_DIR}/deps/libigl-2.6.0/include
${CMAKE_SOURCE_DIR}/deps/libigl-glad/include
)
target_include_directories(example_viewer PRIVATE ${EXAMPLE_PRIVATE_INCLUDES})
target_compile_definitions(example_viewer PRIVATE ${EXAMPLE_DEFS})
target_link_libraries(example_viewer PRIVATE viewer)
endif()