Fixing some GCodeExport and Flow unit tests.
This commit is contained in:
parent
6e6b137151
commit
d1a86e513c
@ -15,7 +15,7 @@
|
|||||||
using namespace Slic3r::Test;
|
using namespace Slic3r::Test;
|
||||||
using namespace Slic3r;
|
using namespace Slic3r;
|
||||||
|
|
||||||
SCENARIO("Extrusion width specifics", "[!mayfail]") {
|
SCENARIO("Extrusion width specifics", "[Flow]") {
|
||||||
GIVEN("A config with a skirt, brim, some fill density, 3 perimeters, and 1 bottom solid layer and a 20mm cube mesh") {
|
GIVEN("A config with a skirt, brim, some fill density, 3 perimeters, and 1 bottom solid layer and a 20mm cube mesh") {
|
||||||
// this is a sharedptr
|
// this is a sharedptr
|
||||||
DynamicPrintConfig config = Slic3r::DynamicPrintConfig::full_print_config();
|
DynamicPrintConfig config = Slic3r::DynamicPrintConfig::full_print_config();
|
||||||
@ -59,7 +59,7 @@ SCENARIO("Extrusion width specifics", "[!mayfail]") {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// needs gcode export
|
// needs gcode export
|
||||||
SCENARIO(" Bridge flow specifics.", "[!mayfail]") {
|
SCENARIO(" Bridge flow specifics.", "[Flow]") {
|
||||||
GIVEN("A default config with no cooling and a fixed bridge speed, flow ratio and an overhang mesh.") {
|
GIVEN("A default config with no cooling and a fixed bridge speed, flow ratio and an overhang mesh.") {
|
||||||
WHEN("bridge_flow_ratio is set to 1.0") {
|
WHEN("bridge_flow_ratio is set to 1.0") {
|
||||||
THEN("Output flow is as expected.") {
|
THEN("Output flow is as expected.") {
|
||||||
@ -92,54 +92,53 @@ SCENARIO(" Bridge flow specifics.", "[!mayfail]") {
|
|||||||
|
|
||||||
/// Test the expected behavior for auto-width,
|
/// Test the expected behavior for auto-width,
|
||||||
/// spacing, etc
|
/// spacing, etc
|
||||||
SCENARIO("Flow: Flow math for non-bridges", "[!mayfail]") {
|
SCENARIO("Flow: Flow math for non-bridges", "[Flow]") {
|
||||||
GIVEN("Nozzle Diameter of 0.4, a desired width of 1mm and layer height of 0.5") {
|
GIVEN("Nozzle Diameter of 0.4, a desired width of 1mm and layer height of 0.5") {
|
||||||
ConfigOptionFloatOrPercent width(1.0, false);
|
ConfigOptionFloatOrPercent width(1.0, false);
|
||||||
float spacing {0.4};
|
float spacing = 0.4f;
|
||||||
float nozzle_diameter {0.4};
|
float nozzle_diameter = 0.4f;
|
||||||
float bridge_flow {1.0};
|
float bridge_flow = 0.f;
|
||||||
float layer_height {0.5};
|
float layer_height = 0.5f;
|
||||||
|
|
||||||
// Spacing for non-bridges is has some overlap
|
// Spacing for non-bridges is has some overlap
|
||||||
THEN("External perimeter flow has spacing fixed to 1.1*nozzle_diameter") {
|
THEN("External perimeter flow has spacing fixed to 1.125 * nozzle_diameter") {
|
||||||
auto flow = Flow::new_from_config_width(frExternalPerimeter, ConfigOptionFloatOrPercent(0, false), nozzle_diameter, layer_height, 0.0f);
|
auto flow = Flow::new_from_config_width(frExternalPerimeter, ConfigOptionFloatOrPercent(0, false), nozzle_diameter, layer_height, bridge_flow);
|
||||||
REQUIRE(flow.spacing() == Approx((1.1*nozzle_diameter) - layer_height * (1.0 - PI / 4.0)));
|
REQUIRE(flow.spacing() == Approx(1.125 * nozzle_diameter - layer_height * (1.0 - PI / 4.0)));
|
||||||
}
|
}
|
||||||
|
|
||||||
THEN("Internal perimeter flow has spacing of 1.05 (minimum)") {
|
THEN("Internal perimeter flow has spacing fixed to 1.125 * nozzle_diameter") {
|
||||||
auto flow = Flow::new_from_config_width(frPerimeter, ConfigOptionFloatOrPercent(0, false), nozzle_diameter, layer_height, 0.0f);
|
auto flow = Flow::new_from_config_width(frPerimeter, ConfigOptionFloatOrPercent(0, false), nozzle_diameter, layer_height, bridge_flow);
|
||||||
REQUIRE(flow.spacing() == Approx((1.05*nozzle_diameter) - layer_height * (1.0 - PI / 4.0)));
|
REQUIRE(flow.spacing() == Approx(1.125 *nozzle_diameter - layer_height * (1.0 - PI / 4.0)));
|
||||||
}
|
}
|
||||||
THEN("Spacing for supplied width is 0.8927f") {
|
THEN("Spacing for supplied width is 0.8927f") {
|
||||||
auto flow = Flow::new_from_config_width(frExternalPerimeter, width, nozzle_diameter, layer_height, 0.0f);
|
auto flow = Flow::new_from_config_width(frExternalPerimeter, width, nozzle_diameter, layer_height, bridge_flow);
|
||||||
REQUIRE(flow.spacing() == Approx(width.value - layer_height * (1.0 - PI / 4.0)));
|
REQUIRE(flow.spacing() == Approx(width.value - layer_height * (1.0 - PI / 4.0)));
|
||||||
flow = Flow::new_from_config_width(frPerimeter, width, nozzle_diameter, layer_height, 0.0f);
|
flow = Flow::new_from_config_width(frPerimeter, width, nozzle_diameter, layer_height, bridge_flow);
|
||||||
REQUIRE(flow.spacing() == Approx(width.value - layer_height * (1.0 - PI / 4.0)));
|
REQUIRE(flow.spacing() == Approx(width.value - layer_height * (1.0 - PI / 4.0)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/// Check the min/max
|
/// Check the min/max
|
||||||
GIVEN("Nozzle Diameter of 0.25") {
|
GIVEN("Nozzle Diameter of 0.25") {
|
||||||
float spacing {0.4};
|
float spacing = 0.4f;
|
||||||
float nozzle_diameter {0.25};
|
float nozzle_diameter = 0.25f;
|
||||||
float bridge_flow {0.0};
|
float bridge_flow = 0.f;
|
||||||
float layer_height {0.5};
|
float layer_height = 0.5f;
|
||||||
WHEN("layer height is set to 0.2") {
|
WHEN("layer height is set to 0.2") {
|
||||||
layer_height = 0.15f;
|
layer_height = 0.15f;
|
||||||
THEN("Max width is set.") {
|
THEN("Max width is set.") {
|
||||||
auto flow = Flow::new_from_config_width(frPerimeter, ConfigOptionFloatOrPercent(0, false), nozzle_diameter, layer_height, 0.0f);
|
auto flow = Flow::new_from_config_width(frPerimeter, ConfigOptionFloatOrPercent(0, false), nozzle_diameter, layer_height, bridge_flow);
|
||||||
REQUIRE(flow.width == Approx(1.4*nozzle_diameter));
|
REQUIRE(flow.width == Approx(1.125 * nozzle_diameter));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
WHEN("Layer height is set to 0.2") {
|
WHEN("Layer height is set to 0.2") {
|
||||||
layer_height = 0.3f;
|
layer_height = 0.3f;
|
||||||
THEN("Min width is set.") {
|
THEN("Min width is set.") {
|
||||||
auto flow = Flow::new_from_config_width(frPerimeter, ConfigOptionFloatOrPercent(0, false), nozzle_diameter, layer_height, 0.0f);
|
auto flow = Flow::new_from_config_width(frPerimeter, ConfigOptionFloatOrPercent(0, false), nozzle_diameter, layer_height, bridge_flow);
|
||||||
REQUIRE(flow.width == Approx(1.05*nozzle_diameter));
|
REQUIRE(flow.width == Approx(1.125 * nozzle_diameter));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
/// Check for an edge case in the maths where the spacing could be 0; original
|
/// Check for an edge case in the maths where the spacing could be 0; original
|
||||||
/// math is 0.99. Slic3r issue #4654
|
/// math is 0.99. Slic3r issue #4654
|
||||||
@ -159,13 +158,13 @@ SCENARIO("Flow: Flow math for non-bridges", "[!mayfail]") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Spacing, width calculation for bridge extrusions
|
/// Spacing, width calculation for bridge extrusions
|
||||||
SCENARIO("Flow: Flow math for bridges", "[!mayfail]") {
|
SCENARIO("Flow: Flow math for bridges", "[Flow]") {
|
||||||
GIVEN("Nozzle Diameter of 0.4, a desired width of 1mm and layer height of 0.5") {
|
GIVEN("Nozzle Diameter of 0.4, a desired width of 1mm and layer height of 0.5") {
|
||||||
auto width = ConfigOptionFloatOrPercent(1.0, false);
|
auto width = ConfigOptionFloatOrPercent(1.0, false);
|
||||||
double spacing = 0.4;
|
float spacing = 0.4f;
|
||||||
double nozzle_diameter = 0.4;
|
float nozzle_diameter = 0.4f;
|
||||||
double bridge_flow = 1.0;
|
float bridge_flow = 1.0f;
|
||||||
double layer_height = 0.5;
|
float layer_height = 0.5f;
|
||||||
WHEN("Flow role is frExternalPerimeter") {
|
WHEN("Flow role is frExternalPerimeter") {
|
||||||
auto flow = Flow::new_from_config_width(frExternalPerimeter, width, nozzle_diameter, layer_height, bridge_flow);
|
auto flow = Flow::new_from_config_width(frExternalPerimeter, width, nozzle_diameter, layer_height, bridge_flow);
|
||||||
THEN("Bridge width is same as nozzle diameter") {
|
THEN("Bridge width is same as nozzle diameter") {
|
||||||
|
@ -6,36 +6,7 @@
|
|||||||
|
|
||||||
using namespace Slic3r;
|
using namespace Slic3r;
|
||||||
|
|
||||||
SCENARIO("lift() and unlift() behavior with large values of Z", "[!shouldfail]") {
|
SCENARIO("lift() is not ignored after unlift() at normal values of Z", "[GCodeWriter]") {
|
||||||
GIVEN("A config from a file and a single extruder.") {
|
|
||||||
GCodeWriter writer;
|
|
||||||
GCodeConfig &config = writer.config;
|
|
||||||
config.load(std::string(TEST_DATA_DIR) + "/fff_print_tests/test_gcodewriter/config_lift_unlift.ini");
|
|
||||||
|
|
||||||
std::vector<unsigned int> extruder_ids {0};
|
|
||||||
writer.set_extruders(extruder_ids);
|
|
||||||
writer.set_extruder(0);
|
|
||||||
|
|
||||||
WHEN("Z is set to 9007199254740992") {
|
|
||||||
double trouble_Z = 9007199254740992;
|
|
||||||
writer.travel_to_z(trouble_Z);
|
|
||||||
AND_WHEN("GcodeWriter::Lift() is called") {
|
|
||||||
REQUIRE(writer.lift().size() > 0);
|
|
||||||
AND_WHEN("Z is moved post-lift to the same delta as the config Z lift") {
|
|
||||||
REQUIRE(writer.travel_to_z(trouble_Z + config.retract_lift.values[0]).size() == 0);
|
|
||||||
AND_WHEN("GCodeWriter::Unlift() is called") {
|
|
||||||
REQUIRE(writer.unlift().size() == 0); // we're the same height so no additional move happens.
|
|
||||||
THEN("GCodeWriter::Lift() emits gcode.") {
|
|
||||||
REQUIRE(writer.lift().size() > 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
SCENARIO("lift() is not ignored after unlift() at normal values of Z") {
|
|
||||||
GIVEN("A config from a file and a single extruder.") {
|
GIVEN("A config from a file and a single extruder.") {
|
||||||
GCodeWriter writer;
|
GCodeWriter writer;
|
||||||
GCodeConfig &config = writer.config;
|
GCodeConfig &config = writer.config;
|
||||||
@ -93,10 +64,11 @@ SCENARIO("lift() is not ignored after unlift() at normal values of Z") {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// The test above will fail for trouble_Z == 9007199254740992, where trouble_Z + 1.5 will be rounded to trouble_Z + 2.0 due to double mantisa overflow.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SCENARIO("set_speed emits values with fixed-point output.") {
|
SCENARIO("set_speed emits values with fixed-point output.", "[GCodeWriter]") {
|
||||||
|
|
||||||
GIVEN("GCodeWriter instance") {
|
GIVEN("GCodeWriter instance") {
|
||||||
GCodeWriter writer;
|
GCodeWriter writer;
|
||||||
|
Loading…
Reference in New Issue
Block a user