2013-06-22 15:16:45 +00:00
|
|
|
#!/usr/bin/perl
|
|
|
|
|
|
|
|
use strict;
|
|
|
|
use warnings;
|
|
|
|
|
|
|
|
use Slic3r::XS;
|
2013-08-04 19:34:26 +00:00
|
|
|
use Test::More tests => 6;
|
2013-06-22 15:16:45 +00:00
|
|
|
|
|
|
|
is Slic3r::TriangleMesh::XS::hello_world(), 'Hello world!',
|
|
|
|
'hello world';
|
|
|
|
|
2013-07-03 09:38:01 +00:00
|
|
|
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;
|
2013-08-04 19:23:27 +00:00
|
|
|
my ($vertices, $facets) = ($m->vertices, $m->facets);
|
|
|
|
|
2013-07-03 09:38:01 +00:00
|
|
|
is_deeply $vertices, $cube->{vertices}, 'vertices arrayref roundtrip';
|
|
|
|
is_deeply $facets, $cube->{facets}, 'facets arrayref roundtrip';
|
2013-07-13 16:51:49 +00:00
|
|
|
|
2013-08-04 19:34:26 +00:00
|
|
|
{
|
|
|
|
my $stats = $m->stats;
|
|
|
|
is $stats->{number_of_facets}, scalar(@{ $cube->{facets} }), 'stats.number_of_facets';
|
|
|
|
ok abs($stats->{volume} - 20*20*20) < 1E-2, 'stats.volume';
|
|
|
|
}
|
|
|
|
|
|
|
|
$m->scale(2);
|
|
|
|
ok abs($m->stats->{volume} - 40*40*40) < 1E-2, 'scale';
|
2013-07-03 09:38:01 +00:00
|
|
|
}
|
|
|
|
|
2013-06-22 15:16:45 +00:00
|
|
|
__END__
|