Files
OrcaSlicer/tests/fff_print/test_printobject.cpp
raistlin7447 5fafbb59fc Revive the disabled fff_print test suite (#14196)
* Fix null-deref and arranger bugs that gate headless slicing tests

export_gcode dereferenced a null result out-param, enum serialization
dereferenced a null keys_map, and get_arrange_polys left bed_idx unseeded so
the arranger dropped items. All only affect the headless test/CLI path.

* Fix the headless test harness and add G-code test helpers

Use the real arranger, fix temp-file handling with an RAII guard, and add
layers_with_role / max_z for inspecting sliced G-code.

* Re-enable the Model construction test

* Re-enable SupportMaterial tests and add an enforced-support test

* Re-enable and extend PrintObject layer-height and perimeter tests

* Re-enable Print skirt, brim, and solid-surface tests

* Re-enable and extend PrintGCode tests

Un-hide the basic scenario (dead-key fixes, reframes, trimmed trivia) and add
initial-layer-height, sequential-order, and null-result export tests.

* Re-enable and reframe the skirt/brim tests

Detect skirt/brim by G-code role comment instead of a sentinel speed, and
resolve the previously-unfinished skirt-enclosure test.

* Replace the stale lift()/unlift() test with a z_hop test

* Delete the stub and broken Flow tests
2026-06-14 17:42:53 +08:00

109 lines
4.6 KiB
C++

#include <catch2/catch_all.hpp>
#include "libslic3r/libslic3r.h"
#include "libslic3r/Print.hpp"
#include "libslic3r/Layer.hpp"
#include "test_data.hpp"
using namespace Slic3r;
using namespace Slic3r::Test;
SCENARIO("PrintObject: object layer heights", "[PrintObject]") {
GIVEN("A 20mm cube") {
WHEN("sliced with a 2mm layer height and a 3mm nozzle") {
Slic3r::Print print;
Slic3r::Test::init_and_process_print({TestMesh::cube_20x20x20}, print, {
{ "initial_layer_print_height", 2 },
{ "layer_height", 2 },
{ "nozzle_diameter", 3 }
});
ConstLayerPtrsAdaptor layers = print.objects().front()->layers();
THEN("The output vector has 10 entries") {
REQUIRE(layers.size() == 10);
}
AND_THEN("Each layer is approximately 2mm above the previous Z") {
coordf_t last = 0.0;
for (size_t i = 0; i < layers.size(); ++ i) {
REQUIRE_THAT(layers[i]->print_z - last, Catch::Matchers::WithinAbs(2.0, 1e-4));
last = layers[i]->print_z;
}
}
}
WHEN("sliced with a 10mm layer height and an 11mm nozzle") {
Slic3r::Print print;
Slic3r::Test::init_and_process_print({TestMesh::cube_20x20x20}, print, {
{ "initial_layer_print_height", 2 },
{ "layer_height", 10 },
{ "nozzle_diameter", 11 }
});
ConstLayerPtrsAdaptor layers = print.objects().front()->layers();
THEN("The output vector has 3 entries") {
REQUIRE(layers.size() == 3);
}
AND_THEN("Layer 0 is at 2mm") {
REQUIRE_THAT(layers.front()->print_z, Catch::Matchers::WithinAbs(2.0, 1e-4));
}
AND_THEN("Layer 1 is at 12mm") {
REQUIRE_THAT(layers[1]->print_z, Catch::Matchers::WithinAbs(12.0, 1e-4));
}
}
WHEN("sliced with a 15mm layer height and a 16mm nozzle") {
Slic3r::Print print;
Slic3r::Test::init_and_process_print({TestMesh::cube_20x20x20}, print, {
{ "initial_layer_print_height", 2 },
{ "layer_height", 15 },
{ "nozzle_diameter", 16 }
});
ConstLayerPtrsAdaptor layers = print.objects().front()->layers();
THEN("The output vector has 2 entries") {
REQUIRE(layers.size() == 2);
}
AND_THEN("Layer 0 is at 2mm") {
REQUIRE_THAT(layers[0]->print_z, Catch::Matchers::WithinAbs(2.0, 1e-4));
}
AND_THEN("Layer 1 is at 17mm") {
REQUIRE_THAT(layers[1]->print_z, Catch::Matchers::WithinAbs(17.0, 1e-4));
}
}
WHEN("layer height exceeds the nozzle diameter") {
// Orca does not clamp an over-large layer height to the nozzle; it
// rejects the slice during flow computation. Pin that behavior.
THEN("Slicing is rejected") {
Slic3r::Print print;
REQUIRE_THROWS(Slic3r::Test::init_and_process_print({TestMesh::cube_20x20x20}, print, {
{ "initial_layer_print_height", 0.3 },
{ "layer_height", 0.5 },
{ "nozzle_diameter", 0.4 }
}));
}
}
}
}
SCENARIO("PrintObject: Perimeter generation", "[PrintObject]") {
GIVEN("20mm cube and default config") {
WHEN("make_perimeters() is called") {
Slic3r::Print print;
Slic3r::Test::init_and_process_print({TestMesh::cube_20x20x20}, print, { { "sparse_infill_density", 0 } });
const PrintObject &object = *print.objects().front();
THEN("Every layer in region 0 has 1 island of perimeters") {
for (const Layer *layer : object.layers())
REQUIRE(layer->regions().front()->perimeters.entities.size() == 1);
}
}
WHEN("wall_loops is set to 3") {
Slic3r::Print print;
Slic3r::Test::init_and_process_print({TestMesh::cube_20x20x20}, print, {
{ "sparse_infill_density", 0 },
{ "wall_loops", 3 }
});
const PrintObject &object = *print.objects().front();
THEN("Every layer in region 0 has 3 perimeter loops") {
for (const Layer *layer : object.layers())
REQUIRE(layer->regions().front()->perimeters.items_count() == 3);
}
}
}
}