diff --git a/lib/Slic3r/Extruder.pm b/lib/Slic3r/Extruder.pm index b04546971..83f422960 100644 --- a/lib/Slic3r/Extruder.pm +++ b/lib/Slic3r/Extruder.pm @@ -75,8 +75,11 @@ sub extrude_loop { # split the loop at the starting point and make a path my $extrusion_path = $loop->split_at($start_at); - # clip the path to avoid the extruder to get exactly on the first point of the loop + # clip the path to avoid the extruder to get exactly on the first point of the loop; + # if polyline was shorter than the clipping distance we'd get a null polyline, so + # we discard it in that case $extrusion_path->clip_end(scale $Slic3r::flow_width * 0.15); + return '' if !@{$extrusion_path->polyline}; # extrude along the path return $self->extrude_path($extrusion_path, $description); diff --git a/lib/Slic3r/ExtrusionPath.pm b/lib/Slic3r/ExtrusionPath.pm index 750b9c5b6..6927cc0b0 100644 --- a/lib/Slic3r/ExtrusionPath.pm +++ b/lib/Slic3r/ExtrusionPath.pm @@ -7,7 +7,7 @@ use Slic3r::Geometry qw(PI X Y epsilon deg2rad rotate_points); has 'polyline' => ( is => 'ro', required => 1, - handles => [qw(merge_continuous_lines lines)], + handles => [qw(merge_continuous_lines lines length)], ); # this integer represents the vertical thickness of the extrusion diff --git a/lib/Slic3r/Polyline.pm b/lib/Slic3r/Polyline.pm index e7e886678..10084e81d 100644 --- a/lib/Slic3r/Polyline.pm +++ b/lib/Slic3r/Polyline.pm @@ -70,6 +70,13 @@ sub reverse { @$self = CORE::reverse @$self; } +sub length { + my $self = shift; + my $length = 0; + $length += $_->length for $self->lines; + return $length; +} + sub nearest_point_to { my $self = shift; my ($point) = @_;