Skip to content

Commit

Permalink
Speed boost for new infill patterns. #20
Browse files Browse the repository at this point in the history
  • Loading branch information
alranel committed Nov 14, 2011
1 parent 86f3e4f commit 12b06b0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
11 changes: 9 additions & 2 deletions lib/Slic3r/Fill/PlanePath.pm
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use Moo;

extends 'Slic3r::Fill::Base';

use Slic3r::Geometry qw(bounding_box);
use Slic3r::Geometry qw(bounding_box X1 Y1 X2 Y2);
use XXX;

sub multiplier () { 1 }
Expand All @@ -29,6 +29,12 @@ sub fill_surface {

my $distance_between_lines = $params{flow_width} / $Slic3r::resolution / $params{density} * $self->multiplier;
my $bounding_box = [ bounding_box(map @$_, $expolygon) ];
my $bounding_box_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] ],
]);

(ref $self) =~ /::([^:]+)$/;
my $path = "Math::PlanePath::$1"->new;
Expand All @@ -41,7 +47,8 @@ sub fill_surface {

$self->process_polyline($polyline, $bounding_box);

my @paths = ($polyline->clip_with_expolygon($expolygon));
my @paths = map $_->clip_with_expolygon($expolygon),
$polyline->clip_with_polygon($bounding_box_polygon);

if (0) {
require "Slic3r/SVG.pm";
Expand Down
7 changes: 7 additions & 0 deletions lib/Slic3r/Polyline.pm
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,13 @@ sub has_segment {
return 0;
}

sub clip_with_polygon {
my $self = shift;
my ($polygon) = @_;

return $self->clip_with_expolygon(Slic3r::ExPolygon->new($polygon));
}

sub clip_with_expolygon {
my $self = shift;
my ($expolygon) = @_;
Expand Down

0 comments on commit 12b06b0

Please sign in to comment.