ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/rt/pmapkdt.h
Revision: 1.1
Committed: Wed May 18 08:22:45 2016 UTC (7 years, 11 months ago) by rschregle
Content type: text/plain
Branch: MAIN
CVS Tags: rad5R2, rad5R1
Log Message:
Added missing sources of iC and ooC pmap

File Contents

# Content
1 /*
2 ==================================================================
3 In-core kd-tree for photon map
4
5 Roland Schregle (roland.schregle@{hslu.ch, gmail.com})
6 (c) Fraunhofer Institute for Solar Energy Systems,
7 (c) Lucerne University of Applied Sciences and Arts,
8 supported by the Swiss National Science Foundation (SNSF, #147053)
9 ==================================================================
10
11 $Id: pmapkdt.h,v 1.2 2015/11/13 17:31:25 taschreg Exp taschreg $
12 */
13
14
15 #ifndef PMAPKDT_H
16 #define PMAPKDT_H
17
18 /* #include <stdio.h>
19 #include "fvect.h" */
20 #include "pmapdata.h"
21
22
23 /* Forward declarations to break dependency loop with pmapdata.h */
24 struct PhotonMap;
25
26
27 /* k-d tree as linear array of photons */
28 typedef struct {
29 Photon *nodes; /* k-d tree as linear array */
30 } PhotonKdTree;
31
32 typedef PhotonKdTree PhotonStorage;
33 typedef Photon* PhotonIdx;
34
35 /* Priority queue node for kd-tree lookups */
36 typedef struct {
37 PhotonIdx idx; /* Pointer to photon */
38 float dist2; /* Photon's SQUARED distance to query point */
39 } kdT_SearchQueueNode;
40
41 typedef struct {
42 kdT_SearchQueueNode *node;
43 unsigned len, tail;
44 } kdT_SearchQueue;
45
46 typedef kdT_SearchQueueNode PhotonSearchQueueNode;
47 typedef kdT_SearchQueue PhotonSearchQueue;
48
49
50
51 void kdT_Null (PhotonKdTree *kdt);
52 /* Initialise kd-tree prior to storing photons */
53
54 void kdT_BuildPhotonMap (struct PhotonMap *pmap);
55 /* Build a balanced kd-tree pmap -> store from photons in unsorted
56 * heapfile pmap -> heap to guarantee logarithmic search times. The heap
57 * is destroyed on return. */
58
59 int kdT_SavePhotons (const struct PhotonMap *pmap, FILE *out);
60 /* Save photons in kd-tree to file. Return -1 on error, else 0 */
61
62 int kdT_LoadPhotons (struct PhotonMap *pmap, FILE *in);
63 /* Load photons in kd-tree from file. Return -1 on error, else 0 */
64
65 void kdT_InitFindPhotons (struct PhotonMap *pmap);
66 /* Initialise NN search queue prior to calling kdT_FindPhotons() */
67
68 void kdT_FindPhotons (struct PhotonMap* pmap, const FVECT pos,
69 const FVECT norm);
70 /* Locate pmap -> squeue.len nearest photons to pos with similar normal
71 * (NULL for volume photons) and return in search queue pmap -> squeue,
72 * starting with the further photon at pmap -> squeue.node */
73
74 void kdT_Find1Photon (struct PhotonMap* pmap, const FVECT pos,
75 const FVECT norm, Photon *photon);
76 /* Locate single nearest photon to pos with similar normal */
77
78 int kdT_GetPhoton (const struct PhotonMap *pmap, PhotonIdx idx,
79 Photon *photon);
80 /* Retrieve photon referenced by idx from kd-tree and return 0 on
81 * success, else -1. */
82
83 Photon *kdT_GetNearestPhoton (const PhotonSearchQueue *squeue,
84 PhotonIdx idx);
85 /* Retrieve photon from NN search queue after OOC_FindPhotons() */
86
87 PhotonIdx kdT_FirstPhoton (const struct PhotonMap* pmap);
88 /* Return pointer to first photon in kd-Tree */
89
90 void kdT_Delete (PhotonKdTree *kdt);
91 /* Self-destruct */
92
93 #endif