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.8 by greg, Thu Sep 24 21:33:52 1992 UTC vs.
Revision 2.12 by greg, Mon Apr 12 09:58:09 1993 UTC

# Line 1 | Line 1
1 < /* Copyright (c) 1991 Regents of the University of California */
1 > /* Copyright (c) 1993 Regents of the University of California */
2  
3   #ifndef lint
4   static char SCCSid[] = "$SunId$ LBL";
# Line 20 | Line 20 | static char SCCSid[] = "$SunId$ LBL";
20  
21   #include "resolu.h"
22  
23 #ifndef BSD
24 #define vfork           fork
25 #endif
26
23   #define pscan(y)        (ourpict+(y)*hresolu)
24   #define zscan(y)        (ourzbuf+(y)*hresolu)
25  
# Line 169 | Line 165 | char   *argv[];
165                                  goto badopt;
166                          check(3,"s");
167                          gotvfile = viewfile(argv[++i], &ourview, 0, 0);
168 <                        if (gotvfile < 0) {
169 <                                perror(argv[i]);
170 <                                exit(1);
175 <                        } else if (gotvfile == 0) {
168 >                        if (gotvfile < 0)
169 >                                syserror(argv[i]);
170 >                        else if (gotvfile == 0) {
171                                  fprintf(stderr, "%s: bad view file\n",
172                                                  argv[i]);
173                                  exit(1);
# Line 200 | Line 195 | char   *argv[];
195          ourpict = (COLR *)bmalloc(hresolu*vresolu*sizeof(COLR));
196          ourzbuf = (float *)bmalloc(hresolu*vresolu*sizeof(float));
197          if (ourpict == NULL || ourzbuf == NULL)
198 <                syserror();
198 >                syserror(progname);
199          bzero((char *)ourzbuf, hresolu*vresolu*sizeof(float));
200                                                          /* get input */
201          for ( ; i < argc; i += 2)
# Line 274 | Line 269 | char   *pfile, *zspec;
269          struct position *plast;
270          int     y;
271                                          /* open picture file */
272 <        if ((pfp = fopen(pfile, "r")) == NULL) {
273 <                perror(pfile);
279 <                exit(1);
280 <        }
272 >        if ((pfp = fopen(pfile, "r")) == NULL)
273 >                syserror(pfile);
274                                          /* get header with exposure and view */
275          theirexp = 1.0;
276          gotview = 0;
# Line 303 | Line 296 | char   *pfile, *zspec;
296          plast = (struct position *)calloc(scanlen(&tresolu),
297                          sizeof(struct position));
298          if (scanin == NULL || zin == NULL || plast == NULL)
299 <                syserror();
299 >                syserror(progname);
300                                          /* get z specification or file */
301          if ((zfd = open(zspec, O_RDONLY)) == -1) {
302                  double  zvalue;
303                  register int    x;
304 <                if (!isfloat(zspec) || (zvalue = atof(zspec)) <= 0.0) {
305 <                        perror(zspec);
313 <                        exit(1);
314 <                }
304 >                if (!isfloat(zspec) || (zvalue = atof(zspec)) <= 0.0)
305 >                        syserror(zspec);
306                  for (x = scanlen(&tresolu); x-- > 0; )
307                          zin[x] = zvalue;
308          }
# Line 386 | Line 377 | COLR   *pline;
377   float   *zline;
378   struct position *lasty;         /* input/output */
379   {
389        extern double   sqrt();
380          FVECT   pos;
381          struct position lastx, newpos;
382          register int    x;
# Line 523 | Line 513 | int    samp;
513                                                          /* get back buffer */
514          yback = (int *)malloc(hresolu*sizeof(int));
515          if (yback == NULL)
516 <                syserror();
516 >                syserror(progname);
517          for (x = 0; x < hresolu; x++)
518                  yback[x] = -2;
519          /*
# Line 627 | Line 617 | writepicture()                         /* write out picture */
617          fprtresolu(hresolu, vresolu, stdout);
618          for (y = vresolu-1; y >= 0; y--)
619                  if (fwritecolrs(pscan(y), hresolu, stdout) < 0)
620 <                        syserror();
620 >                        syserror(progname);
621   }
622  
623  
624   writedistance(fname)                    /* write out z file */
625   char    *fname;
626   {
637        extern double   sqrt();
627          int     donorm = normdist && ourview.type == VT_PER;
628          int     fd;
629          int     y;
630          float   *zout;
631  
632 <        if ((fd = open(fname, O_WRONLY|O_CREAT|O_TRUNC, 0666)) == -1) {
633 <                perror(fname);
645 <                exit(1);
646 <        }
632 >        if ((fd = open(fname, O_WRONLY|O_CREAT|O_TRUNC, 0666)) == -1)
633 >                syserror(fname);
634          if (donorm
635          && (zout = (float *)malloc(hresolu*sizeof(float))) == NULL)
636 <                syserror();
636 >                syserror(progname);
637          for (y = vresolu-1; y >= 0; y--) {
638                  if (donorm) {
639                          double  vx, yzn2;
# Line 661 | Line 648 | char   *fname;
648                  } else
649                          zout = zscan(y);
650                  if (write(fd, (char *)zout, hresolu*sizeof(float))
651 <                                < hresolu*sizeof(float)) {
652 <                        perror(fname);
666 <                        exit(1);
667 <                }
651 >                                < hresolu*sizeof(float))
652 >                        syserror(fname);
653          }
654          if (donorm)
655                  free((char *)zout);
# Line 710 | Line 695 | char   *prog, *args;
695          cp = combuf;
696          wp = argv;
697          for ( ; ; ) {
698 <                while (isspace(*cp)) cp++;
699 <                if (!*cp) break;
700 <                *wp++ = cp;
701 <                while (!isspace(*cp))
702 <                        if (!*cp++) goto done;
703 <                *cp++ = '\0';
698 >                while (isspace(*cp))    /* nullify spaces */
699 >                        *cp++ = '\0';
700 >                if (!*cp)               /* all done? */
701 >                        break;
702 >                *wp++ = cp;             /* add argument to list */
703 >                while (*++cp && !isspace(*cp))
704 >                        ;
705          }
720 done:
706          *wp = NULL;
707                                                  /* start process */
708          if ((rval = open_process(PDesc, argv)) < 0)
709 <                syserror();
709 >                syserror(progname);
710          if (rval == 0) {
711                  fprintf(stderr, "%s: command not found\n", argv[0]);
712                  exit(1);
# Line 762 | Line 747 | clearqueue()                           /* process queue */
747          register float  *fbp;
748          register int    i;
749  
750 +        if (queuesiz == 0)
751 +                return;
752          fbp = fbuf;
753          for (i = 0; i < queuesiz; i++) {
754                  viewray(orig, dir, &ourview,
# Line 795 | Line 782 | clearqueue()                           /* process queue */
782   }
783  
784  
785 < syserror()                      /* report error and exit */
785 > syserror(s)                     /* report error and exit */
786 > char    *s;
787   {
788 <        perror(progname);
788 >        perror(s);
789          exit(1);
790   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines