2011-09-04 10:04:01 +00:00
|
|
|
package Slic3r::ExtrusionPath;
|
2013-07-15 10:14:22 +00:00
|
|
|
use strict;
|
|
|
|
use warnings;
|
|
|
|
|
|
|
|
use parent qw(Exporter);
|
2011-09-04 10:04:01 +00:00
|
|
|
|
2012-12-05 09:47:41 +00:00
|
|
|
our @EXPORT_OK = qw(EXTR_ROLE_PERIMETER EXTR_ROLE_EXTERNAL_PERIMETER
|
2013-05-14 18:19:42 +00:00
|
|
|
EXTR_ROLE_CONTOUR_INTERNAL_PERIMETER EXTR_ROLE_OVERHANG_PERIMETER
|
2013-03-16 23:42:53 +00:00
|
|
|
EXTR_ROLE_FILL EXTR_ROLE_SOLIDFILL EXTR_ROLE_TOPSOLIDFILL EXTR_ROLE_BRIDGE
|
|
|
|
EXTR_ROLE_INTERNALBRIDGE EXTR_ROLE_SKIRT EXTR_ROLE_SUPPORTMATERIAL EXTR_ROLE_GAPFILL);
|
2012-05-19 13:40:11 +00:00
|
|
|
our %EXPORT_TAGS = (roles => \@EXPORT_OK);
|
|
|
|
|
2011-12-30 18:59:51 +00:00
|
|
|
use Slic3r::Geometry qw(PI X Y epsilon deg2rad rotate_points);
|
2012-07-20 12:39:07 +00:00
|
|
|
|
2012-02-25 13:46:21 +00:00
|
|
|
sub clip_with_polygon {
|
|
|
|
my $self = shift;
|
|
|
|
my ($polygon) = @_;
|
|
|
|
|
|
|
|
return $self->clip_with_expolygon(Slic3r::ExPolygon->new($polygon));
|
|
|
|
}
|
|
|
|
|
2012-02-19 11:03:36 +00:00
|
|
|
sub clip_with_expolygon {
|
|
|
|
my $self = shift;
|
|
|
|
my ($expolygon) = @_;
|
|
|
|
|
2013-06-20 18:11:46 +00:00
|
|
|
return map $self->clone(polyline => $_),
|
2013-07-16 07:49:34 +00:00
|
|
|
$self->polyline->clip_with_expolygon($expolygon);
|
2013-06-20 18:11:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
sub intersect_expolygons {
|
|
|
|
my $self = shift;
|
2013-09-16 16:42:28 +00:00
|
|
|
my ($expolygons_pp) = @_;
|
2013-06-20 18:11:46 +00:00
|
|
|
|
|
|
|
return map $self->clone(polyline => Slic3r::Polyline->new(@$_)),
|
2013-09-16 16:42:28 +00:00
|
|
|
@{Boost::Geometry::Utils::multi_polygon_multi_linestring_intersection($expolygons_pp, [$self->pp])};
|
2013-06-20 18:11:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
sub subtract_expolygons {
|
|
|
|
my $self = shift;
|
2013-09-16 16:42:28 +00:00
|
|
|
my ($expolygons_pp) = @_;
|
2013-06-20 18:11:46 +00:00
|
|
|
|
|
|
|
return map $self->clone(polyline => Slic3r::Polyline->new(@$_)),
|
2013-09-16 16:42:28 +00:00
|
|
|
@{Boost::Geometry::Utils::multi_linestring_multi_polygon_difference([$self->pp], $expolygons_pp)};
|
2012-02-19 11:03:36 +00:00
|
|
|
}
|
|
|
|
|
2013-03-16 17:42:56 +00:00
|
|
|
sub simplify {
|
|
|
|
my $self = shift;
|
2013-07-16 15:13:01 +00:00
|
|
|
$self->polyline($self->polyline->simplify(@_));
|
|
|
|
}
|
|
|
|
|
|
|
|
sub clip_end {
|
|
|
|
my $self = shift;
|
|
|
|
my $polyline = $self->polyline;
|
|
|
|
$polyline->clip_end(@_);
|
|
|
|
$self->polyline($polyline);
|
|
|
|
}
|
|
|
|
|
|
|
|
sub length {
|
|
|
|
my $self = shift;
|
|
|
|
return $self->polyline->length;
|
2013-03-16 17:42:56 +00:00
|
|
|
}
|
|
|
|
|
2011-12-30 18:59:51 +00:00
|
|
|
sub points {
|
|
|
|
my $self = shift;
|
|
|
|
return $self->polyline;
|
|
|
|
}
|
|
|
|
|
2013-03-09 19:28:03 +00:00
|
|
|
sub is_perimeter {
|
|
|
|
my $self = shift;
|
|
|
|
return $self->role == EXTR_ROLE_PERIMETER
|
|
|
|
|| $self->role == EXTR_ROLE_EXTERNAL_PERIMETER
|
2013-05-14 18:19:42 +00:00
|
|
|
|| $self->role == EXTR_ROLE_OVERHANG_PERIMETER
|
2013-03-09 19:28:03 +00:00
|
|
|
|| $self->role == EXTR_ROLE_CONTOUR_INTERNAL_PERIMETER;
|
|
|
|
}
|
|
|
|
|
2013-03-04 22:37:58 +00:00
|
|
|
sub is_fill {
|
|
|
|
my $self = shift;
|
|
|
|
return $self->role == EXTR_ROLE_FILL
|
|
|
|
|| $self->role == EXTR_ROLE_SOLIDFILL
|
|
|
|
|| $self->role == EXTR_ROLE_TOPSOLIDFILL;
|
|
|
|
}
|
|
|
|
|
2013-05-10 18:53:49 +00:00
|
|
|
sub is_bridge {
|
|
|
|
my $self = shift;
|
|
|
|
return $self->role == EXTR_ROLE_BRIDGE
|
2013-05-14 18:19:42 +00:00
|
|
|
|| $self->role == EXTR_ROLE_INTERNALBRIDGE
|
|
|
|
|| $self->role == EXTR_ROLE_OVERHANG_PERIMETER;
|
2013-05-10 18:53:49 +00:00
|
|
|
}
|
|
|
|
|
2011-09-04 10:04:01 +00:00
|
|
|
1;
|