mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-26 16:13:58 -06:00
Some tests were failing
This commit is contained in:
parent
02a1b0cdab
commit
7628c83e9f
5 changed files with 64 additions and 65 deletions
|
@ -1,4 +1,6 @@
|
||||||
use Test::More;
|
use Test::More;
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
|
||||||
plan tests => 4;
|
plan tests => 4;
|
||||||
|
|
||||||
|
|
14
t/clipper.t
14
t/clipper.t
|
@ -1,4 +1,6 @@
|
||||||
use Test::More;
|
use Test::More;
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
|
||||||
plan tests => 1;
|
plan tests => 1;
|
||||||
|
|
||||||
|
@ -20,7 +22,7 @@ my $hole_in_square = [ # cw
|
||||||
[16, 14],
|
[16, 14],
|
||||||
];
|
];
|
||||||
|
|
||||||
my $square = [ # ccw
|
my $square2 = [ # ccw
|
||||||
[5, 12],
|
[5, 12],
|
||||||
[25, 12],
|
[25, 12],
|
||||||
[25, 18],
|
[25, 18],
|
||||||
|
@ -28,7 +30,7 @@ my $square = [ # ccw
|
||||||
];
|
];
|
||||||
|
|
||||||
$clipper->add_subject_polygons([ $square, $hole_in_square ]);
|
$clipper->add_subject_polygons([ $square, $hole_in_square ]);
|
||||||
$clipper->add_clip_polygons([ $square ]);
|
$clipper->add_clip_polygons([ $square2 ]);
|
||||||
my $intersection = $clipper->ex_execute(CT_INTERSECTION, PFT_NONZERO, PFT_NONZERO);
|
my $intersection = $clipper->ex_execute(CT_INTERSECTION, PFT_NONZERO, PFT_NONZERO);
|
||||||
|
|
||||||
is_deeply $intersection, [
|
is_deeply $intersection, [
|
||||||
|
@ -42,10 +44,10 @@ is_deeply $intersection, [
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
outer => [
|
outer => [
|
||||||
[5, 18],
|
[10, 18],
|
||||||
[5, 12],
|
[10, 12],
|
||||||
[25, 12],
|
[20, 12],
|
||||||
[25, 18],
|
[20, 18],
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
], 'hole is preserved after intersection';
|
], 'hole is preserved after intersection';
|
||||||
|
|
12
t/geometry.t
12
t/geometry.t
|
@ -127,12 +127,6 @@ is Slic3r::Geometry::can_connect_points(@$points, $polygons), 0, 'can_connect_po
|
||||||
polygon_remove_parallel_continuous_edges($polygon);
|
polygon_remove_parallel_continuous_edges($polygon);
|
||||||
polygon_remove_acute_vertices($polygon);
|
polygon_remove_acute_vertices($polygon);
|
||||||
is scalar(@$polygon), 4, 'polygon_remove_acute_vertices';
|
is scalar(@$polygon), 4, 'polygon_remove_acute_vertices';
|
||||||
|
|
||||||
use Slic3r::SVG;
|
|
||||||
#pop @$polygon;
|
|
||||||
Slic3r::SVG::output(undef, "vert.svg",
|
|
||||||
polylines => [$polygon],
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#==========================================================
|
#==========================================================
|
||||||
|
@ -144,12 +138,6 @@ is Slic3r::Geometry::can_connect_points(@$points, $polygons), 0, 'can_connect_po
|
||||||
];
|
];
|
||||||
polyline_remove_acute_vertices($polygon);
|
polyline_remove_acute_vertices($polygon);
|
||||||
is scalar(@$polygon), 6, 'polyline_remove_acute_vertices';
|
is scalar(@$polygon), 6, 'polyline_remove_acute_vertices';
|
||||||
use Slic3r::SVG;
|
|
||||||
local $Slic3r::resolution = 0.1;
|
|
||||||
pop @$polygon;
|
|
||||||
Slic3r::SVG::output(undef, "vert2.svg",
|
|
||||||
polylines => [$polygon],
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#==========================================================
|
#==========================================================
|
|
@ -1,6 +1,8 @@
|
||||||
use Test::More;
|
use Test::More;
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
|
||||||
plan tests => 13;
|
plan tests => 14;
|
||||||
|
|
||||||
BEGIN {
|
BEGIN {
|
||||||
use FindBin;
|
use FindBin;
|
||||||
|
@ -50,6 +52,7 @@ is_deeply $intersection, [ [12, 12], [18, 16] ], 'internal lines are preserved';
|
||||||
|
|
||||||
#==========================================================
|
#==========================================================
|
||||||
|
|
||||||
|
{
|
||||||
my $hole_in_square = [ # cw
|
my $hole_in_square = [ # cw
|
||||||
[14, 14],
|
[14, 14],
|
||||||
[14, 16],
|
[14, 16],
|
||||||
|
@ -61,9 +64,11 @@ is_deeply $intersections, [
|
||||||
[ [10, 15], [14, 15] ],
|
[ [10, 15], [14, 15] ],
|
||||||
[ [16, 15], [20, 15] ],
|
[ [16, 15], [20, 15] ],
|
||||||
], 'line is clipped to square with hole';
|
], 'line is clipped to square with hole';
|
||||||
|
}
|
||||||
|
|
||||||
#==========================================================
|
#==========================================================
|
||||||
|
|
||||||
|
{
|
||||||
my $large_circle = [ # ccw
|
my $large_circle = [ # ccw
|
||||||
[151.8639,288.1192], [133.2778,284.6011], [115.0091,279.6997], [98.2859,270.8606], [82.2734,260.7933],
|
[151.8639,288.1192], [133.2778,284.6011], [115.0091,279.6997], [98.2859,270.8606], [82.2734,260.7933],
|
||||||
[68.8974,247.4181], [56.5622,233.0777], [47.7228,216.3558], [40.1617,199.0172], [36.6431,180.4328],
|
[68.8974,247.4181], [56.5622,233.0777], [47.7228,216.3558], [40.1617,199.0172], [36.6431,180.4328],
|
||||||
|
@ -95,4 +100,4 @@ is_deeply $intersections, [
|
||||||
[ [152.741724, 35.166466971035], [152.741724, 108.087543109156] ],
|
[ [152.741724, 35.166466971035], [152.741724, 108.087543109156] ],
|
||||||
[ [152.741724, 215.178806915206], [152.741724, 288.086671142818] ],
|
[ [152.741724, 215.178806915206], [152.741724, 288.086671142818] ],
|
||||||
], 'line is clipped to square with hole';
|
], 'line is clipped to square with hole';
|
||||||
|
}
|
||||||
|
|
8
t/stl.t
8
t/stl.t
|
@ -1,4 +1,6 @@
|
||||||
use Test::More;
|
use Test::More;
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
|
||||||
plan tests => 11;
|
plan tests => 11;
|
||||||
|
|
||||||
|
@ -28,8 +30,8 @@ is_deeply lines(28, 20, 30), [ ], 'lower vertex on la
|
||||||
is_deeply lines(24, 10, 16), [ [ [4, 4], [2, 6] ] ], 'two edges intersect';
|
is_deeply lines(24, 10, 16), [ [ [4, 4], [2, 6] ] ], 'two edges intersect';
|
||||||
is_deeply lines(24, 10, 20), [ [ [4, 4], [1, 9] ] ], 'one vertex on plane and one edge intersects';
|
is_deeply lines(24, 10, 20), [ [ [4, 4], [1, 9] ] ], 'one vertex on plane and one edge intersects';
|
||||||
|
|
||||||
my @lower = $stl->intersect_facet(vertices(22, 20, 20), $z, $dz);
|
my @lower = $stl->intersect_facet(vertices(22, 20, 20), $z);
|
||||||
my @upper = $stl->intersect_facet(vertices(20, 20, 10), $z, $dz);
|
my @upper = $stl->intersect_facet(vertices(20, 20, 10), $z);
|
||||||
isa_ok $lower[0], 'Slic3r::Line::FacetEdge', 'bottom edge on layer';
|
isa_ok $lower[0], 'Slic3r::Line::FacetEdge', 'bottom edge on layer';
|
||||||
isa_ok $upper[0], 'Slic3r::Line::FacetEdge', 'upper edge on layer';
|
isa_ok $upper[0], 'Slic3r::Line::FacetEdge', 'upper edge on layer';
|
||||||
is $lower[0]->edge_type, 'bottom', 'lower edge is detected as bottom';
|
is $lower[0]->edge_type, 'bottom', 'lower edge is detected as bottom';
|
||||||
|
@ -40,5 +42,5 @@ sub vertices {
|
||||||
}
|
}
|
||||||
|
|
||||||
sub lines {
|
sub lines {
|
||||||
[ map [ map ref $_ eq 'Slic3r::Point' ? $_->p : [ map sprintf('%.0f', $_), @$_ ], @$_ ], map $_->p, $stl->intersect_facet(vertices(@_), $z, $dz) ];
|
[ map [ map ref $_ eq 'Slic3r::Point' ? $_->p : [ map sprintf('%.0f', $_), @$_ ], @$_ ], map $_->p, $stl->intersect_facet(vertices(@_), $z) ];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue