huathedev commited on
Commit
62596b8
1 Parent(s): 2acb6b2

Upload 4 files

Browse files
Files changed (5) hide show
  1. .gitattributes +1 -0
  2. app.py +33 -16
  3. dental-labels4.json +0 -0
  4. file.obj +3 -0
  5. requirements.txt +1 -4
.gitattributes CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ file.obj filter=lfs diff=lfs merge=lfs -text
app.py CHANGED
@@ -1,17 +1,34 @@
1
- import streamlit as st
2
- import streamlit.components.v1 as components
3
- import pyvista
4
- from pyvista import examples
5
- pyvista.start_xvfb()
6
- mesh = examples.load_uniform()
7
- pl = pyvista.Plotter(shape=(1,2))
8
- _ = pl.add_mesh(mesh, scalars='Spatial Point Data', show_edges=True)
9
- pl.subplot(0,1)
10
- _ = pl.add_mesh(mesh, scalars='Spatial Cell Data', show_edges=True)
11
- pl.export_html('pyvista.html') # doctest:+SKIP
12
 
13
- option=st.sidebar.radio('Pyvista',('On','Off'))
14
- if option=='On':
15
- HtmlFile = open("pyvista.html", 'r', encoding='utf-8')
16
- source_code = HtmlFile.read()
17
- components.html(source_code, height = 500,width=500)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import pyvista as pv
2
+ import json
3
+ from stpyvista import stpyvista
 
 
 
 
 
 
 
 
4
 
5
+ # Load the .obj file
6
+ mesh = pv.read('file.obj')
7
+
8
+ # Load the JSON file
9
+ with open('output/dental-labels4.json', 'r') as file:
10
+ labels_data = json.load(file)
11
+
12
+ # Assuming labels_data['labels'] is a list of labels
13
+ labels = labels_data['labels']
14
+
15
+ # Make sure the number of labels matches the number of vertices or faces
16
+ assert len(labels) == mesh.n_points or len(labels) == mesh.n_cells
17
+
18
+ # If labels correspond to vertices
19
+ if len(labels) == mesh.n_points:
20
+ mesh.point_data['Labels'] = labels
21
+ # If labels correspond to faces
22
+ elif len(labels) == mesh.n_cells:
23
+ mesh.cell_data['Labels'] = labels
24
+
25
+ # Create a pyvista plotter
26
+ plotter = pv.Plotter()
27
+
28
+ # Add the mesh to the plotter with labels as a scalar field
29
+ plotter.add_mesh(mesh, scalars='Labels', show_scalar_bar=True, cmap='jet')
30
+
31
+ # Show the plot
32
+ #plotter.show()
33
+ ## Send to streamlit
34
+ stpyvista(plotter)
dental-labels4.json ADDED
The diff for this file is too large to render. See raw diff
 
file.obj ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:581b9a026e2ce734f6335f34aa900e8114dc33e2a83541ebd6bb26536382545e
3
+ size 18769177
requirements.txt CHANGED
@@ -1,7 +1,4 @@
1
  streamlit
2
  pyvista
3
  pythreejs
4
- trame-vtk
5
- trame==3.3.0
6
- trame-vuetify
7
- nest_asyncio
 
1
  streamlit
2
  pyvista
3
  pythreejs
4
+ stpyvista==0.0.11