Repository navigation
Conversation
Opt-in via -DGMESH_REDUCE_TOL=<m> (undefined: off, no change). After welding and triangulation, gmesh_init collapses edges with quadric error metrics (Garland & Heckbert 1997), pass structure after Fast-Quadric-Mesh-Simplification (Forstmann, MIT), while the error stays below the tolerance. 0 only merges exactly flat regions (surface unchanged). Boundary, non-manifold and property-seam vertices are kept fixed; faceArray then holds the triangles. Lossy reduction changes simulation results; the largest collapse error is printed at init. interoff-lib is unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@Lomholy polygon-reduction mechanism draft. For now only enabled if I have in mind to eventually add something like this - but instead a using runtime-handle set on the command-line, think along the lines of |
|
@willend Cool stuff! I am wondering since this runs in initialize if we should add a handle for alowing the user to export the simulated mesh, such that many runs over the same mesh (with the same mesh tol) need not perform this edge collapse? This would then also apply to the face collapse that is currently in the geometry-mesh-lib. |
|
Agreed, this is a good idea! Another interesting option to consider: Let's let this PR sit for a while before we do anything further? Then the two of us can discuss interesting options next time we meet up? :-) (I will pull from main once in a while as we go forward to keep the PR relatively updated.) |
|
@Lomholy we can also look at either making such a small stand-alone tool ourselves or look for existing open-source implementations? (I am convinced they are out there.) |
|
Is this not exactly what the addition in this PR does if you add a few handles and logic flows? And agreed, lets discuss when next we meet up! |
|
@Lomholy what I meant as an alternative was a small, stand-alone tool just for this purpose alone. Commandline-util instead of adding it to the actual instrument/McCode c-base. But let's chat about that when we get a chance. :-) |
Summary
Opt-in mesh reduction in
geometry-mesh-lib, enabled per instrument withDEPENDENCY " -DGMESH_REDUCE_TOL=<m> ". Undefined (default): no change.gmesh_reduce()runs insidegmesh_initafter welding/triangulation, before normals and BVH build.0= lossless: only exactly flat regions are merged.tri_face(file face numbers, properties) is preserved.faceArraythen holds the triangles so display matches.%includeof gmesh there cannot be shielded by the define, since libraries are embedded once per instrument).Numerical behaviour: with a non-zero tolerance the surface moves, so results change. The largest collapse error is printed at init.
Testing (macOS arm64, clang only)
tol=0(area, volume, inside-test exact); UV sphere 14160→5132 at 1e-3 (volume −0.05%); open seamed plate keeps boundary and property seam.knot.stl,socket.off,twisted_guide.off,Guide.off): closed/oriented/Euler unchanged.Tests_union/Many_meshes:tol=0monitors identical to reference;tol=1e-4742→94 triangles, monitor −1.2%.Not tested: Linux, Windows/MSVC, GPU (nvc), McXtrace Union instruments.
🤖 Generated with Claude Code