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

Method FindCell

Common/DataModel/vtkClosestNPointsStrategy.cxx:29–77  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

27
28//------------------------------------------------------------------------------
29vtkIdType vtkClosestNPointsStrategy::FindCell(double x[3], vtkCell* cell, vtkGenericCell* gencell,
30 vtkIdType cellId, double tol2, int& subId, double pcoords[3], double* weights)
31{
32 // First try standard strategy which is reasonably fast
33 vtkIdType foundCell =
34 this->Superclass::FindCell(x, cell, gencell, cellId, tol2, subId, pcoords, weights);
35 if (foundCell >= 0)
36 {
37 return foundCell;
38 }
39
40 // Couldn't find anything so try more time consuming strategy. It is
41 // possible that the closest point is not part of a cell containing the
42 // query point (i.e., a hanging node situation). In this case, look for the
43 // N closest points (beyond any coincident points identified
44 // previously). Typically N=9 (somewhat arbitrary, empirical, based on 2:1
45 // subdivision of hexahedral cells). Using large N affects performance but
46 // produces better results.
47 vtkIdType numPts = this->NearPointIds->GetNumberOfIds();
48 this->PointLocator->FindClosestNPoints(numPts + this->ClosestNPoints, x, this->NearPointIds);
49 numPts = this->NearPointIds->GetNumberOfIds();
50
51 vtkIdType i, j, ptId, numCells;
52 int ret;
53 double closest[3], dist2;
54 for (i = 0; i < numPts; ++i)
55 {
56 ptId = this->NearPointIds->GetId(i);
57 this->PointSet->GetPointCells(ptId, this->CellIds);
58 numCells = this->CellIds->GetNumberOfIds();
59 for (j = 0; j < numCells; j++)
60 {
61 cellId = this->CellIds->GetId(j);
62 if (!this->VisitedCells[cellId])
63 {
64 cell = this->SelectCell(this->PointSet, cellId, nullptr, gencell);
65 ret = cell->EvaluatePosition(x, closest, subId, pcoords, dist2, weights);
66 if (ret != -1 && dist2 <= tol2)
67 {
68 return cellId;
69 }
70 this->VisitedCells[cellId] = true;
71 this->VisitedCellIds->InsertNextId(cellId);
72 }
73 }
74 }
75
76 return -1;
77}
78
79//------------------------------------------------------------------------------
80void vtkClosestNPointsStrategy::CopyParameters(vtkFindCellStrategy* from)

Callers

nothing calls this directly

Calls 7

SelectCellMethod · 0.80
InsertNextIdMethod · 0.80
GetNumberOfIdsMethod · 0.45
FindClosestNPointsMethod · 0.45
GetIdMethod · 0.45
GetPointCellsMethod · 0.45
EvaluatePositionMethod · 0.45

Tested by

no test coverage detected