Skip to content

Feature: Fuzzy Skin Extrusion Mode #9878

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions src/libslic3r/PerimeterGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ static void fuzzy_extrusion_line(std::vector<Arachne::ExtrusionJunction>& 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();
Expand All @@ -172,7 +173,18 @@ static void fuzzy_extrusion_line(std::vector<Arachne::ExtrusionJunction>& 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<coord_t>();
double r = noise->GetValue(unscale_(pa.x()), unscale_(pa.y()), slice_z) * cfg.thickness;
out.emplace_back(pa + (perp(p0p1).cast<double>().normalized() * r).cast<coord_t>(), p1.w, p1.perimeter_index);
switch (cfg.mode) { //the curly code for testing
case FuzzySkinMode::Displacement :
out.emplace_back(pa + (perp(p0p1).cast<double>().normalized() * r).cast<coord_t>(), 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<double>().normalized() * ((rad - p1.w) / 2)).cast<coord_t>(), rad, p1.perimeter_index); //0.05 - minimum width of extruded line
break;
}
}
dist_left_over = p0pa_dist - p0p1_size;
p0 = &p1;
Expand All @@ -186,8 +198,10 @@ static void fuzzy_extrusion_line(std::vector<Arachne::ExtrusionJunction>& 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);
Expand Down Expand Up @@ -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) {
Expand Down
4 changes: 3 additions & 1 deletion src/libslic3r/PerimeterGenerator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ struct FuzzySkinConfig
double noise_scale;
int noise_octaves;
double noise_persistence;
FuzzySkinMode mode;

bool operator==(const FuzzySkinConfig& r) const
{
Expand All @@ -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); }
Expand Down
2 changes: 1 addition & 1 deletion src/libslic3r/Preset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -790,7 +790,7 @@ static std::vector<std::string> 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",
Expand Down
31 changes: 30 additions & 1 deletion src/libslic3r/PrintConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) },
Expand All @@ -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 },
Expand Down Expand Up @@ -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<FuzzySkinMode>::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>(FuzzySkinMode::Displacement));

def = this->add("fuzzy_skin_noise_type", coEnum);
def->label = L("Fuzzy skin noise type");
def->category = L("Others");
Expand Down
9 changes: 9 additions & 0 deletions src/libslic3r/PrintConfig.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,20 @@ enum GCodeFlavor : unsigned char {
gcfSmoothie, gcfNoExtrusion
};


enum class FuzzySkinType {
None,
External,
All,
AllWalls,
};

enum class FuzzySkinMode {
Displacement,
Extrusion,
Combined,
};

enum class NoiseType {
Classic,
Perlin,
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -944,6 +952,7 @@ PRINT_CONFIG_CLASS_DEFINE(
((ConfigOptionFloat, fuzzy_skin_point_distance))
((ConfigOptionBool, fuzzy_skin_first_layer))
((ConfigOptionEnum<NoiseType>, fuzzy_skin_noise_type))
((ConfigOptionEnum<FuzzySkinMode>, fuzzy_skin_mode))
((ConfigOptionFloat, fuzzy_skin_scale))
((ConfigOptionInt, fuzzy_skin_octaves))
((ConfigOptionFloat, fuzzy_skin_persistence))
Expand Down
1 change: 1 addition & 0 deletions src/libslic3r/PrintObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
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 @@ -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<FuzzySkinType>("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<NoiseType>("fuzzy_skin_noise_type");
Expand Down
1 change: 1 addition & 0 deletions src/slic3r/GUI/Tab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down