Customizable overlap ratio (it defaults to 0.15 now)

This commit is contained in:
Alessandro Ranellucci 2011-12-07 19:33:59 +01:00
parent 9f6be233f8
commit d9a70ea80d
15 changed files with 67 additions and 42 deletions

View File

@ -125,10 +125,6 @@ The author is Alessandro Ranellucci (me).
layer with (> 0, default: 1)
--infill-every-layers
Infill every N layers (default: 1)
--extrusion-width-ratio
Calculate the extrusion width as the layer height multiplied by
this value (> 0, default: calculated automatically)
--bridge-flow-ratio Multiplier for extrusion when bridging (> 0, default: 1)
Print options:
--perimeters Number of perimeters/horizontal skins (range: 1+,
@ -169,6 +165,14 @@ The author is Alessandro Ranellucci (me).
--duplicate-y Number of items along Y axis (1+, default: 1)
--duplicate-distance Distance in mm between copies (default: 6)
Flow options (advanced):
--extrusion-width-ratio
Calculate the extrusion width as the layer height multiplied by
this value (> 0, default: calculated automatically)
--bridge-flow-ratio Multiplier for extrusion when bridging (> 0, default: 1)
--overlap-ratio Overlap between extrusion threads expressed as a ratio over extrusion
width (> 0, default: 0.15)
If you want to change a preset file, just do
slic3r.pl --load config.ini --layer-height 0.25 --save config.ini

View File

@ -18,7 +18,7 @@ use Slic3r::ExtrusionPath;
use Slic3r::ExtrusionPath::Arc;
use Slic3r::ExtrusionPath::Collection;
use Slic3r::Fill;
use Slic3r::Geometry;
use Slic3r::Geometry qw(PI);
use Slic3r::Layer;
use Slic3r::Line;
use Slic3r::Perimeter;
@ -62,15 +62,18 @@ our $small_perimeter_area = (5 / $resolution) ** 2;
our $layer_height = 0.4;
our $first_layer_height_ratio = 1;
our $infill_every_layers = 1;
# flow options
our $extrusion_width_ratio = 0;
our $bridge_flow_ratio = 1;
our $flow_speed_ratio = 1;
our $flow_width;
our $overlap_ratio = 0.15;
our $flow_spacing;
# print options
our $perimeters = 3;
our $solid_layers = 3;
our $perimeter_infill_overlap_ratio = 0.15; # factor for flow width
our $fill_pattern = 'rectilinear';
our $solid_fill_pattern = 'rectilinear';
our $fill_density = 0.4; # 1 = 100%

View File

@ -115,6 +115,18 @@ our $Options = {
cli => 'layer-height=f',
type => 'f',
},
'first_layer_height_ratio' => {
label => 'First layer height ratio',
cli => 'first-layer-height-ratio=f',
type => 'f',
},
'infill_every_layers' => {
label => 'Infill every N layers',
cli => 'infill-every-layers=i',
type => 'i',
},
# flow options
'extrusion_width_ratio' => {
label => 'Extrusion width (ratio over layer height; leave zero to calculate automatically)',
cli => 'extrusion-width-ratio=f',
@ -125,16 +137,11 @@ our $Options = {
cli => 'bridge-flow-ratio=f',
type => 'f',
},
'first_layer_height_ratio' => {
label => 'First layer height ratio',
cli => 'first-layer-height-ratio=f',
'overlap_ratio' => {
label => 'Extrusion overlap (ratio over extrusion width)',
cli => 'overlap-ratio=f',
type => 'f',
},
'infill_every_layers' => {
label => 'Infill every N layers',
cli => 'infill-every-layers=i',
type => 'i',
},
# print options
'perimeters' => {
@ -371,9 +378,11 @@ sub validate {
$Slic3r::flow_speed_ratio = $max_flow_width / $Slic3r::flow_width;
$Slic3r::flow_width = $max_flow_width;
}
$Slic3r::flow_spacing = $Slic3r::flow_width * (1-$Slic3r::overlap_ratio);
Slic3r::debugf "Flow width = $Slic3r::flow_width\n";
Slic3r::debugf "Flow speed ratio = $Slic3r::flow_speed_ratio\n";
Slic3r::debugf "Flow spacing = $Slic3r::flow_spacing\n";
# --perimeters
die "Invalid value for --perimeters\n"

View File

@ -1,6 +1,8 @@
package Slic3r::Extruder;
use Moo;
use Slic3r::Geometry qw(scale);
has 'layer' => (is => 'rw');
has 'shift_x' => (is => 'ro', default => sub {0} );
has 'shift_y' => (is => 'ro', default => sub {0} );
@ -75,7 +77,7 @@ sub extrude_loop {
my $extrusion_path = $loop->split_at($start_at);
# clip the path to avoid the extruder to get exactly on the first point of the loop
$extrusion_path->clip_end($Slic3r::flow_width / $Slic3r::resolution);
$extrusion_path->clip_end(scale $Slic3r::flow_spacing);
# extrude along the path
return $self->extrude($extrusion_path, $description);

View File

@ -85,12 +85,12 @@ sub make_fill {
])};
SURFACE: foreach my $surface (@surfaces) {
my $filler = $Slic3r::fill_pattern;
my $density = $Slic3r::fill_density;
my $flow_width = $Slic3r::flow_width;
my $flow_ratio = 1;
my $is_bridge = $layer->id > 0 && $surface->surface_type eq 'bottom';
my $is_solid = $surface->surface_type =~ /^(top|bottom)$/;
my $filler = $Slic3r::fill_pattern;
my $density = $Slic3r::fill_density;
my $flow_spacing = $Slic3r::flow_spacing;
my $flow_ratio = 1;
my $is_bridge = $layer->id > 0 && $surface->surface_type eq 'bottom';
my $is_solid = $surface->surface_type =~ /^(top|bottom)$/;
# force 100% density and rectilinear fill for external surfaces
if ($surface->surface_type ne 'internal') {
@ -98,7 +98,8 @@ sub make_fill {
$filler = $Slic3r::solid_fill_pattern;
if ($is_bridge) {
$filler = 'rectilinear';
$flow_width = sqrt($Slic3r::bridge_flow_ratio * ($Slic3r::nozzle_diameter**2));
$flow_spacing = sqrt($Slic3r::bridge_flow_ratio * ($Slic3r::nozzle_diameter**2))
* (1-$Slic3r::overlap_ratio);
$flow_ratio = $Slic3r::bridge_flow_ratio;
}
} else {
@ -107,8 +108,8 @@ sub make_fill {
my @paths = $self->fillers->{$filler}->fill_surface(
$surface,
density => $density,
flow_width => $flow_width,
density => $density,
flow_spacing => $flow_spacing,
);
my $params = shift @paths;

View File

@ -3,6 +3,7 @@ use Moo;
extends 'Slic3r::Fill::Base';
use Slic3r::Geometry qw(scale);
use XXX;
sub fill_surface {
@ -11,8 +12,8 @@ sub fill_surface {
# no rotation is supported for this infill pattern
my $flow_width_res = $params{flow_width} / $Slic3r::resolution;
my $distance = $flow_width_res / $params{density};
my $scaled_flow_spacing = scale $params{flow_spacing};
my $distance = $scaled_flow_spacing / $params{density};
my @contour_loops = ();
my @hole_loops = ();
@ -43,7 +44,7 @@ sub fill_surface {
my $path = $loop->split_at($cur_pos);
# clip the path to avoid the extruder to get exactly on the first point of the loop
$path->clip_end($Slic3r::flow_width / $Slic3r::resolution);
$path->clip_end(scale $Slic3r::flow_spacing);
push @paths, $path->p;
}

View File

@ -3,7 +3,7 @@ use Moo;
extends 'Slic3r::Fill::Base';
use Slic3r::Geometry qw(bounding_box X1 Y1 X2 Y2);
use Slic3r::Geometry qw(scale bounding_box X1 Y1 X2 Y2);
use XXX;
sub multiplier () { 1 }
@ -27,7 +27,7 @@ sub fill_surface {
my $rotate_vector = $self->infill_direction($surface);
$self->rotate_points($expolygon, $rotate_vector);
my $distance_between_lines = $params{flow_width} / $Slic3r::resolution / $params{density} * $self->multiplier;
my $distance_between_lines = scale $params{flow_spacing} / $params{density} * $self->multiplier;
my $bounding_box = [ bounding_box(map @$_, $expolygon) ];
my $bounding_box_polygon = Slic3r::Polygon->new([
[ $bounding_box->[X1], $bounding_box->[Y1] ],

View File

@ -19,7 +19,7 @@ sub fill_surface {
$bounding_box->[X1] += scale 0.1;
$bounding_box->[X2] -= scale 0.1;
my $min_spacing = scale $params{flow_width};
my $min_spacing = scale $params{flow_spacing};
my $distance_between_lines = $min_spacing / $params{density};
my $line_oscillation = $distance_between_lines - $min_spacing;

View File

@ -3,7 +3,7 @@ use Moo;
extends 'Slic3r::Fill::Base';
use Slic3r::Geometry qw(X1 Y1 X2 Y2 A B X Y);
use Slic3r::Geometry qw(scale X1 Y1 X2 Y2 A B X Y);
use XXX;
sub fill_surface {
@ -16,7 +16,7 @@ sub fill_surface {
my $rotate_vector = $self->infill_direction($surface);
$self->rotate_points($polygons, $rotate_vector);
my $distance_between_lines = $params{flow_width} / $Slic3r::resolution / $params{density};
my $distance_between_lines = scale $params{flow_spacing} / $params{density};
my $number_of_lines = int(0.99999999 + $self->max_print_dimension / $distance_between_lines); # ceil
#printf "distance = %f\n", $distance_between_lines;

View File

@ -57,7 +57,7 @@ sub new {
},
extrusion => {
title => 'Extrusion',
options => [qw(extrusion_width_ratio bridge_flow_ratio)],
options => [qw(extrusion_width_ratio bridge_flow_ratio overlap_ratio)],
},
);
$self->{panels} = \%panels;

View File

@ -182,7 +182,7 @@ sub prepare_fill_surfaces {
sub remove_small_surfaces {
my $self = shift;
my $distance = scale $Slic3r::flow_width / 2;
my $distance = scale $Slic3r::flow_spacing / 2;
my @surfaces = @{$self->fill_surfaces};
@{$self->fill_surfaces} = ();

View File

@ -45,12 +45,12 @@ sub make_perimeter {
push @{ $perimeters[-1] }, [@last_offsets];
# offset distance for inner loops
$distance = $Slic3r::flow_width / $Slic3r::resolution;
$distance = scale $Slic3r::flow_spacing;
}
# create one more offset to be used as boundary for fill
{
$distance -= scale $Slic3r::flow_width * $Slic3r::perimeter_infill_overlap_ratio;
$distance -= scale $Slic3r::flow_spacing;
my @fill_boundaries = map Slic3r::Surface->cast_from_expolygon
($_, surface_type => $surface->surface_type),
map $_->offset_ex(-$distance), @last_offsets;

View File

@ -4,6 +4,7 @@ use Moo;
extends 'Slic3r::Polyline';
use Math::Clipper qw(JT_MITER);
use Slic3r::Geometry qw(scale);
sub lines {
my $self = shift;
@ -31,7 +32,7 @@ sub is_printable {
# if no offset is possible, then polyline is not printable
my $p = $self->p;
@$p = reverse @$p if !Math::Clipper::is_counter_clockwise($p);
my $offsets = Math::Clipper::offset([$p], -($Slic3r::flow_width / 2 / $Slic3r::resolution), $Slic3r::resolution * 100000, JT_MITER, 2);
my $offsets = Math::Clipper::offset([$p], -(scale $Slic3r::flow_spacing / 2), $Slic3r::resolution * 100000, JT_MITER, 2);
return @$offsets ? 1 : 0;
}

View File

@ -334,7 +334,7 @@ sub extrude_skirt {
# draw outlines from outside to inside
my @skirts = ();
for (my $i = $Slic3r::skirts - 1; $i >= 0; $i--) {
my $distance = scale ($Slic3r::skirt_distance + ($Slic3r::flow_width * $i));
my $distance = scale ($Slic3r::skirt_distance + ($Slic3r::flow_spacing * $i));
my $outline = offset([$convex_hull], $distance, $Slic3r::resolution * 100, JT_ROUND);
push @skirts, Slic3r::ExtrusionLoop->cast([ @{$outline->[0]} ], role => 'skirt');
}

View File

@ -131,10 +131,6 @@ Usage: slic3r.pl [ OPTIONS ] file.stl
layer with (> 0, default: $Slic3r::first_layer_height_ratio)
--infill-every-layers
Infill every N layers (default: $Slic3r::infill_every_layers)
--extrusion-width-ratio
Calculate the extrusion width as the layer height multiplied by
this value (> 0, default: calculated automatically)
--bridge-flow-ratio Multiplier for extrusion when bridging (> 0, default: $Slic3r::bridge_flow_ratio)
Print options:
--perimeters Number of perimeters/horizontal skins (range: 1+,
@ -175,6 +171,14 @@ Usage: slic3r.pl [ OPTIONS ] file.stl
--duplicate-y Number of items along Y axis (1+, default: $Slic3r::duplicate_y)
--duplicate-distance Distance in mm between copies (default: $Slic3r::duplicate_distance)
Flow options (advanced):
--extrusion-width-ratio
Calculate the extrusion width as the layer height multiplied by
this value (> 0, default: calculated automatically)
--bridge-flow-ratio Multiplier for extrusion when bridging (> 0, default: $Slic3r::bridge_flow_ratio)
--overlap-ratio Overlap between extrusion threads expressed as a ratio over extrusion
width (> 0, default: $Slic3r::overlap_ratio)
EOF
exit ($exit_code || 0);
}