mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-06-11 06:23:08 +00:00
- 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.
29 lines
888 B
C++
29 lines
888 B
C++
#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);
|
|
}
|