# Speeding up vtkCellPicker with vtkCellLocator

**URL:** https://discourse.vtk.org/t/speeding-up-vtkcellpicker-with-vtkcelllocator/4182
**Category:** Support
**Created:** [September 9, 2020, 6:28pm UTC](https://discourse.vtk.org/t/speeding-up-vtkcellpicker-with-vtkcelllocator/4182 "2020-09-09T18:28:00Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![raungst](https://discourse.vtk.org/user_avatar/discourse.vtk.org/raungst/32/1965_2.png) [@raungst](https://discourse.vtk.org/u/raungst)
#### Post date: [September 9, 2020, 6:28pm UTC](https://discourse.vtk.org/t/speeding-up-vtkcellpicker-with-vtkcelllocator/4182/1 "2020-09-09T18:28:00Z")

</div>

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](https://discourse.vtk.org/t/vtkcellpicker-very-slow/1881)

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

---

<div class="post-metadata">

### Author: ![jaswantp](https://discourse.vtk.org/user_avatar/discourse.vtk.org/jaswantp/32/10046_2.png) [@jaswantp](https://discourse.vtk.org/u/jaswantp)
#### Post date: [October 15, 2020, 6:48pm UTC](https://discourse.vtk.org/t/speeding-up-vtkcellpicker-with-vtkcelllocator/4182/2 "2020-10-15T18:48:13Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![Paulo\_Carvalho](https://discourse.vtk.org/user_avatar/discourse.vtk.org/paulo_carvalho/32/370_2.png) [@Paulo\_Carvalho](https://discourse.vtk.org/u/Paulo_Carvalho)
#### Post date: [October 15, 2020, 9:41pm UTC](https://discourse.vtk.org/t/speeding-up-vtkcellpicker-with-vtkcelllocator/4182/3 "2020-10-15T21:41:45Z")

</div>

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