New --first-layer-extrusion-width option. #385

This commit is contained in:
Alessandro Ranellucci 2012-06-06 17:29:12 +02:00
parent d412820733
commit 8a031fe501
13 changed files with 117 additions and 76 deletions

View file

@ -19,6 +19,8 @@ has 'slicing_errors' => (is => 'rw');
has 'slice_z' => (is => 'lazy');
has 'print_z' => (is => 'lazy');
has 'height' => (is => 'lazy');
has 'flow_spacing' => (is => 'lazy');
has 'flow_width' => (is => 'lazy');
# collection of spare segments generated by slicing the original geometry;
# these need to be merged in continuos (closed) polylines
@ -99,6 +101,16 @@ sub _build_height {
return $self->id == 0 ? $Slic3r::_first_layer_height : $Slic3r::layer_height;
}
sub _build_flow_spacing {
my $self = shift;
return $self->id == 0 ? $Slic3r::first_layer_flow_spacing : $Slic3r::flow_spacing;
}
sub _build_flow_width {
my $self = shift;
return $self->id == 0 ? $Slic3r::first_layer_flow_width : $Slic3r::flow_width;
}
sub add_line {
my $self = shift;
my ($line) = @_;
@ -127,7 +139,7 @@ sub make_surfaces {
# the contours must be offsetted by half extrusion width inwards
{
my $distance = scale $Slic3r::flow_width / 2;
my $distance = scale $self->flow_width / 2;
my @surfaces = @{$self->slices};
@{$self->slices} = ();
foreach my $surface (@surfaces) {
@ -146,12 +158,12 @@ sub make_surfaces {
);
if (@$diff) {
my $area_threshold = scale($Slic3r::flow_spacing) ** 2;
my $area_threshold = scale($self->flow_spacing) ** 2;
@$diff = grep $_->area > ($area_threshold), @$diff;
push @{$self->thin_walls},
grep $_,
map $_->medial_axis(scale $Slic3r::flow_width),
map $_->medial_axis(scale $self->flow_width),
@$diff;
Slic3r::debugf " %d thin walls detected\n", scalar(@{$self->thin_walls}) if @{$self->thin_walls};
@ -201,8 +213,8 @@ sub make_perimeters {
next unless $circumference <= $Slic3r::small_perimeter_length;
# revert the compensation done in make_surfaces() and get the actual radius
# of the hole
my $radius = ($circumference / PI / 2) - scale $Slic3r::flow_spacing/2;
my $new_radius = (scale($Slic3r::flow_width) + sqrt((scale($Slic3r::flow_width)**2) + (4*($radius**2)))) / 2;
my $radius = ($circumference / PI / 2) - scale $self->flow_spacing/2;
my $new_radius = (scale($self->flow_width) + sqrt((scale($self->flow_width)**2) + (4*($radius**2)))) / 2;
# holes are always turned to contours, so reverse point order before and after
$hole->reverse;
my @offsetted = $hole->offset(+ ($new_radius - $radius));
@ -221,7 +233,7 @@ sub make_perimeters {
push @{ $perimeters[-1] }, [@last_offsets];
# offset distance for inner loops
$distance = scale $Slic3r::flow_spacing;
$distance = scale $self->flow_spacing;
}
# create one more offset to be used as boundary for fill
@ -237,7 +249,7 @@ sub make_perimeters {
);
push @{ $self->thin_fills },
grep $_,
map $_->medial_axis(scale $Slic3r::flow_width),
map $_->medial_axis(scale $self->flow_width),
@$small_gaps if 0;
}
}
@ -309,7 +321,7 @@ sub add_perimeter {
my $self = shift;
my ($polygon, $role) = @_;
return unless $polygon->is_printable;
return unless $polygon->is_printable($self->flow_width);
push @{ $self->perimeters }, Slic3r::ExtrusionLoop->new(
polygon => $polygon,
role => (abs($polygon->length) <= $Slic3r::small_perimeter_length) ? EXTR_ROLE_SMALLPERIMETER : ($role // EXTR_ROLE_PERIMETER), #/
@ -324,7 +336,7 @@ sub prepare_fill_surfaces {
# merge too small internal surfaces with their surrounding tops
# (if they're too small, they can be treated as solid)
{
my $min_area = ((7 * $Slic3r::flow_spacing / $Slic3r::scaling_factor)**2) * PI;
my $min_area = ((7 * $self->flow_spacing / $Slic3r::scaling_factor)**2) * PI;
my $small_internal = [
grep { $_->expolygon->contour->area <= $min_area }
grep { $_->surface_type == S_TYPE_INTERNAL }
@ -357,7 +369,7 @@ sub prepare_fill_surfaces {
sub remove_small_surfaces {
my $self = shift;
my $distance = scale $Slic3r::flow_spacing / 2;
my $distance = scale $self->flow_spacing / 2;
my @surfaces = @{$self->fill_surfaces};
@{$self->fill_surfaces} = ();
@ -417,7 +429,7 @@ sub process_bridges {
# offset the contour and intersect it with the internal surfaces to discover
# which of them has contact with our bridge
my @supporting_surfaces = ();
my ($contour_offset) = $expolygon->contour->offset(scale $Slic3r::flow_spacing * sqrt(2));
my ($contour_offset) = $expolygon->contour->offset(scale $self->flow_spacing * sqrt(2));
foreach my $internal_surface (@internal_surfaces) {
my $intersection = intersection_ex([$contour_offset], [$internal_surface->p]);
if (@$intersection) {