-
Notifications
You must be signed in to change notification settings - Fork 83
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DOC: Add pyvista.PolyData example #154
Conversation
Check out this pull request on ReviewNB: https://app.reviewnb.com/InsightSoftwareConsortium/itk-jupyter-widgets/pull/154 You'll be able to see visual diffs and write comments on notebook cells. Powered by ReviewNB. |
This is interesting... REALLY interesting. |
@thewtex - this is major - Considering This is perfect timing with some other PRs in PyVista (see pyvista/pyvista#268 and pyvista/pyvista#300). I'm going to hack at this and see what I can make happen for prototypes and share those here in a bit. As for implementation and path forward: I'm wondering if we should approach this the same way as the other notebook plotting tools we've added in PyVista including VTKjs through @akaszynski - thoughts? This is absolutely the best option in my opinion for notebook plotting. |
@thewtex - I'm curious if there is a way to instantiate a import pyvista as pv
from pyvista import examples
from itkwidgets import view, Viewer
mesh = examples.download_st_helens().warp_by_scalar().extract_geomerty()
plotter = Viewer()
plotter.geometries = [mesh,]
plotter.geometries.append(mesh.contour())
plotter This doesn't seem to be working... I know I can pass many geometries upon instantiation, but ideally, I'd like to make a class that holds on to a class PlotterITK():
def __init__(self, **kwargs):
self.plotter = Viewer()
def add_mesh(self, mesh, **kwargs):
"""Adds mesh to the scene"""
mesh = mesh.extract_geometry()
self.plotter.geometries.append(mesh)
# Handle all the RGB mapping and styling as well
def show(self, **kwargs):
"""Show in cell output"""
return self.plotter
plotter = PlotterITK()
plotter.add_mesh(mesh) # pass args for coloring too
plotter.show() |
Also, I thought we could plot scalar attributes on the geometries... is this not currently possible? |
Also, what about plotting PolyData ( import pyvista as pv
from pyvista import examples
from itkwidgets import view
vol = examples.download_knee_full()
view(image=vol, geometries=vol.contour()) This seems to only show the image data/volume and not the geometries |
@banesullivan sorry for the late follow-up -- I have just returned from the SciPy conference, and I am catching up with GitHub notifications 📚
I am glad you think so -- I would love to see good integration with PyVista!
Yes, you nailed in right on the head! 🏗️ 🚀
Awesome!! Yes, it would be very cool to have these widgets as a plotter backend for PyVista. I do not know enough about the PyVista architecture to suggest a path forward, but it is worth noting that, like K3D, these widgets are based on the ipywidgets / jupyter-widgets, but they obviously map very closely to the PyVista / VTK data and rendering model. |
Instead of
does
work? If not, I will certainly fix it :-) This would be more in line with how the ipywidgets traitlets work. |
It will be possible very soon :-). |
Thanks for the note -- #164 will track the fix for this. |
@thewtex - can I specify the name of geometry so that it's not just Geometry 0/1/2/etc.? |
@banesullivan I'm interested in your thoughts on how we can make this mesh rendering synergistic with pyvista.