Skip to main content

Module boolean

Module boolean 

Source
Expand description

Boolean operations (union, subtract, intersect) between two closed meshes.

boolean_plan splits every triangle of mesh A that mesh B crosses (and vice versa) so that each piece lies strictly on one side of the other mesh, and classifies the pieces; apply_boolean writes the plan into A’s transaction. The result stays on A with A’s placement, like a cut that keeps the tool: for world-space booleans the caller maps B into A’s frame first (see fast-mesh-scene).

Inputs must be closed, manifold, consistently wound, and free of degenerate, duplicate and self-intersecting triangles; anything else is OpsError::InvalidInput. Touches at a point or along an edge are fine, and so are coplanar area overlaps (flush faces): a piece whose centroid lies on the tool surface is decided by the surface just outside it. Disjoint inputs need no splitting (union concatenates, intersect is empty, subtract keeps A); nested inputs classify whole.

Each side is split independently against the other’s surface, so the two rims along the intersection curve generally carry different vertices. The apply step stitches them without any winding assumption: every rim edge is split at the other rim’s nearby vertices (reusing their ids), and a final weld merges what is left within tolerance. The output is closed when the inputs are; point and edge touches leave pinch vertices.

New vertices take channel defaults; only positions and triangles cross over. Tolerances scale with the inputs (1e-6 of the coordinate magnitude); meshes with features near that scale may weld together.

Structs§

BooleanPlan
The plan of boolean_plan: what to drop, rewrite and add on mesh A. Built read-only from both meshes; apply_boolean writes it.
BooleanReport
What apply_boolean did.

Enums§

BooleanOp
Which boolean to compute.

Functions§

apply_boolean
Applies plan to A’s transaction: drops, rewrites and adds triangles, stitches the two rims, welds and cleans up. A failure rolls the transaction back, so the call stays atomic through Scene::edit-style callers.
boolean_plan
Plans the boolean op of A with B (B placed in A’s frame by xf): the result replaces A. Reads only; apply_boolean writes the plan.