trimesh.interfaces.gmsh module

trimesh.interfaces.gmsh.load_gmsh(file_name, gmsh_args=None, interruptible=True)

Returns a surface mesh from CAD model in Open Cascade Breap (.brep), Step (.stp or .step) and Iges formats Or returns a surface mesh from 3D volume mesh using gmsh.

For a list of possible options to pass to GMSH, check: http://gmsh.info/doc/texinfo/gmsh.html

An easy way to install the GMSH SDK is through the gmsh package on PyPi, which downloads and sets up gmsh:

>>> pip install gmsh
Parameters:
  • file_name (str) – Location of the file to be imported

  • gmsh_args ((n, 2) list) – List of (parameter, value) pairs to be passed to gmsh.option.setNumber

  • max_element (float or None) – Maximum length of an element in the volume mesh

  • interruptible (bool) – Allows load_gmsh to run outside of the main thread if False, default behaviour if set to True. Added in 4.12.0

Returns:

mesh – Surface mesh of input geometry

Return type:

trimesh.Trimesh

trimesh.interfaces.gmsh.to_volume(mesh, file_name: str | None = None, file_type: str | None = None, max_element: float | floating | int | integer | unsignedinteger | None = None, mesher_id: int | integer | unsignedinteger = 1) bytes

Convert a surface mesh to a 3D volume mesh generated by gmsh.

An easy way to install the gmsh sdk is through the gmsh package on pypi, which downloads and sets up gmsh:

pip install gmsh

Algorithm details, although check gmsh docs for more information: The “Delaunay” algorithm is split into three separate steps. First, an initial mesh of the union of all the volumes in the model is performed, without inserting points in the volume. The surface mesh is then recovered using H. Si’s boundary recovery algorithm Tetgen/BR. Then a three-dimensional version of the 2D Delaunay algorithm described above is applied to insert points in the volume to respect the mesh size constraints.

The Frontal” algorithm uses J. Schoeberl’s Netgen algorithm. The “HXT” algorithm is a new efficient and parallel reimplementaton of the Delaunay algorithm. The “MMG3D” algorithm (experimental) allows to generate anisotropic tetrahedralizations

Parameters:
  • mesh (trimesh.Trimesh) – Surface mesh of input geometry

  • file_type – Location to save output, in .msh (gmsh) or .bdf (Nastran) format

  • max_element (float or None) – Maximum length of an element in the volume mesh

  • mesher_id (int) – 3D unstructured algorithms: 1: Delaunay, 3: Initial mesh only, 4: Frontal, 7: MMG3D, 9: R-tree, 10: HXT

Returns:

data – MSH data, only returned if file_name is None

Return type:

None or bytes