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

Method FindClosestPointWithinRadius

Common/DataModel/vtkCellLocator.cxx:319–557  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

317
318//------------------------------------------------------------------------------
319vtkIdType vtkCellLocator::FindClosestPointWithinRadius(double x[3], double radius,
320 double closestPoint[3], vtkGenericCell* cell, vtkIdType& cellId, int& subId, double& dist2,
321 int& inside)
322{
323 this->BuildLocator();
324 if (this->Tree == nullptr)
325 {
326 return 0;
327 }
328 int i;
329 vtkIdType j;
330 int tmpInside;
331 int* nei;
332 int closestSubCell = -1;
333 int leafStart;
334 int ijk[3];
335 double pcoords[3], point[3], cachedPoint[3];
336 size_t nPoints;
337 int returnVal = 0;
338 vtkIdList* cellIds;
339 std::vector<bool> cellHasBeenVisited(this->DataSet->GetNumberOfCells(), false);
340 vtkNeighborCells buckets(10);
341 std::vector<double> weights(8);
342
343 double distance2ToBucket;
344 double distance2ToCellBounds, cellBounds[6], *cellBoundsPtr, currentRadius;
345 cellBoundsPtr = cellBounds;
346 double distance2ToDataBounds, maxDistance;
347 int ii, radiusLevels[3], radiusLevel, prevMinLevel[3], prevMaxLevel[3];
348
349 cachedPoint[0] = 0.0;
350 cachedPoint[1] = 0.0;
351 cachedPoint[2] = 0.0;
352
353 leafStart = this->NumberOfOctants -
354 this->NumberOfDivisions * this->NumberOfDivisions * this->NumberOfDivisions;
355
356 // init
357 dist2 = -1.0;
358 vtkIdType closestCell = -1;
359 double radius2 = radius * radius;
360 double minDist2 = 1.1 * radius2; // something slightly bigger....
361 double refinedRadius;
362 double refinedRadius2 = radius2;
363
364 // Find bucket point is in.
365 this->GetBucketIndices(x, ijk);
366
367 // Start by searching the bucket that the point is in.
368 //
369 if ((cellIds = this->Tree[leafStart + ijk[0] + ijk[1] * this->NumberOfDivisions +
370 ijk[2] * this->NumberOfDivisions * this->NumberOfDivisions]) != nullptr)
371 {
372 // query each cell
373 for (j = 0; j < cellIds->GetNumberOfIds(); j++)
374 {
375 // get the cell
376 cellId = cellIds->GetId(j);

Callers

nothing calls this directly

Calls 15

BuildLocatorMethod · 0.95
GetBucketIndicesMethod · 0.95
Distance2ToBoundsMethod · 0.95
GetOverlappingBucketsMethod · 0.95
Distance2ToBucketMethod · 0.95
sqrtFunction · 0.50
minFunction · 0.50
maxFunction · 0.50
GetNumberOfCellsMethod · 0.45
GetNumberOfIdsMethod · 0.45
GetIdMethod · 0.45
GetCellBoundsMethod · 0.45

Tested by

no test coverage detected