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.8 by rschregle, Fri Feb 2 19:47:55 2018 UTC vs.
Revision 2.9 by rschregle, Tue Mar 20 19:55:33 2018 UTC

# Line 20 | Line 20 | static const char RCSid[] = "$Id$";
20  
21   #include "pmap.h"
22   #include "pmapmat.h"
23 + #include "pmapsrc.h"
24   #include "pmapcontrib.h"
25   #include "pmaprand.h"
26   #include "paths.h"
# Line 49 | Line 50 | int      clobber = 0;               /* overwrite outpu
50   COLOR    cextinction = BLKCOLOR;    /* global extinction coefficient */
51   COLOR    salbedo = BLKCOLOR;        /* global scattering albedo */
52   double   seccg = 0;                 /* global scattering eccentricity */
53 < int      ambincl = -1;              /* photon port flag */
54 < char     *amblist [AMBLLEN + 1];    /* photon port list */
53 > char     *amblist [AMBLLEN + 1];    /* ambient include/exclude list */
54 > int      ambincl = -1;              /* include == 1, exclude == 0 */
55   char     *diagFile = NULL;          /* diagnostics output file */
56   int      rand_samp = 1;             /* uncorrelated random sampling */
57   unsigned nproc = 1;                 /* number of parallel processes */
# Line 80 | Line 81 | void printdefaults()
81     /* EvalDRC support */
82     puts("-A\t\t\t\t# angular source file");
83   #endif    
84 +   puts("-ae  mod\t\t\t\t# exclude modifier");
85 +   puts("-aE  file\t\t\t\t# exclude modifiers from file");
86 +   puts("-ai  mod\t\t\t\t# include modifier");
87 +   puts("-aI  file\t\t\t\t# include modifiers from file");
88   #ifdef PMAP_EKSPERTZ
89     puts("-api xmin ymin zmin xmax ymax zmax\t# region of interest");
90   #endif
# Line 96 | Line 101 | void printdefaults()
101     printf("-apm %ld\t\t\t\t# limit photon bounces\n", photonMaxBounce);
102   #endif
103     puts("-apo mod\t\t\t\t# photon port modifier");
104 <   puts("-apO file\t\t\t\t# photon port file");
104 >   puts("-apO file\t\t\t\t# photon ports from file");
105     printf("-apP %f\t\t\t\t# precomputation factor\n", finalGather);
106     printf("-apr %d\t\t\t\t\t# random seed\n", randSeed);
107     puts("-aps mod\t\t\t\t# antimatter sensor modifier");
108 <   puts("-apS file\t\t\t\t# antimatter sensor file");
108 >   puts("-apS file\t\t\t\t# antimatter sensors from file");
109  
110     printf(backvis ? "-bv+\t\t\t\t\t# back face visibility on\n"
111                    : "-bv-\t\t\t\t\t# back face visibility off\n");
# Line 145 | Line 150 | int main (int argc, char* argv [])
150                               default: goto badopt; \
151                            }  
152  
153 <   int loadflags = IO_CHECK | IO_SCENE | IO_TREE | IO_BOUNDS, rval, i;
154 <   char **portLp = NULL, **sensLp = photonSensorList;
153 >   int loadflags = IO_CHECK | IO_SCENE | IO_TREE | IO_BOUNDS, rval, i, j, n;
154 >   char **portLp = photonPortList, **sensLp = photonSensorList,
155 >        **amblp = NULL;
156     struct stat pmstat;
157  
158     /* Global program name */
# Line 183 | Line 189 | int main (int argc, char* argv [])
189        }
190              
191        switch (argv [i][1]) {
192 <         case 'a':
193 <            if (!strcmp(argv [i] + 2, "pg")) {
194 <               /* Global photon map */
195 <               check(4, "ss");
196 <               globalPmapParams.fileName = argv [++i];
197 <               globalPmapParams.distribTarget =
198 <                  parseMultiplier(argv [++i]);
199 <               if (!globalPmapParams.distribTarget)
200 <                  goto badopt;                        
201 <               globalPmapParams.minGather = globalPmapParams.maxGather = 0;
202 <            }                              
192 >         case 'a': /* Ambient */
193 >            switch (argv [i][2]) {
194 >               case 'i': /* Ambient include */
195 >               case 'I':
196 >                  check(3, "s");
197 >                  if (ambincl != 1) {
198 >                     ambincl = 1;
199 >                     amblp = amblist;
200 >                  }
201 >                  if (argv [i][2] == 'I') {    
202 >                     /* Add modifiers from file */
203 >                     rval = wordfile(amblp, AMBLLEN - (amblp - amblist),
204 >                                     getpath(argv [++i],
205 >                                     getrlibpath(), R_OK));
206 >                     if (rval < 0) {
207 >                        sprintf(errmsg,
208 >                                "cannot open ambient include file \"%s\"",
209 >                                argv [i]);
210 >                        error(SYSTEM, errmsg);
211 >                     }
212 >                     amblp += rval;
213 >                  }
214 >                  else {
215 >                     /* Add modifier from next arg */
216 >                     *amblp++ = savqstr(argv [++i]);
217 >                     *amblp = NULL;
218 >                  }
219 >                  break;
220 >
221 >               case 'e': /* Ambient exclude */
222 >               case 'E':
223 >                  check(3, "s");
224 >                  if (ambincl != 0) {
225 >                     ambincl = 0;
226 >                     amblp = amblist;
227 >                  }
228 >                  if (argv [i][2] == 'E') {
229 >                     /* Add modifiers from file */
230 >                     rval = wordfile(amblp, AMBLLEN - (amblp - amblist),
231 >                                     getpath(argv [++i],
232 >                                     getrlibpath(), R_OK));
233 >                     if (rval < 0) {
234 >                        sprintf(errmsg,
235 >                                "cannot open ambient exclude file \"%s\"",
236 >                                argv [i]);
237 >                        error(SYSTEM, errmsg);
238 >                     }
239 >                     amblp += rval;
240 >                  }
241 >                  else {
242 >                     /* Add modifier from next arg */
243 >                     *amblp++ = savqstr(argv [++i]);
244 >                     *amblp = NULL;
245 >                  }
246 >                  break;
247              
248 <            else if (!strcmp(argv [i] + 2, "pp")) {
249 <               /* Precomputed global photon map */
250 <               check(4, "ssi");
251 <               preCompPmapParams.fileName = argv [++i];
252 <               preCompPmapParams.distribTarget =
253 <                  parseMultiplier(argv [++i]);
254 <               if (!preCompPmapParams.distribTarget)
255 <                  goto badopt;
256 <               preCompPmapParams.minGather = preCompPmapParams.maxGather =
257 <                  atoi(argv [++i]);
258 <               if (!preCompPmapParams.maxGather)
259 <                  goto badopt;
210 <            }
248 >               case 'p': /* Pmap-specific */
249 >                  switch (argv [i][3]) {                        
250 >                     case 'g': /* Global photon map */
251 >                        check(4, "ss");
252 >                        globalPmapParams.fileName = argv [++i];
253 >                        globalPmapParams.distribTarget =
254 >                           parseMultiplier(argv [++i]);
255 >                        if (!globalPmapParams.distribTarget)
256 >                           goto badopt;                        
257 >                        globalPmapParams.minGather =
258 >                           globalPmapParams.maxGather = 0;
259 >                        break;
260              
261 <            else if (!strcmp(argv [i] + 2, "pc")) {
262 <               /* Caustic photon map */
263 <               check(4, "ss");
264 <               causticPmapParams.fileName = argv [++i];
265 <               causticPmapParams.distribTarget =
266 <                  parseMultiplier(argv [++i]);
267 <               if (!causticPmapParams.distribTarget)
268 <                  goto badopt;
269 <            }
261 >                     case 'p': /* Precomputed global photon map */
262 >                        check(4, "ssi");
263 >                        preCompPmapParams.fileName = argv [++i];
264 >                        preCompPmapParams.distribTarget =
265 >                           parseMultiplier(argv [++i]);
266 >                        if (!preCompPmapParams.distribTarget)
267 >                           goto badopt;
268 >                        preCompPmapParams.minGather =
269 >                           preCompPmapParams.maxGather = atoi(argv [++i]);
270 >                        if (!preCompPmapParams.maxGather)
271 >                           goto badopt;
272 >                        break;
273              
274 <            else if (!strcmp(argv [i] + 2, "pv")) {
275 <               /* Volume photon map */
276 <               check(4, "ss");
277 <               volumePmapParams.fileName = argv [++i];
278 <               volumePmapParams.distribTarget =
279 <                  parseMultiplier(argv [++i]);
280 <               if (!volumePmapParams.distribTarget)
281 <                  goto badopt;                      
282 <            }
283 <            
284 <            else if (!strcmp(argv [i] + 2, "pd")) {
285 <               /* Direct photon map */
286 <               check(4, "ss");
287 <               directPmapParams.fileName = argv [++i];
288 <               directPmapParams.distribTarget =
289 <                  parseMultiplier(argv [++i]);
290 <               if (!directPmapParams.distribTarget)
291 <                  goto badopt;
292 <            }
293 <            
294 <            else if (!strcmp(argv [i] + 2, "pC")) {
295 <               /* Light source contribution photon map */
296 <               check(4, "ss");
297 <               contribPmapParams.fileName = argv [++i];
298 <               contribPmapParams.distribTarget =
299 <                  parseMultiplier(argv [++i]);
300 <               if (!contribPmapParams.distribTarget)
301 <                  goto badopt;
302 <            }
274 >                     case 'c': /* Caustic photon map */
275 >                        check(4, "ss");
276 >                        causticPmapParams.fileName = argv [++i];
277 >                        causticPmapParams.distribTarget =
278 >                           parseMultiplier(argv [++i]);
279 >                        if (!causticPmapParams.distribTarget)
280 >                           goto badopt;
281 >                        break;
282 >                  
283 >                     case 'v': /* Volume photon map */
284 >                        check(4, "ss");
285 >                        volumePmapParams.fileName = argv [++i];
286 >                        volumePmapParams.distribTarget =
287 >                           parseMultiplier(argv [++i]);
288 >                        if (!volumePmapParams.distribTarget)
289 >                           goto badopt;                      
290 >                        break;
291 >                    
292 >                     case 'd': /* Direct photon map */
293 >                        check(4, "ss");
294 >                        directPmapParams.fileName = argv [++i];
295 >                        directPmapParams.distribTarget =
296 >                           parseMultiplier(argv [++i]);
297 >                        if (!directPmapParams.distribTarget)
298 >                           goto badopt;
299 >                        break;
300 >                    
301 >                     case 'C': /* Contribution photon map */
302 >                        check(4, "ss");
303 >                        contribPmapParams.fileName = argv [++i];
304 >                        contribPmapParams.distribTarget =
305 >                           parseMultiplier(argv [++i]);
306 >                        if (!contribPmapParams.distribTarget)
307 >                           goto badopt;
308 >                        break;
309  
310 <            else if (!strcmp(argv [i] + 2, "pD")) {
311 <               /* Predistribution factor */
312 <               check(4, "f");
313 <               preDistrib = atof(argv [++i]);
314 <               if (preDistrib <= 0)
315 <                  error(USER, "predistribution factor must be > 0");
258 <            }
310 >                     case 'D': /* Predistribution factor */
311 >                        check(4, "f");
312 >                        preDistrib = atof(argv [++i]);
313 >                        if (preDistrib <= 0)
314 >                           error(USER, "predistrib factor must be > 0");
315 >                        break;
316  
317 <            else if (!strcmp(argv [i] + 2, "pM")) {
318 <               /* Max predistribution passes */
319 <               check(4, "i");
320 <               maxPreDistrib = atoi(argv [++i]);
321 <               if (maxPreDistrib <= 0)
322 <                  error(USER, "max predistribution passes must be > 0");
323 <            }
317 >                     case 'M': /* Max predistribution passes */
318 >                        check(4, "i");
319 >                        maxPreDistrib = atoi(argv [++i]);
320 >                        if (maxPreDistrib <= 0)
321 >                           error(USER, "max predistrib passes must be > 0");
322 >                        break;
323 >
324   #if 1
325 <            /* Kept for backwards compat, to be phased out by -lr */
326 <            else if (!strcmp(argv [i] + 2, "pm")) {
327 <               /* Max photon bounces */
328 <               check(4, "i");              
329 <               photonMaxBounce = atol(argv [++i]);
330 <               if (photonMaxBounce <= 0)
331 <                  error(USER, "max photon bounces must be > 0");
275 <            }            
325 >                     /* Kept for backwards compat, to be phased out by -lr */
326 >                     case 'm': /* Max photon bounces */
327 >                        check(4, "i");
328 >                        photonMaxBounce = atol(argv [++i]);
329 >                        if (photonMaxBounce <= 0)
330 >                           error(USER, "max photon bounces must be > 0");
331 >                        break;
332   #endif
333 < #ifdef PMAP_EKSPERTZ
334 <            /* Add region of interest; for Ze Ekspertz only! */
335 <            else if (!strcmp(argv [i] + 2, "pi")) {
336 <               unsigned j, n = pmapNumROI;
337 <               check(4, "ffffff");
338 <              
339 <               pmapROI = realloc(pmapROI,
340 <                                 ++pmapNumROI * sizeof(PhotonMapROI));
341 <               if (!pmapROI)
342 <                  error(SYSTEM, "failed to allocate ROI");
343 <                  
344 <               pmapROI [n].min [0] = atof(argv [++i]);
345 <               pmapROI [n].min [1] = atof(argv [++i]);
346 <               pmapROI [n].min [2] = atof(argv [++i]);
347 <               pmapROI [n].max [0] = atof(argv [++i]);
348 <               pmapROI [n].max [1] = atof(argv [++i]);
349 <               pmapROI [n].max [2] = atof(argv [++i]);
350 <              
351 <               for (j = 0; j < 3; j++)
352 <                  if (pmapROI [n].min [j] >= pmapROI [n].max [j])
297 <                     error(USER,
298 <                           "invalid region of interest (swapped min/max?)");
299 <            }
333 >
334 > #ifdef PMAP_EKSPERTZ                    
335 >                     case 'i': /* Add region of interest */
336 >                        check(4, "ffffff");                        
337 >                        n = pmapNumROI;
338 >                        pmapROI = realloc(pmapROI,
339 >                                          ++pmapNumROI * sizeof(PhotonMapROI));
340 >                        if (!pmapROI)
341 >                           error(SYSTEM, "failed to allocate ROI");
342 >                        pmapROI [n].min [0] = atof(argv [++i]);
343 >                        pmapROI [n].min [1] = atof(argv [++i]);
344 >                        pmapROI [n].min [2] = atof(argv [++i]);
345 >                        pmapROI [n].max [0] = atof(argv [++i]);
346 >                        pmapROI [n].max [1] = atof(argv [++i]);
347 >                        pmapROI [n].max [2] = atof(argv [++i]);                        
348 >                        for (j = 0; j < 3; j++)
349 >                           if (pmapROI [n].min [j] >= pmapROI [n].max [j])
350 >                              error(USER, "invalid region of interest "
351 >                                    "(swapped min/max?)");
352 >                        break;
353   #endif            
301            else if (!strcmp(argv [i] + 2, "pP")) {
302               /* Global photon precomputation factor */
303               check(4, "f");
304               finalGather = atof(argv [++i]);
305               if (finalGather <= 0 || finalGather > 1)
306                  error(USER, "global photon precomputation factor "
307                        "must be in range ]0, 1]");
308            }                  
309            
310            else if (!strcmp(argv [i] + 2, "po") ||
311                     !strcmp(argv [i] + 2, "pO")) {
312               /* Photon port */
313               check(4, "s");
314              
315               if (ambincl != 1) {
316                  ambincl = 1;
317                  portLp = amblist;
318               }
319              
320               if (argv[i][3] == 'O') {
321                  /* Get port modifiers from file */
322                  rval = wordfile(portLp, AMBLLEN-(portLp-amblist),
323                                  getpath(argv [++i], getrlibpath(), R_OK));
324                                  
325                  if (rval < 0) {
326                      sprintf(errmsg, "cannot open photon port file %s",
327                              argv [i]);
328                      error(SYSTEM, errmsg);
329                  }
330                  
331                  portLp += rval;
332               }
333              
334               else {
335                  /* Append modifier to port list */
336                  *portLp++ = argv [++i];
337                  *portLp = NULL;
338               }
339            }
340            
341            else if (!strcmp(argv [i] + 2, "pr")) {
342               /* Random seed */
343               check(4, "i");
344               randSeed = atoi(argv [++i]);
345            }                  
354  
355 <            else if (!strcmp(argv [i] + 2, "ps") ||
356 <                     !strcmp(argv [i] + 2, "pS")) {
357 <               /* Antimatter sensor */
358 <               check(4, "s");
359 <              
360 <               if (argv[i][3] == 'S') {
361 <                  /* Get sensor modifiers from file */
362 <                  rval = wordfile(sensLp, MAXSET-(sensLp-photonSensorList),
363 <                                  getpath(argv [++i], getrlibpath(), R_OK));
364 <                                  
365 <                  if (rval < 0) {
366 <                      sprintf(errmsg, "cannot open antimatter sensor file %s",
367 <                              argv [i]);
368 <                      error(SYSTEM, errmsg);
355 >                     case 'P': /* Global photon precomp ratio */
356 >                        check(4, "f");
357 >                        finalGather = atof(argv [++i]);
358 >                        if (finalGather <= 0 || finalGather > 1)
359 >                           error(USER, "global photon precomputation ratio "
360 >                                 "must be in range ]0, 1]");
361 >                        break;
362 >                    
363 >                     case 'o': /* Photon port */
364 >                     case 'O':
365 >                        check(4, "s");
366 >                        if (argv [i][3] == 'O') {      
367 >                           /* Add port modifiers from file */
368 >                           rval = wordfile(portLp,
369 >                                           MAXSET - (portLp - photonPortList),
370 >                                           getpath(argv [++i],
371 >                                           getrlibpath(), R_OK));
372 >                           if (rval < 0) {
373 >                               sprintf(errmsg,
374 >                                       "cannot open photon port file %s",
375 >                                       argv [i]);
376 >                               error(SYSTEM, errmsg);
377 >                           }
378 >                           portLp += rval;
379 >                        }
380 >                        else {
381 >                           /* Add port modifier from next arg, mark end with
382 >                            * NULL */
383 >                           *portLp++ = savqstr(argv [++i]);
384 >                           *portLp = NULL;
385 >                        }
386 >                        break;
387 >                    
388 >                     case 'r': /* Random seed */
389 >                        check(4, "i");
390 >                        randSeed = atoi(argv [++i]);
391 >                        break;                  
392 >
393 >                     case 's': /* Antimatter sensor */
394 >                     case 'S':
395 >                        check(4, "s");
396 >                        if (argv[i][3] == 'S') {        
397 >                           /* Add sensor modifiers from file */
398 >                           rval = wordfile(sensLp,
399 >                                           MAXSET - (sensLp - photonSensorList),
400 >                                           getpath(argv [++i],
401 >                                           getrlibpath(), R_OK));
402 >                           if (rval < 0) {
403 >                               sprintf(errmsg,
404 >                                       "cannot open antimatter sensor file %s",
405 >                                       argv [i]);
406 >                               error(SYSTEM, errmsg);
407 >                           }
408 >                           sensLp += rval;
409 >                        }
410 >                        else {
411 >                           /* Append modifier to sensor list, mark end with
412 >                            * NULL */
413 >                           *sensLp++ = savqstr(argv [++i]);
414 >                           *sensLp = NULL;
415 >                        }
416 >                        break;
417 >
418 >                     default: goto badopt;
419                    }
420 +                  break;
421                    
422 <                  sensLp += rval;
364 <               }
365 <              
366 <               else {
367 <                  /* Append modifier to sensor list */
368 <                  *sensLp++ = argv [++i];
369 <                  *sensLp = NULL;
370 <               }
422 >               default: goto badopt;
423              }
372
373            else goto badopt;                  
424              break;
425 <                  
426 <         case 'b':
425 >                
426 >         case 'b': /* Back face visibility */
427              if (argv [i][2] == 'v') {
378               /* Back face visibility */
428                 check_bool(3, backvis);
429              }
381                  
430              else goto badopt;
431              break;
432                    
# Line 403 | Line 451 | int main (int argc, char* argv [])
451              diagFile = argv [++i];
452              break;
453                    
454 <         case 'f':
454 >         case 'f': /* Force overwrite */
455              if (argv [i][2] == 'o') {
408               /* Force overwrite */
456                 check_bool(3, clobber);
457              }
411                  
458              else goto badopt;
459              break;
460 +
461   #ifdef PMAP_EKSPERTZ
462           case 'l': /* Limits */
463              switch (argv [i][2]) {
# Line 432 | Line 479 | int main (int argc, char* argv [])
479              }
480              break;
481   #endif
482 +
483           case 'm': /* Medium */
484              switch (argv[i][2]) {
485                 case 'e':        /* Eggs-tinction coefficient */
# Line 456 | Line 504 | int main (int argc, char* argv [])
504                 default: goto badopt;
505              }                  
506              break;
507 +            
508   #if NIX
509           case 'n': /* Num parallel processes (NIX only) */
510              check(2, "i");
# Line 468 | Line 517 | int main (int argc, char* argv [])
517                 error(WARNING, errmsg);
518              }            
519              break;                  
520 < #endif                        
520 > #endif
521 >
522           case 't': /* Timer */
523              check(2, "i");
524              photonRepTime = atoi(argv [++i]);
# Line 476 | Line 526 | int main (int argc, char* argv [])
526              
527           case 'v':   /* Verbosity */
528              check_bool(2, verbose);
529 <            break;            
529 >            break;
530 >            
531   #ifdef EVALDRC_HACK
532           case 'A':   /* Angular source file */
533              check(2,"s");
534              angsrcfile = argv[++i];
535              break;                  
536 < #endif                              
537 <         default: goto badopt;
536 > #endif
537 >
538 >        default: goto badopt;
539        }
540     }
541    

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines