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

Method FindClosestPointInRegion_

Common/DataModel/vtkOctreePointLocator.cxx:584–622  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

582
583//------------------------------------------------------------------------------
584int vtkOctreePointLocator::FindClosestPointInRegion_(
585 int leafNodeId, double x, double y, double z, double& dist2)
586{
587 int minId = 0;
588
589 float fx = static_cast<float>(x);
590 float fy = static_cast<float>(y);
591 float fz = static_cast<float>(z);
592
593 float minDistance2 = 4 * this->MaxWidth * this->MaxWidth;
594
595 int idx = this->LeafNodeList[leafNodeId]->GetMinID();
596
597 float* candidate = this->LocatorPoints + (idx * 3);
598
599 int numPoints = this->LeafNodeList[leafNodeId]->GetNumberOfPoints();
600 for (int i = 0; i < numPoints; i++)
601 {
602 float diffx = fx - candidate[0];
603 float diffy = fy - candidate[1];
604 float diffz = fz - candidate[2];
605 float dxyz = diffx * diffx + diffy * diffy + diffz * diffz;
606 if (dxyz < minDistance2)
607 {
608 minId = idx + i;
609 minDistance2 = dxyz;
610 if (dxyz == 0.0)
611 {
612 break;
613 }
614 }
615
616 candidate += 3;
617 }
618
619 dist2 = minDistance2;
620
621 return minId;
622}
623
624//------------------------------------------------------------------------------
625int vtkOctreePointLocator::FindClosestPointInSphere(

Callers 3

FindClosestPointMethod · 0.95

Calls 1

GetNumberOfPointsMethod · 0.45

Tested by

no test coverage detected