2011-09-01 19:06:28 +00:00
|
|
|
package Slic3r::Layer;
|
2014-06-12 07:23:10 +00:00
|
|
|
use strict;
|
|
|
|
use warnings;
|
2011-09-01 19:06:28 +00:00
|
|
|
|
2012-12-20 17:47:40 +00:00
|
|
|
use List::Util qw(first);
|
2014-04-25 17:11:17 +00:00
|
|
|
use Slic3r::Geometry qw(scale chained_path);
|
2012-09-22 17:04:36 +00:00
|
|
|
use Slic3r::Geometry::Clipper qw(union_ex);
|
2011-09-01 19:06:28 +00:00
|
|
|
|
2014-05-06 08:07:18 +00:00
|
|
|
# the following two were previously generated by Moo
|
|
|
|
sub print {
|
|
|
|
my $self = shift;
|
|
|
|
return $self->object->print;
|
|
|
|
}
|
2011-11-30 15:28:09 +00:00
|
|
|
|
2014-05-06 08:07:18 +00:00
|
|
|
sub config {
|
|
|
|
my $self = shift;
|
|
|
|
return $self->object->config;
|
|
|
|
}
|
2011-09-04 10:04:01 +00:00
|
|
|
|
2013-11-11 19:37:06 +00:00
|
|
|
# the purpose of this method is to be overridden for ::Support layers
|
2013-08-09 12:55:36 +00:00
|
|
|
sub islands {
|
|
|
|
my $self = shift;
|
2013-11-11 19:37:06 +00:00
|
|
|
return $self->slices;
|
2013-06-03 10:29:45 +00:00
|
|
|
}
|
2013-06-03 10:25:32 +00:00
|
|
|
|
2012-09-23 00:52:31 +00:00
|
|
|
sub region {
|
2012-04-29 10:51:20 +00:00
|
|
|
my $self = shift;
|
2012-09-23 00:52:31 +00:00
|
|
|
my ($region_id) = @_;
|
2012-04-29 10:51:20 +00:00
|
|
|
|
2014-05-06 08:07:18 +00:00
|
|
|
while ($self->region_count <= $region_id) {
|
|
|
|
$self->add_region($self->object->print->get_region($self->region_count));
|
2012-04-29 10:51:20 +00:00
|
|
|
}
|
2012-11-05 14:59:31 +00:00
|
|
|
|
2014-05-06 08:07:18 +00:00
|
|
|
return $self->get_region($region_id);
|
|
|
|
}
|
|
|
|
|
|
|
|
sub regions {
|
|
|
|
my ($self) = @_;
|
|
|
|
return [ map $self->get_region($_), 0..($self->region_count-1) ];
|
2012-04-29 10:51:20 +00:00
|
|
|
}
|
|
|
|
|
2012-09-23 00:52:31 +00:00
|
|
|
# merge all regions' slices to get islands
|
2012-09-22 17:04:36 +00:00
|
|
|
sub make_slices {
|
2011-11-30 19:32:28 +00:00
|
|
|
my $self = shift;
|
2013-07-07 10:54:20 +00:00
|
|
|
|
2014-06-09 22:54:37 +00:00
|
|
|
my $slices;
|
|
|
|
if (@{$self->regions} == 1) {
|
|
|
|
$slices = [ map $_->expolygon->clone, @{$self->regions->[0]->slices} ];
|
|
|
|
} else {
|
|
|
|
$slices = union_ex([ map $_->p, map @{$_->slices}, @{$self->regions} ]);
|
|
|
|
}
|
2014-04-25 17:11:17 +00:00
|
|
|
|
|
|
|
# sort slices
|
|
|
|
$slices = [ @$slices[@{chained_path([ map $_->contour->first_point, @$slices ])}] ];
|
|
|
|
|
2013-07-14 13:06:49 +00:00
|
|
|
$self->slices->clear;
|
2013-08-08 00:10:34 +00:00
|
|
|
$self->slices->append(@$slices);
|
2011-10-07 17:07:57 +00:00
|
|
|
}
|
|
|
|
|
2012-09-22 17:04:36 +00:00
|
|
|
sub make_perimeters {
|
2011-10-07 17:07:57 +00:00
|
|
|
my $self = shift;
|
2012-09-22 17:04:36 +00:00
|
|
|
Slic3r::debugf "Making perimeters for layer %d\n", $self->id;
|
2012-09-23 00:52:31 +00:00
|
|
|
$_->make_perimeters for @{$self->regions};
|
2011-10-07 17:07:57 +00:00
|
|
|
}
|
|
|
|
|
2013-07-29 18:49:54 +00:00
|
|
|
package Slic3r::Layer::Support;
|
|
|
|
|
2014-05-19 22:03:29 +00:00
|
|
|
our @ISA = qw(Slic3r::Layer);
|
2013-07-29 18:49:54 +00:00
|
|
|
|
2013-08-09 12:55:36 +00:00
|
|
|
sub islands {
|
|
|
|
my $self = shift;
|
2013-11-11 19:37:06 +00:00
|
|
|
return [ @{$self->slices}, @{$self->support_islands} ];
|
2013-08-09 12:55:36 +00:00
|
|
|
}
|
|
|
|
|
2011-09-01 19:06:28 +00:00
|
|
|
1;
|