How to access original point IDs after subset extraction with vtkExtractPolyDataGeometry?

I’m using VTK 9.3 for my C++ application.
I use vtkInteractorStyleRubberBandPick and vtkExtractPolyDataGeometry to select a vtkPolyData subset of a full vtkPolyData object. How can I find each selected subset point in the full data? Each point in the subset has point ID starting from 0. How do I find the point ID of each subset point in the full data? Claude.ai claims that “vtkExtractPolyDataGeometry` automatically creates point and cell data arrays that store the original IDs” and suggests I retrieve them as follows:

// Enable pass-through of original pointIDs
extractor->SetPassThroughPointIds(true);

// Get the original point IDs
vtkIdTypeArray* originalPointIds = vtkIdTypeArray::SafeDownCast(
    extractedData->GetPointData()->GetArray("vtkOriginalPointIds"));

However the compiler says that vtkExtractPolyDataGeometry has no member named ‘SetPassThroughPointIds’. If I remove that line and run the code, originalPointIds returned by GetArray(“vtkOriginalPointIds”) is null.

What is the proper way to access the original point IDs?
Thanks!

Hello,

AI is not a reliable surce of information. According to the official docs, vtkExtractPolyDataGeometry doesn’t have that method. However, vtkGeometryFilter does. See: VTK: vtkExtractPolyDataGeometry Class Reference and VTK: vtkGeometryFilter Class Reference . Perhaps you could try the latter.

best,

PC

Most filters can pass through point data. Therefore, if you want to access original point IDs in the output of a filter (that does not already have a built-in option for providing pedigree IDs), then a simple solution is to store the point IDs in a point data array. You can achieve this by inserting a vtkIdFilter before the processing filter. Same works for cell IDs.