mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-10-06 23:31:19 +00:00
151 using-directives, using-declarations, type aliases and namespace aliases in source and test files that nothing refers to: the name is never used, it duplicates a using already in scope, or the code sits inside the namespace it names. Each one was removed on its own and the file still compiled, both as it is and with every header-level using taken away, so none of them was only redundant because a header leaks the same name. With the using gone, 28 #include lines and one forward declaration had no other reference left in their file (boost/optional.hpp without any optional, property_tree headers without any ptree) and go with it. No header is touched.
69 lines
2.5 KiB
C++
69 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"
|
|
#include "libslic3r/Arrange.hpp"
|
|
#include "libslic3r/Print.hpp"
|
|
|
|
using namespace Slic3r;
|
|
|
|
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);
|
|
}
|
|
}
|
|
}
|
|
}
|