ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/rt/pmapio.c
(Generate patch)

Comparing ray/src/rt/pmapio.c (file contents):
Revision 2.12 by greg, Thu Aug 2 18:33:49 2018 UTC vs.
Revision 2.13 by rschregle, Thu Feb 18 17:08:50 2021 UTC

# Line 3 | Line 3 | static const char RCSid[] = "$Id$";
3   #endif
4  
5   /*
6 <   ======================================================================
7 <   Photon map file I/O
6 >   =======================================================================
7 >   Photon map portable file I/O
8  
9     Roland Schregle (roland.schregle@{hslu.ch, gmail.com})
10     (c) Fraunhofer Institute for Solar Energy Systems,
11 +       supported by the German Research Foundation
12 +       (DFG LU-204/10-2, "Fassadenintegrierte Regelsysteme FARESYS")
13     (c) Lucerne University of Applied Sciences and Arts,
14 <       supported by the Swiss National Science Foundation (SNSF, #147053)
15 <   ======================================================================
14 >       supported by the Swiss National Science Foundation
15 >       (SNSF #147053, "Daylight Redirecting Components",
16 >        SNSF #179067, "Light Fields for Spatio-Temporal Glare Assessment")
17 >   =======================================================================
18    
19     $Id$    
20   */
# Line 57 | Line 61 | void savePhotonMap (const PhotonMap *pmap, const char
61     printargs(argc, argv, file);
62    
63     /* Include statistics in info text */
64 <   fprintf(file, "NumPhotons\t= %ld\n"
65 <           "AvgFlux\t\t= [%.2e, %.2e, %.2e]\n"
66 <           "Bbox\t\t= [%.3f, %.3f, %.3f] [%.3f, %.3f, %.3f]\n"
67 <           "CoG\t\t= [%.3f, %.3f, %.3f]\n"
68 <           "MaxDist^2\t= %.3f\n",
69 <           pmap -> numPhotons, pmap -> photonFlux [0],
70 <           pmap -> photonFlux [1], pmap -> photonFlux [2],
71 <           pmap -> minPos [0], pmap -> minPos [1], pmap -> minPos [2],
72 <           pmap -> maxPos [0], pmap -> maxPos [1], pmap -> maxPos [2],
73 <           pmap -> CoG [0], pmap -> CoG [1], pmap -> CoG [2],
74 <           pmap -> CoGdist);
64 >   fprintf(
65 >      file,
66 >      "NumPhotons\t= %ld\n"
67 >      "AvgFlux\t\t= [%.2e, %.2e, %.2e]\n"
68 >      "Bbox\t\t= [%.3f, %.3f, %.3f] [%.3f, %.3f, %.3f]\n"
69 >      "CoG\t\t= [%.3f, %.3f, %.3f]\n"
70 >      "MaxDist^2\t= %.3f\n",
71 >      pmap -> numPhotons,
72 >      pmap -> photonFlux [0], pmap -> photonFlux [1], pmap -> photonFlux [2],
73 >      pmap -> minPos [0], pmap -> minPos [1], pmap -> minPos [2],
74 >      pmap -> maxPos [0], pmap -> maxPos [1], pmap -> maxPos [2],
75 >      pmap -> CoG [0], pmap -> CoG [1], pmap -> CoG [2],
76 >      pmap -> CoGdist
77 >   );
78            
79     if (pmap -> primaries)
80        fprintf(file, "%d primary rays\n", pmap -> numPrimary);
81    
82 <   /* Write format */
82 >   /* Write format, including human-readable file version */
83     fputformat((char*)pmapFormat [pmap -> type], file);
84     fprintf(file, "VERSION=%s\n", PMAP_FILEVER);
85    
86     /* Empty line = end of header */
87     putc('\n', file);
88    
89 <   /* Write file format version */
89 >   /* Write machine-readable file format version */
90     putstr(PMAP_FILEVER, file);
91    
92 <   /* Write number of photons */
93 <   putint(pmap -> numPhotons, sizeof(pmap -> numPhotons), file);
92 >   /* Write number of photons as fixed size, which possibly results in
93 >    * padding of MSB with 0 on some platforms.  Unlike sizeof() however,
94 >    * this ensures portability since this value may span 32 or 64 bits
95 >    * depending on platform.  */
96 >   putint(pmap -> numPhotons, PMAP_LONGSIZE, file);
97    
98     /* Write average photon flux */
99     for (j = 0; j < 3; j++)
# Line 177 | Line 187 | PhotonMapType loadPhotonMap (PhotonMap *pmap, const ch
187     if (strcmp(getstr(format, file), PMAP_FILEVER))
188        error(USER, "incompatible photon map file format");
189        
190 <   /* Get number of photons */
191 <   pmap -> numPhotons = getint(sizeof(pmap -> numPhotons), file);
190 >   /* Get number of photons as fixed size, which possibly results in
191 >    * padding of MSB with 0 on some platforms.  Unlike sizeof() however,
192 >    * this ensures portability since this value may span 32 or 64 bits
193 >    * depending on platform.  */
194 >   pmap -> numPhotons = getint(PMAP_LONGSIZE, file);
195        
196     /* Get average photon flux */
197     for (j = 0; j < 3; j++)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines