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.6 by greg, Tue May 26 15:23:09 1992 UTC vs.
Revision 2.13 by greg, Sun Feb 27 10:16:57 1994 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 199 | 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 >                                                        /* new header */
201 >        newheader("RADIANCE", stdout);
202                                                          /* get input */
203          for ( ; i < argc; i += 2)
204                  addpicture(argv[i], argv[i+1]);
# Line 247 | Line 243 | char   *s;
243   {
244          char    fmt[32];
245  
246 <        if (isformat(s)) {
247 <                formatval(fmt, s);
246 >        if (isheadid(s))
247 >                return;
248 >        if (formatval(fmt, s)) {
249                  wrongformat = strcmp(fmt, COLRFMT);
250                  return;
251          }
# Line 275 | Line 272 | char   *pfile, *zspec;
272          struct position *plast;
273          int     y;
274                                          /* open picture file */
275 <        if ((pfp = fopen(pfile, "r")) == NULL) {
276 <                perror(pfile);
280 <                exit(1);
281 <        }
275 >        if ((pfp = fopen(pfile, "r")) == NULL)
276 >                syserror(pfile);
277                                          /* get header with exposure and view */
278          theirexp = 1.0;
279          gotview = 0;
# Line 304 | Line 299 | char   *pfile, *zspec;
299          plast = (struct position *)calloc(scanlen(&tresolu),
300                          sizeof(struct position));
301          if (scanin == NULL || zin == NULL || plast == NULL)
302 <                syserror();
302 >                syserror(progname);
303                                          /* get z specification or file */
304          if ((zfd = open(zspec, O_RDONLY)) == -1) {
305                  double  zvalue;
306                  register int    x;
307 <                if (!isfloat(zspec) || (zvalue = atof(zspec)) <= 0.0) {
308 <                        perror(zspec);
314 <                        exit(1);
315 <                }
307 >                if (!isfloat(zspec) || (zvalue = atof(zspec)) <= 0.0)
308 >                        syserror(zspec);
309                  for (x = scanlen(&tresolu); x-- > 0; )
310                          zin[x] = zvalue;
311          }
# Line 387 | Line 380 | COLR   *pline;
380   float   *zline;
381   struct position *lasty;         /* input/output */
382   {
390        extern double   sqrt();
383          FVECT   pos;
384          struct position lastx, newpos;
385          register int    x;
# Line 524 | Line 516 | int    samp;
516                                                          /* get back buffer */
517          yback = (int *)malloc(hresolu*sizeof(int));
518          if (yback == NULL)
519 <                syserror();
519 >                syserror(progname);
520          for (x = 0; x < hresolu; x++)
521                  yback[x] = -2;
522          /*
# Line 628 | Line 620 | writepicture()                         /* write out picture */
620          fprtresolu(hresolu, vresolu, stdout);
621          for (y = vresolu-1; y >= 0; y--)
622                  if (fwritecolrs(pscan(y), hresolu, stdout) < 0)
623 <                        syserror();
623 >                        syserror(progname);
624   }
625  
626  
627   writedistance(fname)                    /* write out z file */
628   char    *fname;
629   {
638        extern double   sqrt();
630          int     donorm = normdist && ourview.type == VT_PER;
631          int     fd;
632          int     y;
633          float   *zout;
634  
635 <        if ((fd = open(fname, O_WRONLY|O_CREAT|O_TRUNC, 0666)) == -1) {
636 <                perror(fname);
646 <                exit(1);
647 <        }
635 >        if ((fd = open(fname, O_WRONLY|O_CREAT|O_TRUNC, 0666)) == -1)
636 >                syserror(fname);
637          if (donorm
638          && (zout = (float *)malloc(hresolu*sizeof(float))) == NULL)
639 <                syserror();
639 >                syserror(progname);
640          for (y = vresolu-1; y >= 0; y--) {
641                  if (donorm) {
642                          double  vx, yzn2;
# Line 662 | Line 651 | char   *fname;
651                  } else
652                          zout = zscan(y);
653                  if (write(fd, (char *)zout, hresolu*sizeof(float))
654 <                                < hresolu*sizeof(float)) {
655 <                        perror(fname);
667 <                        exit(1);
668 <                }
654 >                                < hresolu*sizeof(float))
655 >                        syserror(fname);
656          }
657          if (donorm)
658                  free((char *)zout);
# Line 711 | Line 698 | char   *prog, *args;
698          cp = combuf;
699          wp = argv;
700          for ( ; ; ) {
701 <                while (isspace(*cp)) cp++;
702 <                if (!*cp) break;
703 <                *wp++ = cp;
704 <                while (!isspace(*cp))
705 <                        if (!*cp++) goto done;
706 <                *cp++ = '\0';
701 >                while (isspace(*cp))    /* nullify spaces */
702 >                        *cp++ = '\0';
703 >                if (!*cp)               /* all done? */
704 >                        break;
705 >                *wp++ = cp;             /* add argument to list */
706 >                while (*++cp && !isspace(*cp))
707 >                        ;
708          }
721 done:
709          *wp = NULL;
710                                                  /* start process */
711          if ((rval = open_process(PDesc, argv)) < 0)
712 <                syserror();
712 >                syserror(progname);
713          if (rval == 0) {
714                  fprintf(stderr, "%s: command not found\n", argv[0]);
715                  exit(1);
# Line 763 | Line 750 | clearqueue()                           /* process queue */
750          register float  *fbp;
751          register int    i;
752  
753 +        if (queuesiz == 0)
754 +                return;
755          fbp = fbuf;
756          for (i = 0; i < queuesiz; i++) {
757                  viewray(orig, dir, &ourview,
# Line 796 | Line 785 | clearqueue()                           /* process queue */
785   }
786  
787  
788 < syserror()                      /* report error and exit */
788 > syserror(s)                     /* report error and exit */
789 > char    *s;
790   {
791 <        perror(progname);
791 >        perror(s);
792          exit(1);
793   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines