Fixing unit tests.
This commit is contained in:
parent
ceea9de8b8
commit
8e27e355c2
@ -31,7 +31,6 @@ use Slic3r::Test;
|
||||
role => FLOW_ROLE_SUPPORT_MATERIAL,
|
||||
nozzle_diameter => $print->config->nozzle_diameter->[$object_config->support_material_extruder-1] // $print->config->nozzle_diameter->[0],
|
||||
layer_height => $object_config->layer_height,
|
||||
bridge_flow_ratio => 0,
|
||||
);
|
||||
my $support = Slic3r::Print::SupportMaterial->new(
|
||||
object_config => $print->print->objects->[0]->config,
|
||||
|
@ -96,43 +96,41 @@ 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") {
|
||||
ConfigOptionFloatOrPercent width(1.0, false);
|
||||
float nozzle_diameter = 0.4f;
|
||||
float bridge_flow = 0.f;
|
||||
float layer_height = 0.5f;
|
||||
|
||||
// Spacing for non-bridges is has some overlap
|
||||
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, bridge_flow);
|
||||
auto flow = Flow::new_from_config_width(frExternalPerimeter, ConfigOptionFloatOrPercent(0, false), nozzle_diameter, layer_height);
|
||||
REQUIRE(flow.spacing() == Approx(1.125 * nozzle_diameter - layer_height * (1.0 - PI / 4.0)));
|
||||
}
|
||||
|
||||
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, bridge_flow);
|
||||
auto flow = Flow::new_from_config_width(frPerimeter, ConfigOptionFloatOrPercent(0, false), nozzle_diameter, layer_height);
|
||||
REQUIRE(flow.spacing() == Approx(1.125 *nozzle_diameter - layer_height * (1.0 - PI / 4.0)));
|
||||
}
|
||||
THEN("Spacing for supplied width is 0.8927f") {
|
||||
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);
|
||||
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, bridge_flow);
|
||||
flow = Flow::new_from_config_width(frPerimeter, width, nozzle_diameter, layer_height);
|
||||
REQUIRE(flow.spacing() == Approx(width.value - layer_height * (1.0 - PI / 4.0)));
|
||||
}
|
||||
}
|
||||
/// Check the min/max
|
||||
GIVEN("Nozzle Diameter of 0.25") {
|
||||
float nozzle_diameter = 0.25f;
|
||||
float bridge_flow = 0.f;
|
||||
float layer_height = 0.5f;
|
||||
WHEN("layer height is set to 0.2") {
|
||||
layer_height = 0.15f;
|
||||
THEN("Max width is set.") {
|
||||
auto flow = Flow::new_from_config_width(frPerimeter, ConfigOptionFloatOrPercent(0, false), nozzle_diameter, layer_height, bridge_flow);
|
||||
REQUIRE(flow.width == Approx(1.125 * nozzle_diameter));
|
||||
auto flow = Flow::new_from_config_width(frPerimeter, ConfigOptionFloatOrPercent(0, false), nozzle_diameter, layer_height);
|
||||
REQUIRE(flow.width() == Approx(1.125 * nozzle_diameter));
|
||||
}
|
||||
}
|
||||
WHEN("Layer height is set to 0.2") {
|
||||
layer_height = 0.3f;
|
||||
THEN("Min width is set.") {
|
||||
auto flow = Flow::new_from_config_width(frPerimeter, ConfigOptionFloatOrPercent(0, false), nozzle_diameter, layer_height, bridge_flow);
|
||||
REQUIRE(flow.width == Approx(1.125 * nozzle_diameter));
|
||||
auto flow = Flow::new_from_config_width(frPerimeter, ConfigOptionFloatOrPercent(0, false), nozzle_diameter, layer_height);
|
||||
REQUIRE(flow.width() == Approx(1.125 * nozzle_diameter));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -158,41 +156,12 @@ SCENARIO("Flow: Flow math for non-bridges", "[Flow]") {
|
||||
/// Spacing, width calculation for bridge extrusions
|
||||
SCENARIO("Flow: Flow math for bridges", "[Flow]") {
|
||||
GIVEN("Nozzle Diameter of 0.4, a desired width of 1mm and layer height of 0.5") {
|
||||
auto width = ConfigOptionFloatOrPercent(1.0, false);
|
||||
float nozzle_diameter = 0.4f;
|
||||
float bridge_flow = 1.0f;
|
||||
float layer_height = 0.5f;
|
||||
WHEN("Flow role is frExternalPerimeter") {
|
||||
auto flow = Flow::new_from_config_width(frExternalPerimeter, width, nozzle_diameter, layer_height, bridge_flow);
|
||||
auto flow = Flow::bridging_flow(nozzle_diameter * sqrt(bridge_flow), nozzle_diameter);
|
||||
THEN("Bridge width is same as nozzle diameter") {
|
||||
REQUIRE(flow.width == Approx(nozzle_diameter));
|
||||
}
|
||||
THEN("Bridge spacing is same as nozzle diameter + BRIDGE_EXTRA_SPACING") {
|
||||
REQUIRE(flow.spacing() == Approx(nozzle_diameter + BRIDGE_EXTRA_SPACING));
|
||||
}
|
||||
}
|
||||
WHEN("Flow role is frInfill") {
|
||||
auto flow = Flow::new_from_config_width(frInfill, width, nozzle_diameter, layer_height, bridge_flow);
|
||||
THEN("Bridge width is same as nozzle diameter") {
|
||||
REQUIRE(flow.width == Approx(nozzle_diameter));
|
||||
}
|
||||
THEN("Bridge spacing is same as nozzle diameter + BRIDGE_EXTRA_SPACING") {
|
||||
REQUIRE(flow.spacing() == Approx(nozzle_diameter + BRIDGE_EXTRA_SPACING));
|
||||
}
|
||||
}
|
||||
WHEN("Flow role is frPerimeter") {
|
||||
auto flow = Flow::new_from_config_width(frPerimeter, width, nozzle_diameter, layer_height, bridge_flow);
|
||||
THEN("Bridge width is same as nozzle diameter") {
|
||||
REQUIRE(flow.width == Approx(nozzle_diameter));
|
||||
}
|
||||
THEN("Bridge spacing is same as nozzle diameter + BRIDGE_EXTRA_SPACING") {
|
||||
REQUIRE(flow.spacing() == Approx(nozzle_diameter + BRIDGE_EXTRA_SPACING));
|
||||
}
|
||||
}
|
||||
WHEN("Flow role is frSupportMaterial") {
|
||||
auto flow = Flow::new_from_config_width(frSupportMaterial, width, nozzle_diameter, layer_height, bridge_flow);
|
||||
THEN("Bridge width is same as nozzle diameter") {
|
||||
REQUIRE(flow.width == Approx(nozzle_diameter));
|
||||
REQUIRE(flow.width() == Approx(nozzle_diameter));
|
||||
}
|
||||
THEN("Bridge spacing is same as nozzle diameter + BRIDGE_EXTRA_SPACING") {
|
||||
REQUIRE(flow.spacing() == Approx(nozzle_diameter + BRIDGE_EXTRA_SPACING));
|
||||
|
@ -434,7 +434,7 @@ SCENARIO("Elephant foot compensation", "[ElephantFoot]") {
|
||||
ExPolygon expoly = contour_with_hole();
|
||||
WHEN("Compensated") {
|
||||
// Elephant foot compensation shall not pinch off bits from this contour.
|
||||
ExPolygon expoly_compensated = elephant_foot_compensation(expoly, Flow(0.419999987f, 0.2f, 0.4f, false), 0.2f);
|
||||
ExPolygon expoly_compensated = elephant_foot_compensation(expoly, Flow(0.419999987f, 0.2f, 0.4f), 0.2f);
|
||||
#ifdef TESTS_EXPORT_SVGS
|
||||
SVG::export_expolygons(debug_out_path("elephant_foot_compensation_with_hole.svg").c_str(),
|
||||
{ { { expoly }, { "gray", "black", "blue", coord_t(scale_(0.02)), 0.5f, "black", coord_t(scale_(0.05)) } },
|
||||
@ -449,7 +449,7 @@ SCENARIO("Elephant foot compensation", "[ElephantFoot]") {
|
||||
GIVEN("Tiny contour") {
|
||||
ExPolygon expoly({ { 133382606, 94912473 }, { 134232493, 95001115 }, { 133783926, 95159440 }, { 133441897, 95180666 }, { 133408242, 95191984 }, { 133339012, 95166830 }, { 132991642, 95011087 }, { 133206549, 94908304 } });
|
||||
WHEN("Compensated") {
|
||||
ExPolygon expoly_compensated = elephant_foot_compensation(expoly, Flow(0.419999987f, 0.2f, 0.4f, false), 0.2f);
|
||||
ExPolygon expoly_compensated = elephant_foot_compensation(expoly, Flow(0.419999987f, 0.2f, 0.4f), 0.2f);
|
||||
#ifdef TESTS_EXPORT_SVGS
|
||||
SVG::export_expolygons(debug_out_path("elephant_foot_compensation_tiny.svg").c_str(),
|
||||
{ { { expoly }, { "gray", "black", "blue", coord_t(scale_(0.02)), 0.5f, "black", coord_t(scale_(0.05)) } },
|
||||
@ -464,7 +464,7 @@ SCENARIO("Elephant foot compensation", "[ElephantFoot]") {
|
||||
GIVEN("Large box") {
|
||||
ExPolygon expoly( { {50000000, 50000000 }, { 0, 50000000 }, { 0, 0 }, { 50000000, 0 } } );
|
||||
WHEN("Compensated") {
|
||||
ExPolygon expoly_compensated = elephant_foot_compensation(expoly, Flow(0.419999987f, 0.2f, 0.4f, false), 0.21f);
|
||||
ExPolygon expoly_compensated = elephant_foot_compensation(expoly, Flow(0.419999987f, 0.2f, 0.4f), 0.21f);
|
||||
#ifdef TESTS_EXPORT_SVGS
|
||||
SVG::export_expolygons(debug_out_path("elephant_foot_compensation_large_box.svg").c_str(),
|
||||
{ { { expoly }, { "gray", "black", "blue", coord_t(scale_(0.02)), 0.5f, "black", coord_t(scale_(0.05)) } },
|
||||
@ -479,7 +479,7 @@ SCENARIO("Elephant foot compensation", "[ElephantFoot]") {
|
||||
GIVEN("Thin ring (GH issue #2085)") {
|
||||
ExPolygon expoly = thin_ring();
|
||||
WHEN("Compensated") {
|
||||
ExPolygon expoly_compensated = elephant_foot_compensation(expoly, Flow(0.419999987f, 0.2f, 0.4f, false), 0.25f);
|
||||
ExPolygon expoly_compensated = elephant_foot_compensation(expoly, Flow(0.419999987f, 0.2f, 0.4f), 0.25f);
|
||||
#ifdef TESTS_EXPORT_SVGS
|
||||
SVG::export_expolygons(debug_out_path("elephant_foot_compensation_thin_ring.svg").c_str(),
|
||||
{ { { expoly }, { "gray", "black", "blue", coord_t(scale_(0.02)), 0.5f, "black", coord_t(scale_(0.05)) } },
|
||||
@ -532,7 +532,7 @@ SCENARIO("Elephant foot compensation", "[ElephantFoot]") {
|
||||
expoly = union_ex({ expoly, expoly2 }).front();
|
||||
|
||||
WHEN("Partially compensated") {
|
||||
ExPolygon expoly_compensated = elephant_foot_compensation(expoly, Flow(0.45f, 0.2f, 0.4f, false), 0.25f);
|
||||
ExPolygon expoly_compensated = elephant_foot_compensation(expoly, Flow(0.45f, 0.2f, 0.4f), 0.25f);
|
||||
#ifdef TESTS_EXPORT_SVGS
|
||||
SVG::export_expolygons(debug_out_path("elephant_foot_compensation_0.svg").c_str(),
|
||||
{ { { expoly }, { "gray", "black", "blue", coord_t(scale_(0.02)), 0.5f, "black", coord_t(scale_(0.05)) } },
|
||||
@ -543,7 +543,7 @@ SCENARIO("Elephant foot compensation", "[ElephantFoot]") {
|
||||
}
|
||||
}
|
||||
WHEN("Fully compensated") {
|
||||
ExPolygon expoly_compensated = elephant_foot_compensation(expoly, Flow(0.35f, 0.2f, 0.4f, false), 0.17f);
|
||||
ExPolygon expoly_compensated = elephant_foot_compensation(expoly, Flow(0.35f, 0.2f, 0.4f), 0.17f);
|
||||
#ifdef TESTS_EXPORT_SVGS
|
||||
SVG::export_expolygons(debug_out_path("elephant_foot_compensation_1.svg").c_str(),
|
||||
{ { { expoly }, { "gray", "black", "blue", coord_t(scale_(0.02)), 0.5f, "black", coord_t(scale_(0.05)) } },
|
||||
@ -558,7 +558,7 @@ SCENARIO("Elephant foot compensation", "[ElephantFoot]") {
|
||||
GIVEN("Box with hole close to wall (GH issue #2998)") {
|
||||
ExPolygon expoly = box_with_hole_close_to_wall();
|
||||
WHEN("Compensated") {
|
||||
ExPolygon expoly_compensated = elephant_foot_compensation(expoly, Flow(0.419999987f, 0.2f, 0.4f, false), 0.25f);
|
||||
ExPolygon expoly_compensated = elephant_foot_compensation(expoly, Flow(0.419999987f, 0.2f, 0.4f), 0.25f);
|
||||
#ifdef TESTS_EXPORT_SVGS
|
||||
SVG::export_expolygons(debug_out_path("elephant_foot_compensation_2.svg").c_str(),
|
||||
{ { { expoly }, { "gray", "black", "blue", coord_t(scale_(0.02)), 0.5f, "black", coord_t(scale_(0.05)) } },
|
||||
@ -575,7 +575,7 @@ SCENARIO("Elephant foot compensation", "[ElephantFoot]") {
|
||||
ExPolygon expoly = spirograph_gear_1mm();
|
||||
|
||||
WHEN("Partially compensated") {
|
||||
ExPolygon expoly_compensated = elephant_foot_compensation(expoly, Flow(0.45f, 0.2f, 0.4f, false), 0.25f);
|
||||
ExPolygon expoly_compensated = elephant_foot_compensation(expoly, Flow(0.45f, 0.2f, 0.4f), 0.25f);
|
||||
#ifdef TESTS_EXPORT_SVGS
|
||||
SVG::export_expolygons(debug_out_path("elephant_foot_compensation_2.svg").c_str(),
|
||||
{ { { expoly }, { "gray", "black", "blue", coord_t(scale_(0.02)), 0.5f, "black", coord_t(scale_(0.05)) } },
|
||||
@ -586,7 +586,7 @@ SCENARIO("Elephant foot compensation", "[ElephantFoot]") {
|
||||
}
|
||||
}
|
||||
WHEN("Fully compensated") {
|
||||
ExPolygon expoly_compensated = elephant_foot_compensation(expoly, Flow(0.35f, 0.2f, 0.4f, false), 0.17f);
|
||||
ExPolygon expoly_compensated = elephant_foot_compensation(expoly, Flow(0.35f, 0.2f, 0.4f), 0.17f);
|
||||
#ifdef TESTS_EXPORT_SVGS
|
||||
SVG::export_expolygons(debug_out_path("elephant_foot_compensation_3.svg").c_str(),
|
||||
{ { { expoly }, { "gray", "black", "blue", coord_t(scale_(0.02)), 0.5f, "black", coord_t(scale_(0.05)) } },
|
||||
@ -597,7 +597,7 @@ SCENARIO("Elephant foot compensation", "[ElephantFoot]") {
|
||||
}
|
||||
}
|
||||
WHEN("Brutally compensated") {
|
||||
ExPolygon expoly_compensated = elephant_foot_compensation(expoly, Flow(0.45f, 0.2f, 0.4f, false), 0.6f);
|
||||
ExPolygon expoly_compensated = elephant_foot_compensation(expoly, Flow(0.45f, 0.2f, 0.4f), 0.6f);
|
||||
#ifdef TESTS_EXPORT_SVGS
|
||||
SVG::export_expolygons(debug_out_path("elephant_foot_compensation_4.svg").c_str(),
|
||||
{ { { expoly }, { "gray", "black", "blue", coord_t(scale_(0.02)), 0.5f, "black", coord_t(scale_(0.05)) } },
|
||||
@ -612,7 +612,7 @@ SCENARIO("Elephant foot compensation", "[ElephantFoot]") {
|
||||
GIVEN("Vase with fins") {
|
||||
ExPolygon expoly = vase_with_fins();
|
||||
WHEN("Compensated") {
|
||||
ExPolygon expoly_compensated = elephant_foot_compensation(expoly, Flow(0.419999987f, 0.2f, 0.4f, false), 0.41f);
|
||||
ExPolygon expoly_compensated = elephant_foot_compensation(expoly, Flow(0.419999987f, 0.2f, 0.4f), 0.41f);
|
||||
#ifdef TESTS_EXPORT_SVGS
|
||||
SVG::export_expolygons(debug_out_path("elephant_foot_compensation_vase_with_fins.svg").c_str(),
|
||||
{ { { expoly }, { "gray", "black", "blue", coord_t(scale_(0.02)), 0.5f, "black", coord_t(scale_(0.05)) } },
|
||||
|
@ -158,7 +158,6 @@ sub new {
|
||||
my $self = $class->_new(
|
||||
@args{qw(width height nozzle_diameter)},
|
||||
);
|
||||
$self->set_bridge($args{bridge} // 0);
|
||||
return $self;
|
||||
}
|
||||
|
||||
@ -166,7 +165,7 @@ sub new_from_width {
|
||||
my ($class, %args) = @_;
|
||||
|
||||
return $class->_new_from_width(
|
||||
@args{qw(role width nozzle_diameter layer_height bridge_flow_ratio)},
|
||||
@args{qw(role width nozzle_diameter layer_height)},
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -8,21 +8,13 @@
|
||||
%name{Slic3r::Flow} class Flow {
|
||||
~Flow();
|
||||
%name{_new} Flow(float width, float height, float nozzle_diameter);
|
||||
void set_height(float height)
|
||||
%code{% THIS->height = height; %};
|
||||
void set_bridge(bool bridge)
|
||||
%code{% THIS->bridge = bridge; %};
|
||||
Clone<Flow> clone()
|
||||
%code{% RETVAL = THIS; %};
|
||||
|
||||
float width()
|
||||
%code{% RETVAL = THIS->width; %};
|
||||
float height()
|
||||
%code{% RETVAL = THIS->height; %};
|
||||
float nozzle_diameter()
|
||||
%code{% RETVAL = THIS->nozzle_diameter; %};
|
||||
bool bridge()
|
||||
%code{% RETVAL = THIS->bridge; %};
|
||||
float width();
|
||||
float height();
|
||||
float nozzle_diameter();
|
||||
bool bridge();
|
||||
float spacing();
|
||||
float spacing_to(Flow* other)
|
||||
%code{% RETVAL = THIS->spacing(*other); %};
|
||||
@ -32,17 +24,16 @@
|
||||
%{
|
||||
|
||||
Flow*
|
||||
_new_from_width(CLASS, role, width, nozzle_diameter, height, bridge_flow_ratio)
|
||||
_new_from_width(CLASS, role, width, nozzle_diameter, height)
|
||||
char* CLASS;
|
||||
FlowRole role;
|
||||
std::string width;
|
||||
float nozzle_diameter;
|
||||
float height;
|
||||
float bridge_flow_ratio;
|
||||
CODE:
|
||||
ConfigOptionFloatOrPercent optwidth;
|
||||
optwidth.deserialize(width);
|
||||
RETVAL = new Flow(Flow::new_from_config_width(role, optwidth, nozzle_diameter, height, bridge_flow_ratio));
|
||||
RETVAL = new Flow(Flow::new_from_config_width(role, optwidth, nozzle_diameter, height));
|
||||
OUTPUT:
|
||||
RETVAL
|
||||
|
||||
|
@ -23,8 +23,8 @@
|
||||
Ref<ExtrusionEntityCollection> fills()
|
||||
%code%{ RETVAL = &THIS->fills; %};
|
||||
|
||||
Clone<Flow> flow(FlowRole role, bool bridge = false, double width = -1)
|
||||
%code%{ RETVAL = THIS->flow(role, bridge, width); %};
|
||||
Clone<Flow> flow(FlowRole role)
|
||||
%code%{ RETVAL = THIS->flow(role); %};
|
||||
void prepare_fill_surfaces();
|
||||
void make_perimeters(SurfaceCollection* slices, SurfaceCollection* fill_surfaces)
|
||||
%code%{ THIS->make_perimeters(*slices, fill_surfaces); %};
|
||||
|
@ -33,9 +33,6 @@ _constant()
|
||||
Ref<StaticPrintConfig> config()
|
||||
%code%{ RETVAL = &THIS->config(); %};
|
||||
Ref<Print> print();
|
||||
|
||||
Clone<Flow> flow(FlowRole role, double layer_height, bool bridge, bool first_layer, double width, PrintObject* object)
|
||||
%code%{ RETVAL = THIS->flow(role, layer_height, bridge, first_layer, width, *object); %};
|
||||
};
|
||||
|
||||
%name{Slic3r::Print::Object} class PrintObject {
|
||||
|
Loading…
Reference in New Issue
Block a user