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
diff options
context:
space:
mode:
authorAlessandro Ranellucci <aar@cpan.org>2013-11-22 19:19:15 +0400
committerAlessandro Ranellucci <aar@cpan.org>2013-11-22 19:19:15 +0400
commita950fbe0c2f7384fda38d0e6816a4406dcfc0e71 (patch)
treec8b9590e9271e6fc74b30d03c241464e21470ba7 /t
parent132d170f73524d0e347a924393e4431e163e988e (diff)
Removed more unused functions and fixed tests
Diffstat (limited to 't')
-rw-r--r--t/clean_polylines.t84
-rw-r--r--t/geometry.t31
-rw-r--r--t/polyclip.t10
3 files changed, 15 insertions, 110 deletions
diff --git a/t/clean_polylines.t b/t/clean_polylines.t
index 4ad905f68..4526bd60c 100644
--- a/t/clean_polylines.t
+++ b/t/clean_polylines.t
@@ -2,7 +2,7 @@ use Test::More;
use strict;
use warnings;
-plan tests => 10;
+plan tests => 6;
BEGIN {
use FindBin;
@@ -12,15 +12,6 @@ BEGIN {
use Slic3r;
{
- my $polygon = Slic3r::Polygon->new(
- [5,0], [10,0], [15,0], [20,0], [20,10], [20,30], [0,0],
- );
-
- $polygon = $polygon->merge_continuous_lines;
- is scalar(@$polygon), 3, 'merge_continuous_lines';
-}
-
-{
my $polyline = Slic3r::Polyline->new(
[0,0],[1,0],[2,0],[2,1],[2,2],[1,2],[0,2],[0,1],[0,0],
);
@@ -37,7 +28,7 @@ use Slic3r;
}
{
- my $gear = [
+ my $gear = Slic3r::Polygon->new_scale(
[144.9694,317.1543], [145.4181,301.5633], [146.3466,296.921], [131.8436,294.1643], [131.7467,294.1464],
[121.7238,291.5082], [117.1631,290.2776], [107.9198,308.2068], [100.1735,304.5101], [104.9896,290.3672],
[106.6511,286.2133], [93.453,279.2327], [81.0065,271.4171], [67.7886,286.5055], [60.7927,280.1127],
@@ -67,76 +58,25 @@ use Slic3r;
[234.9061,298.5798], [227.0321,286.2841], [225.2505,281.8301], [211.5387,287.8187], [202.3025,291.0935],
[197.307,292.831], [199.808,313.1906], [191.5298,315.0787], [187.3082,299.8172], [186.4201,295.3766],
[180.595,296.0487], [161.7854,297.4248], [156.8058,297.6214], [154.3395,317.8592],
- ];
- my $polygon = Slic3r::Polygon->new(@$gear);
- $polygon = $polygon->merge_continuous_lines;
- note sprintf "original points: %d\nnew points: %d", scalar(@$gear), scalar(@$polygon);
- ok @$polygon < @$gear, 'gear was simplified using merge_continuous_lines';
-
- my $num_points = scalar @$polygon;
- my @simplified = $polygon->simplify;
- ok @simplified == 1, 'gear simplified to a single polygon';
- note sprintf "original points: %d\nnew points: %d", $num_points, scalar(@{$simplified[0]});
- ok @{$simplified[0]} < $num_points, 'gear was further simplified using Douglas-Peucker';
+ );
- my @simplified_ex = Slic3r::ExPolygon->new($polygon)->simplify(10);
- is_deeply [ map $_->pp, @simplified_ex ], [ [ map $_->pp, @simplified ] ], 'simplified polygon equals simplified expolygon';
+ my $num_points = scalar @$gear;
+ my $simplified = $gear->simplify(1000);
+ ok @$simplified == 1, 'gear simplified to a single polygon';
+ ###note sprintf "original points: %d\nnew points: %d", $num_points, scalar(@{$simplified->[0]});
+ ok @{$simplified->[0]} < $num_points, 'gear was further simplified using Douglas-Peucker';
}
{
- my $square = Slic3r::Polygon->new( # ccw
- [100, 100],
- [200, 100],
- [200, 200],
- [100, 200],
- );
+
my $hole_in_square = Slic3r::Polygon->new( # cw
[140, 140],
[140, 160],
[160, 160],
[160, 140],
);
- my $expolygon = Slic3r::ExPolygon->new($square, $hole_in_square);
- my @simplified = $hole_in_square->simplify;
- is scalar(@simplified), 1, 'hole simplification returns one polygon';
- ok $simplified[0]->is_counter_clockwise, 'hole simplification turns cw polygon into ccw polygon';
+ my $simplified = $hole_in_square->simplify(2);
+ is scalar(@$simplified), 1, 'hole simplification returns one polygon';
+ ok $simplified->[0]->is_counter_clockwise, 'hole simplification turns cw polygon into ccw polygon';
}
-{
- my $circle = [
- [3744.8,8045.8],[3788.1,8061.4],[3940.6,8116.3],[3984.8,8129.2],[4140.6,8174.4],[4185.5,8184.4],[4343.8,8219.9],
- [4389.2,8227.1],[4549.4,8252.4],[4595.2,8256.7],[4756.6,8272],[4802.6,8273.4],[4964.7,8278.5],[5010.7,8277.1],
- [5172.8,8272],[5218.6,8267.7],[5380,8252.4],[5425.5,8245.2],[5585.6,8219.9],[5630.5,8209.8],[5788.8,8174.4],
- [5833,8161.6],[5988.8,8116.3],[6032,8100.7],[6184.6,8045.8],[6226.8,8027.5],[6375.6,7963.2],[6416.6,7942.3],
- [6561.1,7868.6],[6600.7,7845.2],[6740.3,7762.7],[6778.4,7736.8],[6912.5,7645.7],[6948.8,7617.5],[7077,7518],
- [7111.5,7487.6],[7233.2,7380.4],[7347.9,7265.7],[7380.4,7233.2],[7410.8,7198.7],[7518,7077],[7546.2,7040.6],
- [7645.7,6912.5],[7671.5,6874.4],[7762.7,6740.3],[7786.1,6700.7],[7868.6,6561.1],[7889.5,6520.2],[7963.2,6375.6],
- [7981.4,6333.4],[8045.8,6184.6],[8061.4,6141.3],[8116.3,5988.8],[8129.2,5944.6],[8174.4,5788.8],[8184.4,5743.9],
- [8219.9,5585.6],[8227.1,5540.2],[8252.4,5380],[8256.7,5334.2],[8272,5172.8],[8273.4,5126.8],[8278.5,4964.7],
- [8277.1,4918.7],[8272,4756.6],[8267.7,4710.8],[8252.4,4549.4],[8245.2,4503.9],[8219.9,4343.8],[8209.8,4298.9],
- [8174.4,4140.6],[8161.6,4096.4],[8116.3,3940.6],[8100.7,3897.4],[8045.8,3744.8],[8027.5,3702.6],[7963.2,3553.8],
- [7942.3,3512.8],[7868.6,3368.3],[7845.2,3328.7],[7762.7,3189.1],[7736.8,3151],[7645.7,3016.9],[7617.5,2980.6],
- [7518,2852.4],[7487.6,2817.9],[7380.4,2696.2],[7347.9,2663.7],[7233.2,2549],[7198.7,2518.6],[7077,2411.4],
- [7040.6,2383.2],[6912.5,2283.7],[6874.4,2257.9],[6740.3,2166.7],[6700.7,2143.3],[6561.1,2060.8],[6520.2,2039.9],
- [6375.6,1966.2],[6333.4,1948],[6184.6,1883.6],[6141.3,1868],[5988.8,1813.1],[5944.6,1800.2],[5788.8,1755],
- [5743.9,1745],[5585.6,1709.5],[5540.2,1702.3],[5380,1677],[5334.2,1672.7],[5172.8,1657.4],[5126.8,1656],
- [4964.7,1650.9],[4918.7,1652.3],[4756.6,1657.4],[4710.8,1661.7],[4549.4,1677],[4503.9,1684.2],[4343.8,1709.5],
- [4298.9,1719.6],[4140.6,1755],[4096.4,1767.8],[3940.6,1813.1],[3897.4,1828.7],[3744.8,1883.6],[3702.6,1901.9],
- [3553.8,1966.2],[3512.8,1987.1],[3368.3,2060.8],[3328.7,2084.2],[3189.1,2166.7],[3151,2192.6],[3016.9,2283.7],
- [2980.6,2311.9],[2852.4,2411.4],[2817.9,2441.8],[2696.2,2549],[2581.5,2663.7],[2549,2696.2],[2518.6,2730.7],
- [2411.4,2852.4],[2383.2,2888.8],[2283.7,3016.9],[2257.9,3055],[2166.7,3189.1],[2143.3,3228.7],[2060.8,3368.3],
- [2039.9,3409.2],[1966.2,3553.8],[1948,3596],[1883.6,3744.8],[1868,3788.1],[1813.1,3940.6],[1800.2,3984.8],
- [1755,4140.6],[1745,4185.5],[1709.5,4343.8],[1702.3,4389.2],[1677,4549.4],[1672.7,4595.2],[1657.4,4756.6],
- [1656,4802.6],[1650.9,4964.7],[1652.3,5010.7],[1657.4,5172.8],[1661.7,5218.6],[1677,5380],[1684.2,5425.5],
- [1709.5,5585.6],[1719.6,5630.5],[1755,5788.8],[1767.8,5833],[1813.1,5988.8],[1828.7,6032],[1883.6,6184.6],
- [1901.9,6226.8],[1966.2,6375.6],[1987.1,6416.6],[2060.8,6561.1],[2084.2,6600.7],[2166.7,6740.3],[2192.6,6778.4],
- [2283.7,6912.5],[2311.9,6948.8],[2411.4,7077],[2441.8,7111.5],[2549,7233.2],[2581.5,7265.7],[2696.2,7380.4],
- [2730.7,7410.8],[2852.4,7518],[2888.8,7546.2],[3016.9,7645.7],[3055,7671.5],[3189.1,7762.7],[3228.7,7786.1],
- [3368.3,7868.6],[3409.2,7889.5],[3553.8,7963.2],[3596,7981.4],
- ];
-
- my $polygon = Slic3r::Polygon->new(@$circle);
- $polygon = $polygon->merge_continuous_lines;
- note sprintf "original points: %d\nnew points: %d", scalar(@$circle), scalar(@$polygon);
- ok @$polygon >= @$circle/3, 'circle was simplified using merge_continuous_lines';
-}
diff --git a/t/geometry.t b/t/geometry.t
index 4976f5a09..4edb63dae 100644
--- a/t/geometry.t
+++ b/t/geometry.t
@@ -2,7 +2,7 @@ use Test::More;
use strict;
use warnings;
-plan tests => 25;
+plan tests => 23;
BEGIN {
use FindBin;
@@ -10,9 +10,7 @@ BEGIN {
}
use Slic3r;
-use Slic3r::Geometry qw(PI polyline_remove_parallel_continuous_edges
- polyline_remove_acute_vertices polygon_remove_acute_vertices
- polygon_remove_parallel_continuous_edges polygon_is_convex
+use Slic3r::Geometry qw(PI polygon_is_convex
chained_path_points epsilon scale);
#==========================================================
@@ -116,31 +114,6 @@ my $polygons = [
#==========================================================
{
- my $polygon = [
- [2265447881, 7013509857], [2271869937, 7009802077], [2606221146, 6816764300], [1132221146, 4263721402],
- [1098721150, 4205697705], [1228411320, 4130821051], [1557501031, 3940821051], [1737340080, 3836990933],
- [1736886253, 3837252951], [1494771522, 3977037948], [2959638603, 6514262167], [3002271522, 6588104548],
- [3083252364, 6541350240], [2854283608, 6673545411], [2525193897, 6863545411],
- ];
- polygon_remove_parallel_continuous_edges($polygon);
- polygon_remove_acute_vertices($polygon);
- is scalar(@$polygon), 4, 'polygon_remove_acute_vertices';
-}
-
-#==========================================================
-
-{
- my $polygon = [
- [226.5447881,701.3509857], [260.6221146,681.67643], [109.872115,420.5697705], [149.4771522,397.7037948],
- [300.2271522,658.8104548], [308.3252364,654.135024],
- ];
- polyline_remove_acute_vertices($polygon);
- is scalar(@$polygon), 6, 'polyline_remove_acute_vertices';
-}
-
-#==========================================================
-
-{
my $cw_square = [ [0,0], [0,10], [10,10], [10,0] ];
is polygon_is_convex($cw_square), 0, 'cw square is not convex';
is polygon_is_convex([ reverse @$cw_square ]), 1, 'ccw square is convex';
diff --git a/t/polyclip.t b/t/polyclip.t
index 6ed0028a1..1292d3216 100644
--- a/t/polyclip.t
+++ b/t/polyclip.t
@@ -2,7 +2,7 @@ use Test::More;
use strict;
use warnings;
-plan tests => 19;
+plan tests => 18;
BEGIN {
use FindBin;
@@ -78,14 +78,6 @@ my $square = Slic3r::Polygon->new( # ccw
is $intersection->[0]->length, Slic3r::Line->new([100,180], [200,180])->length,
'tangent line is clipped to square with hole';
}
- {
- my $polyline = Slic3r::Polyline->new([50, 180], [250, 180], [250, 150], [150, 150], [150, 120], [120, 120], [120, 50]);
- is_deeply [ map $_->pp, $polyline->clip_with_expolygon($expolygon) ], [
- [ [100, 180], [200, 180] ],
- [ [200, 150], [160, 150] ],
- [ [150, 140], [150, 120], [120, 120], [120, 100] ],
- ], 'polyline is clipped to square with hole';
- }
}
#==========================================================