yapcad.boolean package
Submodules
yapcad.boolean.native module
Native boolean engine extracted from yapcad.geom3d.
- yapcad.boolean.native.stitch_open_edges(triangles, tol)[source]
Experimental: attempt to close open edge loops by triangulating them.
- Parameters:
triangles (Iterable) – A sequence of triangle coordinate lists
[[x, y, z, w], ...]describing a mesh with potential boundary edges.tol (float) – Tolerance used when deduplicating vertices and detecting shared edges. Typically reuse
_DEFAULT_RAY_TOL.
- Returns:
A new list of triangles with any stitched faces appended.
- Return type:
- yapcad.boolean.native.stitch_solid(sld, tol=1e-07)[source]
Experimental helper that runs
stitch_open_edges()on a solid.
yapcad.boolean.occ_engine module
OCC-backed boolean engine operating on BrepSolid metadata.
- yapcad.boolean.occ_engine.solid_boolean(a, b, operation: str)[source]
Perform an OCC boolean, falling back to mesh engine if BREP unavailable.
Handles both single-solid results and compound results (e.g., union of disconnected solids produces a compound containing multiple solids).
For union operations, includes sanity check: if the result volume is significantly less than expected (more than 10% loss), falls back to creating a simple compound containing both shapes. This works around OCC boolean issues with certain lofted/swept shapes.
If either solid lacks BREP metadata, automatically falls back to the native mesh boolean engine rather than raising an error.
yapcad.boolean.trimesh_engine module
Trimesh-backed boolean engine for yapCAD solids.
This engine is optional. It converts yapCAD solids to trimesh.Trimesh
instances, dispatches boolean operations via trimesh.boolean, and
converts the resulting mesh back into a yapCAD solid.
Availability depends on both the trimesh package and at least one
boolean backend supported by trimesh (e.g. Blender, OpenSCAD, Cork).
- yapcad.boolean.trimesh_engine.engines_available() set[str][source]
Return the set of trimesh boolean backends that are operational.