From 61d82b02b527066803584bc3bcfd3da852caebab Mon Sep 17 00:00:00 2001 From: bubnikv Date: Fri, 4 Nov 2016 00:55:43 +0100 Subject: [PATCH] Improves https://github.com/prusa3d/Slic3r/issues/3 Limits the length of an infill connecting segment of a solid infill to 3x the solid infill spacing. --- xs/src/libslic3r/Fill/Fill.cpp | 11 ++++--- xs/src/libslic3r/PrintObject.cpp | 53 +++++++++++++++++++++++--------- 2 files changed, 45 insertions(+), 19 deletions(-) diff --git a/xs/src/libslic3r/Fill/Fill.cpp b/xs/src/libslic3r/Fill/Fill.cpp index 940ff4f25..bcfed56f0 100644 --- a/xs/src/libslic3r/Fill/Fill.cpp +++ b/xs/src/libslic3r/Fill/Fill.cpp @@ -196,19 +196,22 @@ void make_fill(LayerRegion &layerm, ExtrusionEntityCollection &out) *layerm.layer()->object() ); f->spacing = internal_flow.spacing(); - using_internal_flow = 1; + using_internal_flow = true; } else { f->spacing = flow.spacing(); } double link_max_length = 0.; -#if 0 if (! is_bridge) { +#if 0 link_max_length = layerm.region()->config.get_abs_value(surface.is_external() ? "external_fill_link_max_length" : "fill_link_max_length", flow.spacing()); // printf("flow spacing: %f, is_external: %d, link_max_length: %lf\n", flow.spacing(), int(surface.is_external()), link_max_length); - } +#else + if (density > 80.) // 80% + link_max_length = 3. * f->spacing; #endif - + } + f->layer_id = layerm.layer()->id(); f->z = layerm.layer()->print_z; f->angle = Geometry::deg2rad(layerm.region()->config.fill_angle.value); diff --git a/xs/src/libslic3r/PrintObject.cpp b/xs/src/libslic3r/PrintObject.cpp index b83b785a5..8fbbf8c3e 100644 --- a/xs/src/libslic3r/PrintObject.cpp +++ b/xs/src/libslic3r/PrintObject.cpp @@ -380,13 +380,6 @@ PrintObject::discover_vertical_shells() } #endif /* SLIC3R_DEBUG_SLICE_PROCESSING */ shell = union_(shell, true); - if (! shell.empty()) { - // These regions will be filled by a rectilinear full infill. Currently this type of infill - // will only fill regions, which will fit at least a single line. To avoid gaps in the sparse infill, - // make sure that this region does not contain narrow parts. - coord_t min_perimeter_infill_spacing = coord_t(double(infill_line_spacing) * (1. - INSET_OVERLAP_TOLERANCE)); - shell = offset2(shell, -min_perimeter_infill_spacing/2, min_perimeter_infill_spacing/2); - } #ifdef SLIC3R_DEBUG_SLICE_PROCESSING shell_ex = union_ex(shell, true); #endif /* SLIC3R_DEBUG_SLICE_PROCESSING */ @@ -435,7 +428,44 @@ PrintObject::discover_vertical_shells() } #endif /* SLIC3R_DEBUG_SLICE_PROCESSING */ - // Trim the internal & internalvoid by the $shell. + // Trim the shells region by the internal & internal void surfaces. + const SurfaceType surfaceTypesInternal[] = { stInternal, stInternalVoid }; + const Polygons polygonsInternal = to_polygons(layerm->fill_surfaces.filter_by_types(surfaceTypesInternal, 2)); + shell = intersection(shell, polygonsInternal, true); + if (shell.empty()) + continue; + + // These regions will be filled by a rectilinear full infill. Currently this type of infill + // only fills regions, which fit at least a single line. To avoid gaps in the sparse infill, + // make sure that this region does not contain parts narrower than the infill spacing width. + float min_perimeter_infill_spacing = float(infill_line_spacing) * 1.05f; +#ifdef SLIC3R_DEBUG_SLICE_PROCESSING + Polygons shell_before = shell; +#endif /* SLIC3R_DEBUG_SLICE_PROCESSING */ + // Intentionally inflate a bit more than how much the region has been shrunk, + // so there will be some overlap between this solid infill and the other infill regions (mainly the sparse infill). + shell = offset2(shell, - 0.5f * min_perimeter_infill_spacing, 0.8f * min_perimeter_infill_spacing, + CLIPPER_OFFSET_SCALE, ClipperLib::jtSquare); + if (shell.empty()) + continue; + ExPolygons new_internal_solid = intersection_ex(polygonsInternal, shell, false); +#ifdef SLIC3R_DEBUG_SLICE_PROCESSING + { + static size_t idx = 0; + SVG svg(debug_out_path("discover_vertical_shells-regularized-%d.svg", idx ++), get_extents(shell_before)); + // Source shell. + svg.draw(union_ex(shell_before, true)); + // Shell trimmed to the internal surfaces. + svg.draw_outline(union_ex(shell, true), "black", "blue", scale_(0.05)); + // Regularized infill region. + svg.draw_outline(new_internal_solid, "red", "magenta", scale_(0.05)); + svg.Close(); + } +#endif /* SLIC3R_DEBUG_SLICE_PROCESSING */ + + // Trim the internal & internalvoid by the shell. + // Enforce some overlap with the other infill regions. + shell = offset(shell, - 0.25f * min_perimeter_infill_spacing); Slic3r::ExPolygons new_internal = diff_ex( to_polygons(layerm->fill_surfaces.filter_by_type(stInternal)), shell, @@ -446,13 +476,6 @@ PrintObject::discover_vertical_shells() shell, false ); - // Add shells tstInternalVoido internal & internalvoid. - const SurfaceType surfaceTypesInternal[] = { stInternal, stInternalVoid }; - Slic3r::ExPolygons new_internal_solid = intersection_ex( - to_polygons(layerm->fill_surfaces.filter_by_types(surfaceTypesInternal, 2)), - shell, - true - ); #ifdef SLIC3R_DEBUG_SLICE_PROCESSING {