PrusaSlicer-NonPlainar/lib/Slic3r/ExPolygon.pm

54 lines
1.1 KiB
Perl
Raw Normal View History

package Slic3r::ExPolygon;
use strict;
use warnings;
# an ExPolygon is a polygon with holes
use List::Util qw(first);
2013-11-06 18:38:10 +00:00
use Slic3r::Geometry qw(X Y A B point_in_polygon epsilon scaled_epsilon);
2013-11-21 13:15:38 +00:00
use Slic3r::Geometry::Clipper qw(union_ex diff_pl);
2013-01-27 23:02:34 +00:00
sub wkt {
my $self = shift;
return sprintf "POLYGON(%s)",
join ',', map "($_)", map { join ',', map "$_->[0] $_->[1]", @$_ } @$self;
}
sub dump_perl {
my $self = shift;
return sprintf "[%s]",
join ',', map "[$_]", map { join ',', map "[$_->[0],$_->[1]]", @$_ } @$self;
}
sub offset {
my $self = shift;
2013-07-16 22:48:29 +00:00
return Slic3r::Geometry::Clipper::offset(\@$self, @_);
}
sub offset_ex {
my $self = shift;
return Slic3r::Geometry::Clipper::offset_ex(\@$self, @_);
}
sub noncollapsing_offset_ex {
my $self = shift;
my ($distance, @params) = @_;
return $self->offset_ex($distance + 1, @params);
}
sub bounding_box {
my $self = shift;
return $self->contour->bounding_box;
}
package Slic3r::ExPolygon::Collection;
use Slic3r::Geometry qw(X1 Y1);
sub size {
my $self = shift;
return [ Slic3r::Geometry::size_2D([ map @$_, map @$_, @$self ]) ];
}
1;