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.7 by greg, Fri Jun 19 12:54:41 1992 UTC vs.
Revision 2.10 by greg, Thu Apr 1 11:21:18 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 12 | Line 12 | static char SCCSid[] = "$SunId$ LBL";
12  
13   #include "standard.h"
14  
15 #include <fcntl.h>
16
15   #include <ctype.h>
16  
17   #include "view.h"
# Line 22 | Line 20 | static char SCCSid[] = "$SunId$ LBL";
20  
21   #include "resolu.h"
22  
25 #ifndef BSD
26 #define vfork           fork
27 #endif
28
23   #define pscan(y)        (ourpict+(y)*hresolu)
24   #define zscan(y)        (ourzbuf+(y)*hresolu)
25  
# Line 171 | 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);
177 <                        } 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 202 | 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 276 | 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);
281 <                exit(1);
282 <        }
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 305 | 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);
304 >                if (!isfloat(zspec) || (zvalue = atof(zspec)) <= 0.0)
305 >                        syserror(zspec);
306                          exit(1);
316                }
307                  for (x = scanlen(&tresolu); x-- > 0; )
308                          zin[x] = zvalue;
309          }
# Line 388 | Line 378 | COLR   *pline;
378   float   *zline;
379   struct position *lasty;         /* input/output */
380   {
391        extern double   sqrt();
381          FVECT   pos;
382          struct position lastx, newpos;
383          register int    x;
# Line 525 | Line 514 | int    samp;
514                                                          /* get back buffer */
515          yback = (int *)malloc(hresolu*sizeof(int));
516          if (yback == NULL)
517 <                syserror();
517 >                syserror(progname);
518          for (x = 0; x < hresolu; x++)
519                  yback[x] = -2;
520          /*
# Line 629 | Line 618 | writepicture()                         /* write out picture */
618          fprtresolu(hresolu, vresolu, stdout);
619          for (y = vresolu-1; y >= 0; y--)
620                  if (fwritecolrs(pscan(y), hresolu, stdout) < 0)
621 <                        syserror();
621 >                        syserror(progname);
622   }
623  
624  
625   writedistance(fname)                    /* write out z file */
626   char    *fname;
627   {
639        extern double   sqrt();
628          int     donorm = normdist && ourview.type == VT_PER;
629          int     fd;
630          int     y;
631          float   *zout;
632  
633 <        if ((fd = open(fname, O_WRONLY|O_CREAT|O_TRUNC, 0666)) == -1) {
634 <                perror(fname);
647 <                exit(1);
648 <        }
633 >        if ((fd = open(fname, O_WRONLY|O_CREAT|O_TRUNC, 0666)) == -1)
634 >                syserror(fname);
635          if (donorm
636          && (zout = (float *)malloc(hresolu*sizeof(float))) == NULL)
637 <                syserror();
637 >                syserror(progname);
638          for (y = vresolu-1; y >= 0; y--) {
639                  if (donorm) {
640                          double  vx, yzn2;
# Line 663 | Line 649 | char   *fname;
649                  } else
650                          zout = zscan(y);
651                  if (write(fd, (char *)zout, hresolu*sizeof(float))
652 <                                < hresolu*sizeof(float)) {
653 <                        perror(fname);
668 <                        exit(1);
669 <                }
652 >                                < hresolu*sizeof(float))
653 >                        syserror(fname);
654          }
655          if (donorm)
656                  free((char *)zout);
# Line 723 | Line 707 | done:
707          *wp = NULL;
708                                                  /* start process */
709          if ((rval = open_process(PDesc, argv)) < 0)
710 <                syserror();
710 >                syserror(progname);
711          if (rval == 0) {
712                  fprintf(stderr, "%s: command not found\n", argv[0]);
713                  exit(1);
# Line 764 | Line 748 | clearqueue()                           /* process queue */
748          register float  *fbp;
749          register int    i;
750  
751 +        if (queuesiz == 0)
752 +                return;
753          fbp = fbuf;
754          for (i = 0; i < queuesiz; i++) {
755                  viewray(orig, dir, &ourview,
# Line 797 | Line 783 | clearqueue()                           /* process queue */
783   }
784  
785  
786 < syserror()                      /* report error and exit */
786 > syserror(s)                     /* report error and exit */
787 > char    *s;
788   {
789 <        perror(progname);
789 >        perror(s);
790          exit(1);
791   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines