Merge topic 'locate-points-on-boundary'

461f87dbc Fix issues with PointLocatorUniformGrid not finding all points
e473cb4bb Fix PointLocatorUniformGrid for points on boundary

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: Li-Ta Lo <ollie@lanl.gov>
Merge-request: !1720
This commit is contained in:
Li-Ta Lo 2019-07-11 14:48:18 +00:00 committed by Kitware Robot
commit 2c6061d37f
3 changed files with 30 additions and 3 deletions

@ -48,6 +48,8 @@ public:
VTKM_EXEC void operator()(const CoordVecType& coord, IdType& label) const
{
vtkm::Vec<vtkm::Id, 3> ijk = (coord - Min) / Dxdydz;
ijk = vtkm::Max(ijk, vtkm::Id3(0));
ijk = vtkm::Min(ijk, this->Dims - vtkm::Id3(1));
label = ijk[0] + ijk[1] * Dims[0] + ijk[2] * Dims[0] * Dims[1];
}

@ -108,6 +108,16 @@ public:
{
coordi.push_back(vtkm::make_Vec(dr(dre), dr(dre), dr(dre)));
}
// Add a point to each corner to test the case where points might slip out
// of the range by epsilon
coordi.push_back(vtkm::make_Vec(00.0f, 00.0f, 00.0f));
coordi.push_back(vtkm::make_Vec(00.0f, 10.0f, 00.0f));
coordi.push_back(vtkm::make_Vec(10.0f, 00.0f, 00.0f));
coordi.push_back(vtkm::make_Vec(10.0f, 10.0f, 00.0f));
coordi.push_back(vtkm::make_Vec(00.0f, 00.0f, 10.0f));
coordi.push_back(vtkm::make_Vec(00.0f, 10.0f, 10.0f));
coordi.push_back(vtkm::make_Vec(10.0f, 00.0f, 10.0f));
coordi.push_back(vtkm::make_Vec(10.0f, 10.0f, 10.0f));
auto coordi_Handle = vtkm::cont::make_ArrayHandle(coordi);
vtkm::cont::CoordinateSystem coord("points", coordi_Handle);
@ -126,6 +136,15 @@ public:
{
qcVec.push_back(vtkm::make_Vec(dr(dre), dr(dre), dr(dre)));
}
// Test near each corner to make sure that corner gets included
qcVec.push_back(vtkm::make_Vec(0.01f, 0.01f, 0.01f));
qcVec.push_back(vtkm::make_Vec(0.01f, 9.99f, 0.01f));
qcVec.push_back(vtkm::make_Vec(9.99f, 0.01f, 0.01f));
qcVec.push_back(vtkm::make_Vec(9.99f, 9.99f, 0.01f));
qcVec.push_back(vtkm::make_Vec(0.01f, 0.01f, 9.991f));
qcVec.push_back(vtkm::make_Vec(0.01f, 9.99f, 9.99f));
qcVec.push_back(vtkm::make_Vec(9.99f, 0.01f, 9.99f));
qcVec.push_back(vtkm::make_Vec(9.99f, 9.99f, 9.99f));
auto qc_Handle = vtkm::cont::make_ArrayHandle(qcVec);
vtkm::cont::ArrayHandle<vtkm::Id> nnId_Handle;

@ -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);
}
}