| 860 | // of the circles. |
| 861 | template <typename TIds> |
| 862 | double BucketList2D<TIds>::FindNPointsInAnnulus(int N, const double x[3], |
| 863 | vtkDist2TupleArray& results, double minR2, bool sort, vtkDoubleArray* circles) |
| 864 | { |
| 865 | // Clear out any previous results |
| 866 | results.clear(); |
| 867 | |
| 868 | // Find the bucket the point is in. This is the center of the request |
| 869 | // footprint. |
| 870 | int center[2]; |
| 871 | this->GetBucketIndices(x, center); |
| 872 | |
| 873 | // Traverse and gather points in the bucket/bins contained in the annulus |
| 874 | // request. We hold the information in the results vector. |
| 875 | double minR = sqrt(minR2); |
| 876 | double maxR = 0, maxR2 = 0; |
| 877 | |
| 878 | // Determine absolue limits of iteration (based on possible number of points). |
| 879 | vtkIdType numPts = this->DataSet->GetNumberOfPoints(); |
| 880 | N = (numPts < N ? numPts : N); |
| 881 | |
| 882 | // Gather N points if possible and determine maxR2. Make sure all points |
| 883 | // within maxR2 have been found. We use a annulus iterator to grow a |
| 884 | // "rectangular" annulus from the center bin. Skip over bins inside the |
| 885 | // inner radius minR2. The bin index is updated during iteration, binIdx<0 |
| 886 | // is returned when the iteration is exhausted. |
| 887 | vtkIdType binIdx; |
| 888 | int currentLevel = (minR <= 0 ? 0 : static_cast<int>(std::floor(minR / (2.0 * this->BinRadius)))); |
| 889 | AnnulusIterator<TIds> aiter( |
| 890 | this->DataSet, this, this->Divisions, this->BinRadius, circles, x, center); |
| 891 | |
| 892 | // Loop across levels, gathering points as we go. This will determine the maxR2. It also |
| 893 | // carves out some inner levels (based on current level) that do not have to be revisited. |
| 894 | while (static_cast<int>(results.size()) < N && currentLevel < this->MaxLevel) |
| 895 | { |
| 896 | int i, j; |
| 897 | binIdx = aiter.Initialize(currentLevel, i, j); |
| 898 | // Basically iterating over a "rectangular" footprint defined from |
| 899 | // the current level. |
| 900 | while (binIdx >= 0) |
| 901 | { |
| 902 | maxR2 = aiter.GatherPoints(i, j, binIdx, currentLevel, N, minR2, maxR2, results); |
| 903 | binIdx = aiter.NextBin(i, j); |
| 904 | } |
| 905 | ++currentLevel; |
| 906 | } |
| 907 | // Reset the level to the last successfully processed |
| 908 | int level = currentLevel - 1; |
| 909 | |
| 910 | // We have determined maxR2 and ~N points in the request annulus |
| 911 | // (minR2 < p_d2 <= maxR2). Now gather any other remaining points |
| 912 | // within the request. It's typical that the number of points |
| 913 | // returned is >N. |
| 914 | maxR = sqrt(maxR2); |
| 915 | |
| 916 | // Determine the range of indices in each direction based on radius maxR. |
| 917 | // This block of bins is processed to gather any additional points with |
| 918 | // radius <=maxR2. |
| 919 | double xMin[2], xMax[2]; |
nothing calls this directly
no test coverage detected