#!/usr/bin/perl require 'library.pl'; die unless @ARGV==4; ($prime,$zinput,$options,$output) = @ARGV; $output =~ s/^\-o// or die "$output ?"; die if $prime =~ m/^\-/; die if $zinput =~ m/^\-/; die unless $options =~ m/^\-([gTa])$/; $ztype= $1; $gnuplot= "$output.gnuplot.tmp"; $initdata= "$output.initdata.tmp"; open G, ">$gnuplot" or die $!; open Z, "$zinput" or die "$zinput $!"; sub pg ($$) { printf G "%s(u,v) = %s\n", @_ or die $!; } for (;;) { $!=0; defined($_= ) or die "$zinput $!"; s/\r$//; if ($ztype eq 'g') { print G or die $!; last if m/^END$/; } elsif ($ztype eq 'T') { next unless m/^splot\s+([^,]+),([^,]+),([^,]+)\s*$/; pg('x',$1); pg('y',$2); pg('z',$3); last; } } printf G "set print \"-\"\n" or die $!; sub initdata_prime_point_callback ($$$$) { my ($u,$v,$comment,$floatformat) = @_; # SGT's coordinates for ($k=0; $k<3; $k++) { printf(G "print %s( $floatformat, $floatformat ) ;%s\n", qw(x y z)[$k], $u, $v, $comment) or die $!; } } sub initdata_return_vertex_transform () { $vertex[1] *= -1; } initdata_process_prime(); close G or die $!; run("gnuplot $gnuplot >$initdata"); make_initdata();