From 6c8015ca28fcc8b2ea2dd569e6d98982ab2f1c53 Mon Sep 17 00:00:00 2001 From: "salt.wei" Date: Thu, 13 Oct 2022 18:17:05 +0800 Subject: [PATCH] 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 Change-Id: I127adbb70f33c3954a08f3087e64c4e75212c7f0 --- src/libslic3r/GCode/AvoidCrossingPerimeters.cpp | 6 ++++-- src/libslic3r/PrintConfig.cpp | 17 +++++++++-------- src/libslic3r/PrintConfig.hpp | 2 +- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/libslic3r/GCode/AvoidCrossingPerimeters.cpp b/src/libslic3r/GCode/AvoidCrossingPerimeters.cpp index 6eb33b83b..ebba1dda2 100644 --- a/src/libslic3r/GCode/AvoidCrossingPerimeters.cpp +++ b/src/libslic3r/GCode/AvoidCrossingPerimeters.cpp @@ -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; diff --git a/src/libslic3r/PrintConfig.cpp b/src/libslic3r/PrintConfig.cpp index 9a2d582fd..8632fcb66 100644 --- a/src/libslic3r/PrintConfig.cpp +++ b/src/libslic3r/PrintConfig.cpp @@ -455,22 +455,23 @@ void PrintConfigDef::init_fff_params() const int max_temp = 1500; 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->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 = this->add("max_travel_detour_distance", coFloat); - def->label = L("Max travel detour distance"); + def = this->add("max_travel_detour_distance", coFloatOrPercent); + def->label = L("Avoid crossing wall - Max detour length"); def->category = L("Quality"); def->tooltip = L("Maximum detour distance for avoiding crossing wall. " - "Don't detour if the detour distance is large than this value"); - def->sidetext = L("mm"); + "Don't detour if the detour distance is large than this value. " + "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->max_literal = 1000; - def->mode = comDevelop; - def->set_default_value(new ConfigOptionFloat(0.)); + def->mode = comAdvanced; + def->set_default_value(new ConfigOptionFloatOrPercent(0., false)); // BBS def = this->add("cool_plate_temp", coInts); diff --git a/src/libslic3r/PrintConfig.hpp b/src/libslic3r/PrintConfig.hpp index 2b413adaa..b1becfdc8 100644 --- a/src/libslic3r/PrintConfig.hpp +++ b/src/libslic3r/PrintConfig.hpp @@ -799,7 +799,7 @@ PRINT_CONFIG_CLASS_DERIVED_DEFINE( //BBS ((ConfigOptionInts, additional_cooling_fan_speed)) ((ConfigOptionBool, reduce_crossing_wall)) - ((ConfigOptionFloat, max_travel_detour_distance)) + ((ConfigOptionFloatOrPercent, max_travel_detour_distance)) ((ConfigOptionPoints, printable_area)) //BBS: add bed_exclude_area ((ConfigOptionPoints, bed_exclude_area))