pytessel 1.2.4__cp311-cp311-macosx_11_0_arm64.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.
Potentially problematic release.
This version of pytessel might be problematic. Click here for more details.
- pytessel/__init__.py +3 -0
- pytessel/_version.py +1 -0
- pytessel/isosurface.cpp +561 -0
- pytessel/isosurface.h +180 -0
- pytessel/isosurface_mesh.cpp +144 -0
- pytessel/isosurface_mesh.h +104 -0
- pytessel/pytessel.cpython-311-darwin.so +0 -0
- pytessel/scalar_field.cpp +239 -0
- pytessel/scalar_field.h +104 -0
- pytessel-1.2.4.dist-info/LICENSE +674 -0
- pytessel-1.2.4.dist-info/METADATA +169 -0
- pytessel-1.2.4.dist-info/RECORD +14 -0
- pytessel-1.2.4.dist-info/WHEEL +5 -0
- pytessel-1.2.4.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
Metadata-Version: 2.2
|
|
2
|
+
Name: pytessel
|
|
3
|
+
Version: 1.2.4
|
|
4
|
+
Summary: Python package for building isosurfaces from 3D scalar fields
|
|
5
|
+
Home-page: https://github.com/ifilot/pytessel
|
|
6
|
+
Author: Ivo Filot
|
|
7
|
+
Author-email: ivo@ivofilot.nl
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
+
Classifier: Operating System :: POSIX
|
|
11
|
+
Requires-Python: >=3.5
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
License-File: LICENSE
|
|
14
|
+
Requires-Dist: numpy
|
|
15
|
+
Dynamic: author
|
|
16
|
+
Dynamic: author-email
|
|
17
|
+
Dynamic: classifier
|
|
18
|
+
Dynamic: description
|
|
19
|
+
Dynamic: description-content-type
|
|
20
|
+
Dynamic: home-page
|
|
21
|
+
Dynamic: requires-dist
|
|
22
|
+
Dynamic: requires-python
|
|
23
|
+
Dynamic: summary
|
|
24
|
+
|
|
25
|
+
# PyTessel
|
|
26
|
+
|
|
27
|
+
[](https://github.com/ifilot/pytessel/actions/workflows/build_Conda.yml)
|
|
28
|
+
[](https://github.com/ifilot/pytessel/actions/workflows/build_wheels.yml)
|
|
29
|
+
[](https://anaconda.org/ifilot/pytessel)
|
|
30
|
+
[](https://pypi.org/project/pytessel/)
|
|
31
|
+
[](https://www.gnu.org/licenses/gpl-3.0)
|
|
32
|
+
|
|
33
|
+
## Purpose
|
|
34
|
+
|
|
35
|
+
Python package for building isosurfaces from 3D scalar fields
|
|
36
|
+
|
|
37
|
+
## Installation
|
|
38
|
+
|
|
39
|
+
### Anaconda
|
|
40
|
+
|
|
41
|
+
[](https://anaconda.org/ifilot/pytessel)
|
|
42
|
+
[](https://anaconda.org/ifilot/pytessel)
|
|
43
|
+
[](https://anaconda.org/ifilot/pytessel)
|
|
44
|
+
[](https://anaconda.org/ifilot/pytessel)
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
```
|
|
48
|
+
conda install -c ifilot pyqint
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### PyPi
|
|
52
|
+
|
|
53
|
+
[](https://pypi.org/project/pytessel/)
|
|
54
|
+
[](https://pypi.org/project/pytessel/)
|
|
55
|
+

|
|
56
|
+
|
|
57
|
+
```
|
|
58
|
+
pip install pytessel
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Getting started
|
|
62
|
+
|
|
63
|
+
In the script below, the isosurface of a threedimensional Gaussian function is
|
|
64
|
+
constructed. The isosurface is written to `test.ply` and can, for example,
|
|
65
|
+
be opened using `ctmviewer` (Linux) or `3D viewer` (Windows).
|
|
66
|
+
|
|
67
|
+
```python
|
|
68
|
+
from pytessel import PyTessel
|
|
69
|
+
import numpy as np
|
|
70
|
+
|
|
71
|
+
def main():
|
|
72
|
+
pytessel = PyTessel()
|
|
73
|
+
|
|
74
|
+
# generate some data
|
|
75
|
+
x = np.linspace(0, 10, 50)
|
|
76
|
+
# the grid is organized with z the slowest moving index and x the fastest moving index
|
|
77
|
+
grid = np.flipud(np.vstack(np.meshgrid(x, x, x, indexing='ij')).reshape(3,-1)).T
|
|
78
|
+
|
|
79
|
+
R = [5,5,5]
|
|
80
|
+
scalarfield = np.reshape(np.array([gaussian(r,R) for r in grid]), (len(x),len(x),len(x)))
|
|
81
|
+
unitcell = np.diag(np.ones(3) * 10.0)
|
|
82
|
+
|
|
83
|
+
vertices, normals, indices = pytessel.marching_cubes(scalarfield.flatten(), scalarfield.shape, unitcell.flatten(), 0.1)
|
|
84
|
+
|
|
85
|
+
pytessel.write_ply('test.ply', vertices, normals, indices)
|
|
86
|
+
|
|
87
|
+
def gaussian(r, R):
|
|
88
|
+
return np.exp(-(r-R).dot((r-R)))
|
|
89
|
+
|
|
90
|
+
if __name__ == '__main__':
|
|
91
|
+
main()
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## Isosurface quality
|
|
95
|
+
|
|
96
|
+
In the script below, 6 different images are created of an icosahedral "metaball" using a grid
|
|
97
|
+
of `10x10x10`,`20x20x20`,`25x25x25`,`50x50x50`,`100x100x100`, and `200x200x200` points. The
|
|
98
|
+
resulting `.ply` files are rendered using [Blender](https://www.blender.org/).
|
|
99
|
+
|
|
100
|
+
```python
|
|
101
|
+
from pytessel import PyTessel
|
|
102
|
+
import numpy as np
|
|
103
|
+
|
|
104
|
+
def main():
|
|
105
|
+
"""
|
|
106
|
+
Build 6 .ply files of increasing quality
|
|
107
|
+
"""
|
|
108
|
+
pytessel = PyTessel()
|
|
109
|
+
|
|
110
|
+
for nrpoints in [10,20,25,50,100,200]:
|
|
111
|
+
sz = 3
|
|
112
|
+
|
|
113
|
+
x = np.linspace(-sz, sz, nrpoints)
|
|
114
|
+
y = np.linspace(-sz, sz, nrpoints)
|
|
115
|
+
z = np.linspace(-sz, sz, nrpoints)
|
|
116
|
+
|
|
117
|
+
xx, yy, zz, field = icosahedron_field(x,y,z)
|
|
118
|
+
|
|
119
|
+
unitcell = np.diag(np.ones(3) * sz * 2)
|
|
120
|
+
pytessel = PyTessel()
|
|
121
|
+
isovalue = 3.75
|
|
122
|
+
vertices, normals, indices = pytessel.marching_cubes(field.flatten(), field.shape, unitcell.flatten(), isovalue)
|
|
123
|
+
|
|
124
|
+
pytessel.write_ply('icosahedron_%03i.ply' % nrpoints, vertices, normals, indices)
|
|
125
|
+
|
|
126
|
+
def icosahedron_field(x,y,z):
|
|
127
|
+
"""
|
|
128
|
+
Produce a scalar field for the icosahedral metaballs
|
|
129
|
+
"""
|
|
130
|
+
phi = (1 + np.sqrt(5)) / 2
|
|
131
|
+
vertices = [
|
|
132
|
+
[0,1,phi],
|
|
133
|
+
[0,-1,-phi],
|
|
134
|
+
[0,1,-phi],
|
|
135
|
+
[0,-1,phi],
|
|
136
|
+
[1,phi,0],
|
|
137
|
+
[-1,-phi,0],
|
|
138
|
+
[1,-phi,0],
|
|
139
|
+
[-1,phi,0],
|
|
140
|
+
[phi,0,1],
|
|
141
|
+
[-phi,0,-1],
|
|
142
|
+
[phi,0,-1],
|
|
143
|
+
[-phi,0,1]
|
|
144
|
+
]
|
|
145
|
+
|
|
146
|
+
xx,yy,zz = np.meshgrid(x,y,z)
|
|
147
|
+
field = np.zeros_like(xx)
|
|
148
|
+
for v in vertices:
|
|
149
|
+
field += f(xx,yy,zz,v[0], v[1],v[2])
|
|
150
|
+
|
|
151
|
+
return xx,yy,zz,field
|
|
152
|
+
|
|
153
|
+
def f(x,y,z,X0,Y0,Z0):
|
|
154
|
+
"""
|
|
155
|
+
Single metaball function
|
|
156
|
+
"""
|
|
157
|
+
return 1 / ((x - X0)**2 + (y - Y0)**2 + (z - Z0)**2)
|
|
158
|
+
|
|
159
|
+
if __name__ == '__main__':
|
|
160
|
+
main()
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+

|
|
164
|
+
|
|
165
|
+
## Local compilation (Linux)
|
|
166
|
+
|
|
167
|
+
```bash
|
|
168
|
+
python3 setup.py build_ext --inplace bdist
|
|
169
|
+
```
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
pytessel/_version.py,sha256=XBKH8E1LmDxv06U39yqMBbXZapOERFgICEDYZs_kRso,22
|
|
2
|
+
pytessel/isosurface_mesh.cpp,sha256=zoahovBodabqx2zfHkW5xIGBvU84n15tUlsy0yyexp8,6387
|
|
3
|
+
pytessel/__init__.py,sha256=vro51HMaT-ePmW0CgIsDkOgTzutYGB2UgmyV7elT09A,66
|
|
4
|
+
pytessel/pytessel.cpython-311-darwin.so,sha256=OJJd9rYw1-WOVgNN5ZaTfB70P2ebqxECe0XtxnU-1_Y,177136
|
|
5
|
+
pytessel/isosurface_mesh.h,sha256=5n0TJDDlQBcJu9SOxTmW21_g8YEP5Jq9GVrVwMh7IH0,3458
|
|
6
|
+
pytessel/isosurface.h,sha256=dpenMn9T2KuiYw112HuEdIkuh7fqp12FaVJE-00vMsY,5570
|
|
7
|
+
pytessel/scalar_field.cpp,sha256=Ey1LxTnU_Ul40eIZvZZWgTnhJ8P-dP3aK16nEiOEOsk,8818
|
|
8
|
+
pytessel/isosurface.cpp,sha256=Q4a3lqrgnWGfwyZEdUnC6uSCQ46izSO-8SMWrcGTqWg,20664
|
|
9
|
+
pytessel/scalar_field.h,sha256=sfGoX7VtbA6V99dMqLDpYq79xCFFJAKXL1UXd5QBxWs,3593
|
|
10
|
+
pytessel-1.2.4.dist-info/RECORD,,
|
|
11
|
+
pytessel-1.2.4.dist-info/LICENSE,sha256=4cCtcomD2KVzNeUs8QZPGv_R1FQXPYzr0-2LSnK0hwQ,35121
|
|
12
|
+
pytessel-1.2.4.dist-info/WHEEL,sha256=XnRbs9isaZGW7UFs-rmrxXgojUM9oS1_E-0jMiKye-g,109
|
|
13
|
+
pytessel-1.2.4.dist-info/top_level.txt,sha256=QDauMEeJ6MuBmtCTV4HZAr1XodXsUesXTlcImp5LE54,9
|
|
14
|
+
pytessel-1.2.4.dist-info/METADATA,sha256=WZOztzFkTradGU6FaYkKdxLLCmr3QgoykiMfMxQN06Y,5206
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
pytessel
|