Date:2013-11-02 22:03:49 (5 months 21 days ago)
Author:Werner Almesberger
Commit:5b70e92254efdf96aa2e86c15f2ab1861d7c6d3b
Message:cameo/fped2stl.pl: new options -x and -y to flip on X and Y axis

Files: cameo/fped2stl.pl (3 diffs)

Change Details

cameo/fped2stl.pl
1616
1717sub usage
1818{
19    print STDERR "usage: $0 prefix [file ...]\n\n";
19    print STDERR "usage: $0 [-x] [-y] prefix [file ...]\n\n";
2020    exit(1);
2121}
2222
...... 
5959}
6060
6161
62&usage if $ARGV[0] =~ /^-[^0-9]/;
62while ($ARGV[0] =~ /^-/) {
63    if ($ARGV[0] == "-x") {
64        $flip_x = 1;
65    } elsif ($ARGV[0] == "-y") {
66        $flip_y = 1;
67    } elsif ($ARGV[0] =~ /^-[^0-9]/) {
68        last;
69    } else {
70        &usage;
71    }
72    shift;
73}
6374
6475$pfx = shift @ARGV;
6576&usage unless defined $pfx;
...... 
7788    next if $skip;
7889    next if /^#/;
7990    $s{$z} .= $_;
91    if (/^(-?[0-9]*\.[0-9]*)\s+(-?[0-9]*\.[0-9]*)/) {
92        $xmin = $1 if $1 < $xmin || !defined $xmin;
93        $xmax = $1 if $1 > $xmax || !defined $xmax;
94        $ymin = $2 if $2 < $ymin || !defined $ymin;
95        $ymax = $2 if $2 > $ymax || !defined $ymax;
96    }
97}
98
99for $z (keys %s) {
100    undef $t;
101    for $s (split(/\n/, $s{$z})) {
102        if ($s =~ /^(-?[0-9]*\.[0-9]*)\s+(-?[0-9]*\.[0-9]*)/) {
103            $s = (($xmax+$xmin)/2-$1)." $2" if $flip_y;
104
105            # re-scan, so that we can flip on both axes
106            die unless
107                $s =~ /^(-?[0-9]*\.[0-9]*)\s+(-?[0-9]*\.[0-9]*)/;
108            $s = "$1 ".(($ymax+$ymin)/2-$2) if $flip_x;
109        }
110        $t .= "$s\n";
111    }
112    $s{$z} = $t;
80113}
81114
82115undef $last;

Archive Download the corresponding diff file

Branches:
master



interactive