From fc087c97c4386cdb0a98259343e9b5f7b86bdc51 Mon Sep 17 00:00:00 2001 From: Amini Allight Date: Mon, 28 Oct 2024 18:57:26 +0000 Subject: [PATCH] added bottom layers option to GOO exporter --- src/libslic3r/Format/GOO.cpp | 20 +++++++++++++++++--- src/libslic3r/Preset.cpp | 1 + src/libslic3r/PrintConfig.cpp | 8 ++++++++ src/libslic3r/PrintConfig.hpp | 2 ++ src/slic3r/GUI/Tab.cpp | 1 + 5 files changed, 29 insertions(+), 3 deletions(-) diff --git a/src/libslic3r/Format/GOO.cpp b/src/libslic3r/Format/GOO.cpp index cb210d80874..fcf066355eb 100644 --- a/src/libslic3r/Format/GOO.cpp +++ b/src/libslic3r/Format/GOO.cpp @@ -38,6 +38,20 @@ static float constrained_map(float value, float min, float max, float out_min, f return out_min * (1 - t) + out_max * t; } +static float generate_layer_exposure_time( + int current_layer, int bottom_layers, int faded_layers, + float initial_exposure_time, float exposure_time +) { + if (current_layer <= bottom_layers) { + return initial_exposure_time; + } else { + return constrained_map( + current_layer - bottom_layers, 1, faded_layers + 1, + initial_exposure_time, exposure_time + ); + } +} + static void write_thumbnail( size_t width, size_t height, const ThumbnailsList &thumbnails, uint16_t *buffer ) { @@ -375,8 +389,8 @@ void GOOWriter::export_print( l_def.position_mm = hton( mat.initial_layer_height.getFloat() + layer_height * (current_layer - 1) ); - l_def.exposure_time_s = hton(constrained_map( - current_layer, 1, obj_stats.faded_layers + 1, // + l_def.exposure_time_s = hton(generate_layer_exposure_time( + current_layer, obj_stats.bottom_layers, obj_stats.faded_layers, mat.initial_exposure_time, mat.exposure_time )); l_def.off_time_s = 0; @@ -431,4 +445,4 @@ ConfigSubstitutions GOOReader::read( return {}; } -} // namespace Slic3r \ No newline at end of file +} // namespace Slic3r diff --git a/src/libslic3r/Preset.cpp b/src/libslic3r/Preset.cpp index 35a3d00ac40..8279a2c68f7 100644 --- a/src/libslic3r/Preset.cpp +++ b/src/libslic3r/Preset.cpp @@ -540,6 +540,7 @@ static std::vector s_Preset_printer_options { static std::vector s_Preset_sla_print_options { "layer_height", "faded_layers", + "bottom_layers", "supports_enable", "support_tree_type", diff --git a/src/libslic3r/PrintConfig.cpp b/src/libslic3r/PrintConfig.cpp index 4d868eab430..60fbcefc78f 100644 --- a/src/libslic3r/PrintConfig.cpp +++ b/src/libslic3r/PrintConfig.cpp @@ -4183,6 +4183,14 @@ void PrintConfigDef::init_sla_params() def->mode = comExpert; def->set_default_value(new ConfigOptionInt(10)); + def = this->add("bottom_layers", coInt); + def->label = L("Bottom Layers"); + def->tooltip = L("Number of layers the initial exposure time is repeated for."); + def->min = 1; + def->max = 20; + def->mode = comExpert; + def->set_default_value(new ConfigOptionInt(10)); + def = this->add("min_exposure_time", coFloat); def->label = L("Minimum exposure time"); def->tooltip = L("Minimum exposure time"); diff --git a/src/libslic3r/PrintConfig.hpp b/src/libslic3r/PrintConfig.hpp index 39b7b29c122..ae600656754 100644 --- a/src/libslic3r/PrintConfig.hpp +++ b/src/libslic3r/PrintConfig.hpp @@ -987,6 +987,8 @@ PRINT_CONFIG_CLASS_DEFINE( //Number of the layers needed for the exposure time fade [3;20] ((ConfigOptionInt, faded_layers))/*= 10*/ + //Number of layers the initial exposure time is repeated for [1;20] + ((ConfigOptionInt, bottom_layers))/*= 10*/ ((ConfigOptionFloat, slice_closing_radius)) ((ConfigOptionEnum, slicing_mode)) diff --git a/src/slic3r/GUI/Tab.cpp b/src/slic3r/GUI/Tab.cpp index 0f23eed464f..348347e89e7 100644 --- a/src/slic3r/GUI/Tab.cpp +++ b/src/slic3r/GUI/Tab.cpp @@ -5878,6 +5878,7 @@ void TabSLAPrint::build() auto optgroup = page->new_optgroup(L("Layers")); optgroup->append_single_option_line("layer_height"); optgroup->append_single_option_line("faded_layers"); + optgroup->append_single_option_line("bottom_layers"); page = add_options_page(L("Supports"), "support"/*"sla_supports"*/);