tomwalters@0: /* tomwalters@0: ftoa.c frames (SAI or NAP) to ASCII tomwalters@0: ------ tomwalters@0: tomwalters@0: Each data point is output as a triple: (x,y,z) tomwalters@0: where (x,y) specify the coordinate in terms of a pointwise coordinate tomwalters@0: system with the origin (0,0) in the bottom-left of the display. tomwalters@0: tomwalters@0: The output is in space-separated ASCII numbers with one triple per line. tomwalters@0: */ tomwalters@0: tomwalters@0: #include tomwalters@0: #include tomwalters@0: #include "header.h" tomwalters@0: #include "options.h" tomwalters@0: #include "strmatch.h" tomwalters@0: tomwalters@0: tomwalters@0: char applic[] = "Frames to ASCII triples (x,y,z). " ; tomwalters@0: tomwalters@0: static char *helpstr, *debugstr, *formatstr ; tomwalters@0: tomwalters@0: static Options option[] = { tomwalters@0: { "help" , "off" , &helpstr , "help" , DEBUG }, tomwalters@0: { "debug" , "off" , &debugstr , "debugging switch" , DEBUG }, tomwalters@0: { "format" , "nap" , &formatstr , "frame format (nap or sai)" , VAL }, tomwalters@0: ( char * ) 0 } ; tomwalters@0: tomwalters@0: tomwalters@0: int frameheight, framewidth ; /* Parameters read from header */ tomwalters@0: int frames, framebytes ; tomwalters@0: tomwalters@0: main(argc, argv) tomwalters@0: int argc ; tomwalters@0: char *argv[] ; tomwalters@0: { tomwalters@0: FILE *fp ; tomwalters@0: char *header, *SaiHeader(); tomwalters@0: short *frame ; tomwalters@0: int x, y ; tomwalters@0: tomwalters@0: fp = openopts( option,argc,argv ) ; tomwalters@0: if ( !isoff( helpstr ) ) tomwalters@0: helpopts( helpstr, argv[0], applic, option ) ; tomwalters@0: tomwalters@0: if ( (header = ReadHeader(fp)) == (char *) 0 ) { tomwalters@0: fprintf(stderr,"integrate: header not found\n"); tomwalters@0: exit(1); tomwalters@0: } tomwalters@0: tomwalters@0: frameheight = HeaderInt( header, "frameheight" ); tomwalters@0: framewidth = HeaderInt( header, "framewidth" ); tomwalters@0: frames = HeaderInt( header, "frames" ); tomwalters@0: framebytes = HeaderInt( header, "framebytes" ); tomwalters@0: tomwalters@0: tomwalters@0: if ( isstr( formatstr, "nap" ) ) { tomwalters@0: framebytes = frames*frameheight*sizeof(short) ; tomwalters@0: framewidth = frames ; tomwalters@0: if ( (frame = (short *)malloc( framebytes )) == (short *)0 ) { tomwalters@0: fprintf(stderr,"ftoa: malloc out of space\n"); tomwalters@0: exit(1); tomwalters@0: } tomwalters@0: while ( fread( frame,framebytes,1,fp ) ) { tomwalters@0: for ( x=0 ; x