Fix of #8488 - Infinite loop in the lightning infill.

This commit is contained in:
Lukáš Hejl 2022-07-12 18:59:02 +02:00
parent 92f874cdea
commit 22255822a2
3 changed files with 6 additions and 3 deletions

View File

@ -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. 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 #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<DistanceField::UnsupportedCell> &unsupported_points, const Points &points = {}) void export_distance_field_to_svg(const std::string &path, const Polygons &outline, const Polygons &overhang, const std::vector<DistanceField::UnsupportedCell> &unsupported_points, const Points &points = {})
{ {
coordf_t stroke_width = scaled<coordf_t>(0.01); coordf_t stroke_width = scaled<coordf_t>(0.01);
BoundingBox bbox = get_extents(outline); BoundingBox bbox = get_extents(outline);

View File

@ -200,7 +200,7 @@ protected:
} }
#ifdef LIGHTNING_DISTANCE_FIELD_DEBUG_OUTPUT #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<DistanceField::UnsupportedCell> &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<DistanceField::UnsupportedCell> &unsupported_points, const Points &points);
#endif #endif
}; };

View File

@ -66,10 +66,11 @@ void Generator::generateInitialInternalOverhangs(const PrintObject &print_object
if (surface.surface_type == stInternal || surface.surface_type == stInternalVoid) if (surface.surface_type == stInternal || surface.surface_type == stInternalVoid)
append(infill_area_here, to_polygons(surface.expolygon)); 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. // 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); 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). // 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; m_overhang_per_layer[layer_nr] = overhang;
infill_area_above = std::move(infill_area_here); 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) for (const Surface &surface : layerm->fill_surfaces.surfaces)
if (surface.surface_type == stInternal || surface.surface_type == stInternalVoid) if (surface.surface_type == stInternal || surface.surface_type == stInternalVoid)
append(infill_outlines[layer_id], to_polygons(surface.expolygon)); 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: // For various operations its beneficial to quickly locate nearby features on the polygon: