Disable SAFC and retract for Hilbert curve (#9592)

* SAFC flow for rectilinear/monotonic only and Hilbet curve retract

* Refactor

---------

Co-authored-by: Noisyfox <timemanager.rick@gmail.com>
This commit is contained in:
Vovodroid
2025-06-15 15:50:34 +03:00
committed by GitHub
parent 52e4d2af82
commit b259ee22b3
6 changed files with 30 additions and 24 deletions

View File

@@ -5177,6 +5177,25 @@ double GCode::get_overhang_degree_corr_speed(float normal_speed, double path_deg
return speed_out;
}
bool GCode::_needSAFC(const ExtrusionPath &path)
{
if (!m_small_area_infill_flow_compensator || !m_config.small_area_infill_flow_compensation.value)
return false;
static const InfillPattern supported_patterns[] = {
InfillPattern::ipRectilinear,
InfillPattern::ipAlignedRectilinear,
InfillPattern::ipMonotonic,
InfillPattern::ipMonotonicLine,
};
return std::any_of(std::begin(supported_patterns), std::end(supported_patterns), [&](const InfillPattern pattern) {
return this->on_first_layer() && this->config().bottom_surface_pattern == pattern ||
path.role() == erSolidInfill && this->config().internal_solid_infill_pattern == pattern ||
path.role() == erTopSolidInfill && this->config().top_surface_pattern == pattern;
});
}
std::string GCode::_extrude(const ExtrusionPath &path, std::string description, double speed)
{
std::string gcode;
@@ -5731,8 +5750,7 @@ std::string GCode::_extrude(const ExtrusionPath &path, std::string description,
continue;
path_length += line_length;
auto dE = e_per_mm * line_length;
if (!this->on_first_layer() && m_small_area_infill_flow_compensator
&& m_config.small_area_infill_flow_compensation.value) {
if (_needSAFC(path)) {
auto oldE = dE;
dE = m_small_area_infill_flow_compensator->modify_flow(line_length, dE, path.role());
@@ -5773,8 +5791,7 @@ std::string GCode::_extrude(const ExtrusionPath &path, std::string description,
if (line_length < EPSILON)
continue;
auto dE = e_per_mm * line_length;
if (!this->on_first_layer() && m_small_area_infill_flow_compensator
&& m_config.small_area_infill_flow_compensation.value) {
if (_needSAFC(path)) {
auto oldE = dE;
dE = m_small_area_infill_flow_compensator->modify_flow(line_length, dE, path.role());
@@ -5797,8 +5814,7 @@ std::string GCode::_extrude(const ExtrusionPath &path, std::string description,
continue;
const Vec2d center_offset = this->point_to_gcode(arc.center) - this->point_to_gcode(arc.start_point);
auto dE = e_per_mm * arc_length;
if (!this->on_first_layer() && m_small_area_infill_flow_compensator
&& m_config.small_area_infill_flow_compensation.value) {
if (_needSAFC(path)) {
auto oldE = dE;
dE = m_small_area_infill_flow_compensator->modify_flow(arc_length, dE, path.role());
@@ -5952,8 +5968,7 @@ std::string GCode::_extrude(const ExtrusionPath &path, std::string description,
last_set_speed = F;
}
auto dE = e_per_mm * line_length;
if (!this->on_first_layer() && m_small_area_infill_flow_compensator
&& m_config.small_area_infill_flow_compensation.value) {
if (_needSAFC(path)) {
auto oldE = dE;
dE = m_small_area_infill_flow_compensator->modify_flow(line_length, dE, path.role());
@@ -6334,7 +6349,8 @@ std::string GCode::retract(bool toolchange, bool is_last_retraction, LiftType li
(the extruder might be already retracted fully or partially). We call these
methods even if we performed wipe, since this will ensure the entire retraction
length is honored in case wipe path was too short. */
if (role != erTopSolidInfill || EXTRUDER_CONFIG(retract_on_top_layer))
if ((!this->on_first_layer() || this->config().bottom_surface_pattern != InfillPattern::ipHilbertCurve) &&
(role != erTopSolidInfill || this->config().top_surface_pattern != InfillPattern::ipHilbertCurve))
gcode += toolchange ? m_writer.retract_for_toolchange() : m_writer.retract();
gcode += m_writer.reset_e();