Skip to content

remove_duplicate_vertices

remove_duplicate_vertices(V, epsilon=0.0, faces=None)

Return unique vertices, optionally with a tolerance

Parameters:

Name Type Description Default
V numpy double array

Matrix of vertex positions

required
epsilon double, optional (default 0.0)

Positive uniqueness absolute tolerance

0.0
faces numpy int array, optional (default None)

Matrix of any-type mesh indices, for convenience

None

Returns:

Name Type Description
SV numpy double array

Matrix of new vertex positions

SVI numpy int array

Vector of indices such that SV = V[SVI,:]

SVJ numpy int array

Vector of indices such that V = SV[SVJ,:]

SF numpy int array

Matrix of new mesh indices into SV, only part of the output if faces is not None.

Source code in src/gpytoolbox/remove_duplicate_vertices.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
def remove_duplicate_vertices(V,epsilon=0.0,faces=None):
    """Return unique vertices, optionally with a tolerance

    Parameters
    ----------
    V : numpy double array
        Matrix of vertex positions
    epsilon : double, optional (default 0.0)
        Positive uniqueness absolute tolerance
    faces : numpy int array, optional (default None)
        Matrix of any-type mesh indices, for convenience

    Returns
    -------
    SV : numpy double array
        Matrix of new vertex positions
    SVI : numpy int array
        Vector of indices such that SV = V[SVI,:]
    SVJ : numpy int array
        Vector of indices such that V = SV[SVJ,:]
    SF : numpy int array
        Matrix of new mesh indices into SV, only part of the output if faces is not None.
    """

    if epsilon==0.0:
        SV, SVI, SVJ = np.unique(V,return_index=True,return_inverse=True,axis=0)
    else:
        _, SVI, SVJ = np.unique(np.round(V/epsilon),return_index=True,return_inverse=True,axis=0)
        SV = V[SVI,:]

    if (faces is None):
        return SV, SVI, SVJ
    else:
        return SV, SVI, SVJ, SVJ[faces]