pytetwild 0.1.dev0__cp39-cp39-win_amd64.whl → 0.1.dev1__cp39-cp39-win_amd64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Binary file
pytetwild/__init__.py CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
 
4
4
  # start delvewheel patch
5
- def _delvewheel_patch_1_5_2():
5
+ def _delvewheel_patch_1_5_4():
6
6
  import ctypes
7
7
  import os
8
8
  import platform
@@ -13,9 +13,9 @@ def _delvewheel_patch_1_5_2():
13
13
  if os.path.isdir(libs_dir):
14
14
  os.add_dll_directory(libs_dir)
15
15
  else:
16
- load_order_filepath = os.path.join(libs_dir, '.load-order-pytetwild-0.1.dev0')
16
+ load_order_filepath = os.path.join(libs_dir, '.load-order-pytetwild-0.1.dev1')
17
17
  if os.path.isfile(load_order_filepath):
18
- with open(os.path.join(libs_dir, '.load-order-pytetwild-0.1.dev0')) as file:
18
+ with open(os.path.join(libs_dir, '.load-order-pytetwild-0.1.dev1')) as file:
19
19
  load_order = file.read().split()
20
20
  for lib in load_order:
21
21
  lib_path = os.path.join(os.path.join(libs_dir, lib))
@@ -24,8 +24,8 @@ def _delvewheel_patch_1_5_2():
24
24
  raise OSError('Error loading {}; {}'.format(lib, ctypes.FormatError(ctypes.get_last_error())))
25
25
 
26
26
 
27
- _delvewheel_patch_1_5_2()
28
- del _delvewheel_patch_1_5_2
27
+ _delvewheel_patch_1_5_4()
28
+ del _delvewheel_patch_1_5_4
29
29
  # end delvewheel patch
30
30
 
31
31
  from ._version import __version__ # noqa: F401
pytetwild/py.typed ADDED
@@ -0,0 +1 @@
1
+ partial
pytetwild/pytetwild.py CHANGED
@@ -1,14 +1,32 @@
1
1
  """Wrapper for fTetWild."""
2
2
  import warnings
3
3
  import numpy as np
4
- from pytetwild import PyfTetWildWrapper
4
+ from pytetwild import PyfTetWildWrapper # type: ignore
5
5
  from typing import Tuple, TYPE_CHECKING
6
+ import numpy.typing as npt
6
7
 
7
8
  if TYPE_CHECKING:
8
9
  import pyvista as pv
9
10
 
10
11
 
11
- def tetrahedralize_pv(mesh: "pv.PolyData") -> "pv.UnstructuredGrid":
12
+ def _check_edge_length(edge_length_fac: float) -> None:
13
+ """Check edge length.
14
+
15
+ Parameters
16
+ ----------
17
+ edge_length_fac : float, default: 0.05
18
+ Tetrahedral edge length as a function of bounding box diagional. The
19
+ default ideal edge length is bb/20 (bounding box divided by 20).
20
+
21
+
22
+ """
23
+ if edge_length_fac > 1.0 or edge_length_fac < 0.0 + 1e-16:
24
+ raise ValueError("Edge length factor must be between 1e-16 and 1.0")
25
+
26
+
27
+ def tetrahedralize_pv(
28
+ mesh: "pv.PolyData", edge_length_fac: float = 0.05, optimize: bool = True
29
+ ) -> "pv.UnstructuredGrid":
12
30
  """
13
31
  Convert a PyVista surface mesh to a PyVista unstructured grid.
14
32
 
@@ -16,11 +34,33 @@ def tetrahedralize_pv(mesh: "pv.PolyData") -> "pv.UnstructuredGrid":
16
34
  ----------
17
35
  mesh : pv.PolyData
18
36
  The input surface mesh.
37
+ edge_length_fac : float, default: 0.05
38
+ Tetrahedral edge length as a function of bounding box diagional. The
39
+ default ideal edge length is bb/20 (bounding box divided by 20).
40
+ optimize : bool
41
+ Improve the minimum scaled Jacobean for each cell. This leads to higher
42
+ cell quality at the expense of computation time.
19
43
 
20
44
  Returns
21
45
  -------
22
46
  pv.UnstructuredGrid
23
- The converted unstructured grid.
47
+ The converted unstructured grid containing only tetrahedra.
48
+
49
+ Examples
50
+ --------
51
+ >>> import pyvista as pv
52
+ >>> import pytetwild
53
+ >>> surface_mesh = pv.Sphere()
54
+ >>> tetrahedral_mesh = pytetwild.tetrahedralize_pv(surface_mesh)
55
+ >>> tetrahedral_mesh
56
+ UnstructuredGrid (0x7ff568593d00)
57
+ N Cells: 7247
58
+ N Points: 1658
59
+ X Bounds: -4.993e-01, 4.993e-01
60
+ Y Bounds: -4.965e-01, 4.965e-01
61
+ Z Bounds: -5.000e-01, 4.999e-01
62
+ N Arrays: 0
63
+
24
64
  """
