Repository navigation
Keep remesh and disk_cap finite on folded input - #133
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #133 +/- ##
==========================================
- Coverage 72.22% 72.18% -0.05%
==========================================
Files 20 20
Lines 4087 4095 +8
Branches 522 523 +1
==========================================
+ Hits 2952 2956 +4
- Misses 919 922 +3
- Partials 216 217 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
04119f9 to
f6ad4e1
Compare
There was a problem hiding this comment.
🟡 Changes recommended
The singular-solve and non-finite-result fallbacks lack regression tests verifying that disk_cap preserves the last accepted mesh when failure occurs initially or after a successful round.
1 open issue
What changed in this PR
This PR makes mesh remeshing and disk capping more robust on folded input, preventing undefined smoothing operations and preserving the last accepted disk when a harmonic step fails.
Changes:
- Keep vertices stationary when their summed normals cancel or smoothing weights are zero.
- Reject disk-cap rounds whose harmonic solve raises
RuntimeErroror returns non-finite coordinates. - Add bowtie and figure-eight regression tests for finite output and preserved boundary topology.
| File | Description |
|---|---|
lapy/utils/tests/test_topology.py |
Adds a figure-eight disk-cap regression test. |
lapy/utils/tests/test_remesh.py |
Tests remeshing with cancelling vertex normals. |
lapy/topology.py |
Handles failed or non-finite harmonic steps and documents the fallback. |
lapy/remesh.py |
Guards tangential smoothing against undefined normals and zero weights. |
Review effort: Balanced

disk_capcould fail withValueError: 'x' must be finiteorRuntimeError: Factor is exactly singularwhen the least-area triangulation of its boundary folds. This happens for long boundaries that wind through the folds of a brain surface, for example when closing patches or cropping protrusions in topology correction, and also for a simple figure eight.Two causes, both in remeshing folded input:
remesh: tangential smoothing normalized the summed vertex normals with divide warnings switched off. At a vertex whose surrounding triangles face opposite ways the normals cancel, the vertex became NaN, and the next projection failed. Such vertices, and vertices whose neighbourhood has no area, now stay where they are, since they have no tangent plane to move in.disk_cap: remeshing a folded disk can leave inner vertices with only triangles without area. Their rows in the cotangent matrix are zero, and the minimal surface step cannot be solved. A round whose step fails or gives non-finite vertices is now not applied, and the disk stays as it was, the same as for a round that would fold the disk more.Tests:
remeshof a fan whose neighbours form a bowtie, so that the summed normal at its centre is zero: the result is finite and keeps its boundary.disk_capof a flat figure eight: the result is a finite, oriented disk spanning the boundary.Both fail on the current release. The singular case only showed up on long boundaries from real surfaces and could not be reproduced with a small input, so the second change has no test of its own.