cellLocator fails to find the points on the boundry

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.

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 )

Thanks a lot for the help!

HI, you can try vtkcelltreelocator instead.
cheers

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.

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

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

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.