Mesh-domain algorithms for the OCCTSwift ecosystem. Operates on OCCTSwift.Mesh instances; complements the OCCT-side topology kernel rather than extending it.
Part of the OCCTSwift ecosystem — see the ecosystem map for how this package fits with the kernel, viewport, and sibling layers.
OCCTSwift — B-Rep solid modelling kernel (wraps OpenCASCADE)
OCCTSwiftMesh — mesh-domain algorithms (decimation, smoothing, repair, ...)
OCCTSwiftViewport — Metal viewport for rendering
OCCTSwiftScripts — script harness + occtkit CLI verbs
OCCT's open-source distribution provides BRepMesh_* for mesh generation but no decimation, simplification, smoothing, hole-filling, remeshing, or other mesh-side post-processing. OCCT-Components ships a paywalled "Mesh Decimation" module — this package fills the same role with permissive, vendored implementations.
OCCTSwift itself stays focused on its mission as an OCCT wrapper. Mesh algorithms that happen to consume OCCT-produced meshes live here.
✅ v1.1.0 — SemVer-stable. Ships Mesh.simplified(_:) (decimation, vendored meshoptimizer v1.1) and Mesh.crossSection(plane:) (planar slicing into closed contours). Requires OCCTSwift v1.0.1 or later. See docs/CHANGELOG.md.
import OCCTSwift
import OCCTSwiftMesh
let mesh: Mesh = shape.mesh() // from OCCTSwift
let simplified = mesh.simplified(.init(
targetTriangleCount: 5_000,
preserveBoundary: true,
preserveTopology: true
))
if let result = simplified {
print("\(result.beforeTriangleCount) → \(result.afterTriangleCount)")
print("Hausdorff: \(result.hausdorffDistance)")
let reducedMesh = result.mesh
}Intersect a mesh with a plane and recover the closed contours where it cuts the surface — the perimeter step a 3D-printer slicer performs. Works directly on open / unwelded scan meshes (no B-Rep sewing first). A thin-walled tube slices into separate outer and inner loops, so wall thickness is just their offset; inner-vs-outer comes from contour nesting, not triangle winding.
let section = mesh.crossSection(plane: CutPlane(point: p, normal: n))
for c in section!.contours {
// c.depth == 0 → outer solid boundary; c.isHole → inner wall / pocket
print(c.points.count, "pts, area", c.area, c.isHole ? "(hole)" : "")
}
// Or a whole slicer layer stack along an axis:
let stack = mesh.crossSections(axis: axis, through: p, spacing: 2.0)// Package.swift
dependencies: [
.package(url: "https://github.com/gsdali/OCCTSwiftMesh.git", from: "1.1.0"),
],
targets: [
.target(
name: "YourApp",
dependencies: [
.product(name: "OCCTSwiftMesh", package: "OCCTSwiftMesh"),
]
)
]LGPL-2.1, matching OCCTSwift. Vendored components retain their own permissive licenses (notably meshoptimizer under MIT). See NOTICE.md.
Beyond initial decimation:
- Subdivision (Catmull-Clark, Loop)
- Laplacian / Taubin smoothing
- Mesh repair (non-manifold cleanup, hole filling)
- Remeshing (uniform / adaptive)
- glTF mesh-export niceties (LOD chains, meshopt-encoded streams)
- GPU-accelerated mesh ops where worthwhile
Community needs drive priority — file an issue if you want one of these (or something else) sooner.
- OCCTSwift — OCCT wrapper, source of
Mesh - OCCTSwiftScripts — script harness;
simplify-meshverb consumes this package (#22) - OCCTMCP — MCP server;
simplify_meshtool consumes this package via OCCTSwiftScripts (#6)