Skip to content

Commit 40dd3ac

Browse files
committed
Refactor wall direction
1 parent 158c71f commit 40dd3ac

File tree

6 files changed

+27
-29
lines changed

6 files changed

+27
-29
lines changed

Diff for: src/libslic3r/GCode.cpp

+5-2
Original file line numberDiff line numberDiff line change
@@ -4561,7 +4561,10 @@ std::string GCode::extrude_loop(ExtrusionLoop loop, std::string description, dou
45614561

45624562
if (m_config.spiral_mode && !is_hole) {
45634563
// if spiral vase, we have to ensure that all contour are in the same orientation.
4564-
loop.make_counter_clockwise();
4564+
if (m_config.wall_direction == WallDirection::CounterClockwise)
4565+
loop.make_counter_clockwise();
4566+
else
4567+
loop.make_clockwise();
45654568
}
45664569
if (loop.loop_role() == elrSkirt && (this->m_layer->id() % 2 == 1))
45674570
loop.reverse();
@@ -4622,7 +4625,7 @@ std::string GCode::extrude_loop(ExtrusionLoop loop, std::string description, dou
46224625
// 1 - the currently printed external perimeter and 2 - the neighbouring internal perimeter.
46234626
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) {
46244627
const bool is_full_loop_ccw = loop.polygon().is_counter_clockwise();
4625-
bool is_hole_loop = (loop.loop_role() & ExtrusionLoopRole::elrHole) != 0; // loop.make_counter_clockwise();
4628+
bool is_hole_loop = (loop.loop_role() & ExtrusionLoopRole::elrHole) != 0;
46264629
const double nozzle_diam = nozzle_diameter;
46274630

46284631
// note: previous & next are inverted to extrude "in the opposite direction, and we are "rewinding"

Diff for: src/libslic3r/PerimeterGenerator.cpp

+17-15
Original file line numberDiff line numberDiff line change
@@ -663,7 +663,10 @@ static ExtrusionEntityCollection traverse_loops(const PerimeterGenerator &perime
663663
ExtrusionLoop *eloop = static_cast<ExtrusionLoop*>(coll.entities[idx.first]);
664664
coll.entities[idx.first] = nullptr;
665665

666-
eloop->make_counter_clockwise();
666+
if (perimeter_generator.config->wall_direction == WallDirection::CounterClockwise)
667+
eloop->make_counter_clockwise();
668+
else
669+
eloop->make_clockwise();
667670
eloop->inset_idx = loop.depth;
668671
if (loop.is_contour) {
669672
out.append(std::move(children.entities));
@@ -1046,7 +1049,10 @@ static ExtrusionEntityCollection traverse_extrusions(const PerimeterGenerator& p
10461049
if (!paths.empty()) {
10471050
if (extrusion->is_closed) {
10481051
ExtrusionLoop extrusion_loop(std::move(paths), pg_extrusion.is_contour ? elrDefault : elrHole);
1049-
extrusion_loop.make_counter_clockwise();
1052+
if (perimeter_generator.config->wall_direction == WallDirection::CounterClockwise)
1053+
extrusion_loop.make_counter_clockwise();
1054+
else
1055+
extrusion_loop.make_clockwise();
10501056
// TODO: it seems in practice that ExtrusionLoops occasionally have significantly disconnected paths,
10511057
// triggering the asserts below. Is this a problem?
10521058
for (auto it = std::next(extrusion_loop.paths.begin()); it != extrusion_loop.paths.end(); ++it) {
@@ -1635,7 +1641,7 @@ static void reorient_perimeters(ExtrusionEntityCollection &entities, bool steep_
16351641
}
16361642

16371643
if (need_reverse && !isExternal) {
1638-
eloop->make_clockwise();
1644+
eloop->reverse();
16391645
}
16401646
}
16411647
}
@@ -1947,18 +1953,17 @@ void PerimeterGenerator::process_classic()
19471953
// at this point, all loops should be in contours[0]
19481954
bool steep_overhang_contour = false;
19491955
bool steep_overhang_hole = false;
1950-
const WallDirection wall_direction = config->wall_direction;
1951-
if (wall_direction != WallDirection::Auto) {
1952-
// Skip steep overhang detection if wall direction is specified
1956+
if (!config->overhang_reverse) {
1957+
// Skip steep overhang detection no reverse is specified
19531958
steep_overhang_contour = true;
19541959
steep_overhang_hole = true;
19551960
}
19561961
ExtrusionEntityCollection entities = traverse_loops(*this, contours.front(), thin_walls, steep_overhang_contour, steep_overhang_hole);
19571962
// All walls are counter-clockwise initially, so we don't need to reorient it if that's what we want
1958-
if (wall_direction != WallDirection::CounterClockwise) {
1963+
if (config->overhang_reverse) {
19591964
reorient_perimeters(entities, steep_overhang_contour, steep_overhang_hole,
19601965
// Reverse internal only if the wall direction is auto
1961-
this->config->overhang_reverse_internal_only && wall_direction == WallDirection::Auto);
1966+
this->config->overhang_reverse_internal_only);
19621967
}
19631968

19641969
// if brim will be printed, reverse the order of perimeters so that
@@ -2987,18 +2992,15 @@ void PerimeterGenerator::process_arachne()
29872992

29882993
bool steep_overhang_contour = false;
29892994
bool steep_overhang_hole = false;
2990-
const WallDirection wall_direction = config->wall_direction;
2991-
if (wall_direction != WallDirection::Auto) {
2992-
// Skip steep overhang detection if wall direction is specified
2995+
if (!config->overhang_reverse) {
2996+
// Skip steep overhang detection no reverse is specified
29932997
steep_overhang_contour = true;
29942998
steep_overhang_hole = true;
29952999
}
29963000
if (ExtrusionEntityCollection extrusion_coll = traverse_extrusions(*this, ordered_extrusions, steep_overhang_contour, steep_overhang_hole); !extrusion_coll.empty()) {
2997-
// All walls are counter-clockwise initially, so we don't need to reorient it if that's what we want
2998-
if (wall_direction != WallDirection::CounterClockwise) {
3001+
if (config->overhang_reverse) {
29993002
reorient_perimeters(extrusion_coll, steep_overhang_contour, steep_overhang_hole,
3000-
// Reverse internal only if the wall direction is auto
3001-
this->config->overhang_reverse_internal_only && wall_direction == WallDirection::Auto);
3003+
this->config->overhang_reverse_internal_only);
30023004
}
30033005
this->loops->append(extrusion_coll);
30043006
}

Diff for: src/libslic3r/PrintConfig.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,6 @@ CONFIG_OPTION_ENUM_DEFINE_STATIC_MAPS(WallSequence)
176176

177177
//Orca
178178
static t_config_enum_values s_keys_map_WallDirection{
179-
{ "auto", int(WallDirection::Auto) },
180179
{ "ccw", int(WallDirection::CounterClockwise) },
181180
{ "cw", int(WallDirection::Clockwise)},
182181
};
@@ -1563,14 +1562,12 @@ void PrintConfigDef::init_fff_params()
15631562
def->category = L("Quality");
15641563
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 odd is enabled. Set this to any option other than Auto will force the wall direction regardless of the Reverse on odd.\n\nThis option will be disabled if spiral vase mode is enabled.");
15651564
def->enum_keys_map = &ConfigOptionEnum<WallDirection>::get_enum_values();
1566-
def->enum_values.push_back("auto");
15671565
def->enum_values.push_back("ccw");
15681566
def->enum_values.push_back("cw");
1569-
def->enum_labels.push_back(L("Auto"));
15701567
def->enum_labels.push_back(L("Counter clockwise"));
15711568
def->enum_labels.push_back(L("Clockwise"));
15721569
def->mode = comAdvanced;
1573-
def->set_default_value(new ConfigOptionEnum<WallDirection>(WallDirection::Auto));
1570+
def->set_default_value(new ConfigOptionEnum<WallDirection>(WallDirection::CounterClockwise));
15741571

15751572
def = this->add("extruder", coInt);
15761573
def->gui_type = ConfigOptionDef::GUIType::i_enum_open;
@@ -6202,6 +6199,9 @@ void PrintConfigDef::handle_legacy(t_config_option_key &opt_key, std::string &va
62026199
else if(opt_key == "counterbole_hole_bridging") {
62036200
opt_key = "counterbore_hole_bridging";
62046201
}
6202+
else if (opt_key == "wall_direction" && value == "auto") {
6203+
value = "ccw";
6204+
}
62056205
else if (opt_key == "draft_shield" && value == "limited") {
62066206
value = "disabled";
62076207
} else if (opt_key == "overhang_speed_classic") {

Diff for: src/libslic3r/PrintConfig.hpp

-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ enum class WallSequence {
8585
// Orca
8686
enum class WallDirection
8787
{
88-
Auto,
8988
CounterClockwise,
9089
Clockwise,
9190
Count,

Diff for: src/slic3r/GUI/ConfigManipulation.cpp

+1-6
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,6 @@ void ConfigManipulation::update_print_fff_config(DynamicPrintConfig* config, con
293293
config->opt_int("enforce_support_layers") == 0 &&
294294
! config->opt_bool("detect_thin_wall") &&
295295
! config->opt_bool("overhang_reverse") &&
296-
config->opt_enum<WallDirection>("wall_direction") == WallDirection::Auto &&
297296
config->opt_enum<TimelapseType>("timelapse_type") == TimelapseType::tlTraditional))
298297
{
299298
DynamicPrintConfig new_conf = *config;
@@ -307,7 +306,6 @@ void ConfigManipulation::update_print_fff_config(DynamicPrintConfig* config, con
307306
new_conf.set_key_value("enforce_support_layers", new ConfigOptionInt(0));
308307
new_conf.set_key_value("detect_thin_wall", new ConfigOptionBool(false));
309308
new_conf.set_key_value("overhang_reverse", new ConfigOptionBool(false));
310-
new_conf.set_key_value("wall_direction", new ConfigOptionEnum<WallDirection>(WallDirection::Auto));
311309
new_conf.set_key_value("timelapse_type", new ConfigOptionEnum<TimelapseType>(tlTraditional));
312310
sparse_infill_density = 0;
313311
timelapse_type = TimelapseType::tlTraditional;
@@ -540,8 +538,6 @@ void ConfigManipulation::toggle_print_fff_options(DynamicPrintConfig *config, co
540538
toggle_field("top_shell_thickness", ! has_spiral_vase && has_top_solid_infill);
541539
toggle_field("bottom_shell_thickness", ! has_spiral_vase && has_bottom_solid_infill);
542540

543-
toggle_field("wall_direction", !has_spiral_vase);
544-
545541
// Gap fill is newly allowed in between perimeter lines even for empty infill (see GH #1476).
546542
toggle_field("gap_infill_speed", have_perimeters);
547543

@@ -734,8 +730,7 @@ void ConfigManipulation::toggle_print_fff_options(DynamicPrintConfig *config, co
734730

735731
bool has_detect_overhang_wall = config->opt_bool("detect_overhang_wall");
736732
bool has_overhang_reverse = config->opt_bool("overhang_reverse");
737-
bool force_wall_direction = config->opt_enum<WallDirection>("wall_direction") != WallDirection::Auto;
738-
bool allow_overhang_reverse = has_detect_overhang_wall && !has_spiral_vase && !force_wall_direction;
733+
bool allow_overhang_reverse = has_detect_overhang_wall && !has_spiral_vase;
739734
toggle_field("overhang_reverse", allow_overhang_reverse);
740735
toggle_line("overhang_reverse_threshold", allow_overhang_reverse && has_overhang_reverse);
741736
toggle_line("overhang_reverse_internal_only", allow_overhang_reverse && has_overhang_reverse);

Diff for: src/slic3r/GUI/PartPlate.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -2385,7 +2385,6 @@ void PartPlate::set_vase_mode_related_object_config(int obj_id) {
23852385
new_conf.set_key_value("detect_thin_wall", new ConfigOptionBool(false));
23862386
new_conf.set_key_value("timelapse_type", new ConfigOptionEnum<TimelapseType>(tlTraditional));
23872387
new_conf.set_key_value("overhang_reverse", new ConfigOptionBool(false));
2388-
new_conf.set_key_value("wall_direction", new ConfigOptionEnum<WallDirection>(WallDirection::Auto));
23892388
auto applying_keys = global_config->diff(new_conf);
23902389

23912390
for (ModelObject* object : obj_ptrs) {

0 commit comments

Comments
 (0)