--- ray/src/rt/pmapio.c 2015/02/24 19:39:27 2.1 +++ ray/src/rt/pmapio.c 2015/10/20 15:51:54 2.8 @@ -1,13 +1,16 @@ +#ifndef lint +static const char RCSid[] = "$Id: pmapio.c,v 2.8 2015/10/20 15:51:54 rschregle Exp $"; +#endif /* ================================================================== Photon map file I/O Roland Schregle (roland.schregle@{hslu.ch, gmail.com}) (c) Fraunhofer Institute for Solar Energy Systems, - Lucerne University of Applied Sciences & Arts + (c) Lucerne University of Applied Sciences and Arts, + supported by the Swiss National Science Foundation (SNSF, #147053) ================================================================== - $Id: pmapio.c,v 2.1 2015/02/24 19:39:27 greg Exp $ */ @@ -19,14 +22,14 @@ void savePhotonMap (const PhotonMap *pmap, const char *fname, - PhotonMapType type, int argc, char **argv) + int argc, char **argv) { unsigned long i, j; const Photon* p; FILE* file; if (!pmap || !pmap -> heap || !pmap -> heapSize || - !validPmapType(type)) { + !validPmapType(pmap -> type)) { error(INTERNAL, "attempt to save empty or invalid photon map"); return; } @@ -60,7 +63,7 @@ void savePhotonMap (const PhotonMap *pmap, const char fprintf(file, "%d primary rays\n", pmap -> primaryEnd + 1); /* Write format */ - fputformat((char*)pmapFormat [type], file); + fputformat((char*)pmapFormat [pmap -> type], file); fprintf(file, "VERSION=%d\n", PMAP_FILEVER); /* Empty line = end of header */ @@ -126,11 +129,10 @@ void savePhotonMap (const PhotonMap *pmap, const char putint(prim -> srcIdx, sizeof(prim -> srcIdx), file); - for (j = 0; j < 3; j++) - putflt(prim -> dir [j], file); + putint(prim -> dir, sizeof(prim -> dir), file); for (j = 0; j < 3; j++) - putflt(prim -> org [j], file); + putflt(prim -> pos [j], file); if (ferror(file)) error(SYSTEM, "error writing primary photon rays"); @@ -169,7 +171,7 @@ PhotonMapType loadPhotonMap (PhotonMap *pmap, const ch /* Identify photon map type from format string */ for (ptype = 0; - strcmp(pmapFormat [ptype], format) && ptype < NUM_PMAP_TYPES; + ptype < NUM_PMAP_TYPES && strcmp(pmapFormat [ptype], format); ptype++); if (!validPmapType(ptype)) { @@ -248,11 +250,10 @@ PhotonMapType loadPhotonMap (PhotonMap *pmap, const ch prim -> srcIdx = getint(sizeof(prim -> srcIdx), file); - for (j = 0; j < 3; j++) - prim -> dir [j] = getflt(file); + prim -> dir = getint(sizeof(prim -> dir), file); for (j = 0; j < 3; j++) - prim -> org [j] = getflt(file); + prim -> pos [j] = getflt(file); if (feof(file)) error(SYSTEM, "error reading primary photon rays");