ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/util/glareval.c
(Generate patch)

Comparing ray/src/util/glareval.c (file contents):
Revision 1.1 by greg, Mon Mar 18 12:15:41 1991 UTC vs.
Revision 1.4 by greg, Wed Mar 20 13:20:06 1991 UTC

# Line 20 | Line 20 | static char SCCSid[] = "$SunId$ LBL";
20   #define vfork           fork
21   #endif
22  
23 < #define NSCANS          16              /* number of scanlines to buffer */
23 > #define NSCANS          64              /* number of scanlines to buffer */
24  
25   int     rt_pid = -1;            /* process id for rtrace */
26   int     fd_tort, fd_fromrt;     /* pipe descriptors */
# Line 36 | Line 36 | struct {
36          COLR    *sl;            /* scanline contents */
37   } scan[NSCANS];         /* buffered scanlines */
38  
39 + static long     ncall = 0L;     /* number of calls to getpictscan */
40 + static long     nread = 0L;     /* number of scanlines read */
41  
42 +
43   COLR *
44   getpictscan(y)                  /* get picture scanline */
45   int     y;
46   {
47          extern long     ftell();
45        static long     ncall = 0;
48          int     minused;
49          register int    i;
50                                          /* first check our buffers */
# Line 58 | Line 60 | int    y;
60          }
61                                          /* not there, read it in */
62          if (scanpos[y] == -1) {                 /* need to search */
61                if (verbose)
62                        fprintf(stderr, "%s: reading picture...\n",
63                                        progname);
63                  while (curpos > y) {
64                          scanpos[curpos] = ftell(pictfp);
65                          if (freadcolrs(scan[minused].sl, pxsiz, pictfp) < 0)
# Line 71 | Line 70 | int    y;
70                  fprintf(stderr, "%s: picture seek error\n", progname);
71                  exit(1);
72          }
74        if (verbose)
75                fprintf(stderr, "%s: reading scanline %d...\n", progname, y);
73          if (freadcolrs(scan[minused].sl, pxsiz, pictfp) < 0)
74                  goto readerr;
75 +        nread++;
76          curpos = y-1;
77          scan[minused].lused = ncall;
78          scan[minused].y = y;
# Line 85 | Line 83 | readerr:
83   }
84  
85  
86 + pict_stats()                    /* print out picture read statistics */
87 + {
88 +        static long     lastcall = 0L;  /* ncall at last report */
89 +        static long     lastread = 0L;  /* nread at last report */
90 +
91 +        if (ncall == lastcall)
92 +                return;
93 +        fprintf(stderr, "%s: %ld scanlines read, %ld reused\n",
94 +                        progname, nread-lastread,
95 +                        (ncall-lastcall)-(nread-lastread));
96 +        lastcall = ncall;
97 +        lastread = nread;
98 + }
99 +
100 +
101   double
102   pict_val(vd)                    /* find picture value for view direction */
103   FVECT   vd;
# Line 136 | Line 149 | int    vv;
149   float   *vb;
150   {
151          float   rt_buf[6*MAXPIX];       /* rtrace send/receive buffer */
152 <        int     npix_tort;              /* number of pixels in buffer */
152 >        register int    n;              /* number of pixels in buffer */
153          short   buf_vh[MAXPIX];         /* pixel positions */
154          FVECT   dir;
155          register int    vh;
143        register int    i;
156  
157 + #ifdef DEBUG
158          if (verbose)
159                  fprintf(stderr, "%s: computing view span at %d...\n",
160                                  progname, vv);
161 <        npix_tort = 0;
161 > #endif
162 >        n = 0;
163          for (vh = -hsize; vh <= hsize; vh++) {
164                  if (compdir(dir, vh, vv) < 0) { /* off viewable region */
165                          vb[vh+hsize] = -1.0;
# Line 156 | Line 170 | float  *vb;
170                  if (rt_pid == -1)               /* missing information */
171                          continue;
172                                                  /* send to rtrace */
173 <                if (npix_tort >= MAXPIX) {              /* flush */
174 <                        rt_compute(rt_buf, npix_tort);
175 <                        for (i = 0; i < npix_tort; i++)
176 <                                vb[buf_vh[i]+hsize] = luminance(rt_buf+3*i);
163 <                        npix_tort = 0;
173 >                if (n >= MAXPIX) {                      /* flush */
174 >                        rt_compute(rt_buf, n);
175 >                        while (n-- > 0)
176 >                                vb[buf_vh[n]+hsize] = luminance(rt_buf+3*n);
177                  }
178 <                rt_buf[npix_tort] = ourview.vp[0];
179 <                rt_buf[npix_tort+1] = ourview.vp[1];
180 <                rt_buf[npix_tort+2] = ourview.vp[2];
181 <                rt_buf[npix_tort+3] = dir[0];
182 <                rt_buf[npix_tort+4] = dir[1];
183 <                rt_buf[npix_tort+5] = dir[2];
184 <                buf_vh[npix_tort++] = vh;
178 >                rt_buf[6*n] = ourview.vp[0];
179 >                rt_buf[6*n+1] = ourview.vp[1];
180 >                rt_buf[6*n+2] = ourview.vp[2];
181 >                rt_buf[6*n+3] = dir[0];
182 >                rt_buf[6*n+4] = dir[1];
183 >                rt_buf[6*n+5] = dir[2];
184 >                buf_vh[n++] = vh;
185          }
186 <        if (npix_tort > 0) {                    /* process pending buffer */
187 <                rt_compute(rt_buf, npix_tort);
188 <                for (i = 0; i < npix_tort; i++)
189 <                        vb[buf_vh[i]+hsize] = luminance(rt_buf+3*i);
186 > #ifdef DEBUG
187 >        if (verbose)
188 >                pict_stats();
189 > #endif
190 >        if (n > 0) {                            /* process pending buffer */
191 >                rt_compute(rt_buf, n);
192 >                while (n-- > 0)
193 >                        vb[buf_vh[n]+hsize] = luminance(rt_buf+3*n);
194          }
195   }
196  
# Line 184 | Line 201 | int    np;
201   {
202          static float    nbuf[6] = {0.,0.,0.,0.,0.,0.};
203  
204 + #ifdef DEBUG
205          if (verbose && np > 1)
206                  fprintf(stderr, "%s: sending %d samples to rtrace...\n",
207                                  progname, np);
208 + #endif
209          if (writebuf(fd_tort,(char *)pb,6*sizeof(float)*np) < 6*sizeof(float)*np
210                  || writebuf(fd_tort,(char *)nbuf,sizeof(nbuf)) < sizeof(nbuf)) {
211                  fprintf(stderr, "%s: error writing to rtrace process\n",
# Line 283 | Line 302 | char   *av[];
302                  perror(progname);
303                  exit(1);
304          }
305 +        close(p0[0]);
306 +        close(p1[1]);
307          fd_tort = p0[1];
308          fd_fromrt = p1[0];
309   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines