• Stars
    star
    212
  • Rank 185,019 (Top 4 %)
  • Language
    C++
  • License
    Other
  • Created over 6 years ago
  • Updated 3 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,543
star
2

pymeshfix

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

pyacvd

Python implementation of surface mesh resampling algorithm ACVD
Cython
164
star
4

pyvistaqt

Qt support for PyVista
Python
98
star
5

pyvista-xarray

xarray DataArray accessors for PyVista
Python
97
star
6

fast-simplification

Fast Quadratic Mesh Simplification
C++
79
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
41
star
9

vtk-data

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

pyiges

Python IGES Reader
Python
34
star
11

scikit-gmsh

Scikit for Gmsh to generate 3D finite element mesh
Python
21
star
12

pyvista-reality

OpenVR and OpenXR variants of PyVista
Python
16
star
13

setup-headless-display-action

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

pytest-pyvista

Plugin to test PyVista plot outputs
Python
13
star
15

pyvista-gui

A Graphical User Interface built atop PyVista
Python
12
star
16

pyvistaqt-exe

Create a Windows installable exe from a PyVistaQt application
Python
10
star
17

pyvista-wheels

VTK wheels for PyVista
Python
8
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
8
star
19

vtkjs-viewer

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

streamlit-pyvista

Python
6
star
21

gl-ci-helpers

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

pyvista-fastapi-webapp

Demo FastAPI and Three.js application using PyVista
TypeScript
6
star
23

pyvista-doc-translations

translated docs for pyvista official document
Jupyter Notebook
4
star
24

pyvista-docs-dev

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

show-room

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

cookiecutter-pyvista-binder

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

pyvista-docs-dynamic

3
star
28

pyminiply

Wrapper over the excellent and fast miniply to read PLY files
Python
3
star
29

pytetwild

Python wrapper for fTetWild
C++
3
star
30

pyvista-tutorial-translations

translated docs for pyvista official tutorial
Jupyter Notebook
2
star
31

pyvista-tutorial-ja

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

stl-reader

Fast STL file reader
C
2
star
33

npt-promote

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

pyvista-optimized

Cython optimizations and overrides to PyVista
2
star
35

pyvista-media

PostScript
1
star
36

multiversion-docs-testing

1
star
37

awesome-pyvista

A curated list of awesome stuff related to PyVista 😎
1
star
38

pyvista-osmnx

1
star
39

pyvista-doc-example

Example Documentation build using PyVista
1
star
40

pyvista-docs-dev-ja

1
star
41

pyvista-docs-archive

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

pyvista-bot

Python
1
star
43

pyvista-docs

Main Netlify site for our documentation deployment
HTML
1
star
44

examples

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

streamlit-stlviewer

Python
1
star