Skip to main content

Crate manifold_csg_sys

Crate manifold_csg_sys 

Source
Expand description

Raw FFI bindings to the manifold3d C API.

These are low-level, unsafe bindings. Users should prefer the safe wrappers in the manifold-csg crate.

§Overview

manifold3d is a geometry kernel for constructive solid geometry (CSG) operations. It provides:

  • 3D Boolean operations: union, difference, intersection of solid meshes
  • 2D cross-section operations: offset, boolean, hull for 2D regions
  • Mesh construction: from vertices/indices, primitives (cube, sphere, cylinder)
  • Extrusion: 2D cross-sections to 3D solids
  • Queries: volume, surface area, bounding box, vertex/face counts

Structs§

ManifoldBox
Opaque handle to a manifold3d Box (3D axis-aligned bounding box).
ManifoldCrossSection
Opaque handle to a manifold3d CrossSection object (2D region).
ManifoldCrossSectionVec
Opaque handle to a manifold3d CrossSectionVec (vector of CrossSection objects).
ManifoldExecutionContext
Opaque handle to a manifold3d ExecutionContext — observes progress and allows cooperative cancellation of long-running boolean evaluations. The C API documents it as safe to read/write from any thread.
ManifoldIVec3
3D integer vector.
ManifoldManifold
Opaque handle to a manifold3d Manifold object (3D solid).
ManifoldManifoldPair
Pair of manifolds returned by manifold_split / manifold_split_by_plane.
ManifoldManifoldVec
Opaque handle to a manifold3d ManifoldVec (vector of Manifold objects).
ManifoldMeshGL
Opaque handle to a manifold3d MeshGL object (f32 vertices, u32 indices).
ManifoldMeshGL64
Opaque handle to a manifold3d MeshGL64 object (f64 vertices, u64 indices).
ManifoldMeshGL64Options
Options for constructing a MeshGL64 with additional metadata.
ManifoldMeshGLOptions
Options for constructing a MeshGL with additional metadata.
ManifoldPolygons
Opaque handle to a manifold3d Polygons object (2D polygon set).
ManifoldProperties
Surface area and volume properties returned by manifold queries.
ManifoldRayHit
Result of a ray-manifold intersection test.
ManifoldRayHitVec
Opaque handle to a manifold3d RayHitVec (vector of ray hit results).
ManifoldRect
Opaque handle to a manifold3d Rect (2D axis-aligned bounding box).
ManifoldSimplePolygon
Opaque handle to a manifold3d SimplePolygon object (single polygon ring).
ManifoldTriangulation
Opaque handle to a manifold3d Triangulation result.
ManifoldVec2
2D vector used by manifold3d polygon API.
ManifoldVec3
3D vector returned by manifold3d C API.
ManifoldVec4
4D vector (e.g. for tangents with weight).

Enums§

ManifoldError
Error codes from manifold3d status check.
ManifoldFillRule
Fill rule for constructing CrossSections from polygons.
ManifoldJoinType
Join type for CrossSection offset operations (Clipper2).
ManifoldOpType
Boolean operation type for manifold_batch_boolean.

Functions§

