------------------------------------------------------------------------------
| 274 | |
| 275 | //------------------------------------------------------------------------------ |
| 276 | vtkIdType vtkClosestPointStrategy::FindClosestPointWithinRadius(double x[3], double radius, |
| 277 | double closestPoint[3], vtkGenericCell* genCell, vtkIdType& closestCellId, int& closestSubId, |
| 278 | double& minDist2, int& inside) |
| 279 | { |
| 280 | // the implementation of this function is a copy of an old approach in |
| 281 | // vtkAbstractInterpolatedVelocityField, check git history for more info |
| 282 | // in the future something better could be implemented |
| 283 | vtkIdType retVal = 0; |
| 284 | |
| 285 | // find the point closest to the coordinates |
| 286 | // given and search the attached cells. |
| 287 | vtkIdType ptId = this->PointLocator->FindClosestPoint(x); |
| 288 | if (ptId < 0) |
| 289 | { |
| 290 | return retVal; |
| 291 | } |
| 292 | // find the cells adjacent to the closest point |
| 293 | this->PointSet->GetPointCells(ptId, this->CellIds); |
| 294 | double point[3], pcoords[3], dist2, closestPcoords[3]; |
| 295 | int subId, stat; |
| 296 | vtkIdType cellId; |
| 297 | closestSubId = -1; |
| 298 | closestCellId = -1; |
| 299 | minDist2 = this->PointSet->GetLength2(); |
| 300 | // find the closest adjacent cell |
| 301 | for (vtkIdType id = 0, max = this->CellIds->GetNumberOfIds(); id < max; ++id) |
| 302 | { |
| 303 | cellId = this->CellIds->GetId(id); |
| 304 | this->PointSet->GetCell(cellId, genCell); |
| 305 | if (this->Weights.size() < static_cast<size_t>(genCell->GetNumberOfPoints())) |
| 306 | { |
| 307 | this->Weights.resize(static_cast<size_t>(genCell->GetNumberOfPoints())); |
| 308 | } |
| 309 | stat = genCell->EvaluatePosition(x, point, subId, pcoords, dist2, this->Weights.data()); |
| 310 | if (stat != -1 && dist2 < minDist2) |
| 311 | { |
| 312 | retVal = 1; |
| 313 | inside = stat; |
| 314 | minDist2 = dist2; |
| 315 | closestCellId = cellId; |
| 316 | closestSubId = subId; |
| 317 | closestPoint[0] = point[0]; |
| 318 | closestPoint[1] = point[1]; |
| 319 | closestPoint[2] = point[2]; |
| 320 | closestPcoords[0] = pcoords[0]; |
| 321 | closestPcoords[1] = pcoords[1]; |
| 322 | closestPcoords[2] = pcoords[2]; |
| 323 | } |
| 324 | } |
| 325 | if (closestCellId == -1) |
| 326 | { |
| 327 | return retVal; |
| 328 | } |
| 329 | // Recover the closest cell |
| 330 | this->PointSet->GetCell(closestCellId, genCell); |
| 331 | // get the boundary point ids closest to the parametric coordinates |
| 332 | genCell->CellBoundary(closestSubId, closestPcoords, this->PointIds); |
| 333 | // get the neighbors cells of the boundary points |
nothing calls this directly
no test coverage detected