remove_unreferenced
remove_unreferenced(V, F, return_maps=False)
Removes vertices from a vertex-list-face-list polyline or mesh that are unreferenced in the face list. This can be useful to prevent, for example, a mass matrix that is not invertible because of vertices that are declared in a vertex list, but never used in the face list.
This function will silently skip -1
entries in F
.
You can use this, for example, to mark invalid vertices that are to be
skipped.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
V |
(n,d) numpy array or None
|
vertex list of a mesh. If this is None, will assume a mesh with max(F)+1 vertices. |
required |
F |
(m,k) numpy int array
|
index list of a polyline/triangle mesh/tet mesh |
required |
return_maps |
bool, optional (default False)
|
If True, will return mapping arrays |
False
|
Returns:
Name | Type | Description |
---|---|---|
newV |
(n1,d) numpy array or None
|
vertex list with unreferenced vertices removed, or None if V is None. |
newF |
(m1,d) numpy int array
|
index list with unreferenced vertices removed |
I |
(n,) or (n
|
index list such that |
J |
(n1,) numpy int array, if requested
|
index list such that |
See Also
libigl's remove_unreferenced, which this function is inspired by, but does
not perfectly mirror (in the presence of -1
in the face list, -1
will be
appended to the return value I
to ensure that I(F) == newF
).
Examples:
>>> V = np.array([[0.,0.],[1.,0.],[0.,1.],[-1.,-2.],[1.,1.]])
>>> F = np.array([[0,1,2],[2,1,4]])
>>> newV, newF, I, J = gpy.remove_unreferenced(V, F, return_maps=True)
>>> newV
array([[0., 0.],
[1., 0.],
[0., 1.],
[1., 1.]])
>>> newF
array([[0, 1, 2],
[2, 1, 3]])
>>> I
array([ 0, 1, 2, -1, 3])
>>> J
array([0, 1, 2, 4])
Source code in src/gpytoolbox/remove_unreferenced.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 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
|