Skip to content

Commit

Permalink
Fix of #8488 - Infinite loop in the lightning infill.
Browse files Browse the repository at this point in the history
  • Loading branch information
hejllukas committed Jul 12, 2022
1 parent 92f874c commit 2225582
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/libslic3r/Fill/Lightning/DistanceField.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<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);
BoundingBox bbox = get_extents(outline);
Expand Down
2 changes: 1 addition & 1 deletion src/libslic3r/Fill/Lightning/DistanceField.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ class DistanceField
}

#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
};

Expand Down
5 changes: 4 additions & 1 deletion src/libslic3r/Fill/Lightning/Generator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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:
Expand Down

0 comments on commit 2225582

Please sign in to comment.