Mesh#

class ansys.health.heart.objects.Mesh(*args)#

Bases: pyvista.UnstructuredGrid

Mesh class, which inherits from the PyVista unstructured grid object.

Notes

This class inherits from the pyvista.UnstructuredGrid object and adds additional attributes and convenience methods for enhanced functionality. The _volume_id, _surface_id, and _line_id cell arrays keep track of labeled selections of cells. The _volume_id cell array is used to group 3D volume cells together. Any non-3D volume cell is labeled as numpy.nan. Similarly 2D and 1D cells are tracked through the _surface_id and _line_id cell arrays respectively.

Overview#

save

Save mesh.

load_mesh

Load an existing mesh.

validate_ids_to_name_map

Check whether there are any duplicate or unmapped surfaces/volumes.

clean

Merge duplicate points and return a cleaned copy.

add_volume

Add a volume.

add_surface

Add a surface.

add_lines

Add lines.

get_volume

Get a volume as a PyVista unstructured grid object.

get_volume_by_name

Get the surface associated with a given name.

get_surface

Get a surface as a PyVista polydata object.

get_surface_by_name

Get the surface associated with a given name.

get_lines

Get lines as a PyVista polydata object.

get_lines_by_name

Get the lines associated with a given name.

remove_surface

Remove a surface with a given ID.

remove_volume

Remove a volume with a given ID.

remove_lines

Remove a set of lines with a given ID.

tetrahedrons

Tetrahedrons num_tetra x 4.

triangles

All triangles of the mesh.

lines

Get all triangles of the mesh.

surface_ids

Unique surface IDs.

surface_names

List of surface names.

volume_ids

NumPy array with unique volume IDs.

volume_names

List of volume names.

line_ids

NumPy array with unique line IDs.

line_names

List of volume names.

Import detail#

from ansys.health.heart.objects import Mesh

Property detail#

property Mesh.tetrahedrons#

Tetrahedrons num_tetra x 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.ndarray

NumPy array with unique surface IDs.

property Mesh.surface_names: List[str]#

List of surface names.

property Mesh.volume_ids: numpy.ndarray#

NumPy array with unique volume IDs.

Returns:
np.ndarray

NumPy array with unique volume IDs.

property Mesh.volume_names: List[str]#

List of volume names.

property Mesh.line_ids: numpy.ndarray#

NumPy array with unique line IDs.

Returns:
np.ndarray

NumPy array with unique line IDs.

property Mesh.line_names: List[str]#

List of volume names.

Method detail#

Mesh.save(filename: str | pathlib.Path, **kwargs)#

Save mesh.

Mesh.load_mesh(filename: str | pathlib.Path)#

Load an existing mesh.

Parameters:
filenameUnion[str, pathlib.Path]

Full path to the mesh file.

Notes

This method tries to read a JSON file with the volume/surface ID to a name map with extension .namemap.json in 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.

Parameters:
ignore_nans_in_point_averagebool, default: False

Whether to ignore nan values when averaging point data.

Returns:
Mesh

Cleaned copy of self.

Mesh.add_volume(volume: pyvista.UnstructuredGrid, id: int = None, name: str = None)#

Add a volume.

Parameters:
volumepv.PolyData

PolyData representation of the volume to add.

idint

ID of the volume to add. This ID is tracked as _volume-id.

namestr, default: None

Name of the added volume. The added volume is not tracked by default.

Mesh.add_surface(surface: pyvista.PolyData, id: int = None, name: str = None, overwrite_existing: bool = False)#

Add a surface.

Parameters:
surfacepv.PolyData

PolyData representation of the surface to add.

sidint

ID of the surface to add. This ID is tracked as _surface-id.

namestr, 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.

Mesh.add_lines(lines: pyvista.PolyData, id: int = None, name: str = None)#

Add lines.

Parameters:
linespv.PolyData

PolyData representation of the lines to add.

idint

ID of the surface to add. This ID is tracked as _line-id.

namestr, optional

Name of the added lines. The added lines are not tracked by default.

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 SurfaceMesh object 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.get_lines(sid: int) pyvista.PolyData#

Get lines as a PyVista polydata object.

Mesh.get_lines_by_name(name: str) pyvista.PolyData#

Get the lines associated with a given name.

Mesh.remove_surface(sid: int)#

Remove a surface with a given ID.

Parameters:
sidint

ID of the surface to remove.

Mesh.remove_volume(vid: int)#

Remove a volume with a given ID.

Parameters:
vidint

ID of the volume to remove.

Mesh.remove_lines(lid: int)#

Remove a set of lines with a given ID.

Parameters:
lidint

ID of the lines to remove.