Merge pull request #1956 from ledvinap/fix-bridges

Fix bridges
visilibity
Alessandro Ranellucci 2014-04-23 12:09:02 +02:00
commit d458a7c4d2
2 changed files with 11 additions and 8 deletions

View File

@ -89,16 +89,16 @@ sub detect_angle {
my $my_anchors = [ map $_->clone, @$anchors ];
# rotate everything - the center point doesn't matter
$_->rotate($angle, [0,0]) for @$my_clip_area, @$my_anchors;
$_->rotate(-$angle, [0,0]) for @$my_clip_area, @$my_anchors;
# generate lines in this direction
my $bounding_box = Slic3r::Geometry::BoundingBox->new_from_points([ map @$_, map @$_, @$my_anchors ]);
my @lines = ();
for (my $x = $bounding_box->x_min; $x <= $bounding_box->x_max; $x += $line_increment) {
for (my $y = $bounding_box->y_min; $y <= $bounding_box->y_max; $y+= $line_increment) {
push @lines, Slic3r::Polyline->new(
[$x, $bounding_box->y_min + scaled_epsilon],
[$x, $bounding_box->y_max - scaled_epsilon],
[$bounding_box->x_min, $y],
[$bounding_box->x_max, $y],
);
}
@ -143,7 +143,7 @@ sub detect_angle {
}
if (defined $self->angle) {
if ($self->angle >= PI - epsilon) {
if ($self->angle >= PI) {
$self->angle($self->angle - PI);
}

View File

@ -30,8 +30,8 @@ use Slic3r::Test;
ok check_angle([$lower], $bridge, $expected_angle, $tolerance), 'correct bridge angle for O-shaped overhang';
};
$test->([20,10], 0, 0);
$test->([10,20], 0, 90);
$test->([20,10], 0, 90);
$test->([10,20], 0, 0);
$test->([20,10], 45, 135, 20);
$test->([20,10], 135, 45, 20);
}
@ -81,7 +81,10 @@ sub check_angle {
# our epsilon is equal to the steps used by the bridge detection algorithm
###use XXX; YYY [ rad2deg($result), $expected ];
return defined $result && abs(rad2deg($result) - $expected) < $tolerance;
# returned value must be non-negative, check for that too
my $delta=rad2deg($result) - $expected;
$delta-=180 if $delta>=180 - epsilon;
return defined $result && $result>=0 && abs($delta) < $tolerance;
}
__END__