diff options
author | Alessandro Ranellucci <aar@cpan.org> | 2013-06-08 22:02:21 +0400 |
---|---|---|
committer | Alessandro Ranellucci <aar@cpan.org> | 2013-06-08 22:02:21 +0400 |
commit | 6ae766600657cac98bf3b129fefd28ea33c8cda1 (patch) | |
tree | bfd63806a7de277c1f4a8cb67e1d024f21f99864 /utils/dump-stl.pl | |
parent | b12a09ed71b5264e5e0123ff0e38b12df07a7657 (diff) |
New utility script to dump STL contents in Perl syntax for writing tests
Diffstat (limited to 'utils/dump-stl.pl')
-rw-r--r-- | utils/dump-stl.pl | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/utils/dump-stl.pl b/utils/dump-stl.pl new file mode 100644 index 000000000..a5c716b83 --- /dev/null +++ b/utils/dump-stl.pl @@ -0,0 +1,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__ |