# cellLocator fails to find the points on the boundry

**URL:** https://discourse.vtk.org/t/celllocator-fails-to-find-the-points-on-the-boundry/9628
**Category:** Support
**Created:** [October 17, 2022, 3:18pm UTC](https://discourse.vtk.org/t/celllocator-fails-to-find-the-points-on-the-boundry/9628 "2022-10-17T15:18:29Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![1116](https://discourse.vtk.org/user_avatar/discourse.vtk.org/1116/32/1506_2.png) [@1116](https://discourse.vtk.org/u/1116)
#### Post date: [October 17, 2022, 3:18pm UTC](https://discourse.vtk.org/t/celllocator-fails-to-find-the-points-on-the-boundry/9628/1 "2022-10-17T15:18:29Z")

</div>

Hello, guys:

I have an image data shown in figure 1, and I try to use the points in this image data to do the interpolation for the the mesh in figure 2, which is an unstructured data.

 ![Figure 1](https://discourse.vtk.org/uploads/default/original/2X/c/c356d0e39a97427a8b7bd08d32891aebba3173bb.png)

 ![Figure 2](https://discourse.vtk.org/uploads/default/original/2X/6/623f930662aa0e44ebc5e870ef54a405f81eddff.png)

I try to go through each points in the figure2, and then use cell locator to find the associated cell id in figure 1. Then using the points in associated cell to compute the field value in figure 2.

However, I find that the cellLocator returns -1 for some points on the boundary (the colored points shown in figure 2), do you have more ideas or good practice to address this issue? (This is my [source code](https://github.com/wangzhezhe/UMM/blob/main/interp.cpp#L66) )

Thanks a lot for the help!

---

<div class="post-metadata">

### Author: ![oyster](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/o/a4c791/32.png) [@oyster](https://discourse.vtk.org/u/oyster)
#### Post date: [October 18, 2022, 4:24am UTC](https://discourse.vtk.org/t/celllocator-fails-to-find-the-points-on-the-boundry/9628/2 "2022-10-18T04:24:01Z")

</div>

HI, you can try vtkcelltreelocator instead.  
cheers

---

<div class="post-metadata">

### Author: ![spyridon97](https://discourse.vtk.org/user_avatar/discourse.vtk.org/spyridon97/32/7069_2.png) [@spyridon97](https://discourse.vtk.org/u/spyridon97)
#### Post date: [October 18, 2022, 4:04pm UTC](https://discourse.vtk.org/t/celllocator-fails-to-find-the-points-on-the-boundry/9628/3 "2022-10-18T16:04:37Z")

</div>

vtkImageData a structured dataset which does not need to build a cell locator to find cells because they can be acquired implicitly. You can use imageData-\>FindCell [VTK: vtkImageData Class Reference](https://vtk.org/doc/nightly/html/classvtkImageData.html#a8382eb766943949d54f52bc48b208012).

---

<div class="post-metadata">

### Author: ![1116](https://discourse.vtk.org/user_avatar/discourse.vtk.org/1116/32/1506_2.png) [@1116](https://discourse.vtk.org/u/1116)
#### Post date: [October 18, 2022, 7:50pm UTC](https://discourse.vtk.org/t/celllocator-fails-to-find-the-points-on-the-boundry/9628/4 "2022-10-18T19:50:04Z")

</div>

Hello, Spiros, good to know that, thanks a lot for the information!

---

<div class="post-metadata">

### Author: ![1116](https://discourse.vtk.org/user_avatar/discourse.vtk.org/1116/32/1506_2.png) [@1116](https://discourse.vtk.org/u/1116)
#### Post date: [October 18, 2022, 7:52pm UTC](https://discourse.vtk.org/t/celllocator-fails-to-find-the-points-on-the-boundry/9628/5 "2022-10-18T19:52:38Z")

</div>

Sure, let me try that, is it a more efficient operation compared with the vtkCellLocator?

---

<div class="post-metadata">

### Author: ![spyridon97](https://discourse.vtk.org/user_avatar/discourse.vtk.org/spyridon97/32/7069_2.png) [@spyridon97](https://discourse.vtk.org/u/spyridon97)
#### Post date: [October 18, 2022, 8:37pm UTC](https://discourse.vtk.org/t/celllocator-fails-to-find-the-points-on-the-boundry/9628/6 "2022-10-18T20:37:04Z")

</div>

Yes! It’s more efficient imageData-\>FindCell has O(1) complexity. While CellLocator-\>FindCell depends on the underlying data structure which in the best case is O(log n) for vtkCellTreeLocator.
