diff options
author | Alessandro Ranellucci <aar@cpan.org> | 2011-11-13 21:41:12 +0400 |
---|---|---|
committer | Alessandro Ranellucci <aar@cpan.org> | 2011-11-13 21:41:12 +0400 |
commit | 097b8d9acbccd5ac99ec823737c14df4f926a0d7 (patch) | |
tree | 0ad9e4a488c12b14defc60e242d8082954310742 /lib/Slic3r/Print.pm | |
parent | b123194522b0fbc2c04fc526b622e98274011ca3 (diff) |
New --skirt-height option. #11
Diffstat (limited to 'lib/Slic3r/Print.pm')
-rw-r--r-- | lib/Slic3r/Print.pm | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/lib/Slic3r/Print.pm b/lib/Slic3r/Print.pm index c33f16b11..5a5b22206 100644 --- a/lib/Slic3r/Print.pm +++ b/lib/Slic3r/Print.pm @@ -2,6 +2,7 @@ package Slic3r::Print; use Moo; use Math::Clipper ':all'; +use Math::ConvexHull 1.0.4 qw(convex_hull); use Slic3r::Geometry qw(X Y); use Slic3r::Geometry::Clipper qw(explode_expolygons safety_offset diff_ex intersection_ex); use XXX; @@ -289,6 +290,30 @@ sub process_bridges { $_->process_bridges for @{ $self->layers }; } +sub extrude_skirt { + my $self = shift; + return unless $Slic3r::skirts > 0; + + # collect points from all layers contained in skirt height + my @points = (); + my @layers = map $self->layer($_), 0..($Slic3r::skirt_height-1); + push @points, map @$_, map $_->p, map @{ $_->surfaces }, @layers; + + # find out convex hull + my $convex_hull = convex_hull(\@points); + + # draw outlines from outside to inside + my @skirts = (); + for (my $i = $Slic3r::skirts - 1; $i >= 0; $i--) { + my $distance = ($Slic3r::skirt_distance + ($Slic3r::flow_width * $i)) / $Slic3r::resolution; + my $outline = offset([$convex_hull], $distance, $Slic3r::resolution * 100, JT_ROUND); + push @skirts, Slic3r::ExtrusionLoop->cast([ @{$outline->[0]} ]); + } + + # apply skirts to all layers + push @{$_->skirts}, @skirts for @layers; +} + sub extrude_perimeters { my $self = shift; |