Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F88375621
pmutil.c
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Fri, Oct 18, 11:38
Size
1 KB
Mime Type
text/x-c
Expires
Sun, Oct 20, 11:38 (2 d)
Engine
blob
Format
Raw Data
Handle
21761991
Attached To
R10977 RADIANCE Photon Map
pmutil.c
View Options
#ifndef lint
static const char RCSid[] = "$Id: pmutil.c,v 2.5 2020/04/08 15:14:21 rschregle Exp $";
#endif
/*
======================================================================
Auxiliary photon map utilities
Roland Schregle (roland.schregle@{hslu.ch, gmail.com})
(c) Fraunhofer Institute for Solar Energy Systems,
(c) Lucerne University of Applied Sciences and Arts,
supported by the Swiss National Science Foundation (SNSF, #147053)
======================================================================
$Id: pmutil.c,v 2.5 2020/04/08 15:14:21 rschregle Exp $
*/
#include "pmutil.h"
#if NIX
#include <fcntl.h>
#endif
void colorNorm (COLOR c)
/* Normalise colour channels to average of 1 */
{
const float avg = colorAvg(c);
if (!avg)
return;
c [0] /= avg;
c [1] /= avg;
c [2] /= avg;
}
void cleanUpPmaps (PhotonMap **pmaps)
{
unsigned t;
for (t = 0; t < NUM_PMAP_TYPES; t++) {
if (pmaps [t]) {
deletePhotons(pmaps [t]);
free(pmaps [t]);
}
}
}
#if NIX
void shmLock (int shmFile, int type)
/* Set/release record lock on shared memory file,
where type is either F_RDLCK, F_WRLCK or F_UNLCK*/
{
struct flock lock;
lock.l_type = type;
lock.l_whence = SEEK_SET;
lock.l_start = lock.l_len = 0;
/* F_SETLKW waits until file is released by other process. A loop
* handles interrupt by a signal (error EINTR). */
do
if (fcntl(shmFile, F_SETLKW, &lock) >= 0)
/* Okie dokie */
return;
while (errno == EINTR);
error(SYSTEM,
"failed to (un)lock shared memory in distribPhotonContrib()"
);
}
#endif
Event Timeline
Log In to Comment