Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,100 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import numpy as np
|
2 |
+
from myplot import plot_verticles
|
3 |
+
vertices = np.array([
|
4 |
+
[-3, -3, 0],
|
5 |
+
[+3, -3, 0],
|
6 |
+
[+3, +3, 0],
|
7 |
+
[-3, +3, 0],
|
8 |
+
[+0, +0, +3]
|
9 |
+
])
|
10 |
+
plot_verticles(vertices = vertices, isosurf = False)
|
11 |
+
|
12 |
+
plot_verticles(vertices = vertices, isosurf = True)
|
13 |
+
|
14 |
+
array([
|
15 |
+
[4, 1, 0],
|
16 |
+
[4, 2, 1],
|
17 |
+
[3, 4, 0],
|
18 |
+
[3, 4, 2],
|
19 |
+
[3, 2, 1],
|
20 |
+
[3, 1, 0]
|
21 |
+
], dtype=int32)
|
22 |
+
|
23 |
+
myramid_mesh = mesh.Mesh(
|
24 |
+
np.zeros(faces.shape[0], dtype=mesh.Mesh.dtype)
|
25 |
+
)
|
26 |
+
for i, f in enumerate(faces):
|
27 |
+
for j in range(3):
|
28 |
+
myramid_mesh.vectors[i][j] = vertices[f[j],:]
|
29 |
+
plot_mesh(myramid_mesh)
|
30 |
+
|
31 |
+
import matplotlib.pyplot as plt
|
32 |
+
from scipy import spatial
|
33 |
+
import numpy as np
|
34 |
+
points = np.array([
|
35 |
+
[0,0],
|
36 |
+
[-2,0],
|
37 |
+
[-2,2],
|
38 |
+
[0,1.5],
|
39 |
+
[2,2],
|
40 |
+
[2,0]
|
41 |
+
])
|
42 |
+
hull = spatial.ConvexHull(points)
|
43 |
+
|
44 |
+
array([
|
45 |
+
[2, 1],
|
46 |
+
[2, 4],
|
47 |
+
[5, 1],
|
48 |
+
[5, 4]
|
49 |
+
], dtype=int32)
|
50 |
+
|
51 |
+
plt.plot(points[:,0], points[:,1], 'o')
|
52 |
+
for simplex in hull.simplices:
|
53 |
+
plt.plot(points[simplex, 0], points[simplex, 1], 'k-')
|
54 |
+
|
55 |
+
plt.plot(points[:,0], points[:,1], 'o')
|
56 |
+
for simplex in hull.simplices:
|
57 |
+
plt.plot(points[simplex, 0], points[simplex, 1], 'k-')
|
58 |
+
|
59 |
+
|
60 |
+
import pymesh
|
61 |
+
box_a = pymesh.generate_box_mesh([0,0,0], [1,1,1])
|
62 |
+
filename = "/pymesh_examples/pymesh_example_01.stl"
|
63 |
+
pymesh.save_mesh(filename, box_a, ascii=False)
|
64 |
+
|
65 |
+
import pymesh
|
66 |
+
box_a = pymesh.generate_box_mesh([0,0,0], [1,1,1])
|
67 |
+
box_b = pymesh.generate_box_mesh([0.4,0.4,0], [0.6,0.6,1])
|
68 |
+
box_c = pymesh.boolean(
|
69 |
+
box_a,
|
70 |
+
box_b,
|
71 |
+
operation='difference',
|
72 |
+
engine="igl"
|
73 |
+
)
|
74 |
+
filename = "/pymesh_examples/pymesh_example_02.stl"
|
75 |
+
pymesh.save_mesh(filename, box_c, ascii=False)
|
76 |
+
|
77 |
+
from solid import *
|
78 |
+
d = difference()(
|
79 |
+
cube(size = 10, center = True),
|
80 |
+
sphere(r = 6.5, segments=300)
|
81 |
+
)
|
82 |
+
path = scad_render_to_file(d, 'solidpython_example_01.scad')
|
83 |
+
|
84 |
+
|
85 |
+
from solid import *
|
86 |
+
c = circle(r = 1)
|
87 |
+
t = translate([2, 0, 0]) (c)
|
88 |
+
e = linear_extrude(
|
89 |
+
height = 10,
|
90 |
+
center = True,
|
91 |
+
convexity = 10,
|
92 |
+
twist = -500,
|
93 |
+
slices = 500
|
94 |
+
) (t)
|
95 |
+
col = color('lightgreen') (e)
|
96 |
+
path = scad_render_to_file(col, 'solidpython_example_02.scad')
|
97 |
+
|
98 |
+
|
99 |
+
|
100 |
+
|