diff options
author | Alessandro Ranellucci <aar@cpan.org> | 2011-11-13 22:08:19 +0400 |
---|---|---|
committer | Alessandro Ranellucci <aar@cpan.org> | 2011-11-13 22:08:19 +0400 |
commit | 75a71a23a59407da4ae808bb62a7b58b6f08d217 (patch) | |
tree | 48f9a4fb201229c8c98258edd88dd02e3d14ec05 /lib/Slic3r/STL.pm | |
parent | 097b8d9acbccd5ac99ec823737c14df4f926a0d7 (diff) |
New --first-layer-height-ratio option. #36
Diffstat (limited to 'lib/Slic3r/STL.pm')
-rw-r--r-- | lib/Slic3r/STL.pm | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/lib/Slic3r/STL.pm b/lib/Slic3r/STL.pm index 602c69d36..6fc7ff80c 100644 --- a/lib/Slic3r/STL.pm +++ b/lib/Slic3r/STL.pm @@ -87,6 +87,10 @@ sub parse_file { } } + # remove last layer if empty + # (we might have created it because of the $max_layer = ... + 1 code below) + pop @{$print->layers} if !@{$print->layers->[-1]->surfaces} && !@{$print->layers->[-1]->lines}; + return $print; } @@ -110,8 +114,11 @@ sub _facet { } # calculate the layer extents - my $min_layer = int($min_z * $Slic3r::resolution / $Slic3r::layer_height); - my $max_layer = int($max_z * $Slic3r::resolution / $Slic3r::layer_height); + # (the -1 and +1 here are used as a quick and dirty replacement for some + # complex calculation of the first layer height ratio logic) + my $min_layer = int($min_z * $Slic3r::resolution / $Slic3r::layer_height) - 1; + $min_layer = 0 if $min_layer < 0; + my $max_layer = int($max_z * $Slic3r::resolution / $Slic3r::layer_height) + 1; Slic3r::debugf "layers: min = %s, max = %s\n", $min_layer, $max_layer; # reorder vertices so that the first one is the one with lowest Z @@ -131,7 +138,7 @@ sub _facet { sub intersect_facet { my $self = shift; my ($vertices, $z) = @_; - + printf "Slicing at $z\n"; # build the three segments of the triangle facet my @edges = ( [ $vertices->[0], $vertices->[1] ], |