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.3 by greg, Mon Mar 23 16:50:26 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 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 34 | Line 28 | static char SCCSid[] = "$SunId$ LBL";
28  
29   #define PACKSIZ         256             /* max. calculation packet size */
30  
31 < #define RTCOM           "rtrace -h- -ovl -fff"
31 > #define RTCOM           "rtrace -h- -ovl -fff "
32  
33   #define ABS(x)          ((x)>0?(x):-(x))
34  
# 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);
318 <                        exit(1);
319 <                }
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 391 | Line 377 | COLR   *pline;
377   float   *zline;
378   struct position *lasty;         /* input/output */
379   {
394        extern double   sqrt();
380          FVECT   pos;
381          struct position lastx, newpos;
382          register int    x;
# Line 528 | 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 632 | 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   {
642        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);
650 <                exit(1);
651 <        }
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 666 | 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);
671 <                        exit(1);
672 <                }
651 >                                < hresolu*sizeof(float))
652 >                        syserror(fname);
653          }
654          if (donorm)
655                  free((char *)zout);
# Line 715 | 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          }
725 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 767 | 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 800 | 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