ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/rt/pmapparm.c
Revision: 2.3
Committed: Tue May 26 12:32:21 2015 UTC (9 years ago) by rschregle
Content type: text/plain
Branch: MAIN
Changes since 2.2: +3 -2 lines
Log Message:
Revised header of pmapparm.{h,c} to clarify its primary use with mkpmap

File Contents

# User Rev Content
1 greg 2.1 /*
2     ==================================================================
3 rschregle 2.3 Parameters for photon map generation; used by MKPMAP
4     For inclusion in mkpmap.c
5 greg 2.1
6     Roland Schregle (roland.schregle@{hslu.ch, gmail.com}
7     (c) Fraunhofer Institute for Solar Energy Systems,
8 rschregle 2.2 (c) Lucerne University of Applied Sciences and Arts,
9     supported by the Swiss National Science Foundation (SNSF, #147053)
10 greg 2.1 ==================================================================
11    
12 rschregle 2.3 $Id: pmapparm.c,v 2.2 2015/05/08 13:20:23 rschregle Exp $
13 greg 2.1 */
14    
15    
16     #include "pmapparm.h"
17     #include "pmapdata.h"
18     #include "standard.h"
19     #include <ctype.h>
20    
21    
22     float pdfSamples = 1000, /* PDF samples per steradian */
23     finalGather = 0.25, /* fraction of global photons for
24     irradiance precomputation */
25     preDistrib = 0.25, /* fraction of num photons for
26     distribution prepass */
27     gatherTolerance = 0.5, /* Photon map lookup tolerance;
28     lookups returning fewer than this
29     fraction of minGather/maxGather
30     are restarted with a larger
31     search radius */
32     maxDistCoeff = 100; /* Coefficient for maximum photon
33     search radius */
34    
35     #ifdef PMAP_ROI
36     /* Region of interest bbox: {xmin, xmax, ymin, ymax, zmin, zmax} */
37     float pmapROI [6] = {-FHUGE, FHUGE, -FHUGE, FHUGE, -FHUGE, FHUGE};
38     #endif
39    
40     unsigned long photonHeapSizeInc = 1000, /* Photon heap size increment */
41     photonMaxBounce = 5000; /* Runaway photon bounce limit */
42    
43     unsigned photonRepTime = 0, /* Seconds between reports */
44     maxPreDistrib = 4, /* Max predistrib passes */
45     defaultGather = 40; /* Default num photons for lookup */
46    
47     /* Per photon map params */
48     PhotonMapParams pmapParams [NUM_PMAP_TYPES] = {
49     {NULL, 0, 0, 0}, {NULL, 0, 0, 0}, {NULL, 0, 0, 0}, {NULL, 0, 0, 0},
50     {NULL, 0, 0, 0}, {NULL, 0, 0, 0}
51     };
52    
53    
54     int setPmapParam (PhotonMap** pm, const PhotonMapParams* parm)
55     {
56     if (parm && parm -> fileName) {
57     if (!(*pm = (PhotonMap*)malloc(sizeof(PhotonMap))))
58     error(INTERNAL, "failed to allocate photon map");
59    
60     (*pm) -> fileName = parm -> fileName;
61     (*pm) -> minGather = parm -> minGather;
62     (*pm) -> maxGather = parm -> maxGather;
63     (*pm) -> distribTarget = parm -> distribTarget;
64     (*pm) -> heapSizeInc = photonHeapSizeInc;
65     (*pm) -> maxDist0 = FHUGE;
66     (*pm) -> srcContrib = NULL;
67    
68     return 1;
69     }
70    
71     return 0;
72     }
73    
74    
75     unsigned long parseMultiplier (const char *num)
76     {
77     unsigned long mult = 1;
78     const int strEnd = strlen(num) - 1;
79    
80     if (strEnd <= 0)
81     return 0;
82    
83     if (!isdigit(num [strEnd]))
84     switch (toupper(num [strEnd])) {
85     case 'G': mult *= 1000;
86     case 'M': mult *= 1000;
87     case 'K': mult *= 1000;
88     break;
89     default : error(USER, "unknown multiplier");
90     }
91    
92     return (unsigned long)(mult * atof(num));
93     }