1 #include <grass/gis.h>
2 
3 #ifndef  DIG___EXTERNS___
4 #define DIG___EXTERNS___
5 
6 
7 /*!
8   \file include/vect/dig_externs.h
9 
10   \brief Function prototypes for diglib (part of vector library)
11 */
12 
13 /* allocation.c */
14 void *dig_alloc_space(int, int *, int, void *, int);	/* exits on error, calls _alloc_space () */
15 void *dig__alloc_space(int, int *, int, void *, int);	/* returns NULL on error, calls calloc(), _frealloc() */
16 void *dig_falloc(int, int);	/* exits on error, calls _falloc () */
17 void *dig_frealloc(void *, int, int, int);	/* exits on error, calls _frealloc () */
18 void *dig__falloc(int, int);	/* returns NULL on error, calls calloc () */
19 void *dig__frealloc(void *, int, int, int);	/* returns NULL on error, calls calloc () */
20 
21 /* angle.c */
22 float dig_calc_begin_angle(const struct line_pnts *, double);
23 float dig_calc_end_angle(const struct line_pnts *, double);
24 int dig_line_degenerate(const struct line_pnts *);
25 int dig_is_line_degenerate(const struct line_pnts *, double);
26 
27 /* box.c */
28 int dig_box_copy(struct bound_box *, struct bound_box *);
29 int dig_box_extend(struct bound_box *, struct bound_box *);
30 int dig_line_box(const struct line_pnts *, struct bound_box *);
31 /*
32 int dig_line_set_box(struct Plus_head *, plus_t, struct bound_box *);
33 int dig_line_get_box(struct Plus_head *, plus_t, struct bound_box *);
34 
35 int dig_area_bound_box(struct Map_info *, struct P_area *);
36 int dig_bound_box2(struct line_pnts *, double *, double *, double *, double *,
37 		   long);
38 */
39 
40 /* category index */
41 /* cindex.c */
42 int dig_cidx_init(struct Plus_head *);
43 void dig_cidx_free(struct Plus_head *);
44 int dig_cidx_add_cat(struct Plus_head *, int, int, int, int);
45 int dig_cidx_add_cat_sorted(struct Plus_head *, int, int, int, int);
46 int dig_cidx_del_cat(struct Plus_head *, int, int, int, int);
47 void dig_cidx_sort(struct Plus_head *);
48 
49 /* cindex_rw.c */
50 int dig_write_cidx_head(struct gvfile *, struct Plus_head *);
51 int dig_read_cidx_head(struct gvfile *, struct Plus_head *);
52 int dig_write_cidx(struct gvfile *, struct Plus_head *);
53 int dig_read_cidx(struct gvfile *, struct Plus_head *, int);
54 
55 /* file.c */
56 /* file loaded to memory; mostly unused */
57 off_t dig_ftell(struct gvfile * file);
58 int dig_fseek(struct gvfile * file, off_t offset, int whence);
59 void dig_rewind(struct gvfile * file);
60 int dig_fflush(struct gvfile * file);
61 size_t dig_fread(void *ptr, size_t size, size_t nmemb, struct gvfile * file);
62 size_t dig_fwrite(const void *ptr, size_t size, size_t nmemb, struct gvfile * file);
63 void dig_file_init(struct gvfile * file);
64 int dig_file_load(struct gvfile * file);
65 void dig_file_free(struct gvfile * file);
66 
67 /* frmt.c */
68 int dig_write_frmt_ascii(FILE *, struct Format_info *, int);
69 int dig_read_frmt_ascii(FILE *, struct Format_info *);
70 
71 /* head.c */
72 int dig__write_head(struct Map_info *);
73 int dig__read_head(struct Map_info *);
74 
75 /* inside.c */
76 double dig_x_intersect(double, double, double, double, double);
77 
78 /* linecross.c */
79 int dig_test_for_intersection(double, double, double, double, double, double,
80 			      double, double);
81 int dig_find_intersection(double, double, double, double, double, double,
82 			  double, double, double *, double *);
83 
84 /* line_dist.c */
85 double dig_distance2_point_to_line(double, double, double, double, double,
86 				   double, double, double, double, int,
87 				   double *, double *, double *, double *,
88 				   int *);
89 int dig_set_distance_to_line_tolerance(double);
90 
91 /* list.c */
92 int dig_init_boxlist(struct boxlist *, int);
93 int dig_boxlist_add(struct boxlist *, int, const struct bound_box *);
94 
95 /* plus.c */
96 int dig_init_plus(struct Plus_head *);
97 void dig_free_plus_nodes(struct Plus_head *);
98 void dig_free_plus_lines(struct Plus_head *);
99 void dig_free_plus_areas(struct Plus_head *);
100 void dig_free_plus_isles(struct Plus_head *);
101 void dig_free_plus(struct Plus_head *);
102 int dig_load_plus(struct Plus_head *, struct gvfile *, int);
103 int dig_write_plus_file(struct gvfile *, struct Plus_head *);
104 int dig_write_nodes(struct gvfile *, struct Plus_head *);
105 int dig_write_lines(struct gvfile *, struct Plus_head *);
106 int dig_write_areas(struct gvfile *, struct Plus_head *);
107 int dig_write_isles(struct gvfile *, struct Plus_head *);
108 
109 /* plus_area.c */
110 int dig_add_area(struct Plus_head *, int, plus_t *, struct bound_box *);
111 int dig_area_add_isle(struct Plus_head *, int, int);
112 int dig_area_del_isle(struct Plus_head *, int, int);
113 int dig_del_area(struct Plus_head *, int);
114 int dig_add_isle(struct Plus_head *, int, plus_t *, struct bound_box *);
115 int dig_del_isle(struct Plus_head *, int);
116 int dig_build_area_with_line(struct Plus_head *, plus_t, int, plus_t **);
117 int dig_angle_next_line(struct Plus_head *, plus_t, int, int, float *);
118 int dig_node_angle_check(struct Plus_head *, int, int);
119 int dig_area_get_box(struct Plus_head *, plus_t, struct bound_box *);
120 int dig_isle_get_box(struct Plus_head *, plus_t, struct bound_box *);
121 
122 /* plus_line.c */
123 int dig_add_line(struct Plus_head *, int, const struct line_pnts *,
124 		 const struct bound_box *, off_t);
125 int dig_restore_line(struct Plus_head *, int, int, const struct line_pnts *,
126 		     const struct bound_box *, off_t);
127 int dig_del_line(struct Plus_head *, int, double, double, double);
128 plus_t dig_line_get_area(struct Plus_head *, plus_t, int);
129 int dig_line_set_area(struct Plus_head *, plus_t, int, plus_t);
130 
131 /* plus_node.c */
132 int dig_add_node(struct Plus_head *, double, double, double);
133 int dig_which_node(struct Plus_head *, double, double, double);
134 
135 int dig_node_add_line(struct Plus_head *, int, int, const struct line_pnts *, int);
136 float dig_node_line_angle(struct Plus_head *, int, int);
137 
138 /* plus_struct.c */
139 int dig_Rd_P_node(struct Plus_head *, int i, struct gvfile *);
140 int dig_Wr_P_node(struct Plus_head *, int i, struct gvfile *);
141 int dig_Rd_P_line(struct Plus_head *, int i, struct gvfile *);
142 int dig_Wr_P_line(struct Plus_head *, int i, struct gvfile *);
143 int dig_Rd_P_area(struct Plus_head *, int i, struct gvfile *);
144 int dig_Wr_P_area(struct Plus_head *, int i, struct gvfile *);
145 int dig_Rd_P_isle(struct Plus_head *, int i, struct gvfile *);
146 int dig_Wr_P_isle(struct Plus_head *, int i, struct gvfile *);
147 int dig_Rd_Plus_head(struct gvfile *, struct Plus_head *);
148 int dig_Wr_Plus_head(struct gvfile *, struct Plus_head *);
149 
150 /* poly.c */
151 int dig_find_area_poly(struct line_pnts *, double *);
152 double dig_find_poly_orientation(struct line_pnts *);
153 int dig_get_poly_points(int, struct line_pnts **, int *, struct line_pnts *);
154 
155 /* portable.c */
156 void dig_init_portable(struct Port_info *, int);
157 int dig__byte_order_out();
158 
159 /* int dig__set_cur_head (struct dig_head *); */
160 int dig_set_cur_port(struct Port_info *);
161 
162 int dig__fread_port_D(double *, size_t, struct gvfile *);
163 int dig__fread_port_F(float *, size_t, struct gvfile *);
164 int dig__fread_port_O(off_t *, size_t, struct gvfile *, size_t);
165 int dig__fread_port_L(long *, size_t, struct gvfile *);
166 int dig__fread_port_S(short *, size_t, struct gvfile *);
167 int dig__fread_port_I(int *, size_t, struct gvfile *);
168 int dig__fread_port_P(plus_t *, size_t, struct gvfile *);
169 int dig__fread_port_C(char *, size_t, struct gvfile *);
170 int dig__fwrite_port_D(const double *, size_t, struct gvfile *);
171 int dig__fwrite_port_F(const float *, size_t, struct gvfile *);
172 int dig__fwrite_port_O(const off_t *, size_t, struct gvfile *, size_t);
173 int dig__fwrite_port_L(const long *, size_t, struct gvfile *);
174 int dig__fwrite_port_S(const short *, size_t, struct gvfile *);
175 int dig__fwrite_port_I(const int *, size_t, struct gvfile *);
176 int dig__fwrite_port_P(const plus_t *, size_t, struct gvfile *);
177 int dig__fwrite_port_C(const char *, size_t, struct gvfile *);
178 
179 /* port_init.c */
180 
181 /* port_test.c */
182 
183 /* prune.c */
184 int dig_prune(struct line_pnts *, double);
185 
186 /* spatial index */
187 /* spindex.c */
188 int dig_spidx_init(struct Plus_head *);
189 void dig_spidx_free_nodes(struct Plus_head *);
190 void dig_spidx_free_lines(struct Plus_head *);
191 void dig_spidx_free_areas(struct Plus_head *);
192 void dig_spidx_free_isles(struct Plus_head *);
193 void dig_spidx_free(struct Plus_head *);
194 
195 int dig_spidx_add_node(struct Plus_head *, int, double, double, double);
196 int dig_spidx_add_line(struct Plus_head *, int, const struct bound_box *);
197 int dig_spidx_add_area(struct Plus_head *, int, const struct bound_box *);
198 int dig_spidx_add_isle(struct Plus_head *, int, const struct bound_box *);
199 
200 int dig_spidx_del_node(struct Plus_head *, int);
201 int dig_spidx_del_line(struct Plus_head *, int, double, double, double);
202 int dig_spidx_del_area(struct Plus_head *, int);
203 int dig_spidx_del_isle(struct Plus_head *, int);
204 
205 int dig_select_nodes(struct Plus_head *, const struct bound_box *, struct ilist *);
206 int dig_select_lines(struct Plus_head *, const struct bound_box *, struct boxlist *);
207 int dig_select_areas(struct Plus_head *, const struct bound_box *, struct boxlist *);
208 int dig_select_isles(struct Plus_head *, const struct bound_box *, struct boxlist *);
209 int dig_find_node(struct Plus_head *, double, double, double);
210 int dig_find_line_box(struct Plus_head *, int, struct bound_box *);
211 int dig_find_area_box(struct Plus_head *, int, struct bound_box *);
212 int dig_find_isle_box(struct Plus_head *, int, struct bound_box *);
213 
214 /* spindex_rw.c */
215 int dig_Rd_spidx_head(struct gvfile  *, struct Plus_head *);
216 int dig_Wr_spidx_head(struct gvfile  *, struct Plus_head *);
217 int dig_Wr_spidx(struct gvfile *, struct Plus_head *);
218 int dig_Rd_spidx(struct gvfile *, struct Plus_head *);
219 
220 int dig_dump_spidx(FILE *, const struct Plus_head *);
221 
222 int rtree_search(struct RTree *, struct RTree_Rect *,
223                  SearchHitCallback , void *, struct Plus_head *);
224 
225 /* struct_alloc.c */
226 int dig_node_alloc_line(struct P_node *, int);
227 int dig_alloc_nodes(struct Plus_head *, int);
228 int dig_alloc_lines(struct Plus_head *, int);
229 int dig_alloc_areas(struct Plus_head *, int);
230 int dig_alloc_isles(struct Plus_head *, int);
231 struct P_node *dig_alloc_node();
232 struct P_line *dig_alloc_line();
233 void *dig_alloc_topo(char);
234 struct P_area *dig_alloc_area();
235 struct P_isle *dig_alloc_isle();
236 void dig_free_node(struct P_node *);
237 void dig_free_line(struct P_line *);
238 void dig_free_area(struct P_area *);
239 void dig_free_isle(struct P_isle *);
240 int dig_alloc_points(struct line_pnts *, int);
241 int dig_alloc_cats(struct line_cats *, int);
242 int dig_area_alloc_line(struct P_area *, int);
243 int dig_area_alloc_isle(struct P_area *, int);
244 int dig_isle_alloc_line(struct P_isle *, int);
245 int dig_out_of_memory(void);
246 
247 /* type.c */
248 /* conversion of types */
249 int dig_type_to_store(int);
250 int dig_type_from_store(int);
251 
252 /* update.c */
253 /* list of updated */
254 void dig_line_reset_updated(struct Plus_head *);
255 void dig_line_add_updated(struct Plus_head *, int, off_t);
256 void dig_node_reset_updated(struct Plus_head *);
257 void dig_node_add_updated(struct Plus_head *, int);
258 
259 /*********************************************************************
260  *		    unused/removed functions
261  *********************************************************************/
262 
263 
264 char *color_name(int);		/* pass it an int, returns the name of the color */
265 
266 char *dig_float_point(char *, int, double);
267 
268 /* double dig_point_in_area (struct Map_info *, double, double, struct P_area *); */
269 
270 double dig_unit_conversion(void);
271 
272 /* portable data routines  -  only to be called by library routines! */
273 double *dig__double_convert(double *, double *, int, struct dig_head *);
274 float *dig__float_convert(float *, float *, int, struct dig_head *);
275 short *dig__short_convert(short *in, short *out, int, struct dig_head *);
276 long *dig__long_convert(long *, long *, int, struct dig_head *);
277 long *dig__int_convert(int *, long *, int, struct dig_head *);
278 long *dig__plus_t_convert(plus_t *, long *, int, struct dig_head *);
279 int *dig__long_convert_to_int(long *, int *, int, struct dig_head *);
280 plus_t *dig__long_convert_to_plus_t(long *, plus_t *, int, struct dig_head *);
281 char *dig__convert_buffer(int);
282 
283 plus_t **dig_get_cont_lines(struct Map_info *, plus_t, double, int);
284 plus_t dig_get_next_cont_line(struct Map_info *, plus_t, double, int);
285 
286 struct dig_head *dig_get_head(void);
287 struct dig_head *dig__get_head(void);
288 
289 
290 /* int dig_check_nodes (struct Map_info *, struct new_node *, struct line_pnts *);
291    int dig_in_area_bbox (struct P_area *, double, double); */
292 int dig_start_clock(long *);
293 int dig_stop_clock(long *);
294 char *dig_stop_clock_str(long *);
295 int dig_write_file_checks(struct gvfile *, struct Plus_head *);
296 int dig_do_file_checks(struct Map_info *, char *, char *);
297 
298 /* int dig_find_area (struct Map_info *, struct P_area *, double *, double *, double *, double);
299    int dig_find_area2 (struct Map_info *, struct P_area *, double *); */
300 
301 int dig_map_to_head(struct Map_info *, struct Plus_head *);
302 int dig_head_to_map(struct Plus_head *, struct Map_info *);
303 int dig_spindex_init(struct Plus_head *);
304 
305 /* int dig_snap_line_to_node (struct Map_info *, int, int, struct line_pnts *); */
306 
307 /* int dig_node_del_line (struct Plus_head *plus, int node, int line);
308    int dig_add_line_to_node (int, int, char, struct Map_info *, struct line_pnts *); */
309 int dig_point_to_area(struct Map_info *, double, double);
310 int dig_point_to_next_area(struct Map_info *, double, double, double *);
311 int dig_point_to_line(struct Map_info *, double, double, char);
312 
313 /* int dig_in_line_bbox (struct P_line *, double, double); */
314 int dig_check_dist(struct Map_info *, int, double, double, double *);
315 int dig__check_dist(struct Map_info *, struct line_pnts *, double, double,
316 		    double *);
317 /* int dig_center_check (struct P_line *, int, int, double, double); */
318 int dig_point_by_line(struct Map_info *, double, double, double, double,
319 		      char);
320 /* int dig_by_line_bbox (struct P_line *, double, double, double, double); */
321 int dig_write_head_ascii(FILE *, struct dig_head *);
322 int dig_read_head_ascii(FILE *, struct dig_head *);
323 
324 int dig_struct_copy(void *, void *, int);
325 int dig_rmcr(char *);
326 
327 #endif /* DIG__EXTERNS__ */
328