diff --git a/src/libslic3r/GCode.cpp b/src/libslic3r/GCode.cpp index c4bbf5ed19..8ff4519e8a 100644 --- a/src/libslic3r/GCode.cpp +++ b/src/libslic3r/GCode.cpp @@ -4273,7 +4273,6 @@ LayerResult GCode::process_layer( m_last_obj_copy = this_object_copy; this->set_origin(unscale(offset)); //FIXME the following code prints regions in the order they are defined, the path is not optimized in any way. - bool is_infill_first =m_config.is_infill_first; auto has_infill = [](const std::vector &by_region) { for (auto region : by_region) { @@ -4282,10 +4281,9 @@ LayerResult GCode::process_layer( } return false; }; - - //BBS: for first layer, we always print wall firstly to get better bed adhesive force - //This behaviour is same with cura - if (is_infill_first && !first_layer) { + { + // Print perimeters of regions that has is_infill_first == false + gcode += this->extrude_perimeters(print, by_region_specific, first_layer, false); 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); @@ -4302,27 +4300,10 @@ LayerResult GCode::process_layer( has_insert_timelapse_gcode = true; } + // Then print infill gcode += this->extrude_infill(print, by_region_specific, false); - gcode += this->extrude_perimeters(print, by_region_specific); - } else { - gcode += this->extrude_perimeters(print, 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); - - std::string timepals_gcode = insert_timelapse_gcode(); - gcode += timepals_gcode; - m_writer.set_current_position_clear(false); - //BBS: check whether custom gcode changes the z position. Update if changed - double temp_z_after_timepals_gcode; - if (GCodeProcessor::get_last_z_from_gcode(timepals_gcode, temp_z_after_timepals_gcode)) { - Vec3d pos = m_writer.get_position(); - pos(2) = temp_z_after_timepals_gcode; - m_writer.set_position(pos); - } - - has_insert_timelapse_gcode = true; - } - gcode += this->extrude_infill(print,by_region_specific, false); + // Then print perimeters of regions that has is_infill_first == true + gcode += this->extrude_perimeters(print, by_region_specific, first_layer, true); } // ironing gcode += this->extrude_infill(print,by_region_specific, true); @@ -4920,12 +4901,17 @@ 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 &by_region) +std::string GCode::extrude_perimeters(const Print &print, const std::vector &by_region, bool is_first_layer, bool is_infill_first) { std::string gcode; for (const ObjectByExtruder::Island::Region ®ion : by_region) if (! region.perimeters.empty()) { m_config.apply(print.get_print_region(®ion - &by_region.front()).config()); + // BBS: for first layer, we always print wall firstly to get better bed adhesive force + // This behaviour is same with cura + const bool should_print = is_first_layer ? !is_infill_first + : (m_config.is_infill_first == is_infill_first); + if (!should_print) continue; for (const ExtrusionEntity* ee : region.perimeters) gcode += this->extrude_entity(*ee, "perimeter", -1., region.perimeters); diff --git a/src/libslic3r/GCode.hpp b/src/libslic3r/GCode.hpp index 5f92fd6237..cb39342d94 100644 --- a/src/libslic3r/GCode.hpp +++ b/src/libslic3r/GCode.hpp @@ -445,7 +445,7 @@ private: // 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& by_region); + std::string extrude_perimeters(const Print& print, const std::vector& by_region, bool is_first_layer, bool is_infill_first); std::string extrude_infill(const Print& print, const std::vector& by_region, bool ironing); std::string extrude_support(const ExtrusionEntityCollection& support_fills); diff --git a/src/libslic3r/Layer.cpp b/src/libslic3r/Layer.cpp index cb98c6e6b5..ad494aeac7 100644 --- a/src/libslic3r/Layer.cpp +++ b/src/libslic3r/Layer.cpp @@ -168,6 +168,8 @@ void Layer::make_perimeters() const PrintRegionConfig &other_config = other_layerm->region().config(); if (config.wall_filament == other_config.wall_filament && config.wall_loops == other_config.wall_loops + && config.wall_sequence == other_config.wall_sequence + && config.is_infill_first == other_config.is_infill_first && config.inner_wall_speed == other_config.inner_wall_speed && config.outer_wall_speed == other_config.outer_wall_speed && config.small_perimeter_speed == other_config.small_perimeter_speed