From 47c0da8110f3b01965a6070f464b523fd9c6e56a Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Wed, 16 Nov 2011 14:53:30 +0100 Subject: [PATCH] Bugfix: some solid layers were skipped. #47 --- lib/Slic3r/Layer.pm | 4 ++-- lib/Slic3r/Print.pm | 44 ++++++++++---------------------------------- 2 files changed, 12 insertions(+), 36 deletions(-) diff --git a/lib/Slic3r/Layer.pm b/lib/Slic3r/Layer.pm index 52d79ce7b..82088ae69 100644 --- a/lib/Slic3r/Layer.pm +++ b/lib/Slic3r/Layer.pm @@ -4,7 +4,7 @@ use Moo; use Math::Clipper ':all'; use Slic3r::Geometry qw(polygon_lines points_coincide angle3points polyline_lines nearest_point line_length collinear X Y A B PI); -use Slic3r::Geometry::Clipper qw(safety_offset union_ex); +use Slic3r::Geometry::Clipper qw(safety_offset union_ex PFT_EVENODD); use XXX; # a sequential number of layer, starting at 0 @@ -301,7 +301,7 @@ sub make_surfaces { } { - my $expolygons = union_ex([ @polygons ]); + my $expolygons = union_ex([ @polygons ], PFT_EVENODD); Slic3r::debugf " %d surface(s) having %d holes detected from %d polylines\n", scalar(@$expolygons), scalar(map $_->holes, @$expolygons), scalar(@polygons); diff --git a/lib/Slic3r/Print.pm b/lib/Slic3r/Print.pm index d5641b92d..f87e95488 100644 --- a/lib/Slic3r/Print.pm +++ b/lib/Slic3r/Print.pm @@ -103,23 +103,6 @@ sub detect_surfaces_type { if ($upper_layer) { # offset upper layer surfaces by extrusion_width * perimeters @top = $surface_difference->($layer->surfaces, $upper_layer->surfaces, 'top'); - - # now check whether each resulting top surfaces is large enough to have its - # own perimeters or whether it may be sufficient to use the lower layer's - # perimeters - - # offset upper layer's surfaces - my $upper_surfaces_offsetted; - { - my $distance = $Slic3r::flow_width * ($Slic3r::perimeter_offsets + 1) / $Slic3r::resolution; - $upper_surfaces_offsetted = offset([ map $_->p, @{$upper_layer->surfaces} ], $distance, 100, JT_MITER, 2); - } - - @top = grep { - my $surface = $_; - my $diff = diff_ex([ map $_->p, $surface ], $upper_surfaces_offsetted); - @$diff; - } @top; } else { # if no upper layer, all surfaces of this one are solid @top = @{$layer->surfaces}; @@ -146,25 +129,18 @@ sub detect_surfaces_type { @{$surface->contour->points} = map Slic3r::Point->new($_), @{ $offset->[0] }; } - use Slic3r::SVG; - Slic3r::SVG::output(undef, "layer_" . $layer->id . "_diff.svg", - green_polygons => [ map $_->p, @{$layer->surfaces} ], - red_polygons => [ map $_->p, @{$lower_layer->surfaces} ], - );exit if $layer->id == 3; - - # offset lower layer's surfaces - my $lower_surfaces_offsetted; - { - my $distance = $Slic3r::flow_width * ($Slic3r::perimeter_offsets + 1) / $Slic3r::resolution; - $lower_surfaces_offsetted = offset([ map $_->p, @{$lower_layer->surfaces} ], $distance, 100, JT_MITER, 2); + if (0) { + require "Slic3r/SVG.pm"; + Slic3r::SVG::output(undef, "layer_" . $layer->id . "_surfaces.svg", + green_polygons => [ map $_->p, @{$layer->surfaces} ], + red_polygons => [ map $_->p, @{$lower_layer->surfaces} ], + ); + Slic3r::SVG::output(undef, "layer_" . $layer->id . "_diff.svg", + red_polygons => [ map $_->p, @bottom ], + ); + exit if $layer->id == 3; } - @bottom = grep { - my $surface = $_; - my $diff = diff_ex([ map $_->p, $surface ], $lower_surfaces_offsetted); - @$diff; - } @bottom; - } else { # if no lower layer, all surfaces of this one are solid @bottom = @{$layer->surfaces};