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

Method GetClosestCellId

Filters/Modeling/vtkSelectPolyData.cxx:491–522  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

489
490//------------------------------------------------------------------------------
491vtkIdType vtkSelectPolyData::GetClosestCellId(vtkPolyData* mesh, vtkIntArray* pointMarks)
492{
493 vtkPoints* inPts = mesh->GetPoints();
494 vtkIdType numPts = inPts->GetNumberOfPoints();
495
496 vtkIdType closestCellId = -1;
497 double closestDist2 = VTK_DOUBLE_MAX;
498 vtkIdType closestPointId = -1;
499 for (vtkIdType pointId = 0; pointId < numPts; pointId++)
500 {
501 double x[3];
502 inPts->GetPoint(pointId, x);
503 double dist2 = vtkMath::Distance2BetweenPoints(x, this->ClosestPoint);
504 // get closest point not on the boundary
505 if (dist2 < closestDist2 && pointMarks->GetValue(pointId) != 0)
506 {
507 closestPointId = pointId;
508 closestDist2 = dist2;
509 }
510 }
511 if (closestPointId >= 0)
512 {
513 vtkIdType ncells;
514 vtkIdType* cells;
515 mesh->GetPointCells(closestPointId, ncells, cells);
516 if (ncells > 0)
517 {
518 closestCellId = cells[0];
519 }
520 }
521 return closestCellId;
522}
523
524//------------------------------------------------------------------------------
525void vtkSelectPolyData::FillMarksInRegion(vtkPolyData* mesh, vtkIdList* edgePointIds,

Callers 1

RequestDataMethod · 0.95

Calls 5

GetPointsMethod · 0.45
GetNumberOfPointsMethod · 0.45
GetPointMethod · 0.45
GetValueMethod · 0.45
GetPointCellsMethod · 0.45

Tested by

no test coverage detected