diff options
author | Alessandro Ranellucci <aar@cpan.org> | 2014-03-03 04:48:05 +0400 |
---|---|---|
committer | Alessandro Ranellucci <aar@cpan.org> | 2014-03-03 04:48:05 +0400 |
commit | b49a6527360a48b5f56d95e410b94a2b1400e2f2 (patch) | |
tree | b0ade48dcb00f8c3b3e17d528f7036fd289846b1 /t/thin.t | |
parent | eadffe4a9ea2c8ab9784bfc6c03b21b413a4c5dc (diff) |
Rewritten half-edge traversal in a more robust way. Includes first medial axis unit test
Diffstat (limited to 't/thin.t')
-rw-r--r-- | t/thin.t | 25 |
1 files changed, 23 insertions, 2 deletions
@@ -1,4 +1,4 @@ -use Test::More tests => 1; +use Test::More tests => 3; use strict; use warnings; @@ -9,7 +9,7 @@ BEGIN { use Slic3r; use List::Util qw(first); -use Slic3r::Geometry qw(epsilon); +use Slic3r::Geometry qw(epsilon scale); use Slic3r::Test; { @@ -45,4 +45,25 @@ use Slic3r::Test; 'no superfluous thin walls are generated for toothed profile'; } +my $square = Slic3r::Polygon->new_scale( # ccw + [100, 100], + [200, 100], + [200, 200], + [100, 200], +); +my $hole_in_square = Slic3r::Polygon->new_scale( # cw + [140, 140], + [140, 160], + [160, 160], + [160, 140], +); + +{ + my $expolygon = Slic3r::ExPolygon->new($square, $hole_in_square); + my $res = $expolygon->medial_axis(scale 10); + is scalar(@$res), 1, 'medial axis of a square shape is a single closed loop'; + ok $res->[0]->length > $hole_in_square->length && $res->[0]->length < $square->length, + 'medial axis loop has reasonable length'; +} + __END__ |