ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/rt/pmapopt.c
Revision: 2.7
Committed: Tue Sep 1 16:27:52 2015 UTC (8 years, 9 months ago) by greg
Content type: text/plain
Branch: MAIN
CVS Tags: rad5R0
Changes since 2.6: +1 -2 lines
Log Message:
Removed redundant $Id: in file

File Contents

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