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; 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; bool max_detour_length_exceeded = false;
if (opt_max_detour.value > 0) { if (opt_max_detour.value > 0) {
double direct_length = travel.length(); double direct_length = travel.length();
double detour = result_pl.length() - direct_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) { if (detour > max_detour_length) {
result_pl = {start, end}; result_pl = {start, end};
max_detour_length_exceeded = true; max_detour_length_exceeded = true;

View file

@ -455,22 +455,23 @@ void PrintConfigDef::init_fff_params()
const int max_temp = 1500; const int max_temp = 1500;
def = this->add("reduce_crossing_wall", coBool); def = this->add("reduce_crossing_wall", coBool);
def->label = L("Avoid crossing wall when travel"); def->label = L("Avoid crossing wall");
def->category = L("Quality"); def->category = L("Quality");
def->tooltip = L("Detour and avoid to travel across wall which may cause blob on surface"); def->tooltip = L("Detour and avoid to travel across wall which may cause blob on surface");
def->mode = comDevelop; def->mode = comAdvanced;
def->set_default_value(new ConfigOptionBool(false)); def->set_default_value(new ConfigOptionBool(false));
def = this->add("max_travel_detour_distance", coFloat); def = this->add("max_travel_detour_distance", coFloatOrPercent);
def->label = L("Max travel detour distance"); def->label = L("Avoid crossing wall - Max detour length");
def->category = L("Quality"); def->category = L("Quality");
def->tooltip = L("Maximum detour distance for avoiding crossing wall. " def->tooltip = L("Maximum detour distance for avoiding crossing wall. "
"Don't detour if the detour distance is large than this value"); "Don't detour if the detour distance is large than this value. "
def->sidetext = L("mm"); "Detour length could be specified either as an absolute value or as percentage (for example 50%) of a direct travel path. Zero to disable");
def->sidetext = L("mm or %");
def->min = 0; def->min = 0;
def->max_literal = 1000; def->max_literal = 1000;
def->mode = comDevelop; def->mode = comAdvanced;
def->set_default_value(new ConfigOptionFloat(0.)); def->set_default_value(new ConfigOptionFloatOrPercent(0., false));
// BBS // BBS
def = this->add("cool_plate_temp", coInts); def = this->add("cool_plate_temp", coInts);

View file

@ -799,7 +799,7 @@ PRINT_CONFIG_CLASS_DERIVED_DEFINE(
//BBS //BBS
((ConfigOptionInts, additional_cooling_fan_speed)) ((ConfigOptionInts, additional_cooling_fan_speed))
((ConfigOptionBool, reduce_crossing_wall)) ((ConfigOptionBool, reduce_crossing_wall))
((ConfigOptionFloat, max_travel_detour_distance)) ((ConfigOptionFloatOrPercent, max_travel_detour_distance))
((ConfigOptionPoints, printable_area)) ((ConfigOptionPoints, printable_area))
//BBS: add bed_exclude_area //BBS: add bed_exclude_area
((ConfigOptionPoints, bed_exclude_area)) ((ConfigOptionPoints, bed_exclude_area))