Beispiel #1
0
 def visible_pick_call_back(picker, event_id):
     x0, y0, x1, y1 = renderer_().get_pick_position()
     selector = vtk.vtkOpenGLHardwareSelector()
     selector.SetFieldAssociation(
         vtk.vtkDataObject.FIELD_ASSOCIATION_CELLS)
     selector.SetRenderer(renderer_())
     selector.SetArea(x0, y0, x1, y1)
     selection = selector.Select()
     picked = pyvista.MultiBlock()
     for node in range(selection.GetNumberOfNodes()):
         selection_node = selection.GetNode(node)
         if selection_node is None:
             # No selection
             continue
         cids = pyvista.convert_array(selection_node.GetSelectionList())
         actor = selection_node.GetProperties().Get(
             vtk.vtkSelectionNode.PROP())
         if actor.GetProperty().GetRepresentation() != 2:  # surface
             logging.warning(
                 "Display representations other than `surface` will result in incorrect results."
             )
         smesh = actor.GetMapper().GetInputAsDataSet()
         smesh = smesh.copy()
         smesh["original_cell_ids"] = np.arange(smesh.n_cells)
         tri_smesh = smesh.extract_surface().triangulate()
         cids_to_get = tri_smesh.extract_cells(
             cids)["original_cell_ids"]
         picked.append(smesh.extract_cells(cids_to_get))
     if len(picked) == 1:
         self_().picked_cells = picked[0]
     else:
         self_().picked_cells = picked
     return end_pick_helper(picker, event_id)
Beispiel #2
0
 def visible_pick_call_back(picker, event_id):
     x0, y0, x1, y1 = renderer.get_pick_position()
     selector = vtk.vtkOpenGLHardwareSelector()
     selector.SetFieldAssociation(
         vtk.vtkDataObject.FIELD_ASSOCIATION_CELLS)
     selector.SetRenderer(renderer)
     selector.SetArea(x0, y0, x1, y1)
     selection = selector.Select()
     picked = pyvista.MultiBlock()
     for node in range(selection.GetNumberOfNodes()):
         cellids = selection.GetNode(node)
         if cellids is None:
             # No selection
             continue
         smesh = cellids.GetProperties().Get(vtk.vtkSelectionNode.PROP(
         )).GetMapper().GetInputAsDataSet()
         selection_filter = vtk.vtkSelection()
         selection_filter.AddNode(cellids)
         extract = vtk.vtkExtractSelectedIds()
         extract.SetInputData(0, smesh)
         extract.SetInputData(1, selection_filter)
         extract.Update()
         picked.append(pyvista.wrap(extract.GetOutput()))
     if len(picked) == 1:
         self.picked_cells = picked[0]
     else:
         self.picked_cells = picked
     return end_pick_helper(picker, event_id)
Beispiel #3
0
 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)
     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)