Skip to content

Commit

Permalink
overhangs_speed_enforce: fix & add a simple mode for arachne
Browse files Browse the repository at this point in the history
  • Loading branch information
supermerill committed Jul 11, 2023
1 parent 92b3b21 commit b380222
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 8 deletions.
25 changes: 22 additions & 3 deletions src/libslic3r/PerimeterGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2415,7 +2415,7 @@ static void fuzzy_paths(ExtrusionPaths& paths, coordf_t fuzzy_skin_thickness, co
}

ExtrusionEntityCollection PerimeterGenerator::_traverse_loops(
const PerimeterGeneratorLoops &loops, ThickPolylines &thin_walls, int count_since_overhang /*= 0*/) const
const PerimeterGeneratorLoops &loops, ThickPolylines &thin_walls, int count_since_overhang /*= -1*/) const
{
// loops is an arrayref of ::Loop objects
// turn each one into an ExtrusionLoop object
Expand Down Expand Up @@ -2532,7 +2532,7 @@ ExtrusionEntityCollection PerimeterGenerator::_traverse_loops(
break;
}
}
if (has_overhang || this->config->overhangs_speed_enforce.value > count_since_overhang) {
if (has_overhang || ( count_since_overhang>=0 && this->config->overhangs_speed_enforce.value > count_since_overhang)) {
//enforce
for (ExtrusionPath& path : eloop->paths) {
if (path.role() == erPerimeter || path.role() == erExternalPerimeter) {
Expand All @@ -2543,7 +2543,7 @@ ExtrusionEntityCollection PerimeterGenerator::_traverse_loops(

}
assert(thin_walls.empty());
ExtrusionEntityCollection children = this->_traverse_loops(loop.children, thin_walls, has_overhang ? 1 : (count_since_overhang+1));
ExtrusionEntityCollection children = this->_traverse_loops(loop.children, thin_walls, has_overhang ? 1 : count_since_overhang < 0 ? -1 : (count_since_overhang+1));
coll_out.set_entities().reserve(coll_out.entities().size() + children.entities().size() + 1);
coll[idx.first] = nullptr;
if (loop.is_contour) {
Expand Down Expand Up @@ -2669,6 +2669,25 @@ ExtrusionEntityCollection PerimeterGenerator::_traverse_extrusions(std::vector<P
fuzzy_paths(paths, scale_d(fuzzy_skin_thickness), scale_d(fuzzy_skin_point_dist));
}

//set to overhang speed if any chunk is overhang
bool has_overhang = false;
if (this->config->overhangs_speed_enforce.value > 0) {
for (const ExtrusionPath& path : paths) {
if (path.role() == erOverhangPerimeter) {
has_overhang = true;
break;
}
}
if (has_overhang) {
//enforce
for (ExtrusionPath& path : paths) {
if (path.role() == erPerimeter || path.role() == erExternalPerimeter) {
path.set_role(erOverhangPerimeter);
}
}
}
}

// Append paths to collection.
if (!paths.empty()) {
if (extrusion->is_closed) {
Expand Down
2 changes: 1 addition & 1 deletion src/libslic3r/PerimeterGenerator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ class PerimeterGenerator {
ExtrusionPaths create_overhangs(const ClipperLib_Z::Path& loop_polygons, ExtrusionRole role, bool is_external) const;

// transform loops into ExtrusionEntityCollection, adding also thin walls into it.
ExtrusionEntityCollection _traverse_loops(const PerimeterGeneratorLoops &loops, ThickPolylines &thin_walls, int count_since_overhang = 0) const;
ExtrusionEntityCollection _traverse_loops(const PerimeterGeneratorLoops &loops, ThickPolylines &thin_walls, int count_since_overhang = -1) const;
ExtrusionEntityCollection _traverse_extrusions(std::vector<PerimeterGeneratorArachneExtrusion>& pg_extrusions);
// try to merge thin walls to a current periemter exrusion or just add it to the end of the list.
void _merge_thin_walls(ExtrusionEntityCollection &extrusions, ThickPolylines &thin_walls) const;
Expand Down
4 changes: 2 additions & 2 deletions src/libslic3r/PrintConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3867,8 +3867,8 @@ void PrintConfigDef::init_fff_params()
def->category = OptionCategory::speed;
def->tooltip = L("Set the speed of the full perimeters to the overhang speed, and also the next one(s) if any."
"\nSet to 0 to disable."
"\nSet to 1 to set the overhang speed to the full periemter if there is any overhang detected in the periemter."
"\nSet to more than 1 to also set the overhang speed to the next perimeter(s)."
"\nSet to 1 to set the overhang speed to the full perimeter if there is any overhang detected inside it."
"\nSet to more than 1 to also set the overhang speed to the next perimeter(s) (only in classic mode)."
);
def->sidetext = L("perimeters");
def->min = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/libslic3r/PrintObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -813,6 +813,7 @@ bool PrintObject::invalidate_state_by_config_options(
|| opt_key == "overhangs_width"
|| opt_key == "overhangs_reverse"
|| opt_key == "overhangs_reverse_threshold"
|| opt_key == "overhangs_speed_enforce"
|| opt_key == "perimeter_extrusion_change_odd_layers"
|| opt_key == "perimeter_extrusion_spacing"
|| opt_key == "perimeter_extrusion_width"
Expand Down Expand Up @@ -1055,7 +1056,6 @@ bool PrintObject::invalidate_state_by_config_options(
|| opt_key == "gap_fill_speed"
|| opt_key == "infill_speed"
|| opt_key == "overhangs_speed"
|| opt_key == "overhangs_speed_enforce"
|| opt_key == "perimeter_speed"
|| opt_key == "seam_position"
|| opt_key == "seam_preferred_direction"
Expand Down
4 changes: 3 additions & 1 deletion src/slic3r/GUI/ConfigManipulation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -338,13 +338,15 @@ void ConfigManipulation::toggle_print_fff_options(DynamicPrintConfig* config)
toggle_field(el, have_arachne);


for (auto el : {"perimeter_loop", "only_one_perimeter_top", "extra_perimeters_overhangs", "no_perimeter_unsupported_algo",
for (auto el : {"perimeter_loop", "extra_perimeters_overhangs", "no_perimeter_unsupported_algo",
"thin_perimeters", "overhangs_reverse", "perimeter_round_corners"})
toggle_field(el, have_perimeters && !have_arachne);

toggle_field("only_one_perimeter_top", have_perimeters); // with arachne, it will only do it for the last layer
toggle_field("only_one_perimeter_first_layer", config->opt_int("perimeters") > 1);
toggle_field("overhangs_width", config->option<ConfigOptionFloatOrPercent>("overhangs_width_speed")->value > 0);
toggle_field("overhangs_reverse_threshold", have_perimeters && config->opt_bool("overhangs_reverse"));
toggle_field("overhangs_speed_enforce", have_perimeters && !config->opt_bool("perimeter_loop"));
toggle_field("min_width_top_surface", have_perimeters && config->opt_bool("only_one_perimeter_top") && !have_arachne);
toggle_field("thin_perimeters_all", have_perimeters && config->option("thin_perimeters")->getFloat() != 0 && !have_arachne);
bool have_thin_wall = !have_arachne && have_perimeters;
Expand Down

0 comments on commit b380222

Please sign in to comment.