~ubuntu-branches/ubuntu/utopic/slic3r/utopic

« back to all changes in this revision

Viewing changes to lib/Slic3r/ExPolygon.pm

  • Committer: Package Import Robot
  • Author(s): Chow Loong Jin
  • Date: 2014-06-17 01:27:26 UTC
  • Revision ID: package-import@ubuntu.com-20140617012726-2wrs4zdo251nr4vg
Tags: upstream-1.1.4+dfsg
ImportĀ upstreamĀ versionĀ 1.1.4+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
package Slic3r::ExPolygon;
 
2
use strict;
 
3
use warnings;
 
4
 
 
5
# an ExPolygon is a polygon with holes
 
6
 
 
7
use List::Util qw(first);
 
8
use Slic3r::Geometry qw(X Y A B point_in_polygon epsilon scaled_epsilon);
 
9
use Slic3r::Geometry::Clipper qw(union_ex diff_pl);
 
10
 
 
11
sub wkt {
 
12
    my $self = shift;
 
13
    return sprintf "POLYGON(%s)", 
 
14
        join ',', map "($_)", map { join ',', map "$_->[0] $_->[1]", @$_ } @$self;
 
15
}
 
16
 
 
17
sub dump_perl {
 
18
    my $self = shift;
 
19
    return sprintf "[%s]", 
 
20
        join ',', map "[$_]", map { join ',', map "[$_->[0],$_->[1]]", @$_ } @$self;
 
21
}
 
22
 
 
23
sub offset {
 
24
    my $self = shift;
 
25
    return Slic3r::Geometry::Clipper::offset(\@$self, @_);
 
26
}
 
27
 
 
28
sub offset_ex {
 
29
    my $self = shift;
 
30
    return Slic3r::Geometry::Clipper::offset_ex(\@$self, @_);
 
31
}
 
32
 
 
33
sub noncollapsing_offset_ex {
 
34
    my $self = shift;
 
35
    my ($distance, @params) = @_;
 
36
    
 
37
    return $self->offset_ex($distance + 1, @params);
 
38
}
 
39
 
 
40
sub bounding_box {
 
41
    my $self = shift;
 
42
    return $self->contour->bounding_box;
 
43
}
 
44
 
 
45
package Slic3r::ExPolygon::Collection;
 
46
use Slic3r::Geometry qw(X1 Y1);
 
47
 
 
48
sub size {
 
49
    my $self = shift;
 
50
    return [ Slic3r::Geometry::size_2D([ map @$_, map @$_, @$self ]) ];
 
51
}
 
52
 
 
53
1;