Welcome to mirror list, hosted at ThFree Co, Russian Federation.

01_trianglemesh.t « t « xs - github.com/prusa3d/PrusaSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 42ed111454a1b2d5090300b3832f1c9c9b758abf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/usr/bin/perl

use strict;
use warnings;

use Slic3r::XS;
use Test::More tests => 5;

is Slic3r::TriangleMesh::XS::hello_world(), 'Hello world!',
    'hello world';

my $cube = {
    vertices    => [ [20,20,0], [20,0,0], [0,0,0], [0,20,0], [20,20,20], [0,20,20], [0,0,20], [20,0,20] ],
    facets      => [ [0,1,2], [0,2,3], [4,5,6], [4,6,7], [0,4,7], [0,7,1], [1,7,6], [1,6,2], [2,6,5], [2,5,3], [4,0,3], [4,3,5] ],
};

{
    my $m = Slic3r::TriangleMesh::XS->new;
    $m->ReadFromPerl($cube->{vertices}, $cube->{facets});
    $m->Repair;
    my ($vertices, $facets) = @{$m->ToPerl};
    is_deeply $vertices, $cube->{vertices}, 'vertices arrayref roundtrip';
    is_deeply $facets, $cube->{facets}, 'facets arrayref roundtrip';
    
    my $stats = $m->stats;
    is $stats->{number_of_facets}, scalar(@{ $cube->{facets} }), 'stats.number_of_facets';
    ok abs($stats->{volume} - 20*20*20) < 1E-3, 'stats.volume';
}

__END__