From 5c46a60f33d4035a3e77bdf95e256ccab28b4531 Mon Sep 17 00:00:00 2001 From: supermerill Date: Fri, 1 Nov 2019 22:52:29 +0100 Subject: [PATCH] more perimeters on overhangs: don't allow on top of holes #46 #112 --- src/libslic3r/ExPolygon.hpp | 22 ++++++++++++++++++++++ src/libslic3r/PerimeterGenerator.cpp | 6 +++++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/libslic3r/ExPolygon.hpp b/src/libslic3r/ExPolygon.hpp index dce032cf7..3240104ea 100644 --- a/src/libslic3r/ExPolygon.hpp +++ b/src/libslic3r/ExPolygon.hpp @@ -80,6 +80,28 @@ inline size_t number_polygons(const ExPolygons &expolys) return n_polygons; } + +inline ExPolygon to_expolygon(const Polygon &other) +{ + ExPolygon ex; + ex.contour = other; + return ex; +} + +inline ExPolygon to_expolygon(Polygon &&other) +{ + ExPolygon ex; + ex.contour = std::move(other); + return ex; +} + +inline ExPolygons to_expolygon(const Polygons &other) +{ + ExPolygons exs; + for (const Polygon &po : other) exs.emplace_back(to_expolygon(po)); + return exs; +} + inline Lines to_lines(const ExPolygon &src) { size_t n_lines = src.contour.points.size(); diff --git a/src/libslic3r/PerimeterGenerator.cpp b/src/libslic3r/PerimeterGenerator.cpp index 302023d63..012ace35e 100644 --- a/src/libslic3r/PerimeterGenerator.cpp +++ b/src/libslic3r/PerimeterGenerator.cpp @@ -293,7 +293,11 @@ void PerimeterGenerator::process() ExPolygons overhangs_unsupported; if (this->config->extra_perimeters && !last.empty() && this->lower_slices != NULL && !this->lower_slices->expolygons.empty()) { - overhangs_unsupported = diff_ex(last, this->lower_slices->expolygons); + //remove holes from lower layer, we only ant that for overhangs, not bridges! + ExPolygons lower_without_holes; + for (const ExPolygon &exp : this->lower_slices->expolygons) + lower_without_holes.emplace_back(to_expolygon(exp.contour)); + overhangs_unsupported = diff_ex(last, lower_without_holes); if (!overhangs_unsupported.empty()) { //only consider overhangs and let bridges alone //only consider the part that can be bridged (really, by the bridge algorithm)