mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-08-05 21:14:01 -06:00
Implemented Slic3r::ExtrusionLoop
This commit is contained in:
parent
c9749ca3b3
commit
d0701cdcd4
10 changed files with 145 additions and 88 deletions
|
@ -1,38 +1,20 @@
|
|||
package Slic3r::ExtrusionLoop;
|
||||
use Moo;
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use Slic3r::Geometry qw(same_point);
|
||||
|
||||
# the underlying Slic3r::Polygon objects holds the geometry
|
||||
has 'polygon' => (
|
||||
is => 'rw',
|
||||
required => 1,
|
||||
handles => [qw(is_printable nearest_point_index_to reverse)],
|
||||
);
|
||||
|
||||
has 'flow_spacing' => (is => 'rw', required => 1);
|
||||
|
||||
# see EXTR_ROLE_* constants in ExtrusionPath.pm
|
||||
has 'role' => (is => 'rw', required => 1);
|
||||
|
||||
use constant PACK_FMT => 'fca*';
|
||||
sub polygon { $_[0] }
|
||||
|
||||
# class or object method
|
||||
sub pack {
|
||||
my $self = shift;
|
||||
my %args = @_;
|
||||
|
||||
if (ref $self) {
|
||||
%args = map { $_ => $self->$_ } qw(flow_spacing role polygon);
|
||||
return $self;
|
||||
} else {
|
||||
return $self->new(@_);
|
||||
}
|
||||
|
||||
my $o = \ pack PACK_FMT,
|
||||
$args{flow_spacing} || -1,
|
||||
$args{role} // (die "Missing mandatory attribute 'role'"), #/
|
||||
$args{polygon}->serialize;
|
||||
|
||||
bless $o, 'Slic3r::ExtrusionLoop::Packed';
|
||||
return $o;
|
||||
}
|
||||
|
||||
# no-op
|
||||
|
@ -42,9 +24,10 @@ sub split_at_index {
|
|||
my $self = shift;
|
||||
|
||||
return Slic3r::ExtrusionPath->new(
|
||||
polyline => $self->polygon->split_at_index(@_),
|
||||
polyline => $self->as_polygon->split_at_index(@_),
|
||||
role => $self->role,
|
||||
flow_spacing => $self->flow_spacing,
|
||||
height => $self->height,
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -52,9 +35,10 @@ sub split_at {
|
|||
my $self = shift;
|
||||
|
||||
return Slic3r::ExtrusionPath->new(
|
||||
polyline => $self->polygon->split_at(@_),
|
||||
polyline => $self->as_polygon->split_at(@_),
|
||||
role => $self->role,
|
||||
flow_spacing => $self->flow_spacing,
|
||||
height => $self->height,
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -68,18 +52,4 @@ sub first_point {
|
|||
return $self->polygon->[0];
|
||||
}
|
||||
|
||||
package Slic3r::ExtrusionLoop::Packed;
|
||||
sub unpack {
|
||||
my $self = shift;
|
||||
|
||||
my ($flow_spacing, $role, $polygon_s)
|
||||
= unpack Slic3r::ExtrusionLoop::PACK_FMT, $$self;
|
||||
|
||||
return Slic3r::ExtrusionLoop->new(
|
||||
flow_spacing => ($flow_spacing == -1) ? undef : $flow_spacing,
|
||||
role => $role,
|
||||
polygon => Slic3r::Polygon->deserialize($polygon_s),
|
||||
);
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue