feat(meshing): trimesh_remesh — protect_boundary + sharp-feature edge constraints#72
Open
jf--- wants to merge 2 commits into
Open
feat(meshing): trimesh_remesh — protect_boundary + sharp-feature edge constraints#72jf--- wants to merge 2 commits into
jf--- wants to merge 2 commits into
Conversation
…s_angle_deg
Expose CGAL's edge_is_constrained_map + protect_constraints for
isotropic_remeshing. Two new optional kwargs (both default-disabled,
backward-compatible):
- protect_boundary=True → all boundary edges constrained; preserves
boundary curves verbatim including sharp corners that the default
smoothing pass otherwise rounds.
- protect_sharp_edges_angle_deg=>0 → also constrain interior edges
with dihedral angle >= threshold (via PMP::detect_sharp_edges).
Pattern matches existing edge_is_constrained_map usage in
src/{isolines,geodesics,booleans}.cpp.
…_sharp_edges_angle_deg - default mode: boundary IS subdivided on annular layer - protect_boundary=True: all 8 original corners survive verbatim - protect_boundary=True: boundary-vertex count stays exactly 8 (no inserts) - protect_sharp_edges_angle_deg=0.0: no behavioural change vs unset
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
Expose CGAL's
edge_is_constrained_map+protect_constraintsparameters fromPolygon_mesh_processing::isotropic_remeshingvia two new optional kwargs ontrimesh_remesh. Both default to disabled, so the change is backward-compatible.protect_boundary=True— every boundary edge is constrained, preserving the input boundary curve (including sharp corners) verbatim. Without this, CGAL's default smoothing pass re-samples boundary edges totarget_edge_lengthand rounds sharp corners.protect_sharp_edges_angle_deg=>0— additionally constrain interior edges whose adjacent faces meet at a dihedral angle ≥ threshold (viaPMP::detect_sharp_edges).Motivation
Discovered while remeshing curved 3D-printing layers (annular cross-sections of a torus). With the default
trimesh_remesh, sharp boundary corners get visibly rounded because CGAL smooths them along with interior vertices — there was no way from Python to mark those edges as features.Implementation
Follows the existing
edge_is_constrained_mappattern already used insrc/isolines.cpp,src/geodesics.cpp, andsrc/booleans.cpp: a boolean property map is built on the mesh, marked for the protected edges, then passed to PMP viaparameters().edge_is_constrained_map(ecm).protect_constraints(True).PMP::detect_sharp_edgesis also imported (one extra header —CGAL/Polygon_mesh_processing/detect_features.h).Tests
Added under
tests/test_meshing.py(4 new cases, all passing alongside the existing 2):test_remesh_default_subdivides_boundary— default mode (no protection) subdivides boundary verts on an annular layer, as before.test_remesh_protect_boundary_keeps_corners— every original corner of an outer + inner square boundary survives verbatim underprotect_boundary=True.test_remesh_protect_boundary_keeps_boundary_vertex_count— boundary-vertex count stays exactly 8 (4 outer + 4 inner) withprotect_boundary=True; no inserts.test_remesh_protect_sharp_edges_default_disabled—protect_sharp_edges_angle_deg=0.0(default) produces identical output to omitting the kwarg, confirming backward compatibility.Backward compatibility
Both new params default to their old behaviour (
protect_boundary=False,protect_sharp_edges_angle_deg=0.0). No existing call sites change.