diff --git a/src/libslic3r/Layer.cpp b/src/libslic3r/Layer.cpp index c120103ae..17d0c0e53 100644 --- a/src/libslic3r/Layer.cpp +++ b/src/libslic3r/Layer.cpp @@ -183,7 +183,8 @@ void Layer::make_perimeters() && config.infill_wall_overlap == other_config.infill_wall_overlap && config.fuzzy_skin == other_config.fuzzy_skin && config.fuzzy_skin_thickness == other_config.fuzzy_skin_thickness - && config.fuzzy_skin_point_distance == other_config.fuzzy_skin_point_distance) + && config.fuzzy_skin_point_distance == other_config.fuzzy_skin_point_distance + && config.fuzzy_skin_first_layer == other_config.fuzzy_skin_first_layer) { other_layerm->perimeters.clear(); other_layerm->fills.clear(); diff --git a/src/libslic3r/PerimeterGenerator.cpp b/src/libslic3r/PerimeterGenerator.cpp index e25068572..b9ab300dc 100644 --- a/src/libslic3r/PerimeterGenerator.cpp +++ b/src/libslic3r/PerimeterGenerator.cpp @@ -68,16 +68,14 @@ static void fuzzy_polygon(Polygon &poly, double fuzzy_skin_thickness, double fuz { // 'a' is the (next) new point between p0 and p1 Vec2d p0p1 = (p1 - *p0).cast(); double p0p1_size = p0p1.norm(); - // so that p0p1_size - dist_last_point evaulates to dist_left_over - p0p1_size - double dist_last_point = dist_left_over + p0p1_size * 2.; - for (double p0pa_dist = dist_left_over; p0pa_dist < p0p1_size; + double p0pa_dist = dist_left_over; + for (; p0pa_dist < p0p1_size; p0pa_dist += min_dist_between_points + double(rand()) * range_random_point_dist / double(RAND_MAX)) { double r = double(rand()) * (fuzzy_skin_thickness * 2.) / double(RAND_MAX) - fuzzy_skin_thickness; out.emplace_back(*p0 + (p0p1 * (p0pa_dist / p0p1_size) + perp(p0p1).cast().normalized() * r).cast()); - dist_last_point = p0pa_dist; } - dist_left_over = p0p1_size - dist_last_point; + dist_left_over = p0pa_dist - p0p1_size; p0 = &p1; } while (out.size() < 3) { @@ -96,7 +94,7 @@ static void fuzzy_extrusion_line(Arachne::ExtrusionLine& ext_lines, double fuzzy { const double min_dist_between_points = fuzzy_skin_point_dist * 3. / 4.; // hardcoded: the point distance may vary between 3/4 and 5/4 the supplied value const double range_random_point_dist = fuzzy_skin_point_dist / 2.; - double dist_left_over = double(rand()) * (min_dist_between_points / 2) / double(RAND_MAX); // the distance to be traversed on the line before making the first new point + double dist_left_over = double(rand()) * (min_dist_between_points / 2) / double(RAND_MAX); // the distance to be traversed on the line before making the first new point auto* p0 = &ext_lines.front(); std::vector out; @@ -110,14 +108,12 @@ static void fuzzy_extrusion_line(Arachne::ExtrusionLine& ext_lines, double fuzzy // 'a' is the (next) new point between p0 and p1 Vec2d p0p1 = (p1.p - p0->p).cast(); double p0p1_size = p0p1.norm(); - // so that p0p1_size - dist_last_point evaulates to dist_left_over - p0p1_size - double dist_last_point = dist_left_over + p0p1_size * 2.; - for (double p0pa_dist = dist_left_over; p0pa_dist < p0p1_size; p0pa_dist += min_dist_between_points + double(rand()) * range_random_point_dist / double(RAND_MAX)) { + double p0pa_dist = dist_left_over; + for (; p0pa_dist < p0p1_size; p0pa_dist += min_dist_between_points + double(rand()) * range_random_point_dist / double(RAND_MAX)) { double r = double(rand()) * (fuzzy_skin_thickness * 2.) / double(RAND_MAX) - fuzzy_skin_thickness; out.emplace_back(p0->p + (p0p1 * (p0pa_dist / p0p1_size) + perp(p0p1).cast().normalized() * r).cast(), p1.w, p1.perimeter_index); - dist_last_point = p0pa_dist; } - dist_left_over = p0p1_size - dist_last_point; + dist_left_over = p0pa_dist - p0p1_size; p0 = &p1; } @@ -2093,8 +2089,7 @@ void PerimeterGenerator::process_arachne() current_position = best_path->junctions.back().p; //Pick the other end from where we started. } } - - if (this->layer_id > 0 && this->config->fuzzy_skin != FuzzySkinType::None) { + if ((this->config->fuzzy_skin_first_layer || this->layer_id>0) && this->config->fuzzy_skin != FuzzySkinType::None) { std::vector closed_loop_extrusions; for (PerimeterGeneratorArachneExtrusion& extrusion : ordered_extrusions) if (extrusion.extrusion->inset_idx == 0) { diff --git a/src/libslic3r/Preset.cpp b/src/libslic3r/Preset.cpp index ef2c9108a..9136fec72 100644 --- a/src/libslic3r/Preset.cpp +++ b/src/libslic3r/Preset.cpp @@ -732,7 +732,7 @@ static std::vector s_Preset_print_options { "minimum_sparse_infill_area", "reduce_infill_retraction","internal_solid_infill_pattern", "ironing_type", "ironing_pattern", "ironing_flow", "ironing_speed", "ironing_spacing", "ironing_angle", "max_travel_detour_distance", - "fuzzy_skin", "fuzzy_skin_thickness", "fuzzy_skin_point_distance", + "fuzzy_skin", "fuzzy_skin_thickness", "fuzzy_skin_point_distance", "fuzzy_skin_first_layer", "max_volumetric_extrusion_rate_slope", "max_volumetric_extrusion_rate_slope_segment_length", "inner_wall_speed", "outer_wall_speed", "sparse_infill_speed", "internal_solid_infill_speed", "top_surface_speed", "support_speed", "support_object_xy_distance", "support_interface_speed", diff --git a/src/libslic3r/PrintConfig.cpp b/src/libslic3r/PrintConfig.cpp index 435f94b42..e8f921994 100644 --- a/src/libslic3r/PrintConfig.cpp +++ b/src/libslic3r/PrintConfig.cpp @@ -2101,6 +2101,13 @@ def = this->add("filament_loading_speed", coFloats); def->mode = comSimple; def->set_default_value(new ConfigOptionFloat(0.8)); + def = this->add("fuzzy_skin_first_layer", coBool); + def->label = L("Apply fuzzy skin to first layer"); + def->category = L("Others"); + def->tooltip = L("Whether to apply fuzzy skin on the first layer"); + def->mode = comSimple; + def->set_default_value(new ConfigOptionBool(0)); + def = this->add("filter_out_gap_fill", coFloat); def->label = L("Filter out tiny gaps"); def->category = L("Layers and Perimeters"); diff --git a/src/libslic3r/PrintConfig.hpp b/src/libslic3r/PrintConfig.hpp index 4306fcaf9..7cdd60514 100644 --- a/src/libslic3r/PrintConfig.hpp +++ b/src/libslic3r/PrintConfig.hpp @@ -811,6 +811,7 @@ PRINT_CONFIG_CLASS_DEFINE( ((ConfigOptionEnum, fuzzy_skin)) ((ConfigOptionFloat, fuzzy_skin_thickness)) ((ConfigOptionFloat, fuzzy_skin_point_distance)) + ((ConfigOptionBool, fuzzy_skin_first_layer)) ((ConfigOptionFloat, gap_infill_speed)) ((ConfigOptionInt, sparse_infill_filament)) ((ConfigOptionFloatOrPercent, sparse_infill_line_width)) diff --git a/src/libslic3r/PrintObject.cpp b/src/libslic3r/PrintObject.cpp index 4a5861460..d3ccbfbb3 100644 --- a/src/libslic3r/PrintObject.cpp +++ b/src/libslic3r/PrintObject.cpp @@ -1095,6 +1095,7 @@ bool PrintObject::invalidate_state_by_config_options( || opt_key == "fuzzy_skin" || opt_key == "fuzzy_skin_thickness" || opt_key == "fuzzy_skin_point_distance" + || opt_key == "fuzzy_skin_first_layer" || opt_key == "detect_overhang_wall" || opt_key == "overhang_reverse" || opt_key == "overhang_reverse_internal_only" diff --git a/src/slic3r/GUI/ConfigManipulation.cpp b/src/slic3r/GUI/ConfigManipulation.cpp index b26e3e8ca..64a0ac84e 100644 --- a/src/slic3r/GUI/ConfigManipulation.cpp +++ b/src/slic3r/GUI/ConfigManipulation.cpp @@ -702,7 +702,7 @@ void ConfigManipulation::toggle_print_fff_options(DynamicPrintConfig *config, co toggle_line("flush_into_objects", !is_global_config); bool has_fuzzy_skin = (config->opt_enum("fuzzy_skin") != FuzzySkinType::None); - for (auto el : { "fuzzy_skin_thickness", "fuzzy_skin_point_distance"}) + for (auto el : { "fuzzy_skin_thickness", "fuzzy_skin_point_distance", "fuzzy_skin_first_layer"}) toggle_line(el, has_fuzzy_skin); bool have_arachne = config->opt_enum("wall_generator") == PerimeterGeneratorType::Arachne; diff --git a/src/slic3r/GUI/Tab.cpp b/src/slic3r/GUI/Tab.cpp index d424dc1d3..3bf9d5523 100644 --- a/src/slic3r/GUI/Tab.cpp +++ b/src/slic3r/GUI/Tab.cpp @@ -2109,6 +2109,7 @@ void TabPrint::build() optgroup->append_single_option_line("fuzzy_skin"); optgroup->append_single_option_line("fuzzy_skin_point_distance"); optgroup->append_single_option_line("fuzzy_skin_thickness"); + optgroup->append_single_option_line("fuzzy_skin_first_layer"); optgroup = page->new_optgroup(L("G-code output"), L"param_gcode");