跳转到主要内容

fTetWild的Python包装器

项目描述

pypi MPL

pytetwild是一个用于网格四面体化的Python库。它是围绕由fTetWild提供的有效C++四面体网格化库包装的Python库。

安装

我们为Windows和Linux x64预构建了Python 3.8 - Python 3.12的wheel。

安装pytetwild的推荐方法是使用PyPI

pip install pytetwild

您也可以克隆存储库并从源代码安装它,但由于涉及C++,构建稍微复杂一些。有关更多详细信息,请参阅CONTRIBUTING.md

使用

要从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

您还可以处理原始数组。这里是一个简单的立方体,我们将其转换为四面体。

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)

使用 - 选项

我们在每个接口tetrahedralizetetrahedralize_pv中公开了一些参数。以下是可选参数。

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.

许可证和致谢

本项目依赖fTetWild,并归功于原始作者为其高效的C++四面体网格化库。该作品根据Mozilla公共许可证v2.0许可。

存储库中的工作也根据Mozilla公共许可证v2.0许可。

支持

如果您遇到问题,请随时提出问题

项目详情


下载文件

下载适用于您的平台的文件。如果您不确定选择哪个,请了解有关安装包的更多信息。

源分布

pytetwild-0.1.dev1.tar.gz (3.1 MB 查看哈希值)

上传时间: 源代码

构建分布

pytetwild-0.1.dev1-cp312-cp312-win_amd64.whl (1.9 MB 查看哈希值)

上传时间: CPython 3.12 Windows x86-64

pytetwild-0.1.dev1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.7 MB 查看哈希值)

上传时间: CPython 3.12 manylinux: glibc 2.17+ x86-64

pytetwild-0.1.dev1-cp311-cp311-win_amd64.whl (1.9 MB 查看哈希值)

上传时间: CPython 3.11 Windows x86-64

pytetwild-0.1.dev1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.7 MB 查看哈希值)

上传时间: CPython 3.11 manylinux: glibc 2.17+ x86-64

pytetwild-0.1.dev1-cp310-cp310-win_amd64.whl (1.9 MB 查看哈希值)

上传时间: CPython 3.10 Windows x86-64

pytetwild-0.1.dev1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.7 MB 查看哈希值)

上传时间: CPython 3.10 manylinux: glibc 2.17+ x86-64

pytetwild-0.1.dev1-cp39-cp39-win_amd64.whl (1.9 MB 查看哈希值)

上传时间: CPython 3.9 Windows x86-64

pytetwild-0.1.dev1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.7 MB 查看哈希值)

上传时间: CPython 3.9 manylinux: glibc 2.17+ x86-64

pytetwild-0.1.dev1-cp38-cp38-win_amd64.whl (1.9 MB 查看哈希值)

上传时间 CPython 3.8 Windows x86-64

pytetwild-0.1.dev1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.7 MB 查看哈希值)

上传时间 CPython 3.8 manylinux: glibc 2.17+ x86-64

支持者

AWS AWS 云计算和安全赞助商 Datadog Datadog 监控 Fastly Fastly CDN Google Google 下载分析 Microsoft Microsoft PSF赞助商 Pingdom Pingdom 监控 Sentry Sentry 错误日志 StatusPage StatusPage 状态页面