Ported test_support_material.cpp from upstream slic3r.

Ported extension of ExtrusionEntityCollection::flatten() to disable
flattening of no_sort() collections.
This commit is contained in:
bubnikv 2019-10-17 19:09:24 +02:00
parent f9710eff08
commit 98a71a557b
12 changed files with 250 additions and 143 deletions

View File

@ -1554,7 +1554,19 @@ public:
// Set a configuration value from a string, it will call an overridable handle_legacy()
// to resolve renamed and removed configuration keys.
bool set_deserialize(const t_config_option_key &opt_key, const std::string &str, bool append = false);
struct SetDeserializeItem { std::string opt_key; std::string opt_value; bool append = false; };
struct SetDeserializeItem {
SetDeserializeItem(const char *opt_key, const char *opt_value, bool append = false) : opt_key(opt_key), opt_value(opt_value), append(append) {}
SetDeserializeItem(const std::string &opt_key, const std::string &opt_value, bool append = false) : opt_key(opt_key), opt_value(opt_value), append(append) {}
SetDeserializeItem(const char *opt_key, const bool value, bool append = false) : opt_key(opt_key), opt_value(value ? "1" : "0"), append(append) {}
SetDeserializeItem(const std::string &opt_key, const bool value, bool append = false) : opt_key(opt_key), opt_value(value ? "1" : "0"), append(append) {}
SetDeserializeItem(const char *opt_key, const int value, bool append = false) : opt_key(opt_key), opt_value(std::to_string(value)), append(append) {}
SetDeserializeItem(const std::string &opt_key, const int value, bool append = false) : opt_key(opt_key), opt_value(std::to_string(value)), append(append) {}
SetDeserializeItem(const char *opt_key, const float value, bool append = false) : opt_key(opt_key), opt_value(std::to_string(value)), append(append) {}
SetDeserializeItem(const std::string &opt_key, const float value, bool append = false) : opt_key(opt_key), opt_value(std::to_string(value)), append(append) {}
SetDeserializeItem(const char *opt_key, const double value, bool append = false) : opt_key(opt_key), opt_value(std::to_string(value)), append(append) {}
SetDeserializeItem(const std::string &opt_key, const double value, bool append = false) : opt_key(opt_key), opt_value(std::to_string(value)), append(append) {}
std::string opt_key; std::string opt_value; bool append = false;
};
bool set_deserialize(std::initializer_list<SetDeserializeItem> items);
double get_abs_value(const t_config_option_key &opt_key) const;

View File

@ -126,18 +126,26 @@ size_t ExtrusionEntityCollection::items_count() const
}
// Returns a single vector of pointers to all non-collection items contained in this one.
ExtrusionEntityCollection ExtrusionEntityCollection::flatten() const
ExtrusionEntityCollection ExtrusionEntityCollection::flatten(bool preserve_ordering) const
{
struct Flatten {
Flatten(bool preserve_ordering) : preserve_ordering(preserve_ordering) {}
ExtrusionEntityCollection out;
bool preserve_ordering;
void recursive_do(const ExtrusionEntityCollection &collection) {
if (collection.no_sort && preserve_ordering) {
// Don't flatten whatever happens below this level.
out.append(collection);
} else {
for (const ExtrusionEntity *entity : collection.entities)
if (entity->is_collection())
this->recursive_do(*static_cast<const ExtrusionEntityCollection*>(entity));
else
out.append(*entity);
}
} flatten;
}
} flatten(preserve_ordering);
flatten.recursive_do(*this);
return flatten.out;
}

View File

