Do EFC for the first faded layers of SLA, interpolate efc parameters
Compensated slices have negative orientation... Move efc to common params Fix elefant foot compensation reversed contours Remove redundant assertions and don't apply absolute correction if zero
This commit is contained in:
parent
41d77b492c
commit
6deb6a776d
@ -593,6 +593,10 @@ ExPolygon elephant_foot_compensation(const ExPolygon &input_expoly, double min_c
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FIXME: orientations are messed up (Tamas)
|
||||||
|
out.contour.make_counter_clockwise();
|
||||||
|
for (auto &h : out.holes) h.make_clockwise();
|
||||||
|
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -113,6 +113,16 @@ void PrintConfigDef::init_common_params()
|
|||||||
"If left blank, the default OS CA certificate repository is used.");
|
"If left blank, the default OS CA certificate repository is used.");
|
||||||
def->mode = comAdvanced;
|
def->mode = comAdvanced;
|
||||||
def->set_default_value(new ConfigOptionString(""));
|
def->set_default_value(new ConfigOptionString(""));
|
||||||
|
|
||||||
|
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));
|
||||||
}
|
}
|
||||||
|
|
||||||
void PrintConfigDef::init_fff_params()
|
void PrintConfigDef::init_fff_params()
|
||||||
@ -371,16 +381,6 @@ void PrintConfigDef::init_fff_params()
|
|||||||
def->min = 0;
|
def->min = 0;
|
||||||
def->set_default_value(new ConfigOptionFloat(6));
|
def->set_default_value(new ConfigOptionFloat(6));
|
||||||
|
|
||||||
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));
|
|
||||||
|
|
||||||
def = this->add("end_gcode", coString);
|
def = this->add("end_gcode", coString);
|
||||||
def->label = L("End G-code");
|
def->label = L("End G-code");
|
||||||
def->tooltip = L("This end procedure is inserted at the end of the output file. "
|
def->tooltip = L("This end procedure is inserted at the end of the output file. "
|
||||||
@ -2443,16 +2443,6 @@ void PrintConfigDef::init_sla_params()
|
|||||||
def->mode = comExpert;
|
def->mode = comExpert;
|
||||||
def->set_default_value(new ConfigOptionFloat(0.0));
|
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("elefant_foot_min_width", coFloat);
|
def = this->add("elefant_foot_min_width", coFloat);
|
||||||
def->label = L("Elefant foot minimum width");
|
def->label = L("Elefant foot minimum width");
|
||||||
def->category = L("Advanced");
|
def->category = L("Advanced");
|
||||||
|
@ -1089,8 +1089,7 @@ const std::vector<ExPolygons> &SLAPrintObject::get_support_slices() const
|
|||||||
|
|
||||||
const ExPolygons &SliceRecord::get_slice(SliceOrigin o) const
|
const ExPolygons &SliceRecord::get_slice(SliceOrigin o) const
|
||||||
{
|
{
|
||||||
size_t idx = o == soModel ? m_model_slices_idx :
|
size_t idx = o == soModel ? m_model_slices_idx : m_support_slices_idx;
|
||||||
m_support_slices_idx;
|
|
||||||
|
|
||||||
if(m_po == nullptr) return EMPTY_SLICE;
|
if(m_po == nullptr) return EMPTY_SLICE;
|
||||||
|
|
||||||
|
@ -152,6 +152,10 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
const ExPolygons& get_slice(SliceOrigin o) const;
|
const ExPolygons& get_slice(SliceOrigin o) const;
|
||||||
|
size_t get_slice_idx(SliceOrigin o) const
|
||||||
|
{
|
||||||
|
return o == soModel ? m_model_slices_idx : m_support_slices_idx;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -80,16 +80,37 @@ SLAPrint::Steps::Steps(SLAPrint *print)
|
|||||||
, objectstep_scale{(max_objstatus - min_objstatus) / (objcount * 100.0)}
|
, objectstep_scale{(max_objstatus - min_objstatus) / (objcount * 100.0)}
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
void SLAPrint::Steps::apply_printer_corrections(SLAPrintObject &po, SliceOrigin o)
|
||||||
void SLAPrint::Steps::apply_elefant_foot_compensation(SLAPrintObject &po, SliceOrigin o)
|
|
||||||
{
|
{
|
||||||
|
if (o == soSupport && !po.m_supportdata) return;
|
||||||
|
|
||||||
auto faded_lyrs = size_t(po.m_config.faded_layers.getInt());
|
auto faded_lyrs = size_t(po.m_config.faded_layers.getInt());
|
||||||
|
double min_w = m_print->m_printer_config.elefant_foot_min_width.getFloat() / 2.;
|
||||||
|
double start_efc = m_print->m_printer_config.elefant_foot_compensation.getFloat();
|
||||||
|
|
||||||
|
double doffs = m_print->m_printer_config.absolute_correction.getFloat();
|
||||||
|
coord_t clpr_offs = scaled(doffs);
|
||||||
|
|
||||||
faded_lyrs = std::min(po.m_slice_index.size(), faded_lyrs);
|
faded_lyrs = std::min(po.m_slice_index.size(), faded_lyrs);
|
||||||
|
|
||||||
if (!po.m_model_height_levels.empty() && po.m_model_height_levels[0] < ilh) {
|
auto efc = [start_efc, faded_lyrs](size_t pos) {
|
||||||
auto &first_sl = po.m_model_slices[0];
|
return (faded_lyrs - 1 - pos) * start_efc / (faded_lyrs - 1);
|
||||||
double compensation = m_print->m_printer_config.elefant_foot_compensation.getFloat();
|
};
|
||||||
first_sl = elephant_foot_compensation(first_sl, 0., compensation);
|
|
||||||
|
std::vector<ExPolygons> &slices = o == soModel ?
|
||||||
|
po.m_model_slices :
|
||||||
|
po.m_supportdata->support_slices;
|
||||||
|
|
||||||
|
if (clpr_offs != 0) for (size_t i = 0; i < po.m_slice_index.size(); ++i) {
|
||||||
|
size_t idx = po.m_slice_index[i].get_slice_idx(o);
|
||||||
|
if (idx < slices.size())
|
||||||
|
slices[idx] = offset_ex(slices[idx], float(clpr_offs));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (start_efc > 0.) for (size_t i = 0; i < faded_lyrs; ++i) {
|
||||||
|
size_t idx = po.m_slice_index[i].get_slice_idx(o);
|
||||||
|
if (idx < slices.size())
|
||||||
|
slices[idx] = elephant_foot_compensation(slices[idx], min_w, efc(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -251,23 +272,15 @@ void SLAPrint::Steps::slice_model(SLAPrintObject &po)
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto mit = slindex_it;
|
auto mit = slindex_it;
|
||||||
double doffs = m_print->m_printer_config.absolute_correction.getFloat();
|
for (size_t id = 0;
|
||||||
coord_t clpr_offs = scaled(doffs);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
for(size_t id = 0;
|
|
||||||
id < po.m_model_slices.size() && mit != po.m_slice_index.end();
|
id < po.m_model_slices.size() && mit != po.m_slice_index.end();
|
||||||
id++)
|
id++) {
|
||||||
{
|
|
||||||
// We apply the printer correction offset here.
|
|
||||||
if(clpr_offs != 0)
|
|
||||||
po.m_model_slices[id] =
|
|
||||||
offset_ex(po.m_model_slices[id], float(clpr_offs));
|
|
||||||
|
|
||||||
mit->set_model_slice_idx(po, id); ++mit;
|
mit->set_model_slice_idx(po, id); ++mit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// We apply the printer correction offset here.
|
||||||
|
apply_printer_corrections(po, soModel);
|
||||||
|
|
||||||
if(po.m_config.supports_enable.getBool() || po.m_config.pad_enable.getBool())
|
if(po.m_config.supports_enable.getBool() || po.m_config.pad_enable.getBool())
|
||||||
{
|
{
|
||||||
po.m_supportdata.reset(new SLAPrintObject::SupportData(mesh));
|
po.m_supportdata.reset(new SLAPrintObject::SupportData(mesh));
|
||||||
@ -467,24 +480,12 @@ void SLAPrint::Steps::slice_supports(SLAPrintObject &po) {
|
|||||||
|
|
||||||
sd->support_slices = sd->support_tree_ptr->slice(
|
sd->support_slices = sd->support_tree_ptr->slice(
|
||||||
heights, float(po.config().slice_closing_radius.value));
|
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();
|
for (size_t i = 0; i < sd->support_slices.size() && i < po.m_slice_index.size(); ++i)
|
||||||
coord_t clpr_offs = scaled(doffs);
|
|
||||||
|
|
||||||
for (size_t i = 0; i < sd->support_slices.size() && i < po.m_slice_index.size(); ++i) {
|
|
||||||
// We apply the printer correction offset here.
|
|
||||||
if (clpr_offs != 0)
|
|
||||||
sd->support_slices[i] = offset_ex(sd->support_slices[i], float(clpr_offs));
|
|
||||||
|
|
||||||
po.m_slice_index[i].set_support_slice_idx(po, i);
|
po.m_slice_index[i].set_support_slice_idx(po, i);
|
||||||
}
|
|
||||||
|
apply_printer_corrections(po, soSupport);
|
||||||
|
|
||||||
// Using RELOAD_SLA_PREVIEW to tell the Plater to pass the update
|
// Using RELOAD_SLA_PREVIEW to tell the Plater to pass the update
|
||||||
// status to the 3D preview to load the SLA slices.
|
// status to the 3D preview to load the SLA slices.
|
||||||
|
@ -43,7 +43,7 @@ private:
|
|||||||
bool canceled() const { return m_print->canceled(); }
|
bool canceled() const { return m_print->canceled(); }
|
||||||
void initialize_printer_input();
|
void initialize_printer_input();
|
||||||
|
|
||||||
void apply_elefant_foot_compensation(SLAPrintObject &po, SliceOrigin o);
|
void apply_printer_corrections(SLAPrintObject &po, SliceOrigin o);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Steps(SLAPrint *print);
|
Steps(SLAPrint *print);
|
||||||
|
@ -413,6 +413,19 @@ static ExPolygon contour_with_hole()
|
|||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool is_valid_orientation(const ExPolygon &p)
|
||||||
|
{
|
||||||
|
bool ret = p.contour.is_counter_clockwise();
|
||||||
|
for (auto &h : p.holes) ret = ret && h.is_clockwise();
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool is_efc_result_smaller(const ExPolygon &efc, const ExPolygon &orig)
|
||||||
|
{
|
||||||
|
double efc_area = efc.area();
|
||||||
|
return efc_area > 0. && efc_area < orig.area() && is_valid_orientation(efc);
|
||||||
|
}
|
||||||
|
|
||||||
SCENARIO("Elephant foot compensation", "[ElephantFoot]") {
|
SCENARIO("Elephant foot compensation", "[ElephantFoot]") {
|
||||||
|
|
||||||
GIVEN("Contour with hole") {
|
GIVEN("Contour with hole") {
|
||||||
@ -426,7 +439,7 @@ SCENARIO("Elephant foot compensation", "[ElephantFoot]") {
|
|||||||
{ { expoly_compensated }, { "gray", "black", "blue", coord_t(scale_(0.02)), 0.5f, "black", coord_t(scale_(0.05)) } } });
|
{ { expoly_compensated }, { "gray", "black", "blue", coord_t(scale_(0.02)), 0.5f, "black", coord_t(scale_(0.05)) } } });
|
||||||
#endif /* TESTS_EXPORT_SVGS */
|
#endif /* TESTS_EXPORT_SVGS */
|
||||||
THEN("area of the compensated polygon is smaller") {
|
THEN("area of the compensated polygon is smaller") {
|
||||||
REQUIRE(expoly_compensated.area() < expoly.area());
|
REQUIRE(is_efc_result_smaller(expoly_compensated, expoly));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -456,7 +469,7 @@ SCENARIO("Elephant foot compensation", "[ElephantFoot]") {
|
|||||||
{ { expoly_compensated }, { "gray", "black", "blue", coord_t(scale_(0.02)), 0.5f, "black", coord_t(scale_(0.05)) } } });
|
{ { expoly_compensated }, { "gray", "black", "blue", coord_t(scale_(0.02)), 0.5f, "black", coord_t(scale_(0.05)) } } });
|
||||||
#endif /* TESTS_EXPORT_SVGS */
|
#endif /* TESTS_EXPORT_SVGS */
|
||||||
THEN("area of the compensated polygon is smaller") {
|
THEN("area of the compensated polygon is smaller") {
|
||||||
REQUIRE(expoly_compensated.area() < expoly.area());
|
REQUIRE(is_efc_result_smaller(expoly_compensated, expoly));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -471,7 +484,7 @@ SCENARIO("Elephant foot compensation", "[ElephantFoot]") {
|
|||||||
{ { expoly_compensated }, { "gray", "black", "blue", coord_t(scale_(0.02)), 0.5f, "black", coord_t(scale_(0.05)) } } });
|
{ { expoly_compensated }, { "gray", "black", "blue", coord_t(scale_(0.02)), 0.5f, "black", coord_t(scale_(0.05)) } } });
|
||||||
#endif /* TESTS_EXPORT_SVGS */
|
#endif /* TESTS_EXPORT_SVGS */
|
||||||
THEN("area of the compensated polygon is smaller") {
|
THEN("area of the compensated polygon is smaller") {
|
||||||
REQUIRE(expoly_compensated.area() < expoly.area());
|
REQUIRE(is_efc_result_smaller(expoly_compensated, expoly));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -523,7 +536,7 @@ SCENARIO("Elephant foot compensation", "[ElephantFoot]") {
|
|||||||
{ { expoly_compensated }, { "gray", "black", "blue", coord_t(scale_(0.02)), 0.5f, "black", coord_t(scale_(0.05)) } } });
|
{ { expoly_compensated }, { "gray", "black", "blue", coord_t(scale_(0.02)), 0.5f, "black", coord_t(scale_(0.05)) } } });
|
||||||
#endif /* TESTS_EXPORT_SVGS */
|
#endif /* TESTS_EXPORT_SVGS */
|
||||||
THEN("area of the compensated polygon is smaller") {
|
THEN("area of the compensated polygon is smaller") {
|
||||||
REQUIRE(expoly_compensated.area() < expoly.area());
|
REQUIRE(is_efc_result_smaller(expoly_compensated, expoly));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
WHEN("Fully compensated") {
|
WHEN("Fully compensated") {
|
||||||
@ -534,7 +547,7 @@ SCENARIO("Elephant foot compensation", "[ElephantFoot]") {
|
|||||||
{ { expoly_compensated }, { "gray", "black", "blue", coord_t(scale_(0.02)), 0.5f, "black", coord_t(scale_(0.05)) } } });
|
{ { expoly_compensated }, { "gray", "black", "blue", coord_t(scale_(0.02)), 0.5f, "black", coord_t(scale_(0.05)) } } });
|
||||||
#endif /* TESTS_EXPORT_SVGS */
|
#endif /* TESTS_EXPORT_SVGS */
|
||||||
THEN("area of the compensated polygon is smaller") {
|
THEN("area of the compensated polygon is smaller") {
|
||||||
REQUIRE(expoly_compensated.area() < expoly.area());
|
REQUIRE(is_efc_result_smaller(expoly_compensated, expoly));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -549,7 +562,7 @@ SCENARIO("Elephant foot compensation", "[ElephantFoot]") {
|
|||||||
{ { expoly_compensated }, { "gray", "black", "blue", coord_t(scale_(0.02)), 0.5f, "black", coord_t(scale_(0.05)) } } });
|
{ { expoly_compensated }, { "gray", "black", "blue", coord_t(scale_(0.02)), 0.5f, "black", coord_t(scale_(0.05)) } } });
|
||||||
#endif /* TESTS_EXPORT_SVGS */
|
#endif /* TESTS_EXPORT_SVGS */
|
||||||
THEN("area of the compensated polygon is smaller") {
|
THEN("area of the compensated polygon is smaller") {
|
||||||
REQUIRE(expoly_compensated.area() < expoly.area());
|
REQUIRE(is_efc_result_smaller(expoly_compensated, expoly));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -566,7 +579,7 @@ SCENARIO("Elephant foot compensation", "[ElephantFoot]") {
|
|||||||
{ { expoly_compensated }, { "gray", "black", "blue", coord_t(scale_(0.02)), 0.5f, "black", coord_t(scale_(0.05)) } } });
|
{ { expoly_compensated }, { "gray", "black", "blue", coord_t(scale_(0.02)), 0.5f, "black", coord_t(scale_(0.05)) } } });
|
||||||
#endif /* TESTS_EXPORT_SVGS */
|
#endif /* TESTS_EXPORT_SVGS */
|
||||||
THEN("area of the compensated polygon is smaller") {
|
THEN("area of the compensated polygon is smaller") {
|
||||||
REQUIRE(expoly_compensated.area() < expoly.area());
|
REQUIRE(is_efc_result_smaller(expoly_compensated, expoly));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
WHEN("Fully compensated") {
|
WHEN("Fully compensated") {
|
||||||
@ -577,7 +590,7 @@ SCENARIO("Elephant foot compensation", "[ElephantFoot]") {
|
|||||||
{ { expoly_compensated }, { "gray", "black", "blue", coord_t(scale_(0.02)), 0.5f, "black", coord_t(scale_(0.05)) } } });
|
{ { expoly_compensated }, { "gray", "black", "blue", coord_t(scale_(0.02)), 0.5f, "black", coord_t(scale_(0.05)) } } });
|
||||||
#endif /* TESTS_EXPORT_SVGS */
|
#endif /* TESTS_EXPORT_SVGS */
|
||||||
THEN("area of the compensated polygon is smaller") {
|
THEN("area of the compensated polygon is smaller") {
|
||||||
REQUIRE(expoly_compensated.area() < expoly.area());
|
REQUIRE(is_efc_result_smaller(expoly_compensated, expoly));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
WHEN("Brutally compensated") {
|
WHEN("Brutally compensated") {
|
||||||
@ -588,7 +601,7 @@ SCENARIO("Elephant foot compensation", "[ElephantFoot]") {
|
|||||||
{ { expoly_compensated }, { "gray", "black", "blue", coord_t(scale_(0.02)), 0.5f, "black", coord_t(scale_(0.05)) } } });
|
{ { expoly_compensated }, { "gray", "black", "blue", coord_t(scale_(0.02)), 0.5f, "black", coord_t(scale_(0.05)) } } });
|
||||||
#endif /* TESTS_EXPORT_SVGS */
|
#endif /* TESTS_EXPORT_SVGS */
|
||||||
THEN("area of the compensated polygon is smaller") {
|
THEN("area of the compensated polygon is smaller") {
|
||||||
REQUIRE(expoly_compensated.area() < expoly.area());
|
REQUIRE(is_efc_result_smaller(expoly_compensated, expoly));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -603,7 +616,7 @@ SCENARIO("Elephant foot compensation", "[ElephantFoot]") {
|
|||||||
{ { expoly_compensated }, { "gray", "black", "blue", coord_t(scale_(0.02)), 0.5f, "black", coord_t(scale_(0.05)) } } });
|
{ { expoly_compensated }, { "gray", "black", "blue", coord_t(scale_(0.02)), 0.5f, "black", coord_t(scale_(0.05)) } } });
|
||||||
#endif /* TESTS_EXPORT_SVGS */
|
#endif /* TESTS_EXPORT_SVGS */
|
||||||
THEN("area of the compensated polygon is smaller") {
|
THEN("area of the compensated polygon is smaller") {
|
||||||
REQUIRE(expoly_compensated.area() < expoly.area());
|
REQUIRE(is_efc_result_smaller(expoly_compensated, expoly));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user