Skip to content

Commit

Permalink
interp_g7x: Fix endless loop in recursive function
Browse files Browse the repository at this point in the history
If the last path returns false in dive(), it's a high probability to end
up in an endless loop, there is one specific case that can prevent it.

This commit checks if we're on the last path and returns from the
recursive function.

The check is added before we calculate intersecting lines, since we're
on the last path, there shouldn't be any.
  • Loading branch information
havardAasen committed Feb 11, 2024
1 parent 0edaa1a commit 48a3ee4
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/emc/rs274ngc/interp_g7x.cc
Original file line number Diff line number Diff line change
Expand Up @@ -773,6 +773,12 @@ void g7x::pocket(int cycle, std::complex<double> location, iterator p,
}
return;
}

// We have added our move commands for the last path, we end the
// recursive function before calculating and adding intersections.
if (p==std::prev(end()))
return;

if(std::abs(imag(location)-x)>tolerance) {
/* Our x coordinate is beyond the current segment, move onto
the next
Expand Down

0 comments on commit 48a3ee4

Please sign in to comment.