Fix bug in regression infill causing bad clipping at very low layer heights. Includes regression test. #1669

Conflicts:

	lib/Slic3r/Fill/Rectilinear.pm
issue1834
Alessandro Ranellucci 2014-01-11 21:34:26 +01:00
parent 3084876e60
commit c99b9d91db
2 changed files with 31 additions and 7 deletions

View File

@ -60,12 +60,12 @@ sub fill_surface {
$x += $line_spacing;
}
# clip paths against a slightly offsetted expolygon, so that the first and last paths
# clip paths against a slightly larger expolygon, so that the first and last paths
# are kept even if the expolygon has vertical sides
# the minimum offset for preventing edge lines from being clipped is scaled_epsilon;
# however we use a larger offset to support expolygons with slightly skewed sides and
# not perfectly straight
my @polylines = @{intersection_pl(\@vertical_lines, $expolygon->offset($line_spacing*0.05))};
my @polylines = @{intersection_pl(\@vertical_lines, $expolygon->offset(scale 0.02))};
# connect lines
unless ($params{dont_connect} || !@polylines) { # prevent calling leftmost_point() on empty collections

View File

@ -2,15 +2,16 @@ use Test::More;
use strict;
use warnings;
plan tests => 34;
plan tests => 40;
BEGIN {
use FindBin;
use lib "$FindBin::Bin/../lib";
}
use List::Util qw(first);
use Slic3r;
use Slic3r::Geometry qw(scale X Y);
use Slic3r::Geometry qw(scale X Y convex_hull);
use Slic3r::Geometry::Clipper qw(diff_ex);
use Slic3r::Surface qw(:types);
use Slic3r::Test;
@ -166,11 +167,34 @@ sub scale_points (@) { map [scale $_->[X], scale $_->[Y]], @_ }
'chained path';
}
for my $pattern (qw(hilbertcurve concentric)) {
for my $pattern (qw(rectilinear honeycomb hilbertcurve concentric)) {
my $config = Slic3r::Config->new_from_defaults;
$config->set('fill_pattern', $pattern);
my $print = Slic3r::Test::init_print('20mm_cube', config => $config);
ok Slic3r::Test::gcode($print), "successful $pattern infill generation";
$config->set('perimeters', 1);
$config->set('skirts', 0);
$config->set('fill_density', 0.2);
$config->set('layer_height', 0.05);
$config->set('perimeter_extruder', 1);
$config->set('infill_extruder', 2);
my $print = Slic3r::Test::init_print('20mm_cube', config => $config, scale => 2);
ok my $gcode = Slic3r::Test::gcode($print), "successful $pattern infill generation";
my $tool = undef;
my @perimeter_points = my @infill_points = ();
Slic3r::GCode::Reader->new->parse($gcode, sub {
my ($self, $cmd, $args, $info) = @_;
if ($cmd =~ /^T(\d+)/) {
$tool = $1;
} elsif ($cmd eq 'G1' && $info->{extruding} && $info->{dist_XY} > 0) {
if ($tool == $config->perimeter_extruder-1) {
push @perimeter_points, Slic3r::Point->new_scale($args->{X}, $args->{Y});
} elsif ($tool == $config->infill_extruder-1) {
push @infill_points, Slic3r::Point->new_scale($args->{X}, $args->{Y});
}
}
});
my $convex_hull = convex_hull(\@perimeter_points);
ok !(defined first { !$convex_hull->contains_point($_) } @infill_points), "infill does not exceed perimeters ($pattern)";
}
{