diff --git a/README.markdown b/README.markdown index d63f2c1b0..026acb5bc 100644 --- a/README.markdown +++ b/README.markdown @@ -164,9 +164,11 @@ The author is Alessandro Ranellucci. Support material options: --support-material Generate support material for overhangs + --support-material-threshold + Overhang threshold angle (range: 0-90, default: 45) --support-material-pattern Pattern to use for support material (default: rectilinear) - --support-material-angle + --support-material-angle Support material angle in degrees (range: 0-90, default: 0) Retraction options: diff --git a/lib/Slic3r.pm b/lib/Slic3r.pm index e534403d4..5e908fa6c 100644 --- a/lib/Slic3r.pm +++ b/lib/Slic3r.pm @@ -123,6 +123,7 @@ our $fill_angle = 45; our $extra_perimeters = 1; our $randomize_start = 1; our $support_material = 0; +our $support_material_threshold = 45; our $support_material_pattern = 'rectilinear'; our $support_material_angle = 0; our $support_material_tool = 0; diff --git a/lib/Slic3r/Config.pm b/lib/Slic3r/Config.pm index 21aa85563..d37251ec9 100644 --- a/lib/Slic3r/Config.pm +++ b/lib/Slic3r/Config.pm @@ -284,6 +284,11 @@ our $Options = { cli => 'support-material!', type => 'bool', }, + 'support_material_threshold' => { + label => 'Overhang threshold (°)', + cli => 'support-material-threshold=i', + type => 'i', + }, 'support_material_pattern' => { label => 'Pattern', cli => 'support-material-pattern=s', @@ -292,7 +297,7 @@ our $Options = { labels => [qw(rectilinear honeycomb)], }, 'support_material_angle' => { - label => 'Angle (°)', + label => 'Pattern angle (°)', cli => 'support-material-angle=i', type => 'i', }, diff --git a/lib/Slic3r/GUI/SkeinPanel.pm b/lib/Slic3r/GUI/SkeinPanel.pm index f216c7d0f..2d513f43f 100644 --- a/lib/Slic3r/GUI/SkeinPanel.pm +++ b/lib/Slic3r/GUI/SkeinPanel.pm @@ -86,7 +86,7 @@ sub new { }, support_material => { title => 'Support material', - options => [qw(support_material support_material_tool)], + options => [qw(support_material support_material_threshold support_material_pattern support_material_angle support_material_tool)], }, ); $self->{panels} = \%panels; diff --git a/lib/Slic3r/Print/Object.pm b/lib/Slic3r/Print/Object.pm index 22f308177..31441170b 100644 --- a/lib/Slic3r/Print/Object.pm +++ b/lib/Slic3r/Print/Object.pm @@ -2,7 +2,7 @@ package Slic3r::Print::Object; use Moo; use Slic3r::ExtrusionPath ':roles'; -use Slic3r::Geometry qw(scale unscale); +use Slic3r::Geometry qw(scale unscale deg2rad); use Slic3r::Geometry::Clipper qw(diff_ex intersection_ex union_ex); use Slic3r::Surface ':types'; @@ -488,9 +488,10 @@ sub generate_support_material { my $self = shift; my %params = @_; + my $threshold_rad = deg2rad($Slic3r::support_material_threshold + 1); # +1 makes the threshold inclusive + my $overhang_width = $threshold_rad == 0 ? undef : scale $Slic3r::layer_height * ((cos $threshold_rad) / (sin $threshold_rad)); my $distance_from_object = scale $Slic3r::flow->width; - my $extra_margin = scale 1; - + printf "width = %s\n", unscale $overhang_width; # determine unsupported surfaces my @unsupported_expolygons = (); @@ -517,8 +518,8 @@ sub generate_support_material { # we need an angle threshold for this my @overhangs = (); if ($upper_layer) { - @overhangs = @{diff_ex( - [ map @$_, map $_->expolygon->offset_ex($extra_margin), @{$upper_layer->slices} ], + @overhangs = map $_->offset_ex(2 * $overhang_width), @{diff_ex( + [ map @$_, map $_->expolygon->offset_ex(-$overhang_width), @{$upper_layer->slices} ], [ map @{$_->expolygon}, @{$layer->slices} ], 1, )}; @@ -547,8 +548,9 @@ sub generate_support_material { Slic3r::debugf "Generating patterns\n"; my $support_patterns = []; # in case we want cross-hatching { + # 0.5 makes sure the paths don't get clipped externally when applying them to layers my @support_material_areas = map $_->offset_ex(- 0.5 * scale $Slic3r::flow->width), - @{union_ex([ map @$_, @unsupported_expolygons ])}; + @{union_ex([ map $_->contour, @unsupported_expolygons ])}; my $fill = Slic3r::Fill->new(print => $params{print}); my $filler = $fill->filler($Slic3r::support_material_pattern); diff --git a/slic3r.pl b/slic3r.pl index 4538ac40f..113a301e8 100755 --- a/slic3r.pl +++ b/slic3r.pl @@ -209,6 +209,8 @@ $j Support material options: --support-material Generate support material for overhangs + --support-material-threshold + Overhang threshold angle (range: 0-90, default: $Slic3r::support_material_threshold) --support-material-pattern Pattern to use for support material (default: $Slic3r::support_material_pattern) --support-material-angle