From 7b938b00024926ec22ed7e09bd8add422bc223c2 Mon Sep 17 00:00:00 2001 From: Vitaliy Filippov Date: Fri, 16 May 2014 01:17:01 +0400 Subject: [PATCH] Fix raft/support contact and printing with both raft and support --- lib/Slic3r/Print/Object.pm | 10 +---- lib/Slic3r/Print/SupportMaterial.pm | 60 +++++++++++------------------ 2 files changed, 24 insertions(+), 46 deletions(-) diff --git a/lib/Slic3r/Print/Object.pm b/lib/Slic3r/Print/Object.pm index 2fbe57f9..b3365725 100644 --- a/lib/Slic3r/Print/Object.pm +++ b/lib/Slic3r/Print/Object.pm @@ -105,8 +105,6 @@ sub slice { # make layers taking custom heights into account my $print_z = my $slice_z = my $height = my $id = 0; - my $first_object_layer_height = -1; - my $first_object_layer_distance = -1; # add raft layers if ($self->config->raft_layers > 0) { @@ -124,8 +122,7 @@ sub slice { # force first layer print_z according to the contact distance # (the loop below will raise print_z by such height) - $first_object_layer_height = $nozzle_diameter; - $first_object_layer_distance = $distance; + $print_z += $distance; } # loop until we have at least one layer and the max slice_z reaches the object height @@ -147,11 +144,6 @@ sub slice { } } - if ($first_object_layer_height != -1 && !@{$self->layers}) { - $height = $first_object_layer_height; - $print_z += ($first_object_layer_distance - $height); - } - $print_z += $height; $slice_z += $height/2; diff --git a/lib/Slic3r/Print/SupportMaterial.pm b/lib/Slic3r/Print/SupportMaterial.pm index 29afa12c..d4ac5609 100644 --- a/lib/Slic3r/Print/SupportMaterial.pm +++ b/lib/Slic3r/Print/SupportMaterial.pm @@ -128,40 +128,25 @@ sub contact_area { my $diff; # If a threshold angle was specified, use a different logic for detecting overhangs. - if (defined $threshold_rad - || $layer_id < $self->object_config->support_material_enforce_layers - || ($self->object_config->raft_layers > 0 && $layer_id == 0)) { - my $d = defined $threshold_rad + my $d = 0; + if ($layer_id > $self->object_config->support_material_enforce_layers) { + $d = defined $threshold_rad ? scale $lower_layer->height * ((cos $threshold_rad) / (sin $threshold_rad)) - : 0; - - $diff = diff( - offset([ map $_->p, @{$layerm->slices} ], -$d), - [ map @$_, @{$lower_layer->slices} ], - ); - - # only enforce spacing from the object ($fw/2) if the threshold angle - # is not too high: in that case, $d will be very small (as we need to catch - # very short overhangs), and such contact area would be eaten by the - # enforced spacing, resulting in high threshold angles to be almost ignored - $diff = diff( - offset($diff, $d - $fw/2), - [ map @$_, @{$lower_layer->slices} ], - ) if $d > $fw/2; - } else { - $diff = diff( - [ map $_->p, @{$layerm->slices} ], - offset([ map @$_, @{$lower_layer->slices} ], +$fw*2), - ); - - # collapse very tiny spots - $diff = offset2($diff, -$fw/10, +$fw/10); - - # $diff now contains the ring or stripe comprised between the boundary of - # lower slices and the centerline of the last perimeter in this overhanging layer. - # Void $diff means that there's no upper perimeter whose centerline is - # outside the lower slice boundary, thus no overhang + : $fw*2; } + + $diff = diff( + [ map $_->p, @{$layerm->slices} ], + offset([ map @$_, @{$lower_layer->slices} ], +$d), + ); + + # collapse very tiny spots + $diff = offset2($diff, -$fw/10, +$fw/10); + + # $diff now contains the ring or stripe comprised between the boundary of + # lower slices and the centerline of the last perimeter in this overhanging layer. + # Void $diff means that there's no upper perimeter whose centerline is + # outside the lower slice boundary, thus no overhang if ($self->object_config->dont_support_bridges) { # compute the area of bridging perimeters @@ -269,7 +254,7 @@ sub contact_area { @{$layer->regions}; my $nozzle_diameter = sum(@nozzle_diameters)/@nozzle_diameters; - my $contact_z = $layer->print_z - contact_distance($nozzle_diameter); + my $contact_z = $layer->print_z - contact_distance($nozzle_diameter) - $layer->height; ###$contact_z = $layer->print_z - $layer->height; # ignore this contact area if it's too low @@ -337,7 +322,8 @@ sub support_layers_z { # we use max() to prevent many ultra-thin layers to be inserted in case # layer_height > nozzle_diameter * 0.75 my $nozzle_diameter = $self->print_config->get_at('nozzle_diameter', $self->object_config->support_material_extruder-1); - my $support_material_height = max($max_object_layer_height, $nozzle_diameter * 0.75); + my $support_material_height = $max_object_layer_height;#max($max_object_layer_height, $nozzle_diameter * 0.75); + my @z = sort { $a <=> $b } @$contact_z, @$top_z, (map $_ + $nozzle_diameter, @$top_z); # enforce first layer height @@ -353,7 +339,7 @@ sub support_layers_z { splice @z, 1, 0, map { sprintf "%.2f", $_ } map { $z[0] + $height * $_ } - 0..($self->object_config->raft_layers - 1); + 1..($self->object_config->raft_layers - 2); } for (my $i = $#z; $i >= 0; $i--) { @@ -850,10 +836,10 @@ sub overlapping_layers { } 0..$#$support_z; } -# class method +# wanted Z distance between support/raft material and next object layer sub contact_distance { my ($nozzle_diameter) = @_; - return $nozzle_diameter * 1.5; + return 0; #$nozzle_diameter * 0.5; } 1;