2011-11-13 17:14:02 +00:00
|
|
|
package Slic3r::Fill::PlanePath;
|
|
|
|
use Moo;
|
|
|
|
|
|
|
|
extends 'Slic3r::Fill::Base';
|
|
|
|
|
2011-12-07 18:33:59 +00:00
|
|
|
use Slic3r::Geometry qw(scale bounding_box X1 Y1 X2 Y2);
|
2011-11-13 17:14:02 +00:00
|
|
|
use XXX;
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
2011-12-17 18:52:34 +00:00
|
|
|
my $distance_between_lines = scale $params{flow_spacing} / $params{density} * $self->multiplier;
|
2011-11-13 17:14:02 +00:00
|
|
|
my $bounding_box = [ bounding_box(map @$_, $expolygon) ];
|
2011-11-14 09:54:04 +00:00
|
|
|
my $bounding_box_polygon = Slic3r::Polygon->new([
|
|
|
|
[ $bounding_box->[X1], $bounding_box->[Y1] ],
|
|
|
|
[ $bounding_box->[X2], $bounding_box->[Y1] ],
|
|
|
|
[ $bounding_box->[X2], $bounding_box->[Y2] ],
|
|
|
|
[ $bounding_box->[X1], $bounding_box->[Y2] ],
|
|
|
|
]);
|
2011-11-13 17:14:02 +00:00
|
|
|
|
|
|
|
(ref $self) =~ /::([^:]+)$/;
|
|
|
|
my $path = "Math::PlanePath::$1"->new;
|
|
|
|
my @n = $self->get_n($path, [map +($_ / $distance_between_lines), @$bounding_box]);
|
|
|
|
|
2011-12-30 18:59:51 +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,
|
|
|
|
]);
|
2012-01-12 09:48:18 +00:00
|
|
|
return {} if !@$polyline;
|
2011-11-13 17:14:02 +00:00
|
|
|
|
|
|
|
$self->process_polyline($polyline, $bounding_box);
|
|
|
|
|
2011-11-14 09:54:04 +00:00
|
|
|
my @paths = map $_->clip_with_expolygon($expolygon),
|
|
|
|
$polyline->clip_with_polygon($bounding_box_polygon);
|
2011-11-13 17:14:02 +00:00
|
|
|
|
|
|
|
if (0) {
|
|
|
|
require "Slic3r/SVG.pm";
|
|
|
|
Slic3r::SVG::output(undef, "fill.svg",
|
|
|
|
polygons => $expolygon,
|
|
|
|
polylines => [map $_->p, @paths],
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
# paths must be rotated back
|
|
|
|
$self->rotate_points_back(\@paths, $rotate_vector);
|
|
|
|
|
2011-12-04 15:24:46 +00:00
|
|
|
return {}, @paths;
|
2011-11-13 17:14:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
1;
|