Area picking of points.

Hi, working on an implementation of an area picker. Currently I have the following:

std::vector<int> ActorAreaPick(vtkActor* ActorPtr, vtkPlanes* Frustrum)
   // List of sub elements picked.
   std::vector<int> PickedSubElements;

   // Reverse access polydata.
   vtkSmartPointer<vtkDataSet> PolyData = ActorPtr->GetMapper()->GetInput();

   // Clip the polydata using the frustrum.
   vtkSmartPointer<vtkClipDataSet> DataSetClipper = vtkSmartPointer<vtkClipDataSet>::New();

   // Store the clipped data.
   vtkSmartPointer<vtkUnstructuredGrid> UnstructuredGrid = DataSetClipper->GetOutput();

   for(vtkIdType PointNb = 0; PointNb < UnstructuredGrid->GetNumberOfPoints(); PointNb++)
      { PickedSubElements.emplace_back(PolyData->FindPoint(UnstructuredGrid->GetPoint(PointNb))); }
   return PickedSubElements;

This works although I’m curious if there is an easier way to get the vtkIdType’s for each point in the area. Feels slow to get the locations and then do a reverse lookup on them. Mostly built this function through various vtk examples.

Still looking into this problem, I saw that I could add arrays to the PointData. Is there a way to have that same list clipped in the same way the points are:

Set array to be {0, … MAX_NB} then have it clipped so I can know what are the original indexes in the polydata after the fact?

Currently any lists are either purged or kept intact between the clip.

I haven’t done much (if any) selection of points in VTK, but perhaps vtkSelectEnclosedPoints together with something like vtkFrustumSource might also work?

Thanks for the reply!

I tried this and it definitely works although was quite a bit slower to previous iteration of the code. It also required to be passed into a vtkDataSetSurfaceFilter (In my case I took the clipping points and passed them into a Delaunay3D first). This also seemed to miss a few points but I probably should’nt be using the clipping points since they appear to miss outline points.

My solution ended up being to add a array to the point data containing the original indexes and then setting the clipper’s InputArrayToProcess to the associated array. This has worked with no issues!