Test bridges when infill flow is larger than perimeter flow. #1917

This commit is contained in:
Alessandro Ranellucci 2014-04-09 12:09:25 +02:00
parent 8e5ca0ab76
commit 26bdbf0210

View File

@ -1,4 +1,4 @@
use Test::More tests => 4; use Test::More tests => 8;
use strict; use strict;
use warnings; use warnings;
@ -12,14 +12,9 @@ use Slic3r;
use Slic3r::Geometry qw(scale epsilon rad2deg PI); use Slic3r::Geometry qw(scale epsilon rad2deg PI);
use Slic3r::Test; use Slic3r::Test;
my $flow = Slic3r::Flow->new(width => 0.5, spacing => 0.45, nozzle_diameter => 0.5); my $full_test = sub {
my $bd = Slic3r::Layer::BridgeDetector->new( my ($bd) = @_;
lower_slices => [], {
perimeter_flow => $flow,
infill_flow => $flow,
);
{
my $test = sub { my $test = sub {
my ($bridge_size, $expected_angle) = @_; my ($bridge_size, $expected_angle) = @_;
@ -34,14 +29,14 @@ my $bd = Slic3r::Layer::BridgeDetector->new(
$bridge = Slic3r::ExPolygon->new($bridge); $bridge = Slic3r::ExPolygon->new($bridge);
$bd->lower_slices([$lower]); $bd->lower_slices([$lower]);
ok check_angle($bd->detect_angle($bridge), $expected_angle), 'correct bridge angle for O-shaped overhang'; ok check_angle($bd, $bridge, $expected_angle), 'correct bridge angle for O-shaped overhang';
}; };
$test->([20,10], 90); $test->([20,10], 90);
$test->([10,20], 0); $test->([10,20], 0);
} }
{ {
my $bridge = Slic3r::ExPolygon->new( my $bridge = Slic3r::ExPolygon->new(
Slic3r::Polygon->new_scale([0,0], [20,0], [20,10], [0,10]), Slic3r::Polygon->new_scale([0,0], [20,0], [20,10], [0,10]),
); );
@ -56,10 +51,10 @@ my $bd = Slic3r::Layer::BridgeDetector->new(
$lower->[1]->translate(scale 22, 0); $lower->[1]->translate(scale 22, 0);
$bd->lower_slices($lower); $bd->lower_slices($lower);
ok check_angle($bd->detect_angle($bridge), 0), 'correct bridge angle for two-sided bridge'; ok check_angle($bd, $bridge, 0), 'correct bridge angle for two-sided bridge';
} }
{ {
my $bridge = Slic3r::ExPolygon->new( my $bridge = Slic3r::ExPolygon->new(
Slic3r::Polygon->new_scale([0,0], [20,0], [10,10], [0,10]), Slic3r::Polygon->new_scale([0,0], [20,0], [10,10], [0,10]),
); );
@ -71,11 +66,28 @@ my $bd = Slic3r::Layer::BridgeDetector->new(
$_->translate(scale 20, scale 20) for $bridge, @$lower; # avoid negative coordinates for easier SVG preview $_->translate(scale 20, scale 20) for $bridge, @$lower; # avoid negative coordinates for easier SVG preview
$bd->lower_slices($lower); $bd->lower_slices($lower);
ok check_angle($bd->detect_angle($bridge), 135), 'correct bridge angle for C-shaped overhang'; ok check_angle($bd, $bridge, 135), 'correct bridge angle for C-shaped overhang';
} }
};
my $flow = Slic3r::Flow->new(width => 0.5, spacing => 0.45, nozzle_diameter => 0.5);
my $bd = Slic3r::Layer::BridgeDetector->new(
lower_slices => [],
perimeter_flow => $flow,
infill_flow => $flow,
);
$full_test->($bd);
# infill flow larger than perimeter flow
$bd->infill_flow(Slic3r::Flow->new(width => 0.9, spacing => 0.85, nozzle_diameter => 0.5));
$full_test->($bd);
sub check_angle { sub check_angle {
my ($result, $expected) = @_; my ($bd, $bridge, $expected) = @_;
my $result = $bd->detect_angle($bridge);
# our epsilon is equal to the steps used by the bridge detection algorithm # our epsilon is equal to the steps used by the bridge detection algorithm
###use XXX; YYY [ rad2deg($result), $expected ]; ###use XXX; YYY [ rad2deg($result), $expected ];