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.27 by greg, Mon Oct 16 11:40:16 1995 UTC vs.
Revision 2.35 by schorsch, Mon Jun 30 14:59:12 2003 UTC

# Line 1 | Line 1
1 /* Copyright (c) 1995 Regents of the University of California */
2
1   #ifndef lint
2 < static char SCCSid[] = "$SunId$ LBL";
2 > static const char       RCSid[] = "$Id$";
3   #endif
6
4   /*
5   * Interpolate and extrapolate pictures with different view parameters.
6   *
7   *      Greg Ward       09Dec89
8   */
9  
10 < #include "standard.h"
10 > #include "copyright.h"
11  
12   #include <ctype.h>
13 + #include <string.h>
14  
15 + #include "standard.h"
16 + #include "rtprocess.h" /* Windows: must come before color.h */
17   #include "view.h"
18
18   #include "color.h"
19  
21 #include "resolu.h"
22
20   #define LOG2            0.69314718055994530942
21  
22   #define pscan(y)        (ourpict+(y)*hresolu)
# Line 39 | Line 36 | static char SCCSid[] = "$SunId$ LBL";
36  
37   #define PACKSIZ         256             /* max. calculation packet size */
38  
39 < #define RTCOM           "rtrace -h- -ovl -fff "
39 > #define RTCOM           "rtrace -h- -ovl -fff -ld- -i- -I- "
40  
41   #define ABS(x)          ((x)>0?(x):-(x))
42  
# Line 89 | Line 86 | double theirexp;                       /* input picture exposure */
86   MAT4    theirs2ours;                    /* transformation matrix */
87   int     hasmatrix = 0;                  /* has transformation matrix */
88  
89 < int     PDesc[3] = {-1,-1,-1};          /* rtrace process descriptor */
93 < #define childpid        (PDesc[2])
89 > static SUBPROC PDesc = SP_INACTIVE; /* rtrace process descriptor */
90   unsigned short  queue[PACKSIZ][2];      /* pending pixels */
91   int     packsiz;                        /* actual packet size */
92   int     queuesiz = 0;                   /* number of pixels pending */
# Line 213 | Line 209 | char   *argv[];
209                          if (argv[an][2] != 'f')
210                                  goto badopt;
211                          check(3,"s");
212 <                        gotvfile = viewfile(argv[++an], &ourview, 0, 0);
212 >                        gotvfile = viewfile(argv[++an], &ourview, NULL);
213                          if (gotvfile < 0)
214                                  syserror(argv[an]);
215                          else if (gotvfile == 0) {
# Line 252 | Line 248 | char   *argv[];
248                                  rexpadj = pow(2.0, (double)expadj);
249                  }
250                                                  /* set view */
251 <        if (nextview(doblur ? stdin : NULL) == EOF) {
251 >        if (nextview(doblur ? stdin : (FILE *)NULL) == EOF) {
252                  fprintf(stderr, "%s: no view on standard input!\n",
253                                  progname);
254                  exit(1);
# Line 279 | Line 275 | char   *argv[];
275                  syserror(progname);
276                                                          /* new header */
277          newheader("RADIANCE", stdout);
278 +        fputnow(stdout);
279                                                          /* run pictures */
280          do {
281 <                bzero((char *)ourzbuf, hresolu*vresolu*sizeof(float));
281 >                memset((char *)ourzbuf, '\0', hresolu*vresolu*sizeof(float));
282                  for (i = an; i < argc; i += 2)
283                          addpicture(argv[i], argv[i+1]);
284                  if (fillo&F_BACK)                       /* fill in spaces */
# Line 328 | Line 325 | userr:
325   }
326  
327  
328 + int
329   headline(s)                             /* process header string */
330   char    *s;
331   {
332          char    fmt[32];
333  
334          if (isheadid(s))
335 <                return;
335 >                return(0);
336          if (formatval(fmt, s)) {
337                  if (globmatch(ourfmt, fmt)) {
338                          wrongformat = 0;
339                          strcpy(ourfmt, fmt);
340                  } else
341                          wrongformat = 1;
342 <                return;
342 >                return(0);
343          }
344          if (nvavg < 2) {
345                  putc('\t', stdout);
# Line 349 | Line 347 | char   *s;
347          }
348          if (isexpos(s)) {
349                  theirexp *= exposval(s);
350 <                return;
350 >                return(0);
351          }
352          if (isview(s) && sscanview(&theirview, s) > 0)
353                  gotview++;
354 +        return(0);
355   }
356  
357  
# Line 471 | Line 470 | char   *pfile, *zspec;
470          if (xlim == NULL)
471                  syserror(progname);
472          if (!getperim(xlim, &ylim, zin, zfd)) { /* overlapping area? */
473 <                free((char *)zin);
474 <                free((char *)xlim);
473 >                free((void *)zin);
474 >                free((void *)xlim);
475                  if (zfd != -1)
476                          close(zfd);
477                  fclose(pfp);
# Line 491 | Line 490 | char   *pfile, *zspec;
490                          exit(1);
491                  }
492          if (zfd != -1 && lseek(zfd,
493 <                        (long)ylim.min*scanlen(&tresolu)*sizeof(float), 0) < 0)
493 >                        (off_t)ylim.min*scanlen(&tresolu)*sizeof(float), 0) < 0)
494                  syserror(zspec);
495                                          /* load image */
496          for (y = ylim.min; y <= ylim.max; y++) {
# Line 506 | Line 505 | char   *pfile, *zspec;
505                  addscanline(xlim+y, y, scanin, zin, plast);
506          }
507                                          /* clean up */
508 <        free((char *)xlim);
509 <        free((char *)scanin);
510 <        free((char *)zin);
511 <        free((char *)plast);
508 >        free((void *)xlim);
509 >        free((void *)scanin);
510 >        free((void *)zin);
511 >        free((void *)plast);
512          fclose(pfp);
513          if (zfd != -1)
514                  close(zfd);
# Line 672 | Line 671 | register FVECT pos;
671   {
672          FVECT   pt, tdir, odir;
673          double  d;
675        register int    i;
674          
675          if (pos[2] <= 0)                /* empty pixel */
676                  return(0);
# Line 717 | Line 715 | register FVECT pos;
715                  return(0);
716          if (!averaging)
717                  return(1);
718 <        if (ourview.type == VT_PAR)             /* compute our direction */
719 <                VCOPY(odir, ourview.vdir);
720 <        else
721 <                for (i = 0; i < 3; i++)
722 <                        odir[i] = (pt[i] - ourview.vp[i])/pos[2];
723 <        d = DOT(odir,tdir);                     /* compute pixel weight */
724 <        if (d >= 1.-1./MAXWT/MAXWT)
718 >                                                /* compute pixel weight */
719 >        if (ourview.type == VT_PAR) {
720 >                d = DOT(ourview.vdir,tdir);
721 >                d = 1. - d*d;
722 >        } else {
723 >                VSUB(odir, pt, ourview.vp);
724 >                d = DOT(odir,tdir);
725 >                d = 1. - d*d/DOT(odir,odir);
726 >        }
727 >        if (d <= 1./MAXWT/MAXWT)
728                  return(MAXWT);          /* clip to maximum weight */
729 <        return(1./sqrt(1.-d));
729 >        return(1./sqrt(d));
730   }
731  
732  
# Line 756 | Line 757 | int    zfd;
757          yl->min = 32000; yl->max = 0;           /* search for points on image */
758          for (y = step - 1; y < numscans(&tresolu); y += step) {
759                  if (zfd != -1) {
760 <                        if (lseek(zfd, (long)y*scanlen(&tresolu)*sizeof(float),
760 >                        if (lseek(zfd, (off_t)y*scanlen(&tresolu)*sizeof(float),
761                                          0) < 0)
762                                  syserror("lseek");
763                          if (read(zfd, (char *)zline,
# Line 917 | Line 918 | int    samp;
918                                  xback = -2;
919                          }
920          }
921 <        free((char *)yback);
921 >        free((void *)yback);
922   }
923  
924  
# Line 961 | Line 962 | clipaft()                      /* perform aft clipping as indicated */
962                                                  continue;
963                                  }
964                                  if (averaging)
965 <                                        bzero(sscan(y)[x], sizeof(COLOR));
965 >                                        memset(sscan(y)[x], '\0', sizeof(COLOR));
966                                  else
967 <                                        bzero(pscan(y)[x], sizeof(COLR));
967 >                                        memset(pscan(y)[x], '\0', sizeof(COLR));
968                                  zscan(y)[x] = 0.0;
969                          }
970          }
# Line 1095 | Line 1096 | char   *prog, *args;
1096          int     rval;
1097          register char   **wp, *cp;
1098  
1099 <        if (childpid != -1) {
1099 >        if (PDesc.running) {
1100                  fprintf(stderr, "%s: too many calculations\n", progname);
1101                  exit(1);
1102          }
# Line 1114 | Line 1115 | char   *prog, *args;
1115          }
1116          *wp = NULL;
1117                                                  /* start process */
1118 <        if ((rval = open_process(PDesc, argv)) < 0)
1118 >        if ((rval = open_process(&PDesc, argv)) < 0)
1119                  syserror(progname);
1120          if (rval == 0) {
1121                  fprintf(stderr, "%s: command not found\n", argv[0]);
# Line 1129 | Line 1130 | char   *prog, *args;
1130  
1131   caldone()                               /* done with calculation */
1132   {
1133 <        if (childpid == -1)
1133 >        if (!PDesc.running)
1134                  return;
1135          clearqueue();
1136 <        close_process(PDesc);
1136 <        childpid = -1;
1136 >        close_process(&PDesc);
1137   }
1138  
1139  
# Line 1168 | Line 1168 | clearqueue()                           /* process queue */
1168                  *fbp++ = dir[0]; *fbp++ = dir[1]; *fbp++ = dir[2];
1169          }
1170                                          /* mark end and get results */
1171 <        bzero((char *)fbp, 6*sizeof(float));
1172 <        if (process(PDesc, fbuf, fbuf, 4*sizeof(float)*queuesiz,
1171 >        memset((char *)fbp, '\0', 6*sizeof(float));
1172 >        if (process(&PDesc, (char *)fbuf, (char *)fbuf,
1173 >                        4*sizeof(float)*(queuesiz+1),
1174                          6*sizeof(float)*(queuesiz+1)) !=
1175 <                        4*sizeof(float)*queuesiz) {
1175 >                        4*sizeof(float)*(queuesiz+1)) {
1176                  fprintf(stderr, "%s: error reading from rtrace process\n",
1177                                  progname);
1178                  exit(1);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines