mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-07-23 10:52:15 +00:00
Refactor custom GCode handling and mixed filament management
- Updated `custom_tool_changes` function to use filament IDs instead of extruder IDs, ensuring better compatibility with mixed filament configurations. - Enhanced `MixedFilament` structure to include a `stable_id` for persistent identity across mixed filament entries, improving remapping during updates. - Introduced new methods for stable ID allocation and normalization in `MixedFilamentManager`. - Updated serialization and loading functions to maintain stable IDs, ensuring consistent behavior when mixed filament entries are modified. - Added tests to verify the correct handling of tool changes and stable ID remapping in mixed filament scenarios.
This commit is contained in:
28
tests/libslic3r/test_custom_gcode.cpp
Normal file
28
tests/libslic3r/test_custom_gcode.cpp
Normal file
@@ -0,0 +1,28 @@
|
||||
#include <catch2/catch.hpp>
|
||||
|
||||
#include "libslic3r/CustomGCode.hpp"
|
||||
|
||||
using namespace Slic3r;
|
||||
|
||||
TEST_CASE("Custom layer tool changes keep mixed virtual filament ids", "[CustomGCode]")
|
||||
{
|
||||
CustomGCode::Info info;
|
||||
info.gcodes.emplace_back(CustomGCode::Item{1.25, CustomGCode::ToolChange, 5, "", ""});
|
||||
|
||||
const auto tool_changes = CustomGCode::custom_tool_changes(info, 6);
|
||||
|
||||
REQUIRE(tool_changes.size() == 1);
|
||||
CHECK(tool_changes.front().first == Approx(1.25));
|
||||
CHECK(tool_changes.front().second == 5u);
|
||||
}
|
||||
|
||||
TEST_CASE("Custom layer tool changes still clamp stale filament ids", "[CustomGCode]")
|
||||
{
|
||||
CustomGCode::Info info;
|
||||
info.gcodes.emplace_back(CustomGCode::Item{2.0, CustomGCode::ToolChange, 7, "", ""});
|
||||
|
||||
const auto tool_changes = CustomGCode::custom_tool_changes(info, 6);
|
||||
|
||||
REQUIRE(tool_changes.size() == 1);
|
||||
CHECK(tool_changes.front().second == 1u);
|
||||
}
|
||||
Reference in New Issue
Block a user