new function remove_degenerate(Polylines ...)

This commit is contained in:
bubnikv 2017-01-25 18:23:57 +01:00
parent c46b6ca27e
commit 40eaf144f0
2 changed files with 19 additions and 0 deletions

View File

@ -237,6 +237,23 @@ BoundingBox get_extents(const Polylines &polylines)
return bb;
}
bool remove_degenerate(Polylines &polylines)
{
bool modified = false;
size_t j = 0;
for (size_t i = 0; i < polylines.size(); ++ i) {
if (polylines[i].points.size() >= 2) {
if (j < i)
std::swap(polylines[i].points, polylines[j].points);
++ j;
} else
modified = true;
}
if (j < polylines.size())
polylines.erase(polylines.begin() + j, polylines.end());
return modified;
}
ThickLines
ThickPolyline::thicklines() const
{

View File

@ -111,6 +111,8 @@ inline void polylines_append(Polylines &dst, Polylines &&src)
}
}
bool remove_degenerate(Polylines &polylines);
class ThickPolyline : public Polyline {
public:
std::vector<coordf_t> width;