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.9 by greg, Mon Mar 17 01:59:48 2014 UTC vs.
Revision 2.10 by greg, Tue Mar 18 01:33:07 2014 UTC

# Line 110 | Line 110 | build_tree(TNODE *tp, const int bmin[], int l2s)
110  
111   /* Set our trimming threshold */
112   static void
113 < set_threshold()
113 > set_threshold(void)
114   {
115          int     hsum = 0;
116          int     i;
# Line 235 | Line 235 | read_double(float *rowp, int n)
235          return(nread);
236   }
237  
238 + /* Truncate any negative values to zero */
239 + static void
240 + noneg(float *varr, int n)
241 + {
242 +        int     nnan = 0;
243 +
244 +        while (n-- > 0) {
245 + #ifdef isnan
246 +                if (isnan(*varr)) {
247 +                        *varr = 0;
248 +                        ++nnan;
249 +                } else
250 + #endif
251 +                if (*varr < 0) *varr = 0;
252 +                ++varr;
253 +        }
254 +        if (nnan)
255 +                fprintf(stderr, "Warning: BSDF data contains %d NaN values\n",
256 +                                nnan);
257 + }
258 +
259   /* Load data array, filling zeroes for rank 3 demi-tensor */
260   static void
261 < load_data()
261 > load_data(void)
262   {
263          int     (*readf)(float *, int) = NULL;
264          
# Line 289 | Line 310 | load_data()
310                  }
311          } else if (getc(stdin) != EOF)
312                  error(WARNING, "binary data past end of expected input");
313 +
314 +        noneg(datarr, 1<<(log2g*ttrank));       /* take precautions */
315   }
316  
317   /* Enforce reciprocity by averaging data values */
318   static void
319 < do_reciprocity()
319 > do_reciprocity(void)
320   {
321          const int       siz = 1<<log2g;
322          float           *v1p, *v2p;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines