mirror of
https://github.com/FULU-Foundation/OrcaSlicer-bambulab.git
synced 2026-05-14 13:02:39 -07:00
Faster support generation. Includes a new implementation of the Douglas-Peucker algorithm
This commit is contained in:
@@ -2,7 +2,7 @@ use Test::More;
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
plan tests => 3;
|
||||
plan tests => 6;
|
||||
|
||||
BEGIN {
|
||||
use FindBin;
|
||||
@@ -20,6 +20,22 @@ use Slic3r;
|
||||
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],
|
||||
]);
|
||||
$polyline->simplify(1);
|
||||
is_deeply $polyline, [ [0, 0], [2, 0], [2, 2], [0, 2], [0, 0] ], 'Douglas-Peucker';
|
||||
}
|
||||
|
||||
{
|
||||
my $polyline = Slic3r::Polyline->new([
|
||||
[0,0],[0.5,0.5],[1,0],[1.25,-0.25],[1.5,.5],
|
||||
]);
|
||||
$polyline->simplify(0.25);
|
||||
is_deeply $polyline, [ [0, 0], [0.5, 0.5], [1.25, -0.25], [1.5, 0.5] ], 'Douglas-Peucker';
|
||||
}
|
||||
|
||||
{
|
||||
my $gear = [
|
||||
[144.9694,317.1543], [145.4181,301.5633], [146.3466,296.921], [131.8436,294.1643], [131.7467,294.1464],
|
||||
@@ -57,13 +73,10 @@ use Slic3r;
|
||||
note sprintf "original points: %d\nnew points: %d", scalar(@$gear), scalar(@$polygon);
|
||||
ok @$polygon < @$gear, 'gear was simplified using merge_continuous_lines';
|
||||
|
||||
# simplify() is not being used, so we don't test it
|
||||
if (0) {
|
||||
my $num_points = scalar @$polygon;
|
||||
$polygon->simplify;
|
||||
note sprintf "original points: %d\nnew points: %d", $num_points, scalar(@$polygon);
|
||||
ok @$polygon < $num_points, 'gear was further simplified using Douglas-Peucker';
|
||||
}
|
||||
my $num_points = scalar @$polygon;
|
||||
$polygon->simplify;
|
||||
note sprintf "original points: %d\nnew points: %d", $num_points, scalar(@$polygon);
|
||||
ok @$polygon < $num_points, 'gear was further simplified using Douglas-Peucker';
|
||||
}
|
||||
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user