Export as VTKjs
On this page, we demonstrate how to quickly share a 3D rendering of your ParaView visualizations with anyone who has access to the internet so that that can explore the whole scene in a dynamic manner.
In order to effectively communicate our geoscientific findings, we often need to share our 3D visualizations with interested stakeholders. These interested parties are likely not going to have ParaView or other visualization software at hand. Thus we desire to have a means to export our complex visualizations in ParaView to a simple, shareable format that anyone can view. To accomplish this, we will take advantage of vtk.js and its standalone web viewer for vtk.js formats.
Would not it be great to send your client or interested parties an interactive 3D scene of your Geophysical findings like the example below?
vtk.js is a rendering library made for scientific visualization on the web. This code base brings high performance rendering into anyone’s web browser. This library allows us to export complex scenes from ParaView and share them with anyone that has a web browser like Safari or Google Chrome.
The vtk.js library has an open-source standalone scene viewer which they have a nice demo for here. The first link can either be downloaded as an HTML file to be ran locally, or you can go to that link and run from the vtk.js server. vtk.js also published a scene export macro for ParaView that compresses a data scene in ParaView to a shareable format for viewing on the web. The macro from the vtk.js library can be found here but we also deploy an updated (we think more robust) version of this export macro in the sub-module
export of our Python module
Demo Shareable Format¶
Here are some samples to demonstrate the web viewer which we host on viewer.pvgeo.org. We have included a few of our scenes and one of the vtk.js sample scenes for you to demo:
First, make a complex scene in ParaView that you might like to share with someone. Now that you have your scene loaded, open the python shell from’View->Python Shell’ (or ‘Tools->Python Shell’ depending on your ParaView version) within ParaView. From here, import our Python module delivered in the repository called
pvmacros. From the
export sub-module, there is a function called
def exportVTKjs() which takes two optional arguments (
FileName string and
compress boolean). Execute this function and note the output text as it will describe where the exported scene was saved.
## Import our ParaView Macros module: import pvmacros as pvm ## Now run the exportVTKjs script from the export sub-module pvm.export.exportVTKjs(FileName='test_export')
Now open the standalone web viewer by opening viewer.pvgeo.org.
Select the exported scene as the input file for the web viewer from where you saved it (should be under
~/Dropbox/PVGeo_vtkjs/). The export macro should have printed out the location of the saved scene in the Python Shell.
How to Share¶
To share these exported scenes with non-technical stakeholders, we recommend the following processes:
Quick and Easy¶
- Create your scene and export to the vtk.js format (follow process above)
- Quality control your visualization by viewing in web browser yourself (follow process above)
- Send an email with your visualization (
*.vtkjsfile) and something along the lines of:
Check out the data scene/model by downloading the attached file. Then go to the link below and open that downloaded file.
A Bit More Robust¶
Sometimes we might want to give someone a direct link to the web visualization so all they have to do is open the link on any device and they can see our visualization. Here is a method to share scenes that have a slightly easier process of viewing the file for the end user and will handle the case for mobile platforms.
Unfortunately, making the experience for the end user simple means making your experience a bit more complicated. You will need to host your file on a web service like GitHub or Dropbox (we have been unsuccessful in getting Google Drive to work). Then get a public link to the
*.vtkjs file on that web service and append it to the web viewer URL.
We have created a Python script to generate these links for you if you are sharing your data file on either Dropbox or GitHub. The script is delivered in the repository and can also be found here.
The easiest way that we have found is to share the files on Dropbox. Use the desktop client for Dropbox and right-click your exported
*.vtkjs file and select “Copy Dropbox Link.”
Once you have that link, use the this script on your URLs in this manner:
## Usage: python get_vtkjs_url.py <web file host> <file link> ## Dropbox example: python get_vtkjs_url.py dropbox "https://www.dropbox.com/s/6m5ttdbv5bf4ngj/ripple.vtkjs?dl=0"