Ported test_support_material from upstream Slic3r.
Reworked the FFF testing framework & ConfigBase::set_deserialize() for more compact tests: set_deserialize() now accepts list of key / value pairs. Fixed an incorrect assert in LayerRegion.
This commit is contained in:
parent
0ee78543a4
commit
c228a49fe0
13 changed files with 769 additions and 536 deletions
|
@ -10,31 +10,20 @@ using namespace Slic3r::Test;
|
|||
|
||||
SCENARIO("PrintObject: Perimeter generation", "[PrintObject]") {
|
||||
GIVEN("20mm cube and default config") {
|
||||
Slic3r::DynamicPrintConfig config = Slic3r::DynamicPrintConfig::full_print_config();
|
||||
TestMesh m = TestMesh::cube_20x20x20;
|
||||
Slic3r::Model model;
|
||||
size_t event_counter = 0;
|
||||
std::string stage;
|
||||
int value = 0;
|
||||
auto callback = [&event_counter, &stage, &value] (int a, const char* b) { stage = std::string(b); ++ event_counter; value = a; };
|
||||
config.set_deserialize("fill_density", "0");
|
||||
|
||||
WHEN("make_perimeters() is called") {
|
||||
std::shared_ptr<Slic3r::Print> print = Slic3r::Test::init_print({m}, model, config);
|
||||
print->process();
|
||||
const PrintObject& object = *(print->objects().at(0));
|
||||
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()) {
|
||||
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()) {
|
||||
for (const Layer *layer : object.layers())
|
||||
REQUIRE(layer->regions().front()->perimeters.items_count() == 3);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -42,66 +31,59 @@ SCENARIO("PrintObject: Perimeter generation", "[PrintObject]") {
|
|||
|
||||
SCENARIO("Print: Skirt generation", "[Print]") {
|
||||
GIVEN("20mm cube and default config") {
|
||||
Slic3r::DynamicPrintConfig config = Slic3r::DynamicPrintConfig::full_print_config();
|
||||
TestMesh m = TestMesh::cube_20x20x20;
|
||||
Slic3r::Model model;
|
||||
std::string stage;
|
||||
int value = 0;
|
||||
config.opt_int("skirt_height") = 1;
|
||||
config.opt_float("skirt_distance") = 1.f;
|
||||
WHEN("Skirts is set to 2 loops") {
|
||||
config.opt_int("skirts") = 2;
|
||||
std::shared_ptr<Slic3r::Print> print = Slic3r::Test::init_print({m}, model, config);
|
||||
print->process();
|
||||
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);
|
||||
REQUIRE(print.skirt().items_count() == 2);
|
||||
REQUIRE(print.skirt().flatten().entities.size() == 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void test_is_solid_infill(std::shared_ptr<Slic3r::Print> p, size_t obj_id, size_t layer_id ) {
|
||||
const PrintObject &obj = *(p->objects().at(obj_id));
|
||||
const Layer &layer = *(obj.get_layer((int)layer_id));
|
||||
|
||||
// iterate over all of the regions in the layer
|
||||
for (const LayerRegion *reg : layer.regions()) {
|
||||
// for each region, iterate over the fill surfaces
|
||||
for (const Surface& s : reg->fill_surfaces.surfaces) {
|
||||
CHECK(s.is_solid());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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();
|
||||
TestMesh m = TestMesh::cube_20x20x20;
|
||||
config.opt_int("top_solid_layers") = 2;
|
||||
config.opt_int("bottom_solid_layers") = 1;
|
||||
config.opt_float("layer_height") = 0.5; // get a known number of layers
|
||||
config.set_deserialize("first_layer_height", "0.5");
|
||||
config.set_deserialize({
|
||||
{ "top_solid_layers", "2" },
|
||||
{ "bottom_solid_layers", "1" },
|
||||
{ "layer_height", "0.5" }, // get a known number of layers
|
||||
{ "first_layer_height", "0.5" }
|
||||
});
|
||||
Slic3r::Print print;
|
||||
Slic3r::Model model;
|
||||
std::string stage;
|
||||
std::shared_ptr<Slic3r::Print> print = Slic3r::Test::init_print({m}, model, config);
|
||||
print->process();
|
||||
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).
|
||||
test_is_solid_infill(print, 0, 0); // should be solid
|
||||
test_is_solid_infill(print, 0, 39); // should be solid
|
||||
test_is_solid_infill(print, 0, 38); // should be solid
|
||||
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, 39); // should be solid
|
||||
test_is_solid_infill(0, 38); // should be solid
|
||||
WHEN("Model is re-sliced with top_solid_layers == 3") {
|
||||
config.opt_int("top_solid_layers") = 3;
|
||||
print->apply(model, config);
|
||||
print->process();
|
||||
print.apply(model, config);
|
||||
print.process();
|
||||
THEN("Print object does not have 0 solid bottom layers.") {
|
||||
test_is_solid_infill(print, 0, 0);
|
||||
test_is_solid_infill(0, 0);
|
||||
}
|
||||
AND_THEN("Print object has 3 top solid layers") {
|
||||
test_is_solid_infill(print, 0, 39);
|
||||
test_is_solid_infill(print, 0, 38);
|
||||
test_is_solid_infill(print, 0, 37);
|
||||
test_is_solid_infill(0, 39);
|
||||
test_is_solid_infill(0, 38);
|
||||
test_is_solid_infill(0, 37);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -109,35 +91,36 @@ SCENARIO("Print: Changing number of solid surfaces does not cause all surfaces t
|
|||
|
||||
SCENARIO("Print: Brim generation", "[Print]") {
|
||||
GIVEN("20mm cube and default config, 1mm first layer width") {
|
||||
Slic3r::DynamicPrintConfig config = Slic3r::DynamicPrintConfig::full_print_config();
|
||||
TestMesh m = TestMesh::cube_20x20x20;
|
||||
Slic3r::Model model;
|
||||
std::string stage;
|
||||
int value = 0;
|
||||
config.set_deserialize("first_layer_extrusion_width", "1");
|
||||
WHEN("Brim is set to 3mm") {
|
||||
config.opt_float("brim_width") = 3;
|
||||
std::shared_ptr<Slic3r::Print> print = Slic3r::Test::init_print({m}, model, config);
|
||||
print->process();
|
||||
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") {
|
||||
REQUIRE(print->brim().items_count() == 3);
|
||||
REQUIRE(print.brim().items_count() == 3);
|
||||
}
|
||||
}
|
||||
WHEN("Brim is set to 6mm") {
|
||||
config.opt_float("brim_width") = 6;
|
||||
std::shared_ptr<Slic3r::Print> print = Slic3r::Test::init_print({m}, model, config);
|
||||
print->process();
|
||||
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") {
|
||||
REQUIRE(print->brim().items_count() == 6);
|
||||
REQUIRE(print.brim().items_count() == 6);
|
||||
}
|
||||
}
|
||||
WHEN("Brim is set to 6mm, extrusion width 0.5mm") {
|
||||
config.opt_float("brim_width") = 6;
|
||||
config.set_deserialize("first_layer_extrusion_width", "0.5");
|
||||
std::shared_ptr<Slic3r::Print> print = Slic3r::Test::init_print({m}, model, config);
|
||||
print->process();
|
||||
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") {
|
||||
REQUIRE(print->brim().items_count() == 14);
|
||||
REQUIRE(print.brim().items_count() == 14);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue