SPE-1728 Fix external bridges expansion - allow expansion into top solid

Github issue: https://github.com/prusa3d/PrusaSlicer/issues/10493
This commit is contained in:
Pavel Mikus 2023-05-23 16:05:11 +02:00
parent 0d1ff6df7d
commit b1c0bf17af

View File

@ -10,6 +10,7 @@
#include "SVG.hpp" #include "SVG.hpp"
#include "Algorithm/RegionExpansion.hpp" #include "Algorithm/RegionExpansion.hpp"
#include <algorithm>
#include <string> #include <string>
#include <map> #include <map>
@ -143,12 +144,12 @@ void LayerRegion::make_perimeters(
#if 1 #if 1
// Extract surfaces of given type from surfaces, extract fill (layer) thickness of one of the surfaces. // Extract surfaces of given type from surfaces, extract fill (layer) thickness of one of the surfaces.
static ExPolygons fill_surfaces_extract_expolygons(Surfaces &surfaces, SurfaceType surface_type, double &thickness) static ExPolygons fill_surfaces_extract_expolygons(Surfaces &surfaces, std::initializer_list<SurfaceType> surface_types, double &thickness)
{ {
size_t cnt = 0; size_t cnt = 0;
for (const Surface &surface : surfaces) for (const Surface &surface : surfaces)
if (surface.surface_type == surface_type) { if (std::find(surface_types.begin(), surface_types.end(), surface.surface_type) != surface_types.end()) {
++ cnt; ++cnt;
thickness = surface.thickness; thickness = surface.thickness;
} }
if (cnt == 0) if (cnt == 0)
@ -157,7 +158,7 @@ static ExPolygons fill_surfaces_extract_expolygons(Surfaces &surfaces, SurfaceTy
ExPolygons out; ExPolygons out;
out.reserve(cnt); out.reserve(cnt);
for (Surface &surface : surfaces) for (Surface &surface : surfaces)
if (surface.surface_type == surface_type) if (std::find(surface_types.begin(), surface_types.end(), surface.surface_type) != surface_types.end())
out.emplace_back(std::move(surface.expolygon)); out.emplace_back(std::move(surface.expolygon));
return out; return out;
} }
@ -173,7 +174,7 @@ Surfaces expand_bridges_detect_orientations(
using namespace Slic3r::Algorithm; using namespace Slic3r::Algorithm;
double thickness; double thickness;
ExPolygons bridges_ex = fill_surfaces_extract_expolygons(surfaces, stBottomBridge, thickness); ExPolygons bridges_ex = fill_surfaces_extract_expolygons(surfaces, {stBottomBridge}, thickness);
if (bridges_ex.empty()) if (bridges_ex.empty())
return {}; return {};
@ -329,7 +330,7 @@ static Surfaces expand_merge_surfaces(
const double bridge_angle = -1.) const double bridge_angle = -1.)
{ {
double thickness; double thickness;
ExPolygons src = fill_surfaces_extract_expolygons(surfaces, surface_type, thickness); ExPolygons src = fill_surfaces_extract_expolygons(surfaces, {surface_type}, thickness);
if (src.empty()) if (src.empty())
return {}; return {};
@ -375,7 +376,7 @@ void LayerRegion::process_external_surfaces(const Layer *lower_layer, const Poly
// Expand the top / bottom / bridge surfaces into the shell thickness solid infills. // Expand the top / bottom / bridge surfaces into the shell thickness solid infills.
double layer_thickness; double layer_thickness;
ExPolygons shells = union_ex(fill_surfaces_extract_expolygons(m_fill_surfaces.surfaces, stInternalSolid, layer_thickness)); ExPolygons shells = union_ex(fill_surfaces_extract_expolygons(m_fill_surfaces.surfaces, {stInternalSolid, stTop}, layer_thickness));
SurfaceCollection bridges; SurfaceCollection bridges;
{ {