Skip to content

Fix visible cell picking#799

Merged
banesullivan merged 2 commits intomasterfrom
fix/visible-cell-picking
Jun 14, 2020
Merged

Fix visible cell picking#799
banesullivan merged 2 commits intomasterfrom
fix/visible-cell-picking

Conversation

@banesullivan
Copy link
Copy Markdown
Member

Overview

This fixes all the issues we were having with visible cell picking 🎉

resolves pyvista/pyvista-support#177

Details

In summary: vtkSelectionNode was giving us the cell IDs after running a vtkDataSetSurfaceFilter and a vtkTriangleFilter. So we have to mimic that pipeline to map the selected cells back to the original mesh. Easy-peasy once I thought about it a little bit...

An important note... the representation style MUST be surface!!!!!!!!!! Using wireframe or points will break this pipeline. I added a warning for this.

@banesullivan
Copy link
Copy Markdown
Member Author

import pyvista as pv

def picked_cells(subgrid):
    pass

grid = pv.UniformGrid((10, 20, 5))

plotter = pv.Plotter(notebook=False)
plotter.add_mesh(grid, show_edges=True, style="surface")
plotter.enable_cell_picking(callback=picked_cells, through=False)
plotter.show()

2020-06-13 15 00 56

@banesullivan
Copy link
Copy Markdown
Member Author

FYI I took out the warnings about non-NVIDIA GPUs because I don't think that is relevant anymore. Also, I was testing this on a Radeon GPU and it worked beautifully.

@banesullivan
Copy link
Copy Markdown
Member Author

@akaszynski, I'm thinking we should cherrypick this onto the release branch if testing comes back good (from you and/or @rodrigomologni locally, please???)

@akaszynski
Copy link
Copy Markdown
Member

All for cherrypicking this and pushing a patch release. We need to add in the sdist patch as well. Would you like to make a PR containing this and the sdist commit?

Copy link
Copy Markdown
Member

@akaszynski akaszynski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not intuitive that you had to generate a surface mesh and triangulate it. Nice job for figuring it out!

@banesullivan banesullivan merged commit d7c88db into master Jun 14, 2020
@rodrigomologni
Copy link
Copy Markdown
Member

@banesullivan, sorry for the delay. I was offline for a few days. I ran the code with your changes in Windows 10 with AMD Radeon and NVIDIA too. The bug was fixed in both. Thank you! :-)

@rodrigomologni
Copy link
Copy Markdown
Member

@banesullivan, your bug fix is not working in VTK 8.2.1. Nothing happens when I to press R or P. I tested only in AMD Radeon. :-(

@banesullivan
Copy link
Copy Markdown
Member Author

Ugh, thanks for reporting that... and good thing we didn't ship it yet

@banesullivan
Copy link
Copy Markdown
Member Author

@rodrigomologni, I was able to confirm this... it appears to me this is a bug with vtkOpenGLHardwareSelector/vtkHardwareSelector on VTK version 8.1.2. The selector is not working/returning anything so I'm afraid we'll just have to not support visible cell picking with 8.1.2

@banesullivan
Copy link
Copy Markdown
Member Author

In the release notes for VTK8.2, it mentions how the hardware selector was massively reworked/improved. It seems we are using the API for those improvements... I can try to make this backward compatible but no guarantees

@banesullivan
Copy link
Copy Markdown
Member Author

Yeah.... it looks complicated. need to set up the mappers constantly sync their data to the GPU I think. This seems like a big task for backward compat... maybe you can use a more up to date version of VTK? 😉

@rodrigomologni
Copy link
Copy Markdown
Member

rodrigomologni commented Jun 20, 2020

@banesullivan all right! Let's think about the future. VTK 9 is the future! I'm already using VTK 9. 😉

@banesullivan banesullivan deleted the fix/visible-cell-picking branch July 22, 2020 02:24
@akaszynski akaszynski mentioned this pull request Sep 8, 2020
@banesullivan banesullivan added the bug Uh-oh! Something isn't working as expected. label Feb 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Uh-oh! Something isn't working as expected.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

How to pick a single grid cell under the mouse location?

3 participants