Cut
The Cut module splits meshes along intersection curves, performs boolean operations, and classifies regions. It builds on the Intersect module for computing intersections. All operations are geometrically and topologically exact.
import trueform as tf
Overview
The Cut module provides operations at several levels:
- Embedded intersection curves: Split a mesh along intersection curves without classifying regions
- Mesh arrangements: Decompose two or more meshes into classified regions — the complete intersection problem
- Boolean operations: Select regions from arrangements to produce union, intersection, or difference
- Polygon arrangements: Decompose a mesh at its self-intersection curves
- Isocurve embedding: Split meshes along scalar field level sets
All cut operations return face_labels — an array mapping each output face back to the index of the original face it came from in the source mesh. This enables attribute transfer and provenance tracking. Multi-mesh operations (arrangements and booleans) additionally return tag_labels (or labels) — which input mesh each face belongs to.
All cut operations support an optional return_curves=True parameter that additionally returns the intersection curves.
Supported Input
Embedding and arrangement operations inherit the same robustness as the Intersect module:
- Open and closed meshes — boundaries are handled correctly
- Non-manifold edges — edges shared by 3 or more faces
- Coplanar faces — overlapping faces are classified
- Self-intersecting geometry — detected and resolved
- Crossing intersection curves — where curves from different mesh pairs meet on a face, crossings can be resolved. Controlled via
resolve_crossingsandresolve_self_crossingsparameters — see Intersection Modes.
Boolean operations additionally require that intersection curves split the meshes into separate inside/outside regions. Input meshes should be PWN (piecewise winding number) — locally consistent orientation.
tf.embedded_self_intersection_curves or tf.polygon_arrangements.Embedded Intersection Curves
Embed intersection curves between mesh A and mesh B into mesh A, without performing boolean selection:
(faces, points), face_labels = tf.embedded_intersection_curves(mesh0, mesh1)
# With curves
(faces, points), face_labels, (paths, curve_pts) = tf.embedded_intersection_curves(
mesh0, mesh1, return_curves=True)
# With explicit mode
(faces, points), face_labels = tf.embedded_intersection_curves(
mesh0, mesh1, mode="primitives", resolve_self_crossings=True)
Default: mode="primitives", resolve_crossings=False, resolve_self_crossings=False.
Self-Intersection
Embed curves where a mesh intersects itself:
(faces, points), face_labels = tf.embedded_self_intersection_curves(mesh)
# With curves
(faces, points), face_labels, (paths, curve_pts) = tf.embedded_self_intersection_curves(
mesh, return_curves=True)
Default: mode="primitives", resolve_crossings=True, resolve_self_crossings=True.
Mesh Arrangements
Decompose intersecting meshes into classified regions:
(faces, points), tag_labels, face_labels = tf.mesh_arrangements([mesh0, mesh1])
# With curves
(faces, points), tag_labels, face_labels, (paths, curve_pts) = tf.mesh_arrangements(
[mesh0, mesh1], return_curves=True)
# With explicit mode
(faces, points), tag_labels, face_labels = tf.mesh_arrangements(
[mesh0, mesh1, mesh2], mode="primitives", resolve_crossings=True)
Returns:
tag_labels: Which input mesh each face came from (0or1)face_labels: Index of the original face each output face came from
Default: mode="primitives", resolve_crossings auto (True for 3+ meshes, False for 2), resolve_self_crossings=False.
Polygon Arrangements
Decompose a single mesh at its self-intersection curves:
(faces, points), face_labels = tf.polygon_arrangements(mesh)
# With curves
(faces, points), face_labels, (paths, curve_pts) = tf.polygon_arrangements(
mesh, return_curves=True)
Default: mode="primitives", resolve_crossings=True, resolve_self_crossings=True.
Boolean Operations
Boolean operations combine two meshes using set operations:
# Union: A ∪ B
(faces, points), labels, face_labels = tf.boolean_union(mesh0, mesh1)
# Intersection: A ∩ B
(faces, points), labels, face_labels = tf.boolean_intersection(mesh0, mesh1)
# Difference: A - B
(faces, points), labels, face_labels = tf.boolean_difference(mesh0, mesh1)
Booleans use primitives mode internally with no contour crossing resolution — with two meshes only one contour exists, so crossings cannot occur.
With curves:
(faces, points), labels, face_labels, (paths, curve_pts) = tf.boolean_union(
mesh0, mesh1, return_curves=True)
With transformations:
import numpy as np
mesh1.transformation = np.eye(4, dtype=np.float32)
mesh1.transformation[:3, 3] = [5, 0, 0]
(faces, points), labels, face_labels = tf.boolean_union(mesh0, mesh1)
Isobands
Extract regions between consecutive threshold values from scalar fields:
(faces, points), labels, face_labels = tf.isobands(mesh, scalar_field, [-1.0, 0.0, 1.0])
# Select specific bands
(faces, points), labels, face_labels = tf.isobands(
mesh, scalar_field, cut_values, selected_bands=[1, 3])
# With curves
(faces, points), labels, face_labels, (paths, curve_pts) = tf.isobands(
mesh, scalar_field, cut_values, return_curves=True)
