Hello, I have some opinions about the wrong choice:
I read the source code of PyVista about Cell selection. The problem of cell selection disorder should be related to the use of HardwareSelector instead of graphics card. For example, in vtk8.2, when selecting a cell from a hexahedral UnstructuredGrid, you should get its id, construct vtkExtractGeometry by cell id, and finally create a vtkActor to represent the selection effect. In fact, the cell id selected by HardwareSelector is converted from UnstructuredGrid to PolyData At this time, a face of a hexahedron has an id, and the id does not correspond to the cell id in the original UnstructuredGrid. Finally, the vtkExtractGeometry is then used to construct the Actor, which will cause confusion. Now I haven’t solved this problem either, you can see this problem:
def visible_pick_call_back(picker, event_id):
x0,y0,x1,y1 = self.get_pick_position()
selector = vtk.vtkOpenGLHardwareSelector()
selector.SetFieldAssociation(vtk.vtkDataObject.FIELD_ASSOCIATION_CELLS)
selector.SetRenderer(self.renderer)
selector.SetArea(x0,y0,x1,y1)
cellids = selector.Select().GetNode(0) ######This cell id is wrong, it comes from polydata converted from unstructuredGrid
if cellids is None:
# No selection
return
selection = vtk.vtkSelection()
selection.AddNode(cellids)
extract = vtk.vtkExtractSelectedIds()
extract.SetInputData(0, mesh)
extract.SetInputData(1, selection)
extract.Update()
self.picked_cells = pyvista.wrap(extract.GetOutput())
return end_pick_helper(picker, event_id)