Просмотр исходного кода

Don't apply acceleration settings to travel moves

Alessandro Ranellucci 12 лет назад
Родитель
Сommit
2acda9973e
3 измененных файлов с 19 добавлено и 6 удалено
  1. 7 0
      lib/Slic3r/ExtrusionPath.pm
  2. 12 0
      lib/Slic3r/GCode.pm
  3. 0 6
      lib/Slic3r/Print.pm

+ 7 - 0
lib/Slic3r/ExtrusionPath.pm

@@ -93,6 +93,13 @@ sub endpoints {
 
 sub is_printable { 1 }
 
+sub is_perimeter {
+    my $self = shift;
+    return $self->role == EXTR_ROLE_PERIMETER
+        || $self->role == EXTR_ROLE_EXTERNAL_PERIMETER
+        || $self->role == EXTR_ROLE_CONTOUR_INTERNAL_PERIMETER;
+}
+
 sub is_fill {
     my $self = shift;
     return $self->role == EXTR_ROLE_FILL

+ 12 - 0
lib/Slic3r/GCode.pm

@@ -197,6 +197,14 @@ sub extrude_path {
     # compensate retraction
     $gcode .= $self->unretract;
     
+    # adjust acceleration
+    my $acceleration;
+    $acceleration = $Slic3r::Config->perimeter_acceleration
+        if $Slic3r::Config->perimeter_acceleration && $path->is_perimeter;
+    $acceleration = $Slic3r::Config->infill_acceleration
+        if $Slic3r::Config->infill_acceleration && $path->is_fill;
+    $gcode .= $self->set_acceleration($acceleration) if $acceleration;
+    
     my $area;  # mm^3 of extrudate per mm of tool movement 
     if ($path->role == EXTR_ROLE_BRIDGE) {
         my $s = $path->flow_spacing;
@@ -242,6 +250,10 @@ sub extrude_path {
         $self->elapsed_time($self->elapsed_time + $path_time);
     }
     
+    # reset acceleration
+    $gcode .= $self->set_acceleration($Slic3r::Config->default_acceleration)
+        if $acceleration && $Slic3r::Config->default_acceleration;
+    
     return $gcode;
 }
 

+ 0 - 6
lib/Slic3r/Print.pm

@@ -853,16 +853,12 @@ sub write_gcode {
                 # extrude perimeters
                 if (@{ $layerm->perimeters }) {
                     $gcode .= $gcodegen->set_extruder($region->extruders->{perimeter});
-                    $gcode .= $gcodegen->set_acceleration($Slic3r::Config->perimeter_acceleration);
                     $gcode .= $gcodegen->extrude($_, 'perimeter') for @{ $layerm->perimeters };
-                    $gcode .= $gcodegen->set_acceleration($Slic3r::Config->default_acceleration)
-                        if $Slic3r::Config->perimeter_acceleration;
                 }
                 
                 # extrude fills
                 if (@{ $layerm->fills }) {
                     $gcode .= $gcodegen->set_extruder($region->extruders->{infill});
-                    $gcode .= $gcodegen->set_acceleration($Slic3r::Config->infill_acceleration);
                     for my $fill (@{ $layerm->fills }) {
                         if ($fill->isa('Slic3r::ExtrusionPath::Collection')) {
                             $gcode .= $gcodegen->extrude($_, 'fill') 
@@ -871,8 +867,6 @@ sub write_gcode {
                             $gcode .= $gcodegen->extrude($fill, 'fill') ;
                         }
                     }
-                    $gcode .= $gcodegen->set_acceleration($Slic3r::Config->default_acceleration)
-                        if $Slic3r::Config->infill_acceleration;
                 }
             }
         }