Bugfix: some solid layers were skipped. #47

This commit is contained in:
Alessandro Ranellucci 2011-11-16 14:53:30 +01:00
parent 9ab81880c9
commit 47c0da8110
2 changed files with 12 additions and 36 deletions

View File

@ -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);

View File

@ -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",
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} ],
);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);
);
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};