Skip to content

Commit

Permalink
Better pruning of thin walls to avoid unwanted extra extrusions. Incl…
Browse files Browse the repository at this point in the history
…udes regression test. supermerill#1794

Conflicts:

	lib/Slic3r/Layer/Region.pm
  • Loading branch information
alranel committed Mar 1, 2014
1 parent a344d68 commit 2295d48
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 5 deletions.
20 changes: 17 additions & 3 deletions lib/Slic3r/Layer/Region.pm
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,14 @@ sub make_perimeters {
# the minimum thickness of a single loop is:
# width/2 + spacing/2 + spacing/2 + width/2
@offsets = @{offset2(\@last, -(0.5*$pwidth + 0.5*$pspacing - 1), +(0.5*$pspacing - 1))};

# look for thin walls
if ($self->config->thin_walls) {
my $diff = diff_ex(
\@last,
offset(\@offsets, +0.5*$pwidth),
);
push @thin_walls, grep abs($_->area) >= $gap_area_threshold, @$diff;
push @thin_walls, @$diff;
}
} else {
@offsets = @{offset2(\@last, -(1.5*$pspacing - 1), +(0.5*$pspacing - 1))};
Expand Down Expand Up @@ -222,15 +222,29 @@ sub make_perimeters {
$self->perimeters->append(@loops);

# process thin walls by collapsing slices to single passes
my $min_thin_wall_width = $pwidth/3;
my $min_thin_wall_length = 2*$pwidth;
@thin_walls = @{offset2_ex([ map @$_, @thin_walls ], -0.5*$min_thin_wall_width, +0.5*$min_thin_wall_width)};
if (@thin_walls) {
if (0) {
require "Slic3r/SVG.pm";
Slic3r::SVG::output(
"thin_walls.svg",
no_arrows => 1,
expolygons => \@thin_walls,
red_polylines => [ map $_->polygon->split_at_first_point, @{$self->perimeters} ],
);
}

my @p = map $_->medial_axis($pspacing), @thin_walls;
my @paths = ();
for my $p (@p) {
next if $p->length <= $pspacing * 2;
next if $p->length < $min_thin_wall_length;
my %params = (
role => EXTR_ROLE_EXTERNAL_PERIMETER,
mm3_per_mm => $mm3_per_mm,
);
printf "len = %s\n", unscale($p->length);
push @paths, $p->isa('Slic3r::Polygon')
? Slic3r::ExtrusionLoop->new(polygon => $p, %params)
: Slic3r::ExtrusionPath->new(polyline => $p, %params);
Expand Down
4 changes: 2 additions & 2 deletions lib/Slic3r/SVG.pm
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ sub output {

my $g = $svg->group(
style => {
'stroke-width' => 2,
'stroke-width' => 0,
'stroke' => $colour || 'black',
'fill' => ($type !~ /polygons/ ? 'none' : ($colour || 'grey')),
'fill-type' => $filltype,
Expand All @@ -68,7 +68,7 @@ sub output {

my $g = $svg->group(
style => {
'stroke-width' => 2,
'stroke-width' => ($method eq 'polyline') ? 1 : 0,
'stroke' => $colour || 'black',
'fill' => ($type !~ /polygons/ ? 'none' : ($colour || 'grey')),
},
Expand Down
Loading

0 comments on commit 2295d48

Please sign in to comment.