@ -15,7 +15,7 @@ public:
ExtrusionEntitiesPtr entities; // we own these entities
bool no_sort;
ExtrusionEntityCollection(): no_sort(false) {};
ExtrusionEntityCollection(): no_sort(false) {}
ExtrusionEntityCollection(const ExtrusionEntityCollection &other) : no_sort(other.no_sort) { this->append(other.entities); }
ExtrusionEntityCollection(ExtrusionEntityCollection &&other) : entities(std::move(other.entities)), no_sort(other.no_sort) {}
explicit ExtrusionEntityCollection(const ExtrusionPaths &paths);
@ -25,7 +25,7 @@ public:
~ExtrusionEntityCollection() { clear(); }
explicit operator ExtrusionPaths() const;
bool is_collection() const { return true; };
bool is_collection() const { return true; }
ExtrusionRole role() const override {
ExtrusionRole out = erNone;
for (const ExtrusionEntity *ee : entities) {
@ -34,8 +34,8 @@ public:
}
return out;
}
bool can_reverse() const { return !this->no_sort; };
bool empty() const { return this->entities.empty(); };
bool can_reverse() const { return !this->no_sort; }
bool empty() const { return this->entities.empty(); }
void clear();
void swap (ExtrusionEntityCollection &c);
void append(const ExtrusionEntity &entity) { this->entities.emplace_back(entity.clone()); }
@ -81,7 +81,10 @@ public:
Polygons polygons_covered_by_spacing(const float scaled_epsilon = 0.f) const
{ Polygons out; this->polygons_covered_by_spacing(out, scaled_epsilon); return out; }
size_t items_count() const;
ExtrusionEntityCollection flatten() const;
/// Returns a flattened copy of this ExtrusionEntityCollection. That is, all of the items in its entities vector are not collections.
/// You should be iterating over flatten().entities if you are interested in the underlying ExtrusionEntities (and don't care about hierarchy).
/// \param preserve_ordering Flag to method that will flatten if and only if the underlying collection is sortable when True (default: False).
ExtrusionEntityCollection flatten(bool preserve_ordering = false) const;
double min_mm3_per_mm() const;
double total_volume() const override { double volume=0.; for (const auto& ent : entities) volume+=ent->total_volume(); return volume; }

View File

