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

Comparing ray/src/util/vwrays.c (file contents):
Revision 3.16 by greg, Sat Aug 20 20:57:52 2011 UTC vs.
Revision 3.20 by greg, Thu Nov 7 23:20:29 2019 UTC

# Line 33 | Line 33 | int    fromstdin = 0;
33  
34   int     unbuffered = 0;
35  
36 + int     repeatcnt = 1;
37 +
38   char    *progname;
39  
40  
# Line 44 | Line 46 | main(
46   {
47          char    *err;
48          int     rval, getdim = 0;
49 <        register int    i;
49 >        int     i;
50  
51          progname = argv[0];
52          if (argc < 2)
# Line 103 | Line 105 | main(
105                                  exit(1);
106                          }
107                          break;
108 +                case 'c':                       /* repeat count */
109 +                        repeatcnt = atoi(argv[++i]);
110 +                        break;
111                  case 'p':                       /* pixel aspect or jitter */
112                          if (argv[i][2] == 'a')
113                                  pa = atof(argv[++i]);
# Line 129 | Line 134 | main(
134                          exit(1);
135                  }
136                  if (i+1 < argc) {
137 <                        zfd = open(argv[i+1], O_RDONLY);
138 <                        if (zfd < 0) {
134 <                                fprintf(stderr,
135 <                                        "%s: cannot open depth buffer\n",
136 <                                                argv[i+1]);
137 >                        zfd = open_float_depth(argv[i+1], (long)rs.xr*rs.yr);
138 >                        if (zfd < 0)
139                                  exit(1);
138                        }
140                  }
141          }
142          if ((err = setview(&vw)) != NULL) {
# Line 156 | Line 157 | main(
157          exit(0);
158   userr:
159          fprintf(stderr,
160 <        "Usage: %s [ -i -u -f{a|f|d} | -d ] { view opts .. | picture [zbuf] }\n",
160 >        "Usage: %s [ -i -u -f{a|f|d} -c rept | -d ] { view opts .. | picture [zbuf] }\n",
161                          progname);
162          exit(1);
163   }
# Line 185 | Line 186 | pix2rays(
186          RREAL   loc[2];
187          int     pp[2];
188          double  d;
189 <        register int    i;
189 >        int     i;
190  
191          while (fscanf(fp, "%lf %lf", &px, &py) == 2) {
192                  px += .5; py += .5;
193                  loc[0] = px/rs.xr; loc[1] = py/rs.yr;
194                  if (zfd >= 0) {
195 +                        if ((loc[0] < 0) | (loc[0] >= 1) |
196 +                                        (loc[1] < 0) | (loc[1] >= 1)) {
197 +                                fprintf(stderr, "%s: input pixel outside image\n",
198 +                                                progname);
199 +                                exit(1);
200 +                        }
201                          loc2pix(pp, &rs, loc[0], loc[1]);
202                          if (lseek(zfd,
203                                  (pp[1]*scanlen(&rs)+pp[0])*sizeof(float),
# Line 234 | Line 241 | putrays(void)
241          float   *zbuf = NULL;
242          int     sc;
243          double  d;
244 <        register int    si, i;
244 >        int     si, i, c;
245  
246          if (zfd >= 0) {
247                  zbuf = (float *)malloc(scanlen(&rs)*sizeof(float));
# Line 253 | Line 260 | putrays(void)
260                          }
261                  }
262                  for (si = 0; si < scanlen(&rs); si++) {
263 +                    for (c = repeatcnt; c-- > 0; ) {
264                          pix2loc(loc, &rs, si, sc);
265                          jitterloc(loc);
266                          d = viewray(rorg, rdir, &vw, loc[0], loc[1]);
# Line 268 | Line 276 | putrays(void)
276                                  rdir[0] *= d; rdir[1] *= d; rdir[2] *= d;
277                          }
278                          (*putr)(rorg, rdir);
279 +                    }
280                  }
281          }
282          if (zfd >= 0)
# Line 297 | Line 306 | putf(          /* put out ray in float format */
306  
307          v[0] = ro[0]; v[1] = ro[1]; v[2] = ro[2];
308          v[3] = rd[0]; v[4] = rd[1]; v[5] = rd[2];
309 <        fwrite(v, sizeof(float), 6, stdout);
309 >        putbinary(v, sizeof(float), 6, stdout);
310   }
311  
312  
# Line 311 | Line 320 | putd(          /* put out ray in double format */
320  
321          v[0] = ro[0]; v[1] = ro[1]; v[2] = ro[2];
322          v[3] = rd[0]; v[4] = rd[1]; v[5] = rd[2];
323 <        fwrite(v, sizeof(double), 6, stdout);
323 >        putbinary(v, sizeof(double), 6, stdout);
324   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines