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 Math::Clipper ':all';
use Slic3r::Geometry qw(polygon_lines points_coincide angle3points polyline_lines nearest_point use Slic3r::Geometry qw(polygon_lines points_coincide angle3points polyline_lines nearest_point
line_length collinear X Y A B PI); 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; use XXX;
# a sequential number of layer, starting at 0 # 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", Slic3r::debugf " %d surface(s) having %d holes detected from %d polylines\n",
scalar(@$expolygons), scalar(map $_->holes, @$expolygons), scalar(@polygons); scalar(@$expolygons), scalar(map $_->holes, @$expolygons), scalar(@polygons);

View File

@ -103,23 +103,6 @@ sub detect_surfaces_type {
if ($upper_layer) { if ($upper_layer) {
# offset upper layer surfaces by extrusion_width * perimeters # offset upper layer surfaces by extrusion_width * perimeters
@top = $surface_difference->($layer->surfaces, $upper_layer->surfaces, 'top'); @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 { } else {
# if no upper layer, all surfaces of this one are solid # if no upper layer, all surfaces of this one are solid
@top = @{$layer->surfaces}; @top = @{$layer->surfaces};
@ -146,25 +129,18 @@ sub detect_surfaces_type {
@{$surface->contour->points} = map Slic3r::Point->new($_), @{ $offset->[0] }; @{$surface->contour->points} = map Slic3r::Point->new($_), @{ $offset->[0] };
} }
use Slic3r::SVG; if (0) {
Slic3r::SVG::output(undef, "layer_" . $layer->id . "_diff.svg", require "Slic3r/SVG.pm";
green_polygons => [ map $_->p, @{$layer->surfaces} ], Slic3r::SVG::output(undef, "layer_" . $layer->id . "_surfaces.svg",
red_polygons => [ map $_->p, @{$lower_layer->surfaces} ], green_polygons => [ map $_->p, @{$layer->surfaces} ],
);exit if $layer->id == 3; red_polygons => [ map $_->p, @{$lower_layer->surfaces} ],
);
# offset lower layer's surfaces Slic3r::SVG::output(undef, "layer_" . $layer->id . "_diff.svg",
my $lower_surfaces_offsetted; red_polygons => [ map $_->p, @bottom ],
{ );
my $distance = $Slic3r::flow_width * ($Slic3r::perimeter_offsets + 1) / $Slic3r::resolution; exit if $layer->id == 3;
$lower_surfaces_offsetted = offset([ map $_->p, @{$lower_layer->surfaces} ], $distance, 100, JT_MITER, 2);
} }
@bottom = grep {
my $surface = $_;
my $diff = diff_ex([ map $_->p, $surface ], $lower_surfaces_offsetted);
@$diff;
} @bottom;
} else { } else {
# if no lower layer, all surfaces of this one are solid # if no lower layer, all surfaces of this one are solid
@bottom = @{$layer->surfaces}; @bottom = @{$layer->surfaces};