25
65
  try:
26
66
  import pyvista as pv
@@ -29,6 +69,9 @@ def tetrahedralize_pv(mesh: "pv.PolyData") -> "pv.UnstructuredGrid":
29
69
  "Install PyVista to use this feature with:\n\n" "pip install pytetwild[all]"
30
70
  )
31
71
 
72
+ if not isinstance(mesh, pv.PolyData):
73
+ raise TypeError(f"`mesh` must be a pyvista.PolyData, got {type(mesh)}")
74
+
32
75
  if not mesh.is_all_triangles:
33
76
  warnings.warn(
34
77
  "Input mesh is not all triangles. Either call `.triangulate()`"
@@ -36,13 +79,14 @@ def tetrahedralize_pv(mesh: "pv.PolyData") -> "pv.UnstructuredGrid":
36
79
  )
37
80
  mesh = mesh.triangulate()
38
81
 
39
- vertices = np.array(mesh.points, dtype=np.float64)
40
- faces = np.array(mesh.faces.reshape((-1, 4))[:, 1:4], dtype=np.int32)
82
+ _check_edge_length(edge_length_fac)
83
+ vertices = mesh.points.astype(np.float64, copy=False)
84
+ faces = mesh.faces.reshape((-1, 4))[:, 1:4].astype(np.float32, copy=False)
41
85
 
42
86
  (
43
87
  tetrahedral_mesh_vertices,
44
88
  tetrahedral_mesh_tetrahedra,
45
- ) = PyfTetWildWrapper.tetrahedralize_mesh(vertices, faces)
89
+ ) = PyfTetWildWrapper.tetrahedralize_mesh(vertices, faces, optimize, edge_length_fac)
46
90
 
