From 957803e60c74584991efdaa90ed72bbeb651ed3e Mon Sep 17 00:00:00 2001 From: bubnikv Date: Tue, 7 Feb 2017 18:46:02 +0100 Subject: [PATCH] Added min_layer_height, max_layer_height per nozzle settings for controlling the support layer height & variable layer height. Added an experimental "rear" seam option. --- lib/Slic3r/GUI/Tab.pm | 7 +++++- xs/src/libslic3r/GCode.cpp | 40 +++++++++++++++++++++----------- xs/src/libslic3r/PrintConfig.cpp | 28 ++++++++++++++++++++-- xs/src/libslic3r/PrintConfig.hpp | 8 +++++-- 4 files changed, 64 insertions(+), 19 deletions(-) diff --git a/lib/Slic3r/GUI/Tab.pm b/lib/Slic3r/GUI/Tab.pm index eafa5f1a6..68b623cda 100644 --- a/lib/Slic3r/GUI/Tab.pm +++ b/lib/Slic3r/GUI/Tab.pm @@ -1402,7 +1402,7 @@ sub _extruders_count_changed { $self->_on_value_change('extruders_count', $extruders_count); } -sub _extruder_options { qw(nozzle_diameter extruder_offset retract_length retract_lift retract_lift_above retract_lift_below retract_speed retract_restart_extra retract_before_travel wipe +sub _extruder_options { qw(nozzle_diameter min_layer_height max_layer_height extruder_offset retract_length retract_lift retract_lift_above retract_lift_below retract_speed retract_restart_extra retract_before_travel wipe retract_layer_change retract_length_toolchange retract_restart_extra_toolchange) } sub _build_extruder_pages { @@ -1431,6 +1431,11 @@ sub _build_extruder_pages { my $optgroup = $page->new_optgroup('Size'); $optgroup->append_single_option_line('nozzle_diameter', $extruder_idx); } + { + my $optgroup = $page->new_optgroup('Limits'); + $optgroup->append_single_option_line($_, $extruder_idx) + for qw(min_layer_height max_layer_height); + } { my $optgroup = $page->new_optgroup('Position (for multi-extruder printers)'); $optgroup->append_single_option_line('extruder_offset', $extruder_idx); diff --git a/xs/src/libslic3r/GCode.cpp b/xs/src/libslic3r/GCode.cpp index 6f3d3296f..2aeb7fc60 100644 --- a/xs/src/libslic3r/GCode.cpp +++ b/xs/src/libslic3r/GCode.cpp @@ -565,31 +565,42 @@ GCode::extrude(ExtrusionLoop loop, std::string description, double speed) bool was_clockwise = loop.make_counter_clockwise(); SeamPosition seam_position = this->config.seam_position; - if (loop.role == elrSkirt) seam_position = spNearest; + if (loop.role == elrSkirt) + seam_position = spNearest; // find the point of the loop that is closest to the current extruder position // or randomize if requested Point last_pos = this->last_pos(); if (this->config.spiral_vase) { loop.split_at(last_pos, false); - } else if (seam_position == spNearest || seam_position == spAligned) { + } else if (seam_position == spNearest || seam_position == spAligned || seam_position == spRear) { Polygon polygon = loop.polygon(); const coordf_t nozzle_dmr = EXTRUDER_CONFIG(nozzle_diameter); const coord_t nozzle_r = scale_(0.5*nozzle_dmr); // Retrieve the last start position for this object. float last_pos_weight = 1.f; - if (seam_position == spAligned && this->layer != NULL && this->_seam_position.count(this->layer->object()) > 0) { - last_pos = this->_seam_position[this->layer->object()]; + switch (seam_position) { + case spAligned: + // Seam is aligned to the seam at the preceding layer. + if (this->layer != NULL && this->_seam_position.count(this->layer->object()) > 0) { + last_pos = this->_seam_position[this->layer->object()]; + last_pos_weight = 5.f; + } + break; + case spRear: + last_pos = this->layer->object()->bounding_box().center(); + last_pos.y += coord_t(3. * this->layer->object()->bounding_box().radius()); last_pos_weight = 5.f; + break; } // Insert a projection of last_pos into the polygon. - size_t last_pos_proj_idx; - { - Points::iterator it = project_point_to_polygon_and_insert(polygon, last_pos, 0.1 * nozzle_r); - last_pos_proj_idx = it - polygon.points.begin(); - } + size_t last_pos_proj_idx; + { + Points::iterator it = project_point_to_polygon_and_insert(polygon, last_pos, 0.1 * nozzle_r); + last_pos_proj_idx = it - polygon.points.begin(); + } Point last_pos_proj = polygon.points[last_pos_proj_idx]; // Parametrize the polygon by its length. std::vector lengths = polygon_parameter_by_length(polygon); @@ -661,8 +672,8 @@ GCode::extrude(ExtrusionLoop loop, std::string description, double speed) { static int iRun = 0; SVG svg(debug_out_path("GCode_extrude_loop-%d.svg", iRun ++)); - if (this->layer->lower_layer != NULL) - svg.draw(this->layer->lower_layer->slices.expolygons); + if (this->layer->lower_layer != NULL) + svg.draw(this->layer->lower_layer->slices.expolygons); for (size_t i = 0; i < loop.paths.size(); ++ i) svg.draw(loop.paths[i].as_polyline(), "red"); Polylines polylines; @@ -673,9 +684,9 @@ GCode::extrude(ExtrusionLoop loop, std::string description, double speed) coord_t delta = scale_(0.5*nozzle_dmr); Slic3r::offset(polylines, &polygons, delta); // for (size_t i = 0; i < polygons.size(); ++ i) svg.draw((Polyline)polygons[i], "blue"); - svg.draw(last_pos, "green", 3); - svg.draw(polygon.points[idx_min], "yellow", 3); - svg.Close(); + svg.draw(last_pos, "green", 3); + svg.draw(polygon.points[idx_min], "yellow", 3); + svg.Close(); } #endif @@ -696,6 +707,7 @@ GCode::extrude(ExtrusionLoop loop, std::string description, double speed) last_pos = Point(polygon.bounding_box().max.x, centroid.y); last_pos.rotate(fmod((float)rand()/16.0, 2.0*PI), centroid); } + // Find the closest point, avoid overhangs. loop.split_at(last_pos, true); } diff --git a/xs/src/libslic3r/PrintConfig.cpp b/xs/src/libslic3r/PrintConfig.cpp index 9b4a0e7e4..9a8915db0 100644 --- a/xs/src/libslic3r/PrintConfig.cpp +++ b/xs/src/libslic3r/PrintConfig.cpp @@ -618,6 +618,18 @@ PrintConfigDef::PrintConfigDef() def->max = 100; def->default_value = new ConfigOptionInt(100); + def = this->add("max_layer_height", coFloats); + def->label = "Max"; + def->tooltip = "This is the highest printable layer height for this extruder, used to cap the variable layer height and support layer height. Maximum recommended layer height is 75% of the extrusion width to achieve reasonable inter-layer adhesion. If set to 0, layer height is limited to 75% of the nozzle diameter."; + def->sidetext = "mm"; + def->cli = "max-layer-height=f@"; + def->min = 0; + { + ConfigOptionFloats* opt = new ConfigOptionFloats(); + opt->values.push_back(0); + def->default_value = opt; + } + def = this->add("max_print_speed", coFloat); def->label = "Max print speed"; def->tooltip = "When setting other speed settings to 0 Slic3r will autocalculate the optimal speed in order to keep constant extruder pressure. This experimental setting is used to set the highest print speed you want to allow."; @@ -661,6 +673,18 @@ PrintConfigDef::PrintConfigDef() def->max = 100; def->default_value = new ConfigOptionInt(35); + def = this->add("min_layer_height", coFloats); + def->label = "Min"; + def->tooltip = "This is the lowest printable layer height for this extruder and limits the resolution for variable layer height. Typical values are between 0.05 mm and 0.1 mm."; + def->sidetext = "mm"; + def->cli = "min-layer-height=f@"; + def->min = 0; + { + ConfigOptionFloats* opt = new ConfigOptionFloats(); + opt->values.push_back(0.07); + def->default_value = opt; + } + def = this->add("min_print_speed", coFloat); def->label = "Min print speed"; def->tooltip = "Slic3r will not scale speed down below this speed."; @@ -942,11 +966,11 @@ PrintConfigDef::PrintConfigDef() def->enum_values.push_back("random"); def->enum_values.push_back("nearest"); def->enum_values.push_back("aligned"); -// def->enum_values.push_back("preferred"); + def->enum_values.push_back("rear"); def->enum_labels.push_back("Random"); def->enum_labels.push_back("Nearest"); def->enum_labels.push_back("Aligned"); -// def->enum_labels.push_back("Preferred Direction"); + def->enum_labels.push_back("Rear"); def->default_value = new ConfigOptionEnum(spAligned); #if 0 diff --git a/xs/src/libslic3r/PrintConfig.hpp b/xs/src/libslic3r/PrintConfig.hpp index c8933bcd9..53a211f5d 100644 --- a/xs/src/libslic3r/PrintConfig.hpp +++ b/xs/src/libslic3r/PrintConfig.hpp @@ -39,7 +39,7 @@ enum SupportMaterialPattern { }; enum SeamPosition { - spRandom, spNearest, spAligned //, spPreferred + spRandom, spNearest, spAligned, spRear }; template<> inline t_config_enum_values ConfigOptionEnum::get_enum_values() { @@ -85,7 +85,7 @@ template<> inline t_config_enum_values ConfigOptionEnum::get_enum_ keys_map["random"] = spRandom; keys_map["nearest"] = spNearest; keys_map["aligned"] = spAligned; -// keys_map["preferred"] = spPreferred; + keys_map["rear"] = spRear; return keys_map; } @@ -404,7 +404,9 @@ class PrintConfig : public GCodeConfig ConfigOptionFloat infill_acceleration; ConfigOptionBool infill_first; ConfigOptionInt max_fan_speed; + ConfigOptionFloats max_layer_height; ConfigOptionInt min_fan_speed; + ConfigOptionFloats min_layer_height; ConfigOptionFloat min_print_speed; ConfigOptionFloat min_skirt_length; ConfigOptionString notes; @@ -461,7 +463,9 @@ class PrintConfig : public GCodeConfig OPT_PTR(infill_acceleration); OPT_PTR(infill_first); OPT_PTR(max_fan_speed); + OPT_PTR(max_layer_height); OPT_PTR(min_fan_speed); + OPT_PTR(min_layer_height); OPT_PTR(min_print_speed); OPT_PTR(min_skirt_length); OPT_PTR(notes);