23 static int cmp_int(
const void *a,
const void *
b)
28 return (*ai < *bi ? -1 : (*ai > *bi));
31 static void remove_bridges(
struct Map_info *Map,
int chtype,
struct Map_info *Err,
49 int *lines_removed,
int *bridges_removed)
51 remove_bridges(Map, 0, Err, lines_removed, bridges_removed);
70 int *lines_changed,
int *bridges_changed)
72 remove_bridges(Map, 1, Err, lines_changed, bridges_changed);
91 int type, nlines, line, *bline;
92 int left, right, node1, node2, current_line, next_line, abs_line;
93 int bridges_removed = 0;
94 int lines_removed = 0;
98 struct RB_TREE *CycleTree, *BridgeTree;
101 int dangle, other_side;
113 G_debug(1,
"nlines = %d", nlines);
115 for (line = 1; line <= nlines; line++) {
126 if (left != 0 || right != 0)
129 G_debug(2,
"line %d - bridge candidate", line);
133 if (abs(node1) == abs(node2))
136 current_line = -line;
138 G_debug(3,
"current line: %d", line);
148 abs_line = abs(next_line);
160 if (abs(next_line) == abs(current_line)) {
161 G_debug(4,
" dangle -> no bridge");
165 if (abs(next_line) == line) {
168 G_debug(5,
" other side reached");
176 current_line = -next_line;
179 if (!dangle && other_side) {
180 G_debug(3,
" line %d is part of bridge chain", line);
209 *lrm = lines_removed;
211 *brm = bridges_removed;
void rbtree_clear(struct RB_TREE *)
void Vect_chtype_bridges(struct Map_info *Map, struct Map_info *Err, int *lines_changed, int *bridges_changed)
Change type of bridges in vector map.
plus_t Vect_get_num_lines(const struct Map_info *)
Fetch number of features (points, lines, boundaries, centroids) in vector map.
off_t Vect_rewrite_line(struct Map_info *, off_t, int, const struct line_pnts *, const struct line_cats *)
Rewrites existing feature (topological level required)
void * rbtree_find(struct RB_TREE *, const void *)
int rbtree_init_trav(struct RB_TRAV *, struct RB_TREE *)
struct RB_TREE * rbtree_create(rb_compare_fn *, size_t)
int dig_angle_next_line(struct Plus_head *, plus_t, int, int, float *)
Find line number of next angle to follow a line.
Feature geometry info - coordinates.
Basic topology-related info.
int rbtree_insert(struct RB_TREE *, void *)
struct line_pnts * Vect_new_line_struct(void)
Creates and initializes a line_pnts structure.
void Vect_destroy_cats_struct(struct line_cats *)
Frees all memory associated with line_cats structure, including the struct itself.
off_t Vect_write_line(struct Map_info *, int, const struct line_pnts *, const struct line_cats *)
Writes a new feature.
void Vect_remove_bridges(struct Map_info *Map, struct Map_info *Err, int *lines_removed, int *bridges_removed)
Remove bridges from vector map.
struct Plus_head plus
Plus info (topology, version, ...)
void * rbtree_traverse(struct RB_TRAV *)
int Vect_get_line_nodes(const struct Map_info *, int, int *, int *)
Get line nodes.
void G_percent(long, long, int)
Print percent complete messages.
int Vect_delete_line(struct Map_info *, off_t)
Delete existing feature (topological level required)
struct line_cats * Vect_new_cats_struct(void)
Creates and initializes line_cats structure.
int Vect_line_alive(const struct Map_info *, int)
Check if feature is alive or dead (topological level required)
void rbtree_destroy(struct RB_TREE *)
void Vect_destroy_line_struct(struct line_pnts *)
Frees all memory associated with a line_pnts structure, including the structure itself.
void void G_verbose_message(const char *,...) __attribute__((format(printf
int Vect_read_line(const struct Map_info *, struct line_pnts *, struct line_cats *, int)
Read vector feature (topological level required)
int G_debug(int, const char *,...) __attribute__((format(printf
int Vect_get_line_areas(const struct Map_info *, int, int *, int *)
Get area id on the left and right side of the boundary.