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

Comparing ray/src/util/rsensor.c (file contents):
Revision 2.16 by greg, Thu Apr 23 23:54:08 2015 UTC vs.
Revision 2.20 by greg, Fri Jul 24 17:09:33 2020 UTC

# Line 9 | Line 9 | static const char RCSid[] = "$Id$";
9   */
10  
11   #include "ray.h"
12 + #include "platform.h"
13   #include "source.h"
14   #include "view.h"
15   #include "random.h"
# Line 77 | Line 78 | quit(ec)                       /* make sure exit is called */
78   int     ec;
79   {
80          if (ray_pnprocs > 0)    /* close children if any */
81 <                ray_pclose(0);          
81 >                ray_pclose(0);
82 >        else if (ray_pnprocs < 0)
83 >                _exit(ec);      /* avoid flush in child */
84          exit(ec);
85   }
86  
# Line 237 | Line 240 | load_sensor(
240                  cp = fskip(cp);
241                  if (cp == NULL)
242                          break;
243 <                if (ntp[1] > 1 && sarr[ntp[1]+1] <= sarr[ntp[1]]) {
243 >                if (ntp[1] > 1 && sarr[ntp[1]+1] <= sarr[ntp[1]]+FTINY) {
244                          sprintf(errmsg,
245                  "Phi values not monotinically increasing in sensor file '%s'",
246                                          sfile);
# Line 263 | Line 266 | load_sensor(
266                          cp = fskip(cp);
267                          if (cp == NULL)
268                                  break;
269 <                        if (i && sarr[i] < .0) {
269 >                        if (sarr[i] < .0) {
270                                  if (!warnedneg++) {
271                                          sprintf(errmsg,
272                  "Negative value(s) in sensor file '%s' (ignored)\n", sfile);
273                                          error(WARNING, errmsg);
274                                  }
275                                  sarr[i] = .0;
276 <                        } else if (i > ntp[0]*(ntp[1]+1) && sarr[i] > FTINY)
276 >                        } else if (sarr[i] > FTINY && i > ntp[0]*(ntp[1]+1))
277                                  last_pos_val = i;
278                          ++i;
279                  }
280 <                if (i == ntp[0]*(ntp[1]+1))
280 >                if (i == ntp[0]*(ntp[1]+1))     /* empty line? */
281                          break;
282                  if (ntp[0] > 1 && sarr[ntp[0]*(ntp[1]+1)] <=
283                                          sarr[(ntp[0]-1)*(ntp[1]+1)]) {
# Line 297 | Line 300 | load_sensor(
300          errmsg[0] = '\0';                       /* sanity checks */
301          if (!last_pos_val)
302                  sprintf(errmsg, "no positive sensor values in file '%s'", sfile);
300        if (ntp[0] <= 0)
301                sprintf(errmsg, "no data in sensor file '%s'", sfile);
303          else if (fabs(sarr[ntp[1]+1]) > FTINY)
304                  sprintf(errmsg, "minimum theta must be 0 in sensor file '%s'",
305                                  sfile);
306          else if (fabs(sarr[1]) > FTINY)
307                  sprintf(errmsg, "minimum phi must be 0 in sensor file '%s'",
308                                  sfile);
309 <        else if (sarr[ntp[1]] <= FTINY)
309 >        else if (sarr[ntp[1]] < 270.-FTINY)
310                  sprintf(errmsg,
311 <                        "maximum phi must be positive in sensor file '%s'",
311 >                        "maximum phi must be 270 or greater in sensor file '%s'",
312                                  sfile);
313 <        else if (sarr[ntp[0]*(ntp[1]+1)] <= FTINY)
313 >        else if (sarr[ntp[1]] >= 360.-FTINY)
314                  sprintf(errmsg,
315 <                        "maximum theta (%f) must be positive in sensor file '%s'",
316 <                                sarr[ntp[0]*(ntp[1]+1)], sfile);
315 >                        "maximum phi must be less than 360 in sensor file '%s'",
316 >                                sfile);
317          if (errmsg[0])
318                  error(USER, errmsg);
319          return((float *)realloc((void *)sarr, sizeof(float)*nelem));
# Line 372 | Line 373 | init_ptable(
373          psize = PI*tsize/maxtheta;
374          if (sntp[0]*sntp[1] < samptot)  /* don't overdo resolution */
375                  samptot = sntp[0]*sntp[1];
376 <        ntheta = (int)(sqrt((double)samptot*tsize/psize) + 0.5);
376 >        ntheta = (int)(sqrt((double)samptot*tsize/psize)*sntp[0]/sntp[1]) + 1;
377          if (ntheta > MAXNT)
378                  ntheta = MAXNT;
379          nphi = samptot/ntheta;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines