| 306 | } |
| 307 | |
| 308 | base::ControlFlow BordersData::TryToReplace(size_t curBorderId, size_t & curLeftPointId, size_t curRightPointId) |
| 309 | { |
| 310 | auto & curPolygon = m_bordersPolygons[curBorderId]; |
| 311 | if (curRightPointId >= curPolygon.m_points.size()) |
| 312 | return base::ControlFlow::Break; |
| 313 | |
| 314 | if (curPolygon.IsFrozen(curRightPointId, curRightPointId)) |
| 315 | { |
| 316 | curLeftPointId = curRightPointId - 1; |
| 317 | return base::ControlFlow::Break; |
| 318 | } |
| 319 | |
| 320 | auto & leftMarkedPoint = curPolygon.m_points[curLeftPointId]; |
| 321 | auto & rightMarkedPoint = curPolygon.m_points[curRightPointId]; |
| 322 | |
| 323 | auto op = rightMarkedPoint.GetLink(curBorderId); |
| 324 | if (!op) |
| 325 | return base::ControlFlow::Continue; |
| 326 | |
| 327 | Link rightLink = *op; |
| 328 | Link leftLink = *leftMarkedPoint.GetLink(curBorderId); |
| 329 | |
| 330 | if (leftLink.m_borderId != rightLink.m_borderId) |
| 331 | return base::ControlFlow::Continue; |
| 332 | |
| 333 | auto const anotherBorderId = leftLink.m_borderId; |
| 334 | auto const anotherLeftPointId = leftLink.m_pointId; |
| 335 | auto const anotherRightPointId = rightLink.m_pointId; |
| 336 | auto & anotherPolygon = m_bordersPolygons[anotherBorderId]; |
| 337 | |
| 338 | if (anotherPolygon.IsFrozen(std::min(anotherLeftPointId, anotherRightPointId), |
| 339 | std::max(anotherLeftPointId, anotherRightPointId))) |
| 340 | { |
| 341 | return base::ControlFlow::Continue; |
| 342 | } |
| 343 | |
| 344 | auto const anotherSubpolygon = |
| 345 | AppendPointsWithAnyDirection(anotherPolygon.m_points, anotherLeftPointId, anotherRightPointId); |
| 346 | |
| 347 | auto const curSubpolygon = AppendPointsWithAnyDirection(curPolygon.m_points, curLeftPointId, curRightPointId); |
| 348 | |
| 349 | if (!NeedReplace(curSubpolygon, anotherSubpolygon)) |
| 350 | return base::ControlFlow::Break; |
| 351 | |
| 352 | // We want to decrease the amount of points in polygons. So we will replace the greater amounts of |
| 353 | // points by smaller amounts of points. |
| 354 | bool const curLenIsLess = curSubpolygon.size() < anotherSubpolygon.size(); |
| 355 | |
| 356 | size_t dstFrom = curLenIsLess ? anotherLeftPointId : curLeftPointId; |
| 357 | size_t dstTo = curLenIsLess ? anotherRightPointId : curRightPointId; |
| 358 | |
| 359 | size_t srcFrom = curLenIsLess ? curLeftPointId : anotherLeftPointId; |
| 360 | size_t srcTo = curLenIsLess ? curRightPointId : anotherRightPointId; |
| 361 | |
| 362 | size_t const borderIdWhereAreaWillBeChanged = curLenIsLess ? anotherBorderId : curBorderId; |
| 363 | size_t const srcBorderId = curLenIsLess ? curBorderId : anotherBorderId; |
| 364 | |
| 365 | bool const reversed = IsReversedIntervals(dstFrom, dstTo, srcFrom, srcTo); |
nothing calls this directly
no test coverage detected