Annotation of researchv10no/cmd/view2d/slice.c, revision 1.1.1.1

1.1       root        1: /*  convert from view2d to anim format by slicing in x or y  */
                      2: 
                      3: #include <stdio.h>
                      4: #include "view2d.h"
                      5: char *progname;
                      6: 
                      7: short timewarp;
                      8: double ts, te;
                      9: extern Rd2d rd;
                     10: int verbose;
                     11: 
                     12: typedef struct Frame {
                     13:   double time;
                     14:   short *p;
                     15: } Frame;
                     16: Frame frame;
                     17: Frame *here;
                     18: 
                     19: short nx, ny;  /* input grid */
                     20: 
                     21: main(argc, argv)
                     22:   int argc;
                     23:   char **argv;
                     24: {
                     25:   int i, j;
                     26:   int fd;
                     27:   int dir = -1;  /* 1=x, 0=y */
                     28:   double cut, atof();
                     29:   char *Malloc();
                     30: 
                     31:   timewarp = 0;
                     32:   verbose = 0;
                     33:   progname = argv[0];
                     34:   here = &frame;
                     35: 
                     36:   for(argc--, argv++; *argv; argv++){
                     37:     if(**argv == '-' ){
                     38:       switch(argv[0][1]) {
                     39:       case 'v':
                     40:         verbose++;
                     41:         break;
                     42:       case 'x':
                     43:         dir=1;
                     44:        cut=atof(&(argv[0][2]));
                     45:         break;
                     46:       case 'y':
                     47:         dir=0;
                     48:        cut=atof(&(argv[0][2]));
                     49:         break;
                     50:       }
                     51:     }else{
                     52:       if(fd) error("can only read one file");
                     53:       fd = Open(*argv,0);
                     54:     }
                     55:   }
                     56:   if(dir<0) error("must supply -x or -y cutpoint");
                     57: 
                     58:   rd2dh(fd,&nx,&ny);
                     59:   if((timewarp>0)&&(verbose))
                     60:      fprintf(stderr,"timewarp=%d ts=%g te=%g\n",timewarp,ts,te);
                     61:   i = nx*ny*sizeof(short);
                     62:   here->p = (short *)Malloc(i);
                     63: 
                     64:   while(rd2di(&here->time,here->p)){
                     65:     wrframe(here->time,here->p,dir,cut);
                     66:   }
                     67:   exit(0);
                     68: }
                     69: 
                     70: 
                     71: wrframe(t,p,dir,cut)
                     72:   double t;
                     73:   short *p;
                     74:   int dir;
                     75:   double cut;
                     76: {
                     77:   float *b;
                     78:   register short *q;
                     79:   int i, j, n, s;
                     80:   double t0, t1, v2, out, pow2();
                     81:   v2 = pow2(rd.v);
                     82:   out = (-BIG-rd.u)*v2;
                     83:   n = dir ? ny: nx;
                     84:   s = dir ? nx: 1;
                     85:   if(dir){ q = p +    (int)(cut*(nx-1));
                     86:     }else{ q = p + nx*(int)(cut*(ny-1));}
                     87:   if(verbose) fprintf(stderr,"time=%g\n",t,j);
                     88:   t0 = out;
                     89:   for(i=0; i<n; i++){
                     90:        t1 = (*q-rd.u)*v2;
                     91:        q += s;
                     92:        if((t1>out)&&(t0>out))
                     93:                printf("L%d: line %d %f %d %f\n",i-1,i-1,t0,i,t1);
                     94:        t0 = t1;
                     95:   }
                     96:   printf("click time\n");
                     97: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.