From be7e211bb69d9863d6141002bdc28793a01abad5 Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Tue, 30 Oct 2012 14:07:01 +0100 Subject: [PATCH] Make flow_spacing required for ExtrusionPath objects --- lib/Slic3r.pm | 2 +- lib/Slic3r/Fill/Concentric.pm | 2 +- lib/Slic3r/Fill/Honeycomb.pm | 6 ++---- lib/Slic3r/Fill/Rectilinear.pm | 14 +++++++------- lib/Slic3r/GCode.pm | 8 ++++---- 5 files changed, 15 insertions(+), 17 deletions(-) diff --git a/lib/Slic3r.pm b/lib/Slic3r.pm index 1b4c57069..f7ffc3af8 100644 --- a/lib/Slic3r.pm +++ b/lib/Slic3r.pm @@ -60,7 +60,7 @@ use constant SCALING_FACTOR => 0.000001; use constant RESOLUTION => 0.01; use constant OVERLAP_FACTOR => 0.5; use constant SMALL_PERIMETER_LENGTH => (6.5 / SCALING_FACTOR) * 2 * PI; -use constant LOOP_CLIPPING_LENGTH_OVER_WIDTH => 0.15; +use constant LOOP_CLIPPING_LENGTH_OVER_SPACING => 0.15; use constant PERIMETER_INFILL_OVERLAP_OVER_WIDTH => 0.4; # The following variables hold the objects used throughout the slicing diff --git a/lib/Slic3r/Fill/Concentric.pm b/lib/Slic3r/Fill/Concentric.pm index b66f54bb6..a0cf087d6 100644 --- a/lib/Slic3r/Fill/Concentric.pm +++ b/lib/Slic3r/Fill/Concentric.pm @@ -63,7 +63,7 @@ sub fill_surface { my $path = $loop->split_at_index($index); # clip the path to avoid the extruder to get exactly on the first point of the loop - $path->clip_end(($self->layer ? $self->layer->flow->scaled_width : $Slic3r::flow->scaled_width) * &Slic3r::LOOP_CLIPPING_LENGTH_OVER_WIDTH); + $path->clip_end(($self->layer ? $self->layer->flow->scaled_spacing : $Slic3r::flow->scaled_spacing) * &Slic3r::LOOP_CLIPPING_LENGTH_OVER_SPACING); push @paths, $path->points if @{$path->points}; } diff --git a/lib/Slic3r/Fill/Honeycomb.pm b/lib/Slic3r/Fill/Honeycomb.pm index b635062c5..ccbe89956 100644 --- a/lib/Slic3r/Fill/Honeycomb.pm +++ b/lib/Slic3r/Fill/Honeycomb.pm @@ -90,12 +90,10 @@ sub fill_surface { $self->cache->{$cache_id}, [ map @$_, $expolygon->offset_ex($overlap_distance) ], )}; - my $collection = Slic3r::ExtrusionPath::Collection->new( - paths => [ map Slic3r::ExtrusionPath->pack(polyline => $_, role => -1), @paths ], - ); return { flow_spacing => $params{flow_spacing} }, - map $_->polyline, $collection->shortest_path; + map $_->polyline, + Slic3r::Polyline::Collection->new(polylines => \@paths)->shortest_path; } 1; diff --git a/lib/Slic3r/Fill/Rectilinear.pm b/lib/Slic3r/Fill/Rectilinear.pm index eceed4ef3..37de1521c 100644 --- a/lib/Slic3r/Fill/Rectilinear.pm +++ b/lib/Slic3r/Fill/Rectilinear.pm @@ -59,8 +59,8 @@ sub fill_surface { # connect lines unless ($params{dont_connect}) { - my $collection = Slic3r::ExtrusionPath::Collection->new( - paths => [ map Slic3r::ExtrusionPath->new(polyline => Slic3r::Polyline->new(@$_), role => -1), @paths ], + my $collection = Slic3r::Polyline::Collection->new( + polylines => [ map Slic3r::Polyline->new(@$_), @paths ], ); @paths = (); @@ -75,17 +75,17 @@ sub fill_surface { foreach my $path ($collection->shortest_path) { if (@paths) { - my @distance = map abs($path->points->[0][$_] - $paths[-1][-1][$_]), (X,Y); + my @distance = map abs($path->[0][$_] - $paths[-1][-1][$_]), (X,Y); # TODO: we should also check that both points are on a fill_boundary to avoid # connecting paths on the boundaries of internal regions - if ($can_connect->(@distance, $paths[-1][-1], $path->points->[0]) - && $expolygon_off->encloses_line(Slic3r::Line->new($paths[-1][-1], $path->points->[0]), $tolerance)) { - push @{$paths[-1]}, @{$path->points}; + if ($can_connect->(@distance, $paths[-1][-1], $path->[0]) + && $expolygon_off->encloses_line(Slic3r::Line->new($paths[-1][-1], $path->[0]), $tolerance)) { + push @{$paths[-1]}, @$path; next; } } - push @paths, $path->points; + push @paths, $path; } } diff --git a/lib/Slic3r/GCode.pm b/lib/Slic3r/GCode.pm index 994e4fc7f..095b5666a 100644 --- a/lib/Slic3r/GCode.pm +++ b/lib/Slic3r/GCode.pm @@ -114,7 +114,7 @@ sub extrude_loop { # clip the path to avoid the extruder to get exactly on the first point of the loop; # if polyline was shorter than the clipping distance we'd get a null polyline, so # we discard it in that case - $extrusion_path->clip_end(($self->layer ? $self->layer->flow->scaled_width : $Slic3r::flow->scaled_width) * &Slic3r::LOOP_CLIPPING_LENGTH_OVER_WIDTH); + $extrusion_path->clip_end(scale $extrusion_path->flow_spacing * &Slic3r::LOOP_CLIPPING_LENGTH_OVER_SPACING); return '' if !@{$extrusion_path->polyline}; # extrude along the path @@ -149,7 +149,7 @@ sub extrude_path { my @lines = $self->last_path->lines; my $last_line = $lines[-1]; if (points_coincide($last_line->[B], $self->last_pos)) { - my $point = Slic3r::Geometry::point_along_segment(@$last_line, $last_line->length + scale $self->layer->flow->spacing); + my $point = Slic3r::Geometry::point_along_segment(@$last_line, $last_line->length + scale $path->flow_spacing); bless $point, 'Slic3r::Point'; $point->rotate(PI/6, $last_line->[B]); $gcode .= $self->G0($point, undef, 0, "move inwards before travel"); @@ -169,10 +169,10 @@ sub extrude_path { my $area; # mm^3 of extrudate per mm of tool movement if ($path->role == EXTR_ROLE_BRIDGE) { - my $s = $path->flow_spacing || $self->extruder->nozzle_diameter; + my $s = $path->flow_spacing; $area = ($s**2) * PI/4; } else { - my $s = $path->flow_spacing || ($self->layer ? $self->layer->flow->spacing : $Slic3r::flow->spacing); + my $s = $path->flow_spacing; my $h = $path->height // $self->layer->height; $area = $self->extruder->mm3_per_mm($s, $h); }