mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-10-05 06:41:10 +00:00
perf: speed up G-code export by up to 8% via cheaper G-code text building (#16108)
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
#include <catch2/generators/catch_generators.hpp>
|
||||
|
||||
#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 <string>
|
||||
#include <vector>
|
||||
|
||||
using namespace Slic3r;
|
||||
|
||||
TEST_CASE("Klipper object labels name each copy without the characters Klipper cannot parse", "[GCode]")
|
||||
{
|
||||
const auto [name, label] = GENERATE(table<std::string, std::string>({
|
||||
{"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<TriangleMesh>{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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user