| 86 | } |
| 87 | |
| 88 | void AddPointAndRound(m2::SplineEx & spline, m2::PointD const & pt) |
| 89 | { |
| 90 | if (spline.GetSize() < 2) |
| 91 | { |
| 92 | spline.AddPoint(pt); |
| 93 | return; |
| 94 | } |
| 95 | |
| 96 | auto const dir1 = spline.GetDirections().back(); |
| 97 | auto const dir2 = (pt - spline.GetPath().back()).Normalize(); |
| 98 | |
| 99 | double const dotProduct = m2::DotProduct(dir1, dir2); |
| 100 | if (dotProduct < kCosTurn) |
| 101 | { |
| 102 | int leftStepsCount = static_cast<int>(acos(dotProduct) / kValidPathSplineTurn); |
| 103 | std::vector<m2::PointD> roundedCorner; |
| 104 | while (leftStepsCount > 0 && leftStepsCount <= kMaxStepsCount && |
| 105 | RoundCorner(spline.GetPath()[spline.GetSize() - 2], spline.GetPath().back(), pt, leftStepsCount--, |
| 106 | roundedCorner)) |
| 107 | { |
| 108 | ReplaceLastCorner(roundedCorner, spline); |
| 109 | } |
| 110 | ReplaceLastCorner(roundedCorner, spline); |
| 111 | } |
| 112 | spline.AddPoint(pt); |
| 113 | } |
| 114 | |
| 115 | PathTextContext::PathTextContext(m2::SharedSpline const & spline) : m_globalSpline(spline) {} |
| 116 | |