Merge branch 'master' into grow-narrow

This commit is contained in:
Alessandro Ranellucci 2013-03-16 16:22:03 +01:00
commit 0f8ca6191a
3 changed files with 22 additions and 2 deletions

View file

@ -5,6 +5,7 @@ use warnings;
# an ExPolygon is a polygon with holes # an ExPolygon is a polygon with holes
use Boost::Geometry::Utils; use Boost::Geometry::Utils;
use List::Util qw(first);
use Math::Geometry::Voronoi; use Math::Geometry::Voronoi;
use Slic3r::Geometry qw(X Y A B point_in_polygon same_line line_length epsilon); use Slic3r::Geometry qw(X Y A B point_in_polygon same_line line_length epsilon);
use Slic3r::Geometry::Clipper qw(union_ex JT_MITER); use Slic3r::Geometry::Clipper qw(union_ex JT_MITER);
@ -54,6 +55,13 @@ sub clipper_expolygon {
}; };
} }
sub is_valid {
my $self = shift;
return (!first { !$_->is_valid } @$self)
&& $self->contour->is_counter_clockwise
&& (!first { $_->is_counter_clockwise } $self->holes);
}
sub boost_polygon { sub boost_polygon {
my $self = shift; my $self = shift;
return Boost::Geometry::Utils::polygon(@$self); return Boost::Geometry::Utils::polygon(@$self);

View file

@ -4,7 +4,7 @@ use warnings;
require Exporter; require Exporter;
our @ISA = qw(Exporter); our @ISA = qw(Exporter);
our @EXPORT_OK = qw(safety_offset offset offset_ex our @EXPORT_OK = qw(safety_offset offset offset_ex collapse_ex
diff_ex diff union_ex intersection_ex xor_ex PFT_EVENODD JT_MITER JT_ROUND diff_ex diff union_ex intersection_ex xor_ex PFT_EVENODD JT_MITER JT_ROUND
JT_SQUARE is_counter_clockwise); JT_SQUARE is_counter_clockwise);
@ -91,4 +91,13 @@ sub xor_ex {
]; ];
} }
sub collapse_ex {
my ($polygons, $width) = @_;
my @result = offset(
[ offset($polygons, -$width/2,) ],
+$width/2,
);
return union_ex([@result]);
}
1; 1;

View file

@ -4,7 +4,7 @@ use Moo;
use List::Util qw(min sum first); use List::Util qw(min sum first);
use Slic3r::ExtrusionPath ':roles'; use Slic3r::ExtrusionPath ':roles';
use Slic3r::Geometry qw(Z PI scale unscale deg2rad rad2deg scaled_epsilon); use Slic3r::Geometry qw(Z PI scale unscale deg2rad rad2deg scaled_epsilon);
use Slic3r::Geometry::Clipper qw(diff_ex intersection_ex union_ex offset); use Slic3r::Geometry::Clipper qw(diff_ex intersection_ex union_ex offset collapse_ex);
use Slic3r::Surface ':types'; use Slic3r::Surface ':types';
has 'print' => (is => 'ro', weak_ref => 1, required => 1); has 'print' => (is => 'ro', weak_ref => 1, required => 1);
@ -789,6 +789,7 @@ sub generate_support_material {
[ map @$_, @{ $upper_layers_overhangs[-1] || [] } ], [ map @$_, @{ $upper_layers_overhangs[-1] || [] } ],
[ map @$_, @current_layer_offsetted_slices ], [ map @$_, @current_layer_offsetted_slices ],
); );
$layers_contact_areas{$i} = collapse_ex([ map @$_, @{$layers_contact_areas{$i}} ], $flow->scaled_width);
$_->simplify($flow->scaled_spacing) for @{$layers_contact_areas{$i}}; $_->simplify($flow->scaled_spacing) for @{$layers_contact_areas{$i}};
# to define interface regions of this layer we consider the overhangs of all the upper layers # to define interface regions of this layer we consider the overhangs of all the upper layers
@ -800,6 +801,7 @@ sub generate_support_material {
(map @$_, @{ $layers_contact_areas{$i} }), (map @$_, @{ $layers_contact_areas{$i} }),
], ],
); );
$layers_interfaces{$i} = collapse_ex([ map @$_, @{$layers_interfaces{$i}} ], $flow->scaled_width);
$_->simplify($flow->scaled_spacing) for @{$layers_interfaces{$i}}; $_->simplify($flow->scaled_spacing) for @{$layers_interfaces{$i}};
# generate support material in current layer (for upper layers) # generate support material in current layer (for upper layers)
@ -819,6 +821,7 @@ sub generate_support_material {
(map @$_, @{ $layers_interfaces{$i} }), (map @$_, @{ $layers_interfaces{$i} }),
], ],
); );
$layers{$i} = collapse_ex([ map @$_, @{$layers{$i}} ], $flow->scaled_width);
$_->simplify($flow->scaled_spacing) for @{$layers{$i}}; $_->simplify($flow->scaled_spacing) for @{$layers{$i}};
# get layer overhangs and put them into queue for adding support inside lower layers; # get layer overhangs and put them into queue for adding support inside lower layers;