Fix issues with PointLocatorUniformGrid not finding all points

There was a known issue where PointLocatorUniformGrid would quickly quit
once it found a point. Instead, look at one more level of bins just in
case there is a closer one near the boundary. (Still not guaranteed, but
likely.)

Also, fix a typo that caused some bins in the y and z direction to not
be searched.
This commit is contained in:
Kenneth Moreland 2019-07-10 09:52:49 -06:00
parent e473cb4bbc
commit 461f87dbc8

@ -80,10 +80,16 @@ public:
// TODO: This might stop looking before the absolute nearest neighbor is found.
vtkm::Id maxLevel = vtkm::Max(vtkm::Max(this->Dims[0], this->Dims[1]), this->Dims[2]);
for (vtkm::Id level = 1; (nearestNeighborId < 0) && (level < maxLevel); ++level)
vtkm::Id level;
for (level = 1; (nearestNeighborId < 0) && (level < maxLevel); ++level)
{
this->FindInBox(queryPoint, ijk, level, nearestNeighborId, distance2);
}
// Search one more level out. This is still not guaranteed to find the closest point
// in all cases (past level 2), but it will catch most cases where the closest point
// is just on the other side of a cell boundary.
this->FindInBox(queryPoint, ijk, level, nearestNeighborId, distance2);
}
private:
@ -143,7 +149,7 @@ private:
if ((boxCenter[1] + level) < this->Dims[1])
{
this->FindInYPlane(
queryPoint, boxCenter - vtkm::Id3(0, level, 0), level, nearestNeighborId, nearestDistance2);
queryPoint, boxCenter + vtkm::Id3(0, level, 0), level, nearestNeighborId, nearestDistance2);
}
if ((boxCenter[2] - level) >= 0)
@ -154,7 +160,7 @@ private:
if ((boxCenter[2] + level) < this->Dims[2])
{
this->FindInZPlane(
queryPoint, boxCenter - vtkm::Id3(0, 0, level), level, nearestNeighborId, nearestDistance2);
queryPoint, boxCenter + vtkm::Id3(0, 0, level), level, nearestNeighborId, nearestDistance2);
}
}