Hello, I would like to get a numpy array of integer indices or a numpy boolean mask from a vtkSelection object in Python :
def get_visible_vertices(plotter, pv_mesh):
# perfrom the automatic picking
selector = vtk.vtkOpenGLHardwareSelector()
selector.SetFieldAssociation(vtk.vtkDataObject.FIELD_ASSOCIATION_POINTS)
selector.SetRenderer(plotter.renderer)
selector.SetArea(0,0,plotter.window_size[0],plotter.window_size[1])
selection = selector.Select()
# mask = selection.ExtractBooleanMask() <- How to do this ?
# vertex_indices = selection.ExtractVertexIndices() <- or this ?
plotter
is a an object from Pyvista which is a wrapper around vtk render as far as I understand. pv_mesh
is a PolyData
from Pyvista which should be a wrapper around vtk’s PolyData
The c++ documentation seems overwhelming to me I do not know where to start, sorry.
Thanks
PS : I know that the vtkSelection I get is “correct” because I can plot it with the following code :
extractor = vtk.vtkExtractSelection()
extractor.SetInputData(0, pv_mesh)
extractor.SetInputData(1, selection)
extractor.Update()
pv.wrap(extractor.GetOutput()).plot()
And i get this plot which is coherent (the red drawings represents the camera when selecting the visible vertices):