fix brim ear generation crash of small surfaces

supermerill/SuperSlicer#1513
This commit is contained in:
supermerill 2021-08-30 16:07:08 +02:00 committed by supermerill
parent 2dc9bcc419
commit 6b6035ad00

View File

@ -2370,18 +2370,19 @@ void Print::_make_brim_ears(const Flow &flow, const PrintObjectPtrs &objects, Ex
} }
} }
islands.reserve(islands.size() + object_islands.size() * object->m_instances.size()); islands.reserve(islands.size() + object_islands.size() * object->m_instances.size());
coord_t ear_detection_length = scale_t(object->config().brim_ears_detection_length.value);
for (const PrintInstance &copy_pt : object->m_instances) for (const PrintInstance &copy_pt : object->m_instances)
for (const ExPolygon &poly : object_islands) { for (const ExPolygon &poly : object_islands) {
islands.push_back(poly); islands.push_back(poly);
islands.back().translate(copy_pt.shift.x(), copy_pt.shift.y()); islands.back().translate(copy_pt.shift.x(), copy_pt.shift.y());
Polygon decimated_polygon = poly.contour; Polygon decimated_polygon = poly.contour;
// brim_ears_detection_length codepath // brim_ears_detection_length codepath
if (object->config().brim_ears_detection_length.value > 0) { if (ear_detection_length > 0) {
//decimate polygon //decimate polygon
Points points = poly.contour.points; Points points = poly.contour.points;
points.push_back(points.front()); points.push_back(points.front());
points = MultiPoint::_douglas_peucker(points, scale_(object->config().brim_ears_detection_length.value)); points = MultiPoint::_douglas_peucker(points, ear_detection_length);
if (points.size() > 1) { if (points.size() > 4) { //don't decimate if it's going to be below 4 points, as it's surely enough to fill everything anyway
points.erase(points.end() - 1); points.erase(points.end() - 1);
decimated_polygon.points = points; decimated_polygon.points = points;
} }