From 16db2fd49218b9268fb759772792572ced351878 Mon Sep 17 00:00:00 2001 From: supermerill Date: Tue, 9 Aug 2022 19:19:28 +0200 Subject: Fix solid_over_perimeters supermerill/SuperSlicer#2955 supermerill/SuperSlicer#3015 --- src/libslic3r/PrintObject.cpp | 28 ++++++++++++++----------- src/libslic3r/Surface.cpp | 49 +++++++++++++++++++++++++++++++++++++++++++ src/libslic3r/Surface.hpp | 1 + 3 files changed, 66 insertions(+), 12 deletions(-) diff --git a/src/libslic3r/PrintObject.cpp b/src/libslic3r/PrintObject.cpp index 84ba3ecd6..78d5f8b6b 100644 --- a/src/libslic3r/PrintObject.cpp +++ b/src/libslic3r/PrintObject.cpp @@ -1835,20 +1835,24 @@ bool PrintObject::invalidate_state_by_config_options( float max_perimeter_infill_spacing = float(layerm.flow(frSolidInfill).scaled_spacing()) * 1.75f; // Top surfaces. auto& cache = cache_top_botom_regions[idx_layer]; - cache.top_surfaces = offset_ex(to_expolygons(layerm.slices().filter_by_type(stPosTop | stDensSolid)), min_perimeter_infill_spacing); - append(cache.top_surfaces, offset_ex(to_expolygons(layerm.fill_surfaces.filter_by_type(stPosTop | stDensSolid)), min_perimeter_infill_spacing)); - if (nb_perimeter_layers_for_solid_fill != 0 && (idx_layer > min_layer_no_solid || layer.print_z < min_z_no_solid)) { + ExPolygons raw_slice_temp = to_expolygons(layerm.slices().filter_by_type(stPosTop | stDensSolid)); + ExPolygons raw_fill_temp = to_expolygons(layerm.fill_surfaces.filter_by_type(stPosTop | stDensSolid)); + cache.top_surfaces = offset_ex(raw_slice_temp, min_perimeter_infill_spacing); + append(cache.top_surfaces, offset_ex(raw_fill_temp, min_perimeter_infill_spacing)); + if (nb_perimeter_layers_for_solid_fill != 0) { //it needs to be activated and we don't check the firs layers, where everything have to be solid. - cache.top_fill_surfaces = offset_ex(to_expolygons(layerm.fill_surfaces.filter_by_type(stPosTop | stDensSolid)), max_perimeter_infill_spacing); - cache.top_perimeter_surfaces = to_expolygons(layerm.slices().filter_by_type(stPosTop | stDensSolid)); + cache.top_fill_surfaces = offset_ex(raw_fill_temp, max_perimeter_infill_spacing); + cache.top_perimeter_surfaces = raw_slice_temp; } // Bottom surfaces. const SurfaceType surfaces_bottom[2] = { stPosBottom | stDensSolid, stPosBottom | stDensSolid | stModBridge }; - cache.bottom_surfaces = offset_ex(to_expolygons(layerm.slices().filter_by_types(surfaces_bottom, 2)), min_perimeter_infill_spacing); - append(cache.bottom_surfaces, offset_ex(to_expolygons(layerm.fill_surfaces.filter_by_types(surfaces_bottom, 2)), min_perimeter_infill_spacing)); - if (nb_perimeter_layers_for_solid_fill != 0 && (idx_layer > min_layer_no_solid || layer.print_z < min_z_no_solid)) { - cache.bottom_fill_surfaces = offset_ex(to_expolygons(layerm.fill_surfaces.filter_by_types(surfaces_bottom, 2)), max_perimeter_infill_spacing); - cache.bottom_perimeter_surfaces = to_expolygons(layerm.slices().filter_by_types(surfaces_bottom, 2)); + raw_slice_temp = to_expolygons(layerm.slices().filter_by_types(surfaces_bottom, 2)); + raw_fill_temp = to_expolygons(layerm.fill_surfaces.filter_by_types(surfaces_bottom, 2)); + cache.bottom_surfaces = offset_ex(raw_slice_temp, min_perimeter_infill_spacing); + append(cache.bottom_surfaces, offset_ex(raw_fill_temp, min_perimeter_infill_spacing)); + if (nb_perimeter_layers_for_solid_fill != 0) { + cache.bottom_perimeter_surfaces = raw_slice_temp; + cache.bottom_fill_surfaces = offset_ex(raw_fill_temp, max_perimeter_infill_spacing); } // Holes over all regions. Only collect them once, they are valid for all idx_region iterations. if (cache.holes.empty()) { @@ -1888,7 +1892,7 @@ bool PrintObject::invalidate_state_by_config_options( coord_t infill_line_spacing = solid_infill_flow.scaled_spacing(); // Find a union of perimeters below / above this surface to guarantee a minimum shell thickness. ExPolygons shell; - ExPolygons fill_shell; + ExPolygons fill_shell; // for nb_perimeter_layers_for_solid_fill ExPolygons max_perimeter_shell; // for nb_perimeter_layers_for_solid_fill ExPolygons holes; #ifdef SLIC3R_DEBUG_SLICE_PROCESSING @@ -2043,9 +2047,9 @@ bool PrintObject::invalidate_state_by_config_options( shell = intersection_ex(shell, polygonsInternal, ApplySafetyOffset::Yes); expolygons_append(shell, diff_ex(polygonsInternal, holes)); shell = union_ex(shell); - ExPolygons toadd; //check if a polygon is only over perimeter, in this case evict it (depends from nb_perimeter_layers_for_solid_fill value) if (nb_perimeter_layers_for_solid_fill != 0 && (idx_layer > min_layer_no_solid || layer->print_z < min_z_no_solid)) { + ExPolygons toadd; for (int i = 0; i < shell.size(); i++) { if (nb_perimeter_layers_for_solid_fill < 2 || intersection_ex(ExPolygons{ shell[i] }, max_perimeter_shell, ApplySafetyOffset::No).empty()) { ExPolygons expoly = intersection_ex(ExPolygons{ shell[i] }, fill_shell); diff --git a/src/libslic3r/Surface.cpp b/src/libslic3r/Surface.cpp index e36d340c2..0dcacafff 100644 --- a/src/libslic3r/Surface.cpp +++ b/src/libslic3r/Surface.cpp @@ -143,4 +143,53 @@ bool export_to_svg(const char *path, const Surfaces &surfaces, const float trans return true; } + +std::string surfaceType_to_string(SurfaceType st) +{ + std::string str; + if ((st & stPosTop) != 0) + str += "posTop"; + if ((st & stPosBottom) != 0) { + if (!str.empty()) + str += "||"; + str += "posBottom"; + } + if ((st & stPosInternal) != 0) { + if (!str.empty()) + str += "||"; + str += "posInternal"; + } + if ((st & stPosPerimeter) != 0) { + if (!str.empty()) + str += "||"; + str += "posPerimeter"; + } + if ((st & stDensSolid) != 0) { + if (!str.empty()) + str += "||"; + str += "densSolid"; + } + if ((st & stDensSparse) != 0) { + if (!str.empty()) + str += "||"; + str += "densSparse"; + } + if ((st & stDensVoid) != 0) { + if (!str.empty()) + str += "||"; + str += "densVoid"; + } + if ((st & stModBridge) != 0) { + if (!str.empty()) + str += "||"; + str += "modBridge"; + } + if ((st & stModOverBridge) != 0) { + if (!str.empty()) + str += "||"; + str += "modOverBridge"; + } + return str.empty() ? "none" : str; +} + } diff --git a/src/libslic3r/Surface.hpp b/src/libslic3r/Surface.hpp index e12e15056..764399033 100644 --- a/src/libslic3r/Surface.hpp +++ b/src/libslic3r/Surface.hpp @@ -52,6 +52,7 @@ inline SurfaceType operator&=(SurfaceType& a, SurfaceType b) { //inline bool operator!=(SurfaceType a, SurfaceType b) { // return static_cast(a) ^ static_cast(b) != 0; //} +std::string surfaceType_to_string(SurfaceType st); class Surface -- cgit v1.2.3