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,
32 struct Map_info *Err,
int *lrm,
int *brm);
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);
147 abs_line = abs(next_line);
159 if (abs(next_line) == abs(current_line)) {
160 G_debug(4,
" dangle -> no bridge");
164 if (abs(next_line) == line) {
167 G_debug(5,
" other side reached");
175 current_line = -next_line;
179 if (!dangle && other_side) {
180 G_debug(3,
" line %d is part of bridge chain", line);
208 *lrm = lines_removed;
210 *brm = bridges_removed;
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.
void Vect_remove_bridges(struct Map_info *Map, struct Map_info *Err, int *lines_removed, int *bridges_removed)
Remove bridges from vector map.
void G_percent(long, long, int)
Print percent complete messages.
void void G_verbose_message(const char *,...) __attribute__((format(printf
int G_debug(int, const char *,...) __attribute__((format(printf
int rbtree_insert(struct RB_TREE *, void *)
int rbtree_init_trav(struct RB_TRAV *, struct RB_TREE *)
void rbtree_clear(struct RB_TREE *)
void * rbtree_find(struct RB_TREE *, const void *)
void * rbtree_traverse(struct RB_TRAV *)
void rbtree_destroy(struct RB_TREE *)
struct RB_TREE * rbtree_create(rb_compare_fn *, size_t)
void Vect_destroy_line_struct(struct line_pnts *)
Frees all memory associated with a line_pnts structure, including the structure itself.
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)
int Vect_get_line_nodes(struct Map_info *, int, int *, int *)
Get line nodes.
plus_t Vect_get_num_lines(struct Map_info *)
Fetch number of features (points, lines, boundaries, centroids) in vector map.
void Vect_destroy_cats_struct(struct line_cats *)
Frees all memory associated with line_cats structure, including the struct itself.
int Vect_read_line(struct Map_info *, struct line_pnts *, struct line_cats *, int)
Read vector feature (topological level required)
int Vect_line_alive(struct Map_info *, int)
Check if feature is alive or dead (topological level required)
int Vect_delete_line(struct Map_info *, off_t)
Delete existing feature (topological level required)
off_t Vect_write_line(struct Map_info *, int, const struct line_pnts *, const struct line_cats *)
Writes a new feature.
struct line_pnts * Vect_new_line_struct(void)
Creates and initializes a line_pnts structure.
struct line_cats * Vect_new_cats_struct(void)
Creates and initializes line_cats structure.
int Vect_get_line_areas(struct Map_info *, int, int *, int *)
Get area id on the left and right side of the boundary.
int dig_angle_next_line(struct Plus_head *, plus_t, int, int, float *)
Find line number of next angle to follow a line.
struct Plus_head plus
Plus info (topology, version, ...)
Basic topology-related info.
Feature geometry info - coordinates.