Merge branch 'master' into xsdata

Conflicts:
	lib/Slic3r.pm
	lib/Slic3r/ExPolygon.pm
	lib/Slic3r/Fill.pm
	lib/Slic3r/Fill/Rectilinear.pm
	lib/Slic3r/GCode.pm
	lib/Slic3r/GUI/Plater.pm
	lib/Slic3r/Geometry/Clipper.pm
	lib/Slic3r/Layer/Region.pm
	lib/Slic3r/Print.pm
	lib/Slic3r/Print/Object.pm
	lib/Slic3r/TriangleMesh.pm
	t/shells.t
	xs/MANIFEST
This commit is contained in:
Alessandro Ranellucci 2013-08-08 02:10:34 +02:00
commit b38cc2c244
60 changed files with 1432 additions and 798 deletions

View file

@ -43,14 +43,15 @@ sub length {
sub grow {
my $self = shift;
my ($distance, $scale, $joinType, $miterLimit) = @_;
$joinType //= JT_SQUARE;
$joinType //= JT_SQUARE; # we override this one
$scale //= 100000; # we init these because we can't pass undef
$miterLimit //= 3;
my @points = @$self;
return map Slic3r::Polygon->new(@$_),
@{Slic3r::Geometry::Clipper::offset(
[ Slic3r::Polygon->new(@points, CORE::reverse @points[1..($#points-1)]) ],
$distance, $scale, $joinType, $miterLimit,
)};
return @{Slic3r::Geometry::Clipper::offset(
[ Slic3r::Polygon->new(@points, CORE::reverse @points[1..($#points-1)]) ],
$distance, $scale, $joinType, $miterLimit,
)};
}
sub nearest_point_to {
@ -144,6 +145,38 @@ sub clip_start {
return (ref $self)->new($points);
}
# this method returns a collection of points picked on the polygon contour
# so that they are evenly spaced according to the input distance
# (find a better name!)
sub regular_points {
my $self = shift;
my ($distance) = @_;
my @points = ($self->[0]);
my $len = 0;
for (my $i = 1; $i <= $#$self; $i++) {
my $point = $self->[$i];
my $segment_length = $point->distance_to($self->[$i-1]);
$len += $segment_length;
next if $len < $distance;
if ($len == $distance) {
push @points, $point;
$len = 0;
next;
}
my $take = $segment_length - ($len - $distance); # how much we take of this segment
my $new_point = Slic3r::Geometry::point_along_segment($self->[$i-1], $point, $take);
push @points, Slic3r::Point->new($new_point);
$i--;
$len = -$take;
}
return @points;
}
package Slic3r::Polyline::Collection;
use Moo;