1
package Slic3r::Fill::Concentric;
4
extends 'Slic3r::Fill::Base';
6
use Slic3r::Geometry qw(scale unscale X);
7
use Slic3r::Geometry::Clipper qw(offset offset2 union_pt_chained);
11
my ($surface, %params) = @_;
13
# no rotation is supported for this infill pattern
15
my $expolygon = $surface->expolygon;
16
my $bounding_box = $expolygon->bounding_box;
18
my $flow = $params{flow};
19
my $min_spacing = $flow->scaled_spacing;
20
my $distance = $min_spacing / $params{density};
22
my $flow_spacing = $flow->spacing;
23
if ($params{density} == 1 && !$params{dont_adjust}) {
24
$distance = $self->adjust_solid_spacing(
25
width => $bounding_box->size->[X],
26
distance => $distance,
28
$flow = Slic3r::Flow->new_from_spacing(
29
spacing => unscale($distance),
30
nozzle_diameter => $flow->nozzle_diameter,
31
layer_height => ($params{layer_height} or die "No layer_height supplied to fill_surface()"),
32
bridge => $flow->bridge,
36
# compensate the overlap which is good for rectilinear but harmful for concentric
37
# where the perimeter/infill spacing should be equal to any other loop spacing
38
my @loops = my @last = @{offset(\@$expolygon, -&Slic3r::INFILL_OVERLAP_OVER_SPACING * $min_spacing / 2)};
40
push @loops, @last = @{offset2(\@last, -1.5*$distance, +0.5*$distance)};
43
# generate paths from the outermost to the innermost, to avoid
44
# adhesion problems of the first central tiny loops
45
@loops = map Slic3r::Polygon->new(@$_),
46
reverse @{union_pt_chained(\@loops)};
48
# order paths using a nearest neighbor search
50
my $last_pos = Slic3r::Point->new(0,0);
51
foreach my $loop (@loops) {
52
push @paths, $loop->split_at_index($last_pos->nearest_point_index(\@$loop));
53
$last_pos = $paths[-1]->last_point;
56
# clip the paths to prevent the extruder from getting exactly on the first point of the loop
57
my $clip_length = scale($flow->nozzle_diameter) * &Slic3r::LOOP_CLIPPING_LENGTH_OVER_NOZZLE_DIAMETER;
58
$_->clip_end($clip_length) for @paths;
59
@paths = grep $_->is_valid, @paths; # remove empty paths (too short, thus eaten by clipping)
61
# TODO: return ExtrusionLoop objects to get better chained paths
62
return { flow => $flow, no_sort => 1 }, @paths;