Skip to content

Commit

Permalink
#563 #589 Small perimeter control
Browse files Browse the repository at this point in the history
  • Loading branch information
supermerill committed Oct 21, 2020
1 parent 18847f5 commit ae6c979
Show file tree
Hide file tree
Showing 9 changed files with 78 additions and 12 deletions.
5 changes: 4 additions & 1 deletion resources/ui_layout/print.ui
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,6 @@ group:label_width$8:Speed for print moves
line:Perimeter speed
setting:width$4:perimeter_speed
setting:width$4:external_perimeter_speed
setting:width$4:small_perimeter_speed
end_line
line:Infill speed
setting:width$4:infill_speed
Expand All @@ -217,6 +216,10 @@ group:Modifiers
setting:label_width$8:width$4:first_layer_speed
setting:label_width$8:width$4:first_layer_infill_speed
end_line
line:Small perimeter speed
setting:label_width$8:width$4:small_perimeter_min_length
setting:label_width$8:width$4:small_perimeter_max_length
setting:label_width$8:width$4:small_perimeter_speed
group:Acceleration control (advanced)
setting:perimeter_acceleration
setting:infill_acceleration
Expand Down
35 changes: 30 additions & 5 deletions src/libslic3r/GCode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3034,8 +3034,16 @@ std::string GCode::extrude_loop_vase(const ExtrusionLoop &original_loop, const s
if (paths.empty()) return "";

// apply the small/external? perimeter speed
if (is_perimeter(paths.front().role()) && loop.length() <= SMALL_PERIMETER_LENGTH && speed == -1)
speed = m_config.external_perimeter_speed.get_abs_value(m_config.perimeter_speed);
if (speed == -1 && is_perimeter(paths.front().role()) && loop.length() <=
scale_(this->m_config.small_perimeter_max_length.get_abs_value(EXTRUDER_CONFIG_WITH_DEFAULT(nozzle_diameter, 0)))) {
double min_length = scale_(this->m_config.small_perimeter_min_length.get_abs_value(EXTRUDER_CONFIG_WITH_DEFAULT(nozzle_diameter, 0)));
double max_length = scale_(this->m_config.small_perimeter_max_length.get_abs_value(EXTRUDER_CONFIG_WITH_DEFAULT(nozzle_diameter, 0)));
if (loop.length() <= min_length) {
speed = m_config.small_perimeter_speed.get_abs_value(m_config.perimeter_speed);
} else {
speed = - (loop.length() - min_length) / (max_length - min_length);
}
}

//get extrusion length
coordf_t length = 0;
Expand Down Expand Up @@ -3552,8 +3560,16 @@ std::string GCode::extrude_loop(const ExtrusionLoop &original_loop, const std::s
if (paths.empty()) return "";

// apply the small perimeter speed
if (is_perimeter(paths.front().role()) && loop.length() <= SMALL_PERIMETER_LENGTH && speed == -1)
speed = m_config.small_perimeter_speed.get_abs_value(m_config.perimeter_speed);
if (speed == -1 && is_perimeter(paths.front().role()) && loop.length() <=
scale_(this->m_config.small_perimeter_max_length.get_abs_value(EXTRUDER_CONFIG_WITH_DEFAULT(nozzle_diameter, 0)))) {
double min_length = scale_(this->m_config.small_perimeter_min_length.get_abs_value(EXTRUDER_CONFIG_WITH_DEFAULT(nozzle_diameter, 0)));
double max_length = scale_(this->m_config.small_perimeter_max_length.get_abs_value(EXTRUDER_CONFIG_WITH_DEFAULT(nozzle_diameter, 0)));
if (loop.length() <= min_length) {
speed = m_config.small_perimeter_speed.get_abs_value(m_config.perimeter_speed);
} else {
speed = -(loop.length() - min_length) / (max_length - min_length);
}
}

// extrude along the path
std::string gcode;
Expand Down Expand Up @@ -4130,7 +4146,10 @@ std::string GCode::_before_extrude(const ExtrusionPath &path, const std::string


// set speed
if (speed == -1) {
if (speed < 0) {
//if speed == -1, then it's means "choose yourself, but if it's -1 < speed <0 , then it's a scaling from small_periemter.
//it's a bit hacky, so if you want to rework it, help yourself.
float factor = (-speed);
if (path.role() == erPerimeter) {
speed = m_config.get_abs_value("perimeter_speed");
} else if (path.role() == erExternalPerimeter) {
Expand All @@ -4154,6 +4173,12 @@ std::string GCode::_before_extrude(const ExtrusionPath &path, const std::string
} else {
throw std::invalid_argument("Invalid speed");
}
//don't modify bridge speed
if (factor < 1 && !(path.role() == erOverhangPerimeter || path.role() == erBridgeInfill)) {
float small_speed = m_config.small_perimeter_speed.get_abs_value(m_config.perimeter_speed);
//apply factor between feature speed and small speed
speed = speed * factor + (1 - factor) * small_speed;
}
}
if (m_volumetric_speed != 0. && speed == 0)
speed = m_volumetric_speed / path.mm3_per_mm;
Expand Down
2 changes: 2 additions & 0 deletions src/libslic3r/Layer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,8 @@ void Layer::make_perimeters()
&& config.perimeter_overlap == other_config.perimeter_overlap
&& config.perimeter_speed == other_config.perimeter_speed // it os mandatory? can't this be set at gcode.cpp?
&& config.small_perimeter_speed == other_config.small_perimeter_speed
&& config.small_perimeter_min_length == other_config.small_perimeter_min_length
&& config.small_perimeter_max_length == other_config.small_perimeter_max_length
&& config.thin_walls == other_config.thin_walls
&& config.thin_walls_min_width == other_config.thin_walls_min_width
&& config.thin_walls_overlap == other_config.thin_walls_overlap
Expand Down
32 changes: 29 additions & 3 deletions src/libslic3r/PrintConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2838,18 +2838,44 @@ void PrintConfigDef::init_fff_params()
def->set_default_value(new ConfigOptionInts{ 5 });

def = this->add("small_perimeter_speed", coFloatOrPercent);
def->label = L("Small");
def->label = L("Speed");
def->full_label = ("Small perimeters speed");
def->category = OptionCategory::speed;
def->tooltip = L("This separate setting will affect the speed of perimeters having radius <= 6.5mm "
"(usually holes). If expressed as percentage (for example: 80%) it will be calculated "
"on the perimeters speed setting above. Set to zero for auto.");
"(usually holes). If expressed as percentage (for example: 80%) it will be calculated "
"on the perimeters speed setting above. Set to zero for auto.");
def->sidetext = L("mm/s or %");
def->ratio_over = "perimeter_speed";
def->min = 0;
def->mode = comAdvanced;
def->set_default_value(new ConfigOptionFloatOrPercent(15, false));

def = this->add("small_perimeter_min_length", coFloatOrPercent);
def->label = L("Min length");
def->full_label = ("Min small perimeters length");
def->category = OptionCategory::speed;
def->tooltip = L("This set the threshold for small periemter length. Every loop with a length lower than that will be printed at small perimeter speed"
"\nCan be a mm or a % of the nozzle diameter.");
def->sidetext = L("mm or %");
def->ratio_over = "nozzle_diameter";
def->min = 0;
def->mode = comAdvanced;
def->set_default_value(new ConfigOptionFloatOrPercent(6, false));


def = this->add("small_perimeter_max_length", coFloatOrPercent);
def->label = L("Max length");
def->full_label = ("Max small perimeters length");
def->category = OptionCategory::speed;
def->tooltip = L("This set the end of the threshold for small periemter length."
" Every periemter loop lower than that will see their speed reduced a bit, from their normal spee at this length down to small perimeter speed."
"\nCan be a mm or a % of the nozzle diameter.");
def->sidetext = L("mm or %");
def->ratio_over = "nozzle_diameter";
def->min = 0;
def->mode = comAdvanced;
def->set_default_value(new ConfigOptionFloatOrPercent(20, false));

def = this->add("curve_smoothing_angle_convex", coFloat);
def->label = L("Min convex angle");
def->full_label = L("Curve smoothing minimum angle (convex)");
Expand Down
4 changes: 4 additions & 0 deletions src/libslic3r/PrintConfig.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -711,6 +711,8 @@ class PrintRegionConfig : public StaticPrintConfig
ConfigOptionPercent print_extrusion_multiplier;
ConfigOptionFloat print_retract_length;
ConfigOptionFloatOrPercent small_perimeter_speed;
ConfigOptionFloatOrPercent small_perimeter_min_length;
ConfigOptionFloatOrPercent small_perimeter_max_length;
ConfigOptionEnum<InfillPattern> solid_fill_pattern;
ConfigOptionFloat solid_infill_below_area;
ConfigOptionInt solid_infill_extruder;
Expand Down Expand Up @@ -802,6 +804,8 @@ class PrintRegionConfig : public StaticPrintConfig
OPT_PTR(print_extrusion_multiplier);
OPT_PTR(print_retract_length);
OPT_PTR(small_perimeter_speed);
OPT_PTR(small_perimeter_min_length);
OPT_PTR(small_perimeter_max_length);
OPT_PTR(solid_fill_pattern);
OPT_PTR(solid_infill_below_area);
OPT_PTR(solid_infill_extruder);
Expand Down
2 changes: 2 additions & 0 deletions src/libslic3r/PrintObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -753,6 +753,8 @@ bool PrintObject::invalidate_state_by_config_options(const std::vector<t_config_
|| opt_key == "seam_preferred_direction_jitter"
|| opt_key == "seam_travel"
|| opt_key == "small_perimeter_speed"
|| opt_key == "small_perimeter_min_length"
|| opt_key == "small_perimeter_max_length"
|| opt_key == "solid_infill_speed"
|| opt_key == "support_material_interface_speed"
|| opt_key == "support_material_speed"
Expand Down
2 changes: 1 addition & 1 deletion src/libslic3r/libslic3r.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ typedef double coordf_t;
// When extruding a closed loop, the loop is interrupted and shortened a bit to reduce the seam.
#define LOOP_CLIPPING_LENGTH_OVER_NOZZLE_DIAMETER 0.15
// Maximum perimeter length for the loop to apply the small perimeter speed.
#define SMALL_PERIMETER_LENGTH (6.5 / SCALING_FACTOR) * 2 * PI
//#define SMALL_PERIMETER_LENGTH (6.5 / SCALING_FACTOR) * 2 * PI
#define INSET_OVERLAP_TOLERANCE 0.4
//FIXME Better to use an inline function with an explicit return type.
//inline coord_t scale_(coordf_t v) { return coord_t(floor(v / SCALING_FACTOR + 0.5f)); }
Expand Down
2 changes: 1 addition & 1 deletion src/slic3r/GUI/ConfigManipulation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ void ConfigManipulation::toggle_print_fff_options(DynamicPrintConfig* config)
"only_one_perimeter_top", "ensure_vertical_shell_thickness", "thin_walls",
"overhangs", "overhangs_reverse",
"seam_position", "external_perimeters_first", "external_perimeters_vase", "external_perimeter_extrusion_width",
"perimeter_speed", "small_perimeter_speed", "external_perimeter_speed", "perimeter_loop", "perimeter_loop_seam" })
"perimeter_speed", "small_perimeter_speed", "small_perimeter_min_length", " small_perimeter_max_length", "external_perimeter_speed", "perimeter_loop", "perimeter_loop_seam" })
toggle_field(el, have_perimeters);

toggle_field("overhangs_width", config->option<ConfigOptionFloatOrPercent>("overhangs_width_speed")->value > 0);
Expand Down
6 changes: 5 additions & 1 deletion src/slic3r/GUI/Preset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,11 @@ const std::vector<std::string>& Preset::print_options()
"max_volumetric_extrusion_rate_slope_positive", "max_volumetric_extrusion_rate_slope_negative",
#endif /* HAS_PRESSURE_EQUALIZER */
"min_width_top_surface",
"perimeter_speed", "small_perimeter_speed", "external_perimeter_speed", "infill_speed", "solid_infill_speed",
"perimeter_speed",
"small_perimeter_speed",
"small_perimeter_min_length",
"small_perimeter_max_length",
"external_perimeter_speed", "infill_speed", "solid_infill_speed",
"top_solid_infill_speed", "support_material_speed", "support_material_xy_spacing", "support_material_interface_speed",
"bridge_speed",
"gap_fill",
Expand Down

0 comments on commit ae6c979

Please sign in to comment.