Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

MRCad: new library with ObjectCAD keeping the B-rep and tessellating it - #7663

Draft
Grantim wants to merge 16 commits into
masterfrom
object-cad
Draft

Grantim wants to merge 16 commits into
masterfrom
object-cad

Conversation

@Grantim

@Grantim Grantim commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

New optional library MRCad with ObjectCAD: an ObjectMeshHolder that keeps the boundary representation of a CAD model (OpenCASCADE shape) and tessellates it itself, like ObjectVoxels builds its surface.

  • setTessellationParams (or tessellate in another thread + updateTessellation) gives the mesh, the CAD face of every mesh face (Face2CadFaceMap = Vector<CadFaceId, FaceId>, where CadFaceId is the index of the face in TopExp::MapShapes) and the surface of every CAD face (SmoothSurface from fitSmoothSurfaces: smooth surface (analytic or B-spline) of every given mesh region #7621). Planes, cylinders, cones, spheres, tori and non-rational B-splines convert exactly; other faces get surfaces fitted to their triangles by fitSmoothSurfaces, a B-spline where the analytic surfaces are farther than the linear deflection.
  • applyScale scales the shape, the surfaces and an absolute linear deflection too; shallow clones share the shape, and .mru scenes save it once.
  • .mru scenes keep the shape (.brep, in the version OpenCASCADE 7.5 reads), the parameters, the mesh, the face map and the surfaces.
  • MESHLIB_BUILD_CAD is on by default where STEP files are supported (MESHLIB_BUILD_EXTRA_IO_FORMATS and not MRIOEXTRAS_NO_STEP), off for Emscripten.
  • MRIOExtras keeps its own STEP loading as meshes; loading STEP as ObjectCAD comes next. Python and C bindings of MRCad are not generated yet.

Test plan

  • MRCad.ObjectCADTessellation: faces on all surface types, reversed and moved faces, a periodic B-spline face and a rational face fitted by a B-spline; every mesh vertex lies on the surface of its CAD face, planes and B-splines are directed as the triangles (Release and Debug)
  • MRCad.ObjectCADRelativeDeflection: the fitted face gets a B-spline within the deflection relative to its size
  • MRCad.SerializeObjectCAD: the shape, parameters, face map and surfaces survive saving and loading, a shallow clone still shares the mesh and the shape after loading
  • MRCad.ObjectCADScale: the shape, surfaces and deflection scale, a shallow clone keeps its mesh
  • Full MRTest suite passes locally (Release)

Generated with Claude Code

Grantim and others added 2 commits December 2, 2026 16:54
ObjectMeshHolder with a Face2CadFaceMap and a SmoothSurface per CadFaceId, saved in .mru scenes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ObjectCAD moves out of MRMesh into MRCad (OpenCASCADE, MESHLIB_BUILD_CAD), keeps the shape, tessellates it into the mesh with the CAD face and surface of every triangle, and saves the shape as .brep in .mru scenes. MRIOExtras keeps its own STEP loading.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Grantim Grantim changed the title ObjectCAD: mesh object with the CAD face and surface of every mesh face MRCad: new library with ObjectCAD keeping the B-rep and tessellating it Dec 2, 2026
Grantim and others added 14 commits December 2, 2026 19:55
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…models and scaling of ObjectCAD

CadFaceId is the index of the face in TopExp::MapShapes, so a face shared by solids or without triangles has one id, and the faces without exact surfaces are fitted in one cancelable fitSmoothSurfaces call, which allows B-splines within the linear deflection. B-splines of reversed faces are directed as their triangles, shared models keep the shape, and applyScale scales the shape, the surfaces and the deflection.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
OpenCASCADE 7.6 and later write format version 3 by default, which 7.5 (Ubuntu 22) cannot read.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The configurations without STEP support may have no OpenCASCADE, which MRCad requires.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e filters

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…est margins

The test no longer assumes that located copies of a face share its triangulation, since BRepBuilderAPI_Copy gives each one its own face.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e on a periodic B-spline surface

The duplicated plane face is compared with the same face tessellated alone, and the fitted face is checked to be a B-spline surface within the deflection, whatever its degree. The braces around gtest macros avoid -Wdangling-else of GCC.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…eflection

The automatic threshold of fitSmoothSurfaces assumes that most regions are analytic, so a lone freeform face never got a B-spline surface. OpenCASCADE gives a face at least half of a relative deflection times the largest side of its box, so the smallest of these over the fitted faces is the tolerance, as the linear deflection is with absolute one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The mesh can be shared with other objects (shallow clones, objects of one shared model), whose shapes and surfaces are not scaled.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…d.vcxproj

The option now turns off whenever STEP support is turned off, also in an existing cache.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… the description of the surfaces

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… triangles

.brep keeps 15 digits, so the reloaded shape is tessellated slightly differently on arm64.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant