Skip to main content

Python wrapper of fTetWild

Project description

pypi MPL

pytetwild is a Python library for mesh tetrahedralization. It is a Python wrapper around the efficient C++ library for tetrahedral meshing provided by fTetWild.

Installation

We have pre-built wheels for Python 3.8 - Python 3.12 for Windows and Linux x64.

The recommended way to install pytetwild is via PyPI:

pip install pytetwild

You can also clone the repository and install it from source, but since there’s C++ involved, the build is a bit more complicated. See CONTRIBUTING.md for more details.

Usage

To tetrahedralize a surface mesh from PyVista:

import pyvista as pv
import pytetwild

# Load or create a PyVista PolyData surface mesh
# Here, we'll create a simple sphere mesh as an example
surface_mesh = pv.Icosphere(nsub=2)

# Convert the surface mesh to a tetrahedral mesh. For this example let's
# use a coarse mesh
tetrahedral_mesh = pytetwild.tetrahedralize_pv(surface_mesh, edge_length_fac=1))

# Visualize the tetrahedral mesh in an "exploded" view
tetrahedral_mesh.explode(1).plot(show_edges=True)
https://github.com/pyvista/pytetwild/raw/main/exploded-sphere.png

You can also work with raw arrays. Here’s a simple cube that we turn into tetrahedra.

import numpy as np

# Define vertices of the cube
vertices = np.array([
    [0, 0, 0],  # Vertex 0
    [1, 0, 0],  # Vertex 1
    [1, 1, 0],  # Vertex 2
    [0, 1, 0],  # Vertex 3
    [0, 0, 1],  # Vertex 4
    [1, 0, 1],  # Vertex 5
    [1, 1, 1],  # Vertex 6
    [0, 1, 1]   # Vertex 7
])

# Define faces using vertex indices
# Each face is a rectangle (also accepts triangles)
faces = np.array([
    [0, 1, 2, 3],  # Front face
    [1, 5, 6, 2],  # Right face
    [5, 4, 7, 6],  # Back face
    [4, 0, 3, 7],  # Left face
    [4, 5, 1, 0],  # Bottom face
    [3, 2, 6, 7]   # Top face
])
v_out, tetra = pytetwild.tetrahedralize(vertices, faces, optimize=False)

Usage - Options

We’ve surfaced a handful of parameters to each of our interfaces tetrahedralize and tetrahedralize_pv. Here are the optional parameters.

Additional Parameters
---------------------
edge_length_fac : float, default: 0.05
    Tetrahedral edge length as a function of bounding box diagional. The
    default ideal edge length is bb/20 (bounding box divided by 20).
optimize : bool
    Improve the minimum scaled Jacobean for each cell. This leads to higher
    cell quality at the expense of computation time.

License and Acknowledgments

This project relies on fTetWild and credits go to the original authors for their efficient C++ library for tetrahedral meshing. That work is licensed under the Mozilla Public License v2.0.

The work in this repository is also licensed under the Mozilla Public License v2.0.

Support

If you are having issues, please feel free to raise an Issue.

Project details


Download files

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

Source Distribution

pytetwild-0.1.dev1.tar.gz (3.1 MB view details)

Uploaded Source

Built Distributions

pytetwild-0.1.dev1-cp312-cp312-win_amd64.whl (1.9 MB view details)

Uploaded CPython 3.12 Windows x86-64

pytetwild-0.1.dev1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.7 MB view details)

Uploaded CPython 3.12 manylinux: glibc 2.17+ x86-64

pytetwild-0.1.dev1-cp311-cp311-win_amd64.whl (1.9 MB view details)

Uploaded CPython 3.11 Windows x86-64

pytetwild-0.1.dev1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.7 MB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

pytetwild-0.1.dev1-cp310-cp310-win_amd64.whl (1.9 MB view details)

Uploaded CPython 3.10 Windows x86-64

pytetwild-0.1.dev1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.7 MB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

pytetwild-0.1.dev1-cp39-cp39-win_amd64.whl (1.9 MB view details)

Uploaded CPython 3.9 Windows x86-64

pytetwild-0.1.dev1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.7 MB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

pytetwild-0.1.dev1-cp38-cp38-win_amd64.whl (1.9 MB view details)

Uploaded CPython 3.8 Windows x86-64

pytetwild-0.1.dev1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.7 MB view details)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

File details

Details for the file pytetwild-0.1.dev1.tar.gz.

File metadata

  • Download URL: pytetwild-0.1.dev1.tar.gz
  • Upload date:
  • Size: 3.1 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.0.0 CPython/3.12.2

File hashes

