4 |
|
|
5 |
|
Roland Schregle (roland.schregle@{hslu.ch, gmail.com}) |
6 |
|
(c) Fraunhofer Institute for Solar Energy Systems, |
7 |
< |
Lucerne University of Applied Sciences & Arts |
7 |
> |
(c) Lucerne University of Applied Sciences and Arts, |
8 |
> |
supported by the Swiss National Science Foundation (SNSF, #147053) |
9 |
|
================================================================== |
10 |
|
|
11 |
|
$Id$ |
102 |
|
prim -> dir [1] = -ray -> rdir [1]; |
103 |
|
prim -> dir [2] = -ray -> rdir [2]; |
104 |
|
|
105 |
< |
VCOPY(prim -> org, ray -> rorg); |
105 |
> |
VCOPY(prim -> pos, ray -> rop); |
106 |
|
|
107 |
|
return prim; |
108 |
|
} |
330 |
|
pmap -> minError = FHUGE; |
331 |
|
pmap -> maxError = -FHUGE; |
332 |
|
pmap -> rmsError = 0; |
333 |
+ |
#ifdef PMAP_MAXDIST_ABS |
334 |
+ |
/* Treat maxDistCoeff as an *absolute* and *fixed* max search radius. |
335 |
+ |
Primarily intended for debugging; FOR ZE ECKSPURTZ ONLY! */ |
336 |
+ |
pmap -> maxDist0 = pmap -> maxDistLimit = maxDistCoeff; |
337 |
+ |
#else |
338 |
|
/* Maximum search radius limit based on avg photon distance to |
339 |
|
* centre of gravity */ |
340 |
|
pmap -> maxDist0 = pmap -> maxDistLimit = |
341 |
|
maxDistCoeff * pmap -> squeueSize * pmap -> CoGdist / |
342 |
|
pmap -> heapSize; |
343 |
+ |
#endif |
344 |
|
} |
345 |
|
|
346 |
|
do { |
359 |
|
VCOPY(norm, ray -> ron); |
360 |
|
nearestNeighbours(pmap, pos, norm, 1); |
361 |
|
} |
362 |
< |
|
362 |
> |
|
363 |
> |
#ifndef PMAP_MAXDIST_ABS |
364 |
|
if (pmap -> squeueEnd < pmap -> squeueSize * pmap -> gatherTolerance) { |
365 |
|
/* Short lookup; too few photons found */ |
366 |
|
if (pmap -> squeueEnd > PMAP_SHORT_LOOKUP_THRESH) { |
368 |
|
* PMAP_SHORT_LOOKUP_THRESH photons under the assumption there |
369 |
|
* really are no photons in the vicinity, and increasing the max |
370 |
|
* search radius therefore won't help */ |
371 |
< |
#ifdef PMAP_LOOKUP_WARN |
371 |
> |
#ifdef PMAP_LOOKUP_WARN |
372 |
|
sprintf(errmsg, |
373 |
|
"%d/%d %s photons found at (%.2f,%.2f,%.2f) on %s", |
374 |
|
pmap -> squeueEnd, pmap -> squeueSize, |
375 |
|
pmapName [pmap -> type], pos [0], pos [1], pos [2], |
376 |
|
ray -> ro ? ray -> ro -> oname : "<null>"); |
377 |
|
error(WARNING, errmsg); |
378 |
< |
#endif |
379 |
< |
|
378 |
> |
#endif |
379 |
> |
|
380 |
|
if (pmap -> maxDist0 < pmap -> maxDistLimit) { |
381 |
|
/* Increase max search radius if below limit & redo search */ |
382 |
|
pmap -> maxDist0 *= PMAP_MAXDIST_INC; |
383 |
< |
#ifdef PMAP_LOOKUP_REDO |
383 |
> |
#ifdef PMAP_LOOKUP_REDO |
384 |
|
redo = 1; |
385 |
< |
#endif |
385 |
> |
#endif |
386 |
|
|
387 |
< |
#ifdef PMAP_LOOKUP_WARN |
387 |
> |
#ifdef PMAP_LOOKUP_WARN |
388 |
|
sprintf(errmsg, |
389 |
|
redo ? "restarting photon lookup with max radius %.1e" |
390 |
|
: "max photon lookup radius adjusted to %.1e", |
391 |
|
pmap -> maxDist0); |
392 |
|
error(WARNING, errmsg); |
393 |
< |
#endif |
393 |
> |
#endif |
394 |
|
} |
395 |
< |
#ifdef PMAP_LOOKUP_REDO |
395 |
> |
#ifdef PMAP_LOOKUP_REDO |
396 |
|
else { |
397 |
|
sprintf(errmsg, "max photon lookup radius clamped to %.1e", |
398 |
|
pmap -> maxDist0); |
399 |
|
error(WARNING, errmsg); |
400 |
|
} |
401 |
< |
#endif |
401 |
> |
#endif |
402 |
|
} |
403 |
|
|
404 |
|
/* Reset successful lookup counter */ |
405 |
|
pmap -> numLookups = 0; |
406 |
< |
} |
406 |
> |
} |
407 |
|
else { |
408 |
|
/* Increment successful lookup counter and reduce max search radius if |
409 |
|
* wraparound */ |
413 |
|
|
414 |
|
redo = 0; |
415 |
|
} |
416 |
+ |
#endif |
417 |
|
} while (redo); |
418 |
|
} |
419 |
|
|