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

« back to all changes in this revision

Viewing changes to lib/Slic3r/Polygon.pm

  • Committer: Package Import Robot
  • Author(s): Alessandro Ranellucci
  • Date: 2014-08-06 11:18:02 UTC
  • mfrom: (1.1.3)
  • Revision ID: package-import@ubuntu.com-20140806111802-8v6iez93cj6skz5l
Tags: 1.1.7+dfsg-1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
7
7
 
8
8
use Slic3r::Geometry qw(
9
9
    polygon_segment_having_point
10
 
    PI X1 X2 Y1 Y2 epsilon);
 
10
    PI X1 X2 Y1 Y2 epsilon scaled_epsilon);
11
11
use Slic3r::Geometry::Clipper qw(intersection_pl);
12
12
 
13
13
sub wkt {
54
54
    # but angle3points measures CCW angle, so we calculate the complementary angle
55
55
    my $ccw_angle = 2*PI-$angle;
56
56
    
57
 
    my @points = @$self;
58
 
    my @points_pp = @{$self->pp};
59
 
    
60
57
    my @concave = ();
 
58
    my @points = @$self;
 
59
    my @points_pp = @{$self->pp};
 
60
 
61
61
    for my $i (-1 .. ($#points-1)) {
62
 
        next if $points[$i-1]->coincides_with_epsilon($points[$i]) || $points[$i+1]->coincides_with_epsilon($points[$i]);
63
62
        # angle is measured in ccw orientation
64
63
        my $vertex_angle = Slic3r::Geometry::angle3points(@points_pp[$i, $i-1, $i+1]);
65
64
        if ($vertex_angle <= $ccw_angle) {
66
65
            push @concave, $points[$i];
67
66
        }
68
67
    }
 
68
    
69
69
    return [@concave];
70
70
}
71
71
 
78
78
    # but angle3points measures CCW angle, so we calculate the complementary angle
79
79
    my $ccw_angle = 2*PI-$angle;
80
80
    
81
 
    my @points = @$self;
82
 
    my @points_pp = @{$self->pp};
83
 
    
84
81
    my @convex = ();
 
82
    my @points = @$self;
 
83
    my @points_pp = @{$self->pp};
 
84
    
85
85
    for my $i (-1 .. ($#points-1)) {
86
 
        next if $points[$i-1]->coincides_with_epsilon($points[$i]) || $points[$i+1]->coincides_with_epsilon($points[$i]);
87
86
        # angle is measured in ccw orientation
88
87
        my $vertex_angle = Slic3r::Geometry::angle3points(@points_pp[$i, $i-1, $i+1]);
89
88
        if ($vertex_angle >= $ccw_angle) {