Skip to content

Commit

Permalink
Partial revert to solve hang.
Browse files Browse the repository at this point in the history
The exact points are used as start and end-points later on to resolve the total begin/end of the entire loop. So, revert this small improvement that has little to nothing to do with the issue at hand itself.

done as part of CURA-10410
  • Loading branch information
rburema committed Aug 29, 2023
1 parent eea854c commit 1c1035f
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/infill.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -836,7 +836,6 @@ void Infill::connectLines(Polygons& result_lines)
}
}

constexpr coord_t epsilon_squared = 25;
const auto half_line_distance_squared = (line_distance * line_distance) / 4;
for (size_t polygon_index = 0; polygon_index < inner_contour.size(); polygon_index++)
{
Expand Down Expand Up @@ -898,8 +897,7 @@ void Infill::connectLines(Polygons& result_lines)

InfillLineSegment* new_segment;
// If the segment is near zero length, we avoid creating it but still want to connect the crossing with the previous segment.
const auto connect_distance_squared = vSize2(previous_point - next_point);
if (connect_distance_squared < epsilon_squared)
if (previous_point == next_point)
{
(previous_forward ? previous_segment->previous : previous_segment->next) = crossing;
new_segment = previous_segment;
Expand All @@ -908,7 +906,7 @@ void Infill::connectLines(Polygons& result_lines)
{
// Resolve any intersections of the fill lines close to the boundary, by inserting extra points so the lines don't create a tiny 'loop'.
Point intersect;
if (connect_distance_squared < half_line_distance_squared
if (vSize2(previous_point - next_point) < half_line_distance_squared
&& LinearAlg2D::lineLineIntersection(previous_segment->start, previous_segment->end, crossing->start, crossing->end, intersect)
&& LinearAlg2D::pointIsProjectedBeyondLine(intersect, previous_segment->start, previous_segment->end) == 0
&& LinearAlg2D::pointIsProjectedBeyondLine(intersect, crossing->start, crossing->end) == 0)
Expand Down Expand Up @@ -939,7 +937,7 @@ void Infill::connectLines(Polygons& result_lines)

const bool choose_side = (vertex_index == previous_segment->start_segment && polygon_index == previous_segment->start_polygon);
const auto& previous_side = choose_side ? previous_segment->start : previous_segment->end;
if (vSize2(previous_side - vertex_after) < epsilon_squared)
if (previous_side == vertex_after)
{
// Edge case when an infill line ends directly on top of vertex_after: We skip the extra connecting line segment, as that would be 0-length.
previous_segment = nullptr;
Expand Down

0 comments on commit 1c1035f

Please sign in to comment.