Skip to content

Python STL/OBJ CAD mesh viewers comparing Matplotlib/Plotly/Vispy backends and Tkinter GUI

License

Notifications You must be signed in to change notification settings

precise-simulation/mesh-viewer

Repository files navigation

Mesh Viewer

Mesh Viewer is a simple STL/OBJ CAD geometry and surface mesh viewer prototype with a Model View Controller (MVC) type design. Three different visualization backends are compared and embedded within the same Python/tkinter GUI framework.

Mesh Viewer screenshot

The vispy/opengl backend seems to be the best choice overall with respect to performance and packaged size (~35 MB), while plotly (subjectively) looks the best but leads to large binaries due to embedding the Chromium framework (~70-90 MB), matplotlib is the simplest backend but suffers from slow performance for larger visualizations.

Python Script Use

Simply downloading and running the corresponding Python scripts should start both the GUI and mesh viewer application. The examples below show how to set up a new conda Python environment with the required dependencies.

mesh-viewer with matplotlib backend

conda create -n mpl python=3.7 conda activate mpl conda install conda-forge::blas=*=openblas numpy pip install matplotlib==3.2.2 python meshviewer_mpl_tk.py 

mesh-viewer with plotly/cefpython backend

conda create -n plotly python=3.7 conda activate plotly conda install conda-forge::blas=*=openblas numpy pip install cefpython3 python meshviewer_plotly_cef_tk.py 

mesh-viewer with vispy/pyopengltk backend

conda create -n vispy python=3.7 conda activate vispy conda install conda-forge::blas=*=openblas numpy pip install cython pip install pyopengltk git clone --recurse-submodules https://github.com/Wosser1sProductions/vispy.git cd vispy git submodule update --init --recursive pip install . --no-use-pep517 cd .. python meshviewer_vispy_tk.py 

Pre-Built Binaries

The releases include stand-alone and pre-compiled executable one-click binaries (exe) for Windows systems (note that it may take several seconds to load/start due to extracting all resources, and that the plotly backed required an internet connection and accepting a Microsoft/Windows certificate to download the plotly javascript library). Building stand-alone executables can be done with pyinstaller as described below.

build mesh-viewer with matplotlib backend

conda create -n mpl python=3.7 conda activate mpl conda install conda-forge::blas=*=openblas numpy pip install matplotlib==3.2.2 pip install pyinstaller pyinstaller --onefile --windowed --noupx meshviewer_mpl_tk.py conda env remove -n mpl 

build mesh-viewer with plotly/cefpython backend

conda create -n plotly python=3.7 conda activate plotly conda install conda-forge::blas=*=openblas numpy pip install cefpython3 pip install pyinstaller==3.6 cd build python build.py --onefile conda env remove -n plotly 

build mesh-viewer with vispy/pyopengltk backend

conda create -n vispy python=3.7 conda activate vispy conda install conda-forge::blas=*=openblas numpy pip install cython pip install pyopengltk git clone --recurse-submodules https://github.com/Wosser1sProductions/vispy.git cd vispy git submodule update --init --recursive pip install . --no-use-pep517 pip install pyinstaller cd ../build pyinstaller --onefile meshviewer_vispy_tk.spec conda env remove -n vispy 

Note

This is just a simple prototype/proof-of-concept and not intended to be a full fledged application. If you are interested in custom CAE and simulation tools such as this app and FEATool Multiphysics please feel free to get in touch with Precise Simulation.

License

AGPL v3, see LICENSE for more details.

Copyright (C) 2020 Precise Simulation Ltd.