mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-08-07 22:14:00 -06:00
Fixes for hi-res STL models
This commit is contained in:
parent
6444c3d7a9
commit
794b7a99d2
8 changed files with 139 additions and 63 deletions
37
t/stl.t
Normal file
37
t/stl.t
Normal file
|
@ -0,0 +1,37 @@
|
|||
use Test::More;
|
||||
|
||||
plan tests => 7;
|
||||
|
||||
BEGIN {
|
||||
use FindBin;
|
||||
use lib "$FindBin::Bin/../lib";
|
||||
}
|
||||
|
||||
use Slic3r;
|
||||
|
||||
my $stl = Slic3r::STL->new;
|
||||
|
||||
my @lines;
|
||||
my $z = 20;
|
||||
my @points = ([3, 4], [8, 5], [1, 9]);
|
||||
|
||||
is_deeply lines(20, 20, 20), [
|
||||
[ $points[0], $points[1] ],
|
||||
[ $points[1], $points[2] ],
|
||||
[ $points[2], $points[0] ],
|
||||
], 'horizontal';
|
||||
|
||||
is_deeply lines(22, 20, 20), [ [ $points[1], $points[2] ] ], 'lower edge on layer';
|
||||
is_deeply lines(20, 20, 10), [ [ $points[0], $points[1] ] ], 'upper edge on layer';
|
||||
is_deeply lines(20, 15, 10), [ ], 'upper vertex on layer';
|
||||
is_deeply lines(28, 20, 30), [ ], 'lower vertex on layer';
|
||||
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';
|
||||
|
||||
sub vertices {
|
||||
[ map [ @{$points[$_]}, $_[$_] ], 0..2 ]
|
||||
}
|
||||
|
||||
sub lines {
|
||||
[ map [ map ref $_ eq 'Slic3r::Point' ? $_->p : [ map sprintf('%.0f', $_), @$_ ], @$_ ], $stl->intersect_facet(vertices(@_), $z, $dz) ];
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue