Merge branch 'master' into avoid-crossing-perimeters

Conflicts:
	lib/Slic3r/GCode.pm
	lib/Slic3r/Print.pm
This commit is contained in:
Alessandro Ranellucci 2013-01-26 21:45:17 +01:00
commit 61b164b539
21 changed files with 123 additions and 65 deletions

View file

@ -242,11 +242,7 @@ sub object_copies {
sub layer_count {
my $self = shift;
my $count = 0;
foreach my $object (@{$self->objects}) {
$count = @{$object->layers} if @{$object->layers} > $count;
}
return $count;
return max(map { scalar @{$_->layers} } @{$self->objects});
}
sub regions_count {
@ -472,7 +468,7 @@ sub export_svg {
my $output_file = $self->expanded_output_filepath($params{output_file});
$output_file =~ s/\.gcode$/.svg/i;
open my $fh, ">", $output_file or die "Failed to open $output_file for writing\n";
Slic3r::open(\my $fh, ">", $output_file) or die "Failed to open $output_file for writing\n";
print "Exporting to $output_file...";
my $print_size = $self->size;
print $fh sprintf <<"EOF", unscale($print_size->[X]), unscale($print_size->[Y]);
@ -550,10 +546,10 @@ sub make_skirt {
return unless $Slic3r::Config->skirts > 0;
# collect points from all layers contained in skirt height
my $skirt_height = $Slic3r::Config->skirt_height;
$skirt_height = $self->layer_count if $skirt_height > $self->layer_count;
my @points = ();
foreach my $obj_idx (0 .. $#{$self->objects}) {
my $skirt_height = $Slic3r::Config->skirt_height;
$skirt_height = $self->objects->[$obj_idx]->layer_count if $skirt_height > $self->objects->[$obj_idx]->layer_count;
my @layers = map $self->objects->[$obj_idx]->layers->[$_], 0..($skirt_height-1);
my @layer_points = (
(map @$_, map @$_, map @{$_->slices}, @layers),
@ -647,7 +643,7 @@ sub write_gcode {
if (ref $file eq 'IO::Scalar') {
$fh = $file;
} else {
open $fh, ">", $file
Slic3r::open(\$fh, ">", $file)
or die "Failed to open $file for writing\n";
}
@ -675,7 +671,8 @@ sub write_gcode {
# set up our extruder object
my $gcodegen = Slic3r::GCode->new(
multiple_extruders => (@{$self->extruders} > 1),
multiple_extruders => (@{$self->extruders} > 1),
layer_count => $self->layer_count,
);
my $min_print_speed = 60 * $Slic3r::Config->min_print_speed;
my $dec = $gcodegen->dec;
@ -700,7 +697,7 @@ sub write_gcode {
print $fh "G21 ; set units to millimeters\n";
if ($Slic3r::Config->gcode_flavor =~ /^(?:reprap|teacup)$/) {
printf $fh $gcodegen->reset_e;
if ($Slic3r::Config->gcode_flavor =~ /^(?:reprap|makerbot)$/) {
if ($Slic3r::Config->gcode_flavor =~ /^(?:reprap|makerbot|sailfish)$/) {
if ($Slic3r::Config->use_relative_e_distances) {
print $fh "M83 ; use relative distances for extrusion\n";
} else {
@ -753,7 +750,7 @@ sub write_gcode {
}
# set new layer, but don't move Z as support material interfaces may need an intermediate one
$gcodegen->change_layer($self->objects->[$object_copies->[0][0]]->layers->[$layer_id]);
$gcode .= $gcodegen->change_layer($self->objects->[$object_copies->[0][0]]->layers->[$layer_id]);
$gcodegen->elapsed_time(0);
# prepare callback to call as soon as a Z command is generated