Skip to content

Add preserve_border option to simplify and simplify_mesh (#89) - #94

Merged
akaszynski merged 2 commits into
mainfrom
feat/preserve-border
Aug 12, 2026
Merged

Add preserve_border option to simplify and simplify_mesh (#89)#94
akaszynski merged 2 commits into
mainfrom
feat/preserve-border

Conversation

@akaszynski

Copy link
Copy Markdown
Member

Summary

Adds an optional preserve_border flag (default False) that preserves the open boundary of a mesh during decimation, addressing #89.

When preserve_border=True, any edge that touches an open-border vertex is skipped, so the perimeter of an open mesh is retained exactly instead of being eroded by collapses.

What changed

The flag is threaded through the whole stack:

  • fast_simplification/Simplify.hsimplify_mesh and simplify_mesh_lossless each take a new bool preserve_border=false. The existing border check is generalized: with preserve_border it skips a collapse if either endpoint is a border vertex; otherwise it keeps the original v0.border != v1.border behaviour.
  • fast_simplification/_simplify.pyx — extern declarations and the simplify / simplify_lossless wrappers pass the flag through.
  • fast_simplification/simplify.pysimplify(...) (array API) and simplify_mesh(...) (PyVista API) gain a documented preserve_border keyword, threaded through both the standard and lossless branches.

Unlike pyfqmr PR #37 (Kramer84/pyfqmr-Fast-Quadric-Mesh-Reduction#37), which applied border preservation only to the lossless method, this applies it to both the standard and lossless paths.

Test

A new test_preserve_border decimates a triangulated pv.Plane (80 boundary points) at 90% reduction:

  • Standard path: preserve_border=False erodes the boundary (80 → 15 points); preserve_border=True keeps all 80.
  • Lossless path: preserve_border=False collapses the boundary (80 → 3 points); preserve_border=True keeps all 80.

Full existing suite still passes (12 passed).

Closes #89

🤖 Generated with Claude Opus 4.8 (Claude Code)

@akaszynski akaszynski mentioned this pull request Aug 12, 2026
akaszynski and others added 2 commits August 12, 2026 10:00
Add an optional `preserve_border` flag that protects the open boundary
of a mesh during decimation by skipping the collapse of any edge that
touches a border vertex. It is threaded through both the standard
(`simplify_mesh`) and lossless (`simplify_mesh_lossless`) paths in the
core header, the Cython wrapper, and the Python array/PyVista APIs.

This mirrors pyfqmr PR #37, which added border preservation only to the
lossless method; here it is available on both paths.

Closes #89

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@akaszynski
akaszynski force-pushed the feat/preserve-border branch from ca6f81a to fccb10f Compare August 12, 2026 16:00
@akaszynski
akaszynski merged commit 51095c0 into main Aug 12, 2026
23 of 25 checks passed
@akaszynski
akaszynski deleted the feat/preserve-border branch August 12, 2026 17:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Border preservation

1 participant