diff --git a/src/libslic3r/ElephantFootCompensation.cpp b/src/libslic3r/ElephantFootCompensation.cpp index 2694b5e8a..a19aa2687 100644 --- a/src/libslic3r/ElephantFootCompensation.cpp +++ b/src/libslic3r/ElephantFootCompensation.cpp @@ -524,11 +524,10 @@ static inline void smooth_compensation_banded(const Points &contour, float band, } } -ExPolygon elephant_foot_compensation(const ExPolygon &input_expoly, const Flow &external_perimeter_flow, const double compensation) +ExPolygon elephant_foot_compensation(const ExPolygon &input_expoly, double min_contour_width, const double compensation) { - // The contour shall be wide enough to apply the external perimeter plus compensation on both sides. - double min_contour_width = double(external_perimeter_flow.scaled_width() + external_perimeter_flow.scaled_spacing()); double scaled_compensation = scale_(compensation); + min_contour_width = scale_(min_contour_width); double min_contour_width_compensated = min_contour_width + 2. * scaled_compensation; // Make the search radius a bit larger for the averaging in contour_distance over a fan of rays to work. double search_radius = min_contour_width_compensated + min_contour_width * 0.5; @@ -597,6 +596,13 @@ ExPolygon elephant_foot_compensation(const ExPolygon &input_expoly, const Flow & return out; } +ExPolygon elephant_foot_compensation(const ExPolygon &input, const Flow &external_perimeter_flow, const double compensation) +{ + // The contour shall be wide enough to apply the external perimeter plus compensation on both sides. + double min_contour_width = double(external_perimeter_flow.width + external_perimeter_flow.spacing()); + return elephant_foot_compensation(input, min_contour_width, compensation); +} + ExPolygons elephant_foot_compensation(const ExPolygons &input, const Flow &external_perimeter_flow, const double compensation) { ExPolygons out; @@ -606,4 +612,13 @@ ExPolygons elephant_foot_compensation(const ExPolygons &input, const Flow &exter return out; } +ExPolygons elephant_foot_compensation(const ExPolygons &input, double min_contour_width, const double compensation) +{ + ExPolygons out; + out.reserve(input.size()); + for (const ExPolygon &expoly : input) + out.emplace_back(elephant_foot_compensation(expoly, min_contour_width, compensation)); + return out; +} + } // namespace Slic3r diff --git a/src/libslic3r/ElephantFootCompensation.hpp b/src/libslic3r/ElephantFootCompensation.hpp index 0119df1af..beb17d10b 100644 --- a/src/libslic3r/ElephantFootCompensation.hpp +++ b/src/libslic3r/ElephantFootCompensation.hpp @@ -8,6 +8,8 @@ namespace Slic3r { class Flow; +ExPolygon elephant_foot_compensation(const ExPolygon &input, double min_countour_width, const double compensation); +ExPolygons elephant_foot_compensation(const ExPolygons &input, double min_countour_width, const double compensation); ExPolygon elephant_foot_compensation(const ExPolygon &input, const Flow &external_perimeter_flow, const double compensation); ExPolygons elephant_foot_compensation(const ExPolygons &input, const Flow &external_perimeter_flow, const double compensation); diff --git a/src/libslic3r/PrintConfig.cpp b/src/libslic3r/PrintConfig.cpp index 36d56c4c1..dfea714a8 100644 --- a/src/libslic3r/PrintConfig.cpp +++ b/src/libslic3r/PrintConfig.cpp @@ -2442,6 +2442,16 @@ void PrintConfigDef::init_sla_params() "to the sign of the correction."); def->mode = comExpert; def->set_default_value(new ConfigOptionFloat(0.0)); + + def = this->add("elefant_foot_compensation", coFloat); + def->label = L("Elephant foot compensation"); + def->category = L("Advanced"); + def->tooltip = L("The first layer will be shrunk in the XY plane by the configured value " + "to compensate for the 1st layer squish aka an Elephant Foot effect."); + def->sidetext = L("mm"); + def->min = 0; + def->mode = comAdvanced; + def->set_default_value(new ConfigOptionFloat(0.2)); def = this->add("gamma_correction", coFloat); def->label = L("Printer gamma correction"); diff --git a/src/libslic3r/PrintConfig.hpp b/src/libslic3r/PrintConfig.hpp index c854feafc..f320b3da5 100644 --- a/src/libslic3r/PrintConfig.hpp +++ b/src/libslic3r/PrintConfig.hpp @@ -1175,6 +1175,7 @@ public: ConfigOptionBool display_mirror_y; ConfigOptionFloats relative_correction; ConfigOptionFloat absolute_correction; + ConfigOptionFloat elefant_foot_compensation; ConfigOptionFloat gamma_correction; ConfigOptionFloat fast_tilt_time; ConfigOptionFloat slow_tilt_time; @@ -1198,6 +1199,7 @@ protected: OPT_PTR(display_orientation); OPT_PTR(relative_correction); OPT_PTR(absolute_correction); + OPT_PTR(elefant_foot_compensation); OPT_PTR(gamma_correction); OPT_PTR(fast_tilt_time); OPT_PTR(slow_tilt_time); diff --git a/src/libslic3r/SLAPrint.cpp b/src/libslic3r/SLAPrint.cpp index 06c4f687b..4bfc77c80 100644 --- a/src/libslic3r/SLAPrint.cpp +++ b/src/libslic3r/SLAPrint.cpp @@ -785,6 +785,7 @@ bool SLAPrint::invalidate_state_by_config_options(const std::vector #include +#include + #include // For geometry algorithms with native Clipper types (no copies and conversions) @@ -238,6 +240,13 @@ void SLAPrint::Steps::slice_model(SLAPrintObject &po) auto mit = slindex_it; double doffs = m_print->m_printer_config.absolute_correction.getFloat(); coord_t clpr_offs = scaled(doffs); + + if (!po.m_model_height_levels.empty() && po.m_model_height_levels[0] < ilh) { + auto &first_sl = po.m_model_slices[0]; + double compensation = m_print->m_printer_config.elefant_foot_compensation.getFloat(); + first_sl = elephant_foot_compensation(first_sl, 0., compensation); + } + for(size_t id = 0; id < po.m_model_slices.size() && mit != po.m_slice_index.end(); id++) @@ -449,6 +458,12 @@ void SLAPrint::Steps::slice_supports(SLAPrintObject &po) { sd->support_slices = sd->support_tree_ptr->slice( heights, float(po.config().slice_closing_radius.value)); + + if (!heights.empty() && heights[0] < ilh) { + auto &first_sl = sd->support_slices[0]; + double compensation = m_print->m_printer_config.elefant_foot_compensation.getFloat(); + first_sl = elephant_foot_compensation(first_sl, 0., compensation); + } } double doffs = m_print->m_printer_config.absolute_correction.getFloat(); diff --git a/src/slic3r/GUI/Preset.cpp b/src/slic3r/GUI/Preset.cpp index 6f379aa39..f9191b2e7 100644 --- a/src/slic3r/GUI/Preset.cpp +++ b/src/slic3r/GUI/Preset.cpp @@ -557,6 +557,7 @@ const std::vector& Preset::sla_printer_options() "fast_tilt_time", "slow_tilt_time", "area_fill", "relative_correction", "absolute_correction", + "elefant_foot_compensation", "gamma_correction", "min_exposure_time", "max_exposure_time", "min_initial_exposure_time", "max_initial_exposure_time", diff --git a/src/slic3r/GUI/Tab.cpp b/src/slic3r/GUI/Tab.cpp index c5c6dc466..1b46ed755 100644 --- a/src/slic3r/GUI/Tab.cpp +++ b/src/slic3r/GUI/Tab.cpp @@ -2112,8 +2112,9 @@ void TabPrinter::build_sla() } optgroup->append_line(line); optgroup->append_single_option_line("absolute_correction"); + optgroup->append_single_option_line("elefant_foot_compensation"); optgroup->append_single_option_line("gamma_correction"); - + optgroup = page->new_optgroup(_(L("Exposure"))); optgroup->append_single_option_line("min_exposure_time"); optgroup->append_single_option_line("max_exposure_time");