From 014e9bbd042edea470cc7eb45ee683f3af71520f Mon Sep 17 00:00:00 2001 From: vovodroid Date: Sat, 20 Jul 2024 18:31:34 +0300 Subject: [PATCH] Remove "auto" wall direction --- src/libslic3r/GCode.cpp | 7 ++++-- src/libslic3r/PerimeterGenerator.cpp | 32 ++++++++++++++------------- src/libslic3r/PrintConfig.cpp | 8 +++---- src/libslic3r/PrintConfig.hpp | 1 - src/slic3r/GUI/ConfigManipulation.cpp | 7 +----- src/slic3r/GUI/PartPlate.cpp | 1 - 6 files changed, 27 insertions(+), 29 deletions(-) diff --git a/src/libslic3r/GCode.cpp b/src/libslic3r/GCode.cpp index a5af72f4c9..37993966f0 100644 --- a/src/libslic3r/GCode.cpp +++ b/src/libslic3r/GCode.cpp @@ -5370,7 +5370,10 @@ std::string GCode::extrude_loop(ExtrusionLoop loop, std::string description, dou if (m_config.spiral_mode && !is_hole) { // if spiral vase, we have to ensure that all contour are in the same orientation. - loop.make_counter_clockwise(); + if (m_config.wall_direction == WallDirection::CounterClockwise) + loop.make_counter_clockwise(); + else + loop.make_clockwise(); } //if (loop.loop_role() == elrSkirt && (this->m_layer->id() % 2 == 1)) // loop.reverse(); @@ -5432,7 +5435,7 @@ std::string GCode::extrude_loop(ExtrusionLoop loop, std::string description, dou // 1 - the currently printed external perimeter and 2 - the neighbouring internal perimeter. if (m_config.wipe_before_external_loop.value && !paths.empty() && paths.front().size() > 1 && paths.back().size() > 1 && paths.front().role() == erExternalPerimeter && region_perimeters.size() > 1) { const bool is_full_loop_ccw = loop.polygon().is_counter_clockwise(); - bool is_hole_loop = (loop.loop_role() & ExtrusionLoopRole::elrHole) != 0; // loop.make_counter_clockwise(); + bool is_hole_loop = (loop.loop_role() & ExtrusionLoopRole::elrHole) != 0; const double nozzle_diam = nozzle_diameter; // note: previous & next are inverted to extrude "in the opposite direction, and we are "rewinding" diff --git a/src/libslic3r/PerimeterGenerator.cpp b/src/libslic3r/PerimeterGenerator.cpp index cc055c9d8a..7da2f20725 100644 --- a/src/libslic3r/PerimeterGenerator.cpp +++ b/src/libslic3r/PerimeterGenerator.cpp @@ -253,7 +253,10 @@ static ExtrusionEntityCollection traverse_loops(const PerimeterGenerator &perime ExtrusionLoop *eloop = static_cast(coll.entities[idx.first]); coll.entities[idx.first] = nullptr; - eloop->make_counter_clockwise(); + if (perimeter_generator.config->wall_direction == WallDirection::CounterClockwise) + eloop->make_counter_clockwise(); + else + eloop->make_clockwise(); eloop->inset_idx = loop.depth; if (loop.is_contour) { out.append(std::move(children.entities)); @@ -511,7 +514,10 @@ static ExtrusionEntityCollection traverse_extrusions(const PerimeterGenerator& p if (!paths.empty()) { if (extrusion->is_closed) { ExtrusionLoop extrusion_loop(std::move(paths), pg_extrusion.is_contour ? elrDefault : elrHole); - extrusion_loop.make_counter_clockwise(); + if (perimeter_generator.config->wall_direction == WallDirection::CounterClockwise) + extrusion_loop.make_counter_clockwise(); + else + extrusion_loop.make_clockwise(); // TODO: it seems in practice that ExtrusionLoops occasionally have significantly disconnected paths, // triggering the asserts below. Is this a problem? for (auto it = std::next(extrusion_loop.paths.begin()); it != extrusion_loop.paths.end(); ++it) { @@ -1106,7 +1112,7 @@ static void reorient_perimeters(ExtrusionEntityCollection &entities, bool steep_ } if (need_reverse && !isExternal) { - eloop->make_clockwise(); + eloop->reverse(); } } } @@ -1414,18 +1420,17 @@ void PerimeterGenerator::process_classic() // at this point, all loops should be in contours[0] bool steep_overhang_contour = false; bool steep_overhang_hole = false; - const WallDirection wall_direction = config->wall_direction; - if (wall_direction != WallDirection::Auto) { - // Skip steep overhang detection if wall direction is specified + if (!config->overhang_reverse) { + // Skip steep overhang detection no reverse is specified steep_overhang_contour = true; steep_overhang_hole = true; } ExtrusionEntityCollection entities = traverse_loops(*this, contours.front(), thin_walls, steep_overhang_contour, steep_overhang_hole); // All walls are counter-clockwise initially, so we don't need to reorient it if that's what we want - if (wall_direction != WallDirection::CounterClockwise) { + if (config->overhang_reverse) { reorient_perimeters(entities, steep_overhang_contour, steep_overhang_hole, // Reverse internal only if the wall direction is auto - this->config->overhang_reverse_internal_only && wall_direction == WallDirection::Auto); + this->config->overhang_reverse_internal_only); } // if brim will be printed, reverse the order of perimeters so that @@ -2444,18 +2449,15 @@ void PerimeterGenerator::process_arachne() bool steep_overhang_contour = false; bool steep_overhang_hole = false; - const WallDirection wall_direction = config->wall_direction; - if (wall_direction != WallDirection::Auto) { - // Skip steep overhang detection if wall direction is specified + if (!config->overhang_reverse) { + // Skip steep overhang detection no reverse is specified steep_overhang_contour = true; steep_overhang_hole = true; } if (ExtrusionEntityCollection extrusion_coll = traverse_extrusions(*this, ordered_extrusions, steep_overhang_contour, steep_overhang_hole); !extrusion_coll.empty()) { - // All walls are counter-clockwise initially, so we don't need to reorient it if that's what we want - if (wall_direction != WallDirection::CounterClockwise) { + if (config->overhang_reverse) { reorient_perimeters(extrusion_coll, steep_overhang_contour, steep_overhang_hole, - // Reverse internal only if the wall direction is auto - this->config->overhang_reverse_internal_only && wall_direction == WallDirection::Auto); + this->config->overhang_reverse_internal_only); } this->loops->append(extrusion_coll); } diff --git a/src/libslic3r/PrintConfig.cpp b/src/libslic3r/PrintConfig.cpp index 070dc35215..3f60baeef4 100644 --- a/src/libslic3r/PrintConfig.cpp +++ b/src/libslic3r/PrintConfig.cpp @@ -246,7 +246,6 @@ CONFIG_OPTION_ENUM_DEFINE_STATIC_MAPS(WallSequence) //Orca static t_config_enum_values s_keys_map_WallDirection{ - { "auto", int(WallDirection::Auto) }, { "ccw", int(WallDirection::CounterClockwise) }, { "cw", int(WallDirection::Clockwise)}, }; @@ -1987,14 +1986,12 @@ void PrintConfigDef::init_fff_params() def->category = L("Quality"); def->tooltip = L("The direction which the wall loops are extruded when looking down from the top.\n\nBy default all walls are extruded in counter-clockwise, unless Reverse on even is enabled. Set this to any option other than Auto will force the wall direction regardless of the Reverse on even.\n\nThis option will be disabled if spiral vase mode is enabled."); def->enum_keys_map = &ConfigOptionEnum::get_enum_values(); - def->enum_values.push_back("auto"); def->enum_values.push_back("ccw"); def->enum_values.push_back("cw"); - def->enum_labels.push_back(L("Auto")); def->enum_labels.push_back(L("Counter clockwise")); def->enum_labels.push_back(L("Clockwise")); def->mode = comAdvanced; - def->set_default_value(new ConfigOptionEnum(WallDirection::Auto)); + def->set_default_value(new ConfigOptionEnum(WallDirection::CounterClockwise)); def = this->add("extruder", coInt); def->gui_type = ConfigOptionDef::GUIType::i_enum_open; @@ -7512,6 +7509,9 @@ void PrintConfigDef::handle_legacy(t_config_option_key &opt_key, std::string &va } else if (opt_key == "machine_switch_extruder_time") { opt_key = "machine_tool_change_time"; } + else if (opt_key == "wall_direction" && value == "auto") { + value = "ccw"; + } // Ignore the following obsolete configuration keys: static std::set ignore = { diff --git a/src/libslic3r/PrintConfig.hpp b/src/libslic3r/PrintConfig.hpp index cc0c765530..7942eadc67 100644 --- a/src/libslic3r/PrintConfig.hpp +++ b/src/libslic3r/PrintConfig.hpp @@ -113,7 +113,6 @@ enum class WallSequence { // Orca enum class WallDirection { - Auto, CounterClockwise, Clockwise, Count, diff --git a/src/slic3r/GUI/ConfigManipulation.cpp b/src/slic3r/GUI/ConfigManipulation.cpp index 60828cedcf..ac2c073da5 100644 --- a/src/slic3r/GUI/ConfigManipulation.cpp +++ b/src/slic3r/GUI/ConfigManipulation.cpp @@ -327,7 +327,6 @@ void ConfigManipulation::update_print_fff_config(DynamicPrintConfig* config, con config->opt_int("enforce_support_layers") == 0 && ! config->opt_bool("detect_thin_wall") && ! config->opt_bool("overhang_reverse") && - config->opt_enum("wall_direction") == WallDirection::Auto && config->opt_enum("timelapse_type") == TimelapseType::tlTraditional && !config->opt_bool("enable_wrapping_detection"))) { @@ -342,7 +341,6 @@ void ConfigManipulation::update_print_fff_config(DynamicPrintConfig* config, con new_conf.set_key_value("enforce_support_layers", new ConfigOptionInt(0)); new_conf.set_key_value("detect_thin_wall", new ConfigOptionBool(false)); new_conf.set_key_value("overhang_reverse", new ConfigOptionBool(false)); - new_conf.set_key_value("wall_direction", new ConfigOptionEnum(WallDirection::Auto)); new_conf.set_key_value("timelapse_type", new ConfigOptionEnum(tlTraditional)); new_conf.set_key_value("enable_wrapping_detection", new ConfigOptionBool(false)); sparse_infill_density = 0; @@ -661,8 +659,6 @@ void ConfigManipulation::toggle_print_fff_options(DynamicPrintConfig *config, co toggle_field("top_shell_thickness", ! has_spiral_vase && has_top_shell); toggle_field("bottom_shell_thickness", ! has_spiral_vase && has_bottom_shell); - toggle_field("wall_direction", !has_spiral_vase); - // Gap fill is newly allowed in between perimeter lines even for empty infill (see GH #1476). toggle_field("gap_infill_speed", have_perimeters); @@ -891,8 +887,7 @@ void ConfigManipulation::toggle_print_fff_options(DynamicPrintConfig *config, co bool has_detect_overhang_wall = config->opt_bool("detect_overhang_wall"); bool has_overhang_reverse = config->opt_bool("overhang_reverse"); - bool force_wall_direction = config->opt_enum("wall_direction") != WallDirection::Auto; - bool allow_overhang_reverse = !has_spiral_vase && !force_wall_direction; + bool allow_overhang_reverse = !has_spiral_vase; toggle_line("overhang_reverse", allow_overhang_reverse); toggle_line("overhang_reverse_internal_only", allow_overhang_reverse && has_overhang_reverse); bool has_overhang_reverse_internal_only = config->opt_bool("overhang_reverse_internal_only"); diff --git a/src/slic3r/GUI/PartPlate.cpp b/src/slic3r/GUI/PartPlate.cpp index 6ee0733abd..b910e1ebbf 100644 --- a/src/slic3r/GUI/PartPlate.cpp +++ b/src/slic3r/GUI/PartPlate.cpp @@ -2744,7 +2744,6 @@ void PartPlate::set_vase_mode_related_object_config(int obj_id) { new_conf.set_key_value("detect_thin_wall", new ConfigOptionBool(false)); new_conf.set_key_value("timelapse_type", new ConfigOptionEnum(tlTraditional)); new_conf.set_key_value("overhang_reverse", new ConfigOptionBool(false)); - new_conf.set_key_value("wall_direction", new ConfigOptionEnum(WallDirection::Auto)); auto applying_keys = global_config->diff(new_conf); for (ModelObject* object : obj_ptrs) {