TestOSBB / app.py
pgleeson's picture
Tweaks
c3e1016
raw
history blame contribute delete
994 Bytes
import pyvista as pv
import sys
st_mode = '-gui' not in sys.argv
if st_mode:
import streamlit as st
st.set_page_config(layout="wide")
from stpyvista import stpyvista
from stpyvista.utils import start_xvfb
if "IS_XVFB_RUNNING" not in st.session_state:
start_xvfb()
st.session_state.IS_XVFB_RUNNING = True
## Initialize a plotter object
plotter = pv.Plotter(window_size=[800,600])
print('Reading all the objs...')
mesh = pv.read('a_mouse.obj')
plotter.add_mesh(mesh, smooth_shading=True, color='white')
mesh2 = pv.read('full_mouse.obj')
mesh2.translate((-40,0,0), inplace=True)
plotter.add_mesh(mesh2, smooth_shading=True, color='tan')
print('Read objs...')
plotter.add_axes()
plotter.enable_mesh_picking(show_message=True)
## Final touches
plotter.view_isometric()
#plotter.add_scalar_bar()
plotter.background_color = 'white'
if st_mode:
## Pass a key to avoid re-rendering at each page change
stpyvista(plotter, key="pv_cube")
else:
plotter.show()