Fixed regression in --infill-only-where-needed. Includes a minimal test suite for such feature. #1871

Conflicts:

	t/fill.t
visilibity
Alessandro Ranellucci 2014-04-18 21:40:27 +02:00
parent 15628a90ed
commit 62e19469bc
3 changed files with 54 additions and 8 deletions

View File

@ -566,7 +566,7 @@ sub clip_fill_surfaces {
# We only want infill under ceilings; this is almost like an
# internal support material.
my $additional_margin = scale 3;
my $additional_margin = scale 3*0;
my $overhangs = []; # arrayref of polygons
for my $layer_id (reverse 0..$#{$self->layers}) {
@ -605,10 +605,11 @@ sub clip_fill_surfaces {
# (thus we also consider perimeters)
if ($layer_id > 0) {
my $solid = diff(
[ map @$_, @{$layer->slices} ],
[ map $_->p, map @{$_->fill_surfaces}, @{$layer->regions} ],
[ map $_->p, @layer_internal ],
);
$overhangs = offset($solid, +$additional_margin);
push @$overhangs, map $_->p, @new_internal; # propagate upper overhangs
}
}

File diff suppressed because one or more lines are too long

View File

@ -2,17 +2,17 @@ use Test::More;
use strict;
use warnings;
plan tests => 42;
plan tests => 43;
BEGIN {
use FindBin;
use lib "$FindBin::Bin/../lib";
}
use List::Util qw(first);
use List::Util qw(first sum);
use Slic3r;
use Slic3r::Geometry qw(scale X Y convex_hull);
use Slic3r::Geometry::Clipper qw(union diff_ex);
use Slic3r::Geometry qw(X Y scale unscale convex_hull);
use Slic3r::Geometry::Clipper qw(union diff_ex offset);
use Slic3r::Surface qw(:types);
use Slic3r::Test;
@ -201,8 +201,46 @@ for my $pattern (qw(rectilinear honeycomb hilbertcurve concentric)) {
{
my $config = Slic3r::Config->new_from_defaults;
$config->set('infill_only_where_needed', 1);
my $print = Slic3r::Test::init_print('20mm_cube', config => $config);
ok my $gcode = Slic3r::Test::gcode($print), "successful G-code generation when infill_only_where_needed is set";
$config->set('bottom_solid_layers', 0);
$config->set('infill_extruder', 2);
$config->set('infill_extrusion_width', 0.5);
$config->set('cooling', 0); # for preventing speeds from being altered
$config->set('first_layer_speed', '100%'); # for preventing speeds from being altered
my $test = sub {
my $print = Slic3r::Test::init_print('pyramid', config => $config);
my $tool = undef;
my @infill_extrusions = (); # array of polylines
Slic3r::GCode::Reader->new->parse(Slic3r::Test::gcode($print), 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->infill_extruder-1) {
push @infill_extrusions, Slic3r::Line->new_scale(
[ $self->X, $self->Y ],
[ $info->{new_X}, $info->{new_Y} ],
);
}
}
});
return 0 if !@infill_extrusions; # prevent calling convex_hull() with no points
my $convex_hull = convex_hull([ map $_->pp, map @$_, @infill_extrusions ]);
return unscale unscale sum(map $_->area, @{offset([$convex_hull], scale(+$config->infill_extrusion_width/2))});
};
my $tolerance = 5; # mm^2
$config->set('solid_infill_below_area', 0);
ok $test->() < $tolerance,
'no infill is generated when using infill_only_where_needed on a pyramid';
$config->set('solid_infill_below_area', 70);
ok abs($test->() - $config->solid_infill_below_area) < $tolerance,
'infill is only generated under the forced solid shells';
}
{