mirror of
https://github.com/QIDITECH/QIDISlicer.git
synced 2026-01-31 16:08:43 +03:00
PRUSA 2.7.0
This commit is contained in:
@@ -146,8 +146,10 @@ void Polyline::split_at(const Point &point, Polyline* p1, Polyline* p2) const
|
||||
}
|
||||
|
||||
if (this->points.front() == point) {
|
||||
//FIXME why is p1 NOT empty as in the case above?
|
||||
*p1 = { point };
|
||||
*p2 = *this;
|
||||
return;
|
||||
}
|
||||
|
||||
auto min_dist2 = std::numeric_limits<double>::max();
|
||||
@@ -200,6 +202,31 @@ BoundingBox get_extents(const Polylines &polylines)
|
||||
return bb;
|
||||
}
|
||||
|
||||
// Return True when erase some otherwise False.
|
||||
bool remove_same_neighbor(Polyline &polyline) {
|
||||
Points &points = polyline.points;
|
||||
if (points.empty())
|
||||
return false;
|
||||
auto last = std::unique(points.begin(), points.end());
|
||||
|
||||
// no duplicits
|
||||
if (last == points.end())
|
||||
return false;
|
||||
|
||||
points.erase(last, points.end());
|
||||
return true;
|
||||
}
|
||||
|
||||
bool remove_same_neighbor(Polylines &polylines){
|
||||
if (polylines.empty())
|
||||
return false;
|
||||
bool exist = false;
|
||||
for (Polyline &polyline : polylines)
|
||||
exist |= remove_same_neighbor(polyline);
|
||||
// remove empty polylines
|
||||
polylines.erase(std::remove_if(polylines.begin(), polylines.end(), [](const Polyline &p) { return p.points.size() <= 1; }), polylines.end());
|
||||
return exist;
|
||||
}
|
||||
const Point& leftmost_point(const Polylines &polylines)
|
||||
{
|
||||
if (polylines.empty())
|
||||
|
||||
Reference in New Issue
Block a user