Mesh#
- class ansys.health.heart.objects.Mesh(*args)#
Bases:
pyvista.UnstructuredGridMesh class, which inherits from the PyVista unstructured grid object.
Notes
This class inherits from the
pyvista.UnstructuredGridobject and adds additional attributes and convenience methods for enhanced functionality. The_volume_id,_surface_id, and_line_idcell arrays keep track of labeled selections of cells. The_volume_idcell array is used to group 3D volume cells together. Any non-3D volume cell is labeled asnumpy.nan. Similarly 2D and 1D cells are tracked through the_surface_idand_line_idcell arrays respectively.
Overview#
Get an unused ID within a specified range. |
|
Save mesh. |
|
Load an existing mesh. |
|
Check whether there are any duplicate or unmapped surfaces/volumes. |
|
Merge duplicate points and return a cleaned copy. |
|
Add a volume. |
|
Add a surface. |
|
Add lines. |
|
Get a volume as a PyVista unstructured grid object. |
|
Get the surface associated with a given name. |
|
Get a surface as a PyVista polydata object. |
|
Get the surface associated with a given name. |
|
Get lines as a PyVista polydata object. |
|
Get the lines associated with a given name. |
|
Remove a surface with a given ID. |
|
Remove a volume with a given ID. |
|
Remove a set of lines with a given ID. |
Tetrahedrons |
|
All triangles of the mesh. |
|
Get all triangles of the mesh. |
|
Unique surface IDs. |
|
List of surface names. |
|
NumPy array with unique volume IDs. |
|
List of volume names. |
|
NumPy array with unique line IDs. |
|
List of volume names. |
Import detail#
from ansys.health.heart.objects import Mesh
Property detail#
- property Mesh.tetrahedrons#
Tetrahedrons
num_tetrax 4.
- property Mesh.triangles#
All triangles of the mesh.
- property Mesh.lines#
Get all triangles of the mesh.
- property Mesh.surface_ids: numpy.ndarray#
Unique surface IDs.
- Returns:
np.ndarrayNumPy array with unique surface IDs.
- property Mesh.volume_ids: numpy.ndarray#
NumPy array with unique volume IDs.
- Returns:
np.ndarrayNumPy array with unique volume IDs.
- property Mesh.line_ids: numpy.ndarray#
NumPy array with unique line IDs.
- Returns:
np.ndarrayNumPy array with unique line IDs.
Method detail#
- Mesh.get_unused_id_in_range(id_type: Literal['volume', 'surface', 'line'], start: int = 1, end: int = 1000) int#
Get an unused ID within a specified range.
- Parameters:
- Returns:
intAn unused and unique ID within the specified range.
- Raises:
ValueErrorIf no unused ID is found in the specified range.
- Mesh.save(filename: str | pathlib.Path, **kwargs)#
Save mesh.
- Mesh.load_mesh(filename: str | pathlib.Path)#
Load an existing mesh.
- Parameters:
- filename
Union[str,pathlib.Path] Full path to the mesh file.
- filename
Notes
This method tries to read a JSON file with the volume/surface ID to a name map with extension
.namemap.jsonin the same directory as the file. Alternatively, you can read the name map manually by calling._load_id_to_name_map(filename).
- Mesh.validate_ids_to_name_map()#
Check whether there are any duplicate or unmapped surfaces/volumes.
- Mesh.clean(ignore_nans_in_point_average: bool = False, **kwargs)#
Merge duplicate points and return a cleaned copy.
- Mesh.add_surface(surface: pyvista.PolyData, id: int = None, name: str = None, overwrite_existing: bool = False)#
Add a surface.
- Parameters:
- surface
pv.PolyData PolyData representation of the surface to add.
- sid
int ID of the surface to add. This ID is tracked as
_surface-id.- name
str, default:None Name of the added surface. The added surface is not tracked by default.
- overwrite_existingbool, default:
False Whether to overwrite a surface with the same ID. If
False, the added surface is appended.
- surface
- Mesh.get_volume(sid: int) pyvista.UnstructuredGrid#
Get a volume as a PyVista unstructured grid object.
- Mesh.get_volume_by_name(name: str) pyvista.UnstructuredGrid#
Get the surface associated with a given name.
- Mesh.get_surface(sid: int) pyvista.PolyData | SurfaceMesh#
Get a surface as a PyVista polydata object.
Notes
This method tries to return a
SurfaceMeshobject that also contains a name, ID, and additional convenience properties.
- Mesh.get_surface_by_name(name: str) pyvista.PolyData | SurfaceMesh#
Get the surface associated with a given name.
- Mesh.remove_surface(sid: int)#
Remove a surface with a given ID.
- Parameters:
- sid
int ID of the surface to remove.
- sid