ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/rt/pmapopt.c
Revision: 2.1
Committed: Tue Feb 24 19:39:27 2015 UTC (9 years, 3 months ago) by greg
Content type: text/plain
Branch: MAIN
Log Message:
Initial check-in of photon map addition by Roland Schregle

File Contents

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