MCPcopy Create free account
hub / github.com/Kitware/VTK / FindCell

Method FindCell

Common/DataModel/vtkClosestPointStrategy.cxx:200–273  ·  view source on GitHub ↗

------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

198
199//------------------------------------------------------------------------------
200vtkIdType vtkClosestPointStrategy::FindCell(double x[3], vtkCell* cell, vtkGenericCell* gencell,
201 vtkIdType cellId, double tol2, int& subId, double pcoords[3], double* weights)
202{
203 // Check to see if the point is within the bounds of the data. This is not
204 // a strict check, but it is fast.
205 const double* bounds = this->Bounds;
206 const double tol = std::sqrt(tol2);
207 if ((x[0] < bounds[0] - tol) || (x[0] > bounds[1] + tol) || (x[1] < bounds[2] - tol) ||
208 (x[1] > bounds[3] + tol) || (x[2] < bounds[4] - tol) || (x[2] > bounds[5] + tol))
209 {
210 return -1;
211 }
212
213 // reset the visited cells
214 for (vtkIdType i = 0, max = this->VisitedCellIds->GetNumberOfIds(); i < max; ++i)
215 {
216 this->VisitedCells[this->VisitedCellIds->GetId(i)] = false;
217 }
218 this->VisitedCellIds->Reset();
219
220 // If we are given a starting cell, try that.
221 vtkIdType foundCell;
222 if (cell && (cellId >= 0))
223 {
224 foundCell = FindCellWalk(this, this->PointSet, x, cell, gencell, cellId, tol2, subId, pcoords,
225 weights, this->VisitedCells, this->VisitedCellIds, this->PointIds, this->Neighbors);
226 if (foundCell >= 0)
227 {
228 return foundCell;
229 }
230 }
231
232 // The starting cell didn't work, find the point closest to the coordinates
233 // given and search the attached cells.
234 vtkIdType ptId = this->PointLocator->FindClosestPoint(x);
235 if (ptId < 0)
236 {
237 return -1;
238 }
239 this->PointSet->GetPointCells(ptId, this->CellIds);
240 foundCell = FindCellWalk(this, this->PointSet, x, gencell, this->CellIds, tol2, subId, pcoords,
241 weights, this->VisitedCells, this->VisitedCellIds, this->PointIds, this->Neighbors);
242 if (foundCell >= 0)
243 {
244 return foundCell;
245 }
246
247 // It is possible that the topology is not fully connected as points may be
248 // coincident. Handle this by looking at every point within the tolerance
249 // and consider all cells connected. It has been suggested that we should
250 // really do this coincident point check at every point as we walk through
251 // neighbors, which would happen in FindCellWalk. If that were ever
252 // implemented, this step might become unnecessary.
253 double ptCoord[3];
254 this->PointSet->GetPoint(ptId, ptCoord);
255 this->PointLocator->FindPointsWithinRadius(tol, ptCoord, this->NearPointIds);
256 this->NearPointIds->DeleteId(ptId); // Already searched this one.
257 for (vtkIdType i = 0, numPts = this->NearPointIds->GetNumberOfIds(); i < numPts; i++)

Callers

nothing calls this directly

Calls 10

FindCellWalkFunction · 0.85
sqrtFunction · 0.50
GetNumberOfIdsMethod · 0.45
GetIdMethod · 0.45
ResetMethod · 0.45
FindClosestPointMethod · 0.45
GetPointCellsMethod · 0.45
GetPointMethod · 0.45
DeleteIdMethod · 0.45

Tested by

no test coverage detected