From 22255822a22399b15d1096868a9e2ae9d64f4e9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Hejl?= Date: Tue, 12 Jul 2022 18:59:02 +0200 Subject: [PATCH] Fix of #8488 - Infinite loop in the lightning infill. --- src/libslic3r/Fill/Lightning/DistanceField.cpp | 2 +- src/libslic3r/Fill/Lightning/DistanceField.hpp | 2 +- src/libslic3r/Fill/Lightning/Generator.cpp | 5 ++++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/libslic3r/Fill/Lightning/DistanceField.cpp b/src/libslic3r/Fill/Lightning/DistanceField.cpp index 0cbfa9af5f..ad1a85ac65 100644 --- a/src/libslic3r/Fill/Lightning/DistanceField.cpp +++ b/src/libslic3r/Fill/Lightning/DistanceField.cpp @@ -17,7 +17,7 @@ namespace Slic3r::FillLightning constexpr coord_t radius_per_cell_size = 6; // The cell-size should be small compared to the radius, but not so small as to be inefficient. #ifdef LIGHTNING_DISTANCE_FIELD_DEBUG_OUTPUT -void export_distance_field_to_svg(const std::string &path, const Polygons &outline, const Polygons &overhang, const std::list &unsupported_points, const Points &points = {}) +void export_distance_field_to_svg(const std::string &path, const Polygons &outline, const Polygons &overhang, const std::vector &unsupported_points, const Points &points = {}) { coordf_t stroke_width = scaled(0.01); BoundingBox bbox = get_extents(outline); diff --git a/src/libslic3r/Fill/Lightning/DistanceField.hpp b/src/libslic3r/Fill/Lightning/DistanceField.hpp index 007ac235e5..6e72243841 100644 --- a/src/libslic3r/Fill/Lightning/DistanceField.hpp +++ b/src/libslic3r/Fill/Lightning/DistanceField.hpp @@ -200,7 +200,7 @@ protected: } #ifdef LIGHTNING_DISTANCE_FIELD_DEBUG_OUTPUT - friend void export_distance_field_to_svg(const std::string &path, const Polygons &outline, const Polygons &overhang, const std::list &unsupported_points, const Points &points); + friend void export_distance_field_to_svg(const std::string &path, const Polygons &outline, const Polygons &overhang, const std::vector &unsupported_points, const Points &points); #endif }; diff --git a/src/libslic3r/Fill/Lightning/Generator.cpp b/src/libslic3r/Fill/Lightning/Generator.cpp index ebd3afc0e1..48377f4277 100644 --- a/src/libslic3r/Fill/Lightning/Generator.cpp +++ b/src/libslic3r/Fill/Lightning/Generator.cpp @@ -66,10 +66,11 @@ void Generator::generateInitialInternalOverhangs(const PrintObject &print_object if (surface.surface_type == stInternal || surface.surface_type == stInternalVoid) append(infill_area_here, to_polygons(surface.expolygon)); + infill_area_here = union_(infill_area_here); // Remove the part of the infill area that is already supported by the walls. Polygons overhang = diff(offset(infill_area_here, -float(m_wall_supporting_radius)), infill_area_above); // Filter out unprintable polygons and near degenerated polygons (three almost collinear points and so). - overhang = opening(std::move(overhang), SCALED_EPSILON, SCALED_EPSILON); + overhang = opening(overhang, SCALED_EPSILON, SCALED_EPSILON); m_overhang_per_layer[layer_nr] = overhang; infill_area_above = std::move(infill_area_here); @@ -95,6 +96,8 @@ void Generator::generateTrees(const PrintObject &print_object, const std::functi for (const Surface &surface : layerm->fill_surfaces.surfaces) if (surface.surface_type == stInternal || surface.surface_type == stInternalVoid) append(infill_outlines[layer_id], to_polygons(surface.expolygon)); + + infill_outlines[layer_id] = union_(infill_outlines[layer_id]); } // For various operations its beneficial to quickly locate nearby features on the polygon: