Skip to main content

Python interface to tetgen

Project description

https://travis-ci.org/pyvista/tetgen.svg?branch=master https://img.shields.io/pypi/v/tetgen.svg?logo=python&logoColor=white

This Python module 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.

The last update to the original C++ software was on 19 January 2011, but the software remains relevant today. 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.

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/docs/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'],
                    [' Tesselated Mesh ', 'black']])
plotter.show()
https://github.com/pyvista/tetgen/raw/master/docs/images/sphere_subgrid.png

Cell quality scalars can be obtained and plotted with:

cell_qual = subgrid.quality

# 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/docs/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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

tetgen-0.4.3-cp37-cp37m-win_amd64.whl (294.2 kB view details)

Uploaded CPython 3.7mWindows x86-64

tetgen-0.4.3-cp37-cp37m-manylinux1_x86_64.whl (1.8 MB view details)

Uploaded CPython 3.7m

tetgen-0.4.3-cp37-cp37m-macosx_10_9_x86_64.whl (422.4 kB view details)

Uploaded CPython 3.7mmacOS 10.9+ x86-64

tetgen-0.4.3-cp36-cp36m-win_amd64.whl (294.2 kB view details)

Uploaded CPython 3.6mWindows x86-64

tetgen-0.4.3-cp36-cp36m-manylinux1_x86_64.whl (1.8 MB view details)

Uploaded CPython 3.6m

tetgen-0.4.3-cp36-cp36m-macosx_10_9_x86_64.whl (425.4 kB view details)

Uploaded CPython 3.6mmacOS 10.9+ x86-64

tetgen-0.4.3-cp35-cp35m-win_amd64.whl (293.7 kB view details)

Uploaded CPython 3.5mWindows x86-64

tetgen-0.4.3-cp35-cp35m-manylinux1_x86_64.whl (1.8 MB view details)

Uploaded CPython 3.5m

File details

Details for the file tetgen-0.4.3-cp37-cp37m-win_amd64.whl.

File metadata

  • Download URL: tetgen-0.4.3-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 294.2 kB
  • Tags: CPython 3.7m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.6

File hashes

Hashes for tetgen-0.4.3-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 ffb807a35bc4c2469aa8194547c9fa611ae2c2002e256194d7e2068af572a679
MD5 c92dacfa78d27243f9bf1870c1f4d721
BLAKE2b-256 bd5cfc77df75fb17db7285e7ff44863db24b54c1bd0dbb51fa8a36054a0837ce

See more details on using hashes here.

File details

Details for the file tetgen-0.4.3-cp37-cp37m-manylinux1_x86_64.whl.

File metadata

  • Download URL: tetgen-0.4.3-cp37-cp37m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 1.8 MB
  • Tags: CPython 3.7m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.6

File hashes

Hashes for tetgen-0.4.3-cp37-cp37m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 02c699ea34cda434637630d12bbe428249585858f0ecd23d24e74a7e3b0c682c
MD5 08e6caa5d855bbf8ed27e9a1dec71f48
BLAKE2b-256 25662cbe3d3e76173e406e6d25597a984b2d75511e198d7ee6c5daa8ac308d03

See more details on using hashes here.

File details

Details for the file tetgen-0.4.3-cp37-cp37m-macosx_10_9_x86_64.whl.

File metadata

  • Download URL: tetgen-0.4.3-cp37-cp37m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 422.4 kB
  • Tags: CPython 3.7m, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/2.7.17

File hashes

Hashes for tetgen-0.4.3-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 16ed0a839ec88c3942996f79f09aea6d84c6af6d9de921f3f135f8485ab25a3b
MD5 e0d5593a8a6dc4df1cd713d16c50ae26
BLAKE2b-256 7a1e90f165380dd5740b0dcb113a698c092e09e431934f535cb67dc6bcc21950

See more details on using hashes here.

File details

Details for the file tetgen-0.4.3-cp36-cp36m-win_amd64.whl.

File metadata

  • Download URL: tetgen-0.4.3-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 294.2 kB
  • Tags: CPython 3.6m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.6.8

File hashes

Hashes for tetgen-0.4.3-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 25e513660055ae95bc2df88be37f524cf5af44d141eb6013735910da8ac424f4
MD5 8c954442bbc5ee1037286bc1470a422c
BLAKE2b-256 640a743ae42b8d3407cc34f13b4e6471e2dbace90c1f94abd34722ba90506507

See more details on using hashes here.

File details

Details for the file tetgen-0.4.3-cp36-cp36m-manylinux1_x86_64.whl.

File metadata

  • Download URL: tetgen-0.4.3-cp36-cp36m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 1.8 MB
  • Tags: CPython 3.6m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.6

File hashes

Hashes for tetgen-0.4.3-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 a609455cbf0a7fd1e0e87db0f2aa06138b226992e8d6c4b87a8e10f7ea20e713
MD5 f0065aec02e84fd5db551d6187fdb79a
BLAKE2b-256 01524b8d8d2b51d287d0ad176bfa8194779a37668be21d7a57d1607301c9bf67

See more details on using hashes here.

File details

Details for the file tetgen-0.4.3-cp36-cp36m-macosx_10_9_x86_64.whl.

File metadata

  • Download URL: tetgen-0.4.3-cp36-cp36m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 425.4 kB
  • Tags: CPython 3.6m, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/2.7.17

File hashes

Hashes for tetgen-0.4.3-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 7052f67863f4d065e87d007d0d299e183eacbdd085bcad65e3a9801ecb352413
MD5 1ba218060d855e4e9c347664287fa361
BLAKE2b-256 f579a4893bab5468ffcd07a01f744460e9f2947e11196cb25d0ffb762da73e95

See more details on using hashes here.

File details

Details for the file tetgen-0.4.3-cp35-cp35m-win_amd64.whl.

File metadata

  • Download URL: tetgen-0.4.3-cp35-cp35m-win_amd64.whl
  • Upload date:
  • Size: 293.7 kB
  • Tags: CPython 3.5m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.5.4

File hashes

Hashes for tetgen-0.4.3-cp35-cp35m-win_amd64.whl
Algorithm Hash digest
SHA256 bba5e5c61db1ca1c5d435809af8d5edfe9add5f2a011393f4778401dc75859af
MD5 750c9cb8537492b8488de06cebee28ee
BLAKE2b-256 c9d64f7615524356c24b8b73be86b40f03ffc0aa97d5d253dd34e70cfef80499

See more details on using hashes here.

File details

Details for the file tetgen-0.4.3-cp35-cp35m-manylinux1_x86_64.whl.

File metadata

  • Download URL: tetgen-0.4.3-cp35-cp35m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 1.8 MB
  • Tags: CPython 3.5m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.6

File hashes

Hashes for tetgen-0.4.3-cp35-cp35m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 87aab947aec661d97dc3eae18c69c4fc5463ff58caf68bbbbf034c79aa4ea807
MD5 c2af86342f989772d9614bfc8c0b2c27
BLAKE2b-256 fbf95fefea6a4f00dc7d42ad1c5fb1c490b99a12653c46fae9156a197d333d8e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page