Skip to content

Commit

Permalink
Fix thinwalls/fill with gapfill
Browse files Browse the repository at this point in the history
Also make fills with gapfill follow the min/max width & length values for gapfill.
  • Loading branch information
supermerill committed Aug 9, 2022
1 parent cd8ee42 commit 038a273
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
29 changes: 26 additions & 3 deletions src/libslic3r/Fill/FillConcentric.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,24 @@ FillConcentricWGapFill::fill_surface_extrusion(

//add gapfills
if (!gaps.empty() && params.density >= 1) {
// collapse
// get parameters
coordf_t min = 0.2 * distance * (1 - INSET_OVERLAP_TOLERANCE);
coordf_t max = 2. * distance;
//be sure we don't gapfill where the perimeters are already touching each other (negative spacing).
min = std::max(min, double(Flow::new_from_spacing((float)EPSILON, (float)params.flow.nozzle_diameter(), (float)params.flow.height(), (float)params.flow.spacing_ratio(), false).scaled_width()));
coordf_t real_max = 2.5 * distance;
const coordf_t minwidth = scale_d(params.config->get_abs_value("gap_fill_min_width", params.flow.width()));
const coordf_t maxwidth = scale_d(params.config->get_abs_value("gap_fill_max_width", params.flow.width()));
const coord_t minlength = scale_t(params.config->get_abs_value("gap_fill_min_length", params.flow.width()));
if (minwidth > 0) {
min = std::max(min, minwidth);
}
coordf_t max = real_max;
if (maxwidth > 0) {
max = std::min(max, maxwidth);
}
const coord_t gapfill_extension = scale_t(params.config->get_abs_value("gap_fill_extension", params.flow.width()));

// collapse
ExPolygons gaps_ex = diff_ex(
offset2_ex(gaps, -min / 2, +min / 2),
offset2_ex(gaps, -max / 2, +max / 2),
Expand All @@ -153,7 +168,15 @@ FillConcentricWGapFill::fill_surface_extrusion(
//remove too small gaps that are too hard to fill.
//ie one that are smaller than an extrusion with width of min and a length of max.
if (ex.area() > min_gapfill_area) {
Geometry::MedialAxis{ ex, coord_t(max), coord_t(min), scale_t(params.flow.height()) }.build(polylines);
Geometry::MedialAxis md{ ex, coord_t(real_max), coord_t(min), scale_t(params.flow.height()) };
if (minlength > 0) {
md.set_min_length(minlength);
}
if (gapfill_extension > 0) {
md.set_extension_length(gapfill_extension);
}
md.set_biggest_width(max);
md.build(polylines);
}
}
if (!polylines.empty() && !is_bridge(good_role)) {
Expand Down
1 change: 1 addition & 0 deletions src/libslic3r/Geometry/MedialAxis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2008,6 +2008,7 @@ MedialAxis::remove_too_thin_extrusion(ThickPolylines& pp)
void
MedialAxis::remove_too_thick_extrusion(ThickPolylines& pp)
{
if (this->m_biggest_width <= 0) return;
// remove too thin extrusion at start & end of polylines
bool changes = false;
for (size_t i = 0; i < pp.size(); ++i) {
Expand Down

0 comments on commit 038a273

Please sign in to comment.