From f9344a00e37e179e44f970edd65fd124a9370a96 Mon Sep 17 00:00:00 2001 From: supermerill Date: Wed, 24 Jan 2018 22:26:59 +0100 Subject: [PATCH] Split external infill parameter to top/bottom external infill --- resources/profiles/PrusaResearch.ini | 3 +- slic3r.pl | 3 +- t/fill.t | 3 +- xs/src/libslic3r/Fill/Fill.cpp | 5 ++-- xs/src/libslic3r/PrintConfig.cpp | 43 +++++++++++++++++++++------- xs/src/libslic3r/PrintConfig.hpp | 6 ++-- xs/src/libslic3r/PrintObject.cpp | 3 +- xs/src/slic3r/GUI/Field.cpp | 2 +- xs/src/slic3r/GUI/GUI.cpp | 2 +- xs/src/slic3r/GUI/OptionsGroup.cpp | 2 +- xs/src/slic3r/GUI/Preset.cpp | 2 +- xs/src/slic3r/GUI/Tab.cpp | 15 +++++++--- 12 files changed, 63 insertions(+), 26 deletions(-) diff --git a/resources/profiles/PrusaResearch.ini b/resources/profiles/PrusaResearch.ini index 43d2ecbd1..9cb2b30f2 100644 --- a/resources/profiles/PrusaResearch.ini +++ b/resources/profiles/PrusaResearch.ini @@ -43,7 +43,8 @@ default_acceleration = 1000 dont_support_bridges = 1 elefant_foot_compensation = 0 ensure_vertical_shell_thickness = 1 -external_fill_pattern = rectilinear +top_fill_pattern = rectilinear +bottom_fill_pattern = rectilinear external_perimeters_first = 0 external_perimeter_extrusion_width = 0.45 extra_perimeters = 0 diff --git a/slic3r.pl b/slic3r.pl index d9bed0ab6..037910ed9 100755 --- a/slic3r.pl +++ b/slic3r.pl @@ -369,7 +369,8 @@ Usage: slic3r.pl [ OPTIONS ] [ file.stl ] [ file2.stl ] ... --fill-density Infill density (range: 0%-100%, default: $config->{fill_density}%) --fill-angle Infill angle in degrees (range: 0-90, default: $config->{fill_angle}) --fill-pattern Pattern to use to fill non-solid layers (default: $config->{fill_pattern}) - --external-fill-pattern Pattern to use to fill solid layers (default: $config->{external_fill_pattern}) + --top-fill-pattern Pattern to use to fill solid layers (default: $config->{top_fill_pattern}) + --bottom-fill-pattern Pattern to use to fill solid layers (default: $config->{bottom_fill_pattern}) --start-gcode Load initial G-code from the supplied file. This will overwrite the default command (home all axes [G28]). --end-gcode Load final G-code from the supplied file. This will overwrite diff --git a/t/fill.t b/t/fill.t index a6fe8619c..c7bfe7b80 100644 --- a/t/fill.t +++ b/t/fill.t @@ -165,7 +165,8 @@ SKIP: for my $pattern (qw(rectilinear honeycomb hilbertcurve concentric)) { my $config = Slic3r::Config::new_from_defaults; $config->set('fill_pattern', $pattern); - $config->set('external_fill_pattern', $pattern); + $config->set('top_fill_pattern', $pattern); + $config->set('bottom_fill_pattern', $pattern); $config->set('perimeters', 1); $config->set('skirts', 0); $config->set('fill_density', 20); diff --git a/xs/src/libslic3r/Fill/Fill.cpp b/xs/src/libslic3r/Fill/Fill.cpp index 5333fcfec..4461f0588 100644 --- a/xs/src/libslic3r/Fill/Fill.cpp +++ b/xs/src/libslic3r/Fill/Fill.cpp @@ -69,7 +69,8 @@ void make_fill(LayerRegion &layerm, ExtrusionEntityCollection &out) if (surface.is_solid() && (!surface.is_bridge() || layerm.layer()->id() == 0)) { group_attrib[i].is_solid = true; group_attrib[i].flow_width = (surface.surface_type == stTop) ? top_solid_infill_flow.width : solid_infill_flow.width; - group_attrib[i].pattern = surface.is_external() ? layerm.region()->config.external_fill_pattern.value : ipRectilinear; + group_attrib[i].pattern = (surface.surface_type == stTop && surface.is_external()) ? layerm.region()->config.top_fill_pattern.value : ipRectilinear; + group_attrib[i].pattern = (surface.surface_type == stBottom && surface.is_external()) ? layerm.region()->config.bottom_fill_pattern.value : ipRectilinear; } } // Loop through solid groups, find compatible groups and append them to this one. @@ -161,7 +162,7 @@ void make_fill(LayerRegion &layerm, ExtrusionEntityCollection &out) if (surface.is_solid()) { density = 100.; fill_pattern = (surface.is_external() && ! is_bridge) ? - layerm.region()->config.external_fill_pattern.value : + (surface.surface_type == stTop ? layerm.region()->config.top_fill_pattern.value : layerm.region()->config.bottom_fill_pattern.value) : ipRectilinear; } else if (density <= 0) continue; diff --git a/xs/src/libslic3r/PrintConfig.cpp b/xs/src/libslic3r/PrintConfig.cpp index d7ee1e591..044480d01 100644 --- a/xs/src/libslic3r/PrintConfig.cpp +++ b/xs/src/libslic3r/PrintConfig.cpp @@ -242,12 +242,11 @@ PrintConfigDef::PrintConfigDef() def->cli = "ensure-vertical-shell-thickness!"; def->default_value = new ConfigOptionBool(false); - def = this->add("external_fill_pattern", coEnum); - def->label = L("Top/bottom fill pattern"); + def = this->add("top_fill_pattern", coEnum); + def->label = L("Top fill pattern"); def->category = L("Infill"); - def->tooltip = L("Fill pattern for top/bottom infill. This only affects the external visible layer, " - "and not its adjacent solid shells."); - def->cli = "external-fill-pattern|solid-fill-pattern=s"; + def->tooltip = L("Fill pattern for top infill. This only affects the top external visible layer, and not its adjacent solid shells."); + def->cli = "top-fill-pattern|solid-fill-pattern=s"; def->enum_keys_map = &ConfigOptionEnum::get_enum_values(); def->enum_values.push_back("rectilinear"); def->enum_values.push_back("concentric"); @@ -259,10 +258,28 @@ PrintConfigDef::PrintConfigDef() def->enum_labels.push_back("Hilbert Curve"); def->enum_labels.push_back("Archimedean Chords"); def->enum_labels.push_back("Octagram Spiral"); - // solid_fill_pattern is an obsolete equivalent to external_fill_pattern. + // solid_fill_pattern is an obsolete equivalent to top_fill_pattern/bottom_fill_pattern. def->aliases.push_back("solid_fill_pattern"); def->default_value = new ConfigOptionEnum(ipRectilinear); + def = this->add("bottom_fill_pattern", coEnum); + def->label = L("bottom fill pattern"); + def->category = L("Infill"); + def->tooltip = L("Fill pattern for bottom infill. This only affects the bottom external visible layer, and not its adjacent solid shells."); + def->cli = "bottom-fill-pattern|solid-fill-pattern=s"; + def->enum_keys_map = &ConfigOptionEnum::get_enum_values(); + def->enum_values.push_back("rectilinear"); + def->enum_values.push_back("concentric"); + def->enum_values.push_back("hilbertcurve"); + def->enum_values.push_back("archimedeanchords"); + def->enum_values.push_back("octagramspiral"); + def->enum_labels.push_back("Rectilinear"); + def->enum_labels.push_back("Concentric"); + def->enum_labels.push_back("Hilbert Curve"); + def->enum_labels.push_back("Archimedean Chords"); + def->enum_labels.push_back("Octagram Spiral"); + def->default_value = new ConfigOptionEnum(ipRectilinear); + def = this->add("external_perimeter_extrusion_width", coFloatOrPercent); def->label = L("External perimeters"); def->category = L("Extrusion Width"); @@ -1961,13 +1978,19 @@ std::string FullPrintConfig::validate() if (! print_config_def.get("fill_pattern")->has_enum_value(this->fill_pattern.serialize())) return "Invalid value for --fill-pattern"; - // --external-fill-pattern - if (! print_config_def.get("external_fill_pattern")->has_enum_value(this->external_fill_pattern.serialize())) - return "Invalid value for --external-fill-pattern"; + // --top-fill-pattern + if (! print_config_def.get("top_fill_pattern")->has_enum_value(this->top_fill_pattern.serialize())) + return "Invalid value for --top-fill-pattern"; + + // --bottom-fill-pattern + if (! print_config_def.get("bottom_fill_pattern")->has_enum_value(this->bottom_fill_pattern.serialize())) + return "Invalid value for --bottom-fill-pattern"; // --fill-density if (fabs(this->fill_density.value - 100.) < EPSILON && - ! print_config_def.get("external_fill_pattern")->has_enum_value(this->fill_pattern.serialize())) + (! print_config_def.get("top_fill_pattern")->has_enum_value(this->fill_pattern.serialize()) + || ! print_config_def.get("bottom_fill_pattern")->has_enum_value(this->fill_pattern.serialize()) + )) return "The selected fill pattern is not supposed to work at 100% density"; // --infill-every-layers diff --git a/xs/src/libslic3r/PrintConfig.hpp b/xs/src/libslic3r/PrintConfig.hpp index cb94a7921..159af5e71 100644 --- a/xs/src/libslic3r/PrintConfig.hpp +++ b/xs/src/libslic3r/PrintConfig.hpp @@ -378,7 +378,8 @@ public: ConfigOptionFloat bridge_flow_ratio; ConfigOptionFloat bridge_speed; ConfigOptionBool ensure_vertical_shell_thickness; - ConfigOptionEnum external_fill_pattern; + ConfigOptionEnum top_fill_pattern; + ConfigOptionEnum bottom_fill_pattern; ConfigOptionFloatOrPercent external_perimeter_extrusion_width; ConfigOptionFloatOrPercent external_perimeter_speed; ConfigOptionBool external_perimeters_first; @@ -416,7 +417,8 @@ protected: OPT_PTR(bridge_flow_ratio); OPT_PTR(bridge_speed); OPT_PTR(ensure_vertical_shell_thickness); - OPT_PTR(external_fill_pattern); + OPT_PTR(top_fill_pattern); + OPT_PTR(bottom_fill_pattern); OPT_PTR(external_perimeter_extrusion_width); OPT_PTR(external_perimeter_speed); OPT_PTR(external_perimeters_first); diff --git a/xs/src/libslic3r/PrintObject.cpp b/xs/src/libslic3r/PrintObject.cpp index c61fc102b..6cbb776b4 100644 --- a/xs/src/libslic3r/PrintObject.cpp +++ b/xs/src/libslic3r/PrintObject.cpp @@ -198,7 +198,8 @@ bool PrintObject::invalidate_state_by_config_options(const std::vector(window)->GetSelection(); - if (m_opt_id.compare("external_fill_pattern") == 0) + if (m_opt_id.compare("top_fill_pattern") == 0 || m_opt_id.compare("bottom_fill_pattern") == 0 ) { if (!m_opt.enum_values.empty()){ std::string key = m_opt.enum_values[ret_enum]; diff --git a/xs/src/slic3r/GUI/GUI.cpp b/xs/src/slic3r/GUI/GUI.cpp index 0410b7969..3d6bf45dd 100644 --- a/xs/src/slic3r/GUI/GUI.cpp +++ b/xs/src/slic3r/GUI/GUI.cpp @@ -453,7 +453,7 @@ void change_opt_value(DynamicPrintConfig& config, t_config_option_key opt_key, b } break; case coEnum:{ - if (opt_key.compare("external_fill_pattern") == 0 || + if (opt_key.compare("top_fill_pattern") == 0 || opt_key.compare("bottom_fill_pattern") == 0 || opt_key.compare("fill_pattern") == 0) config.set_key_value(opt_key, new ConfigOptionEnum(boost::any_cast(value))); else if (opt_key.compare("gcode_flavor") == 0) diff --git a/xs/src/slic3r/GUI/OptionsGroup.cpp b/xs/src/slic3r/GUI/OptionsGroup.cpp index 0be24824c..28823a0ac 100644 --- a/xs/src/slic3r/GUI/OptionsGroup.cpp +++ b/xs/src/slic3r/GUI/OptionsGroup.cpp @@ -399,7 +399,7 @@ boost::any ConfigOptionsGroup::get_config_value(DynamicPrintConfig& config, std: ret = config.opt_int(opt_key, idx); break; case coEnum:{ - if (opt_key.compare("external_fill_pattern") == 0 || + if (opt_key.compare("top_fill_pattern") == 0 || opt_key.compare("bottom_fill_pattern") == 0 || opt_key.compare("fill_pattern") == 0 ){ ret = static_cast(config.option>(opt_key)->value); } diff --git a/xs/src/slic3r/GUI/Preset.cpp b/xs/src/slic3r/GUI/Preset.cpp index aa1917bd5..f398a1b85 100644 --- a/xs/src/slic3r/GUI/Preset.cpp +++ b/xs/src/slic3r/GUI/Preset.cpp @@ -180,7 +180,7 @@ const std::vector& Preset::print_options() static std::vector s_opts { "layer_height", "first_layer_height", "perimeters", "spiral_vase", "top_solid_layers", "bottom_solid_layers", "extra_perimeters", "ensure_vertical_shell_thickness", "avoid_crossing_perimeters", "thin_walls", "overhangs", - "seam_position", "external_perimeters_first", "fill_density", "fill_pattern", "external_fill_pattern", + "seam_position", "external_perimeters_first", "fill_density", "fill_pattern", "top_fill_pattern", "bottom_fill_pattern", "infill_every_layers", "infill_only_where_needed", "solid_infill_every_layers", "fill_angle", "bridge_angle", "solid_infill_below_area", "only_retract_when_crossing_perimeters", "infill_first", "max_print_speed", "max_volumetric_speed", "max_volumetric_extrusion_rate_slope_positive", "max_volumetric_extrusion_rate_slope_negative", diff --git a/xs/src/slic3r/GUI/Tab.cpp b/xs/src/slic3r/GUI/Tab.cpp index d0f9f0ce3..20051da7a 100644 --- a/xs/src/slic3r/GUI/Tab.cpp +++ b/xs/src/slic3r/GUI/Tab.cpp @@ -418,7 +418,8 @@ void TabPrint::build() optgroup = page->new_optgroup(_(L("Infill"))); optgroup->append_single_option_line("fill_density"); optgroup->append_single_option_line("fill_pattern"); - optgroup->append_single_option_line("external_fill_pattern"); + optgroup->append_single_option_line("top_fill_pattern"); + optgroup->append_single_option_line("bottom_fill_pattern"); optgroup = page->new_optgroup(_(L("Reducing printing time"))); optgroup->append_single_option_line("infill_every_layers"); @@ -721,9 +722,15 @@ void TabPrint::update() } } if (!str_fill_pattern.empty()){ - auto external_fill_pattern = m_config->def()->get("external_fill_pattern")->enum_values; + auto top_fill_pattern = m_config->def()->get("top_fill_pattern")->enum_values; bool correct_100p_fill = false; - for (auto fill : external_fill_pattern) + for (auto fill : top_fill_pattern) + { + if (str_fill_pattern.compare(fill) == 0) + correct_100p_fill = true; + } + auto bottom_fill_pattern = m_config->def()->get("bottom_fill_pattern")->enum_values; + for (auto fill : bottom_fill_pattern) { if (str_fill_pattern.compare(fill) == 0) correct_100p_fill = true; @@ -766,7 +773,7 @@ void TabPrint::update() bool have_solid_infill = m_config->opt_int("top_solid_layers") > 0 || m_config->opt_int("bottom_solid_layers") > 0; vec_enable.resize(0); - vec_enable = { "external_fill_pattern", "infill_first", "solid_infill_extruder", + vec_enable = { "top_fill_pattern", "bottom_fill_pattern", "infill_first", "solid_infill_extruder", "solid_infill_extrusion_width", "solid_infill_speed" }; // solid_infill_extruder uses the same logic as in Print::extruders() for (auto el : vec_enable)