meshing.diagnostics.self_intersections
meshing.diagnostics.self_intersections(mesh, *, pairs=4096, seed=0)Sampled self-intersection test over non-adjacent triangle pairs.
Draws pairs random triangle pairs with the deterministic np.random.default_rng(seed), discards pairs that share a vertex index (adjacent triangles legitimately touch), and tests the rest by segment-plane clipping: two non-coplanar triangles intersect exactly when an edge of one crosses the interior of the other, so all six edge segments are clipped against the opposing triangle’s plane and checked in barycentric coordinates. Coplanar overlaps and exact touching are not reported.
This is a sampled check, not a proof: it tests O(pairs) of the O(t^2) triangle pairs, so a clean report means no intersection was found among the tested pairs, not that none exists. Raise pairs for more coverage.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| mesh | Mesh | The mesh to test. | required |
| pairs | int | Number of random pairs to draw; must be positive. | 4096 |
| seed | int | Seed for the deterministic pair draw. | 0 |
Returns
| Name | Type | Description |
|---|---|---|
| dict[str, Any] | Dict with count (number of distinct intersecting pairs found), |
|
| dict[str, Any] | pairs (their sorted triangle-index pairs, shaped (count, 2)), |
|
| dict[str, Any] | and tested (how many non-adjacent pairs were actually tested). |
Raises
| Name | Type | Description |
|---|---|---|
| ValueError | If pairs is not positive. |