From 0f5064dd32c9ef08f1e23854846d6a30f7a4dbd6 Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Sat, 16 Mar 2013 21:10:12 +0100 Subject: [PATCH] Untested fix for incomplete honeycomb support material. #1032 --- lib/Slic3r/Fill/Honeycomb.pm | 13 ++++--------- lib/Slic3r/Polygon.pm | 15 ++++++++++++++- lib/Slic3r/Print/Object.pm | 6 +++++- 3 files changed, 23 insertions(+), 11 deletions(-) diff --git a/lib/Slic3r/Fill/Honeycomb.pm b/lib/Slic3r/Fill/Honeycomb.pm index 4d450370e..95754471e 100644 --- a/lib/Slic3r/Fill/Honeycomb.pm +++ b/lib/Slic3r/Fill/Honeycomb.pm @@ -26,7 +26,7 @@ sub fill_surface { my $cache_id = sprintf "d%s_s%s_a%s", $params{density}, $params{flow_spacing}, $rotate_vector->[0][0]; - if (!$self->cache->{$cache_id}) { + if (!$self->cache->{$cache_id} || !defined $self->bounding_box) { # hexagons math my $hex_side = $distance / (sqrt(3)/2); @@ -40,15 +40,10 @@ sub fill_surface { # adjust actual bounding box to the nearest multiple of our hex pattern # and align it so that it matches across layers - $self->bounding_box([ $expolygon->bounding_box ]) if !defined $self->bounding_box; - my $bounding_box = [ 0, 0, $self->bounding_box->[X2], $self->bounding_box->[Y2] ]; + my $bounding_box = [ $self->bounding_box ? @{$self->bounding_box} : $expolygon->bounding_box ]; + $bounding_box->[$_] = 0 for X1, Y1; { - my $bb_polygon = Slic3r::Polygon->new([ - [ $bounding_box->[X1], $bounding_box->[Y1] ], - [ $bounding_box->[X2], $bounding_box->[Y1] ], - [ $bounding_box->[X2], $bounding_box->[Y2] ], - [ $bounding_box->[X1], $bounding_box->[Y2] ], - ]); + my $bb_polygon = Slic3r::Polygon->new_from_bounding_box($bounding_box); $bb_polygon->rotate($rotate_vector->[0][0], $hex_center); $bounding_box = [ Slic3r::Geometry::bounding_box($bb_polygon) ]; # $bounding_box->[X1] and [Y1] represent the displacement between new bounding box offset and old one diff --git a/lib/Slic3r/Polygon.pm b/lib/Slic3r/Polygon.pm index 1d759a06b..e9bfcf81a 100644 --- a/lib/Slic3r/Polygon.pm +++ b/lib/Slic3r/Polygon.pm @@ -6,9 +6,22 @@ use warnings; use parent 'Slic3r::Polyline'; use Slic3r::Geometry qw(polygon_lines polygon_remove_parallel_continuous_edges - polygon_remove_acute_vertices polygon_segment_having_point point_in_polygon); + polygon_remove_acute_vertices polygon_segment_having_point point_in_polygon + X1 X2 Y1 Y2); use Slic3r::Geometry::Clipper qw(JT_MITER); +sub new_from_bounding_box { + my $class = shift; + my ($bounding_box) = @_; + + return $class->new([ + [ $bounding_box->[X1], $bounding_box->[Y1] ], + [ $bounding_box->[X2], $bounding_box->[Y1] ], + [ $bounding_box->[X2], $bounding_box->[Y2] ], + [ $bounding_box->[X1], $bounding_box->[Y2] ], + ]); +} + sub lines { my $self = shift; return polygon_lines($self); diff --git a/lib/Slic3r/Print/Object.pm b/lib/Slic3r/Print/Object.pm index 618cf6950..4d1161882 100644 --- a/lib/Slic3r/Print/Object.pm +++ b/lib/Slic3r/Print/Object.pm @@ -857,7 +857,7 @@ sub generate_support_material { { # 0.5 ensures the paths don't get clipped externally when applying them to layers my @areas = map $_->offset_ex(- 0.5 * $flow->scaled_width), - @{union_ex([ map $_->contour, map @$_, values %layers ])}; + @{union_ex([ map $_->contour, map @$_, values %layers, values %layers_interfaces, values %layers_contact_areas ])}; my $pattern = $Slic3r::Config->support_material_pattern; my @angles = ($Slic3r::Config->support_material_angle); @@ -865,7 +865,11 @@ sub generate_support_material { $pattern = 'rectilinear'; push @angles, $angles[0] + 90; } + my $filler = Slic3r::Fill->filler($pattern); + $filler->bounding_box([ Slic3r::Geometry::bounding_box([ map @$_, map @$_, @areas ]) ]) + if $filler->can('bounding_box'); + my $make_pattern = sub { my ($expolygon, $density) = @_;