Fixes to the new bridging algorithm. It appears to be working fine now

This commit is contained in:
Alessandro Ranellucci 2011-11-20 22:09:59 +01:00
parent 4a9fc942cb
commit bde3c11e82
2 changed files with 17 additions and 9 deletions

View File

@ -53,6 +53,13 @@ sub offset {
return @$offsets; return @$offsets;
} }
sub safety_offset {
my $self = shift;
return (ref $self)->new(
@{ Slic3r::Geometry::Clipper::safety_offset([@$self]) },
);
}
sub offset_ex { sub offset_ex {
my $self = shift; my $self = shift;
my @offsets = $self->offset(@_); my @offsets = $self->offset(@_);

View File

@ -359,14 +359,13 @@ sub process_bridges {
my @internal_surfaces = grep $_->surface_type =~ /internal/, @{$self->surfaces}; my @internal_surfaces = grep $_->surface_type =~ /internal/, @{$self->surfaces};
SURFACE: foreach my $surface (@solid_surfaces) { SURFACE: foreach my $surface (@solid_surfaces) {
# ignore holes in bridges my $expolygon = $surface->expolygon->safety_offset;
my $contour = $surface->expolygon->contour->safety_offset;
my $description = $surface->surface_type eq 'bottom' ? 'bridge/overhang' : 'reverse bridge'; my $description = $surface->surface_type eq 'bottom' ? 'bridge/overhang' : 'reverse bridge';
# offset the contour and intersect it with the internal surfaces to discover # offset the contour and intersect it with the internal surfaces to discover
# which of them has contact with our bridge # which of them has contact with our bridge
my @supporting_surfaces = (); my @supporting_surfaces = ();
my ($contour_offset) = $contour->offset($Slic3r::flow_width / $Slic3r::resolution); my ($contour_offset) = $expolygon->contour->offset($Slic3r::flow_width / $Slic3r::resolution);
foreach my $internal_surface (@internal_surfaces) { foreach my $internal_surface (@internal_surfaces) {
my $intersection = intersection_ex([$contour_offset], [$internal_surface->contour->p]); my $intersection = intersection_ex([$contour_offset], [$internal_surface->contour->p]);
if (@$intersection) { if (@$intersection) {
@ -377,7 +376,7 @@ sub process_bridges {
#use Slic3r::SVG; #use Slic3r::SVG;
#Slic3r::SVG::output(undef, "bridge.svg", #Slic3r::SVG::output(undef, "bridge.svg",
# green_polygons => [ map $_->p, @supporting_surfaces ], # green_polygons => [ map $_->p, @supporting_surfaces ],
# red_polygons => [ $contour ], # red_polygons => [ @$expolygon ],
#); #);
next SURFACE unless @supporting_surfaces; next SURFACE unless @supporting_surfaces;
@ -425,13 +424,14 @@ sub process_bridges {
{ {
# offset the bridge by the specified amount of mm # offset the bridge by the specified amount of mm
my $bridge_overlap = 2 * $Slic3r::perimeters * $Slic3r::flow_width / $Slic3r::resolution; my $bridge_overlap = 2 * $Slic3r::perimeters * $Slic3r::flow_width / $Slic3r::resolution;
my $bridge_offset = ${ offset([$contour], $bridge_overlap, $Slic3r::resolution * 100, JT_MITER, 2) }[0]; my ($bridge_offset) = $expolygon->contour->offset($bridge_overlap, $Slic3r::resolution * 100, JT_MITER, 2);
# calculate the new bridge # calculate the new bridge
my $intersection = intersection_ex( my $intersection = intersection_ex(
[ $contour, map $_->p, @supporting_surfaces ], [ @$expolygon, map $_->p, @supporting_surfaces ],
[ $bridge_offset ], [ $bridge_offset ],
); );
push @{$self->bridges}, map Slic3r::Surface::Bridge->cast_from_expolygon($_, push @{$self->bridges}, map Slic3r::Surface::Bridge->cast_from_expolygon($_,
surface_type => $surface->surface_type, surface_type => $surface->surface_type,
bridge_angle => $bridge_angle, bridge_angle => $bridge_angle,
@ -484,8 +484,9 @@ sub split_bridges_fills {
foreach my $bridge (@{$self->bridges}) { foreach my $bridge (@{$self->bridges}) {
my $intersection = intersection_ex( my $intersection = intersection_ex(
[ map $_->p, @surfaces ], [ map $_->p, @surfaces ],
[ $bridge->contour->p ], [ $bridge->p ],
); );
push @$surfaces, map Slic3r::Surface::Bridge->cast_from_expolygon($_, push @$surfaces, map Slic3r::Surface::Bridge->cast_from_expolygon($_,
surface_type => $bridge->surface_type, surface_type => $bridge->surface_type,
bridge_angle => $bridge->bridge_angle, bridge_angle => $bridge->bridge_angle,
@ -494,7 +495,7 @@ sub split_bridges_fills {
# difference between fill_surfaces and bridges are the other surfaces # difference between fill_surfaces and bridges are the other surfaces
foreach my $surface (@surfaces) { foreach my $surface (@surfaces) {
my $difference = diff_ex([ $surface->p ], [ map $_->contour->p, @{$self->bridges} ]); my $difference = diff_ex([ $surface->p ], [ map $_->p, @{$self->bridges} ]);
push @$surfaces, map Slic3r::Surface->cast_from_expolygon($_, push @$surfaces, map Slic3r::Surface->cast_from_expolygon($_,
surface_type => $surface->surface_type), @$difference; surface_type => $surface->surface_type), @$difference;
} }