Skip to content

Commit

Permalink
Make sure the m_extrusion_quality_estimator.set_current_object() is…
Browse files Browse the repository at this point in the history
… called after regional config has been applied (SoftFever#7946)
  • Loading branch information
Noisyfox committed Jan 8, 2025
1 parent e315586 commit d13d4a4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
26 changes: 14 additions & 12 deletions src/libslic3r/GCode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4190,9 +4190,6 @@ LayerResult GCode::process_layer(
}
}

if (m_config.enable_overhang_speed && !m_config.overhang_speed_classic)
m_extrusion_quality_estimator.set_current_object(&instance_to_print.print_object);

// When starting a new object, use the external motion planner for the first travel move.
const Point &offset = instance_to_print.print_object.instances()[instance_to_print.instance_id].shift;
std::pair<const PrintObject*, Point> this_object_copy(&instance_to_print.print_object, offset);
Expand Down Expand Up @@ -4293,10 +4290,10 @@ LayerResult GCode::process_layer(

has_insert_timelapse_gcode = true;
}
gcode += this->extrude_infill(print, by_region_specific, false);
gcode += this->extrude_perimeters(print, by_region_specific);
gcode += this->extrude_infill(instance_to_print.print_object, by_region_specific, false);
gcode += this->extrude_perimeters(instance_to_print.print_object, by_region_specific);
} else {
gcode += this->extrude_perimeters(print, by_region_specific);
gcode += this->extrude_perimeters(instance_to_print.print_object, by_region_specific);
if (!has_wipe_tower && need_insert_timelapse_gcode_for_traditional && !has_insert_timelapse_gcode && has_infill(by_region_specific)) {
gcode += this->retract(false, false, LiftType::NormalLift);

Expand All @@ -4313,10 +4310,10 @@ LayerResult GCode::process_layer(

has_insert_timelapse_gcode = true;
}
gcode += this->extrude_infill(print,by_region_specific, false);
gcode += this->extrude_infill(instance_to_print.print_object, by_region_specific, false);
}
// ironing
gcode += this->extrude_infill(print,by_region_specific, true);
gcode += this->extrude_infill(instance_to_print.print_object, by_region_specific, true);
}

if (this->config().gcode_label_objects) {
Expand Down Expand Up @@ -4911,12 +4908,14 @@ std::string GCode::extrude_path(ExtrusionPath path, std::string description, dou
}

// Extrude perimeters: Decide where to put seams (hide or align seams).
std::string GCode::extrude_perimeters(const Print &print, const std::vector<ObjectByExtruder::Island::Region> &by_region)
std::string GCode::extrude_perimeters(const PrintObject& print_object, const std::vector<ObjectByExtruder::Island::Region>& by_region)
{
std::string gcode;
for (const ObjectByExtruder::Island::Region &region : by_region)
if (! region.perimeters.empty()) {
m_config.apply(print.get_print_region(&region - &by_region.front()).config());
m_config.apply(print_object.print()->get_print_region(&region - &by_region.front()).config());
if (m_config.enable_overhang_speed && !m_config.overhang_speed_classic)
m_extrusion_quality_estimator.set_current_object(&print_object);

for (const ExtrusionEntity* ee : region.perimeters)
gcode += this->extrude_entity(*ee, "perimeter", -1., region.perimeters);
Expand All @@ -4925,7 +4924,7 @@ std::string GCode::extrude_perimeters(const Print &print, const std::vector<Obje
}

// Chain the paths hierarchically by a greedy algorithm to minimize a travel distance.
std::string GCode::extrude_infill(const Print &print, const std::vector<ObjectByExtruder::Island::Region> &by_region, bool ironing)
std::string GCode::extrude_infill(const PrintObject &print_object, const std::vector<ObjectByExtruder::Island::Region> &by_region, bool ironing)
{
std::string gcode;
ExtrusionEntitiesPtr extrusions;
Expand All @@ -4938,7 +4937,10 @@ std::string GCode::extrude_infill(const Print &print, const std::vector<ObjectBy
if ((ee->role() == erIroning) == ironing)
extrusions.emplace_back(ee);
if (! extrusions.empty()) {
m_config.apply(print.get_print_region(&region - &by_region.front()).config());
m_config.apply(print_object.print()->get_print_region(&region - &by_region.front()).config());
if (m_config.enable_overhang_speed && !m_config.overhang_speed_classic)
m_extrusion_quality_estimator.set_current_object(&print_object);

chain_and_reorder_extrusion_entities(extrusions, &m_last_pos);
for (const ExtrusionEntity *fill : extrusions) {
auto *eec = dynamic_cast<const ExtrusionEntityCollection*>(fill);
Expand Down
4 changes: 2 additions & 2 deletions src/libslic3r/GCode.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -445,8 +445,8 @@ class GCode {
// For sequential print, the instance of the object to be printing has to be defined.
const size_t single_object_instance_idx);

std::string extrude_perimeters(const Print& print, const std::vector<ObjectByExtruder::Island::Region>& by_region);
std::string extrude_infill(const Print& print, const std::vector<ObjectByExtruder::Island::Region>& by_region, bool ironing);
std::string extrude_perimeters(const PrintObject &print_object, const std::vector<ObjectByExtruder::Island::Region>& by_region);
std::string extrude_infill(const PrintObject &print_object, const std::vector<ObjectByExtruder::Island::Region>& by_region, bool ironing);
std::string extrude_support(const ExtrusionEntityCollection& support_fills);

// BBS
Expand Down

0 comments on commit d13d4a4

Please sign in to comment.