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.4 by greg, Thu Mar 26 13:03:34 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 161 | Line 155 | char   *argv[];
155                          vresolu = atoi(argv[++i]);
156                          break;
157                  case 'p':                               /* pixel aspect */
158 <                        check(2,"f");
158 >                        if (argv[i][2] != 'a')
159 >                                goto badopt;
160 >                        check(3,"f");
161                          pixaspect = atof(argv[++i]);
162                          break;
163                  case 'v':                               /* view file */
# 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 197 | Line 192 | char   *argv[];
192          }
193          normaspect(viewaspect(&ourview), &pixaspect, &hresolu, &vresolu);
194                                                  /* allocate frame */
195 <        ourpict = (COLR *)malloc(hresolu*vresolu*sizeof(COLR));
196 <        ourzbuf = (float *)calloc(hresolu*vresolu,sizeof(float));
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)
202                  addpicture(argv[i], argv[i+1]);
# Line 243 | Line 239 | userr:
239   headline(s)                             /* process header string */
240   char    *s;
241   {
246        static char     *altname[] = {VIEWSTR,"rpict","rview","pinterp",NULL};
247        register char   **an;
242          char    fmt[32];
243  
244          if (isformat(s)) {
# Line 259 | Line 253 | char   *s;
253                  theirexp *= exposval(s);
254                  return;
255          }
256 <        for (an = altname; *an != NULL; an++)
257 <                if (!strncmp(*an, s, strlen(*an))) {
264 <                        if (sscanview(&theirview, s+strlen(*an)) > 0)
265 <                                gotview++;
266 <                        break;
267 <                }
256 >        if (isview(s) && sscanview(&theirview, s) > 0)
257 >                gotview++;
258   }
259  
260  
# Line 279 | 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);
284 <                exit(1);
285 <        }
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 308 | 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);
319                }
307                  for (x = scanlen(&tresolu); x-- > 0; )
308                          zin[x] = zvalue;
309          }
# Line 391 | Line 378 | COLR   *pline;
378   float   *zline;
379   struct position *lasty;         /* input/output */
380   {
394        extern double   sqrt();
381          FVECT   pos;
382          struct position lastx, newpos;
383          register int    x;
# Line 528 | 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 632 | 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   {
642        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);
650 <                exit(1);
651 <        }
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 666 | 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);
671 <                        exit(1);
672 <                }
652 >                                < hresolu*sizeof(float))
653 >                        syserror(fname);
654          }
655          if (donorm)
656                  free((char *)zout);
# Line 726 | 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 767 | 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 800 | 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