dig_externs.h 13 KB

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