New option to define the overhang threshold angle for support material generation

degen-loop-screen
Alessandro Ranellucci 2012-06-23 23:54:39 +02:00
parent 07daefeddb
commit 36753d85b7
6 changed files with 21 additions and 9 deletions

View File

@ -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:

View File

@ -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;

View File

@ -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',
},

View File

@ -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;

View File

@ -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);

View File

@ -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