diff options
author | supermerill <merill@free.fr> | 2022-08-09 17:58:54 +0300 |
---|---|---|
committer | supermerill <merill@free.fr> | 2022-08-11 00:56:37 +0300 |
commit | 1cb0fbfd7a0f0b98a5ab7f64683a638f951effe0 (patch) | |
tree | 84980e335ea7d023d0472897b52a5f126d7d9a02 | |
parent | ae6165c8f9b571d073a833a37fe14677309fe71b (diff) |
Fix brim generation (offset & width in constructed holes)
supermerill/SuperSlicer#3050
-rw-r--r-- | src/libslic3r/Brim.cpp | 49 | ||||
-rw-r--r-- | src/libslic3r/PrintConfig.cpp | 4 |
2 files changed, 24 insertions, 29 deletions
diff --git a/src/libslic3r/Brim.cpp b/src/libslic3r/Brim.cpp index bf6e1de0d..d6a975978 100644 --- a/src/libslic3r/Brim.cpp +++ b/src/libslic3r/Brim.cpp @@ -995,18 +995,18 @@ void make_brim(const Print& print, const Flow& flow, const PrintObjectPtrs& obje if (brim_offset == 0) { object_islands.push_back(to_expolygon(expoly.contour)); } else { - for (const ExPolygon& grown_expoly : offset_ex(to_expolygon(expoly.contour), brim_offset)) { + for (ExPolygon& grown_expoly : offset_ex(to_expolygon(expoly.contour), brim_offset)) { object_islands.push_back(std::move(grown_expoly)); } } } if (!object->support_layers().empty()) { - Polygons polys = object->support_layers().front()->support_fills.polygons_covered_by_spacing(flow.spacing_ratio(), float(SCALED_EPSILON)); - for (Polygon poly : polys) { + ExPolygons polys = union_ex(object->support_layers().front()->support_fills.polygons_covered_by_spacing(flow.spacing_ratio(), float(SCALED_EPSILON))); + for (ExPolygon& poly : polys) { if (brim_offset == 0) { - object_islands.emplace_back(poly); + object_islands.push_back(std::move(poly)); } else { - append(object_islands, offset_ex(Polygons{ poly }, brim_offset)); + append(object_islands, offset_ex(ExPolygons{ poly }, brim_offset)); } } } @@ -1073,9 +1073,9 @@ void make_brim(const Print& print, const Flow& flow, const PrintObjectPtrs& obje bigger_islands.clear(); if (i > 0) { for (ExPolygon& expoly : last_islands) { - for (Polygon& big_contour : offset(expoly.contour, double(scaled_spacing), jtSquare)) { - bigger_islands.emplace_back(); - Polygons simplifiesd_big_contour = big_contour.simplify(scaled_resolution / 10); + for (ExPolygon& big_contour : offset_ex(expoly, double(scaled_spacing), jtSquare)) { + bigger_islands.push_back(big_contour); + Polygons simplifiesd_big_contour = big_contour.contour.simplify(scaled_resolution / 10); if (simplifiesd_big_contour.size() == 1) { bigger_islands.back().contour = simplifiesd_big_contour.front(); } @@ -1085,12 +1085,11 @@ void make_brim(const Print& print, const Flow& flow, const PrintObjectPtrs& obje last_islands = union_ex(bigger_islands); for (ExPolygon& expoly : last_islands) { loops.back().emplace_back(expoly.contour); - // buggy - ////also add hole, in case of it's merged with a contour. <= HOW? if there's an island inside a hole! (in the same object) - //for (Polygon &hole : expoly.holes) - // //but remove the points that are inside the holes of islands - // for (Polyline& pl : diff_pl(Polygons{ hole }, unbrimmable_polygons, true)) - // loops[i].emplace_back(pl); + // also add hole, in case of it's merged with a contour. see supermerill/SuperSlicer/issues/3050 + for (Polygon &hole : expoly.holes) + //but remove the points that are inside the holes of islands + for (ExPolygon& pl : diff_ex(Polygons{ hole }, unbrimmable_polygons)) + loops[i].emplace_back(pl.contour); } } @@ -1144,16 +1143,14 @@ void make_brim_ears(const Print& print, const Flow& flow, const PrintObjectPtrs& } if (!object->support_layers().empty()) { - Polygons polys = object->support_layers().front()->support_fills.polygons_covered_by_spacing(flow.spacing_ratio(), float(SCALED_EPSILON)); + ExPolygons polys = union_ex(object->support_layers().front()->support_fills.polygons_covered_by_spacing(flow.spacing_ratio(), float(SCALED_EPSILON))); //put ears over supports unless it's more than 30% fill if (object->config().raft_first_layer_density.get_abs_value(1.) > 0.3) { - for (Polygon poly : polys) { + for (ExPolygon& poly : polys) { if (brim_offset == 0) { - object_islands.emplace_back(poly); + object_islands.push_back(std::move(poly)); } else { - for (const ExPolygon& grown_expoly : offset_ex(Polygons{ poly }, brim_offset)) { - object_islands.push_back(std::move(grown_expoly)); - } + append(object_islands, offset_ex(ExPolygons{ poly }, brim_offset)); } } } else { @@ -1327,16 +1324,14 @@ void make_brim_interior(const Print& print, const Flow& flow, const PrintObjectP } if (!object->support_layers().empty()) { spacing = scaled(object->config().support_material_interface_spacing.value) + support_material_flow(object, float(print.get_first_layer_height())).scaled_width() * 1.5; - Polygons polys = closing( - object->support_layers().front()->support_fills.polygons_covered_by_spacing(flow.spacing_ratio(), float(SCALED_EPSILON)) + ExPolygons polys = closing_ex( + union_ex(object->support_layers().front()->support_fills.polygons_covered_by_spacing(flow.spacing_ratio(), float(SCALED_EPSILON))) , spacing); - for (Polygon poly : polys) { + for (ExPolygon& poly : polys) { if (brim_offset == 0) { - object_islands.emplace_back(poly); + object_islands.push_back(std::move(poly)); } else { - for (const ExPolygon& grown_expoly : offset_ex(Polygons{ poly }, brim_offset)) { - object_islands.push_back(std::move(grown_expoly)); - } + append(object_islands, offset_ex(ExPolygons{ poly }, brim_offset)); } } } diff --git a/src/libslic3r/PrintConfig.cpp b/src/libslic3r/PrintConfig.cpp index 739651ecf..4bdeb5b69 100644 --- a/src/libslic3r/PrintConfig.cpp +++ b/src/libslic3r/PrintConfig.cpp @@ -825,7 +825,8 @@ void PrintConfigDef::init_fff_params() def->label = L("Brim inside holes"); def->full_label = L("Brim inside holes"); def->category = OptionCategory::skirtBrim; - def->tooltip = L("Allow to create a brim over an island when it's inside a hole (or surrounded by an object)."); + def->tooltip = L("Allow to create a brim over an island when it's inside a hole (or surrounded by an object)." + "\nIncompatible with brim_width_interior, as it enables it with brim_width width."); def->mode = comAdvancedE | comSuSi; def->set_default_value(new ConfigOptionBool(false)); @@ -912,7 +913,6 @@ void PrintConfigDef::init_fff_params() def->tooltip = L("Offset of brim from the printed object. Should be kept at 0 unless you encounter great difficulties to separate them." "\nIt's subtracted to brim_width and brim_width_interior, so it has to be lower than them. The offset is applied after the first layer XY compensation (elephant foot)."); def->sidetext = L("mm"); - def->min = 0; def->mode = comExpert | comPrusa; def->set_default_value(new ConfigOptionFloat(0)); def->aliases = { "brim_offset" }; // from superslicer 2.3 |