ENH: imprve scarf seam

Jira: none

fix missing wipe while avoid acrossing wall on

set wipe speeed base on previou path
first implement by orca

add slope gap params

Signed-off-by: qing.zhang <qing.zhang@bambulab.com>
Change-Id: I45655f087f5a165b52b1007ef5afe0b20d0b13a4
This commit is contained in:
qing.zhang 2024-07-01 15:18:30 +08:00 committed by Lane.Wei
parent c0536c09b4
commit 04beaae9e3
10 changed files with 40 additions and 9 deletions

View File

@ -295,7 +295,9 @@ static std::vector<Vec2d> get_path_of_change_filament(const Print& print)
/* Reduce feedrate a bit; travel speed is often too high to move on existing material.
Too fast = ripping of existing material; too slow = short wipe path, thus more blob. */
//OrcaSlicer
double wipe_speed = gcodegen.writer().config.travel_speed.value * gcodegen.config().wipe_speed.value / 100;
double wipe_speed = gcodegen.config().role_base_wipe_speed ? gcodegen.writer().get_current_speed() / 60 :
gcodegen.writer().config.travel_speed.value * gcodegen.config().wipe_speed.value / 100;
// get the retraction length
double length = toolchange
@ -4062,6 +4064,7 @@ std::string GCode::extrude_loop(ExtrusionLoop loop, std::string description, dou
//BBS: avoid overhang on conditional scarf mode
bool slope_has_overhang = false;
// update scarf seam
if (enable_seam_slope) {
// Create seam slope
double start_slope_ratio;
@ -4090,7 +4093,8 @@ std::string GCode::extrude_loop(ExtrusionLoop loop, std::string description, dou
ExtrusionLoopSloped new_loop(paths, seam_gap, slope_min_length, slope_max_segment_length, start_slope_ratio, loop.loop_role());
//BBS: clip end and start to get better seam
new_loop.clip_slope(seam_gap);
const double slope_gap = m_config.seam_slope_gap.get_abs_value(scale_(EXTRUDER_CONFIG(nozzle_diameter)));
new_loop.clip_slope(slope_gap);
// BBS: slowdown speed to improve seam, to be fix, cooling need to be apply correctly
//new_loop.target_speed = get_path_speed(new_loop.starts.back());
//new_loop.slowdown_slope_speed();
@ -4101,6 +4105,7 @@ std::string GCode::extrude_loop(ExtrusionLoop loop, std::string description, dou
for (const auto &p : new_loop.get_all_paths()) {
gcode += this->_extrude(*p, description, speed_for_path(*p));
}
set_last_scarf_seam_flag(true);
// Fix path for wipe
if (!new_loop.ends.empty()) {
@ -4125,6 +4130,7 @@ std::string GCode::extrude_loop(ExtrusionLoop loop, std::string description, dou
for (ExtrusionPaths::iterator path = paths.begin(); path != paths.end(); ++path) {
gcode += this->_extrude(*path, description, speed_for_path(*path));
}
set_last_scarf_seam_flag(false);
}
//BBS: don't reset acceleration when printing first layer. During first layer, acceleration is always same value.
@ -5085,7 +5091,7 @@ std::string GCode::travel_to(const Point &point, ExtrusionRole role, std::string
// generate G-code for the travel move
std::string gcode;
if (needs_retraction) {
if (m_config.reduce_crossing_wall && could_be_wipe_disabled)
if (m_config.reduce_crossing_wall && could_be_wipe_disabled && !m_last_scarf_seam_flag)
m_wipe.reset_path();
Point last_post_before_retract = this->last_pos();

View File

@ -151,6 +151,7 @@ public:
m_layer(nullptr),
m_object_layer_over_raft(false),
//m_volumetric_speed(0),
m_last_scarf_seam_flag(false),
m_last_pos_defined(false),
m_last_extrusion_role(erNone),
m_last_width(0.0f),
@ -179,6 +180,7 @@ public:
void set_origin(const Vec2d &pointf);
void set_origin(const coordf_t x, const coordf_t y) { this->set_origin(Vec2d(x, y)); }
const Point& last_pos() const { return m_last_pos; }
const bool& last_scarf_seam_flag() const { return m_last_scarf_seam_flag; }
Vec2d point_to_gcode(const Point &point) const;
Point gcode_to_point(const Vec2d &point) const;
const FullPrintConfig &config() const { return m_config; }
@ -332,6 +334,7 @@ private:
void check_placeholder_parser_failed();
void set_last_pos(const Point &pos) { m_last_pos = pos; m_last_pos_defined = true; }
void set_last_scarf_seam_flag(bool flag) { m_last_scarf_seam_flag = flag; }
bool last_pos_defined() const { return m_last_pos_defined; }
void set_extruders(const std::vector<unsigned int> &extruder_ids);
std::string preamble();
@ -476,7 +479,7 @@ private:
Point m_last_pos;
bool m_last_pos_defined;
bool m_last_scarf_seam_flag;
std::unique_ptr<CoolingBuffer> m_cooling_buffer;
std::unique_ptr<SpiralVase> m_spiral_vase;
#ifdef HAS_PRESSURE_EQUALIZER

View File

@ -315,11 +315,11 @@ std::string GCodeWriter::toolchange(unsigned int extruder_id)
return gcode.str();
}
std::string GCodeWriter::set_speed(double F, const std::string &comment, const std::string &cooling_marker) const
std::string GCodeWriter::set_speed(double F, const std::string &comment, const std::string &cooling_marker)
{
assert(F > 0.);
assert(F < 100000.);
m_current_speed = F;
GCodeG1Formatter w;
w.emit_f(F);
//BBS

View File

@ -65,7 +65,8 @@ public:
// printed with the same extruder.
std::string toolchange_prefix() const;
std::string toolchange(unsigned int extruder_id);
std::string set_speed(double F, const std::string &comment = std::string(), const std::string &cooling_marker = std::string()) const;
std::string set_speed(double F, const std::string &comment = std::string(), const std::string &cooling_marker = std::string());
double get_current_speed() { return m_current_speed; };
std::string travel_to_xy(const Vec2d &point, const std::string &comment = std::string());
std::string travel_to_xyz(const Vec3d &point, const std::string &comment = std::string());
std::string travel_to_z(double z, const std::string &comment = std::string());
@ -138,7 +139,7 @@ private:
//BBS: x, y offset for gcode generated
double m_x_offset{ 0 };
double m_y_offset{ 0 };
double m_current_speed{ 0 };
std::string m_gcode_label_objects_start;
std::string m_gcode_label_objects_end;

View File

@ -847,7 +847,7 @@ static std::vector<std::string> s_Preset_print_options {
"print_flow_ratio",
//Orca
"exclude_object", "seam_slope_type", "seam_slope_conditional", "scarf_angle_threshold", "seam_slope_start_height", "seam_slope_entire_loop", "seam_slope_min_length",
"seam_slope_steps", "seam_slope_inner_walls"};
"seam_slope_steps", "seam_slope_inner_walls", "role_base_wipe_speed", "seam_slope_gap"};
static std::vector<std::string> s_Preset_filament_options {
/*"filament_colour", */ "default_filament_colour","required_nozzle_HRC","filament_diameter", "filament_type", "filament_soluble", "filament_is_support",

View File

@ -2906,6 +2906,14 @@ void PrintConfigDef::init_fff_params()
def->mode = comAdvanced;
def->set_default_value(new ConfigOptionFloatOrPercent(50, true));
def = this->add("seam_slope_gap", coFloatOrPercent);
def->label = L("Slop gap");
def->tooltip = L("In order to reduce the visibility of the seam in a closed loop extrusion, the loop is interrupted and shortened by a specified amount.\n" "This amount as a percentage of the current extruder diameter. The default value for this parameter is 15");
def->sidetext = L("mm or %");
def->min = 0;
def->mode = comAdvanced;
def->set_default_value(new ConfigOptionFloatOrPercent(15, true));
def = this->add("seam_slope_entire_loop", coBool);
def->label = L("Scarf around entire wall");
def->tooltip = L("The scarf extends to the entire length of the wall.");
@ -2941,6 +2949,12 @@ void PrintConfigDef::init_fff_params()
def->mode = comDevelop;
def->set_default_value(new ConfigOptionPercent(80));
def = this->add("role_base_wipe_speed", coBool);
def->label = L("Role base wipe speed");
def->tooltip = L("The wipe speed is determined by speed of current extrusion role. " "e.g if a wip action is executed immediately following an outer wall extrusion, the speed of the outer wall extrusion will be utilized for the wipe action.");
def->mode = comAdvanced;
def->set_default_value(new ConfigOptionBool(true));
def = this->add("skirt_distance", coFloat);
def->label = L("Skirt distance");
def->tooltip = L("Distance from skirt to brim or object");

View File

@ -766,6 +766,7 @@ PRINT_CONFIG_CLASS_DEFINE(
// OrcaSlicer
((ConfigOptionPercent, seam_gap))
((ConfigOptionPercent, wipe_speed))
((ConfigOptionBool, role_base_wipe_speed))
((ConfigOptionBool, precise_z_height)) // BBS
)
@ -845,6 +846,7 @@ PRINT_CONFIG_CLASS_DEFINE(
((ConfigOptionBool, seam_slope_conditional))
((ConfigOptionInt, scarf_angle_threshold))
((ConfigOptionFloatOrPercent, seam_slope_start_height))
((ConfigOptionFloatOrPercent, seam_slope_gap))
((ConfigOptionBool, seam_slope_entire_loop))
((ConfigOptionFloat, seam_slope_min_length))
((ConfigOptionInt, seam_slope_steps))

View File

@ -899,12 +899,14 @@ bool PrintObject::invalidate_state_by_config_options(
|| opt_key == "seam_slope_conditional"
|| opt_key == "scarf_angle_threshold"
|| opt_key == "seam_slope_start_height"
|| opt_key == "seam_slope_gap"
|| opt_key == "seam_slope_entire_loop"
|| opt_key == "seam_slope_min_length"
|| opt_key == "seam_slope_steps"
|| opt_key == "seam_slope_inner_walls"
|| opt_key == "seam_gap"
|| opt_key == "wipe_speed"
|| opt_key == "role_base_wipe_speed"
|| opt_key == "support_speed"
|| opt_key == "support_interface_speed"
|| opt_key == "smooth_speed_discontinuity_area"

View File

@ -745,6 +745,7 @@ void ConfigManipulation::toggle_print_fff_options(DynamicPrintConfig *config, co
toggle_line("seam_slope_conditional", has_seam_slope);
toggle_line("scarf_angle_threshold", has_seam_slope && config->opt_bool("seam_slope_conditional"));
toggle_line("seam_slope_start_height", has_seam_slope);
toggle_line("seam_slope_gap", has_seam_slope);
toggle_line("seam_slope_entire_loop", has_seam_slope);
toggle_line("seam_slope_min_length", has_seam_slope);
toggle_line("seam_slope_steps", has_seam_slope);

View File

@ -1944,11 +1944,13 @@ void TabPrint::build()
optgroup->append_single_option_line("seam_slope_conditional");
optgroup->append_single_option_line("scarf_angle_threshold");
optgroup->append_single_option_line("seam_slope_start_height");
optgroup->append_single_option_line("seam_slope_gap");
optgroup->append_single_option_line("seam_slope_entire_loop");
optgroup->append_single_option_line("seam_slope_min_length");
optgroup->append_single_option_line("seam_slope_steps");
optgroup->append_single_option_line("seam_slope_inner_walls");
optgroup->append_single_option_line("wipe_speed", "Seam");
optgroup->append_single_option_line("role_base_wipe_speed", "Seam");
optgroup = page->new_optgroup(L("Precision"), L"param_precision");
optgroup->append_single_option_line("slice_closing_radius");