ENH: avoid crossing wall when travel

Provide related two options to avoid crossing wall
when travel.

This is handling for github issue #106

Signed-off-by: salt.wei <salt.wei@bambulab.com>
Change-Id: I127adbb70f33c3954a08f3087e64c4e75212c7f0
This commit is contained in:
salt.wei 2022-10-13 18:17:05 +08:00 committed by Lane.Wei
parent f155f5a498
commit 6c8015ca28
3 changed files with 14 additions and 11 deletions

View file

@ -1167,12 +1167,14 @@ Polyline AvoidCrossingPerimeters::travel_to(const GCode &gcodegen, const Point &
travel_intersection_count = 0;
}
const ConfigOptionFloat &opt_max_detour = gcodegen.config().max_travel_detour_distance;
const ConfigOptionFloatOrPercent &opt_max_detour = gcodegen.config().max_travel_detour_distance;
bool max_detour_length_exceeded = false;
if (opt_max_detour.value > 0) {
double direct_length = travel.length();
double detour = result_pl.length() - direct_length;
double max_detour_length = scale_(opt_max_detour.value);
double max_detour_length = opt_max_detour.percent ?
direct_length * 0.01 * opt_max_detour.value :
scale_(opt_max_detour.value);
if (detour > max_detour_length) {
result_pl = {start, end};
max_detour_length_exceeded = true;