Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,7 +1,8 @@
|
|
1 |
import streamlit as st
|
2 |
import numpy as np
|
3 |
-
from myplotlib import plot_verticles, plot_mesh
|
4 |
import matplotlib.pyplot as plt
|
|
|
|
|
5 |
from scipy import spatial
|
6 |
import pymesh
|
7 |
from solid import *
|
@@ -10,16 +11,29 @@ import os
|
|
10 |
|
11 |
# Function to plot vertices and meshes
|
12 |
def plot_vertices_and_mesh(vertices, faces):
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
|
24 |
# Function to plot convex hull
|
25 |
def plot_convex_hull(points):
|
|
|
1 |
import streamlit as st
|
2 |
import numpy as np
|
|
|
3 |
import matplotlib.pyplot as plt
|
4 |
+
from mpl_toolkits.mplot3d import Axes3D
|
5 |
+
from mpl_toolkits.mplot3d.art3d import Poly3DCollection
|
6 |
from scipy import spatial
|
7 |
import pymesh
|
8 |
from solid import *
|
|
|
11 |
|
12 |
# Function to plot vertices and meshes
|
13 |
def plot_vertices_and_mesh(vertices, faces):
|
14 |
+
fig = plt.figure()
|
15 |
+
ax = fig.add_subplot(111, projection='3d')
|
16 |
+
|
17 |
+
# Plot vertices
|
18 |
+
ax.scatter(vertices[:, 0], vertices[:, 1], vertices[:, 2])
|
19 |
+
|
20 |
+
# Plot faces
|
21 |
+
for face in faces:
|
22 |
+
vertices_of_face = vertices[face]
|
23 |
+
poly = Poly3DCollection([vertices_of_face])
|
24 |
+
ax.add_collection3d(poly)
|
25 |
+
|
26 |
+
st.pyplot(fig)
|
27 |
+
|
28 |
+
# Rest of the functions remain the same
|
29 |
+
|
30 |
+
# Streamlit UI
|
31 |
+
st.title("3D Graphics and Geometry with Streamlit")
|
32 |
+
|
33 |
+
if st.button('Plot Vertices and Meshes'):
|
34 |
+
vertices = np.array([[-3, -3, 0], [+3, -3, 0], [+3, +3, 0], [-3, +3, 0], [+0, +0, +3]])
|
35 |
+
faces = np.array([[4, 1, 0], [4, 2, 1], [3, 4, 0], [3, 4, 2], [3, 2, 1], [3, 1, 0]], dtype=np.int32)
|
36 |
+
plot_vertices_and_mesh(vertices, faces)
|
37 |
|
38 |
# Function to plot convex hull
|
39 |
def plot_convex_hull(points):
|