mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-12-25 00:58:35 -07:00
* Get libslic3r tests closer to passing
I can't get geometry tests to do anything useful. I've added extra
output, but it hasn't helped me figure out why they don't work
yet. That's also probably the last broken 3mf test doesn't work.
The config tests were mostly broken because of config name changes.
The placeholder_parser tests have some things that may-or-may-not
still apply to Orca.
* Vendor a 3.x version of Catch2
Everything is surely broken at this point.
* Allow building tests separately from Orca with build_linux.sh
* Remove unnecessary log message screwing up ctest
Same solution as Prusaslicer
* Make 2 TriangleMesh methods const
Since they can be.
* Move method comment to the header where it belongsc
* Add indirectly-included header directly
Transform3d IIRC
* libslic3r tests converted to Catch2 v3
Still has 3 failing tests, but builds and runs.
* Disable 2D convex hull test and comment what I've learned
Not sure the best way to solve this yet.
* Add diff compare method for DynamicConfig
Help the unit test report errors better.
* Perl no longer used, remove comment line
* Clang-format Config.?pp
So difficult to work with ATM
* Remove cpp17 unit tests
Who gives a shit
* Don't need explicit "example" test
We have lots of tests to serve as examples.
* Leave breadcrumb to enable sla_print tests
* Fix serialization of DynamicConfig
Add comments to test, because these code paths might not be even used
anymore.
* Update run_unit_tests to run all the tests
By the time I'm done with the PR all tests will either excluded by
default or passing, so just do all.
* Update how-to-test now that build_linux.sh builds tests separately
* Update cmake regenerate instructions
Read this online; hopefully works.
* Enable slic3rutils test with Catch2 v3
* Port libnest2d and fff_print to Catch2 v3
They build. Many failing.
* Add slightly more info to Objects not fit on bed exception
* Disable failing fff_print tests from running
They're mostly failing for "objects don't fit on bed" for an
infinite-sized bed. Given infinite bed is probably only used in tests,
it probably was incidentally broken long ago.
* Must checkout tests directory in GH Actions
So we get the test data
* Missed a failing fff_print test
* Disable (most/all) broken libnest2d tests
Trying all, not checking yet though
* Fix Polygon convex/concave detection tests
Document the implementation too. Reorganize the tests to be cleaner.
* Update the test script to run tests in parallel
* Get sla_print tests to build
Probably not passing
* Don't cause full project rebuild when updating test CMakeLists.txts
* Revert "Clang-format Config.?pp"
This reverts commit 771e4c0ad2.
---------
Co-authored-by: SoftFever <softfeverever@gmail.com>
140 lines
5.5 KiB
C++
140 lines
5.5 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: 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, { { "fill_density", 0 } });
|
|
const PrintObject &object = *print.objects().front();
|
|
THEN("67 layers exist in the model") {
|
|
REQUIRE(object.layers().size() == 66);
|
|
}
|
|
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);
|
|
}
|
|
THEN("Every layer in region 0 has 3 paths in its perimeters list.") {
|
|
for (const Layer *layer : object.layers())
|
|
REQUIRE(layer->regions().front()->perimeters.items_count() == 3);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
SCENARIO("Print: Skirt generation", "[Print][.]") {
|
|
GIVEN("20mm cube and default config") {
|
|
WHEN("Skirts is set to 2 loops") {
|
|
Slic3r::Print print;
|
|
Slic3r::Test::init_and_process_print({TestMesh::cube_20x20x20}, print, {
|
|
{ "skirt_height", 1 },
|
|
{ "skirt_distance", 1 },
|
|
{ "skirts", 2 }
|
|
});
|
|
THEN("Skirt Extrusion collection has 2 loops in it") {
|
|
REQUIRE(print.skirt().items_count() == 2);
|
|
REQUIRE(print.skirt().flatten().entities.size() == 2);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
SCENARIO("Print: Changing number of solid surfaces does not cause all surfaces to become internal.", "[Print][.]") {
|
|
GIVEN("sliced 20mm cube and config with top_solid_surfaces = 2 and bottom_solid_surfaces = 1") {
|
|
Slic3r::DynamicPrintConfig config = Slic3r::DynamicPrintConfig::full_print_config();
|
|
config.set_deserialize_strict({
|
|
{ "top_solid_layers", 2 },
|
|
{ "bottom_solid_layers", 1 },
|
|
{ "layer_height", 0.25 }, // get a known number of layers
|
|
{ "first_layer_height", 0.25 }
|
|
});
|
|
Slic3r::Print print;
|
|
Slic3r::Model model;
|
|
Slic3r::Test::init_print({TestMesh::cube_20x20x20}, print, model, config);
|
|
// Precondition: Ensure that the model has 2 solid top layers (39, 38)
|
|
// and one solid bottom layer (0).
|
|
auto test_is_solid_infill = [&print](size_t obj_id, size_t layer_id) {
|
|
const Layer &layer = *(print.objects().at(obj_id)->get_layer((int)layer_id));
|
|
// iterate over all of the regions in the layer
|
|
for (const LayerRegion *region : layer.regions()) {
|
|
// for each region, iterate over the fill surfaces
|
|
for (const Surface &surface : region->fill_surfaces.surfaces)
|
|
CHECK(surface.is_solid());
|
|
}
|
|
};
|
|
print.process();
|
|
test_is_solid_infill(0, 0); // should be solid
|
|
test_is_solid_infill(0, 79); // should be solid
|
|
test_is_solid_infill(0, 78); // should be solid
|
|
WHEN("Model is re-sliced with top_solid_layers == 3") {
|
|
config.set("top_solid_layers", 3);
|
|
print.apply(model, config);
|
|
print.process();
|
|
THEN("Print object does not have 0 solid bottom layers.") {
|
|
test_is_solid_infill(0, 0);
|
|
}
|
|
AND_THEN("Print object has 3 top solid layers") {
|
|
test_is_solid_infill(0, 79);
|
|
test_is_solid_infill(0, 78);
|
|
test_is_solid_infill(0, 77);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
SCENARIO("Print: Brim generation", "[Print][.]") {
|
|
GIVEN("20mm cube and default config, 1mm first layer width") {
|
|
WHEN("Brim is set to 3mm") {
|
|
Slic3r::Print print;
|
|
Slic3r::Test::init_and_process_print({TestMesh::cube_20x20x20}, print, {
|
|
{ "first_layer_extrusion_width", 1 },
|
|
{ "brim_width", 3 }
|
|
});
|
|
THEN("Brim Extrusion collection has 3 loops in it") {
|
|
size_t total_items = 0;
|
|
for (const auto& pair : print.get_brimMap()) {
|
|
total_items += pair.second.items_count();
|
|
}
|
|
REQUIRE(total_items == 3);
|
|
}
|
|
}
|
|
WHEN("Brim is set to 6mm") {
|
|
Slic3r::Print print;
|
|
Slic3r::Test::init_and_process_print({TestMesh::cube_20x20x20}, print, {
|
|
{ "first_layer_extrusion_width", 1 },
|
|
{ "brim_width", 6 }
|
|
});
|
|
THEN("Brim Extrusion collection has 6 loops in it") {
|
|
size_t total_items = 0;
|
|
for (const auto& pair : print.get_brimMap()) {
|
|
total_items += pair.second.items_count();
|
|
}
|
|
REQUIRE(total_items == 6);
|
|
}
|
|
}
|
|
WHEN("Brim is set to 6mm, extrusion width 0.5mm") {
|
|
Slic3r::Print print;
|
|
Slic3r::Test::init_and_process_print({TestMesh::cube_20x20x20}, print, {
|
|
{ "first_layer_extrusion_width", 1 },
|
|
{ "brim_width", 6 },
|
|
{ "first_layer_extrusion_width", 0.5 }
|
|
});
|
|
print.process();
|
|
THEN("Brim Extrusion collection has 12 loops in it") {
|
|
size_t total_items = 0;
|
|
for (const auto& pair : print.get_brimMap()) {
|
|
total_items += pair.second.items_count();
|
|
}
|
|
REQUIRE(total_items == 14);
|
|
}
|
|
}
|
|
}
|
|
}
|