| 203 | namespace |
| 204 | { |
| 205 | std::vector<int> getCellIndicesWithinRadius( |
| 206 | DataDescription const& data, |
| 207 | std::unordered_map<int, std::unordered_map<int, std::vector<int>>> const& cellIndicesBySlot, |
| 208 | RealVector2D const& pos, |
| 209 | float radius) |
| 210 | { |
| 211 | std::vector<int> result; |
| 212 | IntVector2D upperLeftIntPos{toInt(pos.x - radius - 0.5f), toInt(pos.y - radius - 0.5f)}; |
| 213 | IntVector2D lowerRightIntPos{toInt(pos.x + radius + 0.5f), toInt(pos.y + radius + 0.5f)}; |
| 214 | for (int x = upperLeftIntPos.x; x <= lowerRightIntPos.x; ++x) { |
| 215 | for (int y = upperLeftIntPos.y; y <= lowerRightIntPos.y; ++y) { |
| 216 | if (cellIndicesBySlot.find(x) != cellIndicesBySlot.end()) { |
| 217 | if (cellIndicesBySlot.at(x).find(y) != cellIndicesBySlot.at(x).end()) { |
| 218 | for (auto const& cellIndex : cellIndicesBySlot.at(x).at(y)) { |
| 219 | auto const& cell = data.cells.at(cellIndex); |
| 220 | if (Math::length(cell.pos - pos) <= radius) { |
| 221 | result.emplace_back(cellIndex); |
| 222 | } |
| 223 | } |
| 224 | } |
| 225 | } |
| 226 | } |
| 227 | } |
| 228 | std::sort(result.begin(), result.end(), [&](int index1, int index2) { |
| 229 | auto const& cell1 = data.cells.at(index1); |
| 230 | auto const& cell2 = data.cells.at(index2); |
| 231 | return Math::length(cell1.pos - pos) < Math::length(cell2.pos - pos); |
| 232 | }); |
| 233 | return result; |
| 234 | } |
| 235 | } |
| 236 | |
| 237 | DataDescription DescriptionEditService::gridMultiply(DataDescription const& input, GridMultiplyParameters const& parameters) |
no test coverage detected