Refactoring: use the clone() method for inflating Surface objects
This commit is contained in:
parent
e563c62094
commit
1b79b1cb20
4 changed files with 21 additions and 32 deletions
|
@ -89,13 +89,7 @@ sub make_fill {
|
||||||
1,
|
1,
|
||||||
);
|
);
|
||||||
|
|
||||||
push @surfaces, map Slic3r::Surface->new(
|
push @surfaces, map $group->[0]->clone(expolygon => $_), @$union;
|
||||||
expolygon => $_,
|
|
||||||
surface_type => $group->[0]->surface_type,
|
|
||||||
bridge_angle => $group->[0]->bridge_angle,
|
|
||||||
thickness => $group->[0]->thickness,
|
|
||||||
thickness_layers => $group->[0]->thickness_layers,
|
|
||||||
), @$union;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -514,10 +514,7 @@ sub process_external_surfaces {
|
||||||
# subtract the new top surfaces from the other non-top surfaces and re-add them
|
# subtract the new top surfaces from the other non-top surfaces and re-add them
|
||||||
my @other = grep $_->surface_type != S_TYPE_TOP && $_->surface_type != S_TYPE_BOTTOM, @{$self->fill_surfaces};
|
my @other = grep $_->surface_type != S_TYPE_TOP && $_->surface_type != S_TYPE_BOTTOM, @{$self->fill_surfaces};
|
||||||
foreach my $group (Slic3r::Surface->group(@other)) {
|
foreach my $group (Slic3r::Surface->group(@other)) {
|
||||||
push @new_surfaces, map Slic3r::Surface->new(
|
push @new_surfaces, map $group->[0]->clone(expolygon => $_), @{diff_ex(
|
||||||
expolygon => $_,
|
|
||||||
surface_type => $group->[0]->surface_type,
|
|
||||||
), @{diff_ex(
|
|
||||||
[ map $_->p, @$group ],
|
[ map $_->p, @$group ],
|
||||||
[ map $_->p, @new_surfaces ],
|
[ map $_->p, @new_surfaces ],
|
||||||
)};
|
)};
|
||||||
|
|
|
@ -543,10 +543,8 @@ sub bridge_over_infill {
|
||||||
my @new_surfaces = ();
|
my @new_surfaces = ();
|
||||||
# subtract the area from all types of surfaces
|
# subtract the area from all types of surfaces
|
||||||
foreach my $group (Slic3r::Surface->group(@{$lower_layerm->fill_surfaces})) {
|
foreach my $group (Slic3r::Surface->group(@{$lower_layerm->fill_surfaces})) {
|
||||||
push @new_surfaces, map Slic3r::Surface->new(
|
push @new_surfaces, map $group->[0]->clone(expolygon => $_),
|
||||||
expolygon => $_,
|
@{diff_ex(
|
||||||
surface_type => $group->[0]->surface_type,
|
|
||||||
), @{diff_ex(
|
|
||||||
[ map $_->p, @$group ],
|
[ map $_->p, @$group ],
|
||||||
[ map @$_, @$to_bridge ],
|
[ map @$_, @$to_bridge ],
|
||||||
)};
|
)};
|
||||||
|
@ -669,8 +667,7 @@ sub discover_horizontal_shells {
|
||||||
[ map @$_, @$internal_solid, @$internal ],
|
[ map @$_, @$internal_solid, @$internal ],
|
||||||
1,
|
1,
|
||||||
);
|
);
|
||||||
push @$neighbor_fill_surfaces, Slic3r::Surface->new
|
push @$neighbor_fill_surfaces, $s->[0]->clone(expolygon => $_)
|
||||||
(expolygon => $_, surface_type => $s->[0]->surface_type, bridge_angle => $s->[0]->bridge_angle)
|
|
||||||
for @$solid_surfaces;
|
for @$solid_surfaces;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,6 +34,17 @@ sub new {
|
||||||
$self;
|
$self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub clone {
|
||||||
|
my $self = shift;
|
||||||
|
my %p = @_;
|
||||||
|
|
||||||
|
return (ref $self)->new(
|
||||||
|
(map { $_ => $self->$_ } qw(surface_type thickness thickness_layers bridge_angle)),
|
||||||
|
expolygon => ($p{expolygon} ? delete $p{expolygon} : $self->expolygon->clone),
|
||||||
|
%p,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
sub expolygon { $_[0][S_EXPOLYGON] }
|
sub expolygon { $_[0][S_EXPOLYGON] }
|
||||||
sub surface_type { $_[0][S_SURFACE_TYPE] = $_[1] if defined $_[1]; $_[0][S_SURFACE_TYPE] }
|
sub surface_type { $_[0][S_SURFACE_TYPE] = $_[1] if defined $_[1]; $_[0][S_SURFACE_TYPE] }
|
||||||
sub thickness { $_[0][S_THICKNESS] }
|
sub thickness { $_[0][S_THICKNESS] }
|
||||||
|
@ -85,22 +96,12 @@ sub group {
|
||||||
|
|
||||||
sub offset {
|
sub offset {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
return map $self->_inflate_expolygon($_), $self->expolygon->offset_ex(@_);
|
return map $self->clone(expolygon => $_), $self->expolygon->offset_ex(@_);
|
||||||
}
|
}
|
||||||
|
|
||||||
sub simplify {
|
sub simplify {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
return map $self->_inflate_expolygon($_), $self->expolygon->simplify(@_);
|
return map $self->clone(expolygon => $_), $self->expolygon->simplify(@_);
|
||||||
}
|
|
||||||
|
|
||||||
sub _inflate_expolygon {
|
|
||||||
my $self = shift;
|
|
||||||
my ($expolygon) = @_;
|
|
||||||
|
|
||||||
return (ref $self)->new(
|
|
||||||
expolygon => $expolygon,
|
|
||||||
map { $_ => $self->$_ } qw(surface_type thickness thickness_layers bridge_angle),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sub p {
|
sub p {
|
||||||
|
|
Loading…
Reference in a new issue