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
102
103
104
105
106
107
108
109
110
111
112
113
114
| /* Gerris - The GNU Flow Solver
* Copyright (C) 2010 National Institute of Water and Atmospheric Research
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*/
/* padding on 32 bits systems (to match automatic 64 bits padding) */
#if defined (__LP64__) || defined (__64BIT__) || defined (_LP64) || (__WORDSIZE == 64)
#define PADDING_32_BITS
#else
#define PADDING_32_BITS int padding;
#endif
FILE * kdt_tmpfile (void);
typedef struct {
double x, y, z;
} KdtPoint;
typedef struct {
float l, h;
} KdtInterval;
typedef KdtInterval KdtRect[2];
typedef struct {
KdtPoint * p;
long start, len, i, end, buflen, current;
FILE * fp;
void * buf;
} KdtHeap;
void kdt_heap_create (KdtHeap * h, FILE * fp, long start, long len, long buflen);
void kdt_heap_resize (KdtHeap * h, long len);
int kdt_heap_get (KdtHeap * h, KdtPoint * p);
void kdt_heap_split (KdtHeap * h1, long len1, KdtHeap * h2);
void kdt_heap_put (KdtHeap * h, KdtPoint * p);
void kdt_heap_flush (KdtHeap * h);
void kdt_heap_free (KdtHeap * h);
void kdt_heap_rewind (KdtHeap * h);
typedef struct { /* needs to be identical to RSurfaceSum in rsurface.h */
#if AVG_TERRAIN
double H0;
float Hmin, Hmax;
int n;
#else
double m01, m02, m03;
double m11, m13;
double m22, m23, m33;
double m44, m55, m66, m77;
double m67, m76;
double H0, H1, H2, H3, H4;
double H5, H6;
float Hmin, Hmax;
float coverage;
int n;
#endif
} KdtSumCore;
typedef struct {
#if AVG_TERRAIN
double H0;
float Hmin, Hmax;
int n;
#else
double m01, m02, m03;
double m11, m13;
double m22, m23, m33;
double m44, m55, m66, m77;
double m67, m76;
double H0, H1, H2, H3, H4;
double H5, H6;
float Hmin, Hmax;
float coverage;
int n;
#endif
double w;
} KdtSum;
typedef struct _Kdt Kdt;
typedef int (* KdtCheck) (const KdtRect rect, void * data);
int kdt_intersects (const KdtRect rect, const KdtRect query);
int kdt_includes (const KdtRect rect, const KdtRect query);
Kdt * kdt_new (void);
int kdt_create (Kdt * kdt,
const char * name,
int blksize,
KdtHeap * h,
void (* progress) (float complete, void * data),
void * data);
int kdt_open (Kdt * kdt, const char * name);
void kdt_destroy (Kdt * kdt);
long kdt_query (const Kdt * kdt, const KdtRect rect);
long kdt_query_sum (const Kdt * kdt,
KdtCheck includes, KdtCheck intersects, void * data,
const KdtRect query, KdtSum * sum);
void kdt_sum_init (KdtSum * s);
|