awacke1 commited on
Commit
c06450b
·
verified ·
1 Parent(s): 85d8235

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -11
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
- # Assuming 'plot_verticles' and 'plot_mesh' are defined in 'myplot'
14
- plot_verticles(vertices=vertices, isosurf=False)
15
- plot_verticles(vertices=vertices, isosurf=True)
16
-
17
- # Create and plot mesh
18
- myramid_mesh = mesh.Mesh(np.zeros(faces.shape[0], dtype=mesh.Mesh.dtype))
19
- for i, f in enumerate(faces):
20
- for j in range(3):
21
- myramid_mesh.vectors[i][j] = vertices[f[j],:]
22
- plot_mesh(myramid_mesh)
 
 
 
 
 
 
 
 
 
 
 
 
 
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):