mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-10-04 14:20:58 +00:00
Covers src/slic3r/Utils, src/slic3r/plugin, src/slic3r/Config, src/libvgcode, src/dev-utils, src/OrcaSlicer.cpp and tests/, the directories left after src/slic3r/GUI and src/libslic3r. Generated with clang-tidy misc-include-cleaner. libvgcode's own headers are included by relative path as in the rest of that library, and Catch2 and pybind11 with angle brackets as elsewhere in the repo.
68 lines
2.5 KiB
C++
68 lines
2.5 KiB
C++
#include <boost/filesystem/operations.hpp>
|
|
#include <catch2/catch_all.hpp>
|
|
|
|
#include <catch2/catch_test_macros.hpp>
|
|
#include "libslic3r/libslic3r.h"
|
|
#include "libslic3r/Model.hpp"
|
|
#include "libslic3r/ModelArrange.hpp"
|
|
|
|
#include <boost/filesystem.hpp>
|
|
#include "libslic3r/TriangleMesh.hpp"
|
|
#include "libslic3r/PrintConfig.hpp"
|
|
#include <vector>
|
|
#include "libslic3r/Point.hpp"
|
|
#include <cstddef>
|
|
|
|
#include "test_helpers.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);
|
|
}
|
|
}
|
|
}
|
|
}
|