mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-14 18:27:58 -06:00
New fill types (hilbertcurve, archimedeanchords, octagramspiral) and ability to use different patterns for solid layers. #20
This commit is contained in:
parent
041e9877a3
commit
038caddcda
22 changed files with 391 additions and 93 deletions
67
t/polyclip.t
67
t/polyclip.t
|
@ -2,7 +2,7 @@ use Test::More;
|
|||
use strict;
|
||||
use warnings;
|
||||
|
||||
plan tests => 14;
|
||||
plan tests => 24;
|
||||
|
||||
BEGIN {
|
||||
use FindBin;
|
||||
|
@ -59,11 +59,57 @@ is_deeply $intersection, [ [12, 12], [18, 16] ], 'internal lines are preserved';
|
|||
[16, 16],
|
||||
[16, 14],
|
||||
];
|
||||
my $intersections = Slic3r::Geometry::clip_segment_complex_polygon($line, [ $square, $hole_in_square ]);
|
||||
is_deeply $intersections, [
|
||||
[ [10, 15], [14, 15] ],
|
||||
[ [16, 15], [20, 15] ],
|
||||
], 'line is clipped to square with hole';
|
||||
my $expolygon = Slic3r::ExPolygon->new($square, $hole_in_square);
|
||||
is $expolygon->encloses_point([10, 10]), 1, 'corner point is recognized';
|
||||
is $expolygon->encloses_point([10, 18]), 1, 'point on contour is recognized';
|
||||
is $expolygon->encloses_point([14, 15]), 1, 'point on hole contour is recognized';
|
||||
is $expolygon->encloses_point([14, 14]), 1, 'point on hole corner is recognized';
|
||||
{
|
||||
my $intersections = $expolygon->clip_line([ [15,18], [15,15] ]);
|
||||
is_deeply $intersections, [
|
||||
[ [15, 18], [15, 16] ],
|
||||
], 'line is clipped to square with hole';
|
||||
}
|
||||
{
|
||||
my $intersections = $expolygon->clip_line([ [15,15], [15,12] ]);
|
||||
is_deeply $intersections, [
|
||||
[ [15, 14], [15, 12] ],
|
||||
], 'line is clipped to square with hole';
|
||||
}
|
||||
{
|
||||
my $intersections = $expolygon->clip_line([ [12,18], [18,18] ]);
|
||||
is_deeply $intersections, [
|
||||
[ [12,18], [18,18] ],
|
||||
], 'line is clipped to square with hole';
|
||||
}
|
||||
{
|
||||
my $intersections = $expolygon->clip_line($line);
|
||||
is_deeply $intersections, [
|
||||
[ [10, 15], [14, 15] ],
|
||||
[ [16, 15], [20, 15] ],
|
||||
], 'line is clipped to square with hole';
|
||||
}
|
||||
{
|
||||
my $intersections = $expolygon->clip_line([ reverse @$line ]);
|
||||
is_deeply $intersections, [
|
||||
[ [20, 15], [16, 15] ],
|
||||
[ [14, 15], [10, 15] ],
|
||||
], 'reverse line is clipped to square with hole';
|
||||
}
|
||||
{
|
||||
my $intersections = $expolygon->clip_line([ [10,18], [20,18] ]);
|
||||
is_deeply $intersections, [
|
||||
[ [10, 18], [20, 18] ],
|
||||
], 'tangent line is clipped to square with hole';
|
||||
}
|
||||
{
|
||||
my $polyline = Slic3r::Polyline->cast([ [5, 18], [25, 18], [25, 15], [15, 15], [15, 12], [12, 12], [12, 5] ]);
|
||||
is_deeply [ map $_->p, $polyline->clip_with_expolygon($expolygon) ], [
|
||||
[ [10, 18], [20, 18] ],
|
||||
[ [20, 15], [16, 15] ],
|
||||
[ [15, 14], [15, 12], [12, 12], [12, 10] ],
|
||||
], 'polyline is clipped to square with hole';
|
||||
}
|
||||
}
|
||||
|
||||
#==========================================================
|
||||
|
@ -93,11 +139,14 @@ is_deeply $intersection, [ [12, 12], [18, 16] ], 'internal lines are preserved';
|
|||
];
|
||||
is is_counter_clockwise($small_circle), 0, "hole is clockwise";
|
||||
|
||||
my $expolygon = Slic3r::ExPolygon->new($large_circle, $small_circle);
|
||||
$line = [ [152.741724,288.086671142818], [152.741724,34.166466971035] ];
|
||||
|
||||
my $intersections = Slic3r::Geometry::clip_segment_complex_polygon($line, [ $large_circle, $small_circle ]);
|
||||
my $intersections = $expolygon->clip_line($line);
|
||||
is_deeply $intersections, [
|
||||
[ [152.741724, 35.166466971035], [152.741724, 108.087543109156] ],
|
||||
[ [152.741724, 215.178806915206], [152.741724, 288.086671142818] ],
|
||||
[ [152.741724, 288.086671142818], [152.741724, 215.178806915206], ],
|
||||
[ [152.741724, 108.087543109156], [152.741724, 35.166466971035] ],
|
||||
], 'line is clipped to square with hole';
|
||||
}
|
||||
|
||||
#==========================================================
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue