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

Method FindClosestPointInRegion_

Common/DataModel/vtkKdTree.cxx:2293–2335  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

2291
2292//------------------------------------------------------------------------------
2293int vtkKdTree::FindClosestPointInRegion_(int regionId, double x, double y, double z, double& dist2)
2294{
2295 int minId = 0;
2296
2297 double minDistance2 = 4 * this->MaxWidth * this->MaxWidth;
2298
2299 int idx = this->LocatorRegionLocation[regionId];
2300
2301 float* candidate = this->LocatorPoints + (idx * 3);
2302
2303 int numPoints = this->RegionList[regionId]->GetNumberOfPoints();
2304 for (int i = 0; i < numPoints; i++)
2305 {
2306 double dx = (x - candidate[0]) * (x - candidate[0]);
2307
2308 if (dx < minDistance2)
2309 {
2310 double dxy = dx + ((y - candidate[1]) * (y - candidate[1]));
2311
2312 if (dxy < minDistance2)
2313 {
2314 double dxyz = dxy + ((z - candidate[2]) * (z - candidate[2]));
2315
2316 if (dxyz < minDistance2)
2317 {
2318 minId = idx + i;
2319 minDistance2 = dxyz;
2320
2321 if (dxyz == 0.0)
2322 {
2323 break;
2324 }
2325 }
2326 }
2327 }
2328
2329 candidate += 3;
2330 }
2331
2332 dist2 = minDistance2;
2333
2334 return minId;
2335}
2336
2337//------------------------------------------------------------------------------
2338int vtkKdTree::FindClosestPointInSphere(

Callers 3

FindClosestPointMethod · 0.95

Calls 1

GetNumberOfPointsMethod · 0.45

Tested by

no test coverage detected