Analyse a mesh - openep.mesh.mesh_routines¶
This module provides methods for calculating the mesh surface area and volume, calculating Euclidian and geodesic distances bewteen points on a mesh, and identifying the free boundaries of a mesh,
Calculating the mesh surface area and volume¶
-
openep.mesh.mesh_routines.calculate_mesh_volume(mesh: pyvista.PolyData, fill_holes: bool = True) → float[source]¶ Calculate the volume of a mesh.
- Parameters
mesh (PolyData) – mesh for which the volume will be calculated
fill_holes – if True, holes in the mesh are filled. If holes are present the volume is meaningless unless
they are filled.
- Returns
The volume of the mesh.
-
openep.mesh.mesh_routines.calculate_field_area(mesh: pyvista.PolyData, field: numpy.ndarray, threshold: float) → float[source]¶ Calculate the total surface area of cells whose corresponding values in field are less than or equal to the given threshold.
- Parameters
mesh (PolyData) – pyvista mesh
field (ndarray) – scalar values that will be filtered based on the given threshold
threshold (float) – cells with values in field less than or equal to this value will be included when calculating the surface area.
- Returns
float – total area of selected cells
Note
This function makes use of
openep.mesh.mesh_routines.calculate_per_triangle_field()
-
openep.mesh.mesh_routines.calculate_per_triangle_field(mesh: pyvista.PolyData, field: numpy.ndarray) → numpy.ndarray[source]¶ Calculate a per-triangle field from the given per-vertex field. For each triangle the mean of the vertex values is calculated as the triangle value.
- Parameters
mesh (PolyData) – PolyData mesh
field – per-vertex field to convert
- Returns
np.ndarray per-triangle field
Distances between points on a mesh¶
-
openep.mesh.mesh_routines.calculate_vertex_distance(mesh: pyvista.PolyData, start_index: int, end_index: int, metric: str = 'geodesic') → float[source]¶ Calculate the distance from vertex at start_idx to end_idx.
Either the Euclidian or geodesic distance can be calculated.
- Parameters
mesh (PolyData) – Polydata mesh
start_index (int) – index of starting vertex
end_index (int) – index of ending vertex
metric (str) – The distance metric to use. The distance function can be ‘geodesic’ or ‘euclidian’.
- Returns
float – distance between vertices
-
openep.mesh.mesh_routines.calculate_vertex_path(mesh: pyvista.PolyData, start_index: int, end_index: int) → numpy.ndarray[source]¶ Calculate the path from vertex at start_idx to end_idx as a path of vertices through the mesh.
This is a wrapper around pyvista.PolyData.geodesic, but it returns an empty array if no path exist between the two vertices.
- Parameters
mesh (PolyData) – Polydata mesh
start_index (int) – index of starting vertex
end_index (int) – index of ending vertex
- Returns
ndarray – Array of vertex indices defining the path
Identifying and analysing the free boundaries of a mesh¶
-
openep.mesh.mesh_routines.get_free_boundaries(mesh)[source]¶ Determines the freeboundary/outlines of the 3-D mesh.
- Parameters
mesh (pyvista.PolyData) – An open mesh for which the free boundaries will be determined.
- Returns
free_boundaries (openep.mesh.FreeBoundary) – The free boundaries of the open mesh.
-
class
openep.mesh.mesh_routines.FreeBoundary[source]¶ Class for storing information on the free boundaries of a mesh.
- Parameters
points (np.ndarray) – (N,3) array of coordinates
lines (np.ndarray) – (M, 2) array containing the indices of points connected by an edge. Values should be in the interval [0, N-1].
n_boundaries (int) – the number of free boundaries
n_points_per_boundary (np.ndarray) – the number of points in each boundary
original_lines (np.ndarray) – (M, 2) array. Same as lines, but the indices should correspond to those in the original mesh from which free boundaries were identified.
-
separate_boundaries(original_lines=False)[source]¶ Creates a list of numpy arrays where each array contains the indices of node pairs in a single free boundary.
- Parameters
original_lines (bool) – If True, FreeBoundary.original_lines will be used. If False, FreeBoundary.lines will be used.
- Returns
boundaries (list) – a list of numpy arrays - one array per free boundary. Each array is of shape Nx2, where N is the number of lines in a given boundary. Each array contains the indices of pairs of nodes that make up each line in the boundary.