Speeding up vtkCellPicker with vtkCellLocator

I’ve been trying to speed up vtkCellPicker with my large data set (1M cells). I’ve followed other examples to add a vtkCellLocator to the vtkCellPicker to improve performance. Unfortunately, I don’t see any improvement when I do this. I’ve followed the example here: vtkCellPicker very slow

Creating cell locator:

    self.locator = vtkCellLocator()
    self.locator.SetDataSet(femobj.getMesh())  #  unstructured grid
    self.locator.BuildLocator()

    self.picker = vtkCellPicker()
    self.picker.AddLocator(self.locator)

Getting pick:

    clickPos = self.parent.getRenderWindowInteractor().GetEventPosition()
    self.parent.picker.Pick(clickPos[0], clickPos[1], 0, self.parent.getRenderer())
    print(self.parent.picker.GetCellId())

The process seems straight forward and is advertised to make the picking faster, I just haven’t been able to see it happen. Is there something obviously wrong here?

Thanks!
Robby

1 Like

Might not make a difference but did you try self.locator.Update() before adding it to picker? The link you shared mentions it but I don’t think it should affect this as your dataset doesn’t change.

Your code doesn’t seem wrong to me. I also get slow picking response with million-cell grids.