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

Function SmoothPaths

libs/geometry/smoothing.cpp:72–107  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

70} // namespace
71
72void SmoothPaths(GuidePointsForSmooth const & guidePoints, size_t newPointsPerSegmentCount, double smoothAlpha,
73 std::vector<std::vector<m2::PointD>> & paths)
74{
75 ASSERT_EQUAL(guidePoints.size(), paths.size(), ());
76 ASSERT(smoothAlpha >= kUniformAplha && smoothAlpha <= kChordalAlpha, (smoothAlpha));
77
78 for (size_t pathInd = 0; pathInd < paths.size(); ++pathInd)
79 {
80 auto const & path = paths[pathInd];
81 ASSERT_GREATER(path.size(), 1, ());
82
83 auto const & guides = guidePoints[pathInd];
84
85 std::vector<m2::PointD> smoothedPath;
86 smoothedPath.reserve((path.size() - 1) * (2 + newPointsPerSegmentCount));
87
88 smoothedPath.push_back(path.front());
89 for (size_t i = 0; i + 1 < path.size(); ++i)
90 {
91 m2::PointD const & pt0 = i > 0 ? path[i - 1] : guides.first;
92 m2::PointD const & pt1 = path[i];
93 m2::PointD const & pt2 = path[i + 1];
94 m2::PointD const & pt3 = i + 2 < path.size() ? path[i + 2] : guides.second;
95
96 if (smoothAlpha == kUniformAplha)
97 SmoothUniform(pt0, pt1, pt2, pt3, newPointsPerSegmentCount, smoothedPath);
98 else
99 SmoothGeneric(pt0, pt1, pt2, pt3, smoothAlpha, newPointsPerSegmentCount, smoothedPath);
100
101 smoothedPath.push_back(pt2);
102 }
103
104 if (smoothedPath.size() > 2)
105 paths[pathInd] = std::move(smoothedPath);
106 }
107}
108} // namespace m2

Callers 1

ProcessLineRulesMethod · 0.85

Calls 7

ASSERTFunction · 0.85
SmoothUniformFunction · 0.85
SmoothGenericFunction · 0.85
frontMethod · 0.80
sizeMethod · 0.45
reserveMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected