#include #include #include #include "libslic3r/BoundingBox.hpp" #include "libslic3r/Model.hpp" #include "libslic3r/ModelArrange.hpp" #include "libslic3r/Print.hpp" #include "libslic3r/PrintConfig.hpp" #include "test_helpers.hpp" #include "libslic3r/TriangleMesh.hpp" #include "libslic3r/Point.hpp" #include #include using namespace Slic3r; TEST_CASE("Klipper object labels name each copy without the characters Klipper cannot parse", "[GCode]") { const auto [name, label] = GENERATE(table({ {"my part (2)", "my_part_2"}, {"(cube)", "cube"}, })); DynamicPrintConfig config = DynamicPrintConfig::full_print_config(); config.set_deserialize_strict({{"gcode_flavor", "klipper"}, {"exclude_object", "1"}}); Print print; Model model; Test::init_print(std::vector{Test::cube(20.)}, print, model, config, nullptr, false, 2); model.objects.front()->name = name; arrange_objects(model, BoundingBox{Point::new_scale(0., 0.), Point::new_scale(500., 500.)}, ArrangeParams{scaled(min_object_distance(config))}); print.apply(model, config); const std::string gcode = Test::gcode(print); for (const char *copy : {"0", "1"}) { const std::string instance_label = label + "_id_0_copy_" + copy; INFO(instance_label); CHECK(gcode.find("EXCLUDE_OBJECT_DEFINE NAME=" + instance_label + " ") != std::string::npos); CHECK(gcode.find("EXCLUDE_OBJECT_START NAME=" + instance_label + "\n") != std::string::npos); } }