mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-09-16 13:32:44 +00:00
Merge main and resolved conflicts
This commit is contained in:
@@ -19,6 +19,7 @@ add_executable(${_TEST_NAME}_tests
|
||||
test_skirt_brim.cpp
|
||||
test_slicing_pipeline_hook.cpp
|
||||
test_support_material.cpp
|
||||
test_tree_support.cpp
|
||||
test_trianglemesh.cpp
|
||||
test_wipe_tower.cpp
|
||||
)
|
||||
|
||||
@@ -699,6 +699,213 @@ TEST_CASE("Solid infill direction offsets every layer when no template is set",
|
||||
}
|
||||
}
|
||||
|
||||
// Orca: the spiral inset pattern chains the concentric loops into a single continuous path per
|
||||
// island, so it has to cope with the degenerate loops offsetting leaves behind and it must not join
|
||||
// loops that only look adjacent.
|
||||
namespace {
|
||||
|
||||
Slic3r::Polylines spiral_inset_fill(const Slic3r::ExPolygon &surface_shape, double spacing)
|
||||
{
|
||||
std::unique_ptr<Slic3r::Fill> filler(Slic3r::Fill::new_from_type("spiralinset"));
|
||||
filler->spacing = spacing;
|
||||
// Cancel the half-spacing contraction fill_surface() applies, so the filler sees the shape as given.
|
||||
filler->overlap = 0.5 * spacing;
|
||||
|
||||
Slic3r::FillParams fill_params;
|
||||
fill_params.density = 1.f;
|
||||
fill_params.dont_adjust = true;
|
||||
|
||||
Slic3r::Surface surface(Slic3r::stBottom, surface_shape);
|
||||
return filler->fill_surface(&surface, fill_params);
|
||||
}
|
||||
|
||||
Slic3r::ExPolygon rectangle(double x, double y, double w, double h)
|
||||
{
|
||||
return Slic3r::ExPolygon({Slic3r::Point::new_scale(x, y), Slic3r::Point::new_scale(x + w, y),
|
||||
Slic3r::Point::new_scale(x + w, y + h), Slic3r::Point::new_scale(x, y + h)});
|
||||
}
|
||||
|
||||
// Area of the surface the toolpaths fail to cover, and the largest single patch of it, in mm2. Each
|
||||
// bead is measured at its own width so the variable width walls are not sold short.
|
||||
std::pair<double, double> uncovered_area(const Slic3r::ExPolygon &surface_shape, const Slic3r::Polygons &covered)
|
||||
{
|
||||
double total = 0, biggest = 0;
|
||||
for (const Slic3r::ExPolygon &gap : Slic3r::diff_ex(Slic3r::ExPolygons{surface_shape}, Slic3r::union_(covered))) {
|
||||
const double area = unscale<double>(unscale<double>(gap.area()));
|
||||
total += area;
|
||||
biggest = std::max(biggest, area);
|
||||
}
|
||||
return {total, biggest};
|
||||
}
|
||||
|
||||
Slic3r::Polygons beads_of(const Slic3r::Polylines &paths, double width)
|
||||
{
|
||||
return Slic3r::offset(paths, float(scale_(0.5 * width)));
|
||||
}
|
||||
|
||||
Slic3r::Polygons beads_of(const Slic3r::ThickPolylines &paths)
|
||||
{
|
||||
Slic3r::Polygons covered;
|
||||
for (const Slic3r::ThickPolyline &path : paths)
|
||||
for (size_t i = 0; i + 1 < path.points.size(); ++i) {
|
||||
Slic3r::Polyline segment;
|
||||
segment.points = {path.points[i], path.points[i + 1]};
|
||||
Slic3r::append(covered, Slic3r::offset(Slic3r::Polylines{segment},
|
||||
float(0.5 * std::max(path.width[2 * i], path.width[2 * i + 1]))));
|
||||
}
|
||||
return covered;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
TEST_CASE("Spiral inset fill drops loops shorter than the end clipping", "[Fill][Regression]")
|
||||
{
|
||||
// A sliver whose whole perimeter is shorter than the length clipped off the end of a loop, so the
|
||||
// clipping consumes the path entirely. Such a loop carries no extrusion and must be dropped
|
||||
// rather than kept as an empty path and read back from.
|
||||
const double spacing = 0.45;
|
||||
|
||||
Slic3r::Polylines paths;
|
||||
REQUIRE_NOTHROW(paths = spiral_inset_fill(rectangle(0, 0, 0.05, 0.05), spacing));
|
||||
for (const Slic3r::Polyline &path : paths)
|
||||
CHECK(path.size() >= 2);
|
||||
|
||||
// The same surface at a size the clipping cannot swallow still gets filled.
|
||||
REQUIRE_NOTHROW(paths = spiral_inset_fill(rectangle(0, 0, 5, 5), spacing));
|
||||
REQUIRE(paths.size() == 1);
|
||||
CHECK(paths.front().size() >= 2);
|
||||
}
|
||||
|
||||
TEST_CASE("Spiral inset fill keeps separate islands on separate paths", "[Fill]")
|
||||
{
|
||||
// Two lobes joined by a neck narrower than the loop spacing: the inward offsets break the surface
|
||||
// into two islands, which cannot share one spiral, and no path may leave the surface.
|
||||
const double spacing = 0.45;
|
||||
Slic3r::ExPolygon dumbbell = rectangle(0, 0, 6, 6);
|
||||
dumbbell = Slic3r::union_ex(Slic3r::ExPolygons{dumbbell, rectangle(6, 2.9, 4, 0.2), rectangle(10, 0, 6, 6)}).front();
|
||||
|
||||
const Slic3r::Polylines paths = spiral_inset_fill(dumbbell, spacing);
|
||||
REQUIRE(paths.size() >= 2);
|
||||
|
||||
// Inflate by a hair so that loops sitting exactly on the outline still count as contained.
|
||||
const Slic3r::ExPolygons within = Slic3r::offset_ex(dumbbell, float(SCALED_EPSILON));
|
||||
REQUIRE(within.size() == 1);
|
||||
for (const Slic3r::Polyline &path : paths) {
|
||||
CHECK(path.size() >= 2);
|
||||
CHECK(within.front().contains(path));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
TEST_CASE("Spiral inset fill stays connected across sharp corners", "[Fill][Regression]")
|
||||
{
|
||||
// At a corner of half-angle a, the next ring inward retreats along the bisector by spacing/sin(a),
|
||||
// which leaves it several spacings from the end of the ring it continues. Judging the break by
|
||||
// distance broke the spiral into loose rings at every spike; nesting is what decides the island.
|
||||
const double spacing = 0.45;
|
||||
const Slic3r::ExPolygon spike({Slic3r::Point::new_scale(0, 0), Slic3r::Point::new_scale(30, 0),
|
||||
Slic3r::Point::new_scale(15, 4)});
|
||||
|
||||
const Slic3r::Polylines paths = spiral_inset_fill(spike, spacing);
|
||||
CHECK(paths.size() == 1);
|
||||
|
||||
const Slic3r::ExPolygons within = Slic3r::offset_ex(spike, float(SCALED_EPSILON));
|
||||
REQUIRE(within.size() == 1);
|
||||
for (const Slic3r::Polyline &path : paths)
|
||||
CHECK(within.front().contains(path));
|
||||
}
|
||||
|
||||
TEST_CASE("Spiral inset fill starts on a convex corner", "[Fill][Regression]")
|
||||
{
|
||||
// The only right angle on this outline is the reflex one: the two edges meeting at the origin
|
||||
// span 90 degrees exactly as a square corner would, but the material lies outside them. The next
|
||||
// ring in steps away from a reflex corner along the bisector instead of hugging it, so starting
|
||||
// the spiral there sent it across a long diagonal on every single ring.
|
||||
const double spacing = 0.45;
|
||||
const Slic3r::ExPolygon notched({Slic3r::Point::new_scale(0, 0), Slic3r::Point::new_scale(0, 10),
|
||||
Slic3r::Point::new_scale(-16, 18), Slic3r::Point::new_scale(-16, -2),
|
||||
Slic3r::Point::new_scale(-8, -16), Slic3r::Point::new_scale(18, -16),
|
||||
Slic3r::Point::new_scale(10, 0)});
|
||||
|
||||
const Slic3r::Polylines paths = spiral_inset_fill(notched, spacing);
|
||||
REQUIRE(paths.size() >= 1);
|
||||
|
||||
// Every edge of the outline is at least 45 degrees off the bisector of that reflex corner, and
|
||||
// so is every ring offset from it. A long segment running along the bisector can therefore only
|
||||
// be the spiral striking out across the rings to reach the next one.
|
||||
for (const Slic3r::Polyline &path : paths)
|
||||
for (const Slic3r::Line &segment : path.lines()) {
|
||||
const Vec2d v = (segment.b - segment.a).cast<double>();
|
||||
const double direction = std::fmod(std::atan2(v.y(), v.x()) * 180.0 / M_PI + 180.0, 180.0);
|
||||
if (std::abs(direction - 45.0) > 25.0)
|
||||
continue;
|
||||
CAPTURE(direction, unscale<double>(segment.length()));
|
||||
CHECK(segment.length() <= scale_(1.5 * spacing));
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("Spiral inset fill closes the gaps with variable width walls", "[Fill]")
|
||||
{
|
||||
// Fixed width loops cannot fill a region that is not a whole number of lines across and leave the
|
||||
// remainder open, which on a ring shows up as a wedge several lines wide. Plain concentric avoids
|
||||
// that by building solid surfaces out of Arachne's variable width walls, and so must this pattern.
|
||||
const double spacing = 0.45;
|
||||
Slic3r::ExPolygon ring = rectangle(0, 0, 24, 24);
|
||||
Slic3r::Polygon hole;
|
||||
for (int i = 0; i < 64; ++i) {
|
||||
const double angle = -2.0 * PI * i / 64.0; // clockwise, so it reads as a hole
|
||||
hole.points.emplace_back(Slic3r::Point::new_scale(12 + 7.3 * std::cos(angle), 12 + 7.3 * std::sin(angle)));
|
||||
}
|
||||
ring.holes.emplace_back(hole);
|
||||
|
||||
Slic3r::PrintConfig print_config;
|
||||
Slic3r::PrintObjectConfig object_config;
|
||||
auto make_filler = [&]() {
|
||||
std::unique_ptr<Slic3r::Fill> filler(Slic3r::Fill::new_from_type("spiralinset"));
|
||||
filler->spacing = spacing;
|
||||
filler->overlap = 0.5 * spacing; // cancel the contraction, so both see the same surface
|
||||
filler->print_config = &print_config;
|
||||
filler->print_object_config = &object_config;
|
||||
return filler;
|
||||
};
|
||||
|
||||
Slic3r::FillParams params;
|
||||
params.density = 1.f;
|
||||
params.dont_adjust = false;
|
||||
params.layer_height = 0.2;
|
||||
|
||||
const Slic3r::Surface surface(Slic3r::stTop, ring);
|
||||
|
||||
std::unique_ptr<Slic3r::Fill> fixed = make_filler();
|
||||
const Slic3r::Polylines fixed_width = fixed->fill_surface(&surface, params);
|
||||
REQUIRE(!fixed_width.empty());
|
||||
const auto fixed_gaps = uncovered_area(ring, beads_of(fixed_width, fixed->spacing));
|
||||
|
||||
params.use_arachne = true;
|
||||
std::unique_ptr<Slic3r::Fill> variable = make_filler();
|
||||
const Slic3r::ThickPolylines variable_width = variable->fill_surface_arachne(&surface, params);
|
||||
REQUIRE(!variable_width.empty());
|
||||
const auto variable_gaps = uncovered_area(ring, beads_of(variable_width));
|
||||
|
||||
CAPTURE(fixed_gaps.first, fixed_gaps.second, variable_gaps.first, variable_gaps.second);
|
||||
// The wedges the fixed width loops leave behind are what the variable width walls take up.
|
||||
CHECK(variable_gaps.second < 0.5 * fixed_gaps.second);
|
||||
CHECK(variable_gaps.first < fixed_gaps.first);
|
||||
|
||||
// And it is still a spiral: far fewer paths than the ring has loops.
|
||||
// And the walls are still chained into spirals rather than printed one path per wall. The ring is
|
||||
// at its narrowest (12 - 7.3) mm across and is filled from both sides, so it is at least this many
|
||||
// walls thick there and thicker elsewhere. Arachne's short thin feature walls cannot join a spiral,
|
||||
// so only the substantial paths count towards this.
|
||||
const size_t walls_across = size_t(2.0 * (12.0 - 7.3) / spacing);
|
||||
size_t spirals = 0;
|
||||
for (const Slic3r::ThickPolyline &path : variable_width)
|
||||
if (path.length() > scale_(10.0 * spacing))
|
||||
++spirals;
|
||||
CAPTURE(spirals, walls_across, variable_width.size(), fixed_width.size());
|
||||
CHECK(2 * spirals < walls_across);
|
||||
}
|
||||
|
||||
TEST_CASE("Honeycomb infill rounds its cell corners with the smooth factor", "[Fill]")
|
||||
{
|
||||
// A cell whose sides are several times the line width, so that the corners have room to be rounded.
|
||||
|
||||
@@ -3,11 +3,103 @@
|
||||
#include "libslic3r/GCodeReader.hpp"
|
||||
#include "libslic3r/Layer.hpp"
|
||||
|
||||
#include <cmath>
|
||||
#include <map>
|
||||
#include <set>
|
||||
#include <vector>
|
||||
|
||||
#include "test_helpers.hpp" // get access to init_print, etc
|
||||
|
||||
// Not self-contained: its inline constructor uses PrintObject, PrintRegion, SlicingParameters and
|
||||
// Geometry, so it must follow the headers (pulled in via test_helpers.hpp) that define them.
|
||||
#include "libslic3r/Support/SupportParameters.hpp"
|
||||
|
||||
using namespace Slic3r::Test;
|
||||
using namespace Slic3r;
|
||||
|
||||
// Distinct layer Z heights carrying support interface extrusion.
|
||||
static size_t support_interface_layer_count(const std::string &gcode)
|
||||
{
|
||||
return layers_with_role(gcode, "support material interface").size();
|
||||
}
|
||||
|
||||
// Distinct layer Z heights carrying support base extrusion. The base G-code label "support material"
|
||||
// is a substring of "support material interface", so a base line is a support line that is not an
|
||||
// interface line.
|
||||
static size_t support_base_layer_count(const std::string &gcode)
|
||||
{
|
||||
std::set<double> layers;
|
||||
GCodeReader parser;
|
||||
parser.parse_buffer(gcode, [&layers](GCodeReader &self, const GCodeReader::GCodeLine &line) {
|
||||
if (! line.extruding(self)) return;
|
||||
const std::string_view comment = line.comment();
|
||||
if (comment.find("support material") != std::string_view::npos &&
|
||||
comment.find("interface") == std::string_view::npos)
|
||||
layers.insert(self.z());
|
||||
});
|
||||
return layers.size();
|
||||
}
|
||||
|
||||
// Dominant support-interface fill direction per interface layer, in radians [0, pi). Uses the
|
||||
// length-weighted axial mean (each segment angle doubled so a line and its reverse agree, then
|
||||
// halved): the parallel infill lines reinforce while the surrounding perimeter cancels.
|
||||
static std::map<double, double> interface_fill_angle_by_layer(const std::string &gcode)
|
||||
{
|
||||
std::map<double, std::pair<double, double>> acc; // z -> summed length*(cos2a, sin2a)
|
||||
GCodeReader parser;
|
||||
parser.parse_buffer(gcode, [&acc](GCodeReader &self, const GCodeReader::GCodeLine &line) {
|
||||
if (! line.extruding(self)) return;
|
||||
if (line.comment().find("support material interface") == std::string_view::npos) return;
|
||||
const double dx = line.dist_X(self), dy = line.dist_Y(self);
|
||||
const double len = std::hypot(dx, dy);
|
||||
if (len < 1e-6) return;
|
||||
const double a2 = 2.0 * std::atan2(dy, dx);
|
||||
auto &p = acc[self.z()];
|
||||
p.first += len * std::cos(a2);
|
||||
p.second += len * std::sin(a2);
|
||||
});
|
||||
std::map<double, double> out;
|
||||
for (const auto &kv : acc) {
|
||||
double a = 0.5 * std::atan2(kv.second.second, kv.second.first);
|
||||
if (a < 0) a += M_PI;
|
||||
out[kv.first] = a;
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
// Acute angle (degrees) between two axial fill directions in [0, pi).
|
||||
static double axial_angle_diff_deg(double a, double b)
|
||||
{
|
||||
const double d = std::fmod(std::fabs(a - b), M_PI);
|
||||
return std::min(d, M_PI - d) * 180.0 / M_PI;
|
||||
}
|
||||
|
||||
// Denser interface spacing yields more extruded length.
|
||||
static double support_interface_extrusion_length(const std::string &gcode)
|
||||
{
|
||||
double len = 0;
|
||||
GCodeReader parser;
|
||||
parser.parse_buffer(gcode, [&len](GCodeReader &self, const GCodeReader::GCodeLine &line) {
|
||||
if (! line.extruding(self)) return;
|
||||
if (line.comment().find("support material interface") == std::string_view::npos) return;
|
||||
len += std::hypot(line.dist_X(self), line.dist_Y(self));
|
||||
});
|
||||
return len;
|
||||
}
|
||||
|
||||
// A cap slab overhanging a base, joined by a central stem: the cap can only be supported by resting on the
|
||||
// base, forcing a genuine bottom contact. A horizontal tunnel does not work here -- tree/organic can arch a
|
||||
// branch in from the opening and avoid the floor entirely.
|
||||
static TriangleMesh support_capital()
|
||||
{
|
||||
TriangleMesh model = make_cube(40, 40, 2); // base [0,40]x[0,40]x[0,2]
|
||||
TriangleMesh stem = make_cube(8, 8, 12); stem.translate(16, 16, 1); // stem centered, z 1..13
|
||||
TriangleMesh cap = make_cube(40, 40, 2); cap.translate(0, 0, 12); // cap z 12..14
|
||||
model.merge(stem);
|
||||
model.merge(cap);
|
||||
return model;
|
||||
}
|
||||
|
||||
TEST_CASE("Three raft layers are created", "[SupportMaterial]")
|
||||
{
|
||||
Slic3r::Print print;
|
||||
@@ -104,3 +196,272 @@ TEST_CASE("Support G-code emission survives a second slice in the same process",
|
||||
const std::string second = slice({ TestMesh::overhang }, { { "enable_support", 1 } });
|
||||
REQUIRE(! layers_with_role(second, "support").empty());
|
||||
}
|
||||
|
||||
// The contact layer counts toward the configured interface layer count, so N configured top
|
||||
// interface layers produce exactly N interface layers, not N+1.
|
||||
TEST_CASE("Support top interface layer count matches the configured value", "[SupportMaterial]")
|
||||
{
|
||||
const int top = GENERATE(1, 2, 3, 4, 6);
|
||||
const std::string g = slice({ TestMesh::overhang }, {
|
||||
{ "enable_support", 1 },
|
||||
{ "layer_height", 0.2 },
|
||||
{ "support_on_build_plate_only", 1 },
|
||||
{ "support_interface_top_layers", top },
|
||||
{ "support_interface_bottom_layers", 0 },
|
||||
});
|
||||
CAPTURE(top);
|
||||
REQUIRE(support_base_layer_count(g) > 0); // support actually formed
|
||||
REQUIRE(support_interface_layer_count(g) == size_t(top));
|
||||
}
|
||||
|
||||
// A rotated cube-with-hole is a horizontal tunnel whose ceiling and floor both receive support, so top
|
||||
// and bottom interfaces can be exercised independently (the floor is the bottom contact).
|
||||
static TriangleMesh support_tunnel()
|
||||
{
|
||||
TriangleMesh tunnel = Slic3r::Test::mesh(TestMesh::cube_with_hole);
|
||||
tunnel.rotate_x(float(M_PI / 2));
|
||||
return tunnel;
|
||||
}
|
||||
|
||||
static size_t tunnel_interface_layers(const TriangleMesh &tunnel, int top, int bottom)
|
||||
{
|
||||
const std::string g = slice({ tunnel }, {
|
||||
{ "enable_support", 1 },
|
||||
{ "layer_height", 0.2 },
|
||||
{ "support_on_build_plate_only", 0 },
|
||||
{ "support_interface_top_layers", top },
|
||||
{ "support_interface_bottom_layers", bottom },
|
||||
});
|
||||
REQUIRE(support_base_layer_count(g) > 0); // support actually formed
|
||||
return support_interface_layer_count(g);
|
||||
}
|
||||
|
||||
TEST_CASE("No support interface is generated when neither top nor bottom is configured", "[SupportMaterial]")
|
||||
{
|
||||
REQUIRE(tunnel_interface_layers(support_tunnel(), 0, 0) == 0);
|
||||
}
|
||||
|
||||
TEST_CASE("Bottom interface layer count matches its setting with top interface off", "[SupportMaterial]")
|
||||
{
|
||||
const int bottom = GENERATE(1, 3, 6);
|
||||
CAPTURE(bottom);
|
||||
REQUIRE(tunnel_interface_layers(support_tunnel(), 0, bottom) == size_t(bottom));
|
||||
}
|
||||
|
||||
// support_interface_bottom_layers = -1 means "same as top".
|
||||
TEST_CASE("Support interface bottom layers default to the top layer count", "[SupportMaterial]")
|
||||
{
|
||||
const TriangleMesh tunnel = support_tunnel();
|
||||
REQUIRE(tunnel_interface_layers(tunnel, 0, -1) == tunnel_interface_layers(tunnel, 0, 0));
|
||||
REQUIRE(tunnel_interface_layers(tunnel, 3, -1) == tunnel_interface_layers(tunnel, 3, 3));
|
||||
}
|
||||
|
||||
TEST_CASE("Default support still emits base and interface material", "[SupportMaterial][Regression]")
|
||||
{
|
||||
const std::string g = slice({ TestMesh::overhang }, { { "enable_support", 1 } });
|
||||
REQUIRE(support_base_layer_count(g) > 0);
|
||||
REQUIRE(support_interface_layer_count(g) > 0);
|
||||
}
|
||||
|
||||
// Organic runs TreeSupport3D + TreeModelVolumes, the others the classic TreeSupport.cpp path.
|
||||
TEST_CASE("Every tree support style produces base and interface material", "[SupportMaterial]")
|
||||
{
|
||||
const char *style = GENERATE("organic", "tree_slim", "tree_strong", "tree_hybrid");
|
||||
INFO("style=" << style);
|
||||
const std::string g = slice({ TestMesh::overhang }, {
|
||||
{ "enable_support", 1 },
|
||||
{ "layer_height", 0.2 },
|
||||
{ "support_type", "tree(auto)" },
|
||||
{ "support_style", style },
|
||||
{ "support_interface_top_layers", 3 },
|
||||
});
|
||||
CHECK(support_base_layer_count(g) > 0);
|
||||
CHECK(support_interface_layer_count(g) > 0);
|
||||
}
|
||||
|
||||
TEST_CASE("Raft interface angle alternates by 45 degrees per interface id", "[SupportMaterial]")
|
||||
{
|
||||
Slic3r::Print print;
|
||||
Slic3r::Test::init_and_process_print({ TestMesh::overhang }, print, { { "enable_support", 1 } });
|
||||
SupportParameters sp(*print.objects().front());
|
||||
sp.raft_angle_interface = 0.5f;
|
||||
REQUIRE_THAT(sp.raft_interface_angle(0), Catch::Matchers::WithinAbs(0.5 + M_PI / 4., 1e-6));
|
||||
REQUIRE_THAT(sp.raft_interface_angle(1), Catch::Matchers::WithinAbs(0.5 - M_PI / 4., 1e-6));
|
||||
}
|
||||
|
||||
// The angle inputs are overwritten directly, so the pattern-to-angle mapping is checked
|
||||
// independently of the sliced object's configuration.
|
||||
TEST_CASE("Support interface fill angle follows the configured interface pattern", "[SupportMaterial]")
|
||||
{
|
||||
Slic3r::Print print;
|
||||
Slic3r::Test::init_and_process_print({ TestMesh::overhang }, print, { { "enable_support", 1 } });
|
||||
SupportParameters sp(*print.objects().front());
|
||||
sp.interface_angle = 0.3f;
|
||||
sp.base_angle = 1.1f;
|
||||
const double tol = 1e-6;
|
||||
|
||||
SECTION("Rectilinear shifts the interface angle by -45deg for snug support") {
|
||||
sp.support_interface_pattern = smipRectilinear;
|
||||
sp.support_style = smsSnug;
|
||||
REQUIRE_THAT(sp.support_interface_angle(0), Catch::Matchers::WithinAbs(sp.interface_angle - M_PI_4, tol));
|
||||
REQUIRE_THAT(sp.support_interface_angle(3), Catch::Matchers::WithinAbs(sp.interface_angle - M_PI_4, tol));
|
||||
}
|
||||
SECTION("Rectilinear leaves the interface angle alone for the other styles") {
|
||||
sp.support_interface_pattern = smipRectilinear;
|
||||
sp.support_style = smsGrid;
|
||||
REQUIRE_THAT(sp.support_interface_angle(0), Catch::Matchers::WithinAbs(sp.interface_angle, tol));
|
||||
}
|
||||
SECTION("Rectilinear interlaced alternates -/+45deg by interface id parity") {
|
||||
sp.support_interface_pattern = smipRectilinearInterlaced;
|
||||
REQUIRE_THAT(sp.support_interface_angle(0), Catch::Matchers::WithinAbs(sp.interface_angle - M_PI_4, tol));
|
||||
REQUIRE_THAT(sp.support_interface_angle(1), Catch::Matchers::WithinAbs(sp.interface_angle + M_PI_4, tol));
|
||||
}
|
||||
SECTION("Grid uses the base angle") {
|
||||
sp.support_interface_pattern = smipGrid;
|
||||
REQUIRE_THAT(sp.support_interface_angle(0), Catch::Matchers::WithinAbs(sp.base_angle, tol));
|
||||
}
|
||||
SECTION("Auto and concentric use the interface angle unchanged") {
|
||||
sp.support_interface_pattern = smipAuto;
|
||||
REQUIRE_THAT(sp.support_interface_angle(0), Catch::Matchers::WithinAbs(sp.interface_angle, tol));
|
||||
sp.support_interface_pattern = smipConcentric;
|
||||
REQUIRE_THAT(sp.support_interface_angle(0), Catch::Matchers::WithinAbs(sp.interface_angle, tol));
|
||||
}
|
||||
}
|
||||
|
||||
// End-to-end that the pattern reaches the emitted fill, not just support_interface_angle().
|
||||
TEST_CASE("Interlaced support interface alternates fill angle while rectilinear does not", "[SupportMaterial]")
|
||||
{
|
||||
auto interface_angles = [](const char *pattern) {
|
||||
std::vector<double> a;
|
||||
for (const auto &kv : interface_fill_angle_by_layer(slice({ TestMesh::overhang }, {
|
||||
{ "enable_support", 1 },
|
||||
{ "layer_height", 0.2 },
|
||||
{ "support_on_build_plate_only", 1 },
|
||||
{ "support_interface_top_layers", 6 },
|
||||
{ "support_interface_pattern", pattern } })))
|
||||
a.push_back(kv.second);
|
||||
return a;
|
||||
};
|
||||
|
||||
const std::vector<double> rectilinear = interface_angles("rectilinear");
|
||||
const std::vector<double> interlaced = interface_angles("rectilinear_interlaced");
|
||||
REQUIRE(rectilinear.size() >= 3);
|
||||
REQUIRE(interlaced.size() >= 3);
|
||||
|
||||
for (size_t i = 1; i < rectilinear.size(); ++i)
|
||||
REQUIRE(axial_angle_diff_deg(rectilinear[i], rectilinear[0]) < 15.0);
|
||||
|
||||
for (size_t i = 1; i < interlaced.size(); ++i)
|
||||
REQUIRE(axial_angle_diff_deg(interlaced[i], interlaced[i - 1]) > 60.0);
|
||||
}
|
||||
|
||||
// Normal and non-organic tree support share the same interface angle logic: with a rectilinear interface
|
||||
// pattern both emit their interface fill at the same angle (both go through support_interface_angle()).
|
||||
TEST_CASE("Normal and tree support use the same interface fill angle", "[SupportMaterial]")
|
||||
{
|
||||
auto mean_interface_angle = [](const char *type, const char *style) {
|
||||
const auto angles = interface_fill_angle_by_layer(slice({ TestMesh::overhang }, {
|
||||
{ "enable_support", 1 }, { "layer_height", 0.2 }, { "support_on_build_plate_only", 1 },
|
||||
{ "support_type", type }, { "support_style", style },
|
||||
{ "support_interface_top_layers", 6 }, { "support_interface_pattern", "rectilinear" } }));
|
||||
REQUIRE(angles.size() >= 3);
|
||||
// Axial mean, as in interface_fill_angle_by_layer: a plain mean would split angles either
|
||||
// side of the [0, pi) wrap.
|
||||
double x = 0, y = 0;
|
||||
for (const auto &kv : angles) {
|
||||
x += std::cos(2.0 * kv.second);
|
||||
y += std::sin(2.0 * kv.second);
|
||||
}
|
||||
double mean = 0.5 * std::atan2(y, x);
|
||||
if (mean < 0) mean += M_PI;
|
||||
return mean;
|
||||
};
|
||||
REQUIRE(axial_angle_diff_deg(mean_interface_angle("normal(auto)", "default"),
|
||||
mean_interface_angle("tree(auto)", "tree_slim")) < 10.0);
|
||||
}
|
||||
|
||||
// Every style, because the non-organic tree styles once emitted one more top interface layer than the rest.
|
||||
TEST_CASE("Top interface layer count equals the configured value for every support style", "[SupportMaterial]")
|
||||
{
|
||||
auto [type, style] = GENERATE(table<const char *, const char *>({
|
||||
{ "normal(auto)", "grid" }, { "normal(auto)", "snug" },
|
||||
{ "tree(auto)", "organic" }, { "tree(auto)", "tree_slim" },
|
||||
{ "tree(auto)", "tree_strong" }, { "tree(auto)", "tree_hybrid" },
|
||||
}));
|
||||
CAPTURE(style);
|
||||
const std::string g = slice({ TestMesh::overhang }, {
|
||||
{ "enable_support", 1 },
|
||||
{ "layer_height", 0.2 },
|
||||
{ "support_type", type },
|
||||
{ "support_style", style },
|
||||
{ "support_interface_top_layers", 4 },
|
||||
});
|
||||
REQUIRE(support_interface_layer_count(g) == 4u);
|
||||
}
|
||||
|
||||
// The bottom interface was dropped in earlier versions when support started on the model rather
|
||||
// than the plate.
|
||||
TEST_CASE("Non-organic tree support generates a bottom interface on internal geometry", "[SupportMaterial]")
|
||||
{
|
||||
const std::string g = slice({ support_tunnel() }, {
|
||||
{ "enable_support", 1 },
|
||||
{ "layer_height", 0.2 },
|
||||
{ "support_on_build_plate_only", 0 },
|
||||
{ "support_type", "tree(auto)" },
|
||||
{ "support_style", "tree_slim" },
|
||||
{ "support_interface_top_layers", 0 },
|
||||
{ "support_interface_bottom_layers", 6 },
|
||||
});
|
||||
REQUIRE(support_base_layer_count(g) > 0);
|
||||
REQUIRE(support_interface_layer_count(g) > 0);
|
||||
}
|
||||
|
||||
// The capital forces the model contact; on a horizontal tunnel organic can arch a branch in and make none.
|
||||
TEST_CASE("A bottom interface is produced for every support style on a forced model contact", "[SupportMaterial]")
|
||||
{
|
||||
auto [type, style] = GENERATE(table<const char *, const char *>({
|
||||
{ "normal(auto)", "default" }, { "tree(auto)", "tree_slim" },
|
||||
{ "tree(auto)", "tree_strong" }, { "tree(auto)", "tree_hybrid" },
|
||||
{ "tree(auto)", "organic" },
|
||||
}));
|
||||
CAPTURE(style);
|
||||
REQUIRE(support_interface_layer_count(slice({ support_capital() }, {
|
||||
{ "enable_support", 1 }, { "layer_height", 0.2 }, { "support_on_build_plate_only", 0 },
|
||||
{ "support_type", type }, { "support_style", style },
|
||||
{ "support_interface_top_layers", 0 }, { "support_interface_bottom_layers", 6 } })) > 0);
|
||||
}
|
||||
|
||||
TEST_CASE("Bottom interface spacing controls bottom interface density for every support style", "[SupportMaterial]")
|
||||
{
|
||||
auto [type, style] = GENERATE(table<const char *, const char *>({
|
||||
{ "normal(auto)", "default" }, { "tree(auto)", "tree_slim" },
|
||||
{ "tree(auto)", "tree_strong" }, { "tree(auto)", "tree_hybrid" },
|
||||
{ "tree(auto)", "organic" },
|
||||
}));
|
||||
CAPTURE(style);
|
||||
const TriangleMesh model = support_capital();
|
||||
auto len = [&model](const char *support_type, const char *support_style, double spacing) {
|
||||
return support_interface_extrusion_length(slice({ model }, {
|
||||
{ "enable_support", 1 }, { "layer_height", 0.2 }, { "support_on_build_plate_only", 0 },
|
||||
{ "support_type", support_type }, { "support_style", support_style }, { "support_interface_top_layers", 0 },
|
||||
{ "support_interface_bottom_layers", 6 }, { "support_bottom_interface_spacing", spacing } }));
|
||||
};
|
||||
REQUIRE(len(type, style, 0.0) > len(type, style, 4.0) * 1.5);
|
||||
}
|
||||
|
||||
// Interface and base flows are identical in width and rate unless a separate support-interface
|
||||
// filament is used, so density is the observable here, not flow.
|
||||
TEST_CASE("Bottom-only support interface keeps the dense interface density", "[SupportMaterial]")
|
||||
{
|
||||
Slic3r::Print print;
|
||||
Slic3r::Test::init_and_process_print({ TestMesh::overhang }, print, {
|
||||
{ "enable_support", 1 },
|
||||
{ "support_interface_top_layers", 0 },
|
||||
{ "support_interface_bottom_layers", 6 },
|
||||
{ "support_bottom_interface_spacing", 0.0 }, // solid: density resolves to 1.0
|
||||
{ "support_base_pattern_spacing", 2.5 }, // sparse: density stays below 1.0
|
||||
});
|
||||
SupportParameters sp(*print.objects().front());
|
||||
REQUIRE(sp.bottom_interface_density > sp.support_density);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,125 @@
|
||||
#include <catch2/catch_all.hpp>
|
||||
|
||||
#include "libslic3r/Layer.hpp"
|
||||
#include "libslic3r/TriangleMesh.hpp"
|
||||
|
||||
#include "test_helpers.hpp"
|
||||
|
||||
using namespace Slic3r::Test;
|
||||
using namespace Slic3r;
|
||||
|
||||
namespace {
|
||||
|
||||
// The upper plate overhangs both the lower plate and open air, so branches land on the model and on
|
||||
// the bed in the same slice.
|
||||
TriangleMesh two_tier_mesh()
|
||||
{
|
||||
TriangleMesh lower = make_cube(30, 30, 3);
|
||||
TriangleMesh column = make_cube(8, 8, 15);
|
||||
TriangleMesh upper = make_cube(50, 50, 3);
|
||||
// Each part overlaps the one below rather than resting on it; a coplanar join slices ambiguously.
|
||||
column.translate(11.f, 11.f, 2.f);
|
||||
upper.translate(-10.f, -10.f, 16.f);
|
||||
TriangleMesh mesh = lower;
|
||||
mesh.merge(column);
|
||||
mesh.merge(upper);
|
||||
return mesh;
|
||||
}
|
||||
|
||||
TriangleMesh scaled(TestMesh id, float scale)
|
||||
{
|
||||
TriangleMesh mesh = Slic3r::Test::mesh(id);
|
||||
mesh.scale(scale);
|
||||
return mesh;
|
||||
}
|
||||
|
||||
void slice_with_tree_support(const TriangleMesh &mesh, Slic3r::Print &print, const char *style,
|
||||
int threshold_angle = 30, int build_plate_only = 0, int raft_layers = 0)
|
||||
{
|
||||
Slic3r::Test::init_and_process_print({ mesh }, print, {
|
||||
{ "enable_support", 1 },
|
||||
{ "support_type", "tree(auto)" },
|
||||
{ "support_style", style },
|
||||
{ "support_on_build_plate_only", build_plate_only },
|
||||
{ "support_threshold_angle", threshold_angle },
|
||||
{ "raft_layers", raft_layers },
|
||||
{ "layer_height", 0.2 },
|
||||
});
|
||||
}
|
||||
|
||||
Points support_points(const Slic3r::Print &print)
|
||||
{
|
||||
Points points;
|
||||
for (const SupportLayer *layer : print.objects().front()->support_layers())
|
||||
layer->support_fills.collect_points(points);
|
||||
return points;
|
||||
}
|
||||
|
||||
size_t support_point_count(const TriangleMesh &mesh, const char *style, int threshold_angle = 30,
|
||||
int build_plate_only = 0)
|
||||
{
|
||||
Slic3r::Print print;
|
||||
slice_with_tree_support(mesh, print, style, threshold_angle, build_plate_only);
|
||||
return support_points(print).size();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
TEST_CASE("Tree support is generated for an overhang and not for a plain cube", "[TreeSupport]")
|
||||
{
|
||||
REQUIRE(support_point_count(scaled(TestMesh::overhang, 2.f), "tree_slim") > 1000);
|
||||
REQUIRE(support_point_count(Slic3r::Test::cube(20), "tree_slim") == 0);
|
||||
}
|
||||
|
||||
TEST_CASE("Restricting tree support to the build plate changes what is generated", "[TreeSupport]")
|
||||
{
|
||||
const TriangleMesh mesh = two_tier_mesh();
|
||||
const size_t anywhere = support_point_count(mesh, "tree_slim", 30, 0);
|
||||
const size_t plate_only = support_point_count(mesh, "tree_slim", 30, 1);
|
||||
REQUIRE(anywhere > 1000);
|
||||
REQUIRE(plate_only > 1000);
|
||||
// The upper plate overhangs the lower one, so some branches would land on the model.
|
||||
REQUIRE(plate_only != anywhere);
|
||||
}
|
||||
|
||||
TEST_CASE("Tree support layers rise monotonically within the layer height limits", "[TreeSupport]")
|
||||
{
|
||||
Slic3r::Print print;
|
||||
slice_with_tree_support(scaled(TestMesh::overhang, 2.f), print, "tree_slim");
|
||||
const double nozzle = print.config().nozzle_diameter.values.front();
|
||||
|
||||
size_t checked = 0;
|
||||
double previous = 0;
|
||||
bool previous_was_adjacent = false;
|
||||
for (const SupportLayer *layer : print.objects().front()->support_layers()) {
|
||||
if (layer->print_z <= 0 || layer->height <= 0) {
|
||||
// Layers with no nodes are left at zero. Skipping one leaves a hole, so the next pair
|
||||
// spans more than one layer and its gap says nothing about the layer height limit.
|
||||
previous_was_adjacent = false;
|
||||
continue;
|
||||
}
|
||||
if (previous > 0) {
|
||||
CAPTURE(previous, layer->print_z);
|
||||
REQUIRE(layer->print_z > previous);
|
||||
if (previous_was_adjacent)
|
||||
REQUIRE(layer->print_z - previous <= nozzle + EPSILON);
|
||||
}
|
||||
previous = layer->print_z;
|
||||
previous_was_adjacent = true;
|
||||
++checked;
|
||||
}
|
||||
REQUIRE(checked > 10);
|
||||
}
|
||||
|
||||
TEST_CASE("A raft is still generated under tree support", "[TreeSupport]")
|
||||
{
|
||||
// The mesh supports itself, so a layer count alone passes with no raft at all.
|
||||
Slic3r::Print rafted, unrafted;
|
||||
slice_with_tree_support(scaled(TestMesh::overhang, 2.f), rafted, "tree_slim", 30, 0, 3);
|
||||
slice_with_tree_support(scaled(TestMesh::overhang, 2.f), unrafted, "tree_slim", 30, 0, 0);
|
||||
const PrintObject *rafted_object = rafted.objects().front();
|
||||
const PrintObject *unrafted_object = unrafted.objects().front();
|
||||
REQUIRE(rafted_object->support_layers().size() > unrafted_object->support_layers().size());
|
||||
// The raft goes under the object.
|
||||
REQUIRE(rafted_object->layers().front()->print_z > unrafted_object->layers().front()->print_z);
|
||||
}
|
||||
@@ -8,6 +8,7 @@ add_executable(${_TEST_NAME}_tests
|
||||
test_arachne_walls.cpp
|
||||
test_arrange.cpp
|
||||
test_bambu_networking.cpp
|
||||
test_buildvolume.cpp
|
||||
test_calib.cpp
|
||||
test_clipper_offset.cpp
|
||||
test_clipper_utils.cpp
|
||||
|
||||
@@ -22,6 +22,8 @@
|
||||
#include "libslic3r/Arachne/utils/ExtrusionLine.hpp"
|
||||
#include "libslic3r/Arachne/BeadingStrategy/BeadingStrategyFactory.hpp"
|
||||
#include "libslic3r/Arachne/BeadingStrategy/BeadingStrategy.hpp"
|
||||
#include "libslic3r/Feature/FuzzySkin/FuzzySkin.hpp"
|
||||
#include "libslic3r/Flow.hpp"
|
||||
#include "libslic3r/Polygon.hpp"
|
||||
#include "libslic3r/ExPolygon.hpp"
|
||||
#include "libslic3r/ClipperUtils.hpp"
|
||||
@@ -309,3 +311,71 @@ TEST_CASE("Beading interpolation tolerates a thicker side with fewer insets", "[
|
||||
CHECK(result.bead_widths[i] == expected.bead_widths[i]);
|
||||
}
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
// Closed 20 mm square loop at a uniform width.
|
||||
Arachne::ExtrusionJunctions square_loop(coord_t width)
|
||||
{
|
||||
const coord_t s = scaled<coord_t>(20.);
|
||||
return {{Point(0, 0), width, 0}, {Point(s, 0), width, 0}, {Point(s, s), width, 0}, {Point(0, s), width, 0}, {Point(0, 0), width, 0}};
|
||||
}
|
||||
|
||||
FuzzySkinConfig thick_fuzzy_config(FuzzySkinMode mode, NoiseType noise_type, double thickness_mm)
|
||||
{
|
||||
FuzzySkinConfig cfg{};
|
||||
cfg.type = FuzzySkinType::All;
|
||||
cfg.thickness = scaled<coord_t>(thickness_mm);
|
||||
cfg.point_distance = scaled<coord_t>(0.3);
|
||||
cfg.fuzzy_first_layer = true;
|
||||
cfg.noise_type = noise_type;
|
||||
cfg.noise_scale = 1.0;
|
||||
cfg.noise_octaves = 4;
|
||||
cfg.noise_persistence = 0.5;
|
||||
cfg.mode = mode;
|
||||
cfg.layer_id = 5;
|
||||
return cfg;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
// Extrusion and Combined mode add noise to each junction's width. A junction narrower than
|
||||
// height * (1 - PI/4) makes Flow::rounded_rectangle_extrusion_spacing() throw and fails the slice.
|
||||
// The fuzz thickness is 3x the line width so the clamp is hit on every run regardless of RNG seed.
|
||||
// Ridged multifractal is covered because its output is not bounded to [-1, 1], so it scales past
|
||||
// the configured thickness; the floor has to hold for any noise value, not just an in-range one.
|
||||
TEST_CASE("Fuzzy skin extrusion width is floored at the minimum the flow accepts", "[Arachne][FuzzySkin]") {
|
||||
using namespace Slic3r::Feature::FuzzySkin;
|
||||
|
||||
const double layer_height = GENERATE(0.08, 0.2, 0.28);
|
||||
const auto mode = GENERATE(FuzzySkinMode::Extrusion, FuzzySkinMode::Combined);
|
||||
const auto noise_type = GENERATE(NoiseType::Classic, NoiseType::Perlin, NoiseType::Billow, NoiseType::RidgedMulti, NoiseType::Voronoi);
|
||||
CAPTURE(layer_height, int(mode), int(noise_type));
|
||||
|
||||
const double line_width_mm = 0.42;
|
||||
auto loop = square_loop(scaled<coord_t>(line_width_mm));
|
||||
fuzzy_extrusion_line(loop, /*slice_z*/ 1.0, layer_height, thick_fuzzy_config(mode, noise_type, 3 * line_width_mm));
|
||||
|
||||
REQUIRE(loop.size() > 100);
|
||||
|
||||
const auto narrowest = std::min_element(loop.begin(), loop.end(), [](const auto& a, const auto& b) { return a.w < b.w; });
|
||||
const double narrowest_mm = unscaled<double>(narrowest->w);
|
||||
const double floor_mm = layer_height * (1. - 0.25 * PI);
|
||||
CAPTURE(narrowest_mm, floor_mm);
|
||||
|
||||
CHECK(narrowest_mm < line_width_mm); // the clamp was exercised
|
||||
CHECK(narrowest_mm > floor_mm);
|
||||
CHECK_NOTHROW(Flow::rounded_rectangle_extrusion_spacing(float(narrowest_mm), float(layer_height)));
|
||||
}
|
||||
|
||||
// Displacement mode only moves points; widths must pass through unchanged.
|
||||
TEST_CASE("Fuzzy skin displacement mode leaves widths untouched", "[Arachne][FuzzySkin]") {
|
||||
using namespace Slic3r::Feature::FuzzySkin;
|
||||
|
||||
const coord_t width = scaled<coord_t>(0.42);
|
||||
auto loop = square_loop(width);
|
||||
fuzzy_extrusion_line(loop, /*slice_z*/ 1.0, /*layer_height*/ 0.2, thick_fuzzy_config(FuzzySkinMode::Displacement, NoiseType::Classic, 1.26));
|
||||
|
||||
REQUIRE(loop.size() > 100);
|
||||
CHECK(std::all_of(loop.begin(), loop.end(), [width](const auto& j) { return j.w == width; }));
|
||||
}
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
#include <catch2/catch_all.hpp>
|
||||
|
||||
#include "libslic3r/BuildVolume.hpp"
|
||||
|
||||
using namespace Slic3r;
|
||||
|
||||
static std::vector<Vec2d> rect_area(double w, double d)
|
||||
{
|
||||
return { { 0., 0. }, { w, 0. }, { w, d }, { 0., d } };
|
||||
}
|
||||
|
||||
// extruder_printable_height and extruder_printable_area are independent config options, so a
|
||||
// profile can leave the heights short. BuildVolume must not index past the end of the heights.
|
||||
TEST_CASE("BuildVolume falls back to the bed height when extruder_printable_height is short", "[BuildVolume]")
|
||||
{
|
||||
const std::vector<Vec2d> bed = rect_area(200., 200.);
|
||||
const std::vector<std::vector<Vec2d>> areas = { rect_area(200., 200.), rect_area(100., 200.) };
|
||||
const std::vector<double> heights = { 180. };
|
||||
|
||||
const BuildVolume build_volume(bed, 250., areas, heights);
|
||||
|
||||
REQUIRE(build_volume.get_extruder_area_count() == 2);
|
||||
// The extruder with a height of its own keeps it, and differs from the bed, so it gets its own volume.
|
||||
CHECK_THAT(build_volume.get_extruder_area_volume(0).bboxf.max.z(), Catch::Matchers::WithinAbs(180., 1e-6));
|
||||
// The extruder without one falls back to the bed's printable_height instead of reading out of range.
|
||||
CHECK_THAT(build_volume.get_extruder_area_volume(1).bboxf.max.z(), Catch::Matchers::WithinAbs(250., 1e-6));
|
||||
}
|
||||
|
||||
TEST_CASE("BuildVolume keeps per-extruder heights when both vectors match", "[BuildVolume]")
|
||||
{
|
||||
const std::vector<Vec2d> bed = rect_area(200., 200.);
|
||||
const std::vector<std::vector<Vec2d>> areas = { rect_area(120., 200.), rect_area(100., 200.) };
|
||||
const std::vector<double> heights = { 180., 200.5 };
|
||||
|
||||
const BuildVolume build_volume(bed, 250., areas, heights);
|
||||
|
||||
REQUIRE(build_volume.get_extruder_area_count() == 2);
|
||||
CHECK_THAT(build_volume.get_extruder_area_volume(0).bboxf.max.z(), Catch::Matchers::WithinAbs(180., 1e-6));
|
||||
CHECK_THAT(build_volume.get_extruder_area_volume(1).bboxf.max.z(), Catch::Matchers::WithinAbs(200.5, 1e-6));
|
||||
}
|
||||
@@ -856,19 +856,19 @@ TEST_CASE("read_cli rejects an invalid boolean value", "[Config]") {
|
||||
|
||||
TEST_CASE("read_cli accepts the common spellings of a boolean value", "[Config]") {
|
||||
const auto [text, expected] = GENERATE(table<const char*, bool>({
|
||||
{"--reduce-crossing-wall=1", true },
|
||||
{"--reduce-crossing-wall=true", true },
|
||||
{"--reduce-crossing-wall=Yes", true },
|
||||
{"--reduce-crossing-wall=on", true },
|
||||
{"--reduce-crossing-wall=enabled", true },
|
||||
{"--reduce-crossing-wall=TRUE", true },
|
||||
{"--reduce-crossing-wall=oN", true },
|
||||
{"--reduce-crossing-wall=0", false},
|
||||
{"--reduce-crossing-wall=false", false},
|
||||
{"--reduce-crossing-wall=No", false},
|
||||
{"--reduce-crossing-wall=off", false},
|
||||
{"--reduce-crossing-wall=1", true},
|
||||
{"--reduce-crossing-wall=true", true},
|
||||
{"--reduce-crossing-wall=Yes", true},
|
||||
{"--reduce-crossing-wall=on", true},
|
||||
{"--reduce-crossing-wall=enabled", true},
|
||||
{"--reduce-crossing-wall=TRUE", true},
|
||||
{"--reduce-crossing-wall=oN", true},
|
||||
{"--reduce-crossing-wall=0", false},
|
||||
{"--reduce-crossing-wall=false", false},
|
||||
{"--reduce-crossing-wall=No", false},
|
||||
{"--reduce-crossing-wall=off", false},
|
||||
{"--reduce-crossing-wall=disabled", false},
|
||||
{"--reduce-crossing-wall=FALSE", false},
|
||||
{"--reduce-crossing-wall=FALSE", false},
|
||||
{"--reduce-crossing-wall=DiSaBlEd", false},
|
||||
}));
|
||||
|
||||
@@ -1051,3 +1051,43 @@ TEST_CASE("read_cli accepts nil entries for a nullable vector option", "[Config]
|
||||
REQUIRE_FALSE(opt->is_nil(1));
|
||||
REQUIRE_THAT(opt->values[1], Catch::Matchers::WithinAbs(2.5, 1e-9));
|
||||
}
|
||||
|
||||
// get_at() returns values.front() for an out-of-range index, so calling it on an empty vector
|
||||
// option is UB. filament_id and filament_is_support are unpopulated on a CLI from-scratch slice.
|
||||
TEST_CASE("get_filament_type treats empty vector options as absent", "[Config][Filament]")
|
||||
{
|
||||
DynamicPrintConfig config;
|
||||
std::string displayed;
|
||||
|
||||
SECTION("an empty filament_type yields no type at all")
|
||||
{
|
||||
config.set_key_value("filament_type", new ConfigOptionStrings());
|
||||
REQUIRE(config.get_filament_type(displayed, 0) == "");
|
||||
}
|
||||
|
||||
SECTION("an empty filament_is_support falls back to the plain filament type")
|
||||
{
|
||||
config.set_key_value("filament_type", new ConfigOptionStrings({"PETG"}));
|
||||
config.set_key_value("filament_is_support", new ConfigOptionBools());
|
||||
REQUIRE(config.get_filament_type(displayed, 0) == "PETG");
|
||||
REQUIRE(displayed == "PETG");
|
||||
}
|
||||
|
||||
SECTION("a support filament with an empty filament_id resolves from the type alone")
|
||||
{
|
||||
config.set_key_value("filament_type", new ConfigOptionStrings({"PLA"}));
|
||||
config.set_key_value("filament_is_support", new ConfigOptionBools({true}));
|
||||
config.set_key_value("filament_id", new ConfigOptionStrings());
|
||||
REQUIRE(config.get_filament_type(displayed, 0) == "PLA-S");
|
||||
REQUIRE(displayed == "Sup.PLA");
|
||||
}
|
||||
|
||||
SECTION("a populated filament_id still selects the support type by id")
|
||||
{
|
||||
config.set_key_value("filament_type", new ConfigOptionStrings({"PETG"}));
|
||||
config.set_key_value("filament_is_support", new ConfigOptionBools({true}));
|
||||
config.set_key_value("filament_id", new ConfigOptionStrings({"GFS00"}));
|
||||
REQUIRE(config.get_filament_type(displayed, 0) == "PLA-S");
|
||||
REQUIRE(displayed == "Sup.PLA");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -130,6 +130,12 @@ TEST_CASE("get_config_index_base resolves (volume type, extruder type, id) to a
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("support interface pattern registry includes spiral inset", "[Config]")
|
||||
{
|
||||
const auto &values = ConfigOptionEnum<SupportMaterialInterfacePattern>::get_enum_values();
|
||||
REQUIRE(values.at("spiralinset") == SupportMaterialInterfacePattern::smipSpiralInset);
|
||||
}
|
||||
|
||||
TEST_CASE("get_extruder_nozzle_volume_count reads the per-extruder volume-type layout", "[Config]")
|
||||
{
|
||||
std::vector<std::vector<NozzleVolumeType>> nozzle_volume_types;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include <catch2/catch_all.hpp>
|
||||
|
||||
#include <algorithm>
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <fstream>
|
||||
|
||||
@@ -589,6 +590,401 @@ struct LibraryFilamentTestCollection : public PresetCollection
|
||||
|
||||
} // namespace
|
||||
|
||||
TEST_CASE("Missing app config is accepted as default CLI state", "[Preset][Bundle][Regression]")
|
||||
{
|
||||
ScopedTemporaryDir dir;
|
||||
AppConfig app_config;
|
||||
app_config.set_loading_path((dir.path() / "missing.conf").string());
|
||||
CHECK(app_config.load_if_exists().empty());
|
||||
}
|
||||
|
||||
TEST_CASE("Read-only user preset loading does not create or delete files", "[Preset][Bundle][Regression]")
|
||||
{
|
||||
ScopedTemporaryDir dir;
|
||||
PresetBundle bundle;
|
||||
PresetsConfigSubstitutions substitutions;
|
||||
|
||||
const fs::path missing_root = dir.path() / "missing-user";
|
||||
bundle.prints.load_presets(missing_root.string(), PRESET_PRINT_NAME, substitutions,
|
||||
ForwardCompatibilitySubstitutionRule::EnableSilent, nullptr,
|
||||
PresetOrigin(), true);
|
||||
CHECK_FALSE(fs::exists(missing_root / PRESET_PRINT_NAME));
|
||||
|
||||
const fs::path malformed = dir.path() / "existing-user" / PRESET_PRINT_NAME / "malformed.json";
|
||||
fs::create_directories(malformed.parent_path());
|
||||
std::ofstream(malformed.string()) << "{not-json";
|
||||
bundle.prints.load_presets((dir.path() / "existing-user").string(), PRESET_PRINT_NAME, substitutions,
|
||||
ForwardCompatibilitySubstitutionRule::EnableSilent, nullptr,
|
||||
PresetOrigin(), true);
|
||||
CHECK(fs::exists(malformed));
|
||||
}
|
||||
|
||||
TEST_CASE("Typeless preset resolution probes loaded FFF collections", "[Preset][Bundle][Regression]")
|
||||
{
|
||||
ScopedTemporaryDir dir;
|
||||
const fs::path source_file = dir.path() / "typeless-process.json";
|
||||
std::ofstream(source_file.string()) << R"({"name":"Typeless Process","from":"User"})";
|
||||
|
||||
PresetBundle bundle;
|
||||
Preset &process = add_inmemory_preset(bundle.prints, "Typeless Process");
|
||||
process.file = source_file.string();
|
||||
process.config.option<ConfigOptionFloats>("travel_speed", true)->values = {321.0};
|
||||
|
||||
DynamicPrintConfig raw;
|
||||
Preset::Type resolved_type = Preset::TYPE_INVALID;
|
||||
std::string error;
|
||||
REQUIRE(bundle.resolve_preset_config_type(raw, resolved_type, source_file.string(),
|
||||
ForwardCompatibilitySubstitutionRule::EnableSilent, error, false));
|
||||
CHECK(error.empty());
|
||||
CHECK(resolved_type == Preset::TYPE_PRINT);
|
||||
REQUIRE(raw.option<ConfigOptionFloats>("travel_speed")->values.size() == 1);
|
||||
CHECK_THAT(raw.option<ConfigOptionFloats>("travel_speed")->values.front(), Catch::Matchers::WithinAbs(321.0, 1e-6));
|
||||
}
|
||||
|
||||
TEST_CASE("Typeless preset resolution preserves duplicate identity ambiguity", "[Preset][Bundle][Regression]")
|
||||
{
|
||||
ScopedTemporaryDir dir;
|
||||
const fs::path source_file = dir.path() / "duplicate-process.json";
|
||||
std::ofstream(source_file.string()) << "{}";
|
||||
|
||||
PresetBundle bundle;
|
||||
add_inmemory_preset(bundle.prints, "First Process Identity").file = source_file.string();
|
||||
add_inmemory_preset(bundle.prints, "Second Process Identity").file = source_file.string();
|
||||
|
||||
DynamicPrintConfig raw;
|
||||
Preset::Type resolved_type = Preset::TYPE_INVALID;
|
||||
std::string error;
|
||||
CHECK_FALSE(bundle.resolve_preset_config_type(raw, resolved_type, source_file.string(),
|
||||
ForwardCompatibilitySubstitutionRule::EnableSilent, error, false));
|
||||
CHECK(error == "Preset identity is ambiguous");
|
||||
CHECK(resolved_type == Preset::TYPE_INVALID);
|
||||
}
|
||||
|
||||
TEST_CASE("Typeless preset resolution rejects cross-type ambiguity", "[Preset][Bundle][Regression]")
|
||||
{
|
||||
ScopedTemporaryDir dir;
|
||||
const fs::path source_file = dir.path() / "ambiguous.json";
|
||||
std::ofstream(source_file.string()) << "{}";
|
||||
|
||||
PresetBundle bundle;
|
||||
add_inmemory_preset(bundle.prints, "Process Identity").file = source_file.string();
|
||||
add_inmemory_preset(bundle.filaments, "Filament Identity").file = source_file.string();
|
||||
|
||||
DynamicPrintConfig raw;
|
||||
Preset::Type resolved_type = Preset::TYPE_INVALID;
|
||||
std::string error;
|
||||
CHECK_FALSE(bundle.resolve_preset_config_type(raw, resolved_type, source_file.string(),
|
||||
ForwardCompatibilitySubstitutionRule::EnableSilent, error, false));
|
||||
CHECK(error == "Preset type is ambiguous");
|
||||
CHECK(resolved_type == Preset::TYPE_INVALID);
|
||||
}
|
||||
|
||||
TEST_CASE("Typeless preset resolution rejects a missing type candidate", "[Preset][Bundle][Regression]")
|
||||
{
|
||||
ScopedTemporaryDir dir;
|
||||
const fs::path source_file = dir.path() / "unknown.json";
|
||||
std::ofstream(source_file.string()) << "{}";
|
||||
|
||||
PresetBundle bundle;
|
||||
DynamicPrintConfig raw;
|
||||
Preset::Type resolved_type = Preset::TYPE_INVALID;
|
||||
std::string error;
|
||||
CHECK_FALSE(bundle.resolve_preset_config_type(raw, resolved_type, source_file.string(),
|
||||
ForwardCompatibilitySubstitutionRule::EnableSilent, error, false));
|
||||
CHECK(error == "Preset type could not be resolved");
|
||||
CHECK(resolved_type == Preset::TYPE_INVALID);
|
||||
}
|
||||
|
||||
TEST_CASE("Exact file resolution rejects multiple preset identities", "[Preset][Bundle][Regression]")
|
||||
{
|
||||
ScopedTemporaryDir dir;
|
||||
const fs::path source_file = dir.path() / "duplicate.json";
|
||||
std::ofstream(source_file.string()) << "{}";
|
||||
|
||||
PresetBundle bundle;
|
||||
Preset &first = add_inmemory_preset(bundle.prints, "First Identity");
|
||||
first.file = source_file.string();
|
||||
Preset &second = add_inmemory_preset(bundle.prints, "Second Identity");
|
||||
second.file = source_file.string();
|
||||
|
||||
DynamicPrintConfig raw;
|
||||
raw.option<ConfigOptionString>(BBL_JSON_KEY_INHERITS, true)->value = "Parent";
|
||||
|
||||
std::string error;
|
||||
CHECK_FALSE(bundle.resolve_preset_config(raw, Preset::TYPE_PRINT, source_file.string(),
|
||||
ForwardCompatibilitySubstitutionRule::EnableSilent, error, false));
|
||||
CHECK(error == "Preset identity is ambiguous");
|
||||
}
|
||||
|
||||
TEST_CASE("System preset resolution returns the canonical vendor configuration", "[Preset][Bundle][Regression]")
|
||||
{
|
||||
ScopedTemporaryDir source_dir;
|
||||
PresetBundle bundle;
|
||||
|
||||
VendorProfile vendor("VendorB");
|
||||
vendor.name = "Vendor B";
|
||||
auto [vendor_it, inserted] = bundle.vendors.emplace(vendor.id, std::move(vendor));
|
||||
REQUIRE(inserted);
|
||||
|
||||
Preset &resolved = add_inmemory_preset(bundle.prints, "Vendor B Process", "fdm_process_common");
|
||||
resolved.is_system = true;
|
||||
resolved.vendor = &vendor_it->second;
|
||||
resolved.file = (source_dir.path() / "vendor-b-process.json").string();
|
||||
std::ofstream(resolved.file) << "{}";
|
||||
resolved.config.option<ConfigOptionFloats>("travel_speed", true)->values = {321.0};
|
||||
resolved.config.option<ConfigOptionInt>("wall_loops", true)->value = 2;
|
||||
|
||||
DynamicPrintConfig raw;
|
||||
raw.option<ConfigOptionString>(BBL_JSON_KEY_INHERITS, true)->value = "fdm_process_common";
|
||||
raw.option<ConfigOptionInt>("wall_loops", true)->value = 5;
|
||||
|
||||
std::string error;
|
||||
REQUIRE(bundle.resolve_preset_config(raw, Preset::TYPE_PRINT, resolved.file,
|
||||
ForwardCompatibilitySubstitutionRule::EnableSilent, error));
|
||||
CHECK(error.empty());
|
||||
REQUIRE(raw.option<ConfigOptionFloats>("travel_speed")->values.size() == 1);
|
||||
CHECK_THAT(raw.option<ConfigOptionFloats>("travel_speed")->values.front(), Catch::Matchers::WithinAbs(321.0, 1e-6));
|
||||
CHECK(raw.option<ConfigOptionInt>("wall_loops")->value == 2);
|
||||
}
|
||||
|
||||
TEST_CASE("Manifest-backed preset resolution loads the source vendor tree", "[Preset][Bundle][Regression]")
|
||||
{
|
||||
ScopedTemporaryDir dir;
|
||||
const fs::path vendor_dir = dir.path() / "Acme";
|
||||
const fs::path child_file = vendor_dir / "process" / "nested" / "child.json";
|
||||
|
||||
std::ofstream((dir.path() / "Acme.json").string())
|
||||
<< R"({"version":"1.0.0","name":"Acme","process_list":[)"
|
||||
<< R"({"name":"fdm_process_common","sub_path":"process/base.json"},)"
|
||||
<< R"({"name":"Acme Process","sub_path":"process/nested/child.json"}]})";
|
||||
fs::create_directories(child_file.parent_path());
|
||||
std::ofstream((vendor_dir / "process" / "base.json").string())
|
||||
<< R"({"type":"process","name":"fdm_process_common","from":"system",)"
|
||||
<< R"("instantiation":"false","travel_speed":["321"]})";
|
||||
std::ofstream(child_file.string())
|
||||
<< R"({"type":"process","name":"Acme Process","from":"system",)"
|
||||
<< R"("instantiation":"true","inherits":"fdm_process_common","wall_loops":"5"})";
|
||||
|
||||
DynamicPrintConfig raw;
|
||||
raw.option<ConfigOptionString>(BBL_JSON_KEY_INHERITS, true)->value = "fdm_process_common";
|
||||
raw.option<ConfigOptionInt>("wall_loops", true)->value = 5;
|
||||
|
||||
PresetBundle bundle;
|
||||
std::string error;
|
||||
REQUIRE(bundle.resolve_preset_config(raw, Preset::TYPE_PRINT, child_file.string(),
|
||||
ForwardCompatibilitySubstitutionRule::EnableSilent, error));
|
||||
CHECK(error.empty());
|
||||
REQUIRE(raw.option<ConfigOptionFloats>("travel_speed")->values.size() == 1);
|
||||
CHECK_THAT(raw.option<ConfigOptionFloats>("travel_speed")->values.front(), Catch::Matchers::WithinAbs(321.0, 1e-6));
|
||||
CHECK(raw.option<ConfigOptionInt>("wall_loops")->value == 5);
|
||||
}
|
||||
|
||||
TEST_CASE("Manifest-backed resolution is scoped to the explicit source root", "[Preset][Bundle][Regression]")
|
||||
{
|
||||
ScopedTemporaryDir dir;
|
||||
auto write_vendor = [&](const std::string &root_name, double travel_speed) {
|
||||
const fs::path root = dir.path() / root_name;
|
||||
const fs::path child_file = root / "Acme" / "process" / "child.json";
|
||||
fs::create_directories(child_file.parent_path());
|
||||
std::ofstream((root / "Acme.json").string())
|
||||
<< R"({"version":"1.0.0","name":"Acme","process_list":[)"
|
||||
<< R"({"name":"fdm_process_common","sub_path":"process/base.json"},)"
|
||||
<< R"({"name":"Acme Process","sub_path":"process/child.json"}]})";
|
||||
std::ofstream((root / "Acme" / "process" / "base.json").string())
|
||||
<< R"({"type":"process","name":"fdm_process_common","from":"system",)"
|
||||
<< R"("instantiation":"false","travel_speed":[")" << travel_speed << R"("]})";
|
||||
std::ofstream(child_file.string())
|
||||
<< R"({"type":"process","name":"Acme Process","from":"system",)"
|
||||
<< R"("instantiation":"true","inherits":"fdm_process_common"})";
|
||||
return child_file;
|
||||
};
|
||||
|
||||
const fs::path source_a = write_vendor("root-a", 111.0);
|
||||
const fs::path source_b = write_vendor("root-b", 222.0);
|
||||
REQUIRE(fs::exists(source_a));
|
||||
|
||||
DynamicPrintConfig raw;
|
||||
raw.option<ConfigOptionString>(BBL_JSON_KEY_INHERITS, true)->value = "synthetic-parent-marker";
|
||||
|
||||
PresetBundle bundle;
|
||||
std::string error;
|
||||
REQUIRE(bundle.resolve_preset_config(raw, Preset::TYPE_PRINT, source_b.string(),
|
||||
ForwardCompatibilitySubstitutionRule::EnableSilent, error));
|
||||
REQUIRE(raw.option<ConfigOptionFloats>("travel_speed")->values.size() == 1);
|
||||
CHECK_THAT(raw.option<ConfigOptionFloats>("travel_speed")->values.front(), Catch::Matchers::WithinAbs(222.0, 1e-6));
|
||||
}
|
||||
|
||||
TEST_CASE("Exact-only resolution rejects an unconfigured manifest-backed file", "[Preset][Bundle][Regression]")
|
||||
{
|
||||
ScopedTemporaryDir dir;
|
||||
const fs::path source_file = dir.path() / "Acme" / "process" / "child.json";
|
||||
fs::create_directories(source_file.parent_path());
|
||||
std::ofstream((dir.path() / "Acme.json").string())
|
||||
<< R"({"version":"1.0.0","name":"Acme","process_list":[)"
|
||||
<< R"({"name":"Acme Process","sub_path":"process/child.json"}]})";
|
||||
std::ofstream(source_file.string())
|
||||
<< R"({"type":"process","name":"Acme Process","from":"system",)"
|
||||
<< R"("instantiation":"true","layer_height":"0.2"})";
|
||||
|
||||
DynamicPrintConfig raw;
|
||||
raw.option<ConfigOptionString>(BBL_JSON_KEY_INHERITS, true)->value = "Some Parent";
|
||||
|
||||
PresetBundle bundle;
|
||||
std::string error;
|
||||
CHECK_FALSE(bundle.resolve_preset_config(raw, Preset::TYPE_PRINT, source_file.string(),
|
||||
ForwardCompatibilitySubstitutionRule::EnableSilent, error, false));
|
||||
CHECK(error == "Preset was not found in the loaded bundle");
|
||||
}
|
||||
|
||||
TEST_CASE("Vendor filament resolution uses the shared Orca library base", "[Preset][Bundle][Regression]")
|
||||
{
|
||||
ScopedTemporaryDir dir;
|
||||
const fs::path library_dir = dir.path() / PresetBundle::ORCA_FILAMENT_LIBRARY;
|
||||
const fs::path vendor_dir = dir.path() / "Acme";
|
||||
const fs::path child_file = vendor_dir / "filament" / "nested" / "petg.json";
|
||||
|
||||
std::ofstream((dir.path() / (std::string(PresetBundle::ORCA_FILAMENT_LIBRARY) + ".json")).string())
|
||||
<< R"({"version":"1.0.0","name":"OrcaFilamentLibrary","filament_list":[)"
|
||||
<< R"({"name":"fdm_filament_pet","sub_path":"filament/pet.json","filament_id":"GFL99"}]})";
|
||||
fs::create_directories(library_dir / "filament");
|
||||
std::ofstream((library_dir / "filament" / "pet.json").string())
|
||||
<< R"({"type":"filament","name":"fdm_filament_pet","from":"system",)"
|
||||
<< R"("filament_id":"GFL99","instantiation":"false",)"
|
||||
<< R"("filament_type":["PETG"],"filament_density":["1.27"]})";
|
||||
|
||||
std::ofstream((dir.path() / "Acme.json").string())
|
||||
<< R"({"version":"1.0.0","name":"Acme","filament_list":[)"
|
||||
<< R"({"name":"Acme PETG","sub_path":"filament/nested/petg.json","filament_id":"GFA00"}]})";
|
||||
fs::create_directories(child_file.parent_path());
|
||||
std::ofstream(child_file.string())
|
||||
<< R"({"type":"filament","name":"Acme PETG","from":"system",)"
|
||||
<< R"("filament_id":"GFA00","instantiation":"true","inherits":"fdm_filament_pet"})";
|
||||
|
||||
DynamicPrintConfig raw;
|
||||
raw.option<ConfigOptionString>(BBL_JSON_KEY_INHERITS, true)->value = "fdm_filament_pet";
|
||||
|
||||
PresetBundle bundle;
|
||||
std::string error;
|
||||
REQUIRE(bundle.resolve_preset_config(raw, Preset::TYPE_FILAMENT, child_file.string(),
|
||||
ForwardCompatibilitySubstitutionRule::EnableSilent, error));
|
||||
CHECK(error.empty());
|
||||
CHECK(raw.opt_string("filament_type", 0u) == "PETG");
|
||||
REQUIRE(raw.option<ConfigOptionFloats>("filament_density")->values.size() == 1);
|
||||
CHECK_THAT(raw.option<ConfigOptionFloats>("filament_density")->values.front(), Catch::Matchers::WithinAbs(1.27, 1e-6));
|
||||
}
|
||||
|
||||
TEST_CASE("Manifest-backed resolution rejects a missing parent", "[Preset][Bundle][Regression]")
|
||||
{
|
||||
ScopedTemporaryDir dir;
|
||||
const fs::path child_file = dir.path() / "Acme" / "process" / "child.json";
|
||||
|
||||
std::ofstream((dir.path() / "Acme.json").string())
|
||||
<< R"({"version":"1.0.0","name":"Acme","process_list":[)"
|
||||
<< R"({"name":"Acme Process","sub_path":"process/child.json"}]})";
|
||||
fs::create_directories(child_file.parent_path());
|
||||
std::ofstream(child_file.string())
|
||||
<< R"({"type":"process","name":"Acme Process","from":"system",)"
|
||||
<< R"("instantiation":"true","inherits":"Missing Parent","layer_height":"0.2"})";
|
||||
|
||||
DynamicPrintConfig raw;
|
||||
raw.option<ConfigOptionString>(BBL_JSON_KEY_INHERITS, true)->value = "Missing Parent";
|
||||
|
||||
PresetBundle bundle;
|
||||
std::string error;
|
||||
CHECK_FALSE(bundle.resolve_preset_config(raw, Preset::TYPE_PRINT, child_file.string(),
|
||||
ForwardCompatibilitySubstitutionRule::EnableSilent, error));
|
||||
CHECK_FALSE(error.empty());
|
||||
}
|
||||
|
||||
TEST_CASE("Manifest-backed resolution rejects a vendor load with malformed entries", "[Preset][Bundle][Regression]")
|
||||
{
|
||||
ScopedTemporaryDir dir;
|
||||
const fs::path child_file = dir.path() / "Acme" / "process" / "child.json";
|
||||
|
||||
std::ofstream((dir.path() / "Acme.json").string())
|
||||
<< R"({"version":"1.0.0","name":"Acme","process_list":[123,)"
|
||||
<< R"({"name":"Acme Process","sub_path":"process/child.json"}]})";
|
||||
fs::create_directories(child_file.parent_path());
|
||||
std::ofstream(child_file.string())
|
||||
<< R"({"type":"process","name":"Acme Process","from":"system",)"
|
||||
<< R"("instantiation":"true","layer_height":"0.2"})";
|
||||
|
||||
DynamicPrintConfig raw;
|
||||
raw.option<ConfigOptionString>(BBL_JSON_KEY_INHERITS, true)->value = "fdm_process_common";
|
||||
|
||||
PresetBundle bundle;
|
||||
std::string error;
|
||||
CHECK_FALSE(bundle.resolve_preset_config(raw, Preset::TYPE_PRINT, child_file.string(),
|
||||
ForwardCompatibilitySubstitutionRule::EnableSilent, error));
|
||||
CHECK_FALSE(error.empty());
|
||||
}
|
||||
|
||||
TEST_CASE("Manifest-backed resolution rejects files absent from the vendor manifest", "[Preset][Bundle][Regression]")
|
||||
{
|
||||
ScopedTemporaryDir dir;
|
||||
const fs::path listed_file = dir.path() / "Acme" / "process" / "listed.json";
|
||||
const fs::path unlisted_file = dir.path() / "Acme" / "process" / "unlisted.json";
|
||||
|
||||
std::ofstream((dir.path() / "Acme.json").string())
|
||||
<< R"({"version":"1.0.0","name":"Acme","process_list":[)"
|
||||
<< R"({"name":"Listed Process","sub_path":"process/listed.json"}]})";
|
||||
fs::create_directories(listed_file.parent_path());
|
||||
std::ofstream(listed_file.string())
|
||||
<< R"({"type":"process","name":"Listed Process","from":"system",)"
|
||||
<< R"("instantiation":"true","layer_height":"0.2"})";
|
||||
std::ofstream(unlisted_file.string())
|
||||
<< R"({"type":"process","name":"Unlisted Process","from":"system",)"
|
||||
<< R"("instantiation":"true","inherits":"fdm_process_common"})";
|
||||
|
||||
DynamicPrintConfig raw;
|
||||
raw.option<ConfigOptionString>(BBL_JSON_KEY_INHERITS, true)->value = "fdm_process_common";
|
||||
|
||||
PresetBundle bundle;
|
||||
std::string error;
|
||||
CHECK_FALSE(bundle.resolve_preset_config(raw, Preset::TYPE_PRINT, unlisted_file.string(),
|
||||
ForwardCompatibilitySubstitutionRule::EnableSilent, error));
|
||||
CHECK(error == "Source file is not an instantiated preset in its vendor manifest");
|
||||
}
|
||||
|
||||
TEST_CASE("Manifest-backed resolution rejects a mismatched preset type", "[Preset][Bundle][Regression]")
|
||||
{
|
||||
ScopedTemporaryDir dir;
|
||||
const fs::path process_file = dir.path() / "Acme" / "process" / "child.json";
|
||||
|
||||
std::ofstream((dir.path() / "Acme.json").string())
|
||||
<< R"({"version":"1.0.0","name":"Acme","process_list":[)"
|
||||
<< R"({"name":"Acme Process","sub_path":"process/child.json"}]})";
|
||||
fs::create_directories(process_file.parent_path());
|
||||
std::ofstream(process_file.string())
|
||||
<< R"({"type":"process","name":"Acme Process","from":"system",)"
|
||||
<< R"("instantiation":"true","layer_height":"0.2"})";
|
||||
|
||||
DynamicPrintConfig raw;
|
||||
raw.option<ConfigOptionString>(BBL_JSON_KEY_INHERITS, true)->value = "fdm_filament_common";
|
||||
|
||||
PresetBundle bundle;
|
||||
std::string error;
|
||||
CHECK_FALSE(bundle.resolve_preset_config(raw, Preset::TYPE_FILAMENT, process_file.string(),
|
||||
ForwardCompatibilitySubstitutionRule::EnableSilent, error));
|
||||
CHECK(error == "Source file is not an instantiated preset in its vendor manifest");
|
||||
}
|
||||
|
||||
TEST_CASE("Resolution terminates when no vendor manifest exists", "[Preset][Bundle][Regression]")
|
||||
{
|
||||
ScopedTemporaryDir dir;
|
||||
const fs::path detached_file = dir.path() / "detached.json";
|
||||
std::ofstream(detached_file.string()) << "{}";
|
||||
|
||||
DynamicPrintConfig raw;
|
||||
raw.option<ConfigOptionString>(BBL_JSON_KEY_INHERITS, true)->value = "Missing Parent";
|
||||
|
||||
PresetBundle bundle;
|
||||
std::string error;
|
||||
CHECK_FALSE(bundle.resolve_preset_config(raw, Preset::TYPE_PRINT, detached_file.string(),
|
||||
ForwardCompatibilitySubstitutionRule::EnableSilent, error));
|
||||
CHECK(error == "Preset was not found in the loaded bundle");
|
||||
}
|
||||
|
||||
// Orca: a filament in the Orca Filament Library that names its compatible printers has to hide the generic
|
||||
// library filament sharing its alias, the same way a vendor owned filament does. Otherwise both are compatible
|
||||
// with that printer and the plater combo box lists the shared alias twice.
|
||||
@@ -640,6 +1036,88 @@ TEST_CASE("A printer specific filament supersedes the generic library filament w
|
||||
CHECK(is_compatible_with_printer(generic_lib, PresetWithVendorProfile(*printer_c, nullptr)));
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
// One system printer plus the filament presets a machine facing dialog has to choose between:
|
||||
// an Orca Filament Library generic with no compatible_printers, a same alias vendor filament
|
||||
// that names the printer, a library filament with no vendor twin, and a vendor filament that
|
||||
// belongs to a different printer.
|
||||
struct MachineFilaments
|
||||
{
|
||||
PresetBundle bundle;
|
||||
VendorProfile library{PresetBundle::ORCA_FILAMENT_LIBRARY};
|
||||
VendorProfile vendor{"Vendor"};
|
||||
|
||||
MachineFilaments()
|
||||
{
|
||||
// VendorProfile's constructor takes an id; the library rule keys off the name.
|
||||
library.name = PresetBundle::ORCA_FILAMENT_LIBRARY;
|
||||
vendor.name = "Vendor";
|
||||
|
||||
Preset &printer = add_inmemory_preset(bundle.printers, "Printer A 0.4 nozzle");
|
||||
printer.is_system = true;
|
||||
printer.vendor = &vendor;
|
||||
printer.config.option<ConfigOptionString>("printer_model", true)->value = "Printer A";
|
||||
|
||||
add_filament(library, "Generic ABS @System", "Generic ABS", {});
|
||||
add_filament(vendor, "Generic ABS @Printer A", "Generic ABS", { "Printer A 0.4 nozzle" });
|
||||
add_filament(library, "FilAr ABS @System", "FilAr ABS", {});
|
||||
add_filament(vendor, "Vendor PLA @Printer B", "Vendor PLA", { "Printer B 0.4 nozzle" });
|
||||
|
||||
// update_library_profile_excluded_from() is protected and has its own test above; record
|
||||
// the exclusion it derives from the same alias vendor filament.
|
||||
Preset *shadowed = bundle.filaments.find_preset("Generic ABS @System");
|
||||
REQUIRE(shadowed != nullptr);
|
||||
shadowed->m_excluded_from.insert("Printer A 0.4 nozzle");
|
||||
}
|
||||
|
||||
void add_filament(const VendorProfile &owner, const std::string &name, const std::string &alias,
|
||||
std::vector<std::string> compatible_printers)
|
||||
{
|
||||
Preset &preset = add_inmemory_preset(bundle.filaments, name);
|
||||
preset.is_system = true;
|
||||
preset.alias = alias;
|
||||
preset.vendor = &owner;
|
||||
compatible_list(bundle.filaments, name, "compatible_printers") = std::move(compatible_printers);
|
||||
}
|
||||
|
||||
bool offers(const std::string &preset_name, bool include_user_presets = false)
|
||||
{
|
||||
const std::vector<Preset *> offered =
|
||||
bundle.get_filament_presets_for_machine("Printer A", "0.4", include_user_presets);
|
||||
return std::any_of(offered.begin(), offered.end(),
|
||||
[&preset_name](const Preset *p) { return p->name == preset_name; });
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
TEST_CASE("Filaments offered for a machine follow the app's compatibility rule", "[Preset][Bundle]")
|
||||
{
|
||||
MachineFilaments f;
|
||||
|
||||
SECTION("a library filament with no compatible_printers is offered") {
|
||||
CHECK(f.offers("FilAr ABS @System"));
|
||||
}
|
||||
|
||||
SECTION("a same alias vendor filament shadows the library generic") {
|
||||
CHECK(f.offers("Generic ABS @Printer A"));
|
||||
CHECK_FALSE(f.offers("Generic ABS @System"));
|
||||
}
|
||||
|
||||
SECTION("a filament naming a different printer is not offered") {
|
||||
CHECK_FALSE(f.offers("Vendor PLA @Printer B"));
|
||||
}
|
||||
|
||||
SECTION("a user filament is offered only when the printer supports user presets") {
|
||||
add_inmemory_preset(f.bundle.filaments, "My PLA");
|
||||
|
||||
CHECK_FALSE(f.offers("My PLA", /*include_user_presets=*/false));
|
||||
CHECK(f.offers("My PLA", /*include_user_presets=*/true));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
namespace {
|
||||
|
||||
const char *kMixedKeys[] = {
|
||||
|
||||
@@ -5,10 +5,10 @@
|
||||
using namespace Slic3r;
|
||||
|
||||
// Golden vectors from the Python reference generate_preset_setting_id (defined in
|
||||
// scripts/assign_vendor_setting_ids.py). The C++ generate_preset_setting_id() MUST stay
|
||||
// byte-identical to it, otherwise app-side on-the-fly ids would diverge from the
|
||||
// scripts/orca_id_tool.py). The C++ generate_preset_setting_id() MUST stay byte-identical
|
||||
// to it, otherwise app-side on-the-fly ids would diverge from the
|
||||
// script-assigned ones in the profiles. Regenerate a vector with:
|
||||
// python3 -c "from assign_vendor_setting_ids import generate_preset_setting_id as g; print(g('Afinia','filament','Afinia ABS @Afinia H400'))"
|
||||
// python3 -c "import sys; sys.path.insert(0, 'scripts'); from orca_id_tool import generate_preset_setting_id as g; print(g('Afinia','filament','Afinia ABS @Afinia H400'))"
|
||||
TEST_CASE("preset setting_id matches the Python reference", "[Preset][setting_id]") {
|
||||
struct Vec { const char* vendor; const char* type; const char* name; const char* expected; };
|
||||
const Vec vectors[] = {
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
get_filename_component(_TEST_NAME ${CMAKE_CURRENT_LIST_DIR} NAME)
|
||||
add_executable(${_TEST_NAME}_tests
|
||||
${_TEST_NAME}_tests_main.cpp
|
||||
test_bambu_filament_ids.cpp
|
||||
test_creality_cfs_match.cpp
|
||||
test_dev_mapping.cpp
|
||||
test_filament_bitmap_utils.cpp
|
||||
test_network_versions.cpp
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
#include <catch2/catch_all.hpp>
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <boost/nowide/fstream.hpp>
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
#include "libslic3r/Utils.hpp"
|
||||
#include "slic3r/Utils/BBLPrinterAgent.hpp"
|
||||
#include "slic3r/Utils/OrcaPrinterAgent.hpp"
|
||||
|
||||
using json = nlohmann::json;
|
||||
using namespace Slic3r;
|
||||
|
||||
namespace {
|
||||
|
||||
// Point resources_dir() at the repo's own tree for the lifetime of a test and restore it
|
||||
// afterwards, mirroring ScopedResourcesDir (which only ever makes a throwaway directory).
|
||||
// PROFILES_DIR is <repo>/resources/profiles; the map lives in <repo>/resources/printers.
|
||||
struct ScopedRepoResourcesDir
|
||||
{
|
||||
std::string previous{resources_dir()};
|
||||
|
||||
ScopedRepoResourcesDir() { set_resources_dir(boost::filesystem::path(PROFILES_DIR).parent_path().string()); }
|
||||
~ScopedRepoResourcesDir() { set_resources_dir(previous); }
|
||||
|
||||
ScopedRepoResourcesDir(const ScopedRepoResourcesDir&) = delete;
|
||||
ScopedRepoResourcesDir& operator=(const ScopedRepoResourcesDir&) = delete;
|
||||
};
|
||||
|
||||
std::string orca_id_of(const std::string& bambu_id)
|
||||
{
|
||||
boost::nowide::ifstream file(resources_dir() + "/printers/bambu_filament_ids.json");
|
||||
json doc;
|
||||
file >> doc;
|
||||
for (const auto& [orca_id, row] : doc["filaments"].items())
|
||||
if (row["bambu_id"] == bambu_id)
|
||||
return orca_id;
|
||||
FAIL("no map row for " << bambu_id);
|
||||
return {};
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
TEST_CASE("Bambu filament id map is one-to-one and leaves unmapped ids alone", "[BambuFilamentIds]")
|
||||
{
|
||||
const ScopedRepoResourcesDir repo_resources;
|
||||
const BBLPrinterAgent bbl;
|
||||
const std::string abs = orca_id_of("GFB00"); // Bambu ABS
|
||||
REQUIRE(abs.rfind("OF", 0) == 0);
|
||||
CHECK(bbl.from_orca_filament_id(abs) == "GFB00");
|
||||
CHECK(bbl.to_orca_filament_id("GFB00") == abs);
|
||||
CHECK(bbl.from_orca_filament_id("OFnotarow") == "OFnotarow");
|
||||
CHECK(bbl.to_orca_filament_id("GFZZ99") == "GFZZ99"); // Bambu id we do not ship
|
||||
CHECK(bbl.to_orca_filament_id("P1234567") == "P1234567"); // user root
|
||||
CHECK(bbl.from_orca_filament_id("") == "");
|
||||
|
||||
// An agent whose printers already speak our ids inherits IPrinterAgent's identity default.
|
||||
const OrcaPrinterAgent other{""};
|
||||
CHECK(other.from_orca_filament_id(abs) == abs);
|
||||
CHECK(other.to_orca_filament_id("GFB00") == "GFB00");
|
||||
}
|
||||
|
||||
TEST_CASE("Payload rewrite covers nested trays, calibration lists and mapping info", "[BambuFilamentIds]")
|
||||
{
|
||||
const ScopedRepoResourcesDir repo_resources;
|
||||
const std::string abs = orca_id_of("GFB00"), pla = orca_id_of("GFA00");
|
||||
const std::string status =
|
||||
R"({"print":{"ams":{"ams":[{"tray":[{"tray_info_idx":"GFB00"},{"tray_info_idx":"GFZZ99"}]}]},)"
|
||||
R"("vt_tray":{"tray_info_idx":"GFA00"},"filaments":[{"filament_id":"GFA00","setting_id":"GFB00"}]}})";
|
||||
json inbound = json::parse(BBLPrinterAgent::to_orca_payload(status));
|
||||
CHECK(inbound["print"]["ams"]["ams"][0]["tray"][0]["tray_info_idx"] == abs);
|
||||
CHECK(inbound["print"]["ams"]["ams"][0]["tray"][1]["tray_info_idx"] == "GFZZ99"); // no row: untouched
|
||||
CHECK(inbound["print"]["vt_tray"]["tray_info_idx"] == pla);
|
||||
CHECK(inbound["print"]["filaments"][0]["filament_id"] == pla);
|
||||
CHECK(inbound["print"]["filaments"][0]["setting_id"] == "GFB00"); // not an id key: has a map row but must stay put
|
||||
CHECK(json::parse(BBLPrinterAgent::from_orca_payload(inbound.dump())) == json::parse(status)); // round trip
|
||||
|
||||
const std::string mapping = R"([{"ams":0,"filamentId":")" + abs + R"(","filamentType":"ABS"}])";
|
||||
CHECK(BBLPrinterAgent::from_orca_payload(mapping) == R"([{"ams":0,"filamentId":"GFB00","filamentType":"ABS"}])");
|
||||
CHECK(BBLPrinterAgent::from_orca_payload("not json") == "not json");
|
||||
CHECK(BBLPrinterAgent::from_orca_payload(R"({"print":{"command":"pushall"}})") == R"({"print":{"command":"pushall"}})");
|
||||
}
|
||||
@@ -0,0 +1,141 @@
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
|
||||
#include "libslic3r/Preset.hpp"
|
||||
#include "libslic3r/PresetBundle.hpp"
|
||||
#include "libslic3r/PrintConfig.hpp"
|
||||
#include "slic3r/Utils/CrealityPrintAgent.hpp"
|
||||
|
||||
using namespace Slic3r;
|
||||
|
||||
namespace {
|
||||
|
||||
// A standalone filament collection, built the same way PresetBundle builds its own, so the
|
||||
// CFS matcher can be exercised without loading the shipped profiles or touching a printer.
|
||||
struct FilamentTestCollection : public PresetCollection
|
||||
{
|
||||
FilamentTestCollection()
|
||||
: PresetCollection(Preset::TYPE_FILAMENT, Preset::filament_options(),
|
||||
static_cast<const PrintRegionConfig &>(FullPrintConfig::defaults()))
|
||||
{}
|
||||
};
|
||||
|
||||
struct FilamentSpec
|
||||
{
|
||||
const char *name;
|
||||
const char *filament_id;
|
||||
const char *filament_type;
|
||||
bool is_library = false; // belongs to the Orca Filament Library, not the printer vendor
|
||||
bool is_system = true;
|
||||
};
|
||||
|
||||
// Load the specs into the collection, then stamp the fields the matcher reads. Done in a second
|
||||
// pass because load_preset() keeps m_presets sorted, so a reference taken during the first pass
|
||||
// can be left dangling by a later load.
|
||||
void populate(PresetCollection &filaments, const std::vector<FilamentSpec> &specs,
|
||||
const VendorProfile &vendor, const VendorProfile &library)
|
||||
{
|
||||
for (const FilamentSpec &spec : specs) {
|
||||
DynamicPrintConfig config(filaments.default_preset().config);
|
||||
config.option<ConfigOptionStrings>("filament_type", true)->values = {spec.filament_type};
|
||||
filaments.load_preset(std::string(), spec.name, config, /*select=*/false);
|
||||
}
|
||||
for (auto it = filaments.begin(); it != filaments.end(); ++it) {
|
||||
const auto spec = std::find_if(specs.begin(), specs.end(),
|
||||
[&](const FilamentSpec &s) { return it->name == s.name; });
|
||||
if (spec == specs.end())
|
||||
continue;
|
||||
it->filament_id = spec->filament_id;
|
||||
it->vendor = spec->is_library ? &library : &vendor;
|
||||
it->is_system = spec->is_system;
|
||||
it->is_default = false;
|
||||
it->is_visible = true;
|
||||
it->is_compatible = true;
|
||||
}
|
||||
}
|
||||
|
||||
// What a stock K2 with a 0.4 nozzle sees after the filament_id rework: the vendor's plain generics
|
||||
// carry no "Creality" in their name (they are "Generic <material> @<scope>"), while the subtype
|
||||
// variants that do keep a vendor scope are separate products with their own filament_ids.
|
||||
const std::vector<FilamentSpec> k2_stock_nozzle{
|
||||
{"AliZ PLA @System", "ALIZ-PLA", "PLA", /*is_library=*/true},
|
||||
{"Generic PETG @K2-all", "PETG-GENERIC", "PETG"},
|
||||
{"Generic PLA @K2-all", "PLA-GENERIC", "PLA"},
|
||||
{"Generic PLA High Speed @Creality K2-all","PLA-HS", "PLA"},
|
||||
{"Generic PLA Matte @Creality K2-all", "PLA-MATTE", "PLA"},
|
||||
{"Generic PLA Silk @Creality K2-all", "PLA-SILK", "PLA"},
|
||||
{"Hyper PLA @K2-all", "PLA-HYPER", "PLA"},
|
||||
};
|
||||
|
||||
std::string match(const std::vector<FilamentSpec> &specs, const std::string &spool_vendor,
|
||||
const std::string &spool_name, const std::string &base_type)
|
||||
{
|
||||
FilamentTestCollection filaments;
|
||||
VendorProfile vendor("Creality");
|
||||
VendorProfile library(PresetBundle::ORCA_FILAMENT_LIBRARY);
|
||||
vendor.name = "Creality";
|
||||
library.name = PresetBundle::ORCA_FILAMENT_LIBRARY;
|
||||
populate(filaments, specs, vendor, library);
|
||||
return CrealityPrintAgent::match_filament_preset(filaments, spool_vendor, spool_name, base_type);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
// Orca: a CFS spool that names no recognised product must map to the vendor's plain generic. The
|
||||
// subtype variants ("High Speed", "Matte", "Silk") score just as well on vendor alone, and since
|
||||
// each is its own product with its own filament_id, letting one of them win sends the printer the
|
||||
// id of a filament the user does not have loaded.
|
||||
TEST_CASE("An unbranded CFS spool maps to the vendor's plain generic, not a subtype", "[CFS][Creality]")
|
||||
{
|
||||
CHECK(match(k2_stock_nozzle, "Creality", "", "PLA") == "PLA-GENERIC");
|
||||
}
|
||||
|
||||
// Orca: the vendor bonus reads the preset's owning VendorProfile. "Generic PETG @K2-all" does not
|
||||
// repeat "Creality" anywhere in its name, so a name based vendor test scored nothing for it and the
|
||||
// spool fell through to the collection wide first-of-type - an unrelated third party PETG.
|
||||
TEST_CASE("A CFS spool matches its vendor's presets even when the name omits the vendor", "[CFS][Creality]")
|
||||
{
|
||||
CHECK(match(k2_stock_nozzle, "Creality", "", "PETG") == "PETG-GENERIC");
|
||||
}
|
||||
|
||||
TEST_CASE("A branded CFS spool still beats the generic", "[CFS][Creality]")
|
||||
{
|
||||
CHECK(match(k2_stock_nozzle, "Creality", "Hyper PLA", "PLA") == "PLA-HYPER");
|
||||
}
|
||||
|
||||
// Orca: the specificity penalty must not stop a spool that genuinely asks for a subtype from
|
||||
// getting it - only unclaimed qualifiers are penalised.
|
||||
TEST_CASE("A CFS spool that names a subtype gets that subtype", "[CFS][Creality]")
|
||||
{
|
||||
CHECK(match(k2_stock_nozzle, "Creality", "Generic PLA Silk", "PLA") == "PLA-SILK");
|
||||
CHECK(match(k2_stock_nozzle, "Creality", "Generic PLA Matte", "PLA") == "PLA-MATTE");
|
||||
}
|
||||
|
||||
// Orca: a third party spool matches no preset by brand or vendor, so it falls back to the first
|
||||
// visible preset of the same type rather than returning nothing. Which one that is depends on the
|
||||
// collection's ordering, so only the type is pinned here - what matters is that a PLA spool never
|
||||
// comes back empty and never comes back as another material.
|
||||
TEST_CASE("A CFS spool from an unknown vendor falls back to a preset of the same type", "[CFS][Creality]")
|
||||
{
|
||||
const std::string matched = match(k2_stock_nozzle, "SomeOtherBrand", "", "PLA");
|
||||
REQUIRE_FALSE(matched.empty());
|
||||
const auto spec = std::find_if(k2_stock_nozzle.begin(), k2_stock_nozzle.end(),
|
||||
[&](const FilamentSpec &s) { return matched == s.filament_id; });
|
||||
REQUIRE(spec != k2_stock_nozzle.end());
|
||||
CHECK(std::string(spec->filament_type) == "PLA");
|
||||
}
|
||||
|
||||
|
||||
// Orca: Creality's bundle also ships third party filaments ("eSUN PLA+ @K2 Plus-all"). Those carry
|
||||
// Creality's VendorProfile but name their real brand, so the vendor bonus has to accept a name
|
||||
// match as well as a profile match - otherwise an eSUN spool stops matching its own preset.
|
||||
TEST_CASE("A third party spool matches its preset inside the printer vendor's bundle", "[CFS][Creality]")
|
||||
{
|
||||
const std::vector<FilamentSpec> with_third_party{
|
||||
{"Generic PLA @K2-all", "PLA-GENERIC", "PLA"},
|
||||
{"eSUN PLA+ @K2 Plus-all", "ESUN-PLA", "PLA"}, // shipped by Creality, branded eSUN
|
||||
};
|
||||
CHECK(match(with_third_party, "eSUN", "", "PLA") == "ESUN-PLA");
|
||||
// ... and a Creality spool still prefers Creality's own generic over the eSUN preset, which
|
||||
// carries Creality's profile too but adds a brand word the spool never claimed.
|
||||
CHECK(match(with_third_party, "Creality", "", "PLA") == "PLA-GENERIC");
|
||||
}
|
||||
Reference in New Issue
Block a user