From 7d4f090786d93963723aba130250706773d9c373 Mon Sep 17 00:00:00 2001 From: supermerill Date: Mon, 11 Feb 2019 14:02:13 +0100 Subject: [PATCH] medial_axis width bugfix (at least enough for the outer "lobes") assert bugfix in thin walls (edge case) 2 bugfix in overlap --- src/libslic3r/Layer.cpp | 3 ++- src/libslic3r/MedialAxis.cpp | 13 ++++++++----- src/libslic3r/PerimeterGenerator.cpp | 5 +++-- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/libslic3r/Layer.cpp b/src/libslic3r/Layer.cpp index fdf4e1c0c..91170ecdd 100644 --- a/src/libslic3r/Layer.cpp +++ b/src/libslic3r/Layer.cpp @@ -20,7 +20,7 @@ Layer::~Layer() // Test whether whether there are any slices assigned to this layer. bool Layer::empty() const { - for (const LayerRegion *layerm : m_regions) + for (const LayerRegion *layerm : m_regions) if (layerm != nullptr && ! layerm->slices.empty()) // Non empty layer. return false; @@ -149,6 +149,7 @@ void Layer::make_perimeters() // Separate the fill surfaces. ExPolygons expp = intersection_ex(to_polygons(fill_surfaces), (*l)->slices); (*l)->fill_expolygons = expp; + (*l)->fill_no_overlap_expolygons = (*layerm)->fill_no_overlap_expolygons; (*l)->fill_surfaces.set(std::move(expp), fill_surfaces.surfaces.front()); } } diff --git a/src/libslic3r/MedialAxis.cpp b/src/libslic3r/MedialAxis.cpp index 2fc9476b7..0a3a3a8de 100644 --- a/src/libslic3r/MedialAxis.cpp +++ b/src/libslic3r/MedialAxis.cpp @@ -1513,7 +1513,7 @@ MedialAxis::grow_to_nozzle_diameter(ThickPolylines& pp, const ExPolygons& anchor void MedialAxis::taper_ends(ThickPolylines& pp) { - const coord_t min_size = this->nozzle_diameter * 0.1; + const coord_t min_size = std::min(this->nozzle_diameter * 0.1, this->height * (1. - 0.25 * PI)); const coordf_t length = std::min(this->anchor_size, (this->nozzle_diameter - min_size) / 2); if (length <= SCALED_RESOLUTION) return; //ensure the width is not lower than 0.4. @@ -1623,12 +1623,15 @@ ExtrusionEntityCollection thin_variable_width(const ThickPolylines &polylines, E if (path.polyline.points.empty()) { path.polyline.append(line.a); path.polyline.append(line.b); - if (role == erGapFill){ + if (role == erGapFill) { // Convert from spacing to extrusion width based on the extrusion model // of a square extrusion ended with semi circles. - flow.width = (float)unscaled(line.a_width) + flow.height * (1. - 0.25 * PI); - }else{ - flow.width = (float)unscaled(line.a_width); + flow.width = unscale(line.a_width) + flow.height * (1. - 0.25 * PI); + } else if (unscale(line.a_width) < 2 * flow.height * (1. - 0.25 * PI)) { + double percent = unscale(line.a_width) / (2 * flow.height * (1. - 0.25 * PI)); + flow.width = unscale(line.a_width)/2 + flow.height * (1. - 0.25 * PI); + } else { + flow.width = unscale(line.a_width); } #ifdef SLIC3R_DEBUG printf(" filling %f gap\n", flow.width); diff --git a/src/libslic3r/PerimeterGenerator.cpp b/src/libslic3r/PerimeterGenerator.cpp index ef1330e5a..31cb83a01 100644 --- a/src/libslic3r/PerimeterGenerator.cpp +++ b/src/libslic3r/PerimeterGenerator.cpp @@ -282,7 +282,8 @@ void PerimeterGenerator::process() for (ExPolygon &half_thin : half_thins) { //growing back the polygon ExPolygons thin = offset_ex(half_thin, (float)(min_width / 2)); - assert(thin.size() == 1); + assert(thin.size() <= 1); + if (thin.empty()) continue; coord_t overlap = (coord_t)scale_(this->config->thin_walls_overlap.get_abs_value(this->ext_perimeter_flow.nozzle_diameter)); ExPolygons anchor = intersection_ex(offset_ex(half_thin, (float)(min_width / 2) + (float)(overlap), jtSquare), no_thin_zone, true); @@ -514,7 +515,7 @@ void PerimeterGenerator::process() // only apply infill overlap if we actually have one perimeter coord_t overlap = 0; if (inset > 0) { - overlap = scale_(this->config->get_abs_value("infill_overlap", unscale(inset + solid_infill_spacing / 2))); + overlap = scale_(this->config->get_abs_value("infill_overlap", unscale(inset + solid_infill_spacing / 2))); } // simplify infill contours according to resolution Polygons pp;