Extract part of a vtkPolyData based on vertices ids

Dear All, I am currently looking for the best way to extract a subpart of a vtkPolyData from known vertices ids on this vtkPolyData.
The input of the function should be a vtkPolyData and a list of vtkIdType and the output should be a vtkPolyData corresponding to the extraction on the input vtkPolyData of the vertices corresponding to the list of vtkIdType.
After searching in the documentation, the way I do it for now is to use a vtkExtractPolyDataGeometry with a custom vtkImplicitFunction to keep only vertices that are contained into the list of vtkIdType. Then I use this pipeline : vtkExtractPolyDataGeometry => vtkConnectivityFilter => vtkDataSetSurfaceFilter => vtkClipPolyData which seems to be quite complex, long, and requires to create a vtkKdTreePointLocator onto the input vtkPolyData to implement the custom vtkImplicitFunction.

Is there a simpler way to achieve this task?
Greatly appreciate any help.

Thank you

If the point ids are in a consecutive range [pointIdMin,pointIdMax], I believe that you can use vtkGeometryFilter, set PointClippingOn, and then set the PointMinimum and PointMaximum.

You might also be able to use the filter vtkExtractSelectedIds. I haven’t used this filter in a long time, but I think it could be made to work.

1 Like

Thank you for your answer.

Unfortunately the points ids are not in a consecutive range.

I tried to use vtkExtractSelectedIds, which seems to work but the output is a vtkUnstructuredGrid. Is there any method or filter to convert a vtkUnstructuredGrid to a vtkPolyData?
I mostly used this example : https://kitware.github.io/vtk-examples/site/Cxx/PolyData/ExtractSelectedIds/

vtkGeometryFilter converts any dataset type to polydata