2011-09-01 19:06:28 +00:00
|
|
|
package Slic3r::Layer;
|
2011-09-06 09:50:43 +00:00
|
|
|
use Moo;
|
2011-09-01 19:06:28 +00:00
|
|
|
|
2012-12-20 17:47:40 +00:00
|
|
|
use List::Util qw(first);
|
2013-01-28 13:12:01 +00:00
|
|
|
use Slic3r::Geometry qw(scale);
|
2012-09-22 17:04:36 +00:00
|
|
|
use Slic3r::Geometry::Clipper qw(union_ex);
|
2011-09-01 19:06:28 +00:00
|
|
|
|
2012-10-28 09:28:40 +00:00
|
|
|
has 'id' => (is => 'rw', required => 1, trigger => 1); # sequential number of layer, 0-based
|
2013-08-25 12:37:50 +00:00
|
|
|
has 'object' => (is => 'ro', weak_ref => 1, required => 1, handles => [qw(print config)]);
|
2012-09-23 00:52:31 +00:00
|
|
|
has 'regions' => (is => 'ro', default => sub { [] });
|
2012-09-22 17:04:36 +00:00
|
|
|
has 'slicing_errors' => (is => 'rw');
|
2011-09-01 19:06:28 +00:00
|
|
|
|
2013-03-10 10:37:16 +00:00
|
|
|
has 'slice_z' => (is => 'ro', required => 1); # Z used for slicing in scaled coordinates
|
2013-07-28 22:27:53 +00:00
|
|
|
has 'print_z' => (is => 'ro', required => 1); # Z used for printing in unscaled coordinates
|
2013-03-10 10:37:16 +00:00
|
|
|
has 'height' => (is => 'ro', required => 1); # layer height in unscaled coordinates
|
2011-11-30 15:28:09 +00:00
|
|
|
|
2012-09-22 17:38:25 +00:00
|
|
|
# collection of expolygons generated by slicing the original geometry;
|
2013-06-20 17:43:53 +00:00
|
|
|
# also known as 'islands' (all regions and surface types are merged here)
|
2013-07-14 13:06:49 +00:00
|
|
|
has 'slices' => (is => 'rw', default => sub { Slic3r::ExPolygon::Collection->new });
|
2011-09-04 10:04:01 +00:00
|
|
|
|
2012-10-28 09:28:40 +00:00
|
|
|
sub _trigger_id {
|
|
|
|
my $self = shift;
|
|
|
|
$_->_trigger_layer for @{$self->regions || []};
|
|
|
|
}
|
|
|
|
|
2013-08-09 12:55:36 +00:00
|
|
|
sub islands {
|
|
|
|
my $self = shift;
|
|
|
|
return @{$self->slices};
|
|
|
|
}
|
|
|
|
|
|
|
|
sub upper_layer_islands {
|
2013-06-03 10:25:32 +00:00
|
|
|
my $self = shift;
|
|
|
|
|
2013-08-09 12:55:36 +00:00
|
|
|
my $upper_layer = $self->object->layers->[ $self->id + 1 ] or return ();
|
|
|
|
return $upper_layer->islands;
|
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
|
|
|
|
2012-11-05 14:59:31 +00:00
|
|
|
for (my $i = @{$self->regions}; $i <= $region_id; $i++) {
|
|
|
|
$self->regions->[$i] //= Slic3r::Layer::Region->new(
|
2012-09-23 00:52:31 +00:00
|
|
|
layer => $self,
|
2012-11-05 14:59:31 +00:00
|
|
|
region => $self->object->print->regions->[$i],
|
2012-07-20 13:02:25 +00:00
|
|
|
);
|
2012-04-29 10:51:20 +00:00
|
|
|
}
|
2012-11-05 14:59:31 +00:00
|
|
|
|
2012-09-23 00:52:31 +00:00
|
|
|
return $self->regions->[$region_id];
|
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
|
|
|
|
|
|
|
my $slices = union_ex([ map $_->p, map @{$_->slices}, @{$self->regions} ]);
|
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;
|
|
|
|
use Moo;
|
|
|
|
extends 'Slic3r::Layer';
|
|
|
|
|
|
|
|
# ordered collection of extrusion paths to fill surfaces for support material
|
2013-08-09 12:55:36 +00:00
|
|
|
has 'support_islands' => (is => 'rw', default => sub { [] });
|
2013-07-29 18:49:54 +00:00
|
|
|
has 'support_fills' => (is => 'rw');
|
|
|
|
has 'support_interface_fills' => (is => 'rw');
|
|
|
|
|
2013-08-09 12:55:36 +00:00
|
|
|
sub islands {
|
|
|
|
my $self = shift;
|
|
|
|
return @{$self->slices}, @{$self->support_islands};
|
|
|
|
}
|
|
|
|
|
2011-09-01 19:06:28 +00:00
|
|
|
1;
|