Fixed regression in bridging caused by error in porting. Includes regression test. #3175

This commit is contained in:
Alessandro Ranellucci 2016-03-18 22:19:49 +01:00
parent e2aae39f15
commit 5ff7511a14
3 changed files with 41 additions and 6 deletions

View file

@ -118,6 +118,13 @@ sub mesh {
$facets = [
[0,1,2],[3,4,5],[2,1,4],[2,4,3],[2,3,5],[2,5,0],[5,4,1],[5,1,0]
];
} elsif ($name eq 'bridge') {
$vertices = [
[75,84.5,8],[125,84.5,8],[75,94.5,8],[120,84.5,5],[125,94.5,8],[75,84.5,0],[80,84.5,5],[125,84.5,0],[125,94.5,0],[80,94.5,5],[75,94.5,0],[120,94.5,5],[120,84.5,0],[80,94.5,0],[80,84.5,0],[120,94.5,0]
];
$facets = [
[0,1,2],[1,0,3],[2,1,4],[2,5,0],[0,6,3],[1,3,7],[1,8,4],[4,9,2],[10,5,2],[5,6,0],[6,11,3],[3,12,7],[7,8,1],[4,8,11],[4,11,9],[9,10,2],[10,13,5],[14,6,5],[9,11,6],[11,12,3],[12,8,7],[11,8,15],[13,10,9],[5,13,14],[14,13,6],[6,13,9],[15,12,11],[15,8,12]
];
} else {
return undef;
}

View file

@ -1,4 +1,4 @@
use Test::More tests => 14;
use Test::More tests => 16;
use strict;
use warnings;
@ -107,4 +107,30 @@ sub check_angle {
return defined $result && $result>=0 && abs($delta) < $tolerance;
}
{
my $config = Slic3r::Config->new_from_defaults;
$config->set('top_solid_layers', 0); # to prevent bridging on sparse infill
$config->set('bridge_speed', 99);
my $print = Slic3r::Test::init_print('bridge', config => $config);
my %extrusions = (); # angle => length
Slic3r::GCode::Reader->new->parse(Slic3r::Test::gcode($print), sub {
my ($self, $cmd, $args, $info) = @_;
if ($cmd eq 'G1' && ($args->{F} // $self->F)/60 == $config->bridge_speed) {
my $line = Slic3r::Line->new_scale(
[ $self->X, $self->Y ],
[ $info->{new_X}, $info->{new_Y} ],
);
my $angle = $line->direction;
$extrusions{$angle} //= 0;
$extrusions{$angle} += $line->length;
}
});
ok !!%extrusions, "bridge is generated";
my ($main_angle) = sort { $extrusions{$b} <=> $extrusions{$a} } keys %extrusions;
is $main_angle, 0, "bridge has the expected direction";
}
__END__

View file

@ -115,12 +115,14 @@ LayerRegion::process_external_surfaces(const Layer* lower_layer)
printf("Processing bridge at layer %zu:\n", this->layer()->id();
#endif
if (bd.detect_angle() && this->layer()->object()->config.support_material) {
if (bd.detect_angle()) {
angle = bd.angle;
Polygons coverage = bd.coverage();
this->bridged.insert(this->bridged.end(), coverage.begin(), coverage.end());
this->unsupported_bridge_edges.append(bd.unsupported_edges());
if (this->layer()->object()->config.support_material) {
Polygons coverage = bd.coverage();
this->bridged.insert(this->bridged.end(), coverage.begin(), coverage.end());
this->unsupported_bridge_edges.append(bd.unsupported_edges());
}
}
}