Skip to content

copyleft.do_meshes_intersect

do_meshes_intersect(V1, F1, V2, F2)

Finds whether two surface triangle meshes intersect.

Given two triangle meshes A and B, uses exact predicates to compute whether any pair of triangles triA and triB intersect one another.

Parameters:

Name Type Description Default
V1 numpy double array

Matrix of vertex coordinates of the first mesh

required
F1 numpy int array

Matrix of triangle indices of the first mesh

required
V2 numpy double array

Matrix of vertex coordinates of the second mesh

required
F2 numpy int array

Matrix of triangle indices of the second mesh

required

Returns:

Name Type Description
b bool

True if the meshes have non-trivial intersection, False otherwise

inters numpy int array

One pair of intersecting triangle indices.

See Also

mesh_boolean.

Notes

The algorithm stops when it finds one intersection; therefore, the output is not a complete list of all intersecting triangles

Examples:

TO-DO

Source code in src/gpytoolbox/copyleft/do_meshes_intersect.py
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
def do_meshes_intersect(V1,F1,V2,F2):
    """Finds whether two surface triangle meshes intersect.

    Given two triangle meshes A and B, uses exact predicates to compute whether any pair of triangles triA and triB intersect one another.

    Parameters
    ----------
    V1 : numpy double array
        Matrix of vertex coordinates of the first mesh
    F1 : numpy int array
        Matrix of triangle indices of the first mesh
    V2 : numpy double array
        Matrix of vertex coordinates of the second mesh
    F2 : numpy int array
        Matrix of triangle indices of the second mesh

    Returns
    -------
    b : bool
        True if the meshes have non-trivial intersection, False otherwise
    inters : numpy int array
        One pair of intersecting triangle indices.


    See Also
    --------
    mesh_boolean.

    Notes
    -----
    The algorithm stops when it finds one intersection; therefore, the output is not a complete list of all intersecting triangles

    Examples
    --------
    TO-DO
    """

    try:
        from gpytoolbox_bindings_copyleft import _do_meshes_intersect_cpp_impl
    except:
        raise ImportError("Gpytoolbox cannot import its C++ binding.")

    inters = list(_do_meshes_intersect_cpp_impl(V1,F1.astype(np.int32),V2,F2.astype(np.int32)))
    b = False
    if len(inters[0])>0:
        b = True
        inters = inters[0]  
    else:
        inters = None
    return b, inters