• Stars
    star
    223
  • Rank 178,458 (Top 4 %)
  • Language
    C++
  • License
    Other
  • Created over 6 years ago
  • Updated about 2 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A Python interface to the C++ TetGen library to generate tetrahedral meshes of any 3D polyhedral domains

tetgen

https://img.shields.io/pypi/v/tetgen.svg?logo=python&logoColor=white

This Python library is an interface to Hang Si's TetGen C++ software. This module combines speed of C++ with the portability and ease of installation of Python along with integration to PyVista for 3D visualization and analysis. See the TetGen GitHub page for more details on the original creator.

This Python library uses the C++ source from TetGen (version 1.6.0, released on August 31, 2020) hosted at libigl/tetgen.

Brief description from Weierstrass Institute Software:

TetGen is a program to generate tetrahedral meshes of any 3D polyhedral domains. TetGen generates exact constrained Delaunay tetrahedralization, boundary conforming Delaunay meshes, and Voronoi partitions.

TetGen provides various features to generate good quality and adaptive tetrahedral meshes suitable for numerical methods, such as finite element or finite volume methods. For more information of TetGen, please take a look at a list of features.

License (AGPL)

The original TetGen software is under AGPL (see LICENSE) and thus this Python wrapper package must adopt that license as well.

Please look into the terms of this license before creating a dynamic link to this software in your downstream package and understand commercial use limitations. We are not lawyers and cannot provide any guidance on the terms of this license.

Please see https://www.gnu.org/licenses/agpl-3.0.en.html

Installation

From PyPI

pip install tetgen

From source at GitHub

git clone https://github.com/pyvista/tetgen
cd tetgen
pip install .

Basic Example

The features of the C++ TetGen software implemented in this module are primarily focused on the tetrahedralization a manifold triangular surface. This basic example demonstrates how to tetrahedralize a manifold surface and plot part of the mesh.

import pyvista as pv
import tetgen
import numpy as np
pv.set_plot_theme('document')

sphere = pv.Sphere()
tet = tetgen.TetGen(sphere)
tet.tetrahedralize(order=1, mindihedral=20, minratio=1.5)
grid = tet.grid
grid.plot(show_edges=True)
https://github.com/pyvista/tetgen/raw/master/doc/images/sphere.png

Tetrahedralized Sphere

Extract a portion of the sphere's tetrahedral mesh below the xy plane and plot the mesh quality.

# get cell centroids
cells = grid.cells.reshape(-1, 5)[:, 1:]
cell_center = grid.points[cells].mean(1)

# extract cells below the 0 xy plane
mask = cell_center[:, 2] < 0
cell_ind = mask.nonzero()[0]
subgrid = grid.extract_cells(cell_ind)

# advanced plotting
plotter = pv.Plotter()
plotter.add_mesh(subgrid, 'lightgrey', lighting=True, show_edges=True)
plotter.add_mesh(sphere, 'r', 'wireframe')
plotter.add_legend([[' Input Mesh ', 'r'],
                    [' Tessellated Mesh ', 'black']])
plotter.show()

https://github.com/pyvista/tetgen/raw/master/doc/images/sphere_subgrid.png

Here is the cell quality as computed according to the minimum scaled jacobian.

Compute cell quality

>>> cell_qual = subgrid.compute_cell_quality()['CellQuality']

Plot quality

>>> subgrid.plot(scalars=cell_qual, stitle='Quality', cmap='bwr', clim=[0, 1],
...              flip_scalars=True, show_edges=True)

https://github.com/pyvista/tetgen/raw/master/doc/images/sphere_qual.png

Acknowledgments

Software was originally created by Hang Si based on work published in TetGen, a Delaunay-Based Quality Tetrahedral Mesh Generator.

More Repositories

1

pyvista

3D plotting and mesh analysis through a streamlined interface for the Visualization Toolkit (VTK)
Python
2,689
star
2

pymeshfix

Python Wrapper for MeshFix: easily repair holes in surface meshes
C++
283
star
3

