ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/rt/pmapopt.c
Revision: 2.4
Committed: Fri May 22 14:12:11 2015 UTC (8 years, 11 months ago) by greg
Content type: text/plain
Branch: MAIN
Changes since 2.3: +1 -2 lines
Log Message:
Removed extraneous default for photon map

File Contents

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