chiark / gitweb /
6cdbab295e8d404f1db559e5fdc590e62d53e2af
[moebius2.git] / generator
1 #!/usr/bin/perl
2 require 'library.pl';
3 die unless @ARGV==4;
4 ($primer,$zinput,$options,$output) = @ARGV;
5 $output =~ s/^\-o// or die "$output ?";
6 die if $primer =~ m/^\-/;
7 die if $zinput =~ m/^\-/;
8
9 die unless $options =~ m/^\-([gTa])$/;
10 $ztype= $1;
11
12 $gnuplot= "$output.gnuplot.tmp";
13 $initdata= "$output.initdata.tmp";
14
15 open G, ">$gnuplot" or die $!;
16
17 open Z, "$zinput" or die "$zinput $!";
18
19 sub pg ($$) { printf G "%s(u,v) = %s\n", @_ or die $!; }
20 for (;;) {
21     $!=0; defined($_= <Z>) or die "$zinput $!";
22     s/\r$//;
23     if ($ztype eq 'g') {
24         print G or die $!;
25         last if m/^END$/;
26     } elsif ($ztype eq 'T') {
27         next unless m/^splot\s+([^,]+),([^,]+),([^,]+)\s*$/;
28         pg('x',$1); pg('y',$2); pg('z',$3);
29         last;
30     }
31 }
32
33 printf G "set print \"-\"\n" or die $!;
34 close G or die $!;
35
36 run("./$primer 'print ' '+-+' 'xyz' '( ' ', ' ');  # ' ".
37     "'print ' ', ' - >>$gnuplot");
38 run("gnuplot $gnuplot >$initdata");
39
40 make_initdata();