File: 010simplify.t

package info (click to toggle)
libmath-clipper-perl 1.23-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd, stretch
  • size: 484 kB
  • ctags: 1,094
  • sloc: cpp: 3,448; perl: 131; makefile: 2
file content (34 lines) | stat: -rw-r--r-- 729 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
use strict;
use warnings;

use Math::Clipper ':all';
use Test::More tests => 4;

my $p1 = [
    [1,1],
    [3,3],
    [3,1],
    [1,3]
];

my $p2 = [
    [0,0],
    [4,0],
    [4,4],
    [0,4],
];

{
    my $simplified = simplify_polygon($p1, PFT_EVENODD);
    is scalar(@$simplified), 2, 'simplify_polygon returned 2 polygons';
    is scalar(grep !orientation($_), @$simplified), 0, 'simplified polygons are ccw';
}

# check that the same simplified polygons are returned as holes now
{
    my $simplified = simplify_polygons([$p1, $p2], PFT_EVENODD);
    is scalar(@$simplified), 3, 'simplify_polygon returned 3 polygons';
    is scalar(grep !orientation($_), @$simplified), 2, '2 out of 3 polygons are cw (holes)';
}

__END__