diff --git a/src/libslic3r/Layer.cpp b/src/libslic3r/Layer.cpp index 399833c699..4ac64b7775 100644 --- a/src/libslic3r/Layer.cpp +++ b/src/libslic3r/Layer.cpp @@ -121,7 +121,6 @@ void Layer::make_perimeters() for (LayerRegionPtrs::const_iterator it = layerm + 1; it != m_regions.end(); ++it) { LayerRegion* other_layerm = *it; const PrintRegionConfig &other_config = other_layerm->region()->config(); - if (config.perimeter_extruder == other_config.perimeter_extruder && config.perimeters == other_config.perimeters && config.perimeter_speed == other_config.perimeter_speed @@ -130,7 +129,8 @@ void Layer::make_perimeters() && config.overhangs == other_config.overhangs && config.opt_serialize("perimeter_extrusion_width") == other_config.opt_serialize("perimeter_extrusion_width") && config.thin_walls == other_config.thin_walls - && config.external_perimeters_first == other_config.external_perimeters_first) { + && config.external_perimeters_first == other_config.external_perimeters_first + && config.infill_overlap == other_config.infill_overlap) { layerms.push_back(other_layerm); done[it - m_regions.begin()] = true; } @@ -142,12 +142,17 @@ void Layer::make_perimeters() (*layerm)->fill_expolygons = to_expolygons((*layerm)->fill_surfaces.surfaces); } else { SurfaceCollection new_slices; + // Use the region with highest infill rate, as the make_perimeters() function below decides on the gap fill based on the infill existence. + LayerRegion *layerm_config = layerms.front(); { // group slices (surfaces) according to number of extra perimeters std::map slices; // extra_perimeters => [ surface, surface... ] - for (LayerRegion *layerm : layerms) + for (LayerRegion *layerm : layerms) { for (Surface &surface : layerm->slices.surfaces) slices[surface.extra_perimeters].emplace_back(surface); + if (layerm->region()->config().fill_density > layerm_config->region()->config().fill_density) + layerm_config = layerm; + } // merge the surfaces assigned to each group for (std::pair &surfaces_with_extra_perimeters : slices) new_slices.append(union_ex(surfaces_with_extra_perimeters.second, true), surfaces_with_extra_perimeters.second.front()); @@ -155,7 +160,7 @@ void Layer::make_perimeters() // make perimeters SurfaceCollection fill_surfaces; - (*layerm)->make_perimeters(new_slices, &fill_surfaces); + layerm_config->make_perimeters(new_slices, &fill_surfaces); // assign fill_surfaces to each layer if (!fill_surfaces.surfaces.empty()) { diff --git a/src/libslic3r/PerimeterGenerator.cpp b/src/libslic3r/PerimeterGenerator.cpp index 4dac192adc..74df07935f 100644 --- a/src/libslic3r/PerimeterGenerator.cpp +++ b/src/libslic3r/PerimeterGenerator.cpp @@ -37,7 +37,8 @@ void PerimeterGenerator::process() // internal flow which is unrelated. coord_t min_spacing = perimeter_spacing * (1 - INSET_OVERLAP_TOLERANCE); coord_t ext_min_spacing = ext_perimeter_spacing * (1 - INSET_OVERLAP_TOLERANCE); - + bool has_gap_fill = this->config->gap_fill_speed.value > 0; + // prepare grown lower layer slices for overhang detection if (this->lower_slices != NULL && this->config->overhangs) { // We consider overhang any part where the entire nozzle diameter is not supported by the @@ -105,7 +106,7 @@ void PerimeterGenerator::process() // leads to overflows, as in prusa3d/Slic3r GH #32 offset_ex(last, - distance); // look for gaps - if (this->config->gap_fill_speed.value > 0 && this->config->fill_density.value > 0) + if (has_gap_fill) // not using safety offset here would "detect" very narrow gaps // (but still long enough to escape the area threshold) that gap fill // won't be able to fill but we'd still remove from infill area @@ -132,6 +133,11 @@ void PerimeterGenerator::process() } } last = std::move(offsets); + if (i == loop_number && (! has_gap_fill || this->config->fill_density.value == 0)) { + // The last run of this loop is executed to collect gaps for gap fill. + // As the gap fill is either disabled or not + break; + } } // nest loops: holes first diff --git a/src/slic3r/GUI/ConfigManipulation.cpp b/src/slic3r/GUI/ConfigManipulation.cpp index 2f37eb8946..c9cdff1628 100644 --- a/src/slic3r/GUI/ConfigManipulation.cpp +++ b/src/slic3r/GUI/ConfigManipulation.cpp @@ -243,7 +243,8 @@ void ConfigManipulation::toggle_print_fff_options(DynamicPrintConfig* config) "infill_speed", "bridge_speed" }) toggle_field(el, have_infill || have_solid_infill); - toggle_field("gap_fill_speed", have_perimeters && have_infill); + // Gap fill is newly allowed in between perimeter lines even for empty infill (see GH #1476). + toggle_field("gap_fill_speed", have_perimeters); bool have_top_solid_infill = config->opt_int("top_solid_layers") > 0; for (auto el : { "top_infill_extrusion_width", "top_solid_infill_speed" })