2011-11-13 17:14:02 +00:00
|
|
|
package Slic3r::Fill::PlanePath;
|
|
|
|
use Moo;
|
|
|
|
|
|
|
|
extends 'Slic3r::Fill::Base';
|
|
|
|
|
2012-12-31 13:11:15 +00:00
|
|
|
use Slic3r::Geometry qw(scale X1 Y1 X2 Y2);
|
2013-11-21 17:16:03 +00:00
|
|
|
use Slic3r::Geometry::Clipper qw(intersection_pl);
|
2011-11-13 17:14:02 +00:00
|
|
|
|
|
|
|
sub multiplier () { 1 }
|
|
|
|
|
|
|
|
sub get_n {
|
|
|
|
my $self = shift;
|
|
|
|
my ($path, $bounding_box) = @_;
|
|
|
|
|
|
|
|
my ($n_lo, $n_hi) = $path->rect_to_n_range(@$bounding_box);
|
|
|
|
return ($n_lo .. $n_hi);
|
|
|
|
}
|
|
|
|
|
|
|
|
sub process_polyline {}
|
|
|
|
|
|
|
|
sub fill_surface {
|
|
|
|
my $self = shift;
|
|
|
|
my ($surface, %params) = @_;
|
|
|
|
|
|
|
|
# rotate polygons
|
2012-04-09 20:04:57 +00:00
|
|
|
my $expolygon = $surface->expolygon->clone;
|
2011-11-13 17:14:02 +00:00
|
|
|
my $rotate_vector = $self->infill_direction($surface);
|
|
|
|
$self->rotate_points($expolygon, $rotate_vector);
|
|
|
|
|
2014-01-03 19:02:00 +00:00
|
|
|
my $flow = $params{flow};
|
|
|
|
my $distance_between_lines = $flow->scaled_spacing / $params{density} * $self->multiplier;
|
2013-06-16 10:21:25 +00:00
|
|
|
my $bounding_box = $expolygon->bounding_box;
|
2011-11-13 17:14:02 +00:00
|
|
|
|
|
|
|
(ref $self) =~ /::([^:]+)$/;
|
|
|
|
my $path = "Math::PlanePath::$1"->new;
|
2014-01-07 11:48:09 +00:00
|
|
|
my @n = $self->get_n($path, [ map +($_ / $distance_between_lines), @{$bounding_box->min_point}, @{$bounding_box->max_point} ]);
|
2011-11-13 17:14:02 +00:00
|
|
|
|
2013-07-05 12:29:57 +00:00
|
|
|
my $polyline = Slic3r::Polyline->new(
|
2011-11-13 17:14:02 +00:00
|
|
|
map [ map {$_*$distance_between_lines} $path->n_to_xy($_) ], @n,
|
2013-07-05 12:29:57 +00:00
|
|
|
);
|
2013-10-13 14:07:14 +00:00
|
|
|
return {} if @$polyline <= 1;
|
2011-11-13 17:14:02 +00:00
|
|
|
|
|
|
|
$self->process_polyline($polyline, $bounding_box);
|
|
|
|
|
2013-11-21 17:16:03 +00:00
|
|
|
my @paths = @{intersection_pl([$polyline], \@$expolygon)};
|
2011-11-13 17:14:02 +00:00
|
|
|
|
|
|
|
if (0) {
|
|
|
|
require "Slic3r/SVG.pm";
|
2012-11-01 10:34:53 +00:00
|
|
|
Slic3r::SVG::output("fill.svg",
|
2011-11-13 17:14:02 +00:00
|
|
|
polygons => $expolygon,
|
|
|
|
polylines => [map $_->p, @paths],
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
# paths must be rotated back
|
|
|
|
$self->rotate_points_back(\@paths, $rotate_vector);
|
|
|
|
|
2014-01-03 19:02:00 +00:00
|
|
|
return { flow => $flow }, @paths;
|
2011-11-13 17:14:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
1;
|