capytaine.meshes.meshes module¶
This module contains a class to describe the 2D mesh of the surface of a body in a 3D space. Based on meshmagick <https://github.com/LHEEA/meshmagick> by François Rongère.
- class capytaine.meshes.meshes.Mesh(vertices=None, faces=None, name=None)[source]¶
Bases:
SurfaceIntegralsMixin
,Abstract3DObject
A class to handle unstructured 2D meshes in a 3D space.
- Parameters:
vertices (array_like of shape (nv, 3)) – Array of mesh vertices coordinates.Each line of the array represents one vertex coordinates
faces (array_like of shape (nf, 4)) – Arrays of mesh connectivities for faces. Each line of the array represents indices of vertices that form the face, expressed in counterclockwise order to ensure outward normals description.
name (str, optional) – The name of the mesh. If None, the mesh is given an automatic name based on its internal ID.
- property axis_aligned_bbox¶
Get the axis aligned bounding box of the mesh.
- Returns:
(xmin, xmax, ymin, ymax, zmin, zmax)
- Return type:
tuple
- property boundaries: list¶
Get a list that stores lists of boundary connected vertices.
- property center_of_mass_of_nodes¶
(Non-weighted) center of mass of the nodes of the mesh.
- clip(*args, inplace=True, name=None, **kwargs)¶
- copy(name=None) Mesh [source]¶
Get a copy of the current mesh instance.
- Parameters:
name (string, optional) – a name for the new mesh
- Returns:
mesh instance copy
- Return type:
- property diameter_of_nodes¶
Maximum distance between two nodes of the mesh.
- extract_faces(id_faces_to_extract, return_index=False, name=None)[source]¶
Extracts a new mesh from a selection of faces ids
- Parameters:
id_faces_to_extract (ndarray) – Indices of faces that have to be extracted
return_index (bool, optional) – Flag to output old indices
name (string, optional) – Name for the new mesh
- Returns:
A new Mesh instance composed of the extracted faces
- Return type:
- property faces: ndarray¶
Get the faces connectivity array of the mesh.
- property faces_areas: ndarray¶
Get the array of faces areas of the mesh.
- property faces_centers: ndarray¶
Get the array of faces centers of the mesh.
- property faces_normals: ndarray¶
Get the array of faces normals of the mesh.
- property faces_radiuses: ndarray¶
Get the array of faces radiuses of the mesh.
- property ff: dict¶
Get the face / faces connectivity dictionary.
- flip_normals(*args, inplace=True, name=None, **kwargs)¶
- get_face(face_id)[source]¶
Get the face described by its vertices connectivity.
- Parameters:
face_id (int) – Face id
- Returns:
If the face is a triangle, the array has 3 components, else it has 4 (quadrangle)
- Return type:
ndarray
- heal_mesh(*args, inplace=True, name=None, **kwargs)¶
- is_triangle(face_id) bool [source]¶
Returns if a face is a triangle
- Parameters:
face_id (int) – Face id
- keep_immersed_part(*args, inplace=True, name=None, **kwargs)¶
- property max_edge_length: float¶
The mesh’s maximum edge length
- property mean_edge_length: float¶
The mesh’s mean edge length
- property min_edge_length: float¶
The mesh’s minimum edge length
- mirror(*args, inplace=True, name=None, **kwargs)¶
- property nb_boundaries: int¶
Get the number of boundaries in the mesh.
- property nb_faces: int¶
Get the number of faces in the mesh.
- property nb_quadrangles: int¶
Get the number of quadrangles in the mesh.
- property nb_triangles: int¶
Get the number of triangles in the mesh.
- property nb_vertices: int¶
Get the number of vertices in the mesh.
- property quadrangles_ids: ndarray¶
Get the array of ids of quadrangle shaped faces.
- property quadrature_method¶
- property quadrature_points¶
- rotate(*args, inplace=True, name=None, **kwargs)¶
- show_matplotlib(ax=None, normal_vectors=False, scale_normal_vector=None, saveas=None, color_field=None, cmap=None, cbar_label=None, **kwargs)[source]¶
Poor man’s viewer with matplotlib.
- Parameters:
ax (matplotlib axis) – The 3d axis in which to plot the mesh. If not provided, create a new one.
normal_vectors (bool) – If True, print normal vector.
scale_normal_vector (array of shape (nb_faces, )) – Scale separately each of the normal vectors.
saveas (str) – File path where to save the image.
color_field (array of shape (nb_faces, )) – Scalar field to be plot on the mesh (optional).
cmap (matplotlib colormap) – Colormap to use for field plotting.
cbar_label (string) – Label for colormap
Other parameters are passed to Poly3DCollection.
- property squared_axis_aligned_bbox¶
Get a squared axis aligned bounding box of the mesh.
- Returns:
(xmin, xmax, ymin, ymax, zmin, zmax)
- Return type:
tuple
Note
This method differs from axis_aligned_bbox() by the fact that the bounding box that is returned is squared but have the same center as the axis_aligned_bbox().
- to_meshmagick()[source]¶
Convert the Mesh object as a Mesh object from meshmagick. Mostly for debugging.
- translate(*args, inplace=True, name=None, **kwargs)¶
- property triangles_ids: ndarray¶
Get the array of ids of triangle shaped faces.
- triangulate_quadrangles(*args, inplace=True, name=None, **kwargs)¶
- property vertices: ndarray¶
Get the vertices array coordinate of the mesh.
- property vf: dict¶
Get the vertex / faces connectivity dictionary.
- property volume: float¶
Get the mesh enclosed volume.
- property vv: dict¶
Get the vertex / vertex connectivity dictionary.