opengeostat / pygslib

GSLIB fortran code wrapped into python
MIT License
122 stars 53 forks source link

Use PyVista for 3D viz instead of ParaView #37

Open banesullivan opened 5 years ago

banesullivan commented 5 years ago

PyVista can do most things that ParaView can do and would meet the needs of the examples I have seen in the docs. It would be great if this library leveraged PyVista for native Python 3D viz to keep users from having to save out static copies of their data. Since PyVista is simply a wrapping layer on top of VTK, users could still use ParaView if they like, but would now have the additional option of using PyVista out of the box. The vtktools module could mostly be replaced by calls to PyVista which would cut down on a lot of maintenance for the VTK code, especially IO functions with formats like VTK, STL, etc. Also, if there are unique utilites in there leveraging VTK features we haven't yet wrapped in PyVista, I'd be happy to implement those functions in PyVista to keep VTK related maintence over in PyVista.

I'm willing to help implement this. @opengeostat, what do you think this might look like?

FYI: With PyVista support, all of the examples in the docs could be converted to be fully reproducible code to make the figures much like PyVista's examples gallery

banesullivan commented 5 years ago

Just an FYI: in the example notebook from the docs, simply:

import pyvista as pv

cmp = pv.read('cmp.vtk.vtp')
block_model = pv.read('model.vtu')

p = pv.Plotter()

p.add_mesh(cmp, scalars='CU', clim=[0,1], 
         cmap='coolwarm',
         render_lines_as_tubes=True, 
         line_width=5,
         show_grid=True)

p.add_mesh(block_model.clip('y'), scalars='D1',
           clim=[0, 1], cmap='coolwarm')
p.show()

download

Or get interactive with:

import pyvista as pv

cmp = pv.read('cmp.vtk.vtp')
block_model = pv.read('model.vtu')

p = pv.Plotter(notebook=False)

p.add_mesh(cmp, scalars='CU', clim=[0,1], 
         cmap='coolwarm',
         render_lines_as_tubes=True, 
         line_width=5,
         show_grid=True)

p.add_mesh_clip_box(block_model, scalars='D1',
           clim=[0, 1], cmap='coolwarm', rotation_enabled=False)
p.show()

2019-09-13 15 38 50

opengeostat commented 4 years ago

Hi @banesullivan,

Thanks for the advice. It is really cool example. I tried and is a really nice solution for visualization. It also simplifies readers and applying some VTK filters.

I notice that some filters are not implemented yet, for example, vtkLinearExtrusionFilter, and others are very unstable, for example, the boolean operations. However, this issue is on the VTK implementation.

I am considering including some support for CGAL and IGL to overcome some of the limitations in VTK. IGL may be handy to produce unfolding surfaces...

Thanks Again.

banesullivan commented 4 years ago

Many of the filters that are currently missing are pretty easy to implement - so let us know what is missing for you and we can get it going! It looks like vtkLinearExtrusionFilter got delayed in https://github.com/pyvista/pyvista/pull/449 - I will try to push that PR forward.

Support for CGAL and IGL would be awesome! I have no experience with those libraries but do let us know what limitations you're seeing with VTK (and PyVista by extension) to help us improve PyVista and some of PyVista's offshoot projects that address those limitations.

Also, what do you mean by an "unfolding surface"? Do you have an example where this is relevant in pygslib?

bluetyson commented 4 years ago

I just tried a small drillhole DB desurvey and used PyVista for viewing before I saw this (don't have paraview on this machine).

Xiaoyuew commented 2 years ago

Is there anyway that I can use Pyvista together with ParaView? I have succeeded in installing Pyvista on Pip and installing Paraview on Conda, but when I try to install Pyvista on Conda, I get conflicts.