From 41f00c37795b456c7541c750f539ee76c0223b39 Mon Sep 17 00:00:00 2001 From: supermerill Date: Sat, 29 Jun 2024 18:32:34 +0200 Subject: [PATCH] fix (snug) support too narrow Also allow the periemter around support to overlap itself like with prusaslicer (unless there is a 0 support xy distance). supermerill/SuperSlicer#4333 --- src/libslic3r/Fill/FillBase.cpp | 8 +++++--- src/libslic3r/Fill/FillBase.hpp | 2 ++ src/libslic3r/SupportMaterial.cpp | 16 +++++++++------- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/libslic3r/Fill/FillBase.cpp b/src/libslic3r/Fill/FillBase.cpp index 57179471fd2..a6b2798aa31 100644 --- a/src/libslic3r/Fill/FillBase.cpp +++ b/src/libslic3r/Fill/FillBase.cpp @@ -3653,9 +3653,11 @@ FillWithPerimeter::fill_surface_extrusion(const Surface* surface, const FillPara // === extrude perimeter & associated surface at the same time, in the right order === //generate perimeter: - ExPolygons path_perimeter = offset2_ex(ExPolygons{ surface->expolygon }, - scale_d(-this->get_spacing()), scale_d(this->get_spacing() / 2), - ClipperLib::jtMiter, scale_d(this->get_spacing()) * 10); + coord_t offset_for_overlap = scale_d(this->get_spacing() / 2) * ((1 - overlap_ratio) / 2); + ExPolygons path_perimeter = offset2_ex(ExPolygons{surface->expolygon}, + scale_d(-this->get_spacing()) / 2 - offset_for_overlap, + offset_for_overlap, + ClipperLib::jtMiter, scale_d(this->get_spacing()) * 10); //fix a bug that can happens when (positive) offsetting with a big miter limit and two island merge. See https://github.com/supermerill/SuperSlicer/issues/609 path_perimeter = intersection_ex(path_perimeter, offset_ex(surface->expolygon, scale_d(-this->get_spacing() / 2))); for (ExPolygon& expolygon : path_perimeter) { diff --git a/src/libslic3r/Fill/FillBase.hpp b/src/libslic3r/Fill/FillBase.hpp index 9d37d1c3286..cdcfb3d8f51 100644 --- a/src/libslic3r/Fill/FillBase.hpp +++ b/src/libslic3r/Fill/FillBase.hpp @@ -241,6 +241,8 @@ namespace NaiveConnect { class FillWithPerimeter : public Fill { public: + // bewteen 0 (0%) and 1 (100%) overlap + float overlap_ratio = 0; std::unique_ptr infill{ nullptr }; float ratio_fill_inside = 0.f; FillWithPerimeter() : Fill() {} diff --git a/src/libslic3r/SupportMaterial.cpp b/src/libslic3r/SupportMaterial.cpp index f947923285a..b90670dc09b 100644 --- a/src/libslic3r/SupportMaterial.cpp +++ b/src/libslic3r/SupportMaterial.cpp @@ -19,7 +19,7 @@ #include #include #include - +#pragma optimize("", off) #define SUPPORT_USE_AGG_RASTERIZER #ifdef SUPPORT_USE_AGG_RASTERIZER @@ -3912,10 +3912,10 @@ void modulate_extrusion_by_overlapping_layers( const PrintObjectSupportMaterial::MyLayer &overlapping_layer = *overlapping_layers[i_overlapping_layer]; bbox.merge(get_extents(overlapping_layer.polygons)); } - for (ExtrusionEntitiesPtr::const_iterator it = extrusions_in_out.begin(); it != extrusions_in_out.end(); ++ it) { + for (ExtrusionEntitiesPtr::const_iterator it = extrusions_in_out.set_entities().begin(); it != extrusions_in_out.set_entities().end(); ++ it) { ExtrusionPath *path = dynamic_cast(*it); assert(path != nullptr); - bbox.merge(get_extents(path->polyline)); + bbox.merge(get_extents(path->polyline.as_polyline())); } SVG svg(debug_out_path("support-fragments-%d-%lf.svg", iRun, this_layer.print_z).c_str(), bbox); const float transparency = 0.5f; @@ -3932,10 +3932,10 @@ void modulate_extrusion_by_overlapping_layers( svg.draw(to_polylines(overlapping_layer.polygons), dbg_index_to_color(int(i_overlapping_layer)), scale_(0.1)); } // Fill extrusion, the source. - for (ExtrusionEntitiesPtr::const_iterator it = extrusions_in_out.begin(); it != extrusions_in_out.end(); ++ it) { + for (ExtrusionEntitiesPtr::const_iterator it = extrusions_in_out.set_entities().begin(); it != extrusions_in_out.set_entities().end(); ++ it) { ExtrusionPath *path = dynamic_cast(*it); std::string color_name; - switch ((it - extrusions_in_out.begin()) % 9) { + switch ((it - extrusions_in_out.set_entities().begin()) % 9) { case 0: color_name = "magenta"; break; case 1: color_name = "deepskyblue"; break; case 2: color_name = "coral"; break; @@ -3946,7 +3946,7 @@ void modulate_extrusion_by_overlapping_layers( case 7: color_name = "brown"; break; default: color_name = "orchid"; break; } - svg.draw(path->polyline, color_name, scale_(0.2)); + svg.draw(path->polyline.as_polyline(), color_name, scale_(0.2)); } #endif /* SLIC3R_DEBUG */ @@ -4171,8 +4171,10 @@ void PrintObjectSupportMaterial::generate_toolpaths( std::unique_ptr filler_interface = std::unique_ptr(Fill::new_from_type(m_support_params.contact_fill_pattern)); //m_support_params.interface_fill_pattern)); FIXME choose std::unique_ptr filler_support = std::unique_ptr(Fill::new_from_type(m_support_params.base_fill_pattern)); std::unique_ptr filler_support_with_sheath = std::make_unique((Fill::new_from_type(m_support_params.base_fill_pattern))); + filler_support_with_sheath->overlap = m_support_params.gap_xy == 0 ? 0 : 1; // allow periemter overlap is not touching perimeters filler_support_with_sheath->ratio_fill_inside = 0.2f; std::unique_ptr filler_dense = std::make_unique((Fill::new_from_type(ipRectilinear))); + filler_dense->overlap = m_support_params.gap_xy == 0 ? 0 : 1; filler_dense->ratio_fill_inside = 0.2f; filler_interface->set_bounding_box(bbox_object); filler_support->set_bounding_box(bbox_object); @@ -4489,7 +4491,7 @@ void PrintObjectSupportMaterial::generate_toolpaths( // Destination base_layer.extrusions.set_entities(), // Regions to fill - closing_ex(base_layer.polygons_to_extrude(), float(SCALED_EPSILON), float(SCALED_EPSILON + 0.5 * flow.scaled_width())), + closing_ex(base_layer.polygons_to_extrude(), float(SCALED_EPSILON), float(SCALED_EPSILON)), // Filler and its parameters filler, density, // Extrusion parameters