From c73509dacc0862d742fe2025c04c7dd4b904868f Mon Sep 17 00:00:00 2001 From: Werner Almesberger Date: Wed, 22 Aug 2012 13:51:16 -0300 Subject: [PATCH] cameo/fped2d2z.pl: new option -t Zmax to set the height of the workpiece This is similar to -r, except that we don't swap X and Y, and we use the specified value instead of searching for the maximum in the input data. --- cameo/fped2d2z.pl | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/cameo/fped2d2z.pl b/cameo/fped2d2z.pl index e4c5fe9..01df3fd 100755 --- a/cameo/fped2d2z.pl +++ b/cameo/fped2d2z.pl @@ -14,8 +14,10 @@ sub usage { - print STDERR "usage: $0 [-r] [Zin=Zout ...] prefix [file ...]\n\n"; + print STDERR "usage: $0 [-r|-t Zmax] [Zin=Zout ...] prefix ". + "[file ...]\n\n"; print STDERR " Zin=Zout replace Zin with Zout\n"; + print STDERR " -t Zmax set the top of the piece\n"; print STDERR " -r reverse Z stacking. Also swaps X and Y.\n"; exit(1); } @@ -25,6 +27,10 @@ if ($ARGV[0] eq "-r") { shift @ARGV; $reverse = 1; } +if ($ARGV[0] eq "-t") { + shift @ARGV; + $top = shift @ARGV; +} &usage if $ARGV[0] =~ /^-[^0-9]/; while ($ARGV[0] =~ /=/) { @@ -55,6 +61,12 @@ if ($reverse) { } %z = %t; print "0 0 $zmax\n\n"; +} elsif (defined $top) { + for (keys %z) { + ($t{$top-$_} = $z{$_}) =~ + s/^(-?\d+(\.\d*)?)\s+(-?\d+(\.\d*)?)/$1 $3/mg; + } + %z = %t; } else { print "0 0 0\n\n"; }