Modules | PY

Arrangement

Exact mesh arrangements, polygon arrangements, and region classification.

The Arrangement module splits meshes along intersection curves 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 Arrangement module provides operations at several levels:

  • Mesh arrangements: Decompose two or more meshes into classified regions — the complete intersection problem
  • Polygon arrangements: Decompose a mesh at its self-intersection curves

All arrangement 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 arrangements additionally return tag_labels — which input mesh each face belongs to.

All arrangement operations support an optional return_curves=True parameter that additionally returns the intersection curves.

To split a mesh along the level sets of a scalar field, see the Iso module.

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. Configured via mode, tolerance, and resolve_crossings/resolve_self_crossings parameters — see Intersection Configuration.

Region classification additionally requires that intersection curves split the meshes into separate inside/outside regions. Input meshes should be PWN (piecewise winding number) — locally consistent orientation.

To detect where a single mesh's own polygons intersect each other, use tf.polygon_arrangements.

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)

# With tolerance — recover the intended topology on inputs that carry
# float-precision drift. See Intersection Configuration.
(faces, points), tag_labels, face_labels = tf.mesh_arrangements(
    [mesh0, mesh1], tolerance=1e-6)

Returns:

  • tag_labels: Which input mesh each face came from (0 or 1)
  • face_labels: Index of the original face each output face came from

Default: mode="primitives", tolerance=0.0 (exact), resolve_crossings auto (True for 3+ meshes, False for 2), resolve_self_crossings=False, within=False (set it when a mesh can self-overlap, e.g. meshes concatenated into one input). See Intersection Configuration.

Both arrangement functions also take triangulation="cdt" (default) or "refined_cdt" — a quality-refined triangulation of the cut surfaces that adds Steiner points; shared boundaries stay watertight by construction. Same option as CsgGraph.

(faces, points), tag_labels, face_labels = tf.mesh_arrangements(
    [mesh0, mesh1], triangulation="refined_cdt")

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

tf.boolean_union, tf.boolean_intersection and tf.boolean_difference are the two-operand case of the CSG arrangement and live in the CSG module.

For implementation details, see the C++ Arrangement documentation.