Link Search Menu Expand Document

OCCTSwiftIO

Headless, multi-format CAD + mesh file I/O for the OCCTSwift family — no Viewport dependency, so it is safe for CLIs, batch pipelines, and server-side workflows.

The package ships two products so consumers take only what they need:

  • MeshIO — pure Swift, no OCCT. 3D mesh formats (STL / OBJ / PLY / glTF / GLB / 3MF / PMX / .x) load and write into a neutral value-type Mesh (positions + indices).
  • OCCTSwiftIO — OCCT-backed. CAD B-Rep load/export as Shapes (STEP / IGES / BREP), plus JWW (Jw_cad 2D vector) load, a ScriptManifest round-trip, and a TopologyGraph → ML export layer.

The split lets OCCT-free consumers (e.g. a raw-mesh ingest) read meshes without pulling in the 1.3 GB kernel; OCCTSwiftIO builds on MeshIO and adds the kernel-backed formats. See Formats for the full coverage table and per-format notes.


Hero example

import OCCTSwift
import OCCTSwiftIO

// Load a STEP assembly → shapes + per-shape colors + AP242 GD&T metadata.
let result = try await ShapeLoader.load(from: stepURL, format: .step)
print(result.shapes.count, "shapes,", result.dimensions.count, "dimensions")

// Re-export the loaded shapes as a single binary glTF container.
try await ExportManager.export(shapes: result.shapes, format: .glb, to: outURL)

Pure-mesh, no kernel:

import MeshIO

let mesh = try MeshIO.load(contentsOf: stlURL)     // format chosen by extension
print(mesh.vertexCount, mesh.triangleCount)
try MeshIO.write(mesh, to: objURL)                 // writer chosen by extension

Cookbook

Task-oriented, example-rich recipes:


Reference

Per-type API reference with real signatures: API Reference.


Install

Add the package and pick the product(s) you need. Latest release: v1.4.1.

dependencies: [
    .package(url: "https://github.com/SecondMouseAU/OCCTSwiftIO.git", from: "1.4.0"),
],
.target(name: "YourTarget", dependencies: [
    .product(name: "MeshIO", package: "OCCTSwiftIO"),        // mesh, no OCCT
    .product(name: "OCCTSwiftIO", package: "OCCTSwiftIO"),   // CAD + JWW + ML (pulls OCCT)
]),

GitHub: https://github.com/SecondMouseAU/OCCTSwiftIO


Architecture position

OCCTSwiftTools     (bridge — Shape ↔ ViewportBody)
       ↑
OCCTSwiftIO        ← this repo (headless file I/O)        MeshIO  ← pure-Swift mesh (no OCCT)
       ↑                                                     ↑
OCCTSwift          (B-Rep kernel)              SwiftPMX / SwiftX / ThreeMF / SwiftGLTF / SwiftJWW

Hard rule: no Viewport dependency in this package. Produce ViewportBodys in OCCTSwiftTools.

License

LGPL-2.1 (inherited from OCCTSwift / OCCT). The mesh-format reader packages carry their own permissive licenses (MIT / BSD-3).