Add preserve_border option to simplify and simplify_mesh (#89) - #94
Merged
Conversation
Closed
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>
for more information, see https://pre-commit.ci
akaszynski
force-pushed
the
feat/preserve-border
branch
from
August 12, 2026 16:00
ca6f81a to
fccb10f
Compare
This was referenced Aug 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds an optional
preserve_borderflag (defaultFalse) 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.h—simplify_meshandsimplify_mesh_losslesseach take a newbool preserve_border=false. The existing border check is generalized: withpreserve_borderit skips a collapse if either endpoint is a border vertex; otherwise it keeps the originalv0.border != v1.borderbehaviour.fast_simplification/_simplify.pyx— extern declarations and thesimplify/simplify_losslesswrappers pass the flag through.fast_simplification/simplify.py—simplify(...)(array API) andsimplify_mesh(...)(PyVista API) gain a documentedpreserve_borderkeyword, 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_borderdecimates a triangulatedpv.Plane(80 boundary points) at 90% reduction:preserve_border=Falseerodes the boundary (80 → 15 points);preserve_border=Truekeeps all 80.preserve_border=Falsecollapses the boundary (80 → 3 points);preserve_border=Truekeeps all 80.Full existing suite still passes (12 passed).
Closes #89
🤖 Generated with Claude Opus 4.8 (Claude Code)