Hashes for pytetwild-0.1.dev1.tar.gz
Algorithm Hash digest
SHA256 175daafc713af392b8700c8d8ec8877492642744b9abdb39aa8fdf3716e925b1
MD5 164cb1520973b3240f8c7289fab99ef2
BLAKE2b-256 7a6627bd6dd376b0805300a0e4fb2d91dfdc45827b7b9e893232fd21fee15cac

See more details on using hashes here.

File details

Details for the file pytetwild-0.1.dev1-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for pytetwild-0.1.dev1-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 ff2ed5d55f5eb3347a3eed21998fe801331c9b1ceb1e54981cc907af4bee2d5c
MD5 82402521a473cb5b7f6ca8c0b0b4802c
BLAKE2b-256 2c6ca18ee73b469aa53c3c181c5fcdd12e45e52446871565dc9b91030425fa0f

See more details on using hashes here.

File details

Details for the file pytetwild-0.1.dev1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pytetwild-0.1.dev1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 f2a9965d59934d23039230c89da3c972a1d715a914657151239097b00d9a7a4c
MD5 9472a03ff974fde50ea0c01c719c5a84
BLAKE2b-256 e5a7f723e9ec413b582b34ab81fc7e7fed40341e31add0c23e7e061bbdee24d2

See more details on using hashes here.

File details

Details for the file pytetwild-0.1.dev1-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for pytetwild-0.1.dev1-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 6d5e0980c560fe2d768cd542578c1e27c553c08e5de249463cba8fcbe8582748
MD5 fd0aea7c13a5e40c9e56145e628af847
BLAKE2b-256 9f3edb88301eb5fa1e4aaaa405795d02c7401a8b38d3cbdaf7988aaeb60833eb

See more details on using hashes here.

File details

Details for the file pytetwild-0.1.dev1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pytetwild-0.1.dev1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 00ecfda52d9fb07dfeafda6726395de32c95f242f035010680173a9d1f238174
MD5 6e3ee2da0e08c0d7a83006405818d04e
BLAKE2b-256 1671bfe9557bf17b4ea4eae37c59b71837699c11de9982eea827eb78bd809eea

See more details on using hashes here.

File details

Details for the file pytetwild-0.1.dev1-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for pytetwild-0.1.dev1-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 0b0cda5af2cef3112f75db12d822ad7b4ba494d9dca45b89c1d6f0fbb2e125ae
MD5 c265d32d33fd5fcdc96dde6cf3f02d19
BLAKE2b-256 c66f281495b6ee6be56c09ba342b1d3d854b6b9790a71e576ea912554ba9757d

See more details on using hashes here.

File details

Details for the file pytetwild-0.1.dev1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pytetwild-0.1.dev1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 345936295c491ca7d7fc80c3712e0a98bb96bd3c904144a378a484c6975a4370
MD5 37604f979126fdcc48f75a9dd37c9442
BLAKE2b-256 4f8a3b9d74cb191b0dec6a2d7bc73d9ec0246dac0bd97f0f2f2ec000f3650842

See more details on using hashes here.

File details

Details for the file pytetwild-0.1.dev1-cp39-cp39-win_amd64.whl.

File metadata

File hashes

Hashes for pytetwild-0.1.dev1-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 43e0f12da7c1bd13315651aa3df3e6ce4ca47fa7d696daf3a48bb6b5d1089081
MD5 8681fb6b623d9635a3f2693ef5d820db
BLAKE2b-256 1915b30187609a8c4e629f9341be42d378f88190b4349e562972d7de0b47d397

See more details on using hashes here.

File details

Details for the file pytetwild-0.1.dev1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pytetwild-0.1.dev1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 8dc32e1e5dfba2f9fdbfce7ed5240c36cb8de093980d130cf1b532ca0db25036
MD5 4ef0b4afb99610bfb5966bcd54836da8
BLAKE2b-256 9f8a6d727f76ee6021e8613aa302ded4b32506fda4c272be23080500ecb0c5f7

See more details on using hashes here.

File details

Details for the file pytetwild-0.1.dev1-cp38-cp38-win_amd64.whl.

File metadata

File hashes

Hashes for pytetwild-0.1.dev1-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 98b685087b828107e06681a29a07319c3964f74e1113ade46b207c066e9b22cc
MD5 5124cb5910082cd230c632341ec72789
BLAKE2b-256 eb5f7e7ec5fcb5365a7d5cbe229659b49f2be1e708ca495c7c7ddf69e1ba250f

See more details on using hashes here.

File details

Details for the file pytetwild-0.1.dev1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pytetwild-0.1.dev1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e1f1a39787a78ec2be53a0a6e0324126bba732c957b2d4ef1c5fbb38953ae8cd
MD5 f4edbb9c8c93c1d771712c179504473d
BLAKE2b-256 cb8544d99f7c8181714fcdc36d741a2329d939375c097bf530cd594fa85693c9

See more details on using hashes here.

Supported by

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