2011-11-26 09:38:05 +00:00
|
|
|
package Slic3r::Fill::Concentric;
|
|
|
|
use Moo;
|
|
|
|
|
|
|
|
extends 'Slic3r::Fill::Base';
|
|
|
|
|
2012-05-19 13:40:11 +00:00
|
|
|
use Slic3r::ExtrusionPath ':roles';
|
2011-12-17 19:29:06 +00:00
|
|
|
use Slic3r::Geometry qw(scale unscale X1 Y1 X2 Y2);
|
2011-11-26 09:38:05 +00:00
|
|
|
|
|
|
|
sub fill_surface {
|
|
|
|
my $self = shift;
|
|
|
|
my ($surface, %params) = @_;
|
|
|
|
|
|
|
|
# no rotation is supported for this infill pattern
|
|
|
|
|
2011-12-17 19:29:06 +00:00
|
|
|
my $expolygon = $surface->expolygon;
|
|
|
|
my $bounding_box = [ $expolygon->bounding_box ];
|
2011-12-17 18:56:56 +00:00
|
|
|
|
2011-12-17 19:29:06 +00:00
|
|
|
my $min_spacing = scale $params{flow_spacing};
|
|
|
|
my $distance = $min_spacing / $params{density};
|
|
|
|
|
2012-09-12 10:13:43 +00:00
|
|
|
my $flow_spacing = $params{flow_spacing};
|
2012-11-16 17:10:09 +00:00
|
|
|
if ($params{density} == 1 && !$params{dont_adjust) {
|
2011-12-19 08:55:03 +00:00
|
|
|
$distance = $self->adjust_solid_spacing(
|
|
|
|
width => $bounding_box->[X2] - $bounding_box->[X1],
|
|
|
|
distance => $distance,
|
|
|
|
);
|
|
|
|
$flow_spacing = unscale $distance;
|
|
|
|
}
|
2011-11-26 09:38:05 +00:00
|
|
|
|
|
|
|
my @contour_loops = ();
|
|
|
|
my @hole_loops = ();
|
2011-12-17 19:29:06 +00:00
|
|
|
my @last_offsets = ($expolygon->offset_ex($distance));
|
2011-11-26 09:38:05 +00:00
|
|
|
while (@last_offsets) {
|
|
|
|
my @new_offsets = ();
|
2011-12-17 19:29:06 +00:00
|
|
|
foreach my $last_expolygon (@last_offsets) {
|
|
|
|
my @offsets = $last_expolygon->offset_ex(-$distance);
|
2011-11-26 09:38:05 +00:00
|
|
|
foreach my $offset (@offsets) {
|
|
|
|
push @new_offsets, $offset;
|
|
|
|
push @contour_loops, $offset->contour;
|
|
|
|
push @hole_loops, $offset->holes;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@last_offsets = @new_offsets;
|
|
|
|
}
|
|
|
|
|
|
|
|
my @loops = (@contour_loops, reverse @hole_loops);
|
|
|
|
|
|
|
|
# make paths
|
|
|
|
my @paths = ();
|
2011-12-17 18:56:56 +00:00
|
|
|
my $cur_pos = Slic3r::Point->new(
|
|
|
|
($bounding_box->[X1] + $bounding_box->[X2]) / 2,
|
|
|
|
($bounding_box->[Y1] + $bounding_box->[Y2]) / 2,
|
|
|
|
);
|
2012-10-30 14:29:13 +00:00
|
|
|
foreach my $loop (@loops) {
|
2012-04-03 12:11:12 +00:00
|
|
|
# extrude all loops ccw
|
2012-10-30 14:29:13 +00:00
|
|
|
$loop->make_counter_clockwise;
|
2012-04-03 12:11:12 +00:00
|
|
|
|
2011-11-26 09:38:05 +00:00
|
|
|
# find the point of the loop that is closest to the current extruder position
|
2012-07-02 19:26:56 +00:00
|
|
|
my $index = $loop->nearest_point_index_to($cur_pos);
|
2012-10-30 14:29:13 +00:00
|
|
|
$cur_pos = $loop->[0];
|
2011-11-26 09:38:05 +00:00
|
|
|
|
|
|
|
# split the loop at the starting point and make a path
|
2012-07-02 19:26:56 +00:00
|
|
|
my $path = $loop->split_at_index($index);
|
2011-11-28 21:52:35 +00:00
|
|
|
|
2011-11-26 09:38:05 +00:00
|
|
|
# clip the path to avoid the extruder to get exactly on the first point of the loop
|
2012-10-30 13:17:30 +00:00
|
|
|
$path->clip_end(scale $flow_spacing * &Slic3r::LOOP_CLIPPING_LENGTH_OVER_SPACING);
|
2011-11-26 09:38:05 +00:00
|
|
|
|
2012-10-30 14:29:13 +00:00
|
|
|
push @paths, $path if @$path;
|
2011-11-26 09:38:05 +00:00
|
|
|
}
|
|
|
|
|
2011-12-17 19:29:06 +00:00
|
|
|
return { flow_spacing => $flow_spacing }, @paths;
|
2011-11-26 09:38:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
1;
|