pysdic.Mesh.remove_unused_vertices#

Mesh.remove_unused_vertices(force_inplace=False)[source]#

Remove all unused vertices from the mesh, where unused vertices are defined as vertices that are not referenced in the connectivity of the mesh.

Note

The new vertices will be stored in a new vertices object (Copy of the original vertices object with only the used vertices). The new connectivity will be stored in a new connectivity object (Copy of the original connectivity object with only the remaining elements that are not connected to the removed vertices and with remapped vertex indices). The properties of the remaining vertices will be updated to keep only the properties of the remaining vertices and stored in the new vertices object.

See also

Parameters:

force_inplace (bool, optional) – If True, the vertices will be updated in place, modifying the original vertices object and the connectivity object will be updated in place as well. If False, new vertices and connectivity objects will be created to store the updated vertices and connectivity, leaving the original vertices and connectivity objects unchanged. By default False.

Return type:

None

Examples

Create a simple Mesh instance.

import numpy as np
from pysdic import Mesh, PointCloud

points = np.array([[0, 0, 0], [1, 0, 0], [0, 1, 0], [0, 0, 1], [1, 1, 1]])
connectivity = np.array([[0, 1, 2], [0, 1, 3], [0, 2, 3], [1, 2, 3]])
mesh3d = Mesh(points, connectivity, element_type="triangle_3")

Remove all unused vertices from the mesh.

1mesh3d.remove_unused_vertices()
2
3print(mesh3d.vertices)
4# Output: PointCloud with 4 points [[0, 0, 0], [1, 0, 0], [0, 1, 0], [0, 0, 1]]
5
6print(mesh3d.connectivity)
7# Output: Connectivity with 4 elements [[0, 1, 2], [0, 1, 3], [0, 2, 3], [1, 2, 3]]