From 4a25b3e8befc119e7dad880ec4473a6ea460d28b Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Wed, 21 Dec 2016 15:39:07 +0100 Subject: [PATCH] Fix infill_overlap and endpoints_overlap not being linked and not considering both perimeter and infill extrusion width (thus causing potential overflows). #3289 --- xs/src/libslic3r/Fill/FillRectilinear.cpp | 9 +++------ xs/src/libslic3r/LayerRegionFill.cpp | 3 +++ xs/src/libslic3r/PerimeterGenerator.cpp | 4 ---- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/xs/src/libslic3r/Fill/FillRectilinear.cpp b/xs/src/libslic3r/Fill/FillRectilinear.cpp index 5fcb779cf7..286b1a5506 100644 --- a/xs/src/libslic3r/Fill/FillRectilinear.cpp +++ b/xs/src/libslic3r/Fill/FillRectilinear.cpp @@ -283,9 +283,6 @@ FillRectilinear::_fill_single_direction(ExPolygon expolygon, svg.Close(); #endif - // Calculate the extension of the vertical endpoints according to the configured value. - const coord_t extra_y = floor((double)min_spacing * this->endpoints_overlap + 0.5f); - // Store the number of polygons already existing in the output container. const size_t n_polylines_out_old = out->size(); @@ -313,7 +310,7 @@ FillRectilinear::_fill_single_direction(ExPolygon expolygon, // Start our polyline. Polyline polyline; polyline.append(p); - polyline.points.back().y -= extra_y; + polyline.points.back().y -= this->endpoints_overlap; while (true) { // Complete the vertical line by finding the corresponding upper or lower point. @@ -331,7 +328,7 @@ FillRectilinear::_fill_single_direction(ExPolygon expolygon, IntersectionPoint b = it->second; assert(b.type != p.type); polyline.append(b); - polyline.points.back().y += extra_y * (b.type == IntersectionPoint::ipTypeUpper ? 1 : -1); + polyline.points.back().y += this->endpoints_overlap * (b.type == IntersectionPoint::ipTypeUpper ? 1 : -1); // Remove the two endpoints of this vertical line from the grid. { @@ -359,7 +356,7 @@ FillRectilinear::_fill_single_direction(ExPolygon expolygon, const size_t n = polyline.points.size(); polyline.append(b.next); for (Points::iterator pit = polyline.points.begin()+n; pit != polyline.points.end(); ++pit) - pit->y += extra_y * (b.type == IntersectionPoint::ipTypeUpper ? 1 : -1); + pit->y += this->endpoints_overlap * (b.type == IntersectionPoint::ipTypeUpper ? 1 : -1); } // Is the final point still available? diff --git a/xs/src/libslic3r/LayerRegionFill.cpp b/xs/src/libslic3r/LayerRegionFill.cpp index c5b806542e..142e4758f0 100644 --- a/xs/src/libslic3r/LayerRegionFill.cpp +++ b/xs/src/libslic3r/LayerRegionFill.cpp @@ -34,6 +34,7 @@ LayerRegion::make_fill() const Flow infill_flow = this->flow(frInfill); const Flow solid_infill_flow = this->flow(frSolidInfill); const Flow top_solid_infill_flow = this->flow(frTopSolidInfill); + const coord_t perimeter_spacing = this->flow(frPerimeter).scaled_spacing(); SurfaceCollection surfaces; @@ -215,6 +216,8 @@ LayerRegion::make_fill() } else { f->spacing = flow.spacing(); } + f->endpoints_overlap = this->region()->config.get_abs_value("infill_overlap", + (perimeter_spacing + scale_(f->spacing))/2); f->layer_id = this->layer()->id(); f->z = this->layer()->print_z; diff --git a/xs/src/libslic3r/PerimeterGenerator.cpp b/xs/src/libslic3r/PerimeterGenerator.cpp index d2ed60aaf4..83056e8686 100644 --- a/xs/src/libslic3r/PerimeterGenerator.cpp +++ b/xs/src/libslic3r/PerimeterGenerator.cpp @@ -298,10 +298,6 @@ PerimeterGenerator::process() inset += pspacing/2; } - // only apply infill overlap if we actually have one perimeter - if (inset > 0) - inset -= this->config->get_abs_value("infill_overlap", inset + ispacing/2); - { ExPolygons expp = union_ex(last);