1 |
#ifndef lint |
2 |
static const char RCSid[] = "$Id$"; |
3 |
#endif |
4 |
/* |
5 |
================================================================== |
6 |
Photon map interface to RADIANCE render options |
7 |
|
8 |
Roland Schregle (roland.schregle@{hslu.ch, gmail.com}) |
9 |
(c) Fraunhofer Institute for Solar Energy Systems, |
10 |
(c) Lucerne University of Applied Sciences and Arts, |
11 |
supported by the Swiss National Science Foundation (SNSF, #147053) |
12 |
================================================================== |
13 |
|
14 |
$Id: pmapopt.c,v 2.5 2015/05/26 13:31:19 rschregle Exp $ |
15 |
*/ |
16 |
|
17 |
|
18 |
|
19 |
#include "ray.h" |
20 |
#include "pmapparm.h" |
21 |
|
22 |
|
23 |
|
24 |
int getPmapRenderOpt (int ac, char *av []) |
25 |
/* Parse next render option for photon map; interface to getrenderopt(); |
26 |
* return -1 if parsing failed, else number of parameters consumed */ |
27 |
{ |
28 |
#define check(ol,al) (av[0][ol] || badarg(ac-1,av+1,al)) |
29 |
|
30 |
static int t = -1; /* pmap parameter index */ |
31 |
|
32 |
if (ac < 1 || !av [0] || av [0][0] != '-') |
33 |
return -1; |
34 |
|
35 |
switch (av [0][1]) { |
36 |
case 'a': |
37 |
switch (av [0][2]) { |
38 |
case 'p': /* photon map */ |
39 |
/* Asking for photon map, ergo ambounce != 0 */ |
40 |
ambounce += (ambounce == 0); |
41 |
if (!check(3, "s")) { |
42 |
/* File -> assume bwidth = 1 or precomputed pmap */ |
43 |
if (++t >= NUM_PMAP_TYPES) |
44 |
error(USER, "too many photon maps"); |
45 |
|
46 |
pmapParams [t].fileName = savqstr(av [1]); |
47 |
pmapParams [t].minGather = pmapParams [t].maxGather = |
48 |
defaultGather; |
49 |
} |
50 |
else return -1; |
51 |
|
52 |
if (!check(3, "si")) { |
53 |
/* File + bandwidth */ |
54 |
pmapParams [t].minGather = pmapParams [t].maxGather = |
55 |
atoi(av [2]); |
56 |
|
57 |
if (!pmapParams [t].minGather) |
58 |
return -1; |
59 |
} |
60 |
else { |
61 |
sprintf(errmsg, "no photon lookup bandwidth specified, " |
62 |
"using default %d", defaultGather); |
63 |
error(WARNING, errmsg); |
64 |
return 1; |
65 |
} |
66 |
|
67 |
if (!check(3, "sii")) { |
68 |
/* File + min bwidth + max bwidth -> bias compensation */ |
69 |
pmapParams [t].maxGather = atoi(av [3]); |
70 |
|
71 |
if (pmapParams [t].minGather >= pmapParams [t].maxGather) |
72 |
return -1; |
73 |
|
74 |
return 3; |
75 |
} |
76 |
else return 2; |
77 |
|
78 |
case 'm': /* Fixed max photon search radius */ |
79 |
if (check(3, "f") || (maxDistFix = atof(av [1])) <= 0) |
80 |
error(USER, "invalid max photon search radius coefficient"); |
81 |
|
82 |
return 1; |
83 |
} |
84 |
} |
85 |
#undef check |
86 |
|
87 |
/* Unknown option */ |
88 |
return -1; |
89 |
} |
90 |
|
91 |
|
92 |
|
93 |
void printPmapDefaults () |
94 |
/* Print defaults for photon map render options */ |
95 |
{ |
96 |
printf("-am %.1f\t\t\t\t# max photon search radius\n", maxDistFix); |
97 |
} |