diff --git a/lib/Slic3r/Geometry.pm b/lib/Slic3r/Geometry.pm index e69851e3b..ac33a2197 100644 --- a/lib/Slic3r/Geometry.pm +++ b/lib/Slic3r/Geometry.pm @@ -157,7 +157,7 @@ sub point_in_segment { # if line is vertical, check whether point's X is the same as the line if ($line->[A][X] == $line->[B][X]) { - return 1 if abs($x - $line->[A][X]) < epsilon; + return abs($x - $line->[A][X]) < epsilon ? 1 : 0; } # calculate the Y in line at X of the point diff --git a/lib/Slic3r/Layer.pm b/lib/Slic3r/Layer.pm index a715a971e..5a9ebaa59 100644 --- a/lib/Slic3r/Layer.pm +++ b/lib/Slic3r/Layer.pm @@ -281,6 +281,14 @@ sub process_bridges { # in a convex polygon; this will print thin membranes eventually my $surface_p = convex_hull($surface->contour->p); + # offset the surface a bit to avoid approximation issues when doing the + # intersection below (this is to make sure we overlap with supporting + # surfaces, otherwise a little gap will result from intersection) + { + my $offset = offset([$surface_p], 100, 100, JT_MITER, 2); + $surface_p = $offset->[0]; + } + #use Slic3r::SVG; #Slic3r::SVG::output(undef, "bridge.svg", # green_polygons => [ map $_->p, @supporting_surfaces ], diff --git a/lib/Slic3r/Print.pm b/lib/Slic3r/Print.pm index ddc797667..ef889a362 100644 --- a/lib/Slic3r/Print.pm +++ b/lib/Slic3r/Print.pm @@ -140,13 +140,13 @@ sub detect_surfaces_type { # actually, this shouldn't happen so it deserves further investigation @bottom = grep $_->contour->is_valid, @bottom; - for (@bottom) { - $_->contour->remove_acute_vertices; + foreach my $surface (@bottom) { + $surface->contour->remove_acute_vertices; # okay, this is an Ugly Hack(tm) to avoid floating point math problems # with diagonal bridges. will find a nicer solution, promised. - my $offset = offset([$_->contour->p], 100, 100, JT_MITER, 2); - @{$_->contour->points} = map Slic3r::Point->new($_), @{ $offset->[0] }; + my $offset = offset([$surface->contour->p], 100, 100, JT_MITER, 2); + @{$surface->contour->points} = map Slic3r::Point->new($_), @{ $offset->[0] }; } #Slic3r::SVG::output(undef, "layer_" . $layer->id . "_diff.svg",