| 274 | } |
| 275 | |
| 276 | void BordersData::RemoveEmptySpaceBetweenBorders() |
| 277 | { |
| 278 | LOG(LINFO, ("Start removing empty space between borders.")); |
| 279 | |
| 280 | for (size_t curBorderId = 0; curBorderId < m_bordersPolygons.size(); ++curBorderId) |
| 281 | { |
| 282 | LOG(LDEBUG, ("Get:", m_indexToPolyFileName[curBorderId])); |
| 283 | |
| 284 | if (ShouldLog(curBorderId, m_bordersPolygons.size())) |
| 285 | LOG(LINFO, ("Removing empty spaces:", curBorderId + 1, "/", m_bordersPolygons.size())); |
| 286 | |
| 287 | auto & curPolygon = m_bordersPolygons[curBorderId]; |
| 288 | for (size_t curPointId = 0; curPointId < curPolygon.m_points.size(); ++curPointId) |
| 289 | { |
| 290 | if (curPolygon.IsFrozen(curPointId, curPointId) || !HasLinkAt(curBorderId, curPointId)) |
| 291 | continue; |
| 292 | |
| 293 | size_t constexpr kMaxLookAhead = 5; |
| 294 | for (size_t shift = 1; shift <= kMaxLookAhead; ++shift) |
| 295 | { |
| 296 | if (TryToReplace(curBorderId, curPointId /* curLeftPointId */, curPointId + shift /* curRightPointId */) == |
| 297 | base::ControlFlow::Break) |
| 298 | { |
| 299 | break; |
| 300 | } |
| 301 | } |
| 302 | } |
| 303 | } |
| 304 | |
| 305 | DoReplace(); |
| 306 | } |
| 307 | |
| 308 | base::ControlFlow BordersData::TryToReplace(size_t curBorderId, size_t & curLeftPointId, size_t curRightPointId) |
| 309 | { |