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

Comparing ray/src/util/rttree_reduce.c (file contents):
Revision 2.5 by greg, Sat Aug 20 02:46:13 2011 UTC vs.
Revision 2.6 by greg, Mon Nov 21 20:07:50 2011 UTC

# Line 291 | Line 291 | load_data()
291                  error(WARNING, "binary data past end of expected input");
292   }
293  
294 + /* Enforce reciprocity by averaging data values */
295 + static void
296 + do_reciprocity()
297 + {
298 +        float   *v1p, *v2p;
299 +
300 +        if (ttrank == 3) {
301 +                int     ix, ox, oy;
302 +                for (ix = 0; ix < 1<<(log2g-1); ix++)
303 +                    for (ox = 0; ox < 1<<log2g; ox++)
304 +                        for (oy = 0; oy < 1<<(log2g-1); oy++) {
305 +                                v1p = &dval3(ix,ox,oy);
306 +                                v2p = &dval3(ix,ox,(1<<log2g)-1-oy);
307 +                                *v1p = *v2p = .5f*( *v1p + *v2p );
308 +                        }
309 +        } else /* ttrank == 4 */ {
310 +                int     ix, iy, ox, oy;
311 +                for (ix = 1; ix < 1<<log2g; ix++)
312 +                    for (iy = 1; iy < 1<<log2g; iy++)
313 +                        for (ox = 0; ox < ix; ox++)
314 +                            for (oy = 0; oy < iy; oy++) {
315 +                                v1p = &dval4(ix,iy,ox,oy);
316 +                                v2p = &dval4(ox,oy,ix,iy);
317 +                                *v1p = *v2p = .5f*( *v1p + *v2p );
318 +                            }
319 +        }
320 + }
321 +
322   /* Load BSDF array, coalesce uniform regions and format as tensor tree */
323   int
324   main(int argc, char *argv[])
325   {
326          int     doheader = 1;
327 +        int     recipavg = 0;
328          int     bmin[4];
329          TNODE   gtree;
330          int     i;
331                                          /* get options and parameters */
332          for (i = 1; i < argc && argv[i][0] == '-'; i++)
333                  switch (argv[i][1]) {
334 +                case 'a':
335 +                        recipavg = !recipavg;
336 +                        break;
337                  case 'h':
338                          doheader = !doheader;
339                          break;
# Line 338 | Line 370 | main(int argc, char *argv[])
370          if (infmt != 'a')
371                  SET_FILE_BINARY(stdin);
372          load_data();
373 +        if (recipavg)
374 +                do_reciprocity();
375          if (doheader) {
376                  for (i = 0; i < argc; i++) {
377                          fputs(argv[i], stdout);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines