Add elephant foot compensation to SLA print

Work in progress


Convert efc input to the right scaling


Apply EFC on the slice index to make it visible in the preview.
This commit is contained in:
tamasmeszaros 2020-02-06 14:09:48 +01:00
parent f8c5855d55
commit 96d5c8c35d
8 changed files with 51 additions and 4 deletions

View File

@ -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

View File

@ -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);

View File

@ -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");

View File

@ -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);

View File

@ -785,6 +785,7 @@ bool SLAPrint::invalidate_state_by_config_options(const std::vector<t_config_opt
"material_correction",
"relative_correction",
"absolute_correction",
"elefant_foot_compensation",
"gamma_correction"
};

View File

@ -8,6 +8,8 @@
#include <libslic3r/SLA/Pad.hpp>
#include <libslic3r/SLA/SupportPointGenerator.hpp>
#include <libslic3r/ElephantFootCompensation.hpp>
#include <libslic3r/ClipperUtils.hpp>
// 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();

View File

@ -557,6 +557,7 @@ const std::vector<std::string>& 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",

View File

@ -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");