mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-08-09 14:55:08 -06:00
Cleanup lines resulting from plane intersection before detecting polygons. This allows for more tolerance with dirty models. Performance impact depends on how many layers are detected as dirty. #16 #28
This commit is contained in:
parent
fec816b065
commit
c5d5e4d244
10 changed files with 259 additions and 132 deletions
91
t/collinear.t
Normal file
91
t/collinear.t
Normal file
|
@ -0,0 +1,91 @@
|
|||
use Test::More;
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
plan tests => 11;
|
||||
|
||||
BEGIN {
|
||||
use FindBin;
|
||||
use lib "$FindBin::Bin/../lib";
|
||||
}
|
||||
|
||||
use Slic3r;
|
||||
use Slic3r::Geometry qw(collinear);
|
||||
|
||||
#==========================================================
|
||||
|
||||
{
|
||||
my @lines = (
|
||||
[ [0,4], [4,2] ],
|
||||
[ [2,3], [8,0] ],
|
||||
[ [6,1], [8,0] ],
|
||||
);
|
||||
is collinear($lines[0], $lines[1]), 1, 'collinear';
|
||||
is collinear($lines[1], $lines[2]), 1, 'collinear';
|
||||
is collinear($lines[0], $lines[2]), 1, 'collinear';
|
||||
}
|
||||
|
||||
#==========================================================
|
||||
|
||||
{
|
||||
# horizontal
|
||||
my @lines = (
|
||||
[ [0,1], [5,1] ],
|
||||
[ [2,1], [8,1] ],
|
||||
);
|
||||
is collinear($lines[0], $lines[1]), 1, 'collinear';
|
||||
}
|
||||
|
||||
#==========================================================
|
||||
|
||||
{
|
||||
# vertical
|
||||
my @lines = (
|
||||
[ [1,0], [1,5] ],
|
||||
[ [1,2], [1,8] ],
|
||||
);
|
||||
is collinear($lines[0], $lines[1]), 1, 'collinear';
|
||||
}
|
||||
|
||||
#==========================================================
|
||||
|
||||
{
|
||||
# non overlapping
|
||||
my @lines = (
|
||||
[ [0,1], [5,1] ],
|
||||
[ [7,1], [10,1] ],
|
||||
);
|
||||
is collinear($lines[0], $lines[1], 1), 0, 'non overlapping';
|
||||
is collinear($lines[0], $lines[1], 0), 1, 'overlapping';
|
||||
}
|
||||
|
||||
#==========================================================
|
||||
|
||||
{
|
||||
# with one common point
|
||||
my @lines = (
|
||||
[ [0,4], [4,2] ],
|
||||
[ [4,2], [8,0] ],
|
||||
);
|
||||
is collinear($lines[0], $lines[1], 1), 1, 'one common point';
|
||||
is collinear($lines[0], $lines[1], 0), 1, 'one common point';
|
||||
}
|
||||
|
||||
#==========================================================
|
||||
|
||||
{
|
||||
# not collinear
|
||||
my @lines = (
|
||||
[ [290000000,690525600], [285163380,684761540] ],
|
||||
[ [285163380,684761540], [193267599,575244400] ],
|
||||
);
|
||||
is collinear($lines[0], $lines[1], 0), 0, 'not collinear';
|
||||
is collinear($lines[0], $lines[1], 1), 0, 'not collinear';
|
||||
|
||||
use Slic3r::SVG;
|
||||
Slic3r::SVG::output(undef, "collinear.svg",
|
||||
lines => \@lines,
|
||||
);
|
||||
}
|
||||
|
||||
#==========================================================
|
Loading…
Add table
Add a link
Reference in a new issue