PrusaSlicer-NonPlainar/lib/Slic3r/Layer.pm

67 lines
1.4 KiB
Perl
Raw Normal View History

2011-09-01 19:06:28 +00:00
package Slic3r::Layer;
use List::Util qw(first);
use Slic3r::Geometry qw(scale chained_path);
use Slic3r::Geometry::Clipper qw(union_ex);
2011-09-01 19:06:28 +00:00
# the following two were previously generated by Moo
sub print {
my $self = shift;
return $self->object->print;
}
sub config {
my $self = shift;
return $self->object->config;
}
# the purpose of this method is to be overridden for ::Support layers
sub islands {
my $self = shift;
return $self->slices;
2013-06-03 10:29:45 +00:00
}
2012-09-23 00:52:31 +00:00
sub region {
my $self = shift;
2012-09-23 00:52:31 +00:00
my ($region_id) = @_;
while ($self->region_count <= $region_id) {
$self->add_region($self->object->print->get_region($self->region_count));
}
return $self->get_region($region_id);
}
sub regions {
my ($self) = @_;
return [ map $self->get_region($_), 0..($self->region_count-1) ];
}
2012-09-23 00:52:31 +00:00
# merge all regions' slices to get islands
sub make_slices {
my $self = shift;
my $slices = union_ex([ map $_->p, map @{$_->slices}, @{$self->regions} ]);
# sort slices
$slices = [ @$slices[@{chained_path([ map $_->contour->first_point, @$slices ])}] ];
$self->slices->clear;
$self->slices->append(@$slices);
}
sub make_perimeters {
my $self = shift;
Slic3r::debugf "Making perimeters for layer %d\n", $self->id;
2012-09-23 00:52:31 +00:00
$_->make_perimeters for @{$self->regions};
}
2013-07-29 18:49:54 +00:00
package Slic3r::Layer::Support;
sub islands {
my $self = shift;
return [ @{$self->slices}, @{$self->support_islands} ];
}
2011-09-01 19:06:28 +00:00
1;