Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/prusa3d/PrusaSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/t/thin.t
diff options
context:
space:
mode:
authorAlessandro Ranellucci <aar@cpan.org>2015-05-22 15:26:01 +0300
committerAlessandro Ranellucci <aar@cpan.org>2015-05-22 15:26:01 +0300
commita587e1178045e10faaea0f14117ecfe1a1240a7d (patch)
tree46ebd0c4f2fecb8d8099fdaf1d2932126e5e418d /t/thin.t
parent7cc745969c1cd49e07aaf4ed0fc87441113885ad (diff)
Regression test for overlapping gap fill. #2474
Diffstat (limited to 't/thin.t')
-rw-r--r--t/thin.t27
1 files changed, 26 insertions, 1 deletions
diff --git a/t/thin.t b/t/thin.t
index 950c4ee75..0b3843a10 100644
--- a/t/thin.t
+++ b/t/thin.t
@@ -1,4 +1,4 @@
-use Test::More tests => 16;
+use Test::More tests => 21;
use strict;
use warnings;
@@ -144,4 +144,29 @@ if (0) {
ok unscale($res->[0]->length) >= (200-100 - (120-100)) - epsilon, 'medial axis has reasonable length';
}
+{
+ # GH #2474
+ my $expolygon = Slic3r::ExPolygon->new(Slic3r::Polygon->new(
+ [91294454,31032190],[11294481,31032190],[11294481,29967810],[44969182,29967810],[89909960,29967808],[91294454,29967808]
+ ));
+ my $polylines = $expolygon->medial_axis(1871238, 500000);
+
+ is scalar(@$polylines), 1, 'medial axis is a single polyline';
+ my $polyline = $polylines->[0];
+
+ my $expected_y = $expolygon->bounding_box->center->y; #;;
+ ok abs(sum(map $_->y, @$polyline) / @$polyline - $expected_y) < scaled_epsilon, #,,
+ 'medial axis is horizontal and is centered';
+
+ # order polyline from left to right
+ $polyline->reverse if $polyline->first_point->x > $polyline->last_point->x;
+
+ my $polyline_bb = $polyline->bounding_box;
+ is $polyline->first_point->x, $polyline_bb->x_min, 'expected x_min';
+ is $polyline->last_point->x, $polyline_bb->x_max, 'expected x_max';
+
+ is_deeply [ map $_->x, @$polyline ], [ sort map $_->x, @$polyline ],
+ 'medial axis is not self-overlapping';
+}
+
__END__