-
Notifications
You must be signed in to change notification settings - Fork 1
/
smooth1.h
110 lines (83 loc) · 1.71 KB
/
smooth1.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#ifndef SMOOTH_HINCLUDED
#define SMOOTH_HINCLUDED
#include "kd.h"
#define RESMOOTH_SAFE 10
typedef struct pqNode {
float fKey;
struct pqNode *pqLoser;
struct pqNode *pqFromInt;
struct pqNode *pqFromExt;
struct pqNode *pqWinner; /* Only used when building initial tree */
int p;
float ax;
float ay;
float az;
} PQ;
typedef struct nNeighborList {
int p;
float fDist2;
float dx;
float dy;
float dz;
} NN;
typedef struct smContext {
KD kd;
int nSmooth;
PQ *pq;
PQ *pqHead;
char *iMark;
int nExtraScat;
PINIT *pp;
} * SMX;
#define PQ_INIT(pq,n)\
{\
int PQ_j;\
for (PQ_j=0;PQ_j<(n);++PQ_j) {\
if (PQ_j < 2) (pq)[PQ_j].pqFromInt = NULL;\
else (pq)[PQ_j].pqFromInt = &(pq)[PQ_j>>1];\
(pq)[PQ_j].pqFromExt = &(pq)[(PQ_j+(n))>>1];\
(pq)[PQ_j].p = 0;\
}\
}
#define PQ_BUILD(pq,n,q)\
{\
int PQ_i,PQ_j;\
PQ *PQ_t,*PQ_lt;\
for (PQ_j=(n)-1;PQ_j>0;--PQ_j) {\
PQ_i = (PQ_j<<1);\
if (PQ_i < (n)) PQ_t = (pq)[PQ_i].pqWinner;\
else PQ_t = &(pq)[PQ_i-(n)];\
++PQ_i;\
if (PQ_i < (n)) PQ_lt = (pq)[PQ_i].pqWinner;\
else PQ_lt = &(pq)[PQ_i-(n)];\
if (PQ_t->fKey < PQ_lt->fKey) {\
(pq)[PQ_j].pqLoser = PQ_t;\
(pq)[PQ_j].pqWinner = PQ_lt;\
}\
else {\
(pq)[PQ_j].pqLoser = PQ_lt;\
(pq)[PQ_j].pqWinner = PQ_t;\
}\
}\
(q) = (pq)[1].pqWinner;\
}
#define PQ_REPLACE(q)\
{\
PQ *PQ_t,*PQ_lt;\
PQ_t = (q)->pqFromExt;\
while (PQ_t) {\
if (PQ_t->pqLoser->fKey > (q)->fKey) {\
PQ_lt = PQ_t->pqLoser;\
PQ_t->pqLoser = (q);\
(q) = PQ_lt;\
}\
PQ_t = PQ_t->pqFromInt;\
}\
}
int smInit(SMX *,KD,int);
void smFinish(SMX);
void smBallSearch(SMX,float,float *);
int smBallGather(SMX,float,float *,NN *);
void smDensityInit(SMX,int);
int smAccDensity(SMX,int);
#endif