Accept either absolute or relative values for --first-layer-height. #151
This commit is contained in:
parent
896c7e952e
commit
16b774603c
@ -136,9 +136,7 @@ The author is Alessandro Ranellucci.
|
|||||||
|
|
||||||
Accuracy options:
|
Accuracy options:
|
||||||
--layer-height Layer height in mm (default: 0.4)
|
--layer-height Layer height in mm (default: 0.4)
|
||||||
--first-layer-height-ratio
|
--first-layer-height Layer height for first layer (mm or %, default: 100%)
|
||||||
Multiplication factor for the height to slice and print the first
|
|
||||||
layer with (> 0, default: 1)
|
|
||||||
--infill-every-layers
|
--infill-every-layers
|
||||||
Infill every N layers (default: 1)
|
Infill every N layers (default: 1)
|
||||||
|
|
||||||
|
@ -95,7 +95,8 @@ our $scaling_factor = 0.000001;
|
|||||||
our $resolution = 0.01;
|
our $resolution = 0.01;
|
||||||
our $small_perimeter_length = (6.5 / $scaling_factor)*2*PI;
|
our $small_perimeter_length = (6.5 / $scaling_factor)*2*PI;
|
||||||
our $layer_height = 0.4;
|
our $layer_height = 0.4;
|
||||||
our $first_layer_height_ratio = 1;
|
our $first_layer_height = '100%'; # mm or %
|
||||||
|
our $_first_layer_height = undef; # mm (computed)
|
||||||
our $infill_every_layers = 1;
|
our $infill_every_layers = 1;
|
||||||
|
|
||||||
# flow options
|
# flow options
|
||||||
|
@ -186,9 +186,9 @@ our $Options = {
|
|||||||
cli => 'layer-height=f',
|
cli => 'layer-height=f',
|
||||||
type => 'f',
|
type => 'f',
|
||||||
},
|
},
|
||||||
'first_layer_height_ratio' => {
|
'first_layer_height' => {
|
||||||
label => 'First layer height ratio',
|
label => 'First layer height (mm or %)',
|
||||||
cli => 'first-layer-height-ratio=f',
|
cli => 'first-layer-height=f',
|
||||||
type => 'f',
|
type => 'f',
|
||||||
},
|
},
|
||||||
'infill_every_layers' => {
|
'infill_every_layers' => {
|
||||||
@ -520,7 +520,7 @@ sub load {
|
|||||||
|
|
||||||
# handle legacy options
|
# handle legacy options
|
||||||
next if $ignore{$key};
|
next if $ignore{$key};
|
||||||
if ($key =~ /^(?:extrusion_width|bottom_layer_speed)_ratio$/) {
|
if ($key =~ /^(?:extrusion_width|bottom_layer_speed|first_layer_height)_ratio$/) {
|
||||||
$key = $1;
|
$key = $1;
|
||||||
$key =~ s/^bottom_layer_speed$/first_layer_speed/;
|
$key =~ s/^bottom_layer_speed$/first_layer_speed/;
|
||||||
$val = $val =~ /^\d+(\.\d+)?$/ ? ($val*100) . "%" : 0;
|
$val = $val =~ /^\d+(\.\d+)?$/ ? ($val*100) . "%" : 0;
|
||||||
@ -571,9 +571,12 @@ sub validate {
|
|||||||
die "--layer-height must be a multiple of print resolution\n"
|
die "--layer-height must be a multiple of print resolution\n"
|
||||||
if $Slic3r::layer_height / $Slic3r::scaling_factor % 1 != 0;
|
if $Slic3r::layer_height / $Slic3r::scaling_factor % 1 != 0;
|
||||||
|
|
||||||
# --first-layer-height-ratio
|
# --first-layer-height
|
||||||
die "Invalid value for --first-layer-height-ratio\n"
|
die "Invalid value for --first-layer-height\n"
|
||||||
if $Slic3r::first_layer_height_ratio < 0;
|
if $Slic3r::first_layer_height !~ /^(?:\d+(?:\.\d+)?)%?$/;
|
||||||
|
$Slic3r::_first_layer_height = $Slic3r::first_layer_height =~ /^(\d+(?:\.\d+)?)%$/
|
||||||
|
? ($Slic3r::layer_height * $1/100)
|
||||||
|
: $Slic3r::first_layer_height;
|
||||||
|
|
||||||
# --filament-diameter
|
# --filament-diameter
|
||||||
die "Invalid value for --filament-diameter\n"
|
die "Invalid value for --filament-diameter\n"
|
||||||
@ -585,9 +588,7 @@ sub validate {
|
|||||||
die "--layer-height can't be greater than --nozzle-diameter\n"
|
die "--layer-height can't be greater than --nozzle-diameter\n"
|
||||||
if $Slic3r::layer_height > $Slic3r::nozzle_diameter;
|
if $Slic3r::layer_height > $Slic3r::nozzle_diameter;
|
||||||
die "First layer height can't be greater than --nozzle-diameter\n"
|
die "First layer height can't be greater than --nozzle-diameter\n"
|
||||||
if ($Slic3r::layer_height * $Slic3r::first_layer_height_ratio) > $Slic3r::nozzle_diameter;
|
if $Slic3r::_first_layer_height > $Slic3r::nozzle_diameter;
|
||||||
die "First layer height can't be zero or negative\n"
|
|
||||||
if ($Slic3r::layer_height * $Slic3r::first_layer_height_ratio) <= 0;
|
|
||||||
|
|
||||||
if ($Slic3r::extrusion_width) {
|
if ($Slic3r::extrusion_width) {
|
||||||
$Slic3r::flow_width = $Slic3r::extrusion_width =~ /^(\d+(?:\.\d+)?)%$/
|
$Slic3r::flow_width = $Slic3r::extrusion_width =~ /^(\d+(?:\.\d+)?)%$/
|
||||||
|
@ -40,7 +40,7 @@ sub new {
|
|||||||
},
|
},
|
||||||
accuracy => {
|
accuracy => {
|
||||||
title => 'Accuracy',
|
title => 'Accuracy',
|
||||||
options => [qw(layer_height first_layer_height_ratio infill_every_layers)],
|
options => [qw(layer_height first_layer_height infill_every_layers)],
|
||||||
},
|
},
|
||||||
print => {
|
print => {
|
||||||
title => 'Print settings',
|
title => 'Print settings',
|
||||||
|
@ -16,6 +16,10 @@ has 'id' => (
|
|||||||
|
|
||||||
has 'slicing_errors' => (is => 'rw');
|
has 'slicing_errors' => (is => 'rw');
|
||||||
|
|
||||||
|
has 'slice_z' => (is => 'lazy');
|
||||||
|
has 'print_z' => (is => 'lazy');
|
||||||
|
has 'height' => (is => 'lazy');
|
||||||
|
|
||||||
# collection of spare segments generated by slicing the original geometry;
|
# collection of spare segments generated by slicing the original geometry;
|
||||||
# these need to be merged in continuos (closed) polylines
|
# these need to be merged in continuos (closed) polylines
|
||||||
has 'lines' => (
|
has 'lines' => (
|
||||||
@ -74,28 +78,25 @@ has 'fills' => (
|
|||||||
);
|
);
|
||||||
|
|
||||||
# Z used for slicing
|
# Z used for slicing
|
||||||
sub slice_z {
|
sub _build_slice_z {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
|
|
||||||
if ($self->id == 0) {
|
if ($self->id == 0) {
|
||||||
return ($Slic3r::layer_height * $Slic3r::first_layer_height_ratio) / 2 / $Slic3r::scaling_factor;
|
return $Slic3r::_first_layer_height / 2 / $Slic3r::scaling_factor;
|
||||||
}
|
}
|
||||||
return (($Slic3r::layer_height * $Slic3r::first_layer_height_ratio)
|
return ($Slic3r::_first_layer_height + (($self->id-1) * $Slic3r::layer_height) + ($Slic3r::layer_height/2))
|
||||||
+ (($self->id-1) * $Slic3r::layer_height)
|
/ $Slic3r::scaling_factor; #/
|
||||||
+ ($Slic3r::layer_height/2)) / $Slic3r::scaling_factor;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Z used for printing
|
# Z used for printing
|
||||||
sub print_z {
|
sub _build_print_z {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
return (($Slic3r::layer_height * $Slic3r::first_layer_height_ratio)
|
return ($Slic3r::_first_layer_height + ($self->id * $Slic3r::layer_height)) / $Slic3r::scaling_factor;
|
||||||
+ ($self->id * $Slic3r::layer_height)) / $Slic3r::scaling_factor;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sub height {
|
sub _build_height {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
return $self->id == 0
|
return $self->id == 0 ? $Slic3r::_first_layer_height : $Slic3r::layer_height;
|
||||||
? ($Slic3r::layer_height * $Slic3r::first_layer_height_ratio)
|
|
||||||
: $Slic3r::layer_height;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sub add_line {
|
sub add_line {
|
||||||
|
@ -390,10 +390,9 @@ sub slice_facet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# calculate the layer extents
|
# calculate the layer extents
|
||||||
my $first_layer_height = $Slic3r::layer_height * $Slic3r::first_layer_height_ratio;
|
my $min_layer = int((unscale($min_z) - ($Slic3r::_first_layer_height + $Slic3r::layer_height / 2)) / $Slic3r::layer_height) - 2;
|
||||||
my $min_layer = int((unscale($min_z) - ($first_layer_height + $Slic3r::layer_height / 2)) / $Slic3r::layer_height) - 2;
|
|
||||||
$min_layer = 0 if $min_layer < 0;
|
$min_layer = 0 if $min_layer < 0;
|
||||||
my $max_layer = int((unscale($max_z) - ($first_layer_height + $Slic3r::layer_height / 2)) / $Slic3r::layer_height) + 2;
|
my $max_layer = int((unscale($max_z) - ($Slic3r::_first_layer_height + $Slic3r::layer_height / 2)) / $Slic3r::layer_height) + 2;
|
||||||
Slic3r::debugf "layers: min = %s, max = %s\n", $min_layer, $max_layer;
|
Slic3r::debugf "layers: min = %s, max = %s\n", $min_layer, $max_layer;
|
||||||
|
|
||||||
my $lines = {}; # layer_id => [ lines ]
|
my $lines = {}; # layer_id => [ lines ]
|
||||||
|
@ -180,9 +180,7 @@ $j
|
|||||||
|
|
||||||
Accuracy options:
|
Accuracy options:
|
||||||
--layer-height Layer height in mm (default: $Slic3r::layer_height)
|
--layer-height Layer height in mm (default: $Slic3r::layer_height)
|
||||||
--first-layer-height-ratio
|
--first-layer-height Layer height for first layer (mm or %, default: $Slic3r::first_layer_height)
|
||||||
Multiplication factor for the height to slice and print the first
|
|
||||||
layer with (> 0, default: $Slic3r::first_layer_height_ratio)
|
|
||||||
--infill-every-layers
|
--infill-every-layers
|
||||||
Infill every N layers (default: $Slic3r::infill_every_layers)
|
Infill every N layers (default: $Slic3r::infill_every_layers)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user