Split objects in the middle of travel. This works only for single extruder setups (no toolchanges), but is a step forward

This commit is contained in:
Martin Šach 2024-02-28 16:47:40 +01:00 committed by Lukas Matena
parent 28d935b0b3
commit 0207819b57
2 changed files with 3 additions and 58 deletions

View File

@ -3124,17 +3124,16 @@ std::string GCodeGenerator::_extrude(
const std::string_view description_bridge = path_attr.role.is_bridge() ? " (bridge)"sv : ""sv;
const std::string instance_change_gcode{this->m_label_objects.maybe_change_instance()};
std::string travel_instance_change_gcode = m_writer.multiple_extruders ? "" : instance_change_gcode;
if (!m_current_layer_first_position) {
const Vec3crd point = to_3d(path.front().point, scaled(this->m_last_layer_z));
gcode += this->travel_to_first_position(point, unscaled(point.z()), travel_instance_change_gcode);
gcode += this->travel_to_first_position(point, unscaled(point.z()), instance_change_gcode);
} else {
// go to first point of extrusion path
if (!this->last_position) {
const double z = this->m_last_layer_z;
const std::string comment{"move to print after unknown position"};
gcode += this->retract_and_wipe();
gcode += travel_instance_change_gcode;
gcode += instance_change_gcode;
gcode += this->m_writer.travel_to_xy(this->point_to_gcode(path.front().point), comment);
gcode += this->m_writer.get_travel_to_z_gcode(z, comment);
} else if ( this->last_position != path.front().point) {
@ -3142,10 +3141,8 @@ std::string GCodeGenerator::_extrude(
comment += description;
comment += description_bridge;
comment += " point";
const std::string travel_gcode{this->travel_to(*this->last_position, path.front().point, path_attr.role, comment, travel_instance_change_gcode)};
const std::string travel_gcode{this->travel_to(*this->last_position, path.front().point, path_attr.role, comment, instance_change_gcode)};
gcode += travel_gcode;
} else {
travel_instance_change_gcode = "";
}
}
@ -3156,9 +3153,6 @@ std::string GCodeGenerator::_extrude(
this->m_already_unretracted = true;
gcode += "FIRST_UNRETRACT" + this->unretract();
}
if (travel_instance_change_gcode.empty()) {
gcode += instance_change_gcode;
}
if (!m_pending_pre_extrusion_gcode.empty()) {
// There is G-Code that is due to be inserted before an extrusion starts. Insert it.

View File

@ -167,55 +167,6 @@ TEST_CASE_METHOD(CancelObjectFixture, "Single extruder", "[CancelObject]") {
}
}
TEST_CASE_METHOD(CancelObjectFixture, "Multiple extruders", "[CancelObject]") {
auto wipe_tower = GENERATE(0, 1);
INFO("With wipe tower: " + std::string{wipe_tower == 0 ? "false" : "true"});
config.set_deserialize_strict(
{{"nozzle_diameter", "0.4,0.4"},
{"toolchange_gcode", "T[next_extruder]"},
{"wipe_tower", wipe_tower},
{"wipe_tower_x", "50.0"},
{"wipe_tower_y", "50.0"}}
);
Print print;
print.apply(multimaterial_cubes, config);
print.validate();
const std::string gcode{Test::gcode(print)};
if constexpr (debug_files) {
const std::string prefix = wipe_tower == 1 ? "wipe_tower_" : "";
std::ofstream output{prefix + "multi_extruder_two.gcode"};
output << gcode;
}
REQUIRE(gcode.find("T1\n") != std::string::npos);
SECTION("One remaining") {
const std::string removed_object_gcode{remove_object(gcode, 0)};
REQUIRE(removed_object_gcode.find("M486 S1\n") != std::string::npos);
if constexpr (debug_files) {
const std::string prefix = wipe_tower == 1 ? "wipe_tower_" : "";
std::ofstream output{prefix + "multi_extruder_one.gcode"};
output << removed_object_gcode;
}
check_retraction(removed_object_gcode);
}
SECTION("All cancelled") {
const std::string removed_all_gcode{remove_object(remove_object(gcode, 0), 1)};
if constexpr (debug_files) {
const std::string prefix = wipe_tower == 1 ? "wipe_tower_" : "";
std::ofstream output{prefix + "multi_extruder_none.gcode"};
output << removed_all_gcode;
}
check_retraction(removed_all_gcode);
}
}
TEST_CASE_METHOD(CancelObjectFixture, "Sequential print", "[CancelObject]") {
config.set_deserialize_strict({{"complete_objects", 1}});