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.42 by greg, Tue Jan 18 03:59:41 2005 UTC vs.
Revision 2.50 by greg, Thu May 14 20:51:02 2020 UTC

# Line 28 | Line 28 | static const char      RCSid[] = "$Id$";
28   #define averaging       (ourweigh != NULL)
29   #define blurring        (ourbpict != NULL)
30   #define usematrix       (hasmatrix & !averaging)
31 < #define zisnorm         ((!usematrix) | (ourview.type != VT_PER))
31 > #define zisnorm         (!usematrix | (ourview.type != VT_PER))
32  
33   #define MAXWT           1000.           /* maximum pixel weight (averaging) */
34  
# Line 134 | Line 134 | main(                  /* interpolate pictures */
134          char    *expcomp = NULL;
135          int     i, an, rval;
136  
137 +        SET_DEFAULT_BINARY();
138 +        SET_FILE_BINARY(stdout);
139 +
140          progname = argv[0];
141  
142          for (an = 1; an < argc && argv[an][0] == '-'; an++) {
# Line 358 | Line 361 | headline(                              /* process header string */
361          void    *p
362   )
363   {
364 <        char    fmt[32];
364 >        char    fmt[MAXFMTLEN];
365  
366          if (isheadid(s))
367                  return(0);
# Line 391 | Line 394 | nextview(                              /* get and set next view */
394   {
395          char    linebuf[256];
396          char    *err;
397 <        register int    i;
397 >        int     i;
398  
399          if (fp != NULL) {
400                  do                      /* get new view */
# Line 428 | Line 431 | nextview(                              /* get and set next view */
431   static void
432   compavgview(void)                               /* compute average view */
433   {
434 <        register int    i;
434 >        int     i;
435          double  f;
436  
437          if (nvavg < 2)
# Line 494 | Line 497 | addpicture(            /* add picture to output */
497          zin = (float *)malloc(scanlen(&tresolu)*sizeof(float));
498          if (zin == NULL)
499                  syserror(progname);
500 <        if ((zfd = open(zspec, O_RDONLY)) == -1) {
501 <                double  zvalue;
502 <                register int    x;
503 <                if (!isflt(zspec) || (zvalue = atof(zspec)) <= 0.0)
504 <                        syserror(zspec);
500 >        if (isflt(zspec)) {             /* depth is a constant? */
501 >                double  zvalue = atof(zspec);
502 >                int     x;
503 >                if (zvalue <= 0.0) {
504 >                        fprintf(stderr, "%s: illegal Z-value %s\n",
505 >                                        progname, zspec);
506 >                        exit(1);
507 >                }
508                  for (x = scanlen(&tresolu); x-- > 0; )
509                          zin[x] = zvalue;
510 <        }
510 >                zfd = -1;
511 >        } else if ((zfd = open_float_depth(zspec, (long)tresolu.xr*tresolu.yr)) < 0)
512 >                exit(1);
513                                          /* compute transferrable perimeter */
514          xlim = (struct bound *)malloc(numscans(&tresolu)*sizeof(struct bound));
515          if (xlim == NULL)
# Line 555 | Line 563 | addpicture(            /* add picture to output */
563  
564   static int
565   pixform(                /* compute view1 to view2 matrix */
566 <        register MAT4   xfmat,
567 <        register VIEW   *vw1,
568 <        register VIEW   *vw2
566 >        MAT4    xfmat,
567 >        VIEW    *vw1,
568 >        VIEW    *vw2
569   )
570   {
571 <        double  m4t[4][4];
571 >        MAT4    m4t;
572  
573          if ((vw1->type != VT_PER) & (vw1->type != VT_PAR))
574                  return(0);
# Line 609 | Line 617 | addscanline(   /* add scanline to output */
617          FVECT   pos;
618          struct position lastx, newpos;
619          double  wt;
620 <        register int    x;
620 >        int     x;
621  
622          lastx.z = 0;
623          for (x = xl->max; x >= xl->min; x--) {
# Line 647 | Line 655 | addpixel(              /* fill in pixel parallelogram */
655          int     l1, l2, c1, c2;                 /* side lengths and counters */
656          int     p1isy;                          /* p0p1 along y? */
657          int     x1, y1;                         /* p1 position */
658 <        register int    x, y;                   /* final position */
658 >        int     x, y;                   /* final position */
659  
660                                          /* compute vector p0p1 */
661          if (fillo&F_FORE && ABS(p1->z-p0->z) <= zt) {
# Line 714 | Line 722 | addpixel(              /* fill in pixel parallelogram */
722  
723   static double
724   movepixel(                              /* reposition image point */
725 <        register FVECT  pos
725 >        FVECT   pos
726   )
727   {
728          FVECT   pt, tdir, odir;
# Line 745 | Line 753 | movepixel(                             /* reposition image point */
753                  }
754                  pos[0] += .5 - ourview.hoff;
755                  pos[1] += .5 - ourview.voff;
756 +                if ((pos[0] < 0) | (pos[0] >= 1-FTINY) |
757 +                                (pos[1] < 0) | (pos[1] >= 1-FTINY))
758 +                        return(0);
759                  pos[2] -= ourview.vfore;
760          } else {
761                  if (viewray(pt, tdir, &theirview, pos[0], pos[1]) < -FTINY)
762                          return(0);
763 <                if ((!normdist) & (theirview.type == VT_PER))   /* adjust */
764 <                        pos[2] *= sqrt(1. + pos[0]*pos[0]*theirview.hn2
754 <                                        + pos[1]*pos[1]*theirview.vn2);
763 >                if (!normdist & (theirview.type == VT_PER))     /* adjust */
764 >                        pos[2] /= DOT(theirview.vdir, tdir);
765                  pt[0] += tdir[0]*pos[2];
766                  pt[1] += tdir[1]*pos[2];
767                  pt[2] += tdir[2]*pos[2];
768 <                viewloc(pos, &ourview, pt);
759 <                if (pos[2] <= 0)
768 >                if (viewloc(pos, &ourview, pt) != VL_GOOD)
769                          return(0);
770          }
762        if ((pos[0] < 0) | (pos[0] >= 1-FTINY) | (pos[1] < 0) | (pos[1] >= 1-FTINY))
763                return(0);
771          if (!averaging)
772                  return(1);
773                                                  /* compute pixel weight */
# Line 780 | Line 787 | movepixel(                             /* reposition image point */
787  
788   static int
789   getperim(               /* compute overlapping image area */
790 <        register struct bound   *xl,
790 >        struct bound    *xl,
791          struct bound    *yl,
792          float   *zline,
793          int     zfd
# Line 788 | Line 795 | getperim(              /* compute overlapping image area */
795   {
796          int     step;
797          FVECT   pos;
798 <        register int    x, y;
798 >        int     x, y;
799                                                  /* set up step size */
800          if (scanlen(&tresolu) < numscans(&tresolu))
801                  step = scanlen(&tresolu)/NSTEPS;
# Line 872 | Line 879 | backpicture(                   /* background fill algorithm */
879   {
880          int     *yback, xback;
881          int     y;
882 <        register int    x, i;
882 >        int     x, i;
883                                                          /* get back buffer */
884          yback = (int *)malloc(hresolu*sizeof(int));
885          if (yback == NULL)
# Line 979 | Line 986 | fillpicture(           /* paint in empty pixels using fill */
986          fillfunc_t *fill
987   )
988   {
989 <        register int    x, y;
989 >        int     x, y;
990  
991          for (y = 0; y < vresolu; y++)
992                  for (x = 0; x < hresolu; x++)
# Line 993 | Line 1000 | fillpicture(           /* paint in empty pixels using fill */
1000   static int
1001   clipaft(void)                   /* perform aft clipping as indicated */
1002   {
1003 <        register int    x, y;
1003 >        int     x, y;
1004          int     adjtest = (ourview.type == VT_PER) & zisnorm;
1005          double  tstdist;
1006          double  yzn2, vx;
# Line 1032 | Line 1039 | addblur(void)                          /* add to blurred picture */
1039   {
1040          COLOR   cval;
1041          double  d;
1042 <        register int    i;
1042 >        int     i;
1043  
1044          if (!blurring)
1045                  return(0);
# Line 1072 | Line 1079 | static void
1079   writepicture(void)                              /* write out picture (alters buffer) */
1080   {
1081          int     y;
1082 <        register int    x;
1082 >        int     x;
1083          double  d;
1084  
1085          fprtresolu(hresolu, vresolu, stdout);
# Line 1115 | Line 1122 | writedistance(                 /* write out z file (alters buffer) *
1122          for (y = vresolu-1; y >= 0; y--) {
1123                  if (donorm) {
1124                          double  vx, yzn2, d;
1125 <                        register int    x;
1125 >                        int     x;
1126                          yzn2 = (y+.5)/vresolu + ourview.voff - .5;
1127                          yzn2 = 1. + yzn2*yzn2*ourview.vn2;
1128                          for (x = 0; x < hresolu; x++) {
# Line 1159 | Line 1166 | calstart(                    /* start fill calculation
1166          char    combuf[512];
1167          char    *argv[64];
1168          int     rval;
1169 <        register char   **wp, *cp;
1169 >        char    **wp, *cp;
1170  
1171 <        if (PDesc.running) {
1171 >        if (PDesc.flags & PF_RUNNING) {
1172                  fprintf(stderr, "%s: too many calculations\n", progname);
1173                  exit(1);
1174          }
# Line 1196 | Line 1203 | calstart(                    /* start fill calculation
1203   static void
1204   caldone(void)                               /* done with calculation */
1205   {
1206 <        if (!PDesc.running)
1206 >        if (!(PDesc.flags & PF_RUNNING))
1207                  return;
1208          clearqueue();
1209          close_process(&PDesc);
# Line 1223 | Line 1230 | clearqueue(void)                               /* process queue */
1230   {
1231          FVECT   orig, dir;
1232          float   fbuf[6*(PACKSIZ+1)];
1233 <        register float  *fbp;
1234 <        register int    i;
1233 >        float   *fbp;
1234 >        int     i;
1235          double  vx, vy;
1236  
1237          if (queuesiz == 0)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines