vtkImageData::FindCell returns valid cellId for outside points
This issue was created automatically from an original Mantis Issue. Further discussion may take place here.
vtkImageData::FindCell will return a valid cellId (>=0) for points that lie outside the data set bounds. This should never happen for cartesian grids. More specifically, I noticed that only points that lie outside the domain but within one spacing in either dimension are handled in this fashion. Please find attached a short test program illustrating the issue.
Looking at the code of FindCell(...) and vtkImageData::ComputeStructuredCoordinates(...) it looks like this is a combination of a truncation error when moving from physical to grid coordinates combined with an issue in the subsequent computation of the corresponding cellId.
As a short term fix, I might suggest testing the input coords against the bounds in the first place (early exit). However, I wondered why the mapping to a grid point is made in the first place, because it's pretty straightforward to compute the correct cellId from the input coords right away without referring to grid points altogether.