| 1 | < | /* Copyright (c) 1995 Regents of the University of California */ | 
| 1 | > | /* Copyright (c) 1999 Silicon Graphics, Inc. */ | 
| 2 |  |  | 
| 3 |  | #ifndef lint | 
| 4 | < | static char SCCSid[] = "$SunId$ LBL"; | 
| 4 | > | static char SCCSid[] = "$SunId$ SGI"; | 
| 5 |  | #endif | 
| 6 |  |  | 
| 7 |  | /* | 
| 39 |  |  | 
| 40 |  | #define PACKSIZ         256             /* max. calculation packet size */ | 
| 41 |  |  | 
| 42 | < | #define RTCOM           "rtrace -h- -ovl -fff " | 
| 42 | > | #define RTCOM           "rtrace -h- -ovl -fff -ld- -i- -I- " | 
| 43 |  |  | 
| 44 |  | #define ABS(x)          ((x)>0?(x):-(x)) | 
| 45 |  |  | 
| 61 |  | COLOR   *ourspict;                      /* output pixel sums (averaging) */ | 
| 62 |  | float   *ourweigh = NULL;               /* output pixel weights (averaging) */ | 
| 63 |  | float   *ourzbuf;                       /* corresponding z-buffer */ | 
| 64 | < | COLOR   *ourbpict = NULL;               /* blurred picture */ | 
| 64 | > | COLOR   *ourbpict = NULL;               /* blurred picture (view averaging) */ | 
| 65 |  |  | 
| 66 |  | VIEW    avgview;                        /* average view for -B option */ | 
| 67 |  | int     nvavg;                          /* number of views averaged */ | 
| 76 |  | COLOR   backcolor = BLKCOLOR;           /* background color (float) */ | 
| 77 |  | double  backz = 0.0;                    /* background z value */ | 
| 78 |  | int     normdist = 1;                   /* i/o normalized distance? */ | 
| 79 | + | char    ourfmt[LPICFMT+1] = PICFMT;     /* original picture format */ | 
| 80 |  | double  ourexp = -1;                    /* original picture exposure */ | 
| 81 |  | int     expadj = 0;                     /* exposure adjustment (f-stops) */ | 
| 82 |  | double  rexpadj = 1;                    /* real exposure adjustment */ | 
| 93 |  | #define childpid        (PDesc[2]) | 
| 94 |  | unsigned short  queue[PACKSIZ][2];      /* pending pixels */ | 
| 95 |  | int     packsiz;                        /* actual packet size */ | 
| 96 | < | int     queuesiz;                       /* number of pixels pending */ | 
| 96 | > | int     queuesiz = 0;                   /* number of pixels pending */ | 
| 97 |  |  | 
| 98 |  | extern double   movepixel(); | 
| 99 |  |  | 
| 252 |  | rexpadj = pow(2.0, (double)expadj); | 
| 253 |  | } | 
| 254 |  | /* set view */ | 
| 255 | < | if (nextview(doblur ? stdin : NULL) == EOF) { | 
| 255 | > | if (nextview(doblur ? stdin : (FILE *)NULL) == EOF) { | 
| 256 |  | fprintf(stderr, "%s: no view on standard input!\n", | 
| 257 |  | progname); | 
| 258 |  | exit(1); | 
| 309 |  | ourexp = rexpadj; | 
| 310 |  | if (ourexp < .995 | ourexp > 1.005) | 
| 311 |  | fputexpos(ourexp, stdout); | 
| 312 | < | fputformat(COLRFMT, stdout); | 
| 312 | > | if (strcmp(ourfmt, PICFMT))             /* print format if known */ | 
| 313 | > | fputformat(ourfmt, stdout); | 
| 314 |  | putc('\n', stdout); | 
| 315 |  | /* write picture */ | 
| 316 |  | writepicture(); | 
| 328 |  | } | 
| 329 |  |  | 
| 330 |  |  | 
| 331 | + | int | 
| 332 |  | headline(s)                             /* process header string */ | 
| 333 |  | char    *s; | 
| 334 |  | { | 
| 335 |  | char    fmt[32]; | 
| 336 |  |  | 
| 337 |  | if (isheadid(s)) | 
| 338 | < | return; | 
| 338 | > | return(0); | 
| 339 |  | if (formatval(fmt, s)) { | 
| 340 | < | wrongformat = strcmp(fmt, COLRFMT); | 
| 341 | < | return; | 
| 340 | > | if (globmatch(ourfmt, fmt)) { | 
| 341 | > | wrongformat = 0; | 
| 342 | > | strcpy(ourfmt, fmt); | 
| 343 | > | } else | 
| 344 | > | wrongformat = 1; | 
| 345 | > | return(0); | 
| 346 |  | } | 
| 347 |  | if (nvavg < 2) { | 
| 348 |  | putc('\t', stdout); | 
| 350 |  | } | 
| 351 |  | if (isexpos(s)) { | 
| 352 |  | theirexp *= exposval(s); | 
| 353 | < | return; | 
| 353 | > | return(0); | 
| 354 |  | } | 
| 355 |  | if (isview(s) && sscanview(&theirview, s) > 0) | 
| 356 |  | gotview++; | 
| 357 | + | return(0); | 
| 358 |  | } | 
| 359 |  |  | 
| 360 |  |  | 
| 524 |  | { | 
| 525 |  | double  m4t[4][4]; | 
| 526 |  |  | 
| 527 | < | if (vw1->type != VT_PER && vw1->type != VT_PAR) | 
| 527 | > | if (vw1->type != VT_PER & vw1->type != VT_PAR) | 
| 528 |  | return(0); | 
| 529 | < | if (vw2->type != VT_PER && vw2->type != VT_PAR) | 
| 529 | > | if (vw2->type != VT_PER & vw2->type != VT_PAR) | 
| 530 |  | return(0); | 
| 531 |  | setident4(xfmat); | 
| 532 |  | xfmat[0][0] = vw1->hvec[0]; | 
| 643 |  | y1 = p0->y + c1*s1y/l1; | 
| 644 |  | for (c2 = l2; c2-- > 0; ) { | 
| 645 |  | x = x1 + c2*s2x/l2; | 
| 646 | < | if (x < 0 || x >= hresolu) | 
| 646 | > | if (x < 0 | x >= hresolu) | 
| 647 |  | continue; | 
| 648 |  | y = y1 + c2*s2y/l2; | 
| 649 | < | if (y < 0 || y >= vresolu) | 
| 649 | > | if (y < 0 | y >= vresolu) | 
| 650 |  | continue; | 
| 651 |  | if (averaging) { | 
| 652 |  | if (zscan(y)[x] <= 0 || zscan(y)[x]-z | 
| 674 |  | { | 
| 675 |  | FVECT   pt, tdir, odir; | 
| 676 |  | double  d; | 
| 669 | – | register int    i; | 
| 677 |  |  | 
| 678 |  | if (pos[2] <= 0)                /* empty pixel */ | 
| 679 |  | return(0); | 
| 680 |  | if (usematrix) { | 
| 681 |  | pos[0] += theirview.hoff - .5; | 
| 682 |  | pos[1] += theirview.voff - .5; | 
| 683 | < | if (normdist && theirview.type == VT_PER) | 
| 683 | > | if (normdist & theirview.type == VT_PER) | 
| 684 |  | d = sqrt(1. + pos[0]*pos[0]*theirview.hn2 | 
| 685 |  | + pos[1]*pos[1]*theirview.vn2); | 
| 686 |  | else | 
| 714 |  | if (pos[2] <= 0) | 
| 715 |  | return(0); | 
| 716 |  | } | 
| 717 | < | if (pos[0] < 0 || pos[0] >= 1-FTINY || pos[1] < 0 || pos[1] >= 1-FTINY) | 
| 717 | > | if (pos[0] < 0 | pos[0] >= 1-FTINY | pos[1] < 0 | pos[1] >= 1-FTINY) | 
| 718 |  | return(0); | 
| 719 |  | if (!averaging) | 
| 720 |  | return(1); | 
| 721 | < | if (ourview.type == VT_PAR)             /* compute our direction */ | 
| 722 | < | VCOPY(odir, ourview.vdir); | 
| 723 | < | else | 
| 724 | < | for (i = 0; i < 3; i++) | 
| 725 | < | odir[i] = (pt[i] - ourview.vp[i])/pos[2]; | 
| 726 | < | d = DOT(odir,tdir);                     /* compute pixel weight */ | 
| 727 | < | if (d >= 1.-1./MAXWT/MAXWT) | 
| 721 | > | /* compute pixel weight */ | 
| 722 | > | if (ourview.type == VT_PAR) { | 
| 723 | > | d = DOT(ourview.vdir,tdir); | 
| 724 | > | d = 1. - d*d; | 
| 725 | > | } else { | 
| 726 | > | VSUB(odir, pt, ourview.vp); | 
| 727 | > | d = DOT(odir,tdir); | 
| 728 | > | d = 1. - d*d/DOT(odir,odir); | 
| 729 | > | } | 
| 730 | > | if (d <= 1./MAXWT/MAXWT) | 
| 731 |  | return(MAXWT);          /* clip to maximum weight */ | 
| 732 | < | return(1./sqrt(1.-d)); | 
| 732 | > | return(1./sqrt(d)); | 
| 733 |  | } | 
| 734 |  |  | 
| 735 |  |  | 
| 934 |  | for (x = 0; x < hresolu; x++) | 
| 935 |  | if (zscan(y)[x] <= 0) | 
| 936 |  | (*fill)(x,y); | 
| 937 | + | if (fill == rcalfill) | 
| 938 | + | clearqueue(); | 
| 939 |  | } | 
| 940 |  |  | 
| 941 |  |  | 
| 1173 |  | } | 
| 1174 |  | /* mark end and get results */ | 
| 1175 |  | bzero((char *)fbp, 6*sizeof(float)); | 
| 1176 | < | if (process(PDesc, fbuf, fbuf, 4*sizeof(float)*queuesiz, | 
| 1176 | > | if (process(PDesc, fbuf, fbuf, 4*sizeof(float)*(queuesiz+1), | 
| 1177 |  | 6*sizeof(float)*(queuesiz+1)) != | 
| 1178 | < | 4*sizeof(float)*queuesiz) { | 
| 1178 | > | 4*sizeof(float)*(queuesiz+1)) { | 
| 1179 |  | fprintf(stderr, "%s: error reading from rtrace process\n", | 
| 1180 |  | progname); | 
| 1181 |  | exit(1); |