Very large refactoring. Ditched Slic3r::Polyline::Closed and reorganized geometric classes.

This commit is contained in:
Alessandro Ranellucci 2011-12-30 19:59:51 +01:00
parent 2def6a9787
commit 8ed91a8ec4
20 changed files with 293 additions and 349 deletions

View file

@ -24,23 +24,15 @@ has 'lines' => (
);
# collection of surfaces generated by slicing the original geometry
has 'slices' => (
is => 'rw',
#isa => 'ArrayRef[Slic3r::Surface]',
default => sub { [] },
);
has 'slices' => (is => 'ro', default => sub { [] });
# collection of polygons or polylines representing thin walls contained
# in the original geometry
has 'thin_walls' => (is => 'rw', default => sub { [] });
has 'thin_walls' => (is => 'ro', default => sub { [] });
# collection of surfaces generated by offsetting the innermost perimeter(s)
# collection of expolygons generated by offsetting the innermost perimeter(s)
# they represent boundaries of areas to fill
has 'fill_boundaries' => (
is => 'rw',
#isa => 'ArrayRef[Slic3r::Surface]',
default => sub { [] },
);
has 'fill_boundaries' => (is => 'ro', default => sub { [] });
# collection of surfaces generated by clipping the slices to the fill boundaries
has 'surfaces' => (
@ -150,7 +142,7 @@ sub make_surfaces {
scalar(@$expolygons), scalar(map $_->holes, @$expolygons), scalar(@$loops);
push @{$self->slices},
map Slic3r::Surface->cast_from_expolygon($_, surface_type => 'internal'),
map Slic3r::Surface->new(expolygon => $_, surface_type => 'internal'),
@$expolygons;
}
@ -160,8 +152,8 @@ sub make_surfaces {
my @surfaces = @{$self->slices};
@{$self->slices} = ();
foreach my $surface (@surfaces) {
push @{$self->slices}, map Slic3r::Surface->cast_from_expolygon
($_, surface_type => 'internal'),
push @{$self->slices}, map Slic3r::Surface->new
(expolygon => $_, surface_type => 'internal'),
$surface->expolygon->offset_ex(-$distance);
}
@ -183,7 +175,7 @@ sub make_surfaces {
if (0) {
require "Slic3r/SVG.pm";
Slic3r::SVG::output(undef, "surfaces.svg",
polygons => [ map $_->contour->p, @{$self->slices} ],
polygons => [ map $_->contour, @{$self->slices} ],
red_polygons => [ map $_->p, map @{$_->holes}, @{$self->slices} ],
);
}
@ -210,7 +202,7 @@ sub prepare_fill_surfaces {
(map $_->p, grep $_->surface_type eq 'top', @surfaces),
(map @$_, map $_->expolygon->safety_offset, @$small_internal),
]);
my @top = map Slic3r::Surface->cast_from_expolygon($_, surface_type => 'top'), @$union;
my @top = map Slic3r::Surface->new(expolygon => $_, surface_type => 'top'), @$union;
@surfaces = (grep($_->surface_type ne 'top', @surfaces), @top);
}
@ -242,7 +234,8 @@ sub remove_small_surfaces {
@offsets = map $_->offset_ex($distance), @offsets;
@offsets = @{ union_ex([ map @$_, @offsets ], undef, 1) };
push @{$self->fill_surfaces}, map Slic3r::Surface->cast_from_expolygon($_,
push @{$self->fill_surfaces}, map Slic3r::Surface->new(
expolygon => $_,
surface_type => $surface->surface_type), @offsets;
}
@ -257,7 +250,8 @@ sub remove_small_surfaces {
[ map $_->p, @surfaces ],
[ map $_->p, @{$self->fill_surfaces} ],
);
push @{$self->fill_surfaces}, map Slic3r::Surface->cast_from_expolygon($_,
push @{$self->fill_surfaces}, map Slic3r::Surface->new(
expolygon => $_,
surface_type => 'internal-solid'), @$diff;
}
}
@ -382,7 +376,8 @@ sub process_bridges {
[ $bridge_offset ],
);
push @bridges, map Slic3r::Surface->cast_from_expolygon($_,
push @bridges, map Slic3r::Surface->new(
expolygon => $_,
surface_type => $surface->surface_type,
bridge_angle => $bridge_angle,
), @$intersection;
@ -405,7 +400,8 @@ sub process_bridges {
[ map $_->p, @bridges ],
);
push @bridges, map Slic3r::Surface->cast_from_expolygon($_,
push @bridges, map Slic3r::Surface->new(
expolygon => $_,
surface_type => $surfaces->[0]->surface_type,
bridge_angle => $surfaces->[0]->bridge_angle,
), @$union;
@ -424,7 +420,8 @@ sub process_bridges {
[ $bridge->p ],
);
push @{$self->fill_surfaces}, map Slic3r::Surface->cast_from_expolygon($_,
push @{$self->fill_surfaces}, map Slic3r::Surface->new(
expolygon => $_,
surface_type => $bridge->surface_type,
bridge_angle => $bridge->bridge_angle,
), @$actual_bridge;
@ -436,7 +433,8 @@ sub process_bridges {
[ map $_->p, @$group ],
[ map $_->p, @bridges ],
);
push @{$self->fill_surfaces}, map Slic3r::Surface->cast_from_expolygon($_,
push @{$self->fill_surfaces}, map Slic3r::Surface->new(
expolygon => $_,
surface_type => $group->[0]->surface_type), @$difference;
}
}