Skip to main content

self_intersecting_pairs

Function self_intersecting_pairs 

Source
pub fn self_intersecting_pairs(
    mesh: &Mesh,
    bvh: &Bvh,
    out: &mut Vec<(TriangleId, TriangleId)>,
) -> Result<()>
Expand description

Appends to out every pair (a, b) with a < b of alive triangles of mesh that intersect or touch and share no vertex id. The appended pairs are sorted; elements already in out are kept and stay in front.

The test is exact on the f64 coordinates, as for intersecting_pairs. Pairs that share a vertex id are not tested at all: neighbours always touch along their shared edge or corner, so such a pair is never reported, even when the two triangles also cross elsewhere (a fold back onto a neighbour). Degenerate triangles, whose corners are collinear or repeat a vertex id, are skipped too. Distinct vertices at the same position are distinct vertices: two triangles meeting only through such a pair of vertices touch, and are reported.

The BVH is walked against itself so that each unordered pair of nodes is visited once, and each pair of triangles tested once.

ยงErrors

QueryError::MeshMismatch or QueryError::StaleBvh when bvh does not match mesh, and QueryError::OutOfMemory when out cannot grow. On any error out keeps its original length.