Fixed an issue that, in some cases, an inner brim was not generated.

This commit is contained in:
Lukáš Hejl 2022-02-22 12:38:54 +01:00
parent 46939dd6b8
commit dbc3cfc004

View file

@ -298,6 +298,7 @@ static std::vector<InnerBrimExPolygons> inner_brim_area(const Print
const float brim_width = scale_(object->config().brim_width.value);
const bool top_outer_brim = top_level_objects_idx.find(object->id().id) != top_level_objects_idx.end();
ExPolygons brim_area_innermost_object;
ExPolygons brim_area_object;
ExPolygons no_brim_area_object;
Polygons holes_reversed_object;
@ -310,33 +311,35 @@ static std::vector<InnerBrimExPolygons> inner_brim_area(const Print
}
// After 7ff76d07684858fd937ef2f5d863f105a10f798e offset and shrink don't work with CW polygons (holes), so let's make it CCW.
holes_reversed_object = ex_poly.holes;
polygons_reverse(holes_reversed_object);
if (brim_type == BrimType::btInnerOnly || brim_type == BrimType::btNoBrim)
append(no_brim_area_object, diff_ex(offset(ex_poly.contour, no_brim_offset, ClipperLib::jtSquare), holes_reversed_object));
if (brim_type == BrimType::btOuterOnly || brim_type == BrimType::btNoBrim)
append(no_brim_area_object, diff_ex(ExPolygon(ex_poly.contour), shrink_ex(holes_reversed_object, no_brim_offset, ClipperLib::jtSquare)));
}
append(no_brim_area_object, offset_ex(bottom_layers_expolygons[print_object_idx], brim_separation, ClipperLib::jtSquare));
for (const PrintInstance &instance : object->instances()) {
for (const ExPolygon &ex_poly : bottom_layers_expolygons[print_object_idx]) {
Polygons ex_poly_holes_reversed = ex_poly.holes;
polygons_reverse(ex_poly_holes_reversed);
for (const PrintInstance &instance : object->instances()) {
++polygon_idx; // Increase idx because of the contour of the ExPolygon.
if (brim_type == BrimType::btInnerOnly || brim_type == BrimType::btOuterAndInner)
for (const Polygon &hole : holes_reversed_object) {
size_t hole_idx = &hole - &holes_reversed_object.front();
for(const Polygon &hole : ex_poly_holes_reversed) {
size_t hole_idx = &hole - &ex_poly_holes_reversed.front();
if (has_nothing_inside[polygon_idx + hole_idx])
append_and_translate(brim_area_innermost[print_object_idx], shrink_ex({hole}, brim_separation, ClipperLib::jtSquare), instance);
append(brim_area_innermost_object, shrink_ex({hole}, brim_separation, ClipperLib::jtSquare));
else
append_and_translate(brim_area, diff_ex(shrink_ex({hole}, brim_separation, ClipperLib::jtSquare), shrink_ex({hole}, brim_width + brim_separation, ClipperLib::jtSquare)), instance);
append(brim_area_object, diff_ex(shrink_ex({hole}, brim_separation, ClipperLib::jtSquare), shrink_ex({hole}, brim_width + brim_separation, ClipperLib::jtSquare)));
}
polygon_idx += ex_poly.holes.size(); // Increase idx for every hole of the ExPolygon.
}
if (brim_type == BrimType::btInnerOnly || brim_type == BrimType::btNoBrim)
append(no_brim_area_object, diff_ex(offset(ex_poly.contour, no_brim_offset, ClipperLib::jtSquare), ex_poly_holes_reversed));
if (brim_type == BrimType::btOuterOnly || brim_type == BrimType::btNoBrim)
append(no_brim_area_object, diff_ex(ExPolygon(ex_poly.contour), shrink_ex(ex_poly_holes_reversed, no_brim_offset, ClipperLib::jtSquare)));
append(holes_reversed_object, ex_poly_holes_reversed);
}
append(no_brim_area_object, offset_ex(bottom_layers_expolygons[print_object_idx], brim_separation, ClipperLib::jtSquare));
for (const PrintInstance &instance : object->instances()) {
append_and_translate(brim_area_innermost[print_object_idx], brim_area_innermost_object, instance);
append_and_translate(brim_area, brim_area_object, instance);
append_and_translate(no_brim_area, no_brim_area_object, instance);
append_and_translate(holes_reversed, holes_reversed_object, instance);