manifold_alloc_box
manifold_alloc_cross_section
manifold_alloc_cross_section_vec
manifold_alloc_execution_context
manifold_alloc_manifold
manifold_alloc_manifold_vec
manifold_alloc_meshgl
manifold_alloc_meshgl64
manifold_alloc_polygons
manifold_alloc_ray_hit_vec
manifold_alloc_rect
manifold_alloc_simple_polygon
manifold_alloc_triangulation
manifold_as_original
Mark this manifold as the original, assigning it a unique ID for tracking through boolean operations.
manifold_batch_boolean
Batch boolean: apply op across all manifolds in the vector.
manifold_batch_hull
Compute the convex hull of a set of manifolds.
manifold_boolean
Generic boolean operation between two manifolds.
manifold_bounding_box
manifold_box
manifold_box_center
manifold_box_contains_box
manifold_box_contains_pt
manifold_box_dimensions
manifold_box_does_overlap_box
manifold_box_does_overlap_pt
manifold_box_include_pt
manifold_box_is_finite
manifold_box_max
manifold_box_min
manifold_box_mul
manifold_box_scale
manifold_box_size
manifold_box_transform
manifold_box_translate
manifold_box_union
manifold_calculate_curvature
Calculate Gaussian and mean curvature and store at the given property indices.
manifold_calculate_normals
Calculate vertex normals and store at the given property index.
manifold_compose
Compose multiple manifolds into a single compound manifold.
manifold_copy
manifold_cross_section_area
manifold_cross_section_batch_boolean
Batch boolean: apply op across all cross-sections in the vector.
manifold_cross_section_batch_hull
Compute the convex hull of a set of cross-sections.
manifold_cross_section_boolean
Generic boolean operation between two cross-sections.
manifold_cross_section_bounds
manifold_cross_section_circle
manifold_cross_section_compose
Compose multiple cross-sections into a single compound cross-section.
manifold_cross_section_copy
manifold_cross_section_decompose
manifold_cross_section_difference
manifold_cross_section_empty
manifold_cross_section_empty_vec
manifold_cross_section_hull
manifold_cross_section_hull_polygons
Compute the convex hull of a polygon set.
manifold_cross_section_hull_simple_polygon
Compute the convex hull of a simple polygon.
manifold_cross_section_intersection
manifold_cross_section_is_empty
manifold_cross_section_mirror
manifold_cross_section_num_contour
manifold_cross_section_num_vert
manifold_cross_section_of_polygons
manifold_cross_section_of_simple_polygon
manifold_cross_section_offset
Offset (inflate/deflate) a cross-section by delta.
manifold_cross_section_rotate
manifold_cross_section_scale
manifold_cross_section_simplify
Simplify the contours of a cross-section to within epsilon tolerance.
manifold_cross_section_size
manifold_cross_section_square
manifold_cross_section_to_polygons
manifold_cross_section_transform
manifold_cross_section_translate
manifold_cross_section_union
manifold_cross_section_vec
manifold_cross_section_vec_get
manifold_cross_section_vec_length
manifold_cross_section_vec_push_back
manifold_cross_section_vec_reserve
manifold_cross_section_vec_set
manifold_cross_section_vec_size
manifold_cross_section_warp_context
Warp a cross-section by applying a function to each vertex.
manifold_cube
manifold_cylinder
manifold_decompose
Decompose a manifold into its connected components.
manifold_delete_box
manifold_delete_cross_section
manifold_delete_cross_section_vec
manifold_delete_execution_context
manifold_delete_manifold
manifold_delete_manifold_vec
manifold_delete_meshgl
manifold_delete_meshgl64
manifold_delete_polygons
manifold_delete_ray_hit_vec
manifold_delete_rect
manifold_delete_simple_polygon
manifold_delete_triangulation
manifold_destruct_box
manifold_destruct_cross_section
manifold_destruct_cross_section_vec
manifold_destruct_execution_context
manifold_destruct_manifold
manifold_destruct_manifold_vec
manifold_destruct_meshgl
manifold_destruct_meshgl64
manifold_destruct_polygons
manifold_destruct_ray_hit_vec
manifold_destruct_rect
manifold_destruct_simple_polygon
manifold_destruct_triangulation
manifold_difference
manifold_empty
manifold_epsilon
manifold_execution_context
Construct an ExecutionContext in pre-allocated memory. Attach to a manifold via manifold_with_context; subsequent eager operations on the result observe the context.
manifold_execution_context_cancel
Request cancellation of any boolean evaluation observing this context. Sticky: once cancelled, the context stays cancelled.
manifold_execution_context_cancelled
Returns nonzero if the context has been cancelled.
manifold_execution_context_progress
Progress in [0.0, 1.0] for an in-flight evaluation observing this context.
manifold_execution_context_size
manifold_extrude
Extrude a 2D polygon set into a 3D manifold along the Z axis.
manifold_genus
manifold_get_circular_segments
Get the number of circular segments for a given radius.
manifold_get_meshgl
Extract MeshGL from a Manifold.
manifold_get_meshgl64
Extract MeshGL64 from a Manifold.
manifold_get_meshgl64_w_normals
Extract MeshGL64 from a Manifold with normals at the given property index.
manifold_get_meshgl_w_normals
Extract MeshGL from a Manifold with normals at the given property index.
manifold_get_tolerance
manifold_hull
Compute the convex hull of a manifold.
manifold_hull_pts
Compute the convex hull of a set of 3D points.
manifold_intersection
manifold_is_empty
manifold_level_set
Create a manifold from a signed distance function.
manifold_level_set_seq
Create a manifold from a signed distance function (sequential execution).
manifold_manifold_empty_vec
manifold_manifold_pair_size
manifold_manifold_size
manifold_manifold_vec
manifold_manifold_vec_get
manifold_manifold_vec_length
manifold_manifold_vec_push_back
manifold_manifold_vec_reserve
manifold_manifold_vec_set
manifold_manifold_vec_size
manifold_meshgl
Create a MeshGL from vertex properties and triangle indices. vert_props: flat f32 array [x,y,z,…] with n_props values per vertex. tri_verts: flat u32 array, 3 indices per triangle.
manifold_meshgl64
Create a MeshGL64 from f64 vertex properties and u64 triangle indices.
manifold_meshgl64_copy
Copy a MeshGL64.
manifold_meshgl64_face_id
Copy face IDs into caller-provided buffer.
manifold_meshgl64_face_id_length
manifold_meshgl64_halfedge_tangent
Copy halfedge tangents into caller-provided buffer.
manifold_meshgl64_merge
Merge coincident vertices in a MeshGL64, returning a new merged mesh.
manifold_meshgl64_merge_from_vert
Copy merge-from vertex indices into caller-provided buffer.
manifold_meshgl64_merge_length
manifold_meshgl64_merge_to_vert
Copy merge-to vertex indices into caller-provided buffer.
manifold_meshgl64_num_prop
manifold_meshgl64_num_run
Get the number of triangle runs.
manifold_meshgl64_num_tri
manifold_meshgl64_num_vert
manifold_meshgl64_read_obj
Import a MeshGL64 from a Wavefront obj file.
manifold_meshgl64_run_flags
Copy run flags into caller-provided buffer.
manifold_meshgl64_run_flags_length
Get the number of run flags.
manifold_meshgl64_run_index
Copy run indices into caller-provided buffer.
manifold_meshgl64_run_index_length
manifold_meshgl64_run_original_id
Copy run original IDs into caller-provided buffer.
manifold_meshgl64_run_original_id_length
manifold_meshgl64_run_transform
Copy run transforms into caller-provided buffer.
manifold_meshgl64_run_transform_length
manifold_meshgl64_size
manifold_meshgl64_tangent_length
manifold_meshgl64_tolerance
Get the tolerance of a MeshGL64.
manifold_meshgl64_tri_length
manifold_meshgl64_tri_verts
Copy u64 triangle indices into caller-provided buffer.
manifold_meshgl64_vert_properties
Copy f64 vertex properties into caller-provided buffer.
manifold_meshgl64_vert_properties_length
manifold_meshgl64_w_options
Create a MeshGL64 with full options (run indices, merge, tangents).
manifold_meshgl64_w_tangents
Create a MeshGL64 with halfedge tangents.
manifold_meshgl64_write_obj
Export a MeshGL64 to a Wavefront obj string via callback.
manifold_meshgl_copy
Copy a MeshGL.
manifold_meshgl_face_id
Copy face IDs into caller-provided buffer.
manifold_meshgl_face_id_length
manifold_meshgl_halfedge_tangent
Copy halfedge tangents into caller-provided buffer.
manifold_meshgl_merge
Merge coincident vertices in a MeshGL, returning a new merged mesh.
manifold_meshgl_merge_from_vert
Copy merge-from vertex indices into caller-provided buffer.
manifold_meshgl_merge_length
manifold_meshgl_merge_to_vert
Copy merge-to vertex indices into caller-provided buffer.
manifold_meshgl_num_prop
manifold_meshgl_num_run
Get the number of triangle runs.
manifold_meshgl_num_tri
manifold_meshgl_num_vert
manifold_meshgl_run_flags
Copy run flags into caller-provided buffer.
manifold_meshgl_run_flags_length
Get the number of run flags.
manifold_meshgl_run_index
Copy run indices into caller-provided buffer.
manifold_meshgl_run_index_length
manifold_meshgl_run_original_id
Copy run original IDs into caller-provided buffer.
manifold_meshgl_run_original_id_length
manifold_meshgl_run_transform
Copy run transforms into caller-provided buffer.
manifold_meshgl_run_transform_length
manifold_meshgl_size
manifold_meshgl_tangent_length
manifold_meshgl_tolerance
Get the tolerance of a MeshGL.
manifold_meshgl_tri_length
manifold_meshgl_tri_verts
Copy triangle indices into caller-provided buffer.
manifold_meshgl_vert_properties
Copy vertex properties into caller-provided buffer.
manifold_meshgl_vert_properties_length
manifold_meshgl_w_options
Create a MeshGL with full options (run indices, merge, tangents).
manifold_meshgl_w_tangents
Create a MeshGL with halfedge tangents.
manifold_min_gap
Compute the minimum gap between two manifolds within search_length.
manifold_minkowski_difference
Minkowski difference of two manifolds.
manifold_minkowski_sum
Minkowski sum of two manifolds.
manifold_mirror
Mirror a manifold across the plane defined by normal (nx, ny, nz).
manifold_num_edge
manifold_num_prop
manifold_num_prop_vert
manifold_num_tri
manifold_num_vert
manifold_of_meshgl
Create a Manifold from a MeshGL.
manifold_of_meshgl64
Create a Manifold from a MeshGL64.
manifold_original_id
manifold_polygons
Create a polygon set from an array of simple polygon pointers.
manifold_polygons_get_point
Get a point from a polygon set by simple polygon index and point index.
manifold_polygons_get_simple
Extract a simple polygon from a polygon set by index.
manifold_polygons_length
Get the number of simple polygons in a polygon set.
manifold_polygons_simple_length
Get the number of points in a specific simple polygon within a polygon set.
manifold_polygons_size
manifold_project
Project a manifold onto the XY plane, returning 2D polygons.
manifold_ray_cast
Cast a ray from origin to end against a manifold, returning all hits.
manifold_ray_hit_vec_get
Get a hit by index from a ray hit vector.
manifold_ray_hit_vec_length
Number of hits in a ray hit vector.
manifold_ray_hit_vec_size
manifold_read_obj
Import a manifold from a Wavefront obj file.
manifold_rect
manifold_rect_center
manifold_rect_contains_pt
manifold_rect_contains_rect
manifold_rect_dimensions
manifold_rect_does_overlap_rect
manifold_rect_include_pt
manifold_rect_is_empty
manifold_rect_is_finite
manifold_rect_max
manifold_rect_min
manifold_rect_mul
manifold_rect_scale
manifold_rect_size
manifold_rect_transform
manifold_rect_translate
manifold_rect_union
manifold_refine
Increase the density of the mesh by splitting every edge into refine pieces.
manifold_refine_to_length
Refine the mesh so that no edge is longer than length.
manifold_refine_to_tolerance
Refine the mesh to a given tolerance.
manifold_reserve_ids
Reserve a block of unique IDs for use with manifold_as_original.
manifold_reset_to_circular_defaults
manifold_revolve
Revolve a 2D polygon set around the Y axis to create a 3D manifold.
manifold_rotate
Rotate by Euler angles (degrees), applied in z-y’-x“ order.
manifold_scale
manifold_set_circular_segments
manifold_set_min_circular_angle
manifold_set_min_circular_edge_length
manifold_set_properties
Set custom properties on each vertex of a manifold.
manifold_set_tolerance
Set the tolerance of the manifold, returning a new manifold.
manifold_simple_polygon
Create a simple polygon from an array of 2D points.
manifold_simple_polygon_get_point
Get a point from a simple polygon by index.
manifold_simple_polygon_length
Get the number of points in a simple polygon.
manifold_simple_polygon_size
manifold_simplify
Simplify the mesh, removing vertices until the error exceeds tolerance.
manifold_slice
Slice a manifold at a given Z height, returning 2D polygons.
manifold_smooth
Create a smooth manifold from a MeshGL with per-halfedge smoothness.
manifold_smooth64
Create a smooth manifold from a MeshGL64 with per-halfedge smoothness.
manifold_smooth_by_normals
Smooth a manifold by converting sharp edges to smooth curves using vertex normals at the given property index.
manifold_smooth_out
Smooth out sharp edges of a manifold.
manifold_sphere
manifold_split
Split manifold a by manifold b into two parts.
manifold_split_by_plane
Split a manifold into two halves along a plane.
manifold_status
manifold_surface_area
manifold_tetrahedron
Construct a regular tetrahedron.
manifold_transform
Apply a 4x3 affine transformation matrix (column-major).
manifold_translate
manifold_triangulate
Triangulate a polygon set, returning triangle indices.
manifold_triangulation_num_tri
manifold_triangulation_size
manifold_triangulation_tri_verts
Copy triangle vertex indices into caller-provided buffer. Each triangle is 3 consecutive i32 values.
manifold_trim_by_plane
Trim to the positive side of a plane.
manifold_union
manifold_volume
manifold_warp
Warp a manifold by applying a function to each vertex.
manifold_with_context
Returns a copy of m with ctx attached. The attachment is consumed by the next eager op (manifold_status, manifold_refine*). Deferred ops (booleans, transforms, batch) ignore any attached context and produce results with no attached context.
manifold_write_obj
Export a manifold to a Wavefront obj string via callback.

Type Aliases§

ManifoldSdf
SDF callback: fn(x, y, z, ctx) -> distance