10 #ifndef vtk_m_exec_PointLocatorSparseGrid_h
11 #define vtk_m_exec_PointLocatorSparseGrid_h
26 typename vtkm::cont::CoordinateSystem::MultiplexerArrayType::ReadPortalType;
39 , Dxdydz((max - Min) / Dims)
42 , CellLower(cellLower)
43 , CellUpper(cellUpper)
62 vtkm::Id3 ijk = (queryPoint - this->Min) / this->Dxdydz;
64 ijk = vtkm::Min(ijk, this->Dims -
vtkm::Id3(1));
66 nearestNeighborId = -1;
67 distance2 = vtkm::Infinity<vtkm::FloatDefault>();
69 this->FindInCell(queryPoint, ijk, nearestNeighborId, distance2);
72 vtkm::Id maxLevel = vtkm::Max(vtkm::Max(this->Dims[0], this->Dims[1]), this->Dims[2]);
74 for (level = 1; (nearestNeighborId < 0) && (level < maxLevel); ++level)
76 this->FindInBox(queryPoint, ijk, level, nearestNeighborId, distance2);
82 this->FindInBox(queryPoint, ijk, level, nearestNeighborId, distance2);
101 vtkm::Id cellId = ijk[0] + (ijk[1] * this->Dims[0]) + (ijk[2] * this->Dims[0] * this->Dims[1]);
102 vtkm::Id lower = this->CellLower.Get(cellId);
103 vtkm::Id upper = this->CellUpper.Get(cellId);
104 for (
vtkm::Id index = lower; index < upper; index++)
106 vtkm::Id pointid = this->PointIds.Get(index);
109 if (distance2 < nearestDistance2)
111 nearestNeighborId = pointid;
112 nearestDistance2 = distance2;
123 if ((boxCenter[0] - level) >= 0)
126 queryPoint, boxCenter -
vtkm::Id3(level, 0, 0), level, nearestNeighborId, nearestDistance2);
128 if ((boxCenter[0] + level) < this->Dims[0])
131 queryPoint, boxCenter +
vtkm::Id3(level, 0, 0), level, nearestNeighborId, nearestDistance2);
134 if ((boxCenter[1] - level) >= 0)
137 queryPoint, boxCenter -
vtkm::Id3(0, level, 0), level, nearestNeighborId, nearestDistance2);
139 if ((boxCenter[1] + level) < this->Dims[1])
142 queryPoint, boxCenter +
vtkm::Id3(0, level, 0), level, nearestNeighborId, nearestDistance2);
145 if ((boxCenter[2] - level) >= 0)
148 queryPoint, boxCenter -
vtkm::Id3(0, 0, level), level, nearestNeighborId, nearestDistance2);
150 if ((boxCenter[2] + level) < this->Dims[2])
153 queryPoint, boxCenter +
vtkm::Id3(0, 0, level), level, nearestNeighborId, nearestDistance2);
166 for (
vtkm::Id index = 0; index < numInPlane; ++index)
169 vtkm::Id3(index % mod[0], index % mod[1], index % mod[2]) + origin;
170 if ((ijk[0] >= 0) && (ijk[0] < this->Dims[0]) && (ijk[1] >= 0) && (ijk[1] < this->Dims[1]) &&
171 (ijk[2] >= 0) && (ijk[2] < this->Dims[2]))
173 this->FindInCell(queryPoint, ijk, nearestNeighborId, nearestDistance2);
186 vtkm::Id3 div = { yWidth * zWidth, yWidth * zWidth, yWidth };
188 vtkm::Id3 origin = { 0, -level, -level };
189 vtkm::Id numInPlane = yWidth * zWidth;
191 queryPoint, planeCenter, div, mod, origin, numInPlane, nearestNeighborId, nearestDistance2);
202 vtkm::Id3 div = { xWidth * zWidth, xWidth * zWidth, xWidth };
204 vtkm::Id3 origin = { -level + 1, 0, -level };
205 vtkm::Id numInPlane = xWidth * zWidth;
207 queryPoint, planeCenter, div, mod, origin, numInPlane, nearestNeighborId, nearestDistance2);
218 vtkm::Id3 div = { xWidth * yWidth, xWidth, xWidth * yWidth };
220 vtkm::Id3 origin = { -level + 1, -level + 1, 0 };
221 vtkm::Id numInPlane = xWidth * yWidth;
223 queryPoint, planeCenter, div, mod, origin, numInPlane, nearestNeighborId, nearestDistance2);
230 #endif // vtk_m_exec_PointLocatorSparseGrid_h