tetgenpy
tetgenpy is a python wrapper for Hang Si's TetGen - A Quality Tetrahedral Mesh Generator and a 3D Delaunay Triangulator.
It helps to prepare various types of inputs - points, piecewise linear complexes (PLCs), and tetmesh - for tetrahedron mesh generation based on simple python types, such as list
and numpy.ndarray
.
Install
pip install tetgenpy
For current development version,
pip install git+https://github.com/tataratat/tetgenpy.git@main
Quick Start
Following is an example for tetrahedralization of a unit cube defined as PLCs.
Alternatively, you could also use tetgenpy.PLC class to prepare TetgenIO
.
import tetgenpy
import numpy as np
points=[
[0.0, 0.0, 0.0],
[1.0, 0.0, 0.0],
[0.0, 1.0, 0.0],
[1.0, 1.0, 0.0],
[0.0, 0.0, 1.0],
[1.0, 0.0, 1.0],
[0.0, 1.0, 1.0],
[1.0, 1.0, 1.0],
]
facets = [
[1, 0, 2, 3],
[0, 1, 5, 4],
[2, 0, 4, 6],
[1, 3, 7, 5],
[3, 2, 6, 7],
[4, 5, 7, 6],
]
tetgen_in = tetgenpy.TetgenIO()
tetgen_in.setup_plc(
points=points,
facets=facets,
facet_markers=[[i] for i in range(1, len(facets) + 1)],
)
tetgen_out = tetgenpy.tetrahedralize("qa.05", tetgen_in)
print(tetgen_out.points())
print(tetgen_out.tetrahedra())
print(tetgen_out.trifaces())
print(tetgen_out.trifacemarkers())
This package also provides access to tetgen's binary executable. Try:
$ tetgen -h
Dependencies
c++
python
build