OCCTSwiftIO Cookbook
Task-oriented, example-rich guides for the OCCTSwiftIO + MeshIO API — one page per task, each a short bit of prose followed by runnable Swift snippets using the real shipped API.
Conventions
- Every example is runnable Swift in a fenced
swiftblock, using the real current API. Fallible loaders / exporters arethrows; the CAD loaders areasync throws. Mesh I/O is synchronous. - Two imports, two charters.
import MeshIOfor the pure-Swift mesh path (no OCCT);import OCCTSwiftimport OCCTSwiftIOfor CAD B-Rep, JWW, manifests, and ML export.
- Format by extension. Both
CADFileFormat(fileExtension:)andMeshFormat(fileExtension:)map a file extension to a format case;MeshIO.load/MeshIO.writedo this for you.
Pages
- Importing a CAD file —
ShapeLoader.load/loadRobust,CADFileFormat, colors + AP242 metadata. - Exporting shapes —
ExportManager.exportto STEP / BREP / OBJ / PLY / glTF / GLB. - Reading & writing meshes —
MeshIO.load/write, theMeshvalue type, the per-format readers. - The ScriptManifest format —
ShapeLoader.loadFromManifest,ScriptManifest/BodyDescriptor. - Progress reporting —
ImportProgressClosure, fraction + step callbacks, cancellation. - ML graph export —
TopologyGraph.exportForML()/exportJSON(), the COO adjacency layout.