feat: Add sharp edge preservation to dual contouring#19
Open
BizaNator wants to merge 1 commit intoJeffreyXiang:mainfrom
Open
feat: Add sharp edge preservation to dual contouring#19BizaNator wants to merge 1 commit intoJeffreyXiang:mainfrom
BizaNator wants to merge 1 commit intoJeffreyXiang:mainfrom
Conversation
Add new simple_dual_contour_sharp() function that preserves sharp edges during mesh remeshing by: - Computing surface gradients at intersection points using edge direction - Clustering intersection points by gradient similarity (normal direction) - Using iterative plane projection to find optimal vertex position for sharp features instead of simple averaging New parameters added to remesh_narrow_band_dc(): - preserve_sharp_edges: bool = False - sharp_angle_threshold: float = 30.0 (degrees) Test results show significant improvement: - Edges > 60°: 12 (smooth) → 1224 (sharp) - Max edge angle: 70° (smooth) → 89° (sharp) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
3 tasks
Deathdadev
added a commit
to Deathdadev/CuMesh
that referenced
this pull request
Feb 5, 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
This PR adds optional sharp edge preservation to the
remesh_narrow_band_dc()function. Sharp edges and corners are often lost during dual contouring remeshing because the standard algorithm averages all edge intersection points within a voxel. This change detects sharp features by clustering intersection points based on gradient similarity and uses iterative plane projection to find optimal vertex positions that preserve these features.Changes
New CUDA kernel:
simple_dual_contour_sharpinsrc/remesh/simple_dual_contour.cuPython API: Two new parameters added to
remesh_narrow_band_dc():preserve_sharp_edges: bool = False- Enable sharp edge detectionsharp_angle_threshold: float = 30.0- Angle in degrees above which edges are considered sharpBinding: New function registered in
src/ext.cppHeader: Declaration added to
src/remesh/api.hBackward Compatibility
Fully backward compatible. Default behavior unchanged (
preserve_sharp_edges=False).Usage
Test Results
Tested on meshes with sharp features (boxes, mechanical parts):
Technical Details
The algorithm:
The gradient is computed from the edge direction and UDF sign change, which is more robust in sparse grids than querying neighboring vertices.