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

Comparing ray/src/rt/mkpmap.c (file contents):
Revision 2.6 by rschregle, Mon Aug 14 21:12:10 2017 UTC vs.
Revision 2.10 by rschregle, Fri Aug 7 01:21:13 2020 UTC

# Line 9 | Line 9 | static const char RCSid[] = "$Id$";
9    
10     Roland Schregle (roland.schregle@{hslu.ch, gmail.com})
11     (c) Fraunhofer Institute for Solar Energy Systems,
12 <       Lucerne University of Applied Sciences & Arts
12 >       supported by the German Research Foundation (DFG)
13 >       under the FARESYS project.
14     (c) Lucerne University of Applied Sciences and Arts,
15 <       supported by the Swiss National Science Foundation (SNSF, #147053)
15 >       supported by the Swiss National Science Foundation (SNSF #147053).
16 >   (c) Tokyo University of Science,
17 >       supported by the JSPS KAKENHI Grant Number JP19KK0115.
18     ======================================================================
19    
20     $Id$    
# Line 20 | Line 23 | static const char RCSid[] = "$Id$";
23  
24   #include "pmap.h"
25   #include "pmapmat.h"
26 + #include "pmapsrc.h"
27   #include "pmapcontrib.h"
28   #include "pmaprand.h"
29   #include "paths.h"
# Line 30 | Line 34 | static const char RCSid[] = "$Id$";
34   #include <sys/stat.h>
35  
36  
37 + /* Enable options for Ze Ekspertz only! */
38 + #define PMAP_EKSPERTZ
39 +
40 +
41   extern char VersionID [];
42  
43  
# Line 45 | Line 53 | int      clobber = 0;               /* overwrite outpu
53   COLOR    cextinction = BLKCOLOR;    /* global extinction coefficient */
54   COLOR    salbedo = BLKCOLOR;        /* global scattering albedo */
55   double   seccg = 0;                 /* global scattering eccentricity */
56 < int      ambincl = -1;              /* photon port flag */
57 < char     *amblist [AMBLLEN + 1];    /* photon port list */
56 > char     *amblist [AMBLLEN + 1];    /* ambient include/exclude list */
57 > int      ambincl = -1;              /* include == 1, exclude == 0 */
58   char     *diagFile = NULL;          /* diagnostics output file */
59   int      rand_samp = 1;             /* uncorrelated random sampling */
60   unsigned nproc = 1;                 /* number of parallel processes */
# Line 71 | Line 79 | void (*trace)() = NULL, (*addobjnotify [])() = {ambnot
79   void printdefaults()
80   /* print default values to stdout */
81   {
74   puts("-apg file nPhotons\t\t# global photon map");
75   puts("-apc file nPhotons\t\t# caustic photon map");          
76   puts("-apd file nPhotons\t\t# direct photon map");
77   puts("-app file nPhotons bwidth\t# precomputed global photon map");
78   puts("-apv file nPhotons\t\t# volume photon map");
79   puts("-apC file nPhotons\t\t# contribution photon map");
80  
81   printf("-apD %f\t\t\t# predistribution factor\n", preDistrib);
82   printf("-apM %d\t\t\t\t# max predistrib passes\n", maxPreDistrib);
83   printf("-apm %ld\t\t\t# max photon bounces\n", photonMaxBounce);                            
84   puts("-apo mod\t\t\t# photon port modifier");
85   puts("-apO file\t\t\t# photon port file");
86   printf("-apP %f\t\t\t# precomputation factor\n", finalGather);
87   printf("-apr %d\t\t\t\t# random seed\n", randSeed);
88   puts("-aps mod\t\t\t# antimatter sensor modifier");
89   puts("-apS file\t\t\t# antimatter sensor file");
82  
83 <   printf(backvis ? "-bv+\t\t\t\t# back face visibility on\n"
84 <                  : "-bv-\t\t\t\t# back face visibility off\n");
85 <   printf("-dp  %.1f\t\t\t# PDF samples / sr\n", pdfSamples);
86 <   printf("-ds  %f\t\t\t# source partition size ratio\n", srcsizerat);
87 <   printf("-e   %s\t\t\t# diagnostics output file\n", diagFile);
88 <   printf(clobber ? "-fo+\t\t\t\t# force overwrite\n"
89 <                  : "-fo-\t\t\t\t# do not overwrite\n");
90 <   printf("-ma  %.2f %.2f %.2f\t\t# scattering albedo\n",
83 > #ifdef EVALDRC_HACK
84 >   /* EvalDRC support */
85 >   puts("-A\t\t\t\t# angular source file");
86 > #endif    
87 >   puts("-ae  mod\t\t\t\t# exclude modifier");
88 >   puts("-aE  file\t\t\t\t# exclude modifiers from file");
89 >   puts("-ai  mod\t\t\t\t# include modifier");
90 >   puts("-aI  file\t\t\t\t# include modifiers from file");
91 > #ifdef PMAP_EKSPERTZ
92 >   puts("-api xmin ymin zmin xmax ymax zmax\t# region of interest");
93 > #endif
94 >   puts("-apg file nPhotons\t\t\t# global photon map");
95 >   puts("-apc file nPhotons\t\t\t# caustic photon map");          
96 >   puts("-apd file nPhotons\t\t\t# direct photon map");
97 >   puts("-app file nPhotons bwidth\t\t# precomputed global photon map");
98 >   puts("-apv file nPhotons\t\t\t# volume photon map");
99 >   puts("-apC file nPhotons\t\t\t# contribution photon map");  
100 >   printf("-apD %f\t\t\t\t# predistribution factor\n", preDistrib);
101 >   printf("-apM %d\t\t\t\t\t# max predistrib passes\n", maxPreDistrib);
102 > #if 1
103 >   /* Kept for backwards compat, will be gradually phased out by -ld, -lr */
104 >   printf("-apm %ld\t\t\t\t# limit photon bounces\n", photonMaxBounce);
105 > #endif
106 >   puts("-apo+ mod\t\t\t\t# photon port modifier");
107 >   puts("-apO+ file\t\t\t\t# photon ports from file");
108 >   printf("-apP %f\t\t\t\t# precomputation factor\n", finalGather);
109 >   printf("-apr %d\t\t\t\t\t# random seed\n", randSeed);
110 >   puts("-aps mod\t\t\t\t# antimatter sensor modifier");
111 >   puts("-apS file\t\t\t\t# antimatter sensors from file");
112 >
113 >   printf(backvis ? "-bv+\t\t\t\t\t# back face visibility on\n"
114 >                  : "-bv-\t\t\t\t\t# back face visibility off\n");
115 >   printf("-dp  %.1f\t\t\t\t# PDF samples / sr\n", pdfSamples);
116 >   printf("-ds  %f\t\t\t\t# source partition size ratio\n", srcsizerat);
117 >   printf("-e   %s\t\t\t\t# diagnostics output file\n", diagFile);
118 >   printf(clobber ? "-fo+\t\t\t\t\t# force overwrite\n"
119 >                  : "-fo-\t\t\t\t\t# do not overwrite\n");
120 > #ifdef PMAP_EKSPERTZ
121 >   /* (Formerly) NU STUFF for Ze Exspertz! */      
122 >   printf("-ld %.1f\t\t\t\t\t# limit photon distance\n", photonMaxDist);
123 >   printf("-lr %ld\t\t\t\t# limit photon bounces\n", photonMaxBounce);  
124 > #endif  
125 >   printf("-ma  %.2f %.2f %.2f\t\t\t# scattering albedo\n",
126            colval(salbedo,RED), colval(salbedo,GRN), colval(salbedo,BLU));
127 <   printf("-me  %.2e %.2e %.2e\t# extinction coefficient\n",
127 >   printf("-me  %.2e %.2e %.2e\t\t# extinction coefficient\n",
128            colval(cextinction,RED), colval(cextinction,GRN),
129            colval(cextinction,BLU));          
130 <   printf("-mg  %.2f\t\t\t# scattering eccentricity\n", seccg);
130 >   printf("-mg  %.2f\t\t\t\t# scattering eccentricity\n", seccg);
131   #if NIX  
132 <   /* Multiprocessing on NIX only */
133 <   printf("-n   %d\t\t\t\t# number of parallel processes\n", nproc);
132 >   /* Multiprocessing on NIX only; so tuff luck, Windoze Weenies! */
133 >   printf("-n   %d\t\t\t\t\t# number of parallel processes\n", nproc);
134   #endif  
135 <   printf("-t   %-9d\t\t\t# time between reports\n", photonRepTime);
136 <   printf(verbose ? "-v+\t\t\t\t# verbose console output\n"
137 <                  : "-v-\t\t\t\t# terse console output\n");
111 < #ifdef PMAP_ROI
112 <   /* Ziss option for ze egg-spurtz only! */
113 <   puts("-api xmin ymin zmin\n     xmax ymax zmax\t\t# region of interest");
114 < #endif  
115 < #ifdef EVALDRC_HACK
116 <   /* ... and ziss one... */
117 <   puts("-A\t\t\t\t# angular source file");
118 < #endif
135 >   printf("-t   %-9d\t\t\t\t# time between reports\n", photonRepTime);
136 >   printf(verbose ? "-v+\t\t\t\t\t# verbose console output\n"
137 >                  : "-v-\t\t\t\t\t# terse console output\n");
138   }
139  
140  
141   int main (int argc, char* argv [])
142   {
143 <   #define check(ol, al) if (argv [i][ol] || \
144 <                             badarg(argc - i - 1,argv + i + 1, al)) \
145 <                            goto badopt
146 <                            
143 >   #define check(ol, al) if ( \
144 >      argv [i][ol] || badarg(argc - i - 1,argv + i + 1, al) \
145 >   ) goto badopt
146 >  
147 >   /* Evaluate boolean option, setting var accordingly */                        
148     #define check_bool(olen, var) switch (argv [i][olen]) { \
149 <                             case '\0': var = !var; break; \
150 <                             case 'y': case 'Y': case 't': case 'T': \
151 <                             case '+': case '1': var = 1; break; \
152 <                             case 'n': case 'N': case 'f': case 'F': \
153 <                             case '-': case '0': var = 0; break; \
154 <                             default: goto badopt; \
155 <                          }  
149 >      case '\0': \
150 >         var = !var; break; \
151 >      case 'y': case 'Y': case 't': case 'T': case '+': case '1': \
152 >         var = 1; break; \
153 >      case 'n': case 'N': case 'f': case 'F': case '-': case '0': \
154 >         var = 0; break; \
155 >      default: \
156 >         goto badopt; \
157 >   }
158 >  
159 >   /* Evaluate trinary option, setting bits v1 and v2 in var accordingly */
160 >   #define check_tri(olen, v1, v2, var) switch (argv [i][olen]) { \
161 >      case '\0': case '+': \
162 >         var = v1; break; \
163 >      case '-': \
164 >         var = v2; break;\
165 >      case '0': \
166 >         var = v1 | v2; break; \
167 >      default: \
168 >         goto badopt; \
169 >   }
170  
171 <   int loadflags = IO_CHECK | IO_SCENE | IO_TREE | IO_BOUNDS, rval, i;
172 <   char **portLp = NULL, **sensLp = photonSensorList;
173 <   struct stat pmstat;
171 >   int      loadflags = IO_CHECK | IO_SCENE | IO_TREE | IO_BOUNDS,
172 >            rval, i, j, n;
173 >   char     **portLp = photonPortList, **sensLp = photonSensorList,
174 >            **amblp = NULL, sbuf [MAXSTR], portFlags [2] = "\0\0";
175 >   struct   stat pmstat;
176  
177     /* Global program name */
178     progname = fixargv0(argv [0]);
# Line 172 | Line 208 | int main (int argc, char* argv [])
208        }
209              
210        switch (argv [i][1]) {
211 <         case 'a':
212 <            if (!strcmp(argv [i] + 2, "pg")) {
213 <               /* Global photon map */
214 <               check(4, "ss");
215 <               globalPmapParams.fileName = argv [++i];
216 <               globalPmapParams.distribTarget =
217 <                  parseMultiplier(argv [++i]);
218 <               if (!globalPmapParams.distribTarget)
219 <                  goto badopt;                        
220 <               globalPmapParams.minGather = globalPmapParams.maxGather = 0;
221 <            }
222 <                              
223 <            else if (!strcmp(argv [i] + 2, "pm")) {
224 <               /* Max photon bounces */
225 <               check(4, "i");              
226 <               photonMaxBounce = atol(argv [++i]);
227 <               if (photonMaxBounce <= 0)
228 <                  error(USER, "max photon bounces must be > 0");
229 <            }
211 >         case 'a': /* Ambient */
212 >            switch (argv [i][2]) {
213 >               case 'i': /* Ambient include */
214 >               case 'I':
215 >                  check(3, "s");
216 >                  if (ambincl != 1) {
217 >                     ambincl = 1;
218 >                     amblp = amblist;
219 >                  }
220 >                  if (argv [i][2] == 'I') {    
221 >                     /* Add modifiers from file */
222 >                     rval = wordfile(amblp, AMBLLEN - (amblp - amblist),
223 >                                     getpath(argv [++i],
224 >                                     getrlibpath(), R_OK));
225 >                     if (rval < 0) {
226 >                        sprintf(errmsg,
227 >                                "cannot open ambient include file \"%s\"",
228 >                                argv [i]);
229 >                        error(SYSTEM, errmsg);
230 >                     }
231 >                     amblp += rval;
232 >                  }
233 >                  else {
234 >                     /* Add modifier from next arg */
235 >                     *amblp++ = savqstr(argv [++i]);
236 >                     *amblp = NULL;
237 >                  }
238 >                  break;
239 >
240 >               case 'e': /* Ambient exclude */
241 >               case 'E':
242 >                  check(3, "s");
243 >                  if (ambincl != 0) {
244 >                     ambincl = 0;
245 >                     amblp = amblist;
246 >                  }
247 >                  if (argv [i][2] == 'E') {
248 >                     /* Add modifiers from file */
249 >                     rval = wordfile(amblp, AMBLLEN - (amblp - amblist),
250 >                                     getpath(argv [++i],
251 >                                     getrlibpath(), R_OK));
252 >                     if (rval < 0) {
253 >                        sprintf(errmsg,
254 >                                "cannot open ambient exclude file \"%s\"",
255 >                                argv [i]);
256 >                        error(SYSTEM, errmsg);
257 >                     }
258 >                     amblp += rval;
259 >                  }
260 >                  else {
261 >                     /* Add modifier from next arg */
262 >                     *amblp++ = savqstr(argv [++i]);
263 >                     *amblp = NULL;
264 >                  }
265 >                  break;
266              
267 <            else if (!strcmp(argv [i] + 2, "pp")) {
268 <               /* Precomputed global photon map */
269 <               check(4, "ssi");
270 <               preCompPmapParams.fileName = argv [++i];
271 <               preCompPmapParams.distribTarget =
272 <                  parseMultiplier(argv [++i]);
273 <               if (!preCompPmapParams.distribTarget)
274 <                  goto badopt;
275 <               preCompPmapParams.minGather = preCompPmapParams.maxGather =
276 <                  atoi(argv [++i]);
277 <               if (!preCompPmapParams.maxGather)
278 <                  goto badopt;
207 <            }
267 >               case 'p': /* Pmap-specific */
268 >                  switch (argv [i][3]) {                        
269 >                     case 'g': /* Global photon map */
270 >                        check(4, "ss");
271 >                        globalPmapParams.fileName = argv [++i];
272 >                        globalPmapParams.distribTarget =
273 >                           parseMultiplier(argv [++i]);
274 >                        if (!globalPmapParams.distribTarget)
275 >                           goto badopt;                        
276 >                        globalPmapParams.minGather =
277 >                           globalPmapParams.maxGather = 0;
278 >                        break;
279              
280 <            else if (!strcmp(argv [i] + 2, "pc")) {
281 <               /* Caustic photon map */
282 <               check(4, "ss");
283 <               causticPmapParams.fileName = argv [++i];
284 <               causticPmapParams.distribTarget =
285 <                  parseMultiplier(argv [++i]);
286 <               if (!causticPmapParams.distribTarget)
287 <                  goto badopt;
288 <            }
280 >                     case 'p': /* Precomputed global photon map */
281 >                        check(4, "ssi");
282 >                        preCompPmapParams.fileName = argv [++i];
283 >                        preCompPmapParams.distribTarget =
284 >                           parseMultiplier(argv [++i]);
285 >                        if (!preCompPmapParams.distribTarget)
286 >                           goto badopt;
287 >                        preCompPmapParams.minGather =
288 >                           preCompPmapParams.maxGather = atoi(argv [++i]);
289 >                        if (!preCompPmapParams.maxGather)
290 >                           goto badopt;
291 >                        break;
292              
293 <            else if (!strcmp(argv [i] + 2, "pv")) {
294 <               /* Volume photon map */
295 <               check(4, "ss");
296 <               volumePmapParams.fileName = argv [++i];
297 <               volumePmapParams.distribTarget =
298 <                  parseMultiplier(argv [++i]);
299 <               if (!volumePmapParams.distribTarget)
300 <                  goto badopt;                      
227 <            }
228 <            
229 <            else if (!strcmp(argv [i] + 2, "pd")) {
230 <               /* Direct photon map */
231 <               check(4, "ss");
232 <               directPmapParams.fileName = argv [++i];
233 <               directPmapParams.distribTarget =
234 <                  parseMultiplier(argv [++i]);
235 <               if (!directPmapParams.distribTarget)
236 <                  goto badopt;
237 <            }
238 <            
239 <            else if (!strcmp(argv [i] + 2, "pC")) {
240 <               /* Light source contribution photon map */
241 <               check(4, "ss");
242 <               contribPmapParams.fileName = argv [++i];
243 <               contribPmapParams.distribTarget =
244 <                  parseMultiplier(argv [++i]);
245 <               if (!contribPmapParams.distribTarget)
246 <                  goto badopt;
247 <            }
248 <            
249 <            else if (!strcmp(argv [i] + 2, "pD")) {
250 <               /* Predistribution factor */
251 <               check(4, "f");
252 <               preDistrib = atof(argv [++i]);
253 <               if (preDistrib <= 0)
254 <                  error(USER, "predistribution factor must be > 0");
255 <            }
256 <            
257 <            else if (!strcmp(argv [i] + 2, "pM")) {
258 <               /* Max predistribution passes */
259 <               check(4, "i");
260 <               maxPreDistrib = atoi(argv [++i]);
261 <               if (maxPreDistrib <= 0)
262 <                  error(USER, "max predistribution passes must be > 0");
263 <            }
264 <
265 < #ifdef PMAP_ROI
266 <            /* Add region of interest; for ze egg-spurtz only! */
267 <            else if (!strcmp(argv [i] + 2, "pi")) {
268 <               unsigned j, n = pmapNumROI;
269 <               check(4, "ffffff");
270 <              
271 <               pmapROI = realloc(pmapROI,
272 <                                 ++pmapNumROI * sizeof(PhotonMapROI));
273 <               if (!pmapROI)
274 < 1                  error(SYSTEM, "failed to allocate ROI");
293 >                     case 'c': /* Caustic photon map */
294 >                        check(4, "ss");
295 >                        causticPmapParams.fileName = argv [++i];
296 >                        causticPmapParams.distribTarget =
297 >                           parseMultiplier(argv [++i]);
298 >                        if (!causticPmapParams.distribTarget)
299 >                           goto badopt;
300 >                        break;
301                    
302 <               pmapROI [n].min [0] = atof(argv [++i]);
303 <               pmapROI [n].min [1] = atof(argv [++i]);
304 <               pmapROI [n].min [2] = atof(argv [++i]);
305 <               pmapROI [n].max [0] = atof(argv [++i]);
306 <               pmapROI [n].max [1] = atof(argv [++i]);
307 <               pmapROI [n].max [2] = atof(argv [++i]);
308 <              
309 <               for (j = 0; j < 3; j++)
310 <                  if (pmapROI [n].min [j] >= pmapROI [n].max [j])
311 <                     error(USER,
312 <                           "invalid region of interest (swapped min/max?)");
313 <            }
302 >                     case 'v': /* Volume photon map */
303 >                        check(4, "ss");
304 >                        volumePmapParams.fileName = argv [++i];
305 >                        volumePmapParams.distribTarget =
306 >                           parseMultiplier(argv [++i]);
307 >                        if (!volumePmapParams.distribTarget)
308 >                           goto badopt;                      
309 >                        break;
310 >                    
311 >                     case 'd': /* Direct photon map */
312 >                        check(4, "ss");
313 >                        directPmapParams.fileName = argv [++i];
314 >                        directPmapParams.distribTarget =
315 >                           parseMultiplier(argv [++i]);
316 >                        if (!directPmapParams.distribTarget)
317 >                           goto badopt;
318 >                        break;
319 >                    
320 >                     case 'C': /* Contribution photon map */
321 >                        check(4, "ss");
322 >                        contribPmapParams.fileName = argv [++i];
323 >                        contribPmapParams.distribTarget =
324 >                           parseMultiplier(argv [++i]);
325 >                        if (!contribPmapParams.distribTarget)
326 >                           goto badopt;
327 >                        break;
328 >
329 >                     case 'D': /* Predistribution factor */
330 >                        check(4, "f");
331 >                        preDistrib = atof(argv [++i]);
332 >                        if (preDistrib <= 0)
333 >                           error(USER, "predistrib factor must be > 0");
334 >                        break;
335 >
336 >                     case 'M': /* Max predistribution passes */
337 >                        check(4, "i");
338 >                        maxPreDistrib = atoi(argv [++i]);
339 >                        if (maxPreDistrib <= 0)
340 >                           error(USER, "max predistrib passes must be > 0");
341 >                        break;
342 >
343 > #if 1
344 >                     /* Kept for backwards compat, to be phased out by -lr */
345 >                     case 'm': /* Max photon bounces */
346 >                        check(4, "i");
347 >                        photonMaxBounce = atol(argv [++i]);
348 >                        if (photonMaxBounce <= 0)
349 >                           error(USER, "max photon bounces must be > 0");
350 >                        break;
351   #endif
289            
290            else if (!strcmp(argv [i] + 2, "pP")) {
291               /* Global photon precomputation factor */
292               check(4, "f");
293               finalGather = atof(argv [++i]);
294               if (finalGather <= 0 || finalGather > 1)
295                  error(USER, "global photon precomputation factor "
296                        "must be in range ]0, 1]");
297            }                  
298            
299            else if (!strcmp(argv [i] + 2, "po") ||
300                     !strcmp(argv [i] + 2, "pO")) {
301               /* Photon port */
302               check(4, "s");
303              
304               if (ambincl != 1) {
305                  ambincl = 1;
306                  portLp = amblist;
307               }
308              
309               if (argv[i][3] == 'O') {
310                  /* Get port modifiers from file */
311                  rval = wordfile(portLp, AMBLLEN-(portLp-amblist),
312                                  getpath(argv [++i], getrlibpath(), R_OK));
313                                  
314                  if (rval < 0) {
315                      sprintf(errmsg, "cannot open photon port file %s",
316                              argv [i]);
317                      error(SYSTEM, errmsg);
318                  }
319                  
320                  portLp += rval;
321               }
322              
323               else {
324                  /* Append modifier to port list */
325                  *portLp++ = argv [++i];
326                  *portLp = NULL;
327               }
328            }
329            
330            else if (!strcmp(argv [i] + 2, "pr")) {
331               /* Random seed */
332               check(4, "i");
333               randSeed = atoi(argv [++i]);
334            }                  
352  
353 <            else if (!strcmp(argv [i] + 2, "ps") ||
354 <                     !strcmp(argv [i] + 2, "pS")) {
355 <               /* Antimatter sensor */
356 <               check(4, "s");
357 <              
358 <               if (argv[i][3] == 'S') {
359 <                  /* Get sensor modifiers from file */
360 <                  rval = wordfile(sensLp, MAXSET-(sensLp-photonSensorList),
361 <                                  getpath(argv [++i], getrlibpath(), R_OK));
362 <                                  
363 <                  if (rval < 0) {
364 <                      sprintf(errmsg, "cannot open antimatter sensor file %s",
365 <                              argv [i]);
366 <                      error(SYSTEM, errmsg);
353 > #ifdef PMAP_EKSPERTZ                    
354 >                     case 'i': /* Add region of interest */
355 >                        check(4, "ffffff");                        
356 >                        n = pmapNumROI;
357 >                        pmapROI = realloc(pmapROI,
358 >                                          ++pmapNumROI * sizeof(PhotonMapROI));
359 >                        if (!pmapROI)
360 >                           error(SYSTEM, "failed to allocate ROI");
361 >                        pmapROI [n].min [0] = atof(argv [++i]);
362 >                        pmapROI [n].min [1] = atof(argv [++i]);
363 >                        pmapROI [n].min [2] = atof(argv [++i]);
364 >                        pmapROI [n].max [0] = atof(argv [++i]);
365 >                        pmapROI [n].max [1] = atof(argv [++i]);
366 >                        pmapROI [n].max [2] = atof(argv [++i]);                        
367 >                        for (j = 0; j < 3; j++)
368 >                           if (pmapROI [n].min [j] >= pmapROI [n].max [j])
369 >                              error(USER, "invalid region of interest "
370 >                                    "(swapped min/max?)");
371 >                        break;
372 > #endif            
373 >
374 >                     case 'P': /* Global photon precomp ratio */
375 >                        check(4, "f");
376 >                        finalGather = atof(argv [++i]);
377 >                        if (finalGather <= 0 || finalGather > 1)
378 >                           error(USER, "global photon precomputation ratio "
379 >                                 "must be in range ]0, 1]");
380 >                        break;
381 >                    
382 >                     case 'o': /* Photon port */
383 >                     case 'O':
384 >                        /* Check for bad arg and length, taking into account
385 >                         * default forward orientation if none specified, in
386 >                         * order to maintain previous behaviour */
387 >                        check(argv [i][4] ? 5 : 4, "s");
388 >                        /* Get port orientation flags */
389 >                        check_tri(
390 >                           4, PMAP_PORTFWD, PMAP_PORTBWD, portFlags [0]
391 >                        );
392 >                        
393 >                        if (argv [i][3] == 'O') {      
394 >                           /* Add port modifiers from file */
395 >                           rval = wordfile(
396 >                              portLp, MAXSET - (portLp - photonPortList),
397 >                              getpath(argv [++i], getrlibpath(), R_OK)
398 >                           );
399 >                           if (rval < 0) {
400 >                               sprintf(
401 >                                  errmsg, "cannot open photon port file %s",
402 >                                  argv [i]
403 >                               );
404 >                               error(SYSTEM, errmsg);
405 >                           }
406 >                           /* HACK: append port orientation flags to every
407 >                            * modifier; note this requires reallocation */
408 >                           for (; rval--; portLp++) {
409 >                              j = strlen(*portLp);
410 >                              if (!(*portLp = realloc(*portLp, j + 2))) {
411 >                                  sprintf(
412 >                                     errmsg,
413 >                                     "cannot allocate photon port modifiers"
414 >                                     " from file %s", argv [i]
415 >                                  );
416 >                                  error(SYSTEM, errmsg);
417 >                              }
418 >                              strcat(*portLp, portFlags);
419 >                           }
420 >                        }
421 >                        else {
422 >                           /* Append port flags to port modifier, add to
423 >                            * port list and mark of end list with NULL */
424 >                           strcpy(sbuf, argv [++i]);
425 >                           strcat(sbuf, portFlags);
426 >                           *portLp++ = savqstr(sbuf);
427 >                           *portLp = NULL;
428 >                        }
429 >                        break;
430 >                    
431 >                     case 'r': /* Random seed */
432 >                        check(4, "i");
433 >                        randSeed = atoi(argv [++i]);
434 >                        break;                  
435 >
436 >                     case 's': /* Antimatter sensor */
437 >                     case 'S':
438 >                        check(4, "s");
439 >                        if (argv[i][3] == 'S') {        
440 >                           /* Add sensor modifiers from file */
441 >                           rval = wordfile(sensLp,
442 >                                           MAXSET - (sensLp - photonSensorList),
443 >                                           getpath(argv [++i],
444 >                                           getrlibpath(), R_OK));
445 >                           if (rval < 0) {
446 >                               sprintf(errmsg,
447 >                                       "cannot open antimatter sensor file %s",
448 >                                       argv [i]);
449 >                               error(SYSTEM, errmsg);
450 >                           }
451 >                           sensLp += rval;
452 >                        }
453 >                        else {
454 >                           /* Append modifier to sensor list, mark end with
455 >                            * NULL */
456 >                           *sensLp++ = savqstr(argv [++i]);
457 >                           *sensLp = NULL;
458 >                        }
459 >                        break;
460 >
461 >                     default: goto badopt;
462                    }
463 +                  break;
464                    
465 <                  sensLp += rval;
353 <               }
354 <              
355 <               else {
356 <                  /* Append modifier to sensor list */
357 <                  *sensLp++ = argv [++i];
358 <                  *sensLp = NULL;
359 <               }
465 >               default: goto badopt;
466              }
361
362            else goto badopt;                  
467              break;
468 <                  
469 <         case 'b':
468 >                
469 >         case 'b': /* Back face visibility */
470              if (argv [i][2] == 'v') {
367               /* Back face visibility */
471                 check_bool(3, backvis);
472              }
370                  
473              else goto badopt;
474              break;
475                    
# Line 392 | Line 494 | int main (int argc, char* argv [])
494              diagFile = argv [++i];
495              break;
496                    
497 <         case 'f':
497 >         case 'f': /* Force overwrite */
498              if (argv [i][2] == 'o') {
397               /* Force overwrite */
499                 check_bool(3, clobber);
500              }
400                  
501              else goto badopt;
502              break;
503  
504 + #ifdef PMAP_EKSPERTZ
505 +         case 'l': /* Limits */
506 +            switch (argv [i][2]) {
507 +               case 'd': /* Limit photon path distance */
508 +                  check(3, "f");
509 +                  photonMaxDist = atof(argv [++i]);
510 +                  if (photonMaxDist <= 0)
511 +                     error(USER, "max photon distance must be > 0");
512 +                  break;
513 +                
514 +               case 'r': /* Limit photon bounces */              
515 +                  check(3, "i");              
516 +                  photonMaxBounce = atol(argv [++i]);
517 +                  if (photonMaxBounce <= 0)
518 +                     error(USER, "max photon bounces must be > 0");
519 +                  break;
520 +              
521 +               default: goto badopt;
522 +            }
523 +            break;
524 + #endif
525 +
526           case 'm': /* Medium */
527              switch (argv[i][2]) {
528                 case 'e':        /* Eggs-tinction coefficient */
# Line 425 | Line 547 | int main (int argc, char* argv [])
547                 default: goto badopt;
548              }                  
549              break;
550 +            
551   #if NIX
552           case 'n': /* Num parallel processes (NIX only) */
553              check(2, "i");
# Line 437 | Line 560 | int main (int argc, char* argv [])
560                 error(WARNING, errmsg);
561              }            
562              break;                  
563 < #endif                        
563 > #endif
564 >
565           case 't': /* Timer */
566              check(2, "i");
567              photonRepTime = atoi(argv [++i]);
# Line 445 | Line 569 | int main (int argc, char* argv [])
569              
570           case 'v':   /* Verbosity */
571              check_bool(2, verbose);
572 <            break;            
572 >            break;
573 >            
574   #ifdef EVALDRC_HACK
575           case 'A':   /* Angular source file */
576              check(2,"s");
577              angsrcfile = argv[++i];
578              break;                  
579 < #endif                              
580 <         default: goto badopt;
579 > #endif
580 >
581 >        default: goto badopt;
582        }
583     }
584    

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines