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

dump-stl.pl « utils - github.com/prusa3d/PrusaSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: a5c716b8393fe3624380515359444dd0f4e8e96d (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
31
32
33
34
#!/usr/bin/perl
# This script dumps a STL file into Perl syntax for writing tests

use strict;
use warnings;

BEGIN {
    use FindBin;
    use lib "$FindBin::Bin/../lib";
}

use Slic3r;
$|++;

$ARGV[0] or usage(1);

{
    my $model = Slic3r::Format::STL->read_file($ARGV[0]);
    my $mesh = $model->mesh;
    printf "VERTICES = %s\n", join ',', map "[$_->[0],$_->[1],$_->[2]]", @{$mesh->vertices};
    printf "FACETS = %s\n", join ',', map "[$_->[0],$_->[1],$_->[2]]", @{$mesh->facets};
}


sub usage {
    my ($exit_code) = @_;
    
    print <<"EOF";
Usage: dump-stl.pl file.stl
EOF
    exit ($exit_code || 0);
}

__END__