diff --git a/src/libslic3r/PerimeterGenerator.cpp b/src/libslic3r/PerimeterGenerator.cpp index ffda2b50d82..f4abcd898ec 100644 --- a/src/libslic3r/PerimeterGenerator.cpp +++ b/src/libslic3r/PerimeterGenerator.cpp @@ -154,6 +154,7 @@ static void fuzzy_extrusion_line(std::vector& ext_li const double min_dist_between_points = cfg.point_distance * 3. / 4.; // hardcoded: the point distance may vary between 3/4 and 5/4 the supplied value const double range_random_point_dist = cfg.point_distance / 2.; + const double min_extrusion_width = 0.01; // workaround for many print options. Need overwrite formula with the layer height parameter. The width must more than >>> layer_height * (1 - 0.25 * PI) * 1.05 <<< (last num is the coeff of overlay error case) double dist_left_over = random_value() * (min_dist_between_points / 2.); // the distance to be traversed on the line before making the first new point auto* p0 = &ext_lines.front(); @@ -172,7 +173,18 @@ static void fuzzy_extrusion_line(std::vector& ext_li for (; p0pa_dist < p0p1_size; p0pa_dist += min_dist_between_points + random_value() * range_random_point_dist) { Point pa = p0->p + (p0p1 * (p0pa_dist / p0p1_size)).cast(); double r = noise->GetValue(unscale_(pa.x()), unscale_(pa.y()), slice_z) * cfg.thickness; - out.emplace_back(pa + (perp(p0p1).cast().normalized() * r).cast(), p1.w, p1.perimeter_index); + switch (cfg.mode) { //the curly code for testing + case FuzzySkinMode::Displacement : + out.emplace_back(pa + (perp(p0p1).cast().normalized() * r).cast(), p1.w, p1.perimeter_index); + break; + case FuzzySkinMode::Extrusion : + out.emplace_back(pa, std::max(p1.w + r + min_extrusion_width, min_extrusion_width), p1.perimeter_index); + break; + case FuzzySkinMode::Combined : + double rad = std::max(p1.w + r + min_extrusion_width, min_extrusion_width); + out.emplace_back(pa + (perp(p0p1).cast().normalized() * ((rad - p1.w) / 2)).cast(), rad, p1.perimeter_index); //0.05 - minimum width of extruded line + break; + } } dist_left_over = p0pa_dist - p0p1_size; p0 = &p1; @@ -186,8 +198,10 @@ static void fuzzy_extrusion_line(std::vector& ext_li --point_idx; } - if (ext_lines.back().p == ext_lines.front().p) // Connect endpoints. + if (ext_lines.back().p == ext_lines.front().p) { // Connect endpoints. out.front().p = out.back().p; + out.front().w = out.back().w; + } if (out.size() >= 3) ext_lines = std::move(out); @@ -1914,7 +1928,8 @@ static void group_region_by_fuzzify(PerimeterGenerator& g) region_config.fuzzy_skin_noise_type, region_config.fuzzy_skin_scale, region_config.fuzzy_skin_octaves, - region_config.fuzzy_skin_persistence + region_config.fuzzy_skin_persistence, + region_config.fuzzy_skin_mode }; auto& surfaces = regions[cfg]; for (const auto& surface : region->slices.surfaces) { diff --git a/src/libslic3r/PerimeterGenerator.hpp b/src/libslic3r/PerimeterGenerator.hpp index c9767f421c3..9dbfa213e39 100644 --- a/src/libslic3r/PerimeterGenerator.hpp +++ b/src/libslic3r/PerimeterGenerator.hpp @@ -20,6 +20,7 @@ struct FuzzySkinConfig double noise_scale; int noise_octaves; double noise_persistence; + FuzzySkinMode mode; bool operator==(const FuzzySkinConfig& r) const { @@ -30,7 +31,8 @@ struct FuzzySkinConfig && noise_type == r.noise_type && noise_scale == r.noise_scale && noise_octaves == r.noise_octaves - && noise_persistence == r.noise_persistence; + && noise_persistence == r.noise_persistence + && mode == r.mode; } bool operator!=(const FuzzySkinConfig& r) const { return !(*this == r); } diff --git a/src/libslic3r/Preset.cpp b/src/libslic3r/Preset.cpp index df54335939e..dbf7e04ea23 100644 --- a/src/libslic3r/Preset.cpp +++ b/src/libslic3r/Preset.cpp @@ -790,7 +790,7 @@ static std::vector s_Preset_print_options { "minimum_sparse_infill_area", "reduce_infill_retraction","internal_solid_infill_pattern","gap_fill_target", "ironing_type", "ironing_pattern", "ironing_flow", "ironing_speed", "ironing_spacing", "ironing_angle", "ironing_inset", "max_travel_detour_distance", - "fuzzy_skin", "fuzzy_skin_thickness", "fuzzy_skin_point_distance", "fuzzy_skin_first_layer", "fuzzy_skin_noise_type", "fuzzy_skin_scale", "fuzzy_skin_octaves", "fuzzy_skin_persistence", + "fuzzy_skin", "fuzzy_skin_thickness", "fuzzy_skin_point_distance", "fuzzy_skin_first_layer", "fuzzy_skin_noise_type", "fuzzy_skin_mode", "fuzzy_skin_scale", "fuzzy_skin_octaves", "fuzzy_skin_persistence", "max_volumetric_extrusion_rate_slope", "max_volumetric_extrusion_rate_slope_segment_length","extrusion_rate_smoothing_external_perimeter_only", "inner_wall_speed", "outer_wall_speed", "sparse_infill_speed", "internal_solid_infill_speed", "top_surface_speed", "support_speed", "support_object_xy_distance", "support_object_first_layer_gap", "support_interface_speed", diff --git a/src/libslic3r/PrintConfig.cpp b/src/libslic3r/PrintConfig.cpp index 9e9b43c61f8..e90ffd34226 100644 --- a/src/libslic3r/PrintConfig.cpp +++ b/src/libslic3r/PrintConfig.cpp @@ -118,7 +118,6 @@ static t_config_enum_values s_keys_map_GCodeFlavor { }; CONFIG_OPTION_ENUM_DEFINE_STATIC_MAPS(GCodeFlavor) - static t_config_enum_values s_keys_map_FuzzySkinType { { "none", int(FuzzySkinType::None) }, { "external", int(FuzzySkinType::External) }, @@ -136,6 +135,13 @@ static t_config_enum_values s_keys_map_NoiseType { }; CONFIG_OPTION_ENUM_DEFINE_STATIC_MAPS(NoiseType) +static t_config_enum_values s_keys_map_FuzzySkinMode { + { "displacement", int(FuzzySkinMode::Displacement) }, + { "extrusion", int(FuzzySkinMode::Extrusion) }, + { "combined", int(FuzzySkinMode::Combined)} +}; +CONFIG_OPTION_ENUM_DEFINE_STATIC_MAPS(FuzzySkinMode) + static t_config_enum_values s_keys_map_InfillPattern { { "concentric", ipConcentric }, { "zig-zag", ipRectilinear }, @@ -2784,6 +2790,29 @@ void PrintConfigDef::init_fff_params() def->mode = comSimple; def->set_default_value(new ConfigOptionBool(0)); + def = this->add("fuzzy_skin_mode", coEnum); + def->label = L("Fuzzy skin generator mode"); + def->category = L("Others"); + def->tooltip = L("Fuzzy skin generation mode. Works only with Arachne!\n" + "Displacement: Сlassic mode when the pattern is formed by shifting the nozzle sideways from the original path.\n" + "Extrusion: The mode when the pattern formed by the amount of extruded plastic. " + "This is the fast and straight algorithm without unnecessary nozzle shake that gives a smooth pattern. " + "But it is more useful for forming loose walls in the entire they array.\n" + "Combined: Joint mode [Displacement] + [Extrusion]. The appearance of the walls is similar to [Displacement] Mode, but it leaves no pores between the perimeters.\n\n" + "Attention! The [Extrusion] and [Combined] modes works only the fuzzy_skin_thickness parameter not more than the thickness of printed loop." + "At the same time, the width of the extrusion for a particular layer should also not be below a certain level. " + "It is usually equal 15-25%% of a layer height. Therefore, the maximum fuzzy skin thickness with a perimeter width of 0.4 mm and a layer height of 0.2 mm will be 0.4-(0.2*0.25)=±0.35mm! " + "If you enter a higher parameter than this, the error Flow::spacing() will displayed, and the model will not be sliced. You can choose this number until this error is repeated." ); + def->enum_keys_map = &ConfigOptionEnum::get_enum_values(); + def->enum_values.push_back("displacement"); + def->enum_values.push_back("extrusion"); + def->enum_values.push_back("combined"); + def->enum_labels.push_back(L("Displacement")); + def->enum_labels.push_back(L("Extrusion")); + def->enum_labels.push_back(L("Combined")); + def->mode = comSimple; + def->set_default_value(new ConfigOptionEnum(FuzzySkinMode::Displacement)); + def = this->add("fuzzy_skin_noise_type", coEnum); def->label = L("Fuzzy skin noise type"); def->category = L("Others"); diff --git a/src/libslic3r/PrintConfig.hpp b/src/libslic3r/PrintConfig.hpp index 95540005b45..8ddef25e107 100644 --- a/src/libslic3r/PrintConfig.hpp +++ b/src/libslic3r/PrintConfig.hpp @@ -34,6 +34,7 @@ enum GCodeFlavor : unsigned char { gcfSmoothie, gcfNoExtrusion }; + enum class FuzzySkinType { None, External, @@ -41,6 +42,12 @@ enum class FuzzySkinType { AllWalls, }; +enum class FuzzySkinMode { + Displacement, + Extrusion, + Combined, +}; + enum class NoiseType { Classic, Perlin, @@ -416,6 +423,7 @@ static std::string get_bed_temp_1st_layer_key(const BedType type) CONFIG_OPTION_ENUM_DECLARE_STATIC_MAPS(PrinterTechnology) CONFIG_OPTION_ENUM_DECLARE_STATIC_MAPS(GCodeFlavor) CONFIG_OPTION_ENUM_DECLARE_STATIC_MAPS(FuzzySkinType) +CONFIG_OPTION_ENUM_DECLARE_STATIC_MAPS(FuzzySkinMode) CONFIG_OPTION_ENUM_DECLARE_STATIC_MAPS(NoiseType) CONFIG_OPTION_ENUM_DECLARE_STATIC_MAPS(InfillPattern) CONFIG_OPTION_ENUM_DECLARE_STATIC_MAPS(IroningType) @@ -944,6 +952,7 @@ PRINT_CONFIG_CLASS_DEFINE( ((ConfigOptionFloat, fuzzy_skin_point_distance)) ((ConfigOptionBool, fuzzy_skin_first_layer)) ((ConfigOptionEnum, fuzzy_skin_noise_type)) + ((ConfigOptionEnum, fuzzy_skin_mode)) ((ConfigOptionFloat, fuzzy_skin_scale)) ((ConfigOptionInt, fuzzy_skin_octaves)) ((ConfigOptionFloat, fuzzy_skin_persistence)) diff --git a/src/libslic3r/PrintObject.cpp b/src/libslic3r/PrintObject.cpp index 5b53ac07b19..175873e4ddd 100644 --- a/src/libslic3r/PrintObject.cpp +++ b/src/libslic3r/PrintObject.cpp @@ -1116,6 +1116,7 @@ bool PrintObject::invalidate_state_by_config_options( || opt_key == "fuzzy_skin_thickness" || opt_key == "fuzzy_skin_point_distance" || opt_key == "fuzzy_skin_first_layer" + || opt_key == "fuzzy_skin_mode" || opt_key == "fuzzy_skin_noise_type" || opt_key == "fuzzy_skin_scale" || opt_key == "fuzzy_skin_octaves" diff --git a/src/slic3r/GUI/ConfigManipulation.cpp b/src/slic3r/GUI/ConfigManipulation.cpp index f4248baf65e..bd35683f4e0 100644 --- a/src/slic3r/GUI/ConfigManipulation.cpp +++ b/src/slic3r/GUI/ConfigManipulation.cpp @@ -717,7 +717,7 @@ void ConfigManipulation::toggle_print_fff_options(DynamicPrintConfig *config, co toggle_line("support_interface_not_for_body",config->opt_int("support_interface_filament")&&!config->opt_int("support_filament")); bool has_fuzzy_skin = (config->opt_enum("fuzzy_skin") != FuzzySkinType::None); - for (auto el : { "fuzzy_skin_thickness", "fuzzy_skin_point_distance", "fuzzy_skin_first_layer", "fuzzy_skin_noise_type"}) + for (auto el : { "fuzzy_skin_thickness", "fuzzy_skin_point_distance", "fuzzy_skin_first_layer", "fuzzy_skin_noise_type", "fuzzy_skin_mode"}) toggle_line(el, has_fuzzy_skin); NoiseType fuzzy_skin_noise_type = config->opt_enum("fuzzy_skin_noise_type"); diff --git a/src/slic3r/GUI/Tab.cpp b/src/slic3r/GUI/Tab.cpp index 7655c52496b..adc929bb61d 100644 --- a/src/slic3r/GUI/Tab.cpp +++ b/src/slic3r/GUI/Tab.cpp @@ -2389,6 +2389,7 @@ page = add_options_page(L("Others"), "custom-gcode_other"); // ORCA: icon only v optgroup->append_single_option_line("timelapse_type", "Timelapse"); optgroup->append_single_option_line("fuzzy_skin"); + optgroup->append_single_option_line("fuzzy_skin_mode"); optgroup->append_single_option_line("fuzzy_skin_noise_type"); optgroup->append_single_option_line("fuzzy_skin_point_distance"); optgroup->append_single_option_line("fuzzy_skin_thickness");