OCCTSwiftMesh documentation
Mesh-domain algorithms for the OCCTSwift ecosystem. OCCTSwiftMesh operates on the Mesh triangle-soup value type (declared in OCCTSwift and re-exported here) and adds the mesh-side post-processing OCCT’s open-source distribution leaves out: quadric-error-metric (QEM) decimation that reports its achieved Hausdorff error, and planar cross-sectioning that recovers a slice’s closed contours the way a 3D-printer slicer does. Pure-Swift algorithms over Mesh.vertices / Mesh.indices — no extra OCCT kernel calls — so they stay robust on the open, unwelded meshes that raw STL / scan bodies actually are.
import OCCTSwift
import OCCTSwiftMesh
let mesh: Mesh = shape.mesh() // a tessellated Shape from OCCTSwift
guard let result = mesh.simplified(.init(targetTriangleCount: 5_000)) else { return }
print("\(result.beforeTriangleCount) → \(result.afterTriangleCount) triangles")
print("Hausdorff error: \(result.hausdorffDistance)") // absolute, in input mesh units
let reduced: Mesh = result.mesh
Cookbook
Task-oriented, example-rich guides — each a short bit of prose plus runnable Swift. The Cookbook index lists all recipes:
Decimating a Mesh · Target Count vs. Reduction Ratio · Cross-Sections & Contours
Reference
- API Reference — the detailed, per-type reference: signatures, parameters, return values, and runnable examples for every public type.
- Decimation algorithm notes — the QEM backend, vendored meshoptimizer, Hausdorff units, and edge-case semantics.
- Changelog — release-by-release history.
- Vendoring — the re-vendoring procedure for the bundled meshoptimizer.
Project
OCCTSwiftMesh is part of the OCCTSwift family. It depends on OCCTSwift for the Mesh type and vendors meshoptimizer (MIT) for the QEM backend. Install via Swift Package Manager:
// Package.swift
dependencies: [
.package(url: "https://github.com/SecondMouseAU/OCCTSwiftMesh.git", from: "1.1.1"),
],
targets: [
.target(
name: "YourApp",
dependencies: [
.product(name: "OCCTSwiftMesh", package: "OCCTSwiftMesh"),
]
)
]
- Source & issues: github.com/SecondMouseAU/OCCTSwiftMesh
- Platforms: macOS 12+, iOS 15+. LGPL-2.1, matching OCCTSwift.