mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-09-17 05:52:39 +00:00
Read the Belt Tilt Only from the Belt G-code Header
Every printer's config block lists belt_slice_rotation_angle (default 45), so the processor marked all G-code as belt G-code: imported flat G-code got the belt view on a belt printer, and the belt-only Z handling in the processor ran for non-belt prints whose config block precedes the body. Take the angle only from outside the config block, where only the belt header writes it.
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
#include <catch2/catch_all.hpp>
|
||||
|
||||
#include "libslic3r/libslic3r.h"
|
||||
#include "libslic3r/GCode/GCodeProcessor.hpp"
|
||||
#include "libslic3r/PrintConfig.hpp"
|
||||
|
||||
#include "test_utils.hpp"
|
||||
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
|
||||
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));
|
||||
}
|
||||
Reference in New Issue
Block a user