| 1 |
+ |
#ifndef lint |
| 2 |
+ |
static const char RCSid[] = "$Id$"; |
| 3 |
+ |
#endif |
| 4 |
|
/* |
| 5 |
|
================================================================== |
| 6 |
|
Photon map file I/O |
| 11 |
|
supported by the Swiss National Science Foundation (SNSF, #147053) |
| 12 |
|
================================================================== |
| 13 |
|
|
| 11 |
– |
$Id$ |
| 14 |
|
*/ |
| 15 |
|
|
| 16 |
|
|
| 22 |
|
|
| 23 |
|
|
| 24 |
|
void savePhotonMap (const PhotonMap *pmap, const char *fname, |
| 25 |
< |
PhotonMapType type, int argc, char **argv) |
| 25 |
> |
int argc, char **argv) |
| 26 |
|
{ |
| 27 |
|
unsigned long i, j; |
| 28 |
|
const Photon* p; |
| 29 |
|
FILE* file; |
| 30 |
|
|
| 31 |
|
if (!pmap || !pmap -> heap || !pmap -> heapSize || |
| 32 |
< |
!validPmapType(type)) { |
| 32 |
> |
!validPmapType(pmap -> type)) { |
| 33 |
|
error(INTERNAL, "attempt to save empty or invalid photon map"); |
| 34 |
|
return; |
| 35 |
|
} |
| 63 |
|
fprintf(file, "%d primary rays\n", pmap -> primaryEnd + 1); |
| 64 |
|
|
| 65 |
|
/* Write format */ |
| 66 |
< |
fputformat((char*)pmapFormat [type], file); |
| 66 |
> |
fputformat((char*)pmapFormat [pmap -> type], file); |
| 67 |
|
fprintf(file, "VERSION=%d\n", PMAP_FILEVER); |
| 68 |
|
|
| 69 |
|
/* Empty line = end of header */ |
| 129 |
|
|
| 130 |
|
putint(prim -> srcIdx, sizeof(prim -> srcIdx), file); |
| 131 |
|
|
| 132 |
< |
for (j = 0; j < 3; j++) |
| 131 |
< |
putflt(prim -> dir [j], file); |
| 132 |
> |
putint(prim -> dir, sizeof(prim -> dir), file); |
| 133 |
|
|
| 134 |
|
for (j = 0; j < 3; j++) |
| 135 |
|
putflt(prim -> pos [j], file); |
| 171 |
|
|
| 172 |
|
/* Identify photon map type from format string */ |
| 173 |
|
for (ptype = 0; |
| 174 |
< |
strcmp(pmapFormat [ptype], format) && ptype < NUM_PMAP_TYPES; |
| 174 |
> |
ptype < NUM_PMAP_TYPES && strcmp(pmapFormat [ptype], format); |
| 175 |
|
ptype++); |
| 176 |
|
|
| 177 |
|
if (!validPmapType(ptype)) { |
| 250 |
|
|
| 251 |
|
prim -> srcIdx = getint(sizeof(prim -> srcIdx), file); |
| 252 |
|
|
| 253 |
< |
for (j = 0; j < 3; j++) |
| 253 |
< |
prim -> dir [j] = getflt(file); |
| 253 |
> |
prim -> dir = getint(sizeof(prim -> dir), file); |
| 254 |
|
|
| 255 |
|
for (j = 0; j < 3; j++) |
| 256 |
|
prim -> pos [j] = getflt(file); |