Repository navigation
Conversation
The subdivision of the mesh on faces is an input (e.g. edges selected by the user), so there is no region growing or cleaning. Every segment gets the simplest of plane, cylinder, cone, sphere, torus whose RMS distance is within 1.5x of any more complex type, or a B-spline surface if that distance exceeds the tolerance (by default 2.5x the median over the segments, the noise level). Boundary vertices are moved to where the surfaces of adjacent segments meet; boundary chains are smoothed between the snaps, which removes the zigzag of mesh edges where surfaces are nearly tangent. Surfaces, the B-spline fit and the BRep writer are taken from #7581. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…Point Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Fedr
added a commit
that referenced
this pull request
Nov 27, 2026
…rance floor cbrt(eps) (#7611) SymMatrix3::pseudoinverse took the direct-inverse fast path (added in #7178) for some rank-1 matrices: their determinant and 2x2 minors are rounding errors (about eps * trace^3) that could pass its check, and the result was garbage (up to 2e6 times too large, rank reported as 3). Found in #7610. - the direct path also requires det > tol^2 * (trace/3)^3, which every matrix with lambdaMin > tol * lambdaMax satisfies; - its tolerance is at least cbrt(eps) of the type (compile-time detail::cCbrtEpsilon<T>) instead of the fixed 1e-4, which left no margin for float; - the direct inverse scales each element by 1 / d instead of res /= d after filling res: same results, 2x faster with MSVC x64 for double (MSVC reloaded just stored doubles as vectors, defeating store-to-load forwarding; reported as Developer Community 11188541). Performance on 8 compiler/CPU combinations: well-conditioned matrices within 1.3 ns, rank-1 matrices 12-29% slower (now on eigensJacobi, master was only faster by being wrong), double with condition number 1e4..1e5 93-97% faster (now inverted directly).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…enclosing one A segment enclosed by one other segment needs a closed curve where the two surfaces meet near its boundary; a bump of a scanned plane fitted by another plane meets it along a line, and its face came out empty. Such segments (and the segments inside them) become one plane face per triangle; the vertices are snapped only to the other surfaces, and the triangle planes pass through the moved vertices. The STEP uncertainty is the largest distance from a boundary vertex to its surfaces. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 28, 2026
…er, own fitting removed Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…shToStep.cpp Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…AllComponents, trackLeftBoundaryLoop, PointAccumulator Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…vertices Surfaces fitted separately do not meet where they are nearly tangent, and the curves between such faces were not on their surfaces (2 of 127 faces of the scanned housing were invalid in OpenCASCADE). Now the surfaces of the regions with such vertices are fitted again with these vertices in their common positions with a large weight, up to 5 times while the largest gap decreases. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
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.
MR::saveMeshAsStep( mesh, faceBoundaries, out|path, MeshToStepSettings )writes a mesh as a STEP (AP214) boundary representation with one face per mesh segment, where the segments are the connected parts of the mesh separated by given edges (e.g. selected by the user). Unlike #7581, the subdivision on faces is an input, so there is no region growing (Grower) or cleaning (Cleaner).The surfaces of the segments are found by
fitSmoothSurfaces(#7621, in master). Taken from #7581: the BRep/STEP writer (MRMeshToStepBRep.cpp).New:
fitSmoothSurfaceswithMeshToStepSettings::toleranceas itsbsplineThreshold(estimated from the noise of the mesh if not given), and every segment keeps itsSmoothSurface. The boundary snapping measures the distance to a B-spline surface along its normal, which extends the surface beyond its border by its tangent planes, so that the boundary vertices can be moved to where it meets the neighbour surfaces.SymMatrix3::pseudoinverse( 0.01 ): no move along the surfaces, and only along the common normal of nearly tangent surfaces; it needs SymMatrix3::pseudoinverse: no direct inverse of a rank-1 matrix, tolerance floor cbrt(eps) #7611, which fixed the pseudoinverse of rank-1 matrices, i.e. of a vertex on one surface). The chains between two segments are smoothed between the snaps: the selected mesh edges zigzag around the true curve, and where the surfaces are nearly tangent the snap alone keeps that zigzag. The curve tolerance in the BRep writer is per chain (twice the snap residual of its vertices), and circles must pass through their end vertices.MeshToStepStats::maxDeviation: the maximum distance from a mesh vertex to the surface of its face.Scanned housing (37201 vertices, 50 segments from 2694 selected edges)
The whole automatic conversion of the same mesh (#7581) produced thousands of single-triangle planes or broken surfaces, since that mesh is not a CAD tessellation.
Segments enclosed by one other segment whose surfaces do not meet along their boundary (three bumps of the scan, 4 to 9 mm², about 1 mm high, fitted by planes meeting the enclosing plane along a line) become one plane face per triangle; before, their faces came out empty.
OpenCASCADE reports the whole shape and all its 127 faces as valid (
BRepCheck_Analyzer). Without fitting the surfaces together 2 faces were invalid (a self-intersecting wire, a wire of bad orientation): pieces of the large bore fitted separately disagreed by about 0.5 mm, so at their corners with the counterbore floor the three surfaces had no common point. The largest distance from a boundary vertex to its surfaces (the uncertainty written in the file) is now 0.05 mm instead of 0.21 mm, and 9 vertices instead of 226 are farther than 0.02 mm.Test
MRMesh.MeshToStep: cube, cylinder, UV sphere, torus with sharp edges as the boundaries, plus a subdivided cube and a UV sphere with noisy vertices.🤖 Generated with Claude Code