Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
manifold-csg
Safe Rust bindings to the manifold3d geometry kernel for constructive solid geometry (CSG).
manifold3d is a fast, robust C++ library for boolean operations on 3D triangle meshes. These bindings make its capabilities accessible from Rust with minimal overhead and without requiring users to manage C pointers or memory. See the upstream documentation for details on the underlying algorithms and behavior.
What's included
manifold-csg-sys provides raw FFI bindings to the manifold3d C API. If
you need direct C-level control, it's there.
manifold-csg wraps the most commonly needed operations in safe Rust:
- 3D solids (
Manifold) — primitives (cube, sphere, cylinder, tetrahedron), boolean operations (union, difference, intersection), transforms, convex hull, decomposition, Minkowski sum/difference, mesh refinement, smoothing, SDF level sets, warp deformation, and OBJ I/O - 2D regions (
CrossSection) — primitives (square, circle, polygons), boolean operations, Clipper2-based geometric offset, convex hull, transforms, warp, and simplification - Mesh data (
MeshGL64/MeshGL) — f64 and f32 mesh types for getting data in and out - Triangulation (
triangulate_polygons) — constrained Delaunay triangulation of 2D polygons - 2D-to-3D — extrude (with optional twist and scale) and revolve cross-sections into solids; slice solids back to cross-sections
See API_COVERAGE.md for a full table mapping every C API function to its safe wrapper (or noting where one doesn't exist yet).
Design choices
- f64 by default. Mesh I/O uses
MeshGL64so you don't lose precision through f32 round-trips. f32 paths (from_mesh_f32,to_mesh_f32,MeshGL) are available when you need them. Send+Sync. All types can be moved across threads and shared for concurrent reads.- Automatic memory management. All C handles are freed via
Drop. No manual cleanup needed. - Operator overloads.
&a + &b(union),&a - &b(difference),&a ^ &b(intersection) work on bothManifoldandCrossSection. - Callback-based APIs wrapped safely.
warp,set_properties,from_sdf, and OBJ I/O all accept closures withcatch_unwindto prevent panics from unwinding through C stack frames. - C API parity. Parameter order and names follow the C API so users transitioning from C/C++ find things where they expect.
Quick start
use ;
// 3D: drill a cylindrical hole through a cube
let cube = cube;
let hole = cylinder;
let result = &cube - &hole;
assert!;
// 2D -> 3D: offset a rectangle and extrude it
let section = square;
let expanded = section.offset;
let solid = expanded.extrude;
See the examples/ directory for more
complete, runnable examples.
Crates
| Crate | Description |
|---|---|
manifold-csg |
Safe Rust wrapper (start here) |
manifold-csg-sys |
Raw FFI bindings to the full C API |
Build requirements
- Rust 1.85+
- git, cmake, a C++ compiler
- First build clones manifold3d and compiles it from source; subsequent builds use the cached copy. Internet access is required for the initial clone.
Tested on Linux, macOS, and Windows.
Feature flags
| Feature | Default | Description |
|---|---|---|
parallel |
yes | Enables TBB-based parallelism for boolean operations |
nalgebra |
no | Adds convenience methods that accept nalgebra::Matrix3, Vector3, Point3 |
Documentation
- API_COVERAGE.md — maps every manifold3d C function to its safe wrapper, with source links
- docs.rs — generated API docs
- examples/ — runnable code examples
- Upstream docs — manifold3d C++ API documentation (helpful for understanding parameter semantics)
License
Licensed under either of Apache License, Version 2.0 or MIT license at your option.