mirror of
https://github.com/QIDITECH/QIDISlicer.git
synced 2026-01-31 07:58:43 +03:00
PRUSA 2.7.0
This commit is contained in:
@@ -437,6 +437,37 @@ bool has_duplicate_points(const Polygons &polys)
|
||||
#endif
|
||||
}
|
||||
|
||||
bool remove_same_neighbor(Polygon &polygon)
|
||||
{
|
||||
Points &points = polygon.points;
|
||||
if (points.empty())
|
||||
return false;
|
||||
auto last = std::unique(points.begin(), points.end());
|
||||
|
||||
// remove first and last neighbor duplication
|
||||
if (const Point &last_point = *(last - 1); last_point == points.front()) {
|
||||
--last;
|
||||
}
|
||||
|
||||
// no duplicits
|
||||
if (last == points.end())
|
||||
return false;
|
||||
|
||||
points.erase(last, points.end());
|
||||
return true;
|
||||
}
|
||||
|
||||
bool remove_same_neighbor(Polygons &polygons)
|
||||
{
|
||||
if (polygons.empty())
|
||||
return false;
|
||||
bool exist = false;
|
||||
for (Polygon &polygon : polygons)
|
||||
exist |= remove_same_neighbor(polygon);
|
||||
// remove empty polygons
|
||||
polygons.erase(std::remove_if(polygons.begin(), polygons.end(), [](const Polygon &p) { return p.points.size() <= 2; }), polygons.end());
|
||||
return exist;
|
||||
}
|
||||
static inline bool is_stick(const Point &p1, const Point &p2, const Point &p3)
|
||||
{
|
||||
Point v1 = p2 - p1;
|
||||
|
||||
Reference in New Issue
Block a user