Files
OrcaSlicer/tests/fff_print/test_model.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

61 lines
2.3 KiB
C++

#include <catch2/catch_all.hpp>
#include "libslic3r/libslic3r.h"
#include "libslic3r/Model.hpp"
#include "libslic3r/ModelArrange.hpp"
#include <boost/filesystem.hpp>
#include "test_data.hpp"
#include "test_utils.hpp"
using namespace Slic3r;
using namespace Slic3r::Test;
SCENARIO("Model construction", "[Model]") {
GIVEN("A Slic3r Model") {
Slic3r::Model model;
Slic3r::TriangleMesh sample_mesh = Slic3r::make_cube(20,20,20);
Slic3r::DynamicPrintConfig config = Slic3r::DynamicPrintConfig::full_print_config();
Slic3r::Print print;
WHEN("Model object is added") {
Slic3r::ModelObject *model_object = model.add_object();
THEN("Model object list == 1") {
REQUIRE(model.objects.size() == 1);
}
model_object->add_volume(sample_mesh);
THEN("Model volume list == 1") {
REQUIRE(model_object->volumes.size() == 1);
}
THEN("Model volume is a part") {
REQUIRE(model_object->volumes.front()->is_model_part());
}
THEN("Mesh is equivalent to input mesh.") {
REQUIRE(! sample_mesh.its.vertices.empty());
const std::vector<Vec3f>& mesh_vertices = model_object->volumes.front()->mesh().its.vertices;
Vec3f mesh_offset = model_object->volumes.front()->source.mesh_offset.cast<float>();
for (size_t i = 0; i < sample_mesh.its.vertices.size(); ++ i) {
const Vec3f &p1 = sample_mesh.its.vertices[i];
const Vec3f p2 = mesh_vertices[i] + mesh_offset;
REQUIRE((p2 - p1).norm() < EPSILON);
}
}
model_object->add_instance();
arrange_objects(model, InfiniteBed{scaled(Vec2d(100, 100))}, ArrangeParams{scaled(min_object_distance(config))});
model_object->ensure_on_bed();
print.auto_assign_extruders(model_object);
THEN("Print works?") {
print.set_status_silent();
print.apply(model, config);
print.process();
ScopedTemporaryFile temp(".gcode");
print.export_gcode(temp.string(), nullptr, nullptr);
REQUIRE(boost::filesystem::exists(temp.path()));
REQUIRE(boost::filesystem::is_regular_file(temp.path()));
REQUIRE(boost::filesystem::file_size(temp.path()) > 0);
}
}
}
}