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

Comparing ray/src/util/rfluxmtx.c (file contents):
Revision 2.4 by greg, Tue Jul 22 21:55:31 2014 UTC vs.
Revision 2.6 by greg, Wed Jul 23 00:40:17 2014 UTC

# Line 53 | Line 53 | char           *kfullfn = "klems_full.cal";
53   char            *khalffn = "klems_half.cal";
54   char            *kquarterfn = "klems_quarter.cal";
55  
56 < #define PARAMSTART      "@rfluxmtx"     /* string indicating parameters */
56 >                                        /* string indicating parameters */
57 > const char      PARAMSTART[] = "@rfluxmtx";
58  
59                                  /* surface type IDs */
60   #define ST_NONE         0
# Line 95 | Line 96 | typedef struct param_s {
96  
97   PARAMS          curparams;
98   char            curmod[128];
99 + char            newparams[1024];
100  
101   typedef int     SURFSAMP(FVECT, SURF *, double);
102  
# Line 108 | Line 110 | SURFSAMP       *orig_in_surf[4] = {
110   static void
111   clear_params(PARAMS *p, int reset_only)
112   {
111        curmod[0] = '\0';
113          while (p->slist != NULL) {
114                  SURF    *sdel = p->slist;
115                  p->slist = sdel->next;
# Line 123 | Line 124 | clear_params(PARAMS *p, int reset_only)
124                  p->outfn = NULL;
125                  return;
126          }
127 <        memset(p, 0, sizeof(curparams));
127 >        memset(p, 0, sizeof(PARAMS));
128   }
129  
130   /* Get surface type from name */
# Line 308 | Line 309 | nextchar:
309  
310   /* Parse program parameters (directives) */
311   static int
312 < parse_params(char *pargs)
312 > parse_params(PARAMS *p, char *pargs)
313   {
314          char    *cp = pargs;
315          int     nparams = 0;
# Line 319 | Line 320 | parse_params(char *pargs)
320                  case 'h':
321                          if (*cp++ != '=')
322                                  break;
323 <                        curparams.hsiz = 0;
323 >                        p->hsiz = 0;
324                          i = 0;
325                          while (*cp && !isspace(*cp)) {
326                                  if (isdigit(*cp))
327 <                                        curparams.hsiz = 10*curparams.hsiz +
328 <                                                                *cp - '0';
328 <                                curparams.hemis[i++] = *cp++;
327 >                                        p->hsiz = 10*p->hsiz + *cp - '0';
328 >                                p->hemis[i++] = *cp++;
329                          }
330                          if (!i)
331                                  break;
332 <                        curparams.hemis[i] = '\0';
333 <                        curparams.hsiz += !curparams.hsiz;
332 >                        p->hemis[i] = '\0';
333 >                        p->hsiz += !p->hsiz;
334                          ++nparams;
335                          continue;
336                  case 'u':
337                          if (*cp++ != '=')
338                                  break;
339 <                        if (!get_direction(curparams.vup, cp))
339 >                        if (!get_direction(p->vup, cp))
340                                  break;
341                          ++nparams;
342                          continue;
# Line 349 | Line 349 | parse_params(char *pargs)
349                          if (!i)
350                                  break;
351                          *--cp = '\0';
352 <                        curparams.outfn = savqstr(cp-i);
352 >                        p->outfn = savqstr(cp-i);
353                          *cp++ = ' ';
354                          ++nparams;
355                          continue;
# Line 553 | Line 553 | ssamp_ring(FVECT orig, SURF *sp, double x)
553                  sp->priv = (void *)uva;
554          }
555          SDmultiSamp(samp2, 2, x);
556 <        samp2[0] = sp->farg[6] + sqrt(samp2[0]*sp->area*(1./PI));
556 >        samp2[0] = sqrt(samp2[0]*sp->area*(1./PI) + sp->farg[6]*sp->farg[6]);
557          samp2[1] *= 2.*PI;
558          uv[0] = samp2[0]*tcos(samp2[1]);
559          uv[1] = samp2[0]*tsin(samp2[1]);
# Line 1043 | Line 1043 | add_recv_object(FILE *fp)
1043                                  finish_receiver();
1044                                  clear_params(&curparams, 1);
1045                          }
1046 +                        parse_params(&curparams, newparams);
1047 +                        newparams[0] = '\0';
1048                          strcpy(curmod, thismod);
1049                  }
1050                  add_surface(st, oname, fp);     /* read & store surface */
# Line 1079 | Line 1081 | add_send_object(FILE *fp)
1081                          fputs(": cannot use source as a sender!\n", stderr);
1082                          return(-1);
1083                  }
1084 +                parse_params(&curparams, newparams);
1085 +                newparams[0] = '\0';
1086                  add_surface(st, oname, fp);     /* read & store surface */
1087                  return(0);
1088          }
# Line 1122 | Line 1126 | load_scene(const char *inspec, int (*ocb)(FILE *))
1126                          continue;
1127                  }
1128                  if (c == '#') {         /* parameters/comment */
1129 <                        if (fscanf(fp, "%s", inpbuf) == 1 &&
1129 >                        if ((c = getc(fp)) == EOF || ungetc(c,fp) == EOF)
1130 >                                break;
1131 >                        if (!isspace(c) && fscanf(fp, "%s", inpbuf) == 1 &&
1132                                          !strcmp(inpbuf, PARAMSTART)) {
1133                                  if (fgets(inpbuf, sizeof(inpbuf), fp) != NULL)
1134 <                                        parse_params(inpbuf);
1134 >                                        strcat(newparams, inpbuf);
1135                                  continue;
1136                          }
1137                          while ((c = getc(fp)) != EOF && c != '\n');
# Line 1177 | Line 1183 | main(int argc, char *argv[])
1183                          case 'f':
1184                          case 'd':
1185                          case 'c':
1186 <                                if (!(fmtopt[4] = argv[a][3]))
1187 <                                        fmtopt[4] = argv[a][2];
1188 <                                fmtopt[3] = argv[a][2];
1186 >                                if (!(fmtopt[3] = argv[a][3]))
1187 >                                        fmtopt[3] = argv[a][2];
1188 >                                fmtopt[2] = argv[a][2];
1189                                  na = 0;
1190                                  continue;       /* will pass later */
1191                          default:
# Line 1195 | Line 1201 | main(int argc, char *argv[])
1201                          na = 0;
1202                          continue;
1203                  case 'c':               /* number of samples */
1204 <                        sampcnt = atoi(argv[a+1]);
1204 >                        sampcnt = atoi(argv[++a]);
1205                          if (sampcnt <= 0)
1206                                  goto userr;
1207                          na = 0;         /* we re-add this later */
# Line 1267 | Line 1273 | done_opts:
1273                  }
1274                  if (sampcnt <= 0) sampcnt = 1;
1275          } else {                        /* else FVECT determines input format */
1276 <                fmtopt[3] = (sizeof(RREAL)==sizeof(double)) ? 'd' : 'f';
1276 >                fmtopt[2] = (sizeof(RREAL)==sizeof(double)) ? 'd' : 'f';
1277                  if (sampcnt <= 0) sampcnt = 10000;
1278          }
1279          sprintf(sampcntbuf, "%d", sampcnt);
# Line 1317 | Line 1323 | done_opts:
1323   userr:
1324          if (a < argc-2)
1325                  fprintf(stderr, "%s: unsupported option '%s'", progname, argv[a]);
1326 <        fprintf(stderr, "Usage: %s [rcontrib options] sender.rad receiver.rad [system.rad ..]\n",
1326 >        fprintf(stderr, "Usage: %s [-v][rcontrib options] sender.rad receiver.rad [system.rad ..]\n",
1327                                  progname);
1328          return(1);
1329   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines