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

Method FindClosestPointInSphere

Common/DataModel/vtkOctreePointLocator.cxx:625–673  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

623
624//------------------------------------------------------------------------------
625int vtkOctreePointLocator::FindClosestPointInSphere(
626 double x, double y, double z, double radius, int skipRegion, double& dist2)
627{
628 this->BuildLocator();
629
630 dist2 = radius * radius * 1.0001;
631 int localCloseId = -1;
632
633 std::stack<vtkOctreePointLocatorNode*> regions;
634 regions.push(this->Top);
635 while (!regions.empty())
636 {
637 vtkOctreePointLocatorNode* region = regions.top();
638 regions.pop();
639 if (region->GetChild(0))
640 {
641 for (int i = 0; i < 8; i++)
642 {
643 vtkOctreePointLocatorNode* child = region->GetChild(i);
644 // must check for leaf nodes here in case skipRegion == -1
645 // since all non-leaf nodes have Id = -1.
646 if (child->GetID() != skipRegion &&
647 (child->GetDistance2ToBoundary(x, y, z, this->Top, 1) < dist2 ||
648 child->ContainsPoint(x, y, z, 0)))
649 {
650 regions.push(child);
651 }
652 }
653 }
654 else
655 {
656 double tempDist2 = dist2;
657 int tempId = this->FindClosestPointInRegion_(region->GetID(), x, y, z, tempDist2);
658
659 if (tempDist2 < dist2)
660 {
661 dist2 = tempDist2;
662 localCloseId = tempId;
663 }
664 }
665 }
666
667 vtkIdType originalId = -1;
668 if (localCloseId >= 0 && dist2 <= radius * radius)
669 {
670 originalId = static_cast<vtkIdType>(this->LocatorIds[localCloseId]);
671 }
672 return originalId;
673}
674
675//------------------------------------------------------------------------------
676void vtkOctreePointLocator::FindPointsWithinRadius(

Callers 2

FindClosestPointMethod · 0.95

Calls 8

BuildLocatorMethod · 0.95
popMethod · 0.80
pushMethod · 0.45
emptyMethod · 0.45
GetChildMethod · 0.45
ContainsPointMethod · 0.45

Tested by

no test coverage detected