Optimize concentric loops

This commit is contained in:
Alessandro Ranellucci 2013-06-23 00:50:44 +02:00
parent 78f1527ab7
commit cd1a39397b
2 changed files with 11 additions and 3 deletions

View File

@ -3,7 +3,7 @@ use Moo;
extends 'Slic3r::Fill::Base'; extends 'Slic3r::Fill::Base';
use Slic3r::Geometry qw(scale unscale X); use Slic3r::Geometry qw(scale unscale X nearest_point_index);
use Slic3r::Geometry::Clipper qw(offset offset2 union_pt traverse_pt PFT_EVENODD); use Slic3r::Geometry::Clipper qw(offset offset2 union_pt traverse_pt PFT_EVENODD);
sub fill_surface { sub fill_surface {
@ -36,9 +36,17 @@ sub fill_surface {
# generate paths from the outermost to the innermost, to avoid # generate paths from the outermost to the innermost, to avoid
# adhesion problems of the first central tiny loops # adhesion problems of the first central tiny loops
my @paths = map Slic3r::Polygon->new(@$_)->split_at_first_point, @loops = map Slic3r::Polygon->new(@$_),
reverse traverse_pt( union_pt(\@loops, PFT_EVENODD) ); reverse traverse_pt( union_pt(\@loops, PFT_EVENODD) );
# order paths using a nearest neighbor search
my @paths = ();
my $last_pos = [0,0];
foreach my $loop (@loops) {
push @paths, $loop->split_at_index(nearest_point_index($last_pos, $loop));
$last_pos = $paths[-1][-1];
}
# clip the paths to avoid the extruder to get exactly on the first point of the loop # clip the paths to avoid the extruder to get exactly on the first point of the loop
my $clip_length = scale $flow_spacing * &Slic3r::LOOP_CLIPPING_LENGTH_OVER_SPACING; my $clip_length = scale $flow_spacing * &Slic3r::LOOP_CLIPPING_LENGTH_OVER_SPACING;
$_->clip_end($clip_length) for @paths; $_->clip_end($clip_length) for @paths;

View File

@ -12,7 +12,7 @@ our @EXPORT_OK = qw(
point_is_on_left_of_segment polyline_lines polygon_lines nearest_point point_is_on_left_of_segment polyline_lines polygon_lines nearest_point
point_along_segment polygon_segment_having_point polygon_has_subsegment point_along_segment polygon_segment_having_point polygon_has_subsegment
polygon_has_vertex polyline_length can_connect_points deg2rad rad2deg polygon_has_vertex polyline_length can_connect_points deg2rad rad2deg
rotate_points move_points clip_segment_polygon rotate_points move_points clip_segment_polygon nearest_point_index
sum_vectors multiply_vector subtract_vectors dot perp polygon_points_visibility sum_vectors multiply_vector subtract_vectors dot perp polygon_points_visibility
line_intersection bounding_box bounding_box_intersect same_point same_line line_intersection bounding_box bounding_box_intersect same_point same_line
longest_segment angle3points three_points_aligned line_direction longest_segment angle3points three_points_aligned line_direction