#include #include "libslic3r/libslic3r.h" #include "libslic3r/GCode/GCodeProcessor.hpp" #include "libslic3r/PrintConfig.hpp" #include "test_utils.hpp" #include #include using namespace Slic3r; using Catch::Matchers::WithinAbs; namespace { float processed_belt_tilt(const std::string &gcode) { ScopedTemporaryFile temp(".gcode"); { std::ofstream os(temp.string()); os << gcode; } GCodeProcessor proc; proc.apply_config(FullPrintConfig{}); proc.process_file(temp.string()); return proc.get_result().belt_tilt_angle; } constexpr const char *body = "G1 X10 Y10 Z0.2 F3000\nG1 X20 Y10 E1 F1200\n"; } // namespace TEST_CASE("The config block's belt angle does not mark G-code as belt G-code", "[GCodeProcessor][belt]") { // Every printer's config block lists belt_slice_rotation_angle (default 45), belt or not. const std::string gcode = std::string("; CONFIG_BLOCK_START\n; belt_printer = 0\n; belt_slice_rotation_angle = 45\n; CONFIG_BLOCK_END\n") + body; CHECK_THAT(processed_belt_tilt(gcode), WithinAbs(0., 1e-6)); } TEST_CASE("The belt header's angle marks G-code as belt G-code", "[GCodeProcessor][belt]") { const std::string gcode = std::string("; belt_slice_rotation_angle = -45.0\n") + body + "; CONFIG_BLOCK_START\n; belt_printer = 1\n; belt_slice_rotation_angle = -45\n; CONFIG_BLOCK_END\n"; CHECK_THAT(processed_belt_tilt(gcode), WithinAbs(45., 1e-6)); }