Skip to main content

Module mesh_boolean

Module mesh_boolean 

Source
Expand description

Mesh boolean operations on triangle meshes.

Provides robust boolean operations (union, intersection, difference) on closed triangle meshes using:

  • Triangle-triangle intersection detection — Möller’s separating axis test and segment/plane clipping.
  • Contour extraction — intersection curves between two meshes.
  • Surface splitting — re-triangulation of intersected faces.
  • Inside/outside classification — generalised winding number.
  • Co-planar triangle handling — projection-based merging.
  • Mesh stitching — combining split surfaces into a watertight result.
  • Result cleanup — degenerate triangle removal, vertex welding.

Structs§

IntersectionSegment
An intersection segment between two meshes.
MeshStats
Compute mesh quality statistics.
SimpleMesh
A simple indexed triangle mesh using [f64;3] vertices.

Enums§

MeshBooleanOp
Boolean operation type.
TriTriResult
Result of a triangle-triangle intersection test.

Functions§

classify_triangles
Classify each triangle of a mesh as inside or outside another mesh. Returns a boolean per triangle: true = inside.
cleanup_mesh
Full cleanup: weld, remove degenerates, remove unused.
compute_mesh_stats
Compute statistics for a mesh.
euler_characteristic
Compute the Euler characteristic: V - E + F.
extract_intersection_contours
Extract all intersection segments between two meshes.
is_inside
Classify whether a point is inside a closed mesh.
is_inside_ray
Parity-based inside test using ray casting.
is_watertight
Check if a mesh is watertight (every edge shared by exactly 2 triangles).
mesh_boolean
Perform a mesh boolean operation.
ray_mesh_intersection_count
Count ray-mesh intersections for parity-based inside/outside.
ray_triangle_intersect
Möller–Trumbore ray–triangle intersection. Returns Some(t) where t is the ray parameter at intersection.
remove_degenerate_triangles
Remove degenerate triangles (zero-area or duplicate vertex indices).
remove_unused_vertices
Remove unreferenced vertices and compact the index buffer.
split_triangle_by_plane
Split a triangle by a plane defined by (normal, point_on_plane). Returns (front_triangles, back_triangles) as vertex lists.
stitch_meshes
Combine two meshes into one, re-indexing the second mesh’s triangles.
triangle_triangle_intersection
Test if two triangles intersect using Möller’s method.
weld_vertices
Weld vertices that are closer than tolerance. Returns a new mesh with merged vertices.
winding_number
Compute the generalised winding number of a closed mesh at point p.