2019-10-16 11:20:09 +00:00
|
|
|
#include <catch2/catch.hpp>
|
|
|
|
|
|
|
|
#include "libslic3r/libslic3r.h"
|
|
|
|
#include "libslic3r/Print.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") {
|
2019-10-17 15:09:15 +00:00
|
|
|
Slic3r::Print print;
|
2019-10-17 17:09:24 +00:00
|
|
|
Slic3r::Test::init_and_process_print({TestMesh::cube_20x20x20}, print, { { "fill_density", 0 } });
|
2019-10-17 15:09:15 +00:00
|
|
|
const PrintObject &object = *print.objects().front();
|
2019-10-16 11:20:09 +00:00
|
|
|
THEN("67 layers exist in the model") {
|
|
|
|
REQUIRE(object.layers().size() == 66);
|
|
|
|
}
|
|
|
|
THEN("Every layer in region 0 has 1 island of perimeters") {
|
2019-10-17 15:09:15 +00:00
|
|
|
for (const Layer *layer : object.layers())
|
2019-10-16 11:20:09 +00:00
|
|
|
REQUIRE(layer->regions().front()->perimeters.entities.size() == 1);
|
|
|
|
}
|
|
|
|
THEN("Every layer in region 0 has 3 paths in its perimeters list.") {
|
2019-10-17 15:09:15 +00:00
|
|
|
for (const Layer *layer : object.layers())
|
2019-10-16 11:20:09 +00:00
|
|
|
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") {
|
2019-10-17 15:09:15 +00:00
|
|
|
Slic3r::Print print;
|
|
|
|
Slic3r::Test::init_and_process_print({TestMesh::cube_20x20x20}, print, {
|
2019-10-17 17:09:24 +00:00
|
|
|
{ "skirt_height", 1 },
|
|
|
|
{ "skirt_distance", 1 },
|
|
|
|
{ "skirts", 2 }
|
2019-10-17 15:09:15 +00:00
|
|
|
});
|
2019-10-16 11:20:09 +00:00
|
|
|
THEN("Skirt Extrusion collection has 2 loops in it") {
|
2019-10-17 15:09:15 +00:00
|
|
|
REQUIRE(print.skirt().items_count() == 2);
|
|
|
|
REQUIRE(print.skirt().flatten().entities.size() == 2);
|
2019-10-16 11:20:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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();
|
2019-10-17 15:09:15 +00:00
|
|
|
config.set_deserialize({
|
2019-10-17 17:09:24 +00:00
|
|
|
{ "top_solid_layers", 2 },
|
|
|
|
{ "bottom_solid_layers", 1 },
|
|
|
|
{ "layer_height", 0.5 }, // get a known number of layers
|
|
|
|
{ "first_layer_height", 0.5 }
|
2019-10-17 15:09:15 +00:00
|
|
|
});
|
|
|
|
Slic3r::Print print;
|
2019-10-16 11:20:09 +00:00
|
|
|
Slic3r::Model model;
|
2019-10-17 15:09:15 +00:00
|
|
|
Slic3r::Test::init_print({TestMesh::cube_20x20x20}, print, model, config);
|
2019-10-16 11:20:09 +00:00
|
|
|
// Precondition: Ensure that the model has 2 solid top layers (39, 38)
|
|
|
|
// and one solid bottom layer (0).
|
2019-10-17 15:09:15 +00:00
|
|
|
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
|
2019-10-16 11:20:09 +00:00
|
|
|
WHEN("Model is re-sliced with top_solid_layers == 3") {
|
|
|
|
config.opt_int("top_solid_layers") = 3;
|
2019-10-17 15:09:15 +00:00
|
|
|
print.apply(model, config);
|
|
|
|
print.process();
|
2019-10-16 11:20:09 +00:00
|
|
|
THEN("Print object does not have 0 solid bottom layers.") {
|
2019-10-17 15:09:15 +00:00
|
|
|
test_is_solid_infill(0, 0);
|
2019-10-16 11:20:09 +00:00
|
|
|
}
|
|
|
|
AND_THEN("Print object has 3 top solid layers") {
|
2019-10-17 15:09:15 +00:00
|
|
|
test_is_solid_infill(0, 39);
|
|
|
|
test_is_solid_infill(0, 38);
|
|
|
|
test_is_solid_infill(0, 37);
|
2019-10-16 11:20:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
SCENARIO("Print: Brim generation", "[Print]") {
|
|
|
|
GIVEN("20mm cube and default config, 1mm first layer width") {
|
|
|
|
WHEN("Brim is set to 3mm") {
|
2019-10-17 15:09:15 +00:00
|
|
|
Slic3r::Print print;
|
|
|
|
Slic3r::Test::init_and_process_print({TestMesh::cube_20x20x20}, print, {
|
2019-10-17 17:09:24 +00:00
|
|
|
{ "first_layer_extrusion_width", 1 },
|
|
|
|
{ "brim_width", 3 }
|
2019-10-17 15:09:15 +00:00
|
|
|
});
|
2019-10-16 11:20:09 +00:00
|
|
|
THEN("Brim Extrusion collection has 3 loops in it") {
|
2019-10-17 15:09:15 +00:00
|
|
|
REQUIRE(print.brim().items_count() == 3);
|
2019-10-16 11:20:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
WHEN("Brim is set to 6mm") {
|
2019-10-17 15:09:15 +00:00
|
|
|
Slic3r::Print print;
|
|
|
|
Slic3r::Test::init_and_process_print({TestMesh::cube_20x20x20}, print, {
|
2019-10-17 17:09:24 +00:00
|
|
|
{ "first_layer_extrusion_width", 1 },
|
|
|
|
{ "brim_width", 6 }
|
2019-10-17 15:09:15 +00:00
|
|
|
});
|
2019-10-16 11:20:09 +00:00
|
|
|
THEN("Brim Extrusion collection has 6 loops in it") {
|
2019-10-17 15:09:15 +00:00
|
|
|
REQUIRE(print.brim().items_count() == 6);
|
2019-10-16 11:20:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
WHEN("Brim is set to 6mm, extrusion width 0.5mm") {
|
2019-10-17 15:09:15 +00:00
|
|
|
Slic3r::Print print;
|
|
|
|
Slic3r::Test::init_and_process_print({TestMesh::cube_20x20x20}, print, {
|
2019-10-17 17:09:24 +00:00
|
|
|
{ "first_layer_extrusion_width", 1 },
|
|
|
|
{ "brim_width", 6 },
|
|
|
|
{ "first_layer_extrusion_width", 0.5 }
|
2019-10-17 15:09:15 +00:00
|
|
|
});
|
|
|
|
print.process();
|
2019-10-16 11:20:09 +00:00
|
|
|
THEN("Brim Extrusion collection has 12 loops in it") {
|
2019-10-17 15:09:15 +00:00
|
|
|
REQUIRE(print.brim().items_count() == 14);
|
2019-10-16 11:20:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|