pyacvd

Python implementation of surface mesh resampling algorithm ACVD
C++
199
star
4

pyvistaqt

Qt support for PyVista
Python
108
star
5

pyvista-xarray

xarray DataArray accessors for PyVista
Python
98
star
6

fast-simplification

Fast Quadratic Mesh Simplification
C++
95
star
7

pyvista-support

[moved] Please head over to the Discussions tab of the PyVista repository
59
star
8

pyvista-tutorial

PyVista SciPy 2022-2024 Tutorial
Python
56
star
9

scikit-gmsh

Scikit for Gmsh to generate 3D finite element mesh
Python
41
star
10

vtk-data

PyVista example data - These are used for examples in both PyVista and PVGeo
G-code
38
star
11

pyiges

Python IGES Reader
Python
34
star
12

setup-headless-display-action

GitHub Action to setup a headless display on Linux and Windows (not needed on MacOS)
PowerShell
17
star
13

pyvista-reality

OpenVR and OpenXR variants of PyVista
Python
17
star
14

pyvista-gui

A Graphical User Interface built atop PyVista
Python
14
star
15

pytest-pyvista

Plugin to test PyVista plot outputs
Python
13
star
16

pyvista-fastapi-webapp

Demo FastAPI and Three.js application using PyVista
TypeScript
13
star
17

pyvistaqt-exe

Create a Windows installable exe from a PyVistaQt application
Python
12
star
18

pyvista-examples

A place where we host the Jupyter notebooks found in the PyVista docs for use on MyBinder - this repo is automatically deployed by our CI robot friends - NO PRs HERE PLEASE
Dockerfile
11
star
19

pyvista-wheels

VTK wheels for PyVista
Python
8
star
20

vtkjs-viewer

This repo is strictly for the purpose of hosting the vtk.js standalone web viewer
JavaScript
7
star
21

streamlit-pyvista

Python
6
star
22

gl-ci-helpers

Continuous integration helper scripts for your 3D visualization needs
PowerShell
6
star
23

pyminiply

Wrapper over the excellent and fast miniply to read PLY files
Python
5
star
24

pyvista-media

PostScript
4
star
25

pyvista-doc-translations

translated docs for pyvista official document
Python
4
star
26

stl-reader

Fast STL file reader
C++
4
star
27

pytetwild

Python wrapper for fTetWild
C++
4
star
28

pyvista-docs-dev

A place where we host the most up to date development documentation for PyVista
HTML
3
star
29

show-room

[WIP] A set of domain specific examples to showcase how PyVista can be used
Jupyter Notebook
3
star
30

cookiecutter-pyvista-binder

This is a Cookiecutter for using PyVista on the notebook hosting service MyBinder.
Jupyter Notebook
3
star
31

pyvista-docs-dynamic

3
star
32

panel-pyvista

Demonstrate using PyVista, Trame, and Panel in a SPA
Python
3
star
33

pyvista-tutorial-translations

translated docs for pyvista official tutorial
Jupyter Notebook
2
star
34

awesome-pyvista

A curated list of awesome stuff related to PyVista 😎
Python
2
star
35

pyvista-tutorial-ja

A place where we host the most up to date tutorial for PyVista
2
star
36

npt-promote

Mypy plugin to add type promotions between NumPy and builtin data types.
Python
2
star
37

pyvista-optimized

Cython optimizations and overrides to PyVista
2
star
38

multiversion-docs-testing

1
star
39

pyvista-osmnx

1
star
40

pyvista-doc-example

Example Documentation build using PyVista
1
star
41

pyvista-docs-dev-ja

1
star
42

pyvista-docs-archive

A place where we automatically deploy the PyVista documentation
HTML
1
star
43

pyvista-bot

Python
1
star
44

pyvista-docs-netlify-multiversion-archive

no longer in use
HTML
1
star
45

examples

`pyvista-examples` contains a variety of built-in demos and downloadable example datasets.
Python
1
star
46

streamlit-stlviewer

Python
1
star