47
91
  cells = np.hstack(
48
92
  [
@@ -55,7 +99,12 @@ def tetrahedralize_pv(mesh: "pv.PolyData") -> "pv.UnstructuredGrid":
55
99
  return pv.UnstructuredGrid(cells, cell_types, tetrahedral_mesh_vertices)
56
100
 
57
101
 
58
- def tetrahedralize(vertices: np.ndarray, faces: np.ndarray) -> Tuple[np.ndarray, np.ndarray]:
102
+ def tetrahedralize(
103
+ vertices: npt.NDArray[np.float64],
104
+ faces: npt.NDArray[np.int32],
105
+ optimize: bool = True,
106
+ edge_length_fac: float = 0.05,
107
+ ) -> Tuple[npt.NDArray[np.float64], npt.NDArray[np.int32]]:
59
108
  """
60
109
  Convert mesh vertices and faces to a tetrahedral mesh.
61
110
 
@@ -65,10 +114,23 @@ def tetrahedralize(vertices: np.ndarray, faces: np.ndarray) -> Tuple[np.ndarray,
65
114
  The vertices of the mesh.
66
115
  faces : np.ndarray
67
116
  The faces of the mesh.
117
+ optimize : bool
118
+ Improve the minimum scaled Jacobean for each cell. This leads to higher
119
+ cell quality at the expense of computation time.
120
+ edge_length_fac : float, default: 0.05
121
+ Tetrahedral edge length as a function of bounding box diagional. The
122
+ default ideal edge length is bb/20 (bounding box divided by 20).
68
123
 
69
124
  Returns
70
125
  -------
71
126
  Tuple[np.ndarray, np.ndarray]
72
127
  A tuple containing the vertices and tetrahedra of the tetrahedral mesh.
73
128
  """
74
- return PyfTetWildWrapper.tetrahedralize_mesh(vertices, faces)
129
+ _check_edge_length(edge_length_fac)
130
+ if not isinstance(vertices, np.ndarray):
131
+ raise TypeError("`vertices` must be a numpy array")
132
+ if not isinstance(faces, np.ndarray):
133
+ raise TypeError("`faces` must be a numpy array")
134
+ vertices = vertices.astype(np.float64, copy=False)
135
+ faces = faces.astype(np.int32, copy=False)
136
+ return PyfTetWildWrapper.tetrahedralize_mesh(vertices, faces, optimize, edge_length_fac)
@@ -0,0 +1,2 @@
1
+ Version: 1.5.4
2
+ Arguments: ['C:\\Users\\runneradmin\\AppData\\Local\\Temp\\cibw-run-rdukv1yg\\cp39-win_amd64\\build\\venv\\Scripts\\delvewheel', 'repair', '-w', 'C:\\Users\\runneradmin\\AppData\\Local\\Temp\\cibw-run-rdukv1yg\\cp39-win_amd64\\repaired_wheel', 'C:\\Users\\runneradmin\\AppData\\Local\\Temp\\cibw-run-rdukv1yg\\cp39-win_amd64\\built_wheel\\pytetwild-0.1.dev1-cp39-cp39-win_amd64.whl', '--add-path', '.']
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pytetwild
3
- Version: 0.1.dev0
3
+ Version: 0.1.dev1
4
4
  Summary: Python wrapper of fTetWild
5
5
  Author-Email: Alex Kaszynski <akascap@gmail.com>
6
6
  Classifier: Development Status :: 3 - Alpha
@@ -62,28 +62,72 @@ more details.
62
62
  Usage
63
63
  *****
64
64
 
65
- To tetrahedralize a surface mesh:
65
+ To tetrahedralize a surface mesh from `PyVista <https://docs.pyvista.org>`_:
66
66
 
67
- .. code:: pycon
67
+ .. code:: py
68
68
 
69
- >>> import pytetwild
70
- >>> mesh = pytetwild.tetrahedralize("input_mesh.ply")
71
- >>> mesh.vertices
72
- array([[x1, y1, z1],
73
- [x2, y2, z2],
74
- ...], dtype=float32)
75
- >>> mesh.tetrahedra
76
- array([[i1, j1, k1, l1],
77
- [i2, j2, k2, l2],
78
- ...], dtype=int32)
69
+ import pyvista as pv
70
+ import pytetwild
79
71
 
80
- You can also load a mesh, perform tetrahedralization, and export the tetrahedral mesh:
72
+ # Load or create a PyVista PolyData surface mesh
73
+ # Here, we'll create a simple sphere mesh as an example
74
+ surface_mesh = pv.Icosphere(nsub=2)
81
75
 
82
- .. code:: pycon
76
+ # Convert the surface mesh to a tetrahedral mesh. For this example let's
77
+ # use a coarse mesh
78
+ tetrahedral_mesh = pytetwild.tetrahedralize_pv(surface_mesh, edge_length_fac=1))
79
+
80
+ # Visualize the tetrahedral mesh in an "exploded" view
81
+ tetrahedral_mesh.explode(1).plot(show_edges=True)
83
82
 
84
- >>> import pytetwild
85
- >>> pytetwild.tetrahedralize("input_mesh.ply", "output_mesh.ply")
83
+ .. image:: https://github.com/pyvista/pytetwild/raw/main/exploded-sphere.png
84
+
85
+ You can also work with raw arrays. Here's a simple cube that we turn into tetrahedra.
86
+
87
+ .. code:: pycon
86
88
 
89
+ import numpy as np
90
+
91
+ # Define vertices of the cube
92
+ vertices = np.array([
93
+ [0, 0, 0], # Vertex 0
94
+ [1, 0, 0], # Vertex 1
95
+ [1, 1, 0], # Vertex 2
96
+ [0, 1, 0], # Vertex 3
97
+ [0, 0, 1], # Vertex 4
98
+ [1, 0, 1], # Vertex 5
99
+ [1, 1, 1], # Vertex 6
100
+ [0, 1, 1] # Vertex 7
101
+ ])
102
+
103
+ # Define faces using vertex indices
104
+ # Each face is a rectangle (also accepts triangles)
105
+ faces = np.array([
106
+ [0, 1, 2, 3], # Front face
107
+ [1, 5, 6, 2], # Right face
108
+ [5, 4, 7, 6], # Back face
109
+ [4, 0, 3, 7], # Left face
110
+ [4, 5, 1, 0], # Bottom face
111
+ [3, 2, 6, 7] # Top face
112
+ ])
113
+ v_out, tetra = pytetwild.tetrahedralize(vertices, faces, optimize=False)
114
+
115
+
116
+ Usage - Options
117
+ ---------------
118
+ We've surfaced a handful of parameters to each of our interfaces
119
+ ``tetrahedralize`` and ``tetrahedralize_pv``. Here are the optional parameters.
120
+
121
+ .. code::
122
+
123
+ Additional Parameters
124
+ ---------------------
125
+ edge_length_fac : float, default: 0.05
126
+ Tetrahedral edge length as a function of bounding box diagional. The
127
+ default ideal edge length is bb/20 (bounding box divided by 20).
128
+ optimize : bool
129
+ Improve the minimum scaled Jacobean for each cell. This leads to higher
130
+ cell quality at the expense of computation time.
87
131
 
88
132
 
89
133
  License and Acknowledgments
@@ -0,0 +1,15 @@
1
+ pytetwild/py.typed,sha256=mDShSrm8qg9qjacQc2F-rI8ATllqP6EdgHuEYxuCXZ0,7
2
+ pytetwild/PyfTetWildWrapper.pyd,sha256=01CDWJXI1rt6JTCCbrqGgeWCSD46lyS6oApnSuv90is,4988416
3
+ pytetwild/pytetwild.py,sha256=PSLlG5czLo2Z2aZtcgxmZAy97E9eAtbo7EdvY0WONIs,4646
4
+ pytetwild/_version.py,sha256=hbg9UkagWDGV6Zg23kEpex_otuUYHUzMCHXYTnFnHmE,118
5
+ pytetwild/__init__.py,sha256=VV91K2dLxkTdvnTq50PQy_an34g0_F_quG8aO7WdxV0,1528
6
+ pytetwild-0.1.dev1.dist-info/DELVEWHEEL,sha256=pYoKzxqBqhCJTpqHq0KcgcLJeU9jn1gmZdPT-zRSTRE,418
7
+ pytetwild-0.1.dev1.dist-info/entry_points.txt,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
+ pytetwild-0.1.dev1.dist-info/METADATA,sha256=6I1FzXoY9ezDC8EWamtUR2MVxWtBvgjD5frhxz4gw6Y,4587
9
+ pytetwild-0.1.dev1.dist-info/RECORD,,
10
+ pytetwild-0.1.dev1.dist-info/WHEEL,sha256=5LdD53aNvB3JLNYGt7PLG057a2l0YNjBXwsz2n0i3lo,103
11
+ pytetwild-0.1.dev1.dist-info/licenses/LICENSE,sha256=k0P1sbYupRWlxoESvbYq2UzoMW6MXA84LltqR-4mEo4,17096
12
+ pytetwild.libs/.load-order-pytetwild-0.1.dev1,sha256=Hy9XHN9hjgqs9sR6e0sg_OuXmwn6AuJBcT1zgDIQms0,135
13
+ pytetwild.libs/concrt140-ddbfd8b75976783430ced289c6b989c3.dll,sha256=BZPGv1uz0YBgBOgTWBBL0elt7C3clmR348_2Zlqh47Q,302080
14
+ pytetwild.libs/mpir-0f58ffaa159ebf7efb9359a55c2d7f23.dll,sha256=qd6vEIL0JPtRZ39EzelGE9rApfJ6duoMgV8jT8UHGns,612352
15
+ pytetwild.libs/msvcp140-3499a3a8427eec4915749ee9a8991ddd.dll,sha256=oDDcLf0uyiipN1ySmJrfTa8WH5iNteFrnhBnjrDf9Mc,573008
@@ -1,2 +0,0 @@
1
- Version: 1.5.2
2
- Arguments: ['C:\\Users\\runneradmin\\AppData\\Local\\Temp\\cibw-run-a87uf2fd\\cp39-win_amd64\\build\\venv\\Scripts\\delvewheel', 'repair', '-w', 'C:\\Users\\runneradmin\\AppData\\Local\\Temp\\cibw-run-a87uf2fd\\cp39-win_amd64\\repaired_wheel', 'C:\\Users\\runneradmin\\AppData\\Local\\Temp\\cibw-run-a87uf2fd\\cp39-win_amd64\\built_wheel\\pytetwild-0.1.dev0-cp39-cp39-win_amd64.whl', '--add-path', '.']
@@ -1,14 +0,0 @@
1
- pytetwild/PyfTetWildWrapper.pyd,sha256=OzvWZ-YQxgdrG4mSs9zdesncl7S2pCG-iwT4ID_ICZQ,4988416
2
- pytetwild/pytetwild.py,sha256=fA0lXIqIf97TONhpX2vME7_3vS_9kVh8ianOVIC44EU,2169
3
- pytetwild/_version.py,sha256=hbg9UkagWDGV6Zg23kEpex_otuUYHUzMCHXYTnFnHmE,118
4
- pytetwild/__init__.py,sha256=ZsWUxR7X3MfyYCuU3SOJJ8hTQVQC35mXGpxVBck_DRk,1528
5
- pytetwild-0.1.dev0.dist-info/DELVEWHEEL,sha256=Nbi7AuilBeI1zAZCYLVV7oRBwKv2ywMYc7DdN9rmz_o,418
6
- pytetwild-0.1.dev0.dist-info/entry_points.txt,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
- pytetwild-0.1.dev0.dist-info/METADATA,sha256=tAozjdbNnB40sjP1A_7R-maND-a9aNqKpNibMwI0k3c,3038
8
- pytetwild-0.1.dev0.dist-info/RECORD,,
9
- pytetwild-0.1.dev0.dist-info/WHEEL,sha256=5LdD53aNvB3JLNYGt7PLG057a2l0YNjBXwsz2n0i3lo,103
10
- pytetwild-0.1.dev0.dist-info/licenses/LICENSE,sha256=k0P1sbYupRWlxoESvbYq2UzoMW6MXA84LltqR-4mEo4,17096
11
- pytetwild.libs/.load-order-pytetwild-0.1.dev0,sha256=XBEBywweq6Ysj82uFvq2jdDH2rJVEaRa1mBdfdSfpMI,135
12
- pytetwild.libs/concrt140-ddbfd8b75976783430ced289c6b989c3.dll,sha256=BZPGv1uz0YBgBOgTWBBL0elt7C3clmR348_2Zlqh47Q,302080
13
- pytetwild.libs/mpir-0f58ffaa159ebf7efb9359a55c2d7f23.dll,sha256=qd6vEIL0JPtRZ39EzelGE9rApfJ6duoMgV8jT8UHGns,612352
14
- pytetwild.libs/msvcp140-3499a3a8427eec4915749ee9a8991ddd.dll,sha256=oDDcLf0uyiipN1ySmJrfTa8WH5iNteFrnhBnjrDf9Mc,573008
@@ -1,3 +1,3 @@
1
- mpir-0f58ffaa159ebf7efb9359a55c2d7f23.dll
2
- msvcp140-3499a3a8427eec4915749ee9a8991ddd.dll
3
1
  concrt140-ddbfd8b75976783430ced289c6b989c3.dll
2
+ msvcp140-3499a3a8427eec4915749ee9a8991ddd.dll
3
+ mpir-0f58ffaa159ebf7efb9359a55c2d7f23.dll