diff options
author | Alessandro Ranellucci <aar@cpan.org> | 2011-11-23 12:49:39 +0400 |
---|---|---|
committer | Alessandro Ranellucci <aar@cpan.org> | 2011-11-23 12:49:39 +0400 |
commit | 13ef24b5ebd633a5286ee536b8f782c5a7e56d80 (patch) | |
tree | 3907e0551c5349fe8246fb548f41082f0373e0b0 /lib/Slic3r/Print.pm | |
parent | d13a0e250391bfd062d5b5c775ac789b9ef89c8e (diff) |
Fixes, improvements and refactoring for bridges and solid surfaces.
Diffstat (limited to 'lib/Slic3r/Print.pm')
-rw-r--r-- | lib/Slic3r/Print.pm | 38 |
1 files changed, 22 insertions, 16 deletions
diff --git a/lib/Slic3r/Print.pm b/lib/Slic3r/Print.pm index 3fb5653dd..85a9fc7b3 100644 --- a/lib/Slic3r/Print.pm +++ b/lib/Slic3r/Print.pm @@ -4,7 +4,7 @@ use Moo; use Math::ConvexHull 1.0.4 qw(convex_hull); use Slic3r::Geometry qw(X Y PI); use Slic3r::Geometry::Clipper qw(explode_expolygons safety_offset diff_ex intersection_ex - offset JT_ROUND JT_MITER); + union_ex offset JT_ROUND JT_MITER); use XXX; has 'x_length' => ( @@ -220,27 +220,32 @@ sub discover_horizontal_shells { foreach my $surfaces (@{$self->layers->[$n]->fill_surfaces}) { my @neighbor = @$surfaces; - my $neighbor_p = [ map $_->p, @neighbor ]; # find intersection between @surfaces and current layer's surfaces # intersections have contours and holes - my $intersections = intersection_ex($surfaces_p, $neighbor_p); + my $new_internal_solid = intersection_ex( + $surfaces_p, + [ map $_->p, grep $_->surface_type =~ /internal/, @neighbor ], + ); + next if !@$new_internal_solid; - next if @$intersections == 0; + # internal-solid are the union of the existing internal-solid surfaces + # and new ones + my $internal_solid = union_ex([ + ( map $_->p, grep $_->surface_type eq 'internal-solid', @neighbor ), + ( map @$_, @$new_internal_solid ), + ]); # subtract intersections from layer surfaces to get resulting inner surfaces my $internal = diff_ex( - $neighbor_p, - [ - (map @$_, @$intersections), - (map $_->p, grep $_->surface_type !~ /internal/, @neighbor), - ], + [ map $_->p, grep $_->surface_type eq 'internal', @neighbor ], + [ map @$_, @$internal_solid ], ); Slic3r::debugf " %d internal-solid and %d internal surfaces found\n", - scalar(@$intersections), scalar(@$internal); + scalar(@$internal_solid), scalar(@$internal); # Note: due to floating point math we're going to get some very small - # polygons as $internal_polygons; they will be removed by removed_small_features() + # polygons as $internal; they will be removed by removed_small_features() # assign resulting inner surfaces to layer @$surfaces = (); @@ -251,15 +256,16 @@ sub discover_horizontal_shells { # assign new internal-solid surfaces to layer push @$surfaces, Slic3r::Surface->cast_from_expolygon ($_, surface_type => 'internal-solid') - for @$intersections; + for @$internal_solid; - for my $neigh_type (qw(top bottom)) { + # assign top and bottom surfaces to layer + foreach my $s (Slic3r::Surface->group(grep $_->surface_type =~ /top|bottom/, @neighbor)) { my $solid_surfaces = diff_ex( - [ map $_->p, grep $_->surface_type eq $neigh_type, @neighbor ], - [ map @$_, @$intersections, @$internal ], + [ map $_->p, @$s ], + [ map @$_, @$internal_solid, @$internal ], ); push @$surfaces, Slic3r::Surface->cast_from_expolygon - ($_, surface_type => $neigh_type) + ($_, surface_type => $s->[0]->surface_type, bridge_angle => $s->[0]->bridge_angle) for @$solid_surfaces; } } |