API Reference¶
Tetrahedralizer API¶
- tetrahedralizer.mesh_lib.fix_mesh(mesh, repair_kwargs=None)[source]¶
Call the meshfix.repair function on a Pyvista dataset and return a fixed copy of the dataset along with the meshfix holes
- Parameters
mesh (DataSet) – Pyvista Dataset
repair_kwargs (Optional[Dict]) – Kwargs for meshfix.repair
- Returns
Fixed copy of the input mesh, holes identified by meshfix
- Return type
Tuple[DataSet, PolyData]
- tetrahedralizer.mesh_lib.pymeshlab_boolean(meshes, operation)[source]¶
Run a pymesh boolean operation on two input meshes. The meshes are described as a platform agnostic Tuple of ndarrays representing mesh vertices and faces. The format is as follows: Tuple element 0: 3xN ndarray of float representing XYZ points in 3D space Tuple element 1: 3xN ndarray of int representing triangular faces composed of indices the points
Optionally, face normals can be specified: Tuple element 2: 3xN ndarray of float representing face normals. But this doesn’t work
- Parameters
meshes (Tuple[Tuple[ndarray, ...], Tuple[ndarray, ...]]) – Tuple of two input meshes in array format
operation (str) – Pymeshlab boolean operation name. String names are mapped to pymeshlab functions in ppymeshlab_op_map
- Returns
booleaned_mesh – Result of the boolean operation in array format
- Return type
Optional[Tuple[ndarray, ndarray]]
- tetrahedralizer.mesh_lib.gmsh_tetrahedralize(meshes, gmsh_options)[source]¶
Run the gmsh tetrahedralization operation (mesh.generate(3)) on a group of surface meshes. Gmsh will interpret the outermost mesh as the outer surface, and all other meshes as holes to generte in the tetrahedralization.
The meshes are described as a platform agnostic Tuple of ndarrays representing mesh vertices and faces. The format is as follows: Tuple element 0: 3xN ndarray of float representing XYZ points in 3D space Tuple element 1: 3xN ndarray of int representing triangular faces composed of indices the points
- Parameters
meshes (List[Tuple[ndarray, ndarray]]) – List of meshes to tetrahedralize
gmsh_options (dict) – Dict of values to be passed to gmsh.option.set_number
- Returns
nodes, elements – Tetrahedralized mesh. Elements are now represented as a Tuple of ndarray. Element 0 is a 3xN array of surface faces. Element 1 is a 4xN array of tetrahedral cells
- Return type
Tuple[ndarray, Tuple[ndarray, ndarray]]
- tetrahedralizer.mesh_lib.preprocess_and_tetrahedralize(outer_mesh, inner_meshes, mesh_repair_kwargs, gmsh_options)[source]¶
Automatically create a tetrahedralization from multiple input surface meshes. The outer mesh represents the outermost boundary of the output mesh, and the inner meshes represent the boundaries of individual inner sections of the output mesh. The process is configurable with mesh_repair_kwargs and gmsh_options.
- Parameters
outer_mesh (PolyData) – Pyvista DataSet representing the outer surface
inner_meshes (List[PolyData]) – List of Pyvista DataSets representing the surfaces of inner sections
mesh_repair_kwargs (dict) – Kwargs for PyMeshfix
gmsh_options (dict) – Kwargs for gmsh
- Returns
combined – Pyvista unstructured grid
- Return type
UnstructuredGrid
Remove faces shared by any two of a list of Pyvista Polydata and merge the result. This is similar to the Pyvista boolean union, but works with intersections of zero volume. The meshes can optionally be returned unmerged. The removed faces can also optionally be returned.
- Parameters
meshes (List[pv.DataSet]) – List of meshes to merge
tolerance (float) – Tolerance for selecting shared points
merge_result – If true, returns a list with intersecting meshes merged. Otherwise returns a list of each input individually. Default True
return_removed_faces (bool) – If true, returns a list of faces that were removed.
progress_bar (bool) – Include a progress bar
- Returns
output, (faces_to_remove) – List of pv.Polydata with each set of intersecting input meshes merged into one. Input meshes that don’t intersect any other are returned unchanged. Alternatively, a list of non-merged input meshes with shared faces removed.
Optionally, list of faces that were removed.
- Return type
List[pv.PolyData] | Tuple[List[pv.PolyData], list]