pgleeson commited on
Commit
1feac69
·
1 Parent(s): c0520a6

Testing camera

Browse files
Files changed (2) hide show
  1. app.py +14 -26
  2. load.py +7 -1
app.py CHANGED
@@ -1,15 +1,11 @@
1
-
2
-
3
  import streamlit as st
4
-
5
-
6
  import stpyvista.utils
7
 
8
  if "IS_XVFB_RUNNING" not in st.session_state:
9
  stpyvista.utils.start_xvfb()
10
  st.session_state.IS_XVFB_RUNNING = True
11
 
12
- st.title("Sibernetic a example")
13
 
14
  import pyvista as pv
15
  import numpy as np
@@ -17,12 +13,10 @@ import numpy as np
17
  import time
18
 
19
  points = []
20
-
21
  types = []
22
 
23
  file = "position_buffer.txt"
24
 
25
-
26
  colours = {1.1: "lightblue", 2.1: "green", 2.2: "turquoise", 3: "#eeeeee"}
27
  colours = {1.1: "blue", 2.2: "turquoise"}
28
 
@@ -74,18 +68,22 @@ for l in open(file):
74
 
75
  time_count+=1
76
 
77
-
78
  line_count += 1
79
 
80
  #all_points_np = np.array(all_points)
81
 
82
  print(f"Loaded positions with %i elastic, %i liquid and %i boundary points (%i total), %i lines"%(numOfElasticP,numOfLiquidP, numOfBoundaryP,numOfElasticP+numOfLiquidP+numOfBoundaryP, line_count))
83
-
84
  print("Num of time points found: %i"%len(all_points))
85
 
86
- pl = pv.Plotter(window_size=[400,400])
87
  pl.set_background("lightgrey")
88
 
 
 
 
 
 
 
89
  last_mesh = None
90
 
91
  def create_mesh(step):
@@ -100,9 +98,12 @@ def create_mesh(step):
100
  curr_types = all_point_types[index]
101
  if last_mesh is None:
102
 
 
103
  last_mesh = pv.PolyData(curr_points)
104
  last_mesh["types"] = curr_types
105
  print(last_mesh)
 
 
106
 
107
  last_actor = pl.add_mesh(
108
  last_mesh,
@@ -111,26 +112,13 @@ def create_mesh(step):
111
  point_size=3,
112
  )
113
  else:
 
 
114
  last_mesh.points = curr_points
115
 
116
  #pl.render()
117
 
118
  time.sleep(0.1)
119
- '''
120
- ## Initialize a plotter object
121
- #plotter = pv.Plotter(window_size=[400,400])
122
-
123
- ## Create a mesh with a cube
124
- mesh = pv.Cube(center=(0,0,0))
125
-
126
- ## Add some scalar field associated to the mesh
127
- mesh['myscalar'] = mesh.points[:, 2] * mesh.points[:, 0]
128
-
129
- ## Add mesh to the plotter
130
- pl.add_mesh(mesh, scalars='myscalar', cmap='bwr')
131
-
132
- ## Final touches
133
- pl.view_isometric()'''
134
 
135
  return
136
 
@@ -144,5 +132,5 @@ print('Ready...')
144
 
145
  from stpyvista import stpyvista as spv
146
  ## Send to streamlit
147
- spv(pl, key="pv_cube")
148
 
 
 
 
1
  import streamlit as st
 
 
2
  import stpyvista.utils
3
 
4
  if "IS_XVFB_RUNNING" not in st.session_state:
5
  stpyvista.utils.start_xvfb()
6
  st.session_state.IS_XVFB_RUNNING = True
7
 
8
+ st.title("Sibernetic simple example")
9
 
10
  import pyvista as pv
11
  import numpy as np
 
13
  import time
14
 
15
  points = []
 
16
  types = []
17
 
18
  file = "position_buffer.txt"
19
 
 
20
  colours = {1.1: "lightblue", 2.1: "green", 2.2: "turquoise", 3: "#eeeeee"}
21
  colours = {1.1: "blue", 2.2: "turquoise"}
22
 
 
68
 
69
  time_count+=1
70
 
 
71
  line_count += 1
72
 
73
  #all_points_np = np.array(all_points)
74
 
75
  print(f"Loaded positions with %i elastic, %i liquid and %i boundary points (%i total), %i lines"%(numOfElasticP,numOfLiquidP, numOfBoundaryP,numOfElasticP+numOfLiquidP+numOfBoundaryP, line_count))
 
76
  print("Num of time points found: %i"%len(all_points))
77
 
78
+ pl = pv.Plotter(window_size=[800,600])
79
  pl.set_background("lightgrey")
80
 
81
+ pl.camera.position = (300, 100, -100.0)
82
+ pl.camera.focal_point = (50,0,100)
83
+ pl.camera.up = (0.0, 1.0, 0.0)
84
+ #pl.add_axes_at_origin(labels_off=False)
85
+ #pl.add_mesh(pv.Cube(center=(50,0,50)))
86
+
87
  last_mesh = None
88
 
89
  def create_mesh(step):
 
98
  curr_types = all_point_types[index]
99
  if last_mesh is None:
100
 
101
+ print('Adding mesh...')
102
  last_mesh = pv.PolyData(curr_points)
103
  last_mesh["types"] = curr_types
104
  print(last_mesh)
105
+ mesh2 = pv.Cube(center=(0,0,0))
106
+ pl.add_mesh(mesh2)
107
 
108
  last_actor = pl.add_mesh(
109
  last_mesh,
 
112
  point_size=3,
113
  )
114
  else:
115
+
116
+ print('Updating mesh...')
117
  last_mesh.points = curr_points
118
 
119
  #pl.render()
120
 
121
  time.sleep(0.1)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
122
 
123
  return
124
 
 
132
 
133
  from stpyvista import stpyvista as spv
134
  ## Send to streamlit
135
+ spv(pl, key="pv_cube2")
136
 
load.py CHANGED
@@ -77,6 +77,12 @@ print("Num of time points found: %i"%len(all_points))
77
  pl = pv.Plotter()
78
  pl.set_background("lightgrey")
79
 
 
 
 
 
 
 
80
  last_mesh = None
81
 
82
 
@@ -107,7 +113,7 @@ def create_mesh(step):
107
 
108
  pl.render()
109
 
110
- time.sleep(0.1)
111
 
112
  return
113
 
 
77
  pl = pv.Plotter()
78
  pl.set_background("lightgrey")
79
 
80
+ pl.camera.position = (300, 100, -100.0)
81
+ pl.camera.focal_point = (50,0,100)
82
+ pl.camera.up = (0.0, 1.0, 0.0)
83
+ #pl.add_axes_at_origin(labels_off=False)
84
+ #pl.add_mesh(pv.Cube(center=(50,0,50)))
85
+
86
  last_mesh = None
87
 
88
 
 
113
 
114
  pl.render()
115
 
116
+ time.sleep(0.01)
117
 
118
  return
119