1
0
mirror of git://projects.qi-hardware.com/cae-tools.git synced 2024-12-23 09:27:42 +02:00

cameo/fped2d2z.pl: added option -r, like in zstack.pl

This commit is contained in:
Werner Almesberger 2012-03-19 15:22:03 -03:00
parent ce243b6a79
commit 9f5751aaa9

View File

@ -14,11 +14,18 @@
sub usage sub usage
{ {
print STDERR "usage: $0 prefix [file ...]\n"; print STDERR "usage: $0 [-r] prefix [file ...]\n\n";
print STDERR " -r reverse Z stacking. Also swaps X and Y.\n";
exit(1); exit(1);
} }
if ($ARGV[0] eq "-r") {
shift @ARGV;
$reverse = 1;
}
&usage if $ARGV[0] =~ /^-/;
$pfx = shift @ARGV; $pfx = shift @ARGV;
&usage unless defined $pfx; &usage unless defined $pfx;
@ -31,6 +38,20 @@ while (<>) {
$skip = 1; $skip = 1;
} }
next if $skip; next if $skip;
s/\s+-?\d+(\.\d*)?$/$& $z/; $z{$z} .= $_;
print; $zmax = $z if $z > $zmax || !defined $zmax;
}
if ($reverse) {
for (keys %z) {
($t{$zmax-$_} = $z{$_}) =~
s/^(-?\d+(\.\d*)?)\s+(-?\d+(\.\d*)?)/$3 $1/mg;
}
%z = %t;
}
# sort, to make output easier to examine manually
for (sort { $b <=> $a } keys %z) {
$z{$_} =~ s/\s+-?\d+(\.\d*)?$/$& $_/gm;
print $z{$_};
} }