| 1206 | //------------------------------------------------------------------------------ |
| 1207 | template <typename TIds> |
| 1208 | double BucketList2D<TIds>::FindCloseNBoundedPoints(int N, const double x[3], vtkIdList* result) |
| 1209 | { |
| 1210 | int i, j; |
| 1211 | double dist2; |
| 1212 | double pt[3]; |
| 1213 | int level; |
| 1214 | vtkIdType ptId, cno, numIds; |
| 1215 | int ij[2], *nei; |
| 1216 | NeighborBuckets2D buckets; |
| 1217 | const vtkLocatorTuple<TIds>* ids; |
| 1218 | |
| 1219 | // Find the bucket the point is in. |
| 1220 | this->GetBucketIndices(x, ij); |
| 1221 | |
| 1222 | // Gather points keeping track of maximum radius |
| 1223 | level = 0; |
| 1224 | double maxDist2 = 0.0; |
| 1225 | vtkDist2TupleType sortedPts; |
| 1226 | sortedPts.reserve(128); |
| 1227 | |
| 1228 | // Start in the current bucket and expand out to grab first N points. Keep |
| 1229 | // track of maximum distance. |
| 1230 | this->GetBucketNeighbors(&buckets, ij, this->Divisions, level); |
| 1231 | while (buckets.GetNumberOfNeighbors() > 0) |
| 1232 | { |
| 1233 | // For all buckets in this level |
| 1234 | for (i = 0; i < buckets.GetNumberOfNeighbors(); i++) |
| 1235 | { |
| 1236 | nei = buckets.GetPoint(i); |
| 1237 | cno = nei[0] + nei[1] * this->xD; |
| 1238 | if ((numIds = this->GetNumberOfIds(cno)) > 0) |
| 1239 | { |
| 1240 | ids = this->GetIds(cno); |
| 1241 | for (j = 0; j < numIds; j++) |
| 1242 | { |
| 1243 | ptId = ids[j].PtId; |
| 1244 | this->DataSet->GetPoint(ptId, pt); |
| 1245 | dist2 = Distance2BetweenPoints2D(x, pt); |
| 1246 | // accumulate first N points |
| 1247 | if (static_cast<int>(sortedPts.size()) < N) |
| 1248 | { |
| 1249 | maxDist2 = (dist2 > maxDist2 ? dist2 : maxDist2); |
| 1250 | sortedPts.emplace_back(ptId, dist2); |
| 1251 | } |
| 1252 | else if (dist2 <= maxDist2) |
| 1253 | { |
| 1254 | sortedPts.emplace_back(ptId, dist2); |
| 1255 | } |
| 1256 | } |
| 1257 | } // if points in bucket |
| 1258 | } // for buckets in this level |
| 1259 | level++; |
| 1260 | // As soon as N points in this level found, jump out. |
| 1261 | if (static_cast<int>(sortedPts.size()) >= N) |
| 1262 | { |
| 1263 | goto FOUND_N; |
| 1264 | } |
| 1265 | this->GetBucketNeighbors(&buckets, ij, this->Divisions, level); |
nothing calls this directly
no test coverage detected