-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdefs.h
executable file
·227 lines (198 loc) · 5.32 KB
/
defs.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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
/*
$Id: defs.h,v 1.1.1.1 1999/10/15 12:40:27 kise Exp $
$Date: 1999/10/15 12:40:27 $
$Revision: 1.1.1.1 $
$Author: kise $
*/
#ifndef DEFS_H_INCLUDED_
#define DEFS_H_INCLUDED_
#include "const.h"
namespace voronoi{
typedef unsigned short Coordinate;
// Faisal Shafait's modification: changed Label type from short to int
typedef unsigned int Label;
typedef unsigned int NumPixel;
typedef unsigned int Key;
typedef unsigned int HashVal;
typedef double Coord;
// Structure to represent a min heap node
struct MinHeapNode
{
int v;
int dist;
};
// Structure to represent a min heap
struct MinHeap
{
int size; // Number of heap nodes present currently
int capacity; // Capacity of min heap
int *pos; // This is needed for decreaseKey()
struct MinHeapNode **array;
};
/* Representation of graphs - start */
// A structure to represent an adjacency list node
struct AdjListNode
{
int dest;
int weight;
int lineseg_idx;
struct AdjListNode* next;
};
// A structure to represent an adjacency list
struct AdjList
{
struct AdjListNode *head;
};
// A structure to represent a graph. A graph
// is an array of adjacency lists.
// Size of array will be V (number of vertices
// in graph)
struct Graph
{
int V;
struct AdjList* array;
};
/* The structure for a Voronoi point */
struct CC{
int lab;
struct CC *next;
};
/* The structure for zone */
typedef struct {
int len;
int numOfCCs;
struct CC* cc_head;
struct AdjListNode* head;
} Zone;
/* Representation of graphs - end */
/* The structure for a vector */
typedef struct{
int x;
int y;
} Vector;
/* The structure for a binary image */
typedef struct{
char *image;
Coordinate imax, jmax; /* width and height of the image */
} ImageData;
/* The structure for a pixel */
typedef struct{
Label label; /* label */
Coordinate xax,yax; /* coordinates */
} BlackPixel;
/* The structure for a shape of CC */
typedef struct{
Coordinate x_min,x_max,y_min,y_max;
float conf[2048];
float conf_iqr;
float conf_median;
int conf_idx;
} Shape;
/* A structure representing the barycentric coordinates of each connected component and the vertical and horizontal lengths of the rectangle surrounding it */
/*
typedef struct{
unsigned short x,y;
unsigned short dx,dy;
unsigned int bpn;
} Component;
*/
/* The structure for a neighboring relation
between connected components(CC's)
lab2
-------
| x |
-------
--- /
| |/ angle
|x|-----
| |
---
lab1
*/
typedef struct{
float dist; /* min. distance between CC's */
float angle; /* angle between CC's */
Label lab1, lab2; /* labels of CC's */
} Neighborhood;
/* The structure for a Voronoi edge */
typedef struct edge_node{
int sp,ep;
float conf;
int weight;
Coordinate xs,xe,ys,ye; /* + (xs,ys)
\
\ Voronoi edge
\
+ (xe,ye)
*/
Label lab1,lab2; /* this Voronoi edge is between
CC of a label "lab1" and that of lab2 */
unsigned short yn;
struct edge_node *next;
int lineseg_idx;
} LineSegment;
/* The structure for a Voronoi point */
typedef struct node{
int line;
struct node *next;
} EndPoint;
/* The structure for a hash table for
representing labels of CC's */
typedef struct hash {
Label lab1;
Label lab2;
unsigned int entry;
struct hash *next;
} HashTable;
/*
typedef struct hash {
unsigned long id;
unsigned int entry;
struct hash *next;
} HashTable;
*/
/* The structure for a rectangle */
typedef struct{
Coordinate is,ie,js,je;
} Rect;
struct Freenode {
struct Freenode *nextfree;
};
struct Freelist {
struct Freenode *head;
// Faisal Shafait's modification to fix memory leak
#ifdef h_iupr_
colib::narray<void *> allocated_chunks;
#endif
// End of Modification
int nodesize;
};
struct Point {
float x,y;
};
/* structure used both for sites and for vertices */
struct Site {
struct Point coord;
int sitenbr;
int refcnt;
unsigned int label;
};
struct Edge {
float a,b,c;
struct Site *ep[2];
struct Site *reg[2];
int edgenbr;
unsigned int lab1,lab2;
float dist;
};
struct Halfedge {
struct Halfedge *ELleft, *ELright;
struct Edge *ELedge;
int ELrefcnt;
char ELpm;
struct Site *vertex;
float ystar;
struct Halfedge *PQnext;
};
}
#endif /* DEFS_H_INCLUDED_ */