ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/rt/pmapopt.c
Revision: 2.2
Committed: Fri May 8 13:20:23 2015 UTC (9 years ago) by rschregle
Content type: text/plain
Branch: MAIN
Changes since 2.1: +3 -2 lines
Log Message:
Double-counting bugfix for glow sources (thanks DGM!), revised copyright

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.1 2015/02/24 19:39:27 greg Exp $
12 */
13
14
15
16 #include <stdlib.h>
17 #include "pmapparm.h"
18 #include "rtio.h"
19 #include "rterror.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 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 puts("-ap file [bwidth1 [bwidth2]]\t# photon map");
94 printf("-am %.1f\t\t\t# max photon search radius coeff\n", maxDistCoeff);
95 }