Fixed --avoid-crossing-perimeters and --support-material after the xsdata merge

This commit is contained in:
Alessandro Ranellucci 2013-09-04 00:10:53 +02:00
parent a49dc603cc
commit 67aefdccc7
4 changed files with 24 additions and 24 deletions

View File

@ -82,7 +82,7 @@ sub fill_surface {
# we were requested to complete each loop; # we were requested to complete each loop;
# in this case we don't try to make more continuous paths # in this case we don't try to make more continuous paths
@paths = map $_->split_at_first_point, @paths = map $_->split_at_first_point,
@{intersection($surface->expolygon, \@polygons)}; @{intersection([ $surface->p ], \@polygons)};
} else { } else {
# consider polygons as polylines without re-appending the initial point: # consider polygons as polylines without re-appending the initial point:

View File

@ -78,7 +78,7 @@ sub BUILD {
# lines of outer polygons connect visible points # lines of outer polygons connect visible points
for my $i (0 .. $#outer) { for my $i (0 .. $#outer) {
foreach my $line ($outer[$i]->lines) { foreach my $line (@{$outer[$i]->lines}) {
my $dist = $line->length; my $dist = $line->length;
$edges->{$line->a}{$line->b} = $dist; $edges->{$line->a}{$line->b} = $dist;
$edges->{$line->b}{$line->a} = $dist; $edges->{$line->b}{$line->a} = $dist;

View File

@ -584,8 +584,8 @@ sub make_skirt {
if (@{ $object->support_layers }) { if (@{ $object->support_layers }) {
my @support_layers = map $object->support_layers->[$_], 0..min($Slic3r::Config->skirt_height-1, $#{$object->support_layers}); my @support_layers = map $object->support_layers->[$_], 0..min($Slic3r::Config->skirt_height-1, $#{$object->support_layers});
push @layer_points, push @layer_points,
(map @{$_->unpack->polyline}, map @{$_->support_fills->paths}, grep $_->support_fills, @support_layers), (map @{$_->polyline}, map @{$_->support_fills}, grep $_->support_fills, @support_layers),
(map @{$_->unpack->polyline}, map @{$_->support_interface_fills->paths}, grep $_->support_interface_fills, @support_layers); (map @{$_->polyline}, map @{$_->support_interface_fills}, grep $_->support_interface_fills, @support_layers);
} }
push @points, map move_points($_, @layer_points), @{$object->copies}; push @points, map move_points($_, @layer_points), @{$object->copies};
} }
@ -650,10 +650,10 @@ sub make_brim {
if (@{ $object->support_layers }) { if (@{ $object->support_layers }) {
my $support_layer0 = $object->support_layers->[0]; my $support_layer0 = $object->support_layers->[0];
push @object_islands, push @object_islands,
(map $_->unpack->polyline->grow($grow_distance), @{$support_layer0->support_fills->paths}) (map $_->polyline->grow($grow_distance), @{$support_layer0->support_fills})
if $support_layer0->support_fills; if $support_layer0->support_fills;
push @object_islands, push @object_islands,
(map $_->unpack->polyline->grow($grow_distance), @{$support_layer0->support_interface_fills->paths}) (map $_->polyline->grow($grow_distance), @{$support_layer0->support_interface_fills})
if $support_layer0->support_interface_fills; if $support_layer0->support_interface_fills;
} }
foreach my $copy (@{$object->copies}) { foreach my $copy (@{$object->copies}) {

View File

@ -1094,21 +1094,21 @@ sub generate_support_material {
my @loops = @loops0; my @loops = @loops0;
for my $i (2..$contact_loops) { for my $i (2..$contact_loops) {
my $d = ($i-1) * $flow->scaled_spacing; my $d = ($i-1) * $flow->scaled_spacing;
push @loops, offset2(\@loops0, -$d -0.5*$flow->scaled_spacing, +0.5*$flow->scaled_spacing); push @loops, @{offset2(\@loops0, -$d -0.5*$flow->scaled_spacing, +0.5*$flow->scaled_spacing)};
} }
# clip such loops to the side oriented towards the object # clip such loops to the side oriented towards the object
@loops = map Slic3r::Polyline->new(@$_), @loops = map Slic3r::Polyline->new(@$_),
@{ Boost::Geometry::Utils::multi_polygon_multi_linestring_intersection( @{ Boost::Geometry::Utils::multi_polygon_multi_linestring_intersection(
[ offset_ex([ map @$_, @$overhang ], +scale 3) ], [ map $_->pp, @{offset_ex([ map @$_, @$overhang ], +scale 3)} ],
[ map Slic3r::Polygon->new(@$_)->split_at_first_point, @loops ], [ map Slic3r::Polygon->new(@$_)->split_at_first_point->pp, @loops ],
) }; ) };
# add the contact infill area to the interface area # add the contact infill area to the interface area
$contact_infill = [ offset2(\@loops0, -($contact_loops + 0.5) * $flow->scaled_spacing, +0.5*$flow->scaled_spacing) ]; $contact_infill = offset2(\@loops0, -($contact_loops + 0.5) * $flow->scaled_spacing, +0.5*$flow->scaled_spacing);
# transform loops into ExtrusionPath objects # transform loops into ExtrusionPath objects
@loops = map Slic3r::ExtrusionPath->pack( @loops = map Slic3r::ExtrusionPath->new(
polyline => $_, polyline => $_,
role => EXTR_ROLE_SUPPORTMATERIAL, role => EXTR_ROLE_SUPPORTMATERIAL,
flow_spacing => $flow->spacing, flow_spacing => $flow->spacing,
@ -1123,9 +1123,9 @@ sub generate_support_material {
# steal some space from support # steal some space from support
$interface{$layer_id} = intersection( $interface{$layer_id} = intersection(
[ offset([ map @$_, $interface{$layer_id}, $contact_infill ], scale 3) ], offset([ map @$_, $interface{$layer_id}, $contact_infill ], scale 3),
[ map @$_, $interface{$layer_id}, $support{$layer_id}, $contact_infill ], [ map @$_, $interface{$layer_id}, $support{$layer_id}, $contact_infill ],
undef, 1, 1,
); );
$support{$layer_id} = diff( $support{$layer_id} = diff(
$support{$layer_id}, $support{$layer_id},
@ -1135,14 +1135,14 @@ sub generate_support_material {
my @paths = (); my @paths = ();
foreach my $expolygon (@{union_ex($interface{$layer_id})}) { foreach my $expolygon (@{union_ex($interface{$layer_id})}) {
my @p = $fillers{interface}->fill_surface( my @p = $fillers{interface}->fill_surface(
Slic3r::Surface->new(expolygon => $expolygon), Slic3r::Surface->new(expolygon => $expolygon, surface_type => S_TYPE_INTERNAL),
density => $interface_density, density => $interface_density,
flow_spacing => $flow->spacing, flow_spacing => $flow->spacing,
complete => 1, complete => 1,
); );
my $params = shift @p; my $params = shift @p;
push @paths, map Slic3r::ExtrusionPath->pack( push @paths, map Slic3r::ExtrusionPath->new(
polyline => Slic3r::Polyline->new(@$_), polyline => Slic3r::Polyline->new(@$_),
role => EXTR_ROLE_SUPPORTMATERIAL, role => EXTR_ROLE_SUPPORTMATERIAL,
height => undef, height => undef,
@ -1160,7 +1160,7 @@ sub generate_support_material {
my $flow_spacing = $flow->spacing; my $flow_spacing = $flow->spacing;
# TODO: use offset2_ex() # TODO: use offset2_ex()
my $to_infill = union_ex($support{$layer_id}, undef, 1); my $to_infill = union_ex($support{$layer_id}, 1);
my @paths = (); my @paths = ();
# base flange # base flange
@ -1172,7 +1172,7 @@ sub generate_support_material {
} else { } else {
# draw a perimeter all around support infill # draw a perimeter all around support infill
# TODO: use brim ordering algorithm # TODO: use brim ordering algorithm
push @paths, map Slic3r::ExtrusionPath->pack( push @paths, map Slic3r::ExtrusionPath->new(
polyline => $_->split_at_first_point, polyline => $_->split_at_first_point,
role => EXTR_ROLE_SUPPORTMATERIAL, role => EXTR_ROLE_SUPPORTMATERIAL,
height => undef, height => undef,
@ -1180,19 +1180,19 @@ sub generate_support_material {
), map @$_, @$to_infill; ), map @$_, @$to_infill;
# TODO: use offset2_ex() # TODO: use offset2_ex()
$to_infill = [ offset_ex([ map @$_, @$to_infill ], -$flow->scaled_spacing) ]; $to_infill = offset_ex([ map @$_, @$to_infill ], -$flow->scaled_spacing);
} }
foreach my $expolygon (@$to_infill) { foreach my $expolygon (@$to_infill) {
my @p = $filler->fill_surface( my @p = $filler->fill_surface(
Slic3r::Surface->new(expolygon => $expolygon), Slic3r::Surface->new(expolygon => $expolygon, surface_type => S_TYPE_INTERNAL),
density => $density, density => $density,
flow_spacing => $flow_spacing, flow_spacing => $flow_spacing,
complete => 1, complete => 1,
); );
my $params = shift @p; my $params = shift @p;
push @paths, map Slic3r::ExtrusionPath->pack( push @paths, map Slic3r::ExtrusionPath->new(
polyline => Slic3r::Polyline->new(@$_), polyline => Slic3r::Polyline->new(@$_),
role => EXTR_ROLE_SUPPORTMATERIAL, role => EXTR_ROLE_SUPPORTMATERIAL,
height => undef, height => undef,
@ -1221,11 +1221,11 @@ sub generate_support_material {
my ($layer_id, $result) = @_; my ($layer_id, $result) = @_;
my $layer = $self->support_layers->[$layer_id]; my $layer = $self->support_layers->[$layer_id];
my $interface_collection = Slic3r::ExtrusionPath::Collection->new(paths => [ @{$result->{contact}}, @{$result->{interface}} ]); my $interface_collection = Slic3r::ExtrusionPath::Collection->new(@{$result->{contact}}, @{$result->{interface}});
$layer->support_interface_fills($interface_collection) if @{$interface_collection->paths} > 0; $layer->support_interface_fills($interface_collection) if @$interface_collection > 0;
my $support_collection = Slic3r::ExtrusionPath::Collection->new(paths => $result->{support}); my $support_collection = Slic3r::ExtrusionPath::Collection->new(@{$result->{support}});
$layer->support_fills($support_collection) if @{$support_collection->paths} > 0; $layer->support_fills($support_collection) if @$support_collection > 0;
# TODO: use a Slic3r::ExPolygon::Collection # TODO: use a Slic3r::ExPolygon::Collection
$layer->support_islands($result->{islands}); $layer->support_islands($result->{islands});