| 154 | } |
| 155 | |
| 156 | std::optional<m2::PointI> CellsMerger::FindDirection(m2::PointI const & startXy) const |
| 157 | { |
| 158 | std::array<std::pair<size_t, m2::PointI>, 4> directionsWithWeight; |
| 159 | std::array<m2::PointI, 4> const directions{{{1, 1}, {-1, 1}, {1, -1}, {-1, -1}}}; |
| 160 | base::Transform(directions, std::begin(directionsWithWeight), [&](auto const & direction) |
| 161 | { |
| 162 | return std::make_pair(TryGet(startXy.x + direction.x, startXy.y).GetSum() + |
| 163 | TryGet(startXy.x, startXy.y + direction.y).GetSum() + |
| 164 | TryGet(startXy.x + direction.x, startXy.y + direction.y).GetSum(), |
| 165 | direction); |
| 166 | }); |
| 167 | auto const direction = std::max_element(std::cbegin(directionsWithWeight), std::cend(directionsWithWeight))->second; |
| 168 | return Has(startXy + direction) ? direction : std::optional<m2::PointI>{}; |
| 169 | } |
| 170 | |
| 171 | void CellsMerger::Remove(m2::PointI const & minXy, m2::PointI const & maxXy) |
| 172 | { |