------------------------------------------------------------------------------
| 792 | |
| 793 | //------------------------------------------------------------------------------ |
| 794 | void vtkOctreePointLocator::FindClosestNPoints(int N, const double x[3], vtkIdList* result) |
| 795 | { |
| 796 | result->Reset(); |
| 797 | if (N <= 0) |
| 798 | { |
| 799 | return; |
| 800 | } |
| 801 | this->BuildLocator(); |
| 802 | |
| 803 | int numTotalPoints = this->Top->GetNumberOfPoints(); |
| 804 | if (numTotalPoints < N) |
| 805 | { |
| 806 | vtkWarningMacro( |
| 807 | "Number of requested points is greater than total number of points in OctreePointLocator"); |
| 808 | N = numTotalPoints; |
| 809 | } |
| 810 | result->SetNumberOfIds(N); |
| 811 | |
| 812 | // now we want to go about finding a region that contains at least N points |
| 813 | // but not many more -- hopefully the region contains X as well but we |
| 814 | // can't depend on that |
| 815 | vtkOctreePointLocatorNode* node = this->Top; |
| 816 | vtkOctreePointLocatorNode* startingNode = nullptr; |
| 817 | if (!node->ContainsPoint(x[0], x[1], x[2], 0)) |
| 818 | { |
| 819 | // point is not in the region |
| 820 | int numPoints = node->GetNumberOfPoints(); |
| 821 | vtkOctreePointLocatorNode* prevNode = node; |
| 822 | while (node->GetChild(0) && numPoints > N) |
| 823 | { |
| 824 | prevNode = node; |
| 825 | vtkOctreePointLocatorNode* nextNode = node->GetChild(0); |
| 826 | double minDist2 = nextNode->GetDistance2ToBoundary(x[0], x[1], x[2], this->Top, 1); |
| 827 | for (int i = 1; i < 8; i++) |
| 828 | { |
| 829 | double dist2 = node->GetChild(i)->GetDistance2ToBoundary(x[0], x[1], x[2], this->Top, 1); |
| 830 | if (dist2 < minDist2) |
| 831 | { |
| 832 | nextNode = node->GetChild(i); |
| 833 | minDist2 = dist2; |
| 834 | } |
| 835 | } |
| 836 | node = nextNode; |
| 837 | numPoints = node->GetNumberOfPoints(); |
| 838 | } |
| 839 | if (numPoints < N) |
| 840 | { |
| 841 | startingNode = prevNode; |
| 842 | } |
| 843 | else |
| 844 | { |
| 845 | startingNode = node; |
| 846 | } |
| 847 | } |
| 848 | else |
| 849 | { |
| 850 | int numPoints = node->GetNumberOfPoints(); |
| 851 | vtkOctreePointLocatorNode* prevNode = node; |
nothing calls this directly
no test coverage detected