| 70 | } |
| 71 | |
| 72 | PointIdList PointGrid::findNeighbors(BOX2D extent) const |
| 73 | { |
| 74 | extent.clip(bounds()); |
| 75 | |
| 76 | PointIdList neighbors; |
| 77 | |
| 78 | // Find IJ bounding box. |
| 79 | auto [imin, jmin] = toIJ(extent.minx, extent.miny); |
| 80 | auto [imax, jmax] = toIJ(extent.maxx, extent.maxy); |
| 81 | |
| 82 | for (uint16_t i = imin; i <= imax; ++i) |
| 83 | for (uint16_t j = jmin; j <= jmax; ++j) |
| 84 | { |
| 85 | const Cell& c = cell(i, j); |
| 86 | |
| 87 | // If the entire cell is in the extent, append all points. |
| 88 | if (extent.contains(bounds(i, j))) |
| 89 | neighbors.insert(neighbors.end(), c.begin(), c.end()); |
| 90 | // Otherwise, check each point to make sure it's in the xtent. |
| 91 | else |
| 92 | for (PointId id : c) |
| 93 | { |
| 94 | double x = m_view.getFieldAs<double>(Dimension::Id::X, id); |
| 95 | double y = m_view.getFieldAs<double>(Dimension::Id::Y, id); |
| 96 | if (extent.contains(x, y)) |
| 97 | neighbors.push_back(id); |
| 98 | } |
| 99 | } |
| 100 | return neighbors; |
| 101 | } |
| 102 | |
| 103 | PointIdList PointGrid::findNeighbors(PointRef& point, double radius) const |
| 104 | { |