Browse Source

remove bounding boxes from vector topology (Radim's TODO): update headers

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@46898 15284696-431f-4ddb-bdfa-cd5b030d7da7
Markus Metz 14 years ago
parent
commit
23dd9c2335
4 changed files with 469 additions and 391 deletions
  1. 2 2
      include/vect/dig_defines.h
  2. 228 167
      include/vect/dig_externs.h
  3. 222 220
      include/vect/dig_structs.h
  4. 17 2
      include/vector.h

+ 2 - 2
include/vect/dig_defines.h

@@ -154,7 +154,7 @@
 #define GV_COOR_VER_MAJOR  5
 #define GV_COOR_VER_MAJOR  5
 #define GV_COOR_VER_MINOR  1
 #define GV_COOR_VER_MINOR  1
 #define GV_TOPO_VER_MAJOR  5
 #define GV_TOPO_VER_MAJOR  5
-#define GV_TOPO_VER_MINOR  0
+#define GV_TOPO_VER_MINOR  1
 #define GV_SIDX_VER_MAJOR  5
 #define GV_SIDX_VER_MAJOR  5
 #define GV_SIDX_VER_MINOR  1
 #define GV_SIDX_VER_MINOR  1
 #define GV_CIDX_VER_MAJOR  5
 #define GV_CIDX_VER_MAJOR  5
@@ -165,7 +165,7 @@
 #define GV_COOR_EARLIEST_MAJOR  5
 #define GV_COOR_EARLIEST_MAJOR  5
 #define GV_COOR_EARLIEST_MINOR	1
 #define GV_COOR_EARLIEST_MINOR	1
 #define GV_TOPO_EARLIEST_MAJOR  5
 #define GV_TOPO_EARLIEST_MAJOR  5
-#define GV_TOPO_EARLIEST_MINOR	0
+#define GV_TOPO_EARLIEST_MINOR	1
 #define GV_SIDX_EARLIEST_MAJOR  5
 #define GV_SIDX_EARLIEST_MAJOR  5
 #define GV_SIDX_EARLIEST_MINOR	1
 #define GV_SIDX_EARLIEST_MINOR	1
 #define GV_CIDX_EARLIEST_MAJOR  5
 #define GV_CIDX_EARLIEST_MAJOR  5

+ 228 - 167
include/vect/dig_externs.h

@@ -4,6 +4,7 @@
   \brief Function prototypes for diglib (part of vector library)
   \brief Function prototypes for diglib (part of vector library)
 */
 */
 
 
+/* allocation.c */
 void *dig_alloc_space(int, int *, int, void *, int);	/* exits on error, calls _alloc_space () */
 void *dig_alloc_space(int, int *, int, void *, int);	/* exits on error, calls _alloc_space () */
 void *dig__alloc_space(int, int *, int, void *, int);	/* returns NULL on error, calls calloc(), _frealloc() */
 void *dig__alloc_space(int, int *, int, void *, int);	/* returns NULL on error, calls calloc(), _frealloc() */
 void *dig_falloc(int, int);	/* exits on error, calls _falloc () */
 void *dig_falloc(int, int);	/* exits on error, calls _falloc () */
@@ -11,48 +12,148 @@ void *dig_frealloc(void *, int, int, int);	/* exits on error, calls _frealloc ()
 void *dig__falloc(int, int);	/* returns NULL on error, calls calloc () */
 void *dig__falloc(int, int);	/* returns NULL on error, calls calloc () */
 void *dig__frealloc(void *, int, int, int);	/* returns NULL on error, calls calloc () */
 void *dig__frealloc(void *, int, int, int);	/* returns NULL on error, calls calloc () */
 
 
-int dig_init_list(struct ilist *);
-int dig_list_add(struct ilist *, int);
-
-char *color_name(int);		/* pass it an int, returns the name of the color */
-
+/* angle.c */
 float dig_calc_begin_angle(const struct line_pnts *, double);
 float dig_calc_begin_angle(const struct line_pnts *, double);
 float dig_calc_end_angle(const struct line_pnts *, double);
 float dig_calc_end_angle(const struct line_pnts *, double);
 int dig_line_degenerate(const struct line_pnts *);
 int dig_line_degenerate(const struct line_pnts *);
-char *dig_float_point(char *, int, double);
+int dig_is_line_degenerate(const struct line_pnts *, double);
 
 
-/* double dig_point_in_area (struct Map_info *, double, double, struct P_area *); */
+/* box.c */
+int dig_box_copy(struct bound_box *, struct bound_box *);
+int dig_box_extend(struct bound_box *, struct bound_box *);
+int dig_line_box(const struct line_pnts *, struct bound_box *);
+/*
+int dig_line_set_box(struct Plus_head *, plus_t, struct bound_box *);
+int dig_line_get_box(struct Plus_head *, plus_t, struct bound_box *);
+
+int dig_area_bound_box(struct Map_info *, struct P_area *);
+int dig_bound_box2(struct line_pnts *, double *, double *, double *, double *,
+		   long);
+*/
+
+/* category index */
+/* cindex.c */
+int dig_cidx_init(struct Plus_head *);
+void dig_cidx_free(struct Plus_head *);
+int dig_cidx_add_cat(struct Plus_head *, int, int, int, int);
+int dig_cidx_add_cat_sorted(struct Plus_head *, int, int, int, int);
+int dig_cidx_del_cat(struct Plus_head *, int, int, int, int);
+void dig_cidx_sort(struct Plus_head *);
+
+/* cindex_rw.c */
+int dig_write_cidx_head(struct gvfile *, struct Plus_head *);
+int dig_read_cidx_head(struct gvfile *, struct Plus_head *);
+int dig_write_cidx(struct gvfile *, struct Plus_head *);
+int dig_read_cidx(struct gvfile *, struct Plus_head *, int);
+
+/* file.c */
+/* file loaded to memory; mostly unused */
+off_t dig_ftell(struct gvfile * file);
+int dig_fseek(struct gvfile * file, off_t offset, int whence);
+void dig_rewind(struct gvfile * file);
+int dig_fflush(struct gvfile * file);
+size_t dig_fread(void *ptr, size_t size, size_t nmemb, struct gvfile * file);
+size_t dig_fwrite(const void *ptr, size_t size, size_t nmemb, struct gvfile * file);
+void dig_file_init(struct gvfile * file);
+int dig_file_load(struct gvfile * file);
+void dig_file_free(struct gvfile * file);
+
+/* frmt.c */
+int dig_write_frmt_ascii(FILE *, struct Format_info *, int);
+int dig_read_frmt_ascii(FILE *, struct Format_info *);
+
+/* head.c */
+int dig__write_head(struct Map_info *);
+int dig__read_head(struct Map_info *);
+
+/* inside.c */
 double dig_x_intersect(double, double, double, double, double);
 double dig_x_intersect(double, double, double, double, double);
+
+/* linecross.c */
+int dig_test_for_intersection(double, double, double, double, double, double,
+			      double, double);
+int dig_find_intersection(double, double, double, double, double, double,
+			  double, double, double *, double *);
+
+/* line_dist.c */
 double dig_distance2_point_to_line(double, double, double, double, double,
 double dig_distance2_point_to_line(double, double, double, double, double,
 				   double, double, double, double, int,
 				   double, double, double, double, int,
 				   double *, double *, double *, double *,
 				   double *, double *, double *, double *,
 				   int *);
 				   int *);
+int dig_set_distance_to_line_tolerance(double);
 
 
-double dig_unit_conversion(void);
+/* list.c */
+int dig_init_list(struct ilist *);
+int dig_list_add(struct ilist *, int);
+int dig_init_boxlist(struct boxlist *);
+int dig_boxlist_add(struct boxlist *, int, struct bound_box);
 
 
-/* portable data routines  -  only to be called by library routines! */
-double *dig__double_convert(double *, double *, int, struct dig_head *);
-float *dig__float_convert(float *, float *, int, struct dig_head *);
-short *dig__short_convert(short *in, short *out, int, struct dig_head *);
-long *dig__long_convert(long *, long *, int, struct dig_head *);
-long *dig__int_convert(int *, long *, int, struct dig_head *);
-long *dig__plus_t_convert(plus_t *, long *, int, struct dig_head *);
-int *dig__long_convert_to_int(long *, int *, int, struct dig_head *);
-plus_t *dig__long_convert_to_plus_t(long *, plus_t *, int, struct dig_head *);
-char *dig__convert_buffer(int);
+/* plus.c */
+int dig_init_plus(struct Plus_head *);
+void dig_free_plus_nodes(struct Plus_head *);
+void dig_free_plus_lines(struct Plus_head *);
+void dig_free_plus_areas(struct Plus_head *);
+void dig_free_plus_isles(struct Plus_head *);
+void dig_free_plus(struct Plus_head *);
+int dig_load_plus(struct Plus_head *, struct gvfile *, int);
+int dig_write_plus_file(struct gvfile *, struct Plus_head *);
+int dig_write_nodes(struct gvfile *, struct Plus_head *);
+int dig_write_lines(struct gvfile *, struct Plus_head *);
+int dig_write_areas(struct gvfile *, struct Plus_head *);
+int dig_write_isles(struct gvfile *, struct Plus_head *);
 
 
-plus_t **dig_get_cont_lines(struct Map_info *, plus_t, double, int);
-plus_t dig_get_next_cont_line(struct Map_info *, plus_t, double, int);
+/* plus_area.c */
+int dig_add_area(struct Plus_head *, int, plus_t *, struct bound_box *);
+int dig_area_add_isle(struct Plus_head *, int, int);
+int dig_area_del_isle(struct Plus_head *, int, int);
+int dig_del_area(struct Plus_head *, int);
+int dig_add_isle(struct Plus_head *, int, plus_t *, struct bound_box *);
+int dig_del_isle(struct Plus_head *, int);
+int dig_build_area_with_line(struct Plus_head *, plus_t, int, plus_t **);
+int dig_angle_next_line(struct Plus_head *, plus_t, int, int);
+int dig_node_angle_check(struct Plus_head *, int, int);
+int dig_area_get_box(struct Plus_head *, plus_t, struct bound_box *);
+int dig_isle_get_box(struct Plus_head *, plus_t, struct bound_box *);
 
 
-struct dig_head *dig_get_head(void);
-struct dig_head *dig__get_head(void);
+/* plus_line.c */
+int dig_add_line(struct Plus_head *, int, const struct line_pnts *,
+		 struct bound_box *, off_t);
+int dig_restore_line(struct Plus_head *, int, int, struct line_pnts *,
+		     struct bound_box *, off_t);
+int dig_del_line(struct Plus_head *, int, double, double, double);
+plus_t dig_line_get_area(struct Plus_head *, plus_t, int);
+int dig_line_set_area(struct Plus_head *, plus_t, int, plus_t);
+
+/* plus_node.c */
+int dig_add_node(struct Plus_head *, double, double, double);
+int dig_which_node(struct Plus_head *, double, double, double);
+
+int dig_node_add_line(struct Plus_head *, int, int, const struct line_pnts *, int);
+float dig_node_line_angle(struct Plus_head *, int, int);
+
+/* plus_struct.c */
+int dig_Rd_P_node(struct Plus_head *, int i, struct gvfile *);
+int dig_Wr_P_node(struct Plus_head *, int i, struct gvfile *);
+int dig_Rd_P_line(struct Plus_head *, int i, struct gvfile *);
+int dig_Wr_P_line(struct Plus_head *, int i, struct gvfile *);
+int dig_Rd_P_area(struct Plus_head *, int i, struct gvfile *);
+int dig_Wr_P_area(struct Plus_head *, int i, struct gvfile *);
+int dig_Rd_P_isle(struct Plus_head *, int i, struct gvfile *);
+int dig_Wr_P_isle(struct Plus_head *, int i, struct gvfile *);
+int dig_Rd_Plus_head(struct gvfile *, struct Plus_head *);
+int dig_Wr_Plus_head(struct gvfile *, struct Plus_head *);
+
+/* poly.c */
+int dig_find_area_poly(struct line_pnts *, double *);
+double dig_find_poly_orientation(struct line_pnts *);
+int dig_get_poly_points(int, struct line_pnts **, int *, struct line_pnts *);
+
+/* portable.c */
 void dig_init_portable(struct Port_info *, int);
 void dig_init_portable(struct Port_info *, int);
 int dig__byte_order_out();
 int dig__byte_order_out();
 
 
 /* int dig__set_cur_head (struct dig_head *); */
 /* int dig__set_cur_head (struct dig_head *); */
 int dig_set_cur_port(struct Port_info *);
 int dig_set_cur_port(struct Port_info *);
-int dig__write_head(struct Map_info *);
-int dig__read_head(struct Map_info *);
 
 
 int dig__fread_port_D(double *, size_t, struct gvfile *);
 int dig__fread_port_D(double *, size_t, struct gvfile *);
 int dig__fread_port_F(float *, size_t, struct gvfile *);
 int dig__fread_port_F(float *, size_t, struct gvfile *);
@@ -71,94 +172,21 @@ int dig__fwrite_port_I(const int *, size_t, struct gvfile *);
 int dig__fwrite_port_P(const plus_t *, size_t, struct gvfile *);
 int dig__fwrite_port_P(const plus_t *, size_t, struct gvfile *);
 int dig__fwrite_port_C(const char *, size_t, struct gvfile *);
 int dig__fwrite_port_C(const char *, size_t, struct gvfile *);
 
 
+/* port_init.c */
 
 
-/******************************************************************************/
-int dig_build_area_with_line(struct Plus_head *, plus_t, int, plus_t **);
-plus_t dig_line_get_area(struct Plus_head *, plus_t, int);
-int dig_line_set_area(struct Plus_head *, plus_t, int, plus_t);
-int dig_add_area(struct Plus_head *, int, plus_t *);
-int dig_area_add_isle(struct Plus_head *, int, int);
-int dig_area_del_isle(struct Plus_head *, int, int);
-int dig_del_area(struct Plus_head *, int);
-int dig_angle_next_line(struct Plus_head *, plus_t, int, int);
-
-/* int dig_area_bound_box (struct Map_info *, struct P_area *); */
-int dig_bound_box2(struct line_pnts *, double *, double *, double *, double *,
-		   long);
-int dig_box_copy(struct bound_box *, struct bound_box *);
-int dig_box_extend(struct bound_box *, struct bound_box *);
-int dig_line_box(const struct line_pnts *, struct bound_box *);
-int dig_line_set_box(struct Plus_head *, plus_t, struct bound_box *);
-int dig_line_get_box(struct Plus_head *, plus_t, struct bound_box *);
-int dig_area_set_box(struct Plus_head *, plus_t, struct bound_box *);
-int dig_area_get_box(struct Plus_head *, plus_t, struct bound_box *);
-int dig_isle_set_box(struct Plus_head *, plus_t, struct bound_box *);
-int dig_isle_get_box(struct Plus_head *, plus_t, struct bound_box *);
-
-int dig_is_line_degenerate(const struct line_pnts *, double);
-
-/* int dig_check_nodes (struct Map_info *, struct new_node *, struct line_pnts *);
-   int dig_in_area_bbox (struct P_area *, double, double); */
-int dig_start_clock(long *);
-int dig_stop_clock(long *);
-char *dig_stop_clock_str(long *);
-int dig_write_file_checks(struct gvfile *, struct Plus_head *);
-int dig_do_file_checks(struct Map_info *, char *, char *);
-
-/* int dig_find_area (struct Map_info *, struct P_area *, double *, double *, double *, double);
-   int dig_find_area2 (struct Map_info *, struct P_area *, double *); */
-int dig_find_area_poly(struct line_pnts *, double *);
-double dig_find_poly_orientation(struct line_pnts *);
-int dig_get_poly_points(int, struct line_pnts **, int *, struct line_pnts *);
-int dig_add_isle(struct Plus_head *, int, plus_t *);
-int dig_del_isle(struct Plus_head *, int);
-int dig_set_distance_to_line_tolerance(double);
-int dig_test_for_intersection(double, double, double, double, double, double,
-			      double, double);
-int dig_find_intersection(double, double, double, double, double, double,
-			  double, double, double *, double *);
+/* port_test.c */
 
 
-int dig_init_plus(struct Plus_head *);
-void dig_free_plus_nodes(struct Plus_head *);
-void dig_free_plus_lines(struct Plus_head *);
-void dig_free_plus_areas(struct Plus_head *);
-void dig_free_plus_isles(struct Plus_head *);
-void dig_free_plus(struct Plus_head *);
-int dig_load_plus(struct Plus_head *, struct gvfile *, int);
-int dig_map_to_head(struct Map_info *, struct Plus_head *);
-int dig_head_to_map(struct Plus_head *, struct Map_info *);
-int dig_spindex_init(struct Plus_head *);
-
-/* int dig_snap_line_to_node (struct Map_info *, int, int, struct line_pnts *); */
-
-int dig_add_node(struct Plus_head *, double, double, double);
-int dig_which_node(struct Plus_head *, double, double, double);
-int dig_add_line(struct Plus_head *, int, const struct line_pnts *,
-		 off_t);
-int dig_restore_line(struct Plus_head *, int, int, struct line_pnts *,
-		     off_t);
-int dig_del_line(struct Plus_head *, int);
-int dig_node_add_line(struct Plus_head *, int, int, const struct line_pnts *, int);
-float dig_node_line_angle(struct Plus_head *, int, int);
-int dig_node_angle_check(struct Plus_head *, int, int);
-
-/* int dig_node_del_line (struct Plus_head *plus, int node, int line);
-   int dig_add_line_to_node (int, int, char, struct Map_info *, struct line_pnts *); */
-int dig_point_to_area(struct Map_info *, double, double);
-int dig_point_to_next_area(struct Map_info *, double, double, double *);
-int dig_point_to_line(struct Map_info *, double, double, char);
-
-/* list of updated */
-void dig_line_reset_updated(struct Plus_head *Plus);
-void dig_line_add_updated(struct Plus_head *Plus, int line);
-void dig_node_reset_updated(struct Plus_head *Plus);
-void dig_node_add_updated(struct Plus_head *Plus, int node);
-
-/* conversion of types */
-int dig_type_to_store(int);
-int dig_type_from_store(int);
+/* prune.c */
+int dig_prune(struct line_pnts *, double);
 
 
 /* spatial index */
 /* spatial index */
+/* spindex.c */
+int dig_spidx_init(struct Plus_head *);
+void dig_spidx_free_nodes(struct Plus_head *);
+void dig_spidx_free_lines(struct Plus_head *);
+void dig_spidx_free_areas(struct Plus_head *);
+void dig_spidx_free_isles(struct Plus_head *);
+void dig_spidx_free(struct Plus_head *);
 
 
 int dig_spidx_add_node(struct Plus_head *, int, double, double, double);
 int dig_spidx_add_node(struct Plus_head *, int, double, double, double);
 int dig_spidx_add_line(struct Plus_head *, int, struct bound_box *);
 int dig_spidx_add_line(struct Plus_head *, int, struct bound_box *);
@@ -166,22 +194,23 @@ int dig_spidx_add_area(struct Plus_head *, int, struct bound_box *);
 int dig_spidx_add_isle(struct Plus_head *, int, struct bound_box *);
 int dig_spidx_add_isle(struct Plus_head *, int, struct bound_box *);
 
 
 int dig_spidx_del_node(struct Plus_head *, int);
 int dig_spidx_del_node(struct Plus_head *, int);
-int dig_spidx_del_line(struct Plus_head *, int);
+int dig_spidx_del_line(struct Plus_head *, int, double, double, double);
 int dig_spidx_del_area(struct Plus_head *, int);
 int dig_spidx_del_area(struct Plus_head *, int);
 int dig_spidx_del_isle(struct Plus_head *, int);
 int dig_spidx_del_isle(struct Plus_head *, int);
 
 
 int dig_select_nodes(struct Plus_head *, const struct bound_box *, struct ilist *);
 int dig_select_nodes(struct Plus_head *, const struct bound_box *, struct ilist *);
 int dig_select_lines(struct Plus_head *, const struct bound_box *, struct ilist *);
 int dig_select_lines(struct Plus_head *, const struct bound_box *, struct ilist *);
+int dig_select_lines_with_box(struct Plus_head *, const struct bound_box *, struct boxlist *);
 int dig_select_areas(struct Plus_head *, const struct bound_box *, struct ilist *);
 int dig_select_areas(struct Plus_head *, const struct bound_box *, struct ilist *);
+int dig_select_areas_with_box(struct Plus_head *, const struct bound_box *, struct boxlist *);
 int dig_select_isles(struct Plus_head *, const struct bound_box *, struct ilist *);
 int dig_select_isles(struct Plus_head *, const struct bound_box *, struct ilist *);
+int dig_select_isles_with_box(struct Plus_head *, const struct bound_box *, struct boxlist *);
 int dig_find_node(struct Plus_head *, double, double, double);
 int dig_find_node(struct Plus_head *, double, double, double);
+int dig_find_line_box(const struct Plus_head *, struct boxlist *);
+int dig_find_area_box(const struct Plus_head *, struct boxlist *);
+int dig_find_isle_box(const struct Plus_head *, struct boxlist *);
 
 
-int dig_spidx_init(struct Plus_head *);
-void dig_spidx_free_nodes(struct Plus_head *);
-void dig_spidx_free_lines(struct Plus_head *);
-void dig_spidx_free_areas(struct Plus_head *);
-void dig_spidx_free_isles(struct Plus_head *);
-void dig_spidx_free(struct Plus_head *);
+/* spindex_rw.c */
 int dig_Rd_spidx_head(struct gvfile  *, struct Plus_head *);
 int dig_Rd_spidx_head(struct gvfile  *, struct Plus_head *);
 int dig_Wr_spidx_head(struct gvfile  *, struct Plus_head *);
 int dig_Wr_spidx_head(struct gvfile  *, struct Plus_head *);
 int dig_Wr_spidx(struct gvfile *, struct Plus_head *);
 int dig_Wr_spidx(struct gvfile *, struct Plus_head *);
@@ -192,32 +221,7 @@ int dig_dump_spidx(FILE *, const struct Plus_head *);
 int rtree_search(struct RTree *, struct Rect *, SearchHitCallback ,
 int rtree_search(struct RTree *, struct Rect *, SearchHitCallback ,
 		void *, struct Plus_head *);
 		void *, struct Plus_head *);
 
 
-/* category index */
-int dig_cidx_init(struct Plus_head *);
-void dig_cidx_free(struct Plus_head *);
-int dig_cidx_add_cat(struct Plus_head *, int, int, int, int);
-int dig_cidx_add_cat_sorted(struct Plus_head *, int, int, int, int);
-int dig_cidx_del_cat(struct Plus_head *, int, int, int, int);
-void dig_cidx_sort(struct Plus_head *);
-
-int dig_write_cidx_head(struct gvfile *, struct Plus_head *);
-int dig_read_cidx_head(struct gvfile *, struct Plus_head *);
-int dig_write_cidx(struct gvfile *, struct Plus_head *);
-int dig_read_cidx(struct gvfile *, struct Plus_head *, int);
-
-/* int dig_in_line_bbox (struct P_line *, double, double); */
-int dig_check_dist(struct Map_info *, int, double, double, double *);
-int dig__check_dist(struct Map_info *, struct line_pnts *, double, double,
-		    double *);
-/* int dig_center_check (struct P_line *, int, int, double, double); */
-int dig_point_by_line(struct Map_info *, double, double, double, double,
-		      char);
-/* int dig_by_line_bbox (struct P_line *, double, double, double, double); */
-int dig_prune(struct line_pnts *, double);
-int dig_write_head_ascii(FILE *, struct dig_head *);
-int dig_read_head_ascii(FILE *, struct dig_head *);
-int dig_write_frmt_ascii(FILE *, struct Format_info *, int);
-int dig_read_frmt_ascii(FILE *, struct Format_info *);
+/* struct_alloc.c */
 int dig_node_alloc_line(struct P_node *, int add);
 int dig_node_alloc_line(struct P_node *, int add);
 int dig_alloc_nodes(struct Plus_head *, int);
 int dig_alloc_nodes(struct Plus_head *, int);
 int dig_alloc_lines(struct Plus_head *, int);
 int dig_alloc_lines(struct Plus_head *, int);
@@ -225,6 +229,7 @@ int dig_alloc_areas(struct Plus_head *, int);
 int dig_alloc_isles(struct Plus_head *, int);
 int dig_alloc_isles(struct Plus_head *, int);
 struct P_node *dig_alloc_node();
 struct P_node *dig_alloc_node();
 struct P_line *dig_alloc_line();
 struct P_line *dig_alloc_line();
+void *dig_alloc_topo(char);
 struct P_area *dig_alloc_area();
 struct P_area *dig_alloc_area();
 struct P_isle *dig_alloc_isle();
 struct P_isle *dig_alloc_isle();
 void dig_free_node(struct P_node *);
 void dig_free_node(struct P_node *);
@@ -237,32 +242,88 @@ int dig_area_alloc_line(struct P_area *, int);
 int dig_area_alloc_isle(struct P_area *, int);
 int dig_area_alloc_isle(struct P_area *, int);
 int dig_isle_alloc_line(struct P_isle *, int);
 int dig_isle_alloc_line(struct P_isle *, int);
 int dig_out_of_memory(void);
 int dig_out_of_memory(void);
+
+/* type.c */
+/* conversion of types */
+int dig_type_to_store(int);
+int dig_type_from_store(int);
+
+/* update.c */
+/* unused */
+/* list of updated */
+void dig_line_reset_updated(struct Plus_head *Plus);
+void dig_line_add_updated(struct Plus_head *Plus, int line);
+void dig_node_reset_updated(struct Plus_head *Plus);
+void dig_node_add_updated(struct Plus_head *Plus, int node);
+
+
+
+
+/*********************************************************************
+ *		    unused/removed functions
+ *********************************************************************/
+
+
+char *color_name(int);		/* pass it an int, returns the name of the color */
+
+char *dig_float_point(char *, int, double);
+
+/* double dig_point_in_area (struct Map_info *, double, double, struct P_area *); */
+
+double dig_unit_conversion(void);
+
+/* portable data routines  -  only to be called by library routines! */
+double *dig__double_convert(double *, double *, int, struct dig_head *);
+float *dig__float_convert(float *, float *, int, struct dig_head *);
+short *dig__short_convert(short *in, short *out, int, struct dig_head *);
+long *dig__long_convert(long *, long *, int, struct dig_head *);
+long *dig__int_convert(int *, long *, int, struct dig_head *);
+long *dig__plus_t_convert(plus_t *, long *, int, struct dig_head *);
+int *dig__long_convert_to_int(long *, int *, int, struct dig_head *);
+plus_t *dig__long_convert_to_plus_t(long *, plus_t *, int, struct dig_head *);
+char *dig__convert_buffer(int);
+
+plus_t **dig_get_cont_lines(struct Map_info *, plus_t, double, int);
+plus_t dig_get_next_cont_line(struct Map_info *, plus_t, double, int);
+
+struct dig_head *dig_get_head(void);
+struct dig_head *dig__get_head(void);
+
+
+/* int dig_check_nodes (struct Map_info *, struct new_node *, struct line_pnts *);
+   int dig_in_area_bbox (struct P_area *, double, double); */
+int dig_start_clock(long *);
+int dig_stop_clock(long *);
+char *dig_stop_clock_str(long *);
+int dig_write_file_checks(struct gvfile *, struct Plus_head *);
+int dig_do_file_checks(struct Map_info *, char *, char *);
+
+/* int dig_find_area (struct Map_info *, struct P_area *, double *, double *, double *, double);
+   int dig_find_area2 (struct Map_info *, struct P_area *, double *); */
+
+int dig_map_to_head(struct Map_info *, struct Plus_head *);
+int dig_head_to_map(struct Plus_head *, struct Map_info *);
+int dig_spindex_init(struct Plus_head *);
+
+/* int dig_snap_line_to_node (struct Map_info *, int, int, struct line_pnts *); */
+
+/* int dig_node_del_line (struct Plus_head *plus, int node, int line);
+   int dig_add_line_to_node (int, int, char, struct Map_info *, struct line_pnts *); */
+int dig_point_to_area(struct Map_info *, double, double);
+int dig_point_to_next_area(struct Map_info *, double, double, double *);
+int dig_point_to_line(struct Map_info *, double, double, char);
+
+/* int dig_in_line_bbox (struct P_line *, double, double); */
+int dig_check_dist(struct Map_info *, int, double, double, double *);
+int dig__check_dist(struct Map_info *, struct line_pnts *, double, double,
+		    double *);
+/* int dig_center_check (struct P_line *, int, int, double, double); */
+int dig_point_by_line(struct Map_info *, double, double, double, double,
+		      char);
+/* int dig_by_line_bbox (struct P_line *, double, double, double, double); */
+int dig_write_head_ascii(FILE *, struct dig_head *);
+int dig_read_head_ascii(FILE *, struct dig_head *);
+
 int dig_struct_copy(void *, void *, int);
 int dig_struct_copy(void *, void *, int);
 int dig_rmcr(char *);
 int dig_rmcr(char *);
-int dig_write_plus_file(struct gvfile *, struct Plus_head *);
-int dig_write_nodes(struct gvfile *, struct Plus_head *);
-int dig_write_lines(struct gvfile *, struct Plus_head *);
-int dig_write_areas(struct gvfile *, struct Plus_head *);
-int dig_write_isles(struct gvfile *, struct Plus_head *);
 
 
-int dig_Rd_P_node(struct Plus_head *, int i, struct gvfile *);
-int dig_Wr_P_node(struct Plus_head *, int i, struct gvfile *);
-int dig_Rd_P_line(struct Plus_head *, int i, struct gvfile *);
-int dig_Wr_P_line(struct Plus_head *, int i, struct gvfile *);
-int dig_Rd_P_area(struct Plus_head *, int i, struct gvfile *);
-int dig_Wr_P_area(struct Plus_head *, int i, struct gvfile *);
-int dig_Rd_P_isle(struct Plus_head *, int i, struct gvfile *);
-int dig_Wr_P_isle(struct Plus_head *, int i, struct gvfile *);
-int dig_Rd_Plus_head(struct gvfile *, struct Plus_head *);
-int dig_Wr_Plus_head(struct gvfile *, struct Plus_head *);
-
-/* file loaded to memory */
-off_t dig_ftell(struct gvfile * file);
-int dig_fseek(struct gvfile * file, off_t offset, int whence);
-void dig_rewind(struct gvfile * file);
-int dig_fflush(struct gvfile * file);
-size_t dig_fread(void *ptr, size_t size, size_t nmemb, struct gvfile * file);
-size_t dig_fwrite(const void *ptr, size_t size, size_t nmemb, struct gvfile * file);
-void dig_file_init(struct gvfile * file);
-int dig_file_load(struct gvfile * file);
-void dig_file_free(struct gvfile * file);

+ 222 - 220
include/vect/dig_structs.h

@@ -5,6 +5,7 @@
 
 
   \author Written by Dave Gerdes (CERL)  5/1988
   \author Written by Dave Gerdes (CERL)  5/1988
   \author Updated to GRASS 5.7 by Radim Blazek (2001)
   \author Updated to GRASS 5.7 by Radim Blazek (2001)
+  \author Updated to GRASS 7.0 by Markus Metz (2011)
   \author Doxygenized by Martin Landa <landa.martin gmail.com> (2011)
   \author Doxygenized by Martin Landa <landa.martin gmail.com> (2011)
 */
 */
 #include <grass/config.h>
 #include <grass/config.h>
@@ -31,7 +32,7 @@
 /*!
 /*!
   \brief plus_t size
   \brief plus_t size
 
 
-  3.10 changes plus_t to ints. This assumes that any reasonable
+  3.10 changes plus_t to int. This assumes that any reasonable
   machine will use 4 bytes to store an int. The diglib code is not
   machine will use 4 bytes to store an int. The diglib code is not
   guaranteed to work if plus_t is changed to a type that is larger
   guaranteed to work if plus_t is changed to a type that is larger
   than an int.
   than an int.
@@ -98,7 +99,7 @@ struct gvfile
     */
     */
     FILE *file;
     FILE *file;
     /*!
     /*!
-      \brief Pointer to beginnig of the file in the memory
+      \brief Pointer to beginning of the file in the memory
     */
     */
     char *start;
     char *start;
     /*!
     /*!
@@ -127,16 +128,16 @@ struct gvfile
 };
 };
 
 
 /*!
 /*!
-  \brief Field (layer) information
+  \brief Layer (old: field) information
 */
 */
 struct field_info
 struct field_info
 {
 {
     /*!
     /*!
-      \brief Field number
+      \brief Layer number
     */
     */
     int number;
     int number;
     /*!
     /*!
-      \brief Field name (optional)
+      \brief Layer name (optional)
     */
     */
     char *name;
     char *name;
     /*!
     /*!
@@ -146,13 +147,13 @@ struct field_info
     /*!
     /*!
       brief Name of database
       brief Name of database
     */
     */
-    char *database;             
+    char *database;
     /*!
     /*!
       \brief Name of DB table
       \brief Name of DB table
     */
     */
     char *table;
     char *table;
     /*!
     /*!
-      \brief Name of key column (usually 'cat')
+      \brief Name of key column (usualy 'cat')
     */
     */
     char *key;
     char *key;
 };
 };
@@ -165,13 +166,13 @@ struct dblinks
     /*!
     /*!
       \brief Pointer to the first field_info structure
       \brief Pointer to the first field_info structure
     */
     */
-    struct field_info *field;   
+    struct field_info *field;
     /*!
     /*!
       \brief Number of allocated slots
       \brief Number of allocated slots
     */
     */
     int alloc_fields;
     int alloc_fields;
     /*!
     /*!
-      \brief Number of available fields (layers)
+      \brief Number of available layers (old: fields)
     */
     */
     int n_fields;
     int n_fields;
 };
 };
@@ -193,66 +194,66 @@ struct Port_info
     int off_t_size;
     int off_t_size;
 
 
     /*!
     /*!
-      \brief Vonversion matrices between file and native byte order (double)
+      \brief Conversion matrices between file and native byte order (double)
     */
     */
     unsigned char dbl_cnvrt[PORT_DOUBLE];
     unsigned char dbl_cnvrt[PORT_DOUBLE];
     /*!
     /*!
-      \brief Vonversion matrices between file and native byte order (float)
+      \brief Conversion matrices between file and native byte order (float)
     */
     */
     unsigned char flt_cnvrt[PORT_FLOAT];
     unsigned char flt_cnvrt[PORT_FLOAT];
     /*!
     /*!
-      \brief Vonversion matrices between file and native byte order (long)
+      \brief Conversion matrices between file and native byte order (long)
     */
     */
     unsigned char lng_cnvrt[PORT_LONG];
     unsigned char lng_cnvrt[PORT_LONG];
     /*!
     /*!
-      \brief Vonversion matrices between file and native byte order (int)
+      \brief Conversion matrices between file and native byte order (int)
     */
     */
     unsigned char int_cnvrt[PORT_INT];
     unsigned char int_cnvrt[PORT_INT];
     /*!
     /*!
-      \brief Vonversion matrices between file and native byte order (short)
+      \brief Conversion matrices between file and native byte order (short)
     */
     */
     unsigned char shrt_cnvrt[PORT_SHORT];
     unsigned char shrt_cnvrt[PORT_SHORT];
     /*!
     /*!
-      \brief Vonversion matrices between file and native byte order (off_t)
+      \brief Conversion matrices between file and native byte order (off_t)
     */
     */
     unsigned char off_t_cnvrt[PORT_OFF_T];
     unsigned char off_t_cnvrt[PORT_OFF_T];
     /*!
     /*!
-      \brief Byte order for dbl
+      \brief Quick reading flag for double
       
       
       Specify if native byte order of that type is the same
       Specify if native byte order of that type is the same
       as byte order of vector file (TRUE) or not (FALSE)
       as byte order of vector file (TRUE) or not (FALSE)
     */
     */
     int dbl_quick;
     int dbl_quick;
     /*!
     /*!
-      \brief Byte order for dbl
+      \brief Quick reading flag for float
       
       
       Specify if native byte order of that type is the same
       Specify if native byte order of that type is the same
       as byte order of vector file (TRUE) or not (FALSE)
       as byte order of vector file (TRUE) or not (FALSE)
     */
     */
     int flt_quick;
     int flt_quick;
     /*!
     /*!
-      \brief Byte order for lng
+      \brief Quick reading flag for long
       
       
       Specify if native byte order of that type is the same
       Specify if native byte order of that type is the same
       as byte order of vector file (TRUE) or not (FALSE)
       as byte order of vector file (TRUE) or not (FALSE)
     */
     */
     int lng_quick;
     int lng_quick;
     /*!
     /*!
-      \brief Byte order for int
+      \brief Quick reading flag for int
       
       
       Specify if native byte order of that type is the same
       Specify if native byte order of that type is the same
       as byte order of vector file (TRUE) or not (FALSE)
       as byte order of vector file (TRUE) or not (FALSE)
     */
     */
     int int_quick;
     int int_quick;
     /*!
     /*!
-      \brief Byte order for shrt
+      \brief Quick reading flag for short
       
       
       Specify if native byte order of that type is the same
       Specify if native byte order of that type is the same
       as byte order of vector file (TRUE) or not (FALSE)
       as byte order of vector file (TRUE) or not (FALSE)
     */
     */
     int shrt_quick;
     int shrt_quick;
     /*!
     /*!
-      \brief Byte order for off_t
+      \brief Quick reading flag for off_t
       
       
       Specify if native byte order of that type is the same
       Specify if native byte order of that type is the same
       as byte order of vector file (TRUE) or not (FALSE)
       as byte order of vector file (TRUE) or not (FALSE)
@@ -290,7 +291,7 @@ struct dig_head
     /*!
     /*!
       \brief User name
       \brief User name
     */
     */
-    char *your_name;
+    char *user_name;
     /*!
     /*!
       \brief Map name
       \brief Map name
     */
     */
@@ -306,7 +307,9 @@ struct dig_head
     /*!
     /*!
       \brief Comments
       \brief Comments
     */
     */
-    char *line_3;
+    char *comment;
+    int proj;			/* projection */
+
     /*!
     /*!
       \brief Zone (UTM only)
       \brief Zone (UTM only)
     */
     */
@@ -342,7 +345,7 @@ struct dig_head
       - zero for 2D data
       - zero for 2D data
       - non-zero for 3D data
       - non-zero for 3D data
     */
     */
-    int with_z;                 
+    int with_z;
 
 
     /*!
     /*!
       \brief Coor file size
       \brief Coor file size
@@ -418,7 +421,7 @@ struct Format_info_ogr
     /*!
     /*!
       \brief Pointer to OGRLayer
       \brief Pointer to OGRLayer
      */
      */
-    OGRLayerH layer;            
+    OGRLayerH layer;
 #else
 #else
     void *driver;
     void *driver;
     void *ds;
     void *ds;
@@ -512,11 +515,11 @@ struct Format_info
     /*!
     /*!
       \brief id?
       \brief id?
     */
     */
-    int i;                 
+    int i;
     /*!
     /*!
       \brief OGR info
       \brief OGR info
     */
     */
-    struct Format_info_ogr ogr; 
+    struct Format_info_ogr ogr;
 };
 };
 
 
 /*!
 /*!
@@ -629,14 +632,14 @@ struct Plus_head
       - WITH_Z
       - WITH_Z
       - WITHOUT_Z
       - WITHOUT_Z
     */
     */
-    int with_z;                  
+    int with_z;
     /*!
     /*!
       \brief 2D/3D spatial index
       \brief 2D/3D spatial index
 
 
       - WITH_Z
       - WITH_Z
       - WITHOUT_Z
       - WITHOUT_Z
     */
     */
-    int spidx_with_z;            
+    int spidx_with_z;
 
 
     /*!
     /*!
       \brief Offset size
       \brief Offset size
@@ -644,7 +647,7 @@ struct Plus_head
       Because Plus_head is available to all releveant
       Because Plus_head is available to all releveant
       functions
       functions
     */
     */
-    int off_t_size;              
+    int off_t_size;
 
 
     /*** file header size ***/
     /*** file header size ***/
     
     
@@ -662,7 +665,7 @@ struct Plus_head
     long cidx_head_size;	 
     long cidx_head_size;	 
 
 
     /*!
     /*!
-      \brief Release memory occupied by support
+      \brief Release memory occupied by support structures
       (topo, spatial, category)
       (topo, spatial, category)
     */
     */
     int release_support;	 
     int release_support;	 
@@ -676,14 +679,13 @@ struct Plus_head
     /*!
     /*!
       \brief Portability information for spatial index
       \brief Portability information for spatial index
     */
     */
-    struct Port_info spidx_port; 
+    struct Port_info spidx_port;
     /*!
     /*!
-      \brief Portability information for
-      category index
+      \brief Portability information for category index
     */
     */
     struct Port_info cidx_port;	 
     struct Port_info cidx_port;	 
     /*!
     /*!
-      \brie Access mode
+      \brief Access mode
       
       
       - GV_MODE_READ
       - GV_MODE_READ
       - GV_MODE_WRITE
       - GV_MODE_WRITE
@@ -709,57 +711,27 @@ struct Plus_head
 
 
     /*** topology ***/
     /*** topology ***/
    /*!
    /*!
-     \brief Array topo nodes
+     \brief Array of nodes
    */
    */
     struct P_node **Node;	 
     struct P_node **Node;	 
    /*!
    /*!
-     \brief Array topo lines/edges
+     \brief Array of vector geometries
    */
    */
     struct P_line **Line;	 
     struct P_line **Line;	 
    /*!
    /*!
-     \brief Array topo areas
+     \brief Array of areas
    */
    */
     struct P_area **Area;
     struct P_area **Area;
     /*!
     /*!
-      \brief Array topo isles
+      \brief Array of isles
     */
     */
     struct P_isle **Isle;
     struct P_isle **Isle;
     
     
     /* add here P_FACE, P_VOLUME, P_HOLE */
     /* add here P_FACE, P_VOLUME, P_HOLE */
-    
-    /*!
-      \brief Current number of nodes
-    */
-    plus_t n_nodes;		 
-    /*!
-      \brief Current number of edges
-    */
-    plus_t n_edges;	
-    /*!
-      \brief Current number of lines
-    */
-    plus_t n_lines;	
-    /*!
-      \brief Current number of areas
-    */
-    plus_t n_areas;	
-    /*!
-      \brief Current number of isles
-    */
-    plus_t n_isles;	
-    /*!
-      \brief Current number of faces
-    */
-    plus_t n_faces;	
-    /*!
-      \brief Current number of volumes
-    */
-    plus_t n_volumes;	
+
     /*!
     /*!
-      \brief Current number of holes
+      \brief Current number of vector geometries
     */
     */
-    plus_t n_holes;	
-
     /*!
     /*!
       \brief Current number of points
       \brief Current number of points
     */
     */
@@ -792,6 +764,43 @@ struct Plus_head
       \brief Current number of hole faces
       \brief Current number of hole faces
     */
     */
     plus_t n_hfaces;	
     plus_t n_hfaces;	
+    
+    /*!
+      \brief Current number of topological features derived from vector
+      geometries
+    */
+    /*!
+      \brief Current number of nodes
+    */
+    plus_t n_nodes;		 
+    /*!
+      \brief Current number of edges
+    */
+    plus_t n_edges;	
+    /*!
+      \brief Current number of lines
+    */
+    plus_t n_lines;	
+    /*!
+      \brief Current number of areas
+    */
+    plus_t n_areas;	
+    /*!
+      \brief Current number of isles
+    */
+    plus_t n_isles;	
+    /*!
+      \brief Current number of faces
+    */
+    plus_t n_faces;	
+    /*!
+      \brief Current number of volumes
+    */
+    plus_t n_volumes;	
+    /*!
+      \brief Current number of holes
+    */
+    plus_t n_holes;	
 
 
    /*!
    /*!
      \brief Number of allocated nodes
      \brief Number of allocated nodes
@@ -804,7 +813,7 @@ struct Plus_head
 
 
      i.e. array size - 1
      i.e. array size - 1
    */
    */
-    plus_t alloc_edges;  
+    plus_t alloc_edges;
    /*!
    /*!
      \brief Number of allocated lines
      \brief Number of allocated lines
 
 
@@ -849,19 +858,19 @@ struct Plus_head
     /*!
     /*!
       \brief Offset of array of edges in topo file
       \brief Offset of array of edges in topo file
     */
     */
-    off_t Edge_offset; 
+    off_t Edge_offset;
     /*!
     /*!
-      \brief Offset of array of lines in topo file
+      \brief Offset of array of vector geometries in topo file
     */
     */
-    off_t Line_offset; 
+    off_t Line_offset;
     /*!
     /*!
       \brief Offset of array of areas in topo file
       \brief Offset of array of areas in topo file
     */
     */
-    off_t Area_offset; 
+    off_t Area_offset;
     /*!
     /*!
       \brief Offset of array of isles in topo file
       \brief Offset of array of isles in topo file
     */
     */
-    off_t Isle_offset; 
+    off_t Isle_offset;
     /*!
     /*!
       \brief Offset of array of volumes in topo file
       \brief Offset of array of volumes in topo file
     */
     */
@@ -869,7 +878,7 @@ struct Plus_head
     /*!
     /*!
       \brief Offset of array of holes in topo file
       \brief Offset of array of holes in topo file
     */
     */
-    off_t Hole_offset;  
+    off_t Hole_offset;
 
 
     /*** spatial index ***/
     /*** spatial index ***/
     /*!
     /*!
@@ -883,18 +892,18 @@ struct Plus_head
 
 
       Set to 1 if new spatial index will be generated
       Set to 1 if new spatial index will be generated
     */
     */
-    int Spidx_new;               
+    int Spidx_new;
     /*!
     /*!
       \brief Build new spatial index in file
       \brief Build new spatial index in file
 
 
       Set to 1 to build new indices in file
       Set to 1 to build new indices in file
     */
     */
-    int Spidx_file;              
+    int Spidx_file;
 
 
     /*!
     /*!
       \brief Spatial index file pointer
       \brief Spatial index file pointer
     */
     */
-    struct gvfile spidx_fp;	 
+    struct gvfile spidx_fp;
 
 
     /*!
     /*!
       \brief Offset of nodes in sidx file
       \brief Offset of nodes in sidx file
@@ -903,27 +912,27 @@ struct Plus_head
     /*!
     /*!
       \brief Offset of lines in sidx file
       \brief Offset of lines in sidx file
     */
     */
-    off_t Line_spidx_offset;   
+    off_t Line_spidx_offset;
     /*!
     /*!
       \brief Offset of areas in sidx file
       \brief Offset of areas in sidx file
     */
     */
-    off_t Area_spidx_offset;   
+    off_t Area_spidx_offset;
     /*!
     /*!
       \brief Offset of isles in sidx file
       \brief Offset of isles in sidx file
     */
     */
-    off_t Isle_spidx_offset;   
+    off_t Isle_spidx_offset;
     /*!
     /*!
       \brief Offset of faces in sidx file
       \brief Offset of faces in sidx file
     */
     */
-    off_t Face_spidx_offset;   
+    off_t Face_spidx_offset;
     /*!
     /*!
       \brief Offset of volumes in sidx file
       \brief Offset of volumes in sidx file
     */
     */
-    off_t Volume_spidx_offset; 
+    off_t Volume_spidx_offset;
     /*!
     /*!
       \brief Offset of holes in sidx file
       \brief Offset of holes in sidx file
     */
     */
-    off_t Hole_spidx_offset;   
+    off_t Hole_spidx_offset;
 
 
     /*!
     /*!
       \brief Node spatial index
       \brief Node spatial index
@@ -932,27 +941,27 @@ struct Plus_head
     /*!
     /*!
       \brief Line spatial index
       \brief Line spatial index
     */
     */
-    struct RTree *Line_spidx;   
+    struct RTree *Line_spidx;
     /*!
     /*!
       \brief Area spatial index
       \brief Area spatial index
     */
     */
-    struct RTree *Area_spidx;   
+    struct RTree *Area_spidx;
     /*!
     /*!
       \brief Isles spatial index
       \brief Isles spatial index
     */
     */
-    struct RTree *Isle_spidx;   
+    struct RTree *Isle_spidx;
     /*!
     /*!
       \brief Faces spatial index
       \brief Faces spatial index
     */
     */
-    struct RTree *Face_spidx;   
+    struct RTree *Face_spidx;
     /*!
     /*!
       \brief Volumes spatial index
       \brief Volumes spatial index
     */
     */
-    struct RTree *Volume_spidx; 
+    struct RTree *Volume_spidx;
     /*!
     /*!
       \brief Holes spatial index
       \brief Holes spatial index
     */
     */
-    struct RTree *Hole_spidx;   
+    struct RTree *Hole_spidx;
 
 
     /*** category index ***/
     /*** category index ***/
     /*!
     /*!
@@ -960,7 +969,7 @@ struct Plus_head
 
 
       By default, category index is not updated 
       By default, category index is not updated 
     */
     */
-    int update_cidx;		  
+    int update_cidx;
 
 
     /*!
     /*!
       \brief Number of category indexes (one for each field/layer)
       \brief Number of category indexes (one for each field/layer)
@@ -1056,7 +1065,7 @@ struct Map_info
     struct dblinks *dblnk;	
     struct dblinks *dblnk;	
 
 
     /*!
     /*!
-      \brief Header info
+      \brief Topology info
     */
     */
     struct Plus_head plus;	
     struct Plus_head plus;	
 
 
@@ -1115,7 +1124,7 @@ struct Map_info
     */
     */
     int level;
     int level;
     /*!
     /*!
-      \brie Open only header
+      \brief Open only header
 
 
       Non-zero code to open only header of vector map
       Non-zero code to open only header of vector map
     */
     */
@@ -1138,7 +1147,7 @@ struct Map_info
     /*!
     /*!
       \brief Mapset name
       \brief Mapset name
     */
     */
-    char *mapset;              
+    char *mapset;
     /* location and gisdbase is usefull if changed (v.proj or external apps) */
     /* location and gisdbase is usefull if changed (v.proj or external apps) */
     /*!
     /*!
       \brief Location name
       \brief Location name
@@ -1164,29 +1173,9 @@ struct Map_info
     */
     */
     int Constraint_type_flag;
     int Constraint_type_flag;
     /*!
     /*!
-      \brief Constraints for reading features (north)
+      \brief Constraints for reading features (bounding box)
     */
     */
-    double Constraint_N;
-    /*!
-      \brief Constraints for reading features (south)
-    */
-    double Constraint_S;
-    /*!
-      \brief Constraints for reading features (east)
-    */
-    double Constraint_E;
-    /*!
-      \brief Constraints for reading features (west)
-    */
-    double Constraint_W;
-    /*!
-      \brief Constraints for reading features (top)
-    */
-    double Constraint_T;
-    /*!
-      \brief Constraints for reading features (bottom)
-    */
-    double Constraint_B;
+    struct bound_box Constraint_box;
     /*!
     /*!
       \brief Constraints for reading features (type)
       \brief Constraints for reading features (type)
     */
     */
@@ -1205,7 +1194,7 @@ struct Map_info
     /*!
     /*!
       \brief Coor file header info (native format only)
       \brief Coor file header info (native format only)
     */
     */
-    struct dig_head head;      
+    struct dig_head head;
 
 
     /* non native */
     /* non native */
     /*!
     /*!
@@ -1247,7 +1236,7 @@ struct Map_info
 };
 };
 
 
 /*!
 /*!
-  \brief Topological primitive - node
+  \brief Topological feature - node
 */
 */
 struct P_node
 struct P_node
 {
 {
@@ -1279,7 +1268,7 @@ struct P_node
     */
     */
     plus_t *lines;
     plus_t *lines;
     /*!
     /*!
-      \brief List of respected angles
+      \brief List of angles of connected lines
 
 
       Angles for lines/boundaries are in radians between -PI and
       Angles for lines/boundaries are in radians between -PI and
       PI. Value for points or lines with identical points
       PI. Value for points or lines with identical points
@@ -1288,61 +1277,91 @@ struct P_node
     float *angles;
     float *angles;
 };
 };
 
 
-/*!
-  \brief Topological primitive - line (edge)
+/*! 
+  \brief Line topology
 */
 */
-struct P_line
+struct P_topo_l
 {
 {
-    /*!
+    /*! 
       \brief Start node
       \brief Start node
     */
     */
     plus_t N1;
     plus_t N1;
-    /*!
+    /*! 
       \brief End node
       \brief End node
     */
     */
     plus_t N2;
     plus_t N2;
-    /*!
-      \brief Area/isle number to left
+};
 
 
-      - negative for isle
-      - area number for centroid (negative for duplicate centroid)
+/*!
+  \brief Boundary topology
+*/
+struct P_topo_b
+{
+    /*! 
+      \brief Start node
     */
     */
-    plus_t left;
-    /*!
-      \brief Area/isle number to right
-
-      - negative for isle
+    plus_t N1;
+    /*! 
+      \brief End node
     */
     */
-    plus_t right;
-    /*!
-      \brief Line bounding box - north
+    plus_t N2;
+    /*! 
+      \brief Area number to the left, negative for isle
     */
     */
-    double N;
-    /*!
-      \brief Line bounding box - south
+    plus_t left;
+    /*! 
+      \brief Area number to the right, negative for isle
     */
     */
-    double S;
-    /*!
-      \brief Line bounding box - east
+    plus_t right;
+};
+
+/*!
+  \brief Centroid topology
+*/
+struct P_topo_c
+{
+    /*! 
+      \brief Area number, negative for duplicate centroid
     */
     */
-    double E;
-    /*!
-      \brief Line bounding box - west
+    plus_t area;
+};
+
+/*! 
+  \brief Face topology
+*/
+struct P_topo_f
+{
+    /* TODO */
+    /*! 
+      \brief Array of edges
     */
     */
-    double W;
-    /*!
-      \brief Line bounding box - top (3D data only)
+    plus_t E[3];
+    /*! 
+      \brief Volume number to the left, negative for hole
     */
     */
-    double T;			
-    /*!
-      \brief Line bounding box - bottom (3D data only)
+    plus_t left;
+    /*! 
+      \brief Volume number to the right, negative for hole
     */
     */
-    double B;			
+    plus_t right;
+};
 
 
-    /*!
-      \brief Offset in coor file for line
+/*! 
+  \brief Kernel topology
+*/
+struct P_topo_k
+{
+    /*! 
+      \brief Volume number, negative for duplicate kernel
     */
     */
-    off_t offset;		
+    plus_t volume;
+};
+
+/*!
+  \brief Vector geometry
+*/
+struct P_line
+{
     /*!
     /*!
       \brief Line type
       \brief Line type
 
 
@@ -1355,39 +1374,23 @@ struct P_line
       - GV_AREA
       - GV_AREA
       - GV_VOLUME
       - GV_VOLUME
     */
     */
-    int type;
+    char type;
+    /*!
+      \brief Offset in coor file for line
+    */
+    off_t offset;		
+    /*!
+      \brief Topology info
+    */
+    void *topo;		
 };
 };
 
 
 /*!
 /*!
-  \brief Topological primitive - area
+  \brief Area (topology) info
 */
 */
 struct P_area
 struct P_area
 {
 {
     /*!
     /*!
-      \brief Area bounding box - north
-    */
-    double N;
-    /*!
-      \brief Area bounding box - south
-    */
-    double S;
-    /*!
-      \brief Area bounding box - east
-    */
-    double E;
-    /*!
-      \brief Area bounding box - west
-    */
-    double W;
-    /*!
-      \brief Area bounding box - top
-    */
-    double T;			
-    /*!
-      \brief Area bounding box - bottom
-    */
-    double B;			
-    /*!
       \brief Number of boundary lines
       \brief Number of boundary lines
     */
     */
     plus_t n_lines;
     plus_t n_lines;
@@ -1424,35 +1427,11 @@ struct P_area
 };
 };
 
 
 /*!
 /*!
-  \brief Topological primitive - isle
+  \brief Isle (topology) info
 */
 */
 struct P_isle
 struct P_isle
 {
 {
     /*!
     /*!
-      \brief Isle bounding box - north
-    */
-    double N;			
-    /*!
-      \brief Isle bounding box - south
-    */
-    double S;
-    /*!
-      \brief Isle bounding box - east
-    */
-    double E;
-    /*!
-      \brief Isle bounding box - west
-    */
-    double W;
-    /*!
-      \brief Isle bounding box - top
-    */
-    double T;			
-    /*!
-      \brief Isle bounding box - bottom
-    */
-    double B;
-    /*!
       \brief Number of boundary lines
       \brief Number of boundary lines
     */
     */
     plus_t n_lines;
     plus_t n_lines;
@@ -1477,14 +1456,14 @@ struct P_isle
 };
 };
 
 
 /*!
 /*!
-  \brief Feature geometry info
+  \brief Feature geometry info - coordinates
 */
 */
 struct line_pnts
 struct line_pnts
 {
 {
     /*!
     /*!
       \brief Array of X coordinates
       \brief Array of X coordinates
     */
     */
-    double *x; 
+    double *x;
     /*!
     /*!
       \brief Array of Y coordinates
       \brief Array of Y coordinates
     */
     */
@@ -1509,7 +1488,7 @@ struct line_pnts
 struct line_cats
 struct line_cats
 {
 {
     /*!
     /*!
-      \brief Array of fields (layers)
+      \brief Array of layers (fields)
     */
     */
     int *field;	
     int *field;	
     /*!
     /*!
@@ -1530,11 +1509,11 @@ struct line_cats
 struct cat_list
 struct cat_list
 {
 {
     /*!
     /*!
-      \brief Category field (layer)
+      \brief Category layer (field)
     */
     */
     int field;	
     int field;	
     /*!
     /*!
-      \brief Array of minimun values
+      \brief Array of minimum values
     */
     */
     int *min;			
     int *min;			
     /*!
     /*!
@@ -1542,7 +1521,7 @@ struct cat_list
     */
     */
     int *max;			
     int *max;			
     /*!
     /*!
-      \brie Number of ranges
+      \brief Number of ranges
     */
     */
     int n_ranges;		
     int n_ranges;		
     /*!
     /*!
@@ -1563,7 +1542,7 @@ struct ilist
     */
     */
     int *value;			
     int *value;			
     /*!
     /*!
-      \brief Number of values in the array
+      \brief Number of values in the list
     */
     */
     int n_values;		
     int n_values;		
     /*!
     /*!
@@ -1573,6 +1552,29 @@ struct ilist
 };
 };
 
 
 /*!
 /*!
+   \brief List of bounding boxes with id
+*/
+struct boxlist
+{
+    /*!
+      \brief Array of ids
+    */
+    int *id;
+    /*!
+      \brief Array of bounding boxes
+    */
+    struct bound_box *box;
+    /*!
+      \brief Number of items in the list
+    */
+    int n_values;		
+    /*!
+      \brief Allocated space for items
+    */
+    int alloc_values;
+};
+
+/*!
   \brief Vector array
   \brief Vector array
 
 
   Space allocated is size + 1
   Space allocated is size + 1
@@ -1600,13 +1602,13 @@ struct varray
 struct spatial_index
 struct spatial_index
 {
 {
     /*!
     /*!
-      \brief Pointer to the search tree (R*Tree)
+      \brief Pointer to the search tree (R*-Tree)
     */
     */
-    struct RTree *si_tree;      
+    struct RTree *si_tree;
     /*!
     /*!
-      \brief Name (used ?)
+      \brief Name of file to store the search tree
     */
     */
-    char *name;                 
+    char *name;
 };
 };
 
 
 #endif /* DIG___STRUCTS___ */
 #endif /* DIG___STRUCTS___ */

+ 17 - 2
include/vector.h

@@ -128,6 +128,16 @@ int Vect_val_in_list(const struct ilist *, int);
 int Vect_reset_list(struct ilist *);
 int Vect_reset_list(struct ilist *);
 void Vect_destroy_list(struct ilist *);
 void Vect_destroy_list(struct ilist *);
 
 
+/* List of bounding boxes with ids */
+struct boxlist *Vect_new_boxlist(void);
+int Vect_boxlist_append(struct boxlist *, int, struct bound_box);
+int Vect_boxlist_append_list(struct boxlist *, const struct boxlist *);
+int Vect_boxlist_delete(struct boxlist *, int);
+int Vect_boxlist_delete_boxlist(struct boxlist *, const struct boxlist *);
+int Vect_val_in_boxlist(const struct boxlist *, int);
+int Vect_reset_boxlist(struct boxlist *);
+void Vect_destroy_boxlist(struct boxlist *);
+
 /* Bounding box (MBR) */
 /* Bounding box (MBR) */
 int Vect_point_in_box(double, double, double, const struct bound_box *);
 int Vect_point_in_box(double, double, double, const struct bound_box *);
 int Vect_box_overlap(const struct bound_box *, const struct bound_box *);
 int Vect_box_overlap(const struct bound_box *, const struct bound_box *);
@@ -192,6 +202,7 @@ int Vect_get_constraint_box(const struct Map_info *, struct bound_box *);
 
 
 /* Get map level 2 informations */
 /* Get map level 2 informations */
 int Vect_level(const struct Map_info *);
 int Vect_level(const struct Map_info *);
+int Vect_get_line_type(const struct Map_info *, int);
 plus_t Vect_get_num_nodes(const struct Map_info *);
 plus_t Vect_get_num_nodes(const struct Map_info *);
 plus_t Vect_get_num_primitives(const struct Map_info *, int);
 plus_t Vect_get_num_primitives(const struct Map_info *, int);
 plus_t Vect_get_num_lines(const struct Map_info *);
 plus_t Vect_get_num_lines(const struct Map_info *);
@@ -295,8 +306,12 @@ char *Vect_hist_read(char *, int, const struct Map_info *);
 /* Selecting features */
 /* Selecting features */
 int Vect_select_lines_by_box(struct Map_info *, const struct bound_box *, int,
 int Vect_select_lines_by_box(struct Map_info *, const struct bound_box *, int,
 			     struct ilist *);
 			     struct ilist *);
+int Vect_select_lines_by_box_with_box(struct Map_info *, const struct bound_box *,
+			 int, struct boxlist *);
 int Vect_select_areas_by_box(struct Map_info *, const struct bound_box *, struct ilist *);
 int Vect_select_areas_by_box(struct Map_info *, const struct bound_box *, struct ilist *);
+int Vect_select_areas_by_box_with_box(struct Map_info *, const struct bound_box *, struct boxlist *);
 int Vect_select_isles_by_box(struct Map_info *, const struct bound_box *, struct ilist *);
 int Vect_select_isles_by_box(struct Map_info *, const struct bound_box *, struct ilist *);
+int Vect_select_isles_by_box_with_box(struct Map_info *, const struct bound_box *, struct boxlist *);
 int Vect_select_nodes_by_box(struct Map_info *, const struct bound_box *, struct ilist *);
 int Vect_select_nodes_by_box(struct Map_info *, const struct bound_box *, struct ilist *);
 int Vect_find_node(struct Map_info *, double, double, double, double, int);
 int Vect_find_node(struct Map_info *, double, double, double, double, int);
 int Vect_find_line(struct Map_info *, double, double, double, int, double,
 int Vect_find_line(struct Map_info *, double, double, double, int, double,
@@ -324,8 +339,8 @@ int Vect__intersect_line_with_poly(const struct line_pnts *, double,
 				   struct line_pnts *);
 				   struct line_pnts *);
 int Vect_get_point_in_poly(const struct line_pnts *, double *, double *);
 int Vect_get_point_in_poly(const struct line_pnts *, double *, double *);
 int Vect_point_in_poly(double, double, const struct line_pnts *);
 int Vect_point_in_poly(double, double, const struct line_pnts *);
-int Vect_point_in_area_outer_ring(double, double, const struct Map_info *, int);
-int Vect_point_in_island(double, double, const struct Map_info *, int);
+int Vect_point_in_area_outer_ring(double, double, const struct Map_info *, int, struct bound_box);
+int Vect_point_in_island(double, double, const struct Map_info *, int, struct bound_box);
 
 
 /* Cleaning */
 /* Cleaning */
 void Vect_break_lines(struct Map_info *, int, struct Map_info *);
 void Vect_break_lines(struct Map_info *, int, struct Map_info *);