Coder Social home page Coder Social logo

precise-simulation / mesh-viewer Goto Github PK

View Code? Open in Web Editor NEW
34.0 5.0 6.0 248 KB

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

Home Page: https://www.precisesimulation.com

License: GNU Affero General Public License v3.0

Python 100.00%
cad stl obj mesh viewer python matplotlib tkinter gui mvc

mesh-viewer's Introduction

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.

mesh-viewer's People

Contributors

precise-simulation avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

mesh-viewer's Issues

Error loading STL file

I tried to load an STL chess knight but it throws the following error:

Exception in Tkinter callback
Traceback (most recent call last):
  File "C:\ProgramData\Anaconda3\lib\tkinter\__init__.py", line 1705, in __call__
    return self.func(*args)
  File "meshviewer.py", line 274, in open
    self.model.load_file(file_name)
  File "meshviewer.py", line 46, in load_file
    self.data.append(mesh)
UnboundLocalError: local variable 'mesh' referenced before assignment

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.