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

github.com/prusa3d/PrusaSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorAlessandro Ranellucci <aar@cpan.org>2013-06-08 22:02:21 +0400
committerAlessandro Ranellucci <aar@cpan.org>2013-06-08 22:02:21 +0400
commit6ae766600657cac98bf3b129fefd28ea33c8cda1 (patch)
treebfd63806a7de277c1f4a8cb67e1d024f21f99864 /utils
parentb12a09ed71b5264e5e0123ff0e38b12df07a7657 (diff)
New utility script to dump STL contents in Perl syntax for writing tests
Diffstat (limited to 'utils')
-rw-r--r--utils/dump-stl.pl34
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__