From 04d2231901e0068e7979cdcddbec637e4bab74af Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Sat, 30 Mar 2013 11:22:12 +0100 Subject: [PATCH] Bugfix: is_printable() wasn't discarding narrow ring-shaped top/bottom surfaces because it was only considering the contour. This caused extra shell material even in hollow prints. #1049 --- lib/Slic3r/ExPolygon.pm | 11 +++++++++++ lib/Slic3r/ExtrusionPath.pm | 2 -- lib/Slic3r/Polygon.pm | 2 +- lib/Slic3r/Print/Object.pm | 4 ++-- 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/lib/Slic3r/ExPolygon.pm b/lib/Slic3r/ExPolygon.pm index f3742d3c5..ac1d0fb35 100644 --- a/lib/Slic3r/ExPolygon.pm +++ b/lib/Slic3r/ExPolygon.pm @@ -62,6 +62,17 @@ sub is_valid { && (!first { $_->is_counter_clockwise } $self->holes); } +# returns false if the expolygon is too tight to be printed +sub is_printable { + my $self = shift; + my ($width) = @_; + + # try to get an inwards offset + # for a distance equal to half of the extrusion width; + # if no offset is possible, then expolygon is not printable. + return Slic3r::Geometry::Clipper::offset($self, -$width / 2) ? 1 : 0; +} + sub boost_polygon { my $self = shift; return Boost::Geometry::Utils::polygon(@$self); diff --git a/lib/Slic3r/ExtrusionPath.pm b/lib/Slic3r/ExtrusionPath.pm index a150a9c72..87f6d3a14 100644 --- a/lib/Slic3r/ExtrusionPath.pm +++ b/lib/Slic3r/ExtrusionPath.pm @@ -97,8 +97,6 @@ sub first_point { return $self->polyline->[0]; } -sub is_printable { 1 } - sub is_perimeter { my $self = shift; return $self->role == EXTR_ROLE_PERIMETER diff --git a/lib/Slic3r/Polygon.pm b/lib/Slic3r/Polygon.pm index a89cc0791..b3cf77d09 100644 --- a/lib/Slic3r/Polygon.pm +++ b/lib/Slic3r/Polygon.pm @@ -128,7 +128,7 @@ sub subdivide { } } -# returns false if the polyline is too tight to be printed +# returns false if the polygon is too tight to be printed sub is_printable { my $self = shift; my ($width) = @_; diff --git a/lib/Slic3r/Print/Object.pm b/lib/Slic3r/Print/Object.pm index a1193217f..7968ac61f 100644 --- a/lib/Slic3r/Print/Object.pm +++ b/lib/Slic3r/Print/Object.pm @@ -360,8 +360,8 @@ sub detect_surfaces_type { [ map @$_, @$clip_surfaces ], 1, ); - return grep $_->contour->is_printable($layerm->perimeter_flow->scaled_width), - map Slic3r::Surface->new(expolygon => $_, surface_type => $result_type), + return map Slic3r::Surface->new(expolygon => $_, surface_type => $result_type), + grep $_->is_printable($layerm->perimeter_flow->scaled_width), @$expolygons; };