{"id":49923607,"url":"https://github.com/mnmly/swiftigl","last_synced_at":"2026-05-16T22:04:25.937Z","repository":{"id":358326782,"uuid":"1240946702","full_name":"mnmly/SwiftIGL","owner":"mnmly","description":"Swift bindings for libigl — mesh I/O, signed distance, marching cubes, decimation, and more via header-only xcframework","archived":false,"fork":false,"pushed_at":"2026-05-16T20:28:38.000Z","size":49,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-05-16T21:35:17.191Z","etag":null,"topics":["cxx-interop","eigen","geometry-processing","libigl","macos","marching-cubes","mesh","signed-distance-field","swift-package"],"latest_commit_sha":null,"homepage":null,"language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mnmly.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-05-16T19:13:38.000Z","updated_at":"2026-05-16T20:28:41.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/mnmly/SwiftIGL","commit_stats":null,"previous_names":["mnmly/swiftigl"],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/mnmly/SwiftIGL","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mnmly%2FSwiftIGL","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mnmly%2FSwiftIGL/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mnmly%2FSwiftIGL/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mnmly%2FSwiftIGL/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mnmly","download_url":"https://codeload.github.com/mnmly/SwiftIGL/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mnmly%2FSwiftIGL/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33120450,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-16T18:38:32.183Z","status":"ssl_error","status_checked_at":"2026-05-16T18:38:29.903Z","response_time":115,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cxx-interop","eigen","geometry-processing","libigl","macos","marching-cubes","mesh","signed-distance-field","swift-package"],"created_at":"2026-05-16T22:04:24.948Z","updated_at":"2026-05-16T22:04:25.932Z","avatar_url":"https://github.com/mnmly.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SwiftIGL\n\n[![CI](https://github.com/mnmly/SwiftIGL/actions/workflows/ci.yml/badge.svg)](https://github.com/mnmly/SwiftIGL/actions/workflows/ci.yml)\n[![Docs](https://img.shields.io/badge/docs-DocC-blue)](https://mnmly.github.io/SwiftIGL/documentation/swiftigl/)\n[![Swift 6.0](https://img.shields.io/badge/Swift-6.0-orange.svg)](https://swift.org)\n[![Platforms](https://img.shields.io/badge/platforms-macOS%2013%2B-lightgrey.svg)](https://github.com/mnmly/SwiftIGL)\n[![License](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE)\n\nSwift bindings for [libigl](https://libigl.github.io) — a small C++\ngeometry-processing library — via a header-only xcframework and Swift's\nC++ interop.\n\n## Install\n\nAdd to `Package.swift`:\n\n```swift\ndependencies: [\n    .package(url: \"https://github.com/mnmly/SwiftIGL\", from: \"0.1.0\"),\n],\ntargets: [\n    .target(\n        name: \"YourTarget\",\n        dependencies: [.product(name: \"SwiftIGL\", package: \"SwiftIGL\")],\n        swiftSettings: [.interoperabilityMode(.Cxx)]  // contagious from SwiftIGL\n    ),\n]\n```\n\n\u003e **Note:** C++ interop is contagious — any Swift target that imports\n\u003e `SwiftIGL` must also set `.interoperabilityMode(.Cxx)`.\n\n## Quick start\n\n```swift\nimport SwiftIGL\n\n// Load a mesh\nlet mesh = try readTriangleMesh(at: url)\n\n// Voxelize it\nlet bb   = try boundingBox(mesh, pad: 0.05)\nlet grid = try voxelGrid(\n    bboxMin: bb[vertex: 0], bboxMax: bb[vertex: 6],\n    largestSide: 128\n)\n\n// Sample SDF on the grid\nlet sdf = try signedDistance(\n    of: grid.points, on: mesh, type: .fastWindingNumber\n)\n\n// Re-extract as a clean mesh\nlet recon = try marchingCubes(scalars: sdf.distances, grid: grid)\ntry writeTriangleMesh(recon, to: outURL)\n```\n\nFull API: see the [DocC reference](https://mnmly.github.io/SwiftIGL/documentation/swiftigl/).\n\n### End-to-end demo executable\n\n```sh\nswift run MeshToSDF input.obj reconstructed.obj 128 0.05\n```\n\nReads the mesh → builds a 128³ voxel grid covering its padded bbox → samples\nthe SDF via fast winding number → extracts the iso-surface with marching\ncubes → writes it. Source in `Sources/MeshToSDF/main.swift`.\n\n## Current surface (v0.1)\n\n- **Mesh I/O** — `readTriangleMesh`, `writeTriangleMesh` (`.obj`, `.off`, `.ply`, `.stl`, `.mesh`, `.wrl`)\n- **Normals** — `perVertexNormals`, `perFaceNormals`\n- **Signed distance / inside-outside** — `signedDistance(of:on:type:)`, `windingNumber(of:on:)`\n- **Voxelization** — `voxelGrid`, `marchingCubes`\n- **Mesh processing** — `boundingBox`, `decimate`, `removeDuplicateVertices`, `uniqueSimplices`\n\nModules currently **out of scope**: `copyleft/cgal` (booleans), `tetgen`,\n`embree`, `predicates`, `restricted/*`. Open an issue if you need any.\n\n## Requirements\n\n- macOS 13+\n- Swift 6.0 / Xcode 16+\n- C++17\n\n## How it's built\n\n```\nlibigl-xcframework-builder  →  igl.xcframework  →  SwiftIGL\n  (sibling repo, shell)         (header-only         (Swift API\n  produces stub-lib +            xcframework,         + thin C++\n  headers xcframework)           released via         bridge)\n                                 GH Releases)\n```\n\n- **`igl` binaryTarget** — library-form xcframework: a stub `.a` plus\n  `Headers/{igl, Eigen, unsupported}/`. Library-form (not framework-form)\n  so both `\u003cigl/...\u003e` and `\u003cEigen/...\u003e` resolve in C++ TUs.\n- **`CxxIGL` target** — hand-written C++ bridge. Owns every `#include`\n  of libigl/Eigen. Narrow surface (no Eigen types, no exceptions, only\n  `std::string` + `std::vector\u003cdouble|int32_t\u003e` across the boundary).\n- **`SwiftIGL` target** — idiomatic Swift API. C++ interop is enabled\n  here only; consumers' Swift code uses the Swift API and never sees a\n  C++ type.\n\nWhy **header-only library-form** xcframework: libigl consumers need\nboth `\u003cigl/...\u003e` and `\u003cEigen/...\u003e` resolvable in C++ TUs. A\nsingle-prefix framework module cannot offer both; a library+headers\nxcframework can.\n\n## Local development\n\nBy default the package resolves `igl.xcframework` from a GitHub Release.\nTo iterate against a locally-built xcframework, swap the binaryTarget\nin `Package.swift`:\n\n```swift\n.binaryTarget(name: \"igl\", path: \"Frameworks/igl.xcframework\")\n```\n\nRebuild with:\n\n```sh\ncd ../../cpp/libigl-xcframework-builder\nmake LIBIGL_VERSION=2.5.0\n```\n\nThe builder mirrors into `SwiftIGL/Frameworks/` when\n`SWIFT_PACKAGE_FRAMEWORKS_DIR` is set in its `config.sh`. `Frameworks/`\nis gitignored.\n\n## Build \u0026 test\n\n```sh\nswift build\nswift test\n```\n\n## Design notes\n\n- **No Eigen types cross the Swift boundary.** Eigen's expression\n  templates and \u003e3 generic parameters fall outside Swift's C++ interop\n  surface. The bridge wraps caller buffers with `Eigen::Map\u003c\u003e`\n  internally and copies results back into flat `std::vector`s.\n- **No exceptions cross the boundary.** Every bridge entry point\n  returns `bool`; on failure it writes a message to a trailing\n  `std::string\u0026`. Swift rethrows as `IGLError`.\n- **Flat row-major storage** (`3 * V` doubles, `3 * F` int32_t).\n  Matches typical GPU/raw-buffer layouts (Metal, MLX, nvdiffrast) —\n  no transpose at the boundary; no per-row allocation.\n\n## License\n\n[MIT](LICENSE) for the SwiftIGL bindings. The bundled libigl + Eigen\nheaders remain under their original [MPL2](THIRD_PARTY_LICENSES.md)\nlicenses.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmnmly%2Fswiftigl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmnmly%2Fswiftigl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmnmly%2Fswiftigl/lists"}