From e1f3941c584a38e9133cf3723bd349403963c3ab Mon Sep 17 00:00:00 2001 From: SoftFever Date: Tue, 27 Feb 2024 20:40:04 +0800 Subject: [PATCH] offset clipped upper slices --- src/libslic3r/PerimeterGenerator.cpp | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/libslic3r/PerimeterGenerator.cpp b/src/libslic3r/PerimeterGenerator.cpp index c6b689971d1..efa3936d89e 100644 --- a/src/libslic3r/PerimeterGenerator.cpp +++ b/src/libslic3r/PerimeterGenerator.cpp @@ -898,18 +898,16 @@ void PerimeterGenerator::split_top_surfaces(const ExPolygons &orig_polygons, ExP else offset_top_surface = 0; // don't takes into account too thin areas - // skip if the exposed area is smaller than "min_width_top_surface" - double min_width_top_surface = std::max(double(ext_perimeter_spacing / 2 + 10), scale_(config->min_width_top_surface.get_abs_value(unscale_(perimeter_width)))); - - Polygons grown_upper_slices = offset(*this->upper_slices, min_width_top_surface); - // get boungding box of last BoundingBox last_box = get_extents(orig_polygons); last_box.offset(SCALED_EPSILON); + // skip if the exposed area is smaller than "min_width_top_surface" + double min_width_top_surface = std::max(double(ext_perimeter_spacing / 2. + 10), scale_(config->min_width_top_surface.get_abs_value(unscale_(perimeter_width)))); + // get the Polygons upper the polygon this layer - Polygons upper_polygons_series_clipped = - ClipperUtils::clip_clipper_polygons_with_subject_bbox(grown_upper_slices, last_box); + Polygons upper_polygons_series_clipped = ClipperUtils::clip_clipper_polygons_with_subject_bbox(*this->upper_slices, last_box); + upper_polygons_series_clipped = offset(upper_polygons_series_clipped, min_width_top_surface); // set the clip to a virtual "second perimeter" fill_clip = offset_ex(orig_polygons, -double(ext_perimeter_spacing)); @@ -927,7 +925,7 @@ void PerimeterGenerator::split_top_surfaces(const ExPolygons &orig_polygons, ExP const float bridge_margin = std::min(float(scale_(BRIDGE_INFILL_MARGIN)), float(scale_(nozzle_diameter * BRIDGE_INFILL_MARGIN / 0.4))); bridge_checker = offset_ex(diff_ex(orig_polygons, lower_polygons_series_clipped, ApplySafetyOffset::Yes), - 1.5 * bridge_offset + bridge_margin + perimeter_spacing / 2); + 1.5 * bridge_offset + bridge_margin + perimeter_spacing / 2.); } ExPolygons delete_bridge = diff_ex(orig_polygons, bridge_checker, ApplySafetyOffset::Yes); @@ -937,7 +935,7 @@ void PerimeterGenerator::split_top_surfaces(const ExPolygons &orig_polygons, ExP ExPolygons temp_gap = diff_ex(top_polygons, fill_clip); ExPolygons inner_polygons = diff_ex(orig_polygons, - offset_ex(top_polygons, offset_top_surface + min_width_top_surface - double(ext_perimeter_spacing / 2)), + offset_ex(top_polygons, offset_top_surface + min_width_top_surface - double(ext_perimeter_spacing / 2.)), ApplySafetyOffset::Yes); // get the enlarged top surface, by using inner_polygons instead of upper_slices, and clip it for it to be exactly // the polygons to fill. @@ -947,7 +945,7 @@ void PerimeterGenerator::split_top_surfaces(const ExPolygons &orig_polygons, ExP //set the clip to the external wall but go back inside by infill_extrusion_width/2 to be sure the extrusion won't go outside even with a 100% overlap. double infill_spacing_unscaled = this->config->sparse_infill_line_width.get_abs_value(nozzle_diameter); if (infill_spacing_unscaled == 0) infill_spacing_unscaled = Flow::auto_extrusion_width(frInfill, nozzle_diameter); - fill_clip = offset_ex(orig_polygons, double(ext_perimeter_spacing / 2) - scale_(infill_spacing_unscaled / 2)); + fill_clip = offset_ex(orig_polygons, double(ext_perimeter_spacing / 2.) - scale_(infill_spacing_unscaled / 2.)); // ExPolygons oldLast = last; non_top_polygons = intersection_ex(inner_polygons, orig_polygons);