ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/px/pinterp.c
(Generate patch)

Comparing ray/src/px/pinterp.c (file contents):
Revision 2.10 by greg, Thu Apr 1 11:21:18 1993 UTC vs.
Revision 2.15 by greg, Thu Dec 22 19:11:01 1994 UTC

# Line 1 | Line 1
1 < /* Copyright (c) 1993 Regents of the University of California */
1 > /* Copyright (c) 1994 Regents of the University of California */
2  
3   #ifndef lint
4   static char SCCSid[] = "$SunId$ LBL";
# Line 186 | Line 186 | char   *argv[];
186          if (fillsamp == 1)
187                  fillo &= ~F_BACK;
188                                                  /* set view */
189 <        if (err = setview(&ourview)) {
189 >        if ((err = setview(&ourview)) != NULL) {
190                  fprintf(stderr, "%s: %s\n", progname, err);
191                  exit(1);
192          }
# Line 197 | Line 197 | char   *argv[];
197          if (ourpict == NULL || ourzbuf == NULL)
198                  syserror(progname);
199          bzero((char *)ourzbuf, hresolu*vresolu*sizeof(float));
200 +                                                        /* new header */
201 +        newheader("RADIANCE", stdout);
202                                                          /* get input */
203          for ( ; i < argc; i += 2)
204                  addpicture(argv[i], argv[i+1]);
# Line 207 | Line 209 | char   *argv[];
209                  fillpicture(fillfunc);
210                                                          /* close calculation */
211          caldone();
212 +                                                        /* aft clipping */
213 +        clipaft();
214                                                          /* add to header */
215          printargs(argc, argv, stdout);
216          if (gotvfile) {
# Line 241 | Line 245 | char   *s;
245   {
246          char    fmt[32];
247  
248 <        if (isformat(s)) {
249 <                formatval(fmt, s);
248 >        if (isheadid(s))
249 >                return;
250 >        if (formatval(fmt, s)) {
251                  wrongformat = strcmp(fmt, COLRFMT);
252                  return;
253          }
# Line 303 | Line 308 | char   *pfile, *zspec;
308                  register int    x;
309                  if (!isfloat(zspec) || (zvalue = atof(zspec)) <= 0.0)
310                          syserror(zspec);
306                        exit(1);
311                  for (x = scanlen(&tresolu); x-- > 0; )
312                          zin[x] = zvalue;
313          }
# Line 466 | Line 470 | double z;
470   movepixel(pos)                          /* reposition image point */
471   FVECT   pos;
472   {
473 +        double  d0, d1;
474          FVECT   pt, direc;
475          
476          if (pos[2] <= 0)                /* empty pixel */
477                  return(-1);
478 +        if (normdist && theirview.type == VT_PER) {     /* adjust distance */
479 +                d0 = pos[0] + theirview.hoff - .5;
480 +                d1 = pos[1] + theirview.voff - .5;
481 +                pos[2] /= sqrt(1. + d0*d0*theirview.hn2 + d1*d1*theirview.vn2);
482 +        }
483          if (hasmatrix) {
484                  pos[0] += theirview.hoff - .5;
485                  pos[1] += theirview.voff - .5;
486                  if (theirview.type == VT_PER) {
477                        if (normdist)   /* adjust for eye-ray distance */
478                                pos[2] /= sqrt( 1.
479                                        + pos[0]*pos[0]*theirview.hn2
480                                        + pos[1]*pos[1]*theirview.vn2 );
487                          pos[0] *= pos[2];
488                          pos[1] *= pos[2];
489                  }
# Line 492 | Line 498 | FVECT  pos;
498                  pos[1] += .5 - ourview.voff;
499                  return(0);
500          }
501 <        if (viewray(pt, direc, &theirview, pos[0], pos[1]) < 0)
501 >        if (viewray(pt, direc, &theirview, pos[0], pos[1]) < -FTINY)
502                  return(-1);
503          pt[0] += direc[0]*pos[2];
504          pt[1] += direc[1]*pos[2];
# Line 611 | Line 617 | int    (*fill)();
617   }
618  
619  
620 + clipaft()                       /* perform aft clipping as indicated */
621 + {
622 +        register int    x, y;
623 +        double  tstdist;
624 +        double  yzn2, vx;
625 +
626 +        if (ourview.vaft <= FTINY)
627 +                return;
628 +        tstdist = ourview.vaft;
629 +        for (y = 0; y < vresolu; y++) {
630 +                if (ourview.type == VT_PER) {           /* adjust distance */
631 +                        yzn2 = (y+.5)/vresolu + ourview.voff - .5;
632 +                        yzn2 = 1. + yzn2*yzn2*ourview.vn2;
633 +                        tstdist = ourview.vaft * sqrt(yzn2);
634 +                }
635 +                for (x = 0; x < hresolu; x++)
636 +                        if (zscan(y)[x] > tstdist) {
637 +                                if (ourview.type == VT_PER) {
638 +                                        vx = (x+.5)/hresolu + ourview.hoff - .5;
639 +                                        if (zscan(y)[x] <= ourview.vaft *
640 +                                                sqrt(vx*vx*ourview.hn2 + yzn2))
641 +                                                continue;
642 +                                }
643 +                                bzero(pscan(y)[x], sizeof(COLR));
644 +                                zscan(y)[x] = 0.0;
645 +                        }
646 +        }
647 + }
648 +
649 +
650   writepicture()                          /* write out picture */
651   {
652          int     y;
# Line 696 | Line 732 | char   *prog, *args;
732          cp = combuf;
733          wp = argv;
734          for ( ; ; ) {
735 <                while (isspace(*cp)) cp++;
736 <                if (!*cp) break;
737 <                *wp++ = cp;
738 <                while (!isspace(*cp))
739 <                        if (!*cp++) goto done;
740 <                *cp++ = '\0';
735 >                while (isspace(*cp))    /* nullify spaces */
736 >                        *cp++ = '\0';
737 >                if (!*cp)               /* all done? */
738 >                        break;
739 >                *wp++ = cp;             /* add argument to list */
740 >                while (*++cp && !isspace(*cp))
741 >                        ;
742          }
706 done:
743          *wp = NULL;
744                                                  /* start process */
745          if ((rval = open_process(PDesc, argv)) < 0)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines