1 |
+ |
#ifndef lint |
2 |
+ |
static const char RCSid[] = "$Id$"; |
3 |
+ |
#endif |
4 |
+ |
|
5 |
|
/* |
6 |
< |
================================================================== |
6 |
> |
====================================================================== |
7 |
|
Photon map generator |
8 |
|
|
9 |
|
Roland Schregle (roland.schregle@{hslu.ch, gmail.com}) |
10 |
|
(c) Fraunhofer Institute for Solar Energy Systems, |
11 |
|
Lucerne University of Applied Sciences & Arts |
12 |
< |
================================================================== |
12 |
> |
(c) Lucerne University of Applied Sciences and Arts, |
13 |
> |
supported by the Swiss National Science Foundation (SNSF, #147053) |
14 |
> |
====================================================================== |
15 |
|
|
16 |
|
$Id$ |
17 |
|
*/ |
35 |
|
|
36 |
|
|
37 |
|
|
38 |
< |
char* progname; /* argv[0] */ |
39 |
< |
int dimlist [MAXDIM]; /* sampling dimensions */ |
40 |
< |
int ndims = 0; /* number of sampling dimenshunns */ |
41 |
< |
char* octname = NULL; /* octree name */ |
42 |
< |
CUBE thescene; /* scene top-level octree */ |
43 |
< |
OBJECT nsceneobjs; /* number of objects in scene */ |
44 |
< |
double srcsizerat = 0.01; /* source partition size ratio */ |
45 |
< |
int backvis = 1; /* back face visibility */ |
46 |
< |
int clobber = 0; /* overwrite output */ |
47 |
< |
COLOR cextinction = BLKCOLOR; /* global extinction coefficient */ |
48 |
< |
COLOR salbedo = BLKCOLOR; /* global scattering albedo */ |
49 |
< |
double seccg = 0; /* global scattering eccentricity */ |
50 |
< |
int ambincl = -1; /* photon port flag */ |
51 |
< |
char *amblist [AMBLLEN + 1]; /* photon port list */ |
52 |
< |
char *diagFile = NULL; /* diagnostics output file */ |
53 |
< |
int rand_samp = 1; /* uncorrelated random sampling */ |
38 |
> |
char* progname; /* argv[0] */ |
39 |
> |
int dimlist [MAXDIM]; /* sampling dimensions */ |
40 |
> |
int ndims = 0; /* number of sampling dimenshunns */ |
41 |
> |
char* octname = NULL; /* octree name */ |
42 |
> |
CUBE thescene; /* scene top-level octree */ |
43 |
> |
OBJECT nsceneobjs; /* number of objects in scene */ |
44 |
> |
double srcsizerat = 0.01; /* source partition size ratio */ |
45 |
> |
int backvis = 1; /* back face visibility */ |
46 |
> |
int clobber = 0; /* overwrite output */ |
47 |
> |
COLOR cextinction = BLKCOLOR; /* global extinction coefficient */ |
48 |
> |
COLOR salbedo = BLKCOLOR; /* global scattering albedo */ |
49 |
> |
double seccg = 0; /* global scattering eccentricity */ |
50 |
> |
int ambincl = -1; /* photon port flag */ |
51 |
> |
char *amblist [AMBLLEN + 1]; /* photon port list */ |
52 |
> |
char *diagFile = NULL; /* diagnostics output file */ |
53 |
> |
int rand_samp = 1; /* uncorrelated random sampling */ |
54 |
> |
unsigned nproc = 1; /* number of parallel processes */ |
55 |
> |
#ifdef EVALDRC_HACK |
56 |
> |
char *angsrcfile = NULL; /* angular source file for EvalDRC */ |
57 |
> |
#endif |
58 |
|
|
59 |
|
|
60 |
+ |
|
61 |
|
/* Dummies for linkage */ |
62 |
|
|
63 |
|
COLOR ambval = BLKCOLOR; |
103 |
|
printf("-e %s\t\t\t# diagnostics output file\n", diagFile); |
104 |
|
printf(clobber ? "-fo+\t\t\t\t# force overwrite" |
105 |
|
: "-fo-\t\t\t\t# do not overwrite\n"); |
106 |
+ |
#if 0 |
107 |
+ |
/* Heap size increment now fixed & defined by macro in pmapkdt.c */ |
108 |
|
printf("-i %-9ld\t\t\t# photon heap size increment\n", |
109 |
|
photonHeapSizeInc); |
110 |
+ |
#endif |
111 |
|
printf("-ma %.2f %.2f %.2f\t\t# scattering albedo\n", |
112 |
|
colval(salbedo,RED), colval(salbedo,GRN), colval(salbedo,BLU)); |
113 |
|
printf("-me %.2e %.2e %.2e\t# extinction coefficient\n", |
114 |
|
colval(cextinction,RED), colval(cextinction,GRN), |
115 |
|
colval(cextinction,BLU)); |
116 |
|
printf("-mg %.2f\t\t\t# scattering eccentricity\n", seccg); |
117 |
+ |
printf("-n %d\t\t\t\t# number of parallel processes\n", nproc); |
118 |
|
printf("-t %-9d\t\t\t# time between reports\n", photonRepTime); |
119 |
|
|
120 |
|
#ifdef PMAP_ROI |
123 |
|
pmapROI [0], pmapROI [1], pmapROI [2], pmapROI [3], |
124 |
|
pmapROI [4], pmapROI [5]); |
125 |
|
#endif |
126 |
+ |
|
127 |
+ |
#ifdef EVALDRC_HACK |
128 |
+ |
/* ... and ziss one... */ |
129 |
+ |
puts("-A\t\t\t\t# angular source file"); |
130 |
+ |
#endif |
131 |
|
} |
132 |
|
|
133 |
|
|
317 |
|
|
318 |
|
if (argv[i][3] == 'O') { |
319 |
|
/* Get port modifiers file */ |
320 |
< |
rval = wordfile(portLp, getpath(argv [++i], |
321 |
< |
getrlibpath(), R_OK)); |
320 |
> |
rval = wordfile(portLp, AMBLLEN-(portLp-amblist), |
321 |
> |
getpath(argv [++i], getrlibpath(), R_OK)); |
322 |
> |
|
323 |
|
if (rval < 0) { |
324 |
|
sprintf(errmsg, "cannot open photon port file %s", |
325 |
|
argv [i]); |
349 |
|
|
350 |
|
if (argv[i][3] == 'S') { |
351 |
|
/* Get sensor modifiers from file */ |
352 |
< |
rval = wordfile(sensLp, getpath(argv [++i], |
353 |
< |
getrlibpath(), R_OK)); |
352 |
> |
rval = wordfile(sensLp, MAXSET-(sensLp-photonSensorList), |
353 |
> |
getpath(argv [++i], getrlibpath(), R_OK)); |
354 |
> |
|
355 |
|
if (rval < 0) { |
356 |
|
sprintf(errmsg, "cannot open antimatter sensor file %s", |
357 |
|
argv [i]); |
409 |
|
|
410 |
|
else goto badopt; |
411 |
|
break; |
412 |
< |
|
412 |
> |
|
413 |
> |
#if 0 |
414 |
> |
/* Heap size increment now fixed & defined by macro in pmapkdt.c */ |
415 |
|
case 'i': /* Photon heap size increment */ |
416 |
|
check(2, "i"); |
417 |
|
photonHeapSizeInc = atol(argv [++i]); |
418 |
|
break; |
419 |
+ |
#endif |
420 |
|
|
421 |
|
case 'm': /* Medium */ |
422 |
|
switch (argv[i][2]) { |
442 |
|
default: goto badopt; |
443 |
|
} |
444 |
|
break; |
445 |
< |
|
445 |
> |
|
446 |
> |
case 'n': /* Num parallel processes */ |
447 |
> |
check(2, "i"); |
448 |
> |
nproc = atoi(argv [++i]); |
449 |
> |
|
450 |
> |
if (nproc > PMAP_MAXPROC) { |
451 |
> |
nproc = PMAP_MAXPROC; |
452 |
> |
sprintf(errmsg, "too many parallel processes, clamping to " |
453 |
> |
"%d\n", nproc); |
454 |
> |
error(WARNING, errmsg); |
455 |
> |
} |
456 |
> |
|
457 |
> |
break; |
458 |
> |
|
459 |
|
case 't': /* Timer */ |
460 |
|
check(2, "i"); |
461 |
|
photonRepTime = atoi(argv [++i]); |
462 |
|
break; |
463 |
+ |
|
464 |
+ |
#ifdef EVALDRC_HACK |
465 |
+ |
case 'A': /* Angular source file */ |
466 |
+ |
check(2,"s"); |
467 |
+ |
angsrcfile = argv[++i]; |
468 |
+ |
break; |
469 |
+ |
#endif |
470 |
|
|
471 |
|
default: goto badopt; |
472 |
|
} |
507 |
|
error(USER, "no photon maps specified"); |
508 |
|
|
509 |
|
readoct(octname, loadflags, &thescene, NULL); |
510 |
+ |
|
511 |
+ |
#ifdef EVALDRC_HACK |
512 |
+ |
if (angsrcfile) |
513 |
+ |
readobj(angsrcfile); /* load angular sources */ |
514 |
+ |
#endif |
515 |
+ |
|
516 |
|
nsceneobjs = nobjects; |
517 |
|
|
518 |
|
/* Get sources */ |
521 |
|
/* Do forward pass and build photon maps */ |
522 |
|
if (contribPmap) |
523 |
|
/* Just build contrib pmap, ignore others */ |
524 |
< |
distribPhotonContrib(contribPmap); |
524 |
> |
distribPhotonContrib(contribPmap, nproc); |
525 |
|
else |
526 |
< |
distribPhotons(photonMaps); |
526 |
> |
distribPhotons(photonMaps, nproc); |
527 |
|
|
528 |
|
/* Save photon maps; no idea why GCC needs an explicit cast here... */ |
529 |
|
savePmaps((const PhotonMap**)photonMaps, argc, argv); |