@ -3,6 +3,7 @@ add_executable(${_TEST_NAME}_tests
${_TEST_NAME}_tests.cpp
test_data.cpp
test_data.hpp
test_extrusion_entity.cpp
test_fill.cpp
test_flow.cpp
test_gcodewriter.cpp

View File

@ -0,0 +1,85 @@
#include <catch2/catch.hpp>
#include <cstdlib>
#include "libslic3r/ExtrusionEntityCollection.hpp"
#include "libslic3r/ExtrusionEntity.hpp"
#include "libslic3r/Point.hpp"
#include "libslic3r/libslic3r.h"
#include "test_data.hpp"
using namespace Slic3r;
static inline Slic3r::Point random_point(float LO=-50, float HI=50)
{
Vec2f pt = Vec2f(LO, LO) + (Vec2d(rand(), rand()) * (HI-LO) / RAND_MAX).cast<float>();
return pt.cast<coord_t>();
}
// build a sample extrusion entity collection with random start and end points.
static Slic3r::ExtrusionPath random_path(size_t length = 20, float LO = -50, float HI = 50)
{
ExtrusionPath t {erPerimeter, 1.0, 1.0, 1.0};
for (size_t j = 0; j < length; ++ j)
t.polyline.append(random_point(LO, HI));
return t;
}
static Slic3r::ExtrusionPaths random_paths(size_t count = 10, size_t length = 20, float LO = -50, float HI = 50)
{
Slic3r::ExtrusionPaths p;
for (size_t i = 0; i < count; ++ i)
p.push_back(random_path(length, LO, HI));
return p;
}
SCENARIO("ExtrusionEntityCollection: Polygon flattening", "[ExtrusionEntity]") {
srand(0xDEADBEEF); // consistent seed for test reproducibility.
// Generate one specific random path set and save it for later comparison
Slic3r::ExtrusionPaths nosort_path_set = random_paths();
Slic3r::ExtrusionEntityCollection sub_nosort;
sub_nosort.append(nosort_path_set);
sub_nosort.no_sort = true;
Slic3r::ExtrusionEntityCollection sub_sort;
sub_sort.no_sort = false;
sub_sort.append(random_paths());
GIVEN("A Extrusion Entity Collection with a child that has one child that is marked as no-sort") {
Slic3r::ExtrusionEntityCollection sample;
Slic3r::ExtrusionEntityCollection output;
sample.append(sub_sort);
sample.append(sub_nosort);
sample.append(sub_sort);
WHEN("The EEC is flattened with default options (preserve_order=false)") {
output = sample.flatten();
THEN("The output EEC contains no Extrusion Entity Collections") {
CHECK(std::count_if(output.entities.cbegin(), output.entities.cend(), [=](const ExtrusionEntity* e) {return e->is_collection();}) == 0);
}
}
WHEN("The EEC is flattened with preservation (preserve_order=true)") {
output = sample.flatten(true);
THEN("The output EECs contains one EEC.") {
CHECK(std::count_if(output.entities.cbegin(), output.entities.cend(), [=](const ExtrusionEntity* e) {return e->is_collection();}) == 1);
}
AND_THEN("The ordered EEC contains the same order of elements than the original") {
// find the entity in the collection
for (auto e : output.entities)
if (e->is_collection()) {
ExtrusionEntityCollection *temp = dynamic_cast<ExtrusionEntityCollection*>(e);
// check each Extrusion path against nosort_path_set to see if the first and last match the same
CHECK(nosort_path_set.size() == temp->entities.size());
for (size_t i = 0; i < nosort_path_set.size(); ++ i) {
CHECK(temp->entities[i]->first_point() == nosort_path_set[i].first_point());
CHECK(temp->entities[i]->last_point() == nosort_path_set[i].last_point());
}
}
}
}
}
}

View File

@ -20,9 +20,9 @@ SCENARIO("Extrusion width specifics", "[!mayfail]") {
// this is a sharedptr
DynamicPrintConfig config = Slic3r::DynamicPrintConfig::full_print_config();
config.set_deserialize({
{ "brim_width", "2" },
{ "skirts", "1" },
{ "perimeters", "3" },
{ "brim_width", 2 },
{ "skirts", 1 },
{ "perimeters", 3 },
{ "fill_density", "40%" },
{ "first_layer_height", "100%" }
});

View File

@ -40,7 +40,7 @@ SCENARIO("Model construction", "[Model]") {
REQUIRE((p2 - p1).norm() < EPSILON);
}
}
Slic3r::ModelInstance *model_instance = model_object->add_instance();
model_object->add_instance();
model.arrange_objects(PrintConfig::min_object_distance(&config));
model.center_instances_around_point(Slic3r::Vec2d(100, 100));
model_object->ensure_on_bed();

View File

@ -12,7 +12,7 @@ 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" } });
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);
@ -34,9 +34,9 @@ SCENARIO("Print: Skirt generation", "[Print]") {
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"}
{ "skirt_height", 1 },
{ "skirt_distance", 1 },
{ "skirts", 2 }
});
THEN("Skirt Extrusion collection has 2 loops in it") {
REQUIRE(print.skirt().items_count() == 2);
@ -50,10 +50,10 @@ SCENARIO("Print: Changing number of solid surfaces does not cause all surfaces t
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({
{ "top_solid_layers", "2" },
{ "bottom_solid_layers", "1" },
{ "layer_height", "0.5" }, // get a known number of layers
{ "first_layer_height", "0.5" }
{ "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;
@ -94,8 +94,8 @@ SCENARIO("Print: Brim generation", "[Print]") {
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" }
{ "first_layer_extrusion_width", 1 },
{ "brim_width", 3 }
});
THEN("Brim Extrusion collection has 3 loops in it") {
REQUIRE(print.brim().items_count() == 3);
@ -104,8 +104,8 @@ SCENARIO("Print: Brim generation", "[Print]") {
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" }
{ "first_layer_extrusion_width", 1 },
{ "brim_width", 6 }
});
THEN("Brim Extrusion collection has 6 loops in it") {
REQUIRE(print.brim().items_count() == 6);
@ -114,9 +114,9 @@ SCENARIO("Print: Brim generation", "[Print]") {
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" }
{ "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") {

View File

@ -21,10 +21,10 @@ SCENARIO( "PrintGCode basic functionality", "[PrintGCode]") {
Slic3r::Print print;
Slic3r::Model model;
Slic3r::Test::init_print({TestMesh::cube_20x20x20}, print, model, {
{ "layer_height", "0.2" },
{ "first_layer_height", "0.2" },
{ "first_layer_extrusion_width", "0" },
{ "gcode_comments", "1" },
{ "layer_height", 0.2 },
{ "first_layer_height", 0.2 },
{ "first_layer_extrusion_width", 0 },
{ "gcode_comments", true },
{ "start_gcode", "" }
});
std::string gcode = Slic3r::Test::gcode(print);
@ -86,13 +86,13 @@ SCENARIO( "PrintGCode basic functionality", "[PrintGCode]") {
Slic3r::Print print;
Slic3r::Model model;
Slic3r::Test::init_print({TestMesh::cube_20x20x20,TestMesh::cube_20x20x20}, print, model, {
{ "first_layer_extrusion_width", "0" },
{ "first_layer_height", "0.3" },
{ "layer_height", "0.2" },
{ "support_material", "0" },
{ "raft_layers", "0" },
{ "complete_objects", "1" },
{ "gcode_comments", "1" },
{ "first_layer_extrusion_width", 0 },
{ "first_layer_height", 0.3 },
{ "layer_height", 0.2 },
{ "support_material", false },
{ "raft_layers", 0 },
{ "complete_objects", true },
{ "gcode_comments", true },
{ "between_objects_gcode", "; between-object-gcode" }
});
std::string gcode = Slic3r::Test::gcode(print);
@ -154,10 +154,10 @@ SCENARIO( "PrintGCode basic functionality", "[PrintGCode]") {
}
WHEN("the output is executed with support material") {
std::string gcode = ::Test::slice({TestMesh::cube_20x20x20}, {
{ "first_layer_extrusion_width", "0" },
{ "support_material", "1" },
{ "raft_layers", "3" },
{ "gcode_comments", "1" }
{ "first_layer_extrusion_width", 0 },
{ "support_material", true },
{ "raft_layers", 3 },
{ "gcode_comments", true }
});
THEN("Some text output is generated.") {
REQUIRE(gcode.size() > 0);
@ -194,8 +194,8 @@ SCENARIO( "PrintGCode basic functionality", "[PrintGCode]") {
}
WHEN("Cooling is enabled and the fan is disabled.") {
std::string gcode = ::Test::slice({ TestMesh::cube_20x20x20 }, {
{ "cooling", "1" },
{ "disable_fan_first_layers", "5" }
{ "cooling", true },
{ "disable_fan_first_layers", 5 }
});
THEN("GCode to disable fan is emitted."){
REQUIRE(gcode.find("M107") != std::string::npos);
@ -204,8 +204,8 @@ SCENARIO( "PrintGCode basic functionality", "[PrintGCode]") {
WHEN("end_gcode exists with layer_num and layer_z") {
std::string gcode = ::Test::slice({ TestMesh::cube_20x20x20 }, {
{ "end_gcode", "; Layer_num [layer_num]\n; Layer_z [layer_z]" },
{ "layer_height", "0.1" },
{ "first_layer_height", "0.1" }
{ "layer_height", 0.1 },
{ "first_layer_height", 0.1 }
});
THEN("layer_num and layer_z are processed in the end gcode") {
REQUIRE(gcode.find("; Layer_num 199") != std::string::npos);
@ -226,11 +226,11 @@ SCENARIO( "PrintGCode basic functionality", "[PrintGCode]") {
config.set_num_extruders(4);
config.set_deserialize({
{ "start_gcode", "; Extruder [current_extruder]" },
{ "infill_extruder", "2" },
{ "solid_infill_extruder", "2" },
{ "perimeter_extruder", "2" },
{ "support_material_extruder", "2" },
{ "support_material_interface_extruder", "2" }
{ "infill_extruder", 2 },
{ "solid_infill_extruder", 2 },
{ "perimeter_extruder", 2 },
{ "support_material_extruder", 2 },
{ "support_material_interface_extruder", 2 }
});
std::string gcode = Slic3r::Test::slice({TestMesh::cube_20x20x20}, config);
THEN("current_extruder is processed in the start gcode and set for second extruder") {
@ -241,11 +241,11 @@ SCENARIO( "PrintGCode basic functionality", "[PrintGCode]") {
WHEN("layer_num represents the layer's index from z=0") {
std::string gcode = ::Test::slice({ TestMesh::cube_20x20x20, TestMesh::cube_20x20x20 }, {
{ "complete_objects", "1" },
{ "gcode_comments", "1" },
{ "complete_objects", true },
{ "gcode_comments", true },
{ "layer_gcode", ";Layer:[layer_num] ([layer_z] mm)" },
{ "layer_height", "1.0" },
{ "first_layer_height", "1.0" }
{ "layer_height", 1.0 },
{ "first_layer_height", 1.0 }
});
// End of the 1st object.
size_t pos = gcode.find(";Layer:19 ");

View File

@ -10,18 +10,13 @@ using namespace Slic3r::Test;
SCENARIO("PrintObject: object layer heights", "[PrintObject]") {
GIVEN("20mm cube and default initial config, initial layer height of 2mm") {
Slic3r::DynamicPrintConfig config = Slic3r::DynamicPrintConfig::full_print_config();
TestMesh m = TestMesh::cube_20x20x20;
Slic3r::Model model;
config.set_deserialize("first_layer_height", "2");
WHEN("generate_object_layers() is called for 2mm layer heights and nozzle diameter of 3mm") {
config.opt_float("nozzle_diameter", 0) = 3;
config.opt_float("layer_height") = 2.0;
Slic3r::Print print;
Slic3r::Test::init_print({m}, print, model, config);
print.process();
Slic3r::Test::init_and_process_print({TestMesh::cube_20x20x20}, print, {
{ "first_layer_height", 2 },
{ "layer_height", 2 },
{ "nozzle_diameter", 3 }
});
const std::vector<Slic3r::Layer*> &layers = print.objects().front()->layers();
THEN("The output vector has 10 entries") {
REQUIRE(layers.size() == 10);
@ -35,11 +30,12 @@ SCENARIO("PrintObject: object layer heights", "[PrintObject]") {
}
}
WHEN("generate_object_layers() is called for 10mm layer heights and nozzle diameter of 11mm") {
config.opt_float("nozzle_diameter", 0) = 11;
config.opt_float("layer_height") = 10;
Slic3r::Print print;
Slic3r::Test::init_print({m}, print, model, config);
print.process();
Slic3r::Test::init_and_process_print({TestMesh::cube_20x20x20}, print, {
{ "first_layer_height", 2 },
{ "layer_height", 10 },
{ "nozzle_diameter", 11 }
});
const std::vector<Slic3r::Layer*> &layers = print.objects().front()->layers();
THEN("The output vector has 3 entries") {
REQUIRE(layers.size() == 3);
@ -52,11 +48,12 @@ SCENARIO("PrintObject: object layer heights", "[PrintObject]") {
}
}
WHEN("generate_object_layers() is called for 15mm layer heights and nozzle diameter of 16mm") {
config.opt_float("nozzle_diameter", 0) = 16;
config.opt_float("layer_height") = 15.0;
Slic3r::Print print;
Slic3r::Test::init_print({m}, print, model, config);
print.process();
Slic3r::Test::init_and_process_print({TestMesh::cube_20x20x20}, print, {
{ "first_layer_height", 2 },
{ "layer_height", 15 },
{ "nozzle_diameter", 16 }
});
const std::vector<Slic3r::Layer*> &layers = print.objects().front()->layers();
THEN("The output vector has 2 entries") {
REQUIRE(layers.size() == 2);
@ -70,11 +67,12 @@ SCENARIO("PrintObject: object layer heights", "[PrintObject]") {
}
#if 0
WHEN("generate_object_layers() is called for 15mm layer heights and nozzle diameter of 5mm") {
config.opt_float("nozzle_diameter", 0) = 5;
config.opt_float("layer_height") = 15.0;
Slic3r::Print print;
Slic3r::Test::init_print({m}, print, model, config);
print.process();
Slic3r::Test::init_and_process_print({TestMesh::cube_20x20x20}, print, {
{ "first_layer_height", 2 },
{ "layer_height", 15 },
{ "nozzle_diameter", 5 }
});
const std::vector<Slic3r::Layer*> &layers = print.objects().front()->layers();
THEN("The layer height is limited to 5mm.") {
CHECK(layers.size() == 5);

View File

@ -32,12 +32,12 @@ static int get_brim_tool(const std::string &gcode)
TEST_CASE("Skirt height is honored") {
DynamicPrintConfig config = Slic3r::DynamicPrintConfig::full_print_config();
config.set_deserialize({
{ "skirts", "1" },
{ "skirt_height", "5" },
{ "perimeters", "0" },
{ "support_material_speed", "99" },
{ "skirts", 1 },
{ "skirt_height", 5 },
{ "perimeters", 0 },
{ "support_material_speed", 99 },
// avoid altering speeds unexpectedly
{ "cooling", "0" },
{ "cooling", false },
{ "first_layer_speed", "100%" }
});
@ -65,22 +65,22 @@ SCENARIO("Original Slic3r Skirt/Brim tests", "[!mayfail]") {
DynamicPrintConfig config = Slic3r::DynamicPrintConfig::full_print_config();
config.set_num_extruders(4);
config.set_deserialize({
{ "support_material_speed", "99" },
{ "first_layer_height", "0.3" },
{ "gcode_comments", "1" },
{ "support_material_speed", 99 },
{ "first_layer_height", 0.3 },
{ "gcode_comments", true },
// avoid altering speeds unexpectedly
{ "cooling", "0" },
{ "cooling", false },
{ "first_layer_speed", "100%" },
// remove noise from top/solid layers
{ "top_solid_layers", "0" },
{ "bottom_solid_layers", "1" }
{ "top_solid_layers", 0 },
{ "bottom_solid_layers", 1 }
});
WHEN("Brim width is set to 5") {
config.set_deserialize({
{ "perimeters", "0" },
{ "skirts", "0" },
{ "brim_width", "5" }
{ "perimeters", 0 },
{ "skirts", 0 },
{ "brim_width", 5 }
});
THEN("Brim is generated") {
std::string gcode = Slic3r::Test::slice({TestMesh::cube_20x20x20}, config);
@ -100,8 +100,8 @@ SCENARIO("Original Slic3r Skirt/Brim tests", "[!mayfail]") {
WHEN("Skirt area is smaller than the brim") {
config.set_deserialize({
{ "skirts", "1" },
{ "brim_width", "10"}
{ "skirts", 1 },
{ "brim_width", 10}
});
THEN("Gcode generates") {
REQUIRE(! Slic3r::Test::slice({TestMesh::cube_20x20x20}, config).empty());
@ -110,8 +110,8 @@ SCENARIO("Original Slic3r Skirt/Brim tests", "[!mayfail]") {
WHEN("Skirt height is 0 and skirts > 0") {
config.set_deserialize({
{ "skirts", "2" },
{ "skirt_height", "0"}
{ "skirts", 2 },
{ "skirt_height", 0 }
});
THEN("Gcode generates") {
REQUIRE(! Slic3r::Test::slice({TestMesh::cube_20x20x20}, config).empty());
@ -121,10 +121,10 @@ SCENARIO("Original Slic3r Skirt/Brim tests", "[!mayfail]") {
WHEN("Perimeter extruder = 2 and support extruders = 3") {
THEN("Brim is printed with the extruder used for the perimeters of first object") {
std::string gcode = Slic3r::Test::slice({TestMesh::cube_20x20x20}, {
{ "skirts", "0" },
{ "brim_width", "5" },
{ "perimeter_extruder", "2" },
{ "support_material_extruder", "3" }
{ "skirts", 0 },
{ "brim_width", 5 },
{ "perimeter_extruder", 2 },
{ "support_material_extruder", 3 }
});
int tool = get_brim_tool(gcode);
REQUIRE(tool == config.opt_int("perimeter_extruder") - 1);
@ -133,11 +133,11 @@ SCENARIO("Original Slic3r Skirt/Brim tests", "[!mayfail]") {
WHEN("Perimeter extruder = 2, support extruders = 3, raft is enabled") {
THEN("brim is printed with same extruder as skirt") {
std::string gcode = Slic3r::Test::slice({TestMesh::cube_20x20x20}, {
{ "skirts", "0" },
{ "brim_width", "5" },
{ "perimeter_extruder", "2" },
{ "support_material_extruder", "3" },
{ "raft_layers", "1" }
{ "skirts", 0 },
{ "brim_width", 5 },
{ "perimeter_extruder", 2 },
{ "support_material_extruder", 3 },
{ "raft_layers", 1 }
});
int tool = get_brim_tool(gcode);
REQUIRE(tool == config.opt_int("support_material_extruder") - 1);
@ -145,9 +145,9 @@ SCENARIO("Original Slic3r Skirt/Brim tests", "[!mayfail]") {
}
WHEN("brim width to 1 with layer_width of 0.5") {
config.set_deserialize({
{ "skirts", "0" },
{ "first_layer_extrusion_width", "0.5" },
{ "brim_width", "1" }
{ "skirts", 0 },
{ "first_layer_extrusion_width", 0.5 },
{ "brim_width", 1 }
});
THEN("2 brim lines") {
Slic3r::Print print;
@ -159,11 +159,11 @@ SCENARIO("Original Slic3r Skirt/Brim tests", "[!mayfail]") {
#if 0
WHEN("brim ears on a square") {
config.set_deserialize({
{ "skirts", "0" },
{ "first_layer_extrusion_width", "0.5" },
{ "brim_width", "1" },
{ "brim_ears", "1" },
{ "brim_ears_max_angle", "91" }
{ "skirts", 0 },
{ "first_layer_extrusion_width", 0.5 },
{ "brim_width", 1 },
{ "brim_ears", 1 },
{ "brim_ears_max_angle", 91 }
});
Slic3r::Print print;
Slic3r::Test::init_and_process_print({TestMesh::cube_20x20x20}, print, config);
@ -174,11 +174,11 @@ SCENARIO("Original Slic3r Skirt/Brim tests", "[!mayfail]") {
WHEN("brim ears on a square but with a too small max angle") {
config.set_deserialize({
{ "skirts", "0" },
{ "first_layer_extrusion_width", "0.5" },
{ "brim_width", "1" },
{ "brim_ears", "1" },
{ "brim_ears_max_angle", "89" }
{ "skirts", 0 },
{ "first_layer_extrusion_width", 0.5 },
{ "brim_width", 1 },
{ "brim_ears", 1 },
{ "brim_ears_max_angle", 89 }
});
THEN("no brim") {
Slic3r::Print print;
@ -190,15 +190,15 @@ SCENARIO("Original Slic3r Skirt/Brim tests", "[!mayfail]") {
WHEN("Object is plated with overhang support and a brim") {
config.set_deserialize({
{ "layer_height", "0.4" },
{ "first_layer_height", "0.4" },
{ "skirts", "1" },
{ "skirt_distance", "0" },
{ "support_material_speed", "99" },
{ "perimeter_extruder", "1" },
{ "support_material_extruder", "2" },
{ "infill_extruder", "3" }, // ensure that a tool command gets emitted.
{ "cooling", "0" }, // to prevent speeds to be altered
{ "layer_height", 0.4 },
{ "first_layer_height", 0.4 },
{ "skirts", 1 },
{ "skirt_distance", 0 },
{ "support_material_speed", 99 },
{ "perimeter_extruder", 1 },
{ "support_material_extruder", 2 },
{ "infill_extruder", 3 }, // ensure that a tool command gets emitted.
{ "cooling", false }, // to prevent speeds to be altered
{ "first_layer_speed", "100%" }, // to prevent speeds to be altered
});

View File

@ -11,8 +11,8 @@ TEST_CASE("SupportMaterial: Three raft layers created", "[SupportMaterial]")
{
Slic3r::Print print;
Slic3r::Test::init_and_process_print({ TestMesh::cube_20x20x20 }, print, {
{ "support_material", "1" },
{ "raft_layers", "3" }
{ "support_material", 1 },
{ "raft_layers", 3 }
});
REQUIRE(print.objects().front()->support_layers().size() == 3);
}
@ -72,9 +72,9 @@ SCENARIO("SupportMaterial: support_layers_z and contact_distance", "[SupportMate
WHEN("First layer height = 0.4") {
Slic3r::Print print;
Slic3r::Test::init_and_process_print({ mesh }, print, {
{ "support_material", "1" },
{ "layer_height", "0.2" },
{ "first_layer_height", "0.4" },
{ "support_material", 1 },
{ "layer_height", 0.2 },
{ "first_layer_height", 0.4 },
});
bool a, b, c, d;
check(print, a, b, c, d);
@ -86,9 +86,9 @@ SCENARIO("SupportMaterial: support_layers_z and contact_distance", "[SupportMate
WHEN("Layer height = 0.2 and, first layer height = 0.3") {
Slic3r::Print print;
Slic3r::Test::init_and_process_print({ mesh }, print, {
{ "support_material", "1" },
{ "layer_height", "0.2" },
{ "first_layer_height", "0.3" },
{ "support_material", 1 },
{ "layer_height", 0.2 },
{ "first_layer_height", 0.3 },
});
bool a, b, c, d;
check(print, a, b, c, d);
@ -100,9 +100,9 @@ SCENARIO("SupportMaterial: support_layers_z and contact_distance", "[SupportMate
WHEN("Layer height = nozzle_diameter[0]") {
Slic3r::Print print;
Slic3r::Test::init_and_process_print({ mesh }, print, {
{ "support_material", "1" },
{ "layer_height", "0.2" },
{ "first_layer_height", "0.3" },
{ "support_material", 1 },
{ "layer_height", 0.2 },
{ "first_layer_height", 0.3 },
});
bool a, b, c, d;
check(print, a, b, c, d);