1 |
greg |
2.1 |
/* |
2 |
|
|
================================================================== |
3 |
rschregle |
2.3 |
Parameters for photon map generation; used by MKPMAP |
4 |
|
|
For inclusion in mkpmap.c |
5 |
greg |
2.1 |
|
6 |
|
|
Roland Schregle (roland.schregle@{hslu.ch, gmail.com} |
7 |
|
|
(c) Fraunhofer Institute for Solar Energy Systems, |
8 |
rschregle |
2.2 |
(c) Lucerne University of Applied Sciences and Arts, |
9 |
|
|
supported by the Swiss National Science Foundation (SNSF, #147053) |
10 |
greg |
2.1 |
================================================================== |
11 |
|
|
|
12 |
rschregle |
2.4 |
$Id: pmapparm.c,v 2.3 2015/05/26 12:32:21 rschregle Exp $ |
13 |
greg |
2.1 |
*/ |
14 |
|
|
|
15 |
|
|
|
16 |
|
|
#include "pmapparm.h" |
17 |
|
|
#include "pmapdata.h" |
18 |
|
|
#include "standard.h" |
19 |
|
|
#include <ctype.h> |
20 |
|
|
|
21 |
|
|
|
22 |
|
|
float pdfSamples = 1000, /* PDF samples per steradian */ |
23 |
|
|
finalGather = 0.25, /* fraction of global photons for |
24 |
|
|
irradiance precomputation */ |
25 |
|
|
preDistrib = 0.25, /* fraction of num photons for |
26 |
|
|
distribution prepass */ |
27 |
|
|
gatherTolerance = 0.5, /* Photon map lookup tolerance; |
28 |
|
|
lookups returning fewer than this |
29 |
|
|
fraction of minGather/maxGather |
30 |
|
|
are restarted with a larger |
31 |
|
|
search radius */ |
32 |
rschregle |
2.4 |
maxDistFix = 0; /* Static maximum photon search |
33 |
|
|
radius (radius is adaptive if |
34 |
|
|
this is zero) */ |
35 |
greg |
2.1 |
|
36 |
|
|
#ifdef PMAP_ROI |
37 |
|
|
/* Region of interest bbox: {xmin, xmax, ymin, ymax, zmin, zmax} */ |
38 |
|
|
float pmapROI [6] = {-FHUGE, FHUGE, -FHUGE, FHUGE, -FHUGE, FHUGE}; |
39 |
|
|
#endif |
40 |
|
|
|
41 |
|
|
unsigned long photonHeapSizeInc = 1000, /* Photon heap size increment */ |
42 |
|
|
photonMaxBounce = 5000; /* Runaway photon bounce limit */ |
43 |
|
|
|
44 |
|
|
unsigned photonRepTime = 0, /* Seconds between reports */ |
45 |
|
|
maxPreDistrib = 4, /* Max predistrib passes */ |
46 |
|
|
defaultGather = 40; /* Default num photons for lookup */ |
47 |
|
|
|
48 |
|
|
/* Per photon map params */ |
49 |
|
|
PhotonMapParams pmapParams [NUM_PMAP_TYPES] = { |
50 |
|
|
{NULL, 0, 0, 0}, {NULL, 0, 0, 0}, {NULL, 0, 0, 0}, {NULL, 0, 0, 0}, |
51 |
|
|
{NULL, 0, 0, 0}, {NULL, 0, 0, 0} |
52 |
|
|
}; |
53 |
|
|
|
54 |
|
|
|
55 |
|
|
int setPmapParam (PhotonMap** pm, const PhotonMapParams* parm) |
56 |
|
|
{ |
57 |
|
|
if (parm && parm -> fileName) { |
58 |
|
|
if (!(*pm = (PhotonMap*)malloc(sizeof(PhotonMap)))) |
59 |
|
|
error(INTERNAL, "failed to allocate photon map"); |
60 |
|
|
|
61 |
|
|
(*pm) -> fileName = parm -> fileName; |
62 |
|
|
(*pm) -> minGather = parm -> minGather; |
63 |
|
|
(*pm) -> maxGather = parm -> maxGather; |
64 |
|
|
(*pm) -> distribTarget = parm -> distribTarget; |
65 |
|
|
(*pm) -> heapSizeInc = photonHeapSizeInc; |
66 |
|
|
(*pm) -> maxDist0 = FHUGE; |
67 |
|
|
(*pm) -> srcContrib = NULL; |
68 |
|
|
|
69 |
|
|
return 1; |
70 |
|
|
} |
71 |
|
|
|
72 |
|
|
return 0; |
73 |
|
|
} |
74 |
|
|
|
75 |
|
|
|
76 |
|
|
unsigned long parseMultiplier (const char *num) |
77 |
|
|
{ |
78 |
|
|
unsigned long mult = 1; |
79 |
|
|
const int strEnd = strlen(num) - 1; |
80 |
|
|
|
81 |
|
|
if (strEnd <= 0) |
82 |
|
|
return 0; |
83 |
|
|
|
84 |
|
|
if (!isdigit(num [strEnd])) |
85 |
|
|
switch (toupper(num [strEnd])) { |
86 |
|
|
case 'G': mult *= 1000; |
87 |
|
|
case 'M': mult *= 1000; |
88 |
|
|
case 'K': mult *= 1000; |
89 |
|
|
break; |
90 |
|
|
default : error(USER, "unknown multiplier"); |
91 |
|
|
} |
92 |
|
|
|
93 |
|
|
return (unsigned long)(mult * atof(num)); |
94 |
|
|
} |