Skip to content

triangle_triangle_adjacency

triangle_triangle_adjacency(F)

Given a manifold triangle mesh with face indices F, computes adjacency info between triangles

The ordering convention for halfedges is the following: [halfedge opposite vertex 0, halfedge opposite vertex 1, halfedge opposite vertex 2]

Parameters:

Name Type Description Default
F (m,3) numpy int array

face index list of a triangle mesh

required

Returns:

Name Type Description
TT (m,3) numpy int array

Index list specifying which face j is adjacent to which face i across the respective halfedge in position (i,j). If there is no adjacent face (boundary halfedge), the entry is -1.

TTi (m,3) numpy int array

Index list specifying which halfedge of face j (0,1,2) is adjacent to i in position (i,j).

Examples:

TODO

Source code in src/gpytoolbox/triangle_triangle_adjacency.py
 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
def triangle_triangle_adjacency(F):
    """Given a manifold triangle mesh with face indices F, computes adjacency
    info between triangles

    The ordering convention for halfedges is the following:
    [halfedge opposite vertex 0,
     halfedge opposite vertex 1,
     halfedge opposite vertex 2]

    Parameters
    ----------
    F : (m,3) numpy int array
        face index list of a triangle mesh

    Returns
    -------
    TT : (m,3) numpy int array
        Index list specifying which face j is adjacent to which face i across
        the respective halfedge in position (i,j).
        If there is no adjacent face (boundary halfedge), the entry is -1.
    TTi : (m,3) numpy int array
        Index list specifying which halfedge of face j (0,1,2) is adjacent to i
        in position (i,j).

    Examples
    --------
    TODO

    """

    m = F.shape[0]
    assert m > 0
    assert F.shape[1] == 3

    he = halfedges(F)
    he_flat = np.concatenate((he[:,0,:], he[:,1,:], he[:,2,:]), axis=0)
    he_flip_flat = np.flip(he_flat, axis=-1)

    map_to_flip = array_correspondence(he_flat,he_flip_flat,axis=1)
    TT = np.reshape(np.where(map_to_flip<0, -1, map_to_flip % m), F.shape, order='F')
    TTi = np.reshape(np.where(map_to_flip<0, -1, map_to_flip // m), F.shape, order='F')

    return TT, TTi