MCPcopy Create free account
hub / github.com/comaps/comaps / AddPointAndRound

Function AddPointAndRound

libs/drape_frontend/path_text_handle.cpp:88–113  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

86}
87
88void 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
115PathTextContext::PathTextContext(m2::SharedSpline const & spline) : m_globalSpline(spline) {}
116

Callers 2

UpdateMethod · 0.85
UNIT_TESTFunction · 0.85

Calls 8

RoundCornerFunction · 0.85
ReplaceLastCornerFunction · 0.85
backMethod · 0.80
DotProductFunction · 0.50
GetSizeMethod · 0.45
AddPointMethod · 0.45
NormalizeMethod · 0.45
GetPathMethod · 0.45

Tested by 1

UNIT_TESTFunction · 0.68