FIX: endless loop when slicing

1.In some cases, arachne will generate path with self-intersections, this
may cause clipper function to enter an endless loop. Do self intersect before
doing clipper function

jira: STUDIO-12232

Signed-off-by: xun.zhang <xun.zhang@bambulab.com>
Change-Id: I6af901e219558356fdf3c853ca31e0fe6271e3a3
This commit is contained in:
xun.zhang 2025-05-17 19:03:03 +08:00 committed by lane.wei
parent fd990199fd
commit f2304fe1fc

View File

@ -5,6 +5,7 @@
#include "../Surface.hpp"
#include "../VariableWidth.hpp"
#include "../format.hpp"
#include "../EdgeGrid.hpp"
#include "FillFloatingConcentric.hpp"
#include <boost/log/trivial.hpp>
#include <libslic3r/ShortestPath.hpp>
@ -686,7 +687,19 @@ FloatingThickPolylines FillFloatingConcentric::resplit_order_loops(Point curr_po
if (all_extrusions[idx]->empty())
continue;
ThickPolyline thick_polyline = Arachne::to_thick_polyline(*all_extrusions[idx]);
FloatingThickPolyline thick_line_with_floating = detect_floating_line(thick_polyline, floating_areas, default_width, !print_object_config->detect_floating_vertical_shell.value);
bool is_self_intersect = false;
if(print_object_config->detect_floating_vertical_shell.value)
{
Polyline polyline = thick_polyline;
auto bbox_line = get_extents(polyline);
EdgeGrid::Grid grid;
grid.set_bbox(bbox_line);
grid.create({ polyline.points }, scaled<coord_t>(10.), !all_extrusions[idx]->is_closed);
if (grid.has_intersecting_edges())
is_self_intersect = true;
}
FloatingThickPolyline thick_line_with_floating = detect_floating_line(thick_polyline, floating_areas, default_width, !print_object_config->detect_floating_vertical_shell.value || is_self_intersect);
smooth_floating_line(thick_line_with_floating, scale_(2), scale_(2));
int split_idx = 0;
if (!floating_areas.empty() && all_extrusions[idx]->is_closed && thick_line_with_floating.points.front() == thick_line_with_floating.points.back()) {