Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge branch 'raft'
  • Loading branch information
alranel committed Feb 2, 2013
2 parents 02c0f36 + c7b4d99 commit acada05
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 11 deletions.
1 change: 1 addition & 0 deletions README.markdown
Expand Up @@ -209,6 +209,7 @@ The author of the Silk icon set is Mark James.
Spacing between pattern lines (mm, default: 2.5)
--support-material-angle
Support material angle in degrees (range: 0-90, default: 0)
--raft-layers Number of layers to raise the printed objects by (range: 0+, default: 0)
Retraction options:
--retract-length Length of retraction in mm when pausing extrusion (default: 1)
Expand Down
8 changes: 8 additions & 0 deletions lib/Slic3r/Config.pm
Expand Up @@ -578,6 +578,14 @@ our $Options = {
type => 'i',
default => 0,
},
'raft_layers' => {
label => 'Raft layers',
tooltip => 'Number of total raft layers to insert below the object(s).',
sidetext => 'layers',
cli => 'raft-layers=i',
type => 'i',
default => 0,
},
'start_gcode' => {
label => 'Start G-code',
tooltip => 'This start procedure is inserted at the beginning of the output file, right after the temperature control commands for extruder and bed. If Slic3r detects M104 or M190 in your custom codes, such commands will not be prepended automatically. Note that you can use placeholder variables for all Slic3r settings, so you can put a "M104 S[first_layer_temperature]" command wherever you want.',
Expand Down
4 changes: 4 additions & 0 deletions lib/Slic3r/GUI/Tab.pm
Expand Up @@ -456,6 +456,10 @@ sub build {
title => 'Support material',
options => [qw(support_material support_material_threshold support_material_pattern support_material_spacing support_material_angle)],
},
{
title => 'Raft',
options => [qw(raft_layers)],
},
]);

$self->add_options_page('Notes', 'note.png', optgroups => [
Expand Down
14 changes: 10 additions & 4 deletions lib/Slic3r/Layer.pm
Expand Up @@ -2,6 +2,7 @@ package Slic3r::Layer;
use Moo;

use List::Util qw(first);
use Slic3r::Geometry qw(scale);
use Slic3r::Geometry::Clipper qw(union_ex);

has 'id' => (is => 'rw', required => 1, trigger => 1); # sequential number of layer, 0-based
Expand Down Expand Up @@ -32,11 +33,16 @@ sub _trigger_id {
sub _build_slice_z {
my $self = shift;

if ($self->id == 0) {
return $Slic3r::Config->get_value('first_layer_height') / 2 / &Slic3r::SCALING_FACTOR;
if ($Slic3r::Config->raft_layers == 0) {
if ($self->id == 0) {
return scale $Slic3r::Config->get_value('first_layer_height') / 2;
}
return scale($Slic3r::Config->get_value('first_layer_height') + ($self->id-1 + 0.5) * $Slic3r::Config->layer_height);
} else {
return -1 if $self->id < $Slic3r::Config->raft_layers;
my $object_layer_id = $self->id - $Slic3r::Config->raft_layers;
return scale ($object_layer_id + 0.5) * $Slic3r::Config->layer_height;
}
return ($Slic3r::Config->get_value('first_layer_height') + (($self->id-1) * $Slic3r::Config->layer_height) + ($Slic3r::Config->layer_height/2))
/ &Slic3r::SCALING_FACTOR; #/
}

# Z used for printing in scaled coordinates
Expand Down
8 changes: 4 additions & 4 deletions lib/Slic3r/Print.pm
Expand Up @@ -216,7 +216,7 @@ sub init_extruders {
}

# calculate support material flow
if ($self->config->support_material) {
if ($self->config->support_material || $self->config->raft_layers > 0) {
my $extruder = $self->extruders->[$self->config->support_material_extruder-1];
$self->support_material_flow($extruder->make_flow(
width => $self->config->support_material_extrusion_width || $self->config->extrusion_width,
Expand Down Expand Up @@ -413,7 +413,7 @@ sub export_gcode {
}

# generate support material
if ($Slic3r::Config->support_material) {
if ($Slic3r::Config->support_material || $Slic3r::Config->raft_layers > 0) {
$status_cb->(85, "Generating support material");
$_->generate_support_material for @{$self->objects};
}
Expand Down Expand Up @@ -510,7 +510,7 @@ EOF
}
}
# generate support material
if ($Slic3r::Config->support_material && $layer_id > 0) {
if (($Slic3r::Config->support_material || $self->config->raft_layers > 0) && $layer_id > 0) {
my (@supported_slices, @unsupported_slices) = ();
foreach my $expolygon (@current_layer_slices) {
my $intersection = intersection_ex(
Expand Down Expand Up @@ -801,7 +801,7 @@ sub write_gcode {

# extrude support material before other things because it might use a lower Z
# and also because we avoid travelling on other things when printing it
if ($Slic3r::Config->support_material) {
if ($Slic3r::Config->support_material || $self->config->raft_layers > 0) {
$gcode .= $gcodegen->move_z($layer->support_material_interface_z)
if ($layer->support_interface_fills && @{ $layer->support_interface_fills->paths });
$gcode .= $gcodegen->set_extruder($self->extruders->[$Slic3r::Config->support_material_extruder-1]);
Expand Down
9 changes: 6 additions & 3 deletions lib/Slic3r/Print/Object.pm
Expand Up @@ -173,9 +173,10 @@ sub slice {
}

# remove empty layers from bottom
while (@{$self->layers} && !@{$self->layers->[0]->slices} && !map @{$_->thin_walls}, @{$self->layers->[0]->regions}) {
shift @{$self->layers};
for (my $i = 0; $i <= $#{$self->layers}; $i++) {
my $first_object_layer_id = $Slic3r::Config->raft_layers;
while (@{$self->layers} && !@{$self->layers->[$first_object_layer_id]->slices} && !map @{$_->thin_walls}, @{$self->layers->[$first_object_layer_id]->regions}) {
splice @{$self->layers}, $first_object_layer_id, 1;
for (my $i = $first_object_layer_id; $i <= $#{$self->layers}; $i++) {
$self->layers->[$i]->id($i);
}
}
Expand Down Expand Up @@ -591,6 +592,8 @@ sub generate_support_material {
my @current_support_regions = (); # expolygons we've started to support (i.e. below the empty interface layers)
my @queue = (); # the number of items of this array determines the number of empty interface layers
for my $i (reverse 0 .. $#{$self->layers}) {
next unless $Slic3r::Config->support_material || ($i <= $Slic3r::Config->raft_layers); # <= because we need to start from the first non-raft layer

my $layer = $self->layers->[$i];
my $lower_layer = $i > 0 ? $self->layers->[$i-1] : undef;

Expand Down
1 change: 1 addition & 0 deletions slic3r.pl
Expand Up @@ -257,6 +257,7 @@ sub usage {
Spacing between pattern lines (mm, default: $config->{support_material_spacing})
--support-material-angle
Support material angle in degrees (range: 0-90, default: $config->{support_material_angle})
--raft-layers Number of layers to raise the printed objects by (range: 0+, default: $config->{raft_layers})
Retraction options:
--retract-length Length of retraction in mm when pausing extrusion (default: $config->{retract_length}[0])
Expand Down

0 comments on commit acada05

Please sign in to comment.