21 #include <grass/gis.h>
22 #include <grass/Vect.h>
23 #include <grass/glocale.h>
25 #define REMOVE_DANGLE 0
26 #define CHTYPE_DANGLE 1
27 #define SELECT_DANGLE 2
29 static void dangles(
struct Map_info *,
int,
int,
double,
30 struct Map_info *,
struct ilist *);
128 static void dangles(
struct Map_info *Map,
int type,
int option,
129 double maxlength,
struct Map_info *Err,
130 struct ilist *List_dangle)
132 struct line_pnts *Points;
133 struct line_cats *Cats;
134 int i, line, ltype, next_line = 0, nnodelines;
135 int nnodes, node, node1, node2, next_node;
136 int lcount, tmp_next_line = 0;
143 next_line = tmp_next_line = 0;
151 lmsg =
"changed lines";
154 lmsg =
"removed lines";
157 lmsg =
"selected lines";
168 G_debug(2,
"nnodes = %d", nnodes);
170 for (node = 1; node <= nnodes; node++) {
179 for (i = 0; i < nnodelines; i++) {
181 G_debug(3,
" node line %d = %d", i, line);
193 G_debug(3,
" node %d is dangle -> follow the line %d", node,
196 while (next_line != 0) {
201 next_node = next_line > 0 ? node2 : node1;
203 G_debug(3,
" next_node = %d", next_node);
208 for (i = 0; i < nnodelines; i++) {
210 G_debug(3,
" node line %d = %d", i, line);
214 if (ltype & type && abs(line) != abs(next_line)) {
216 tmp_next_line = line;
220 next_line = tmp_next_line;
228 for (i = 0; i < List->n_values; i++) {
229 G_debug(3,
" chain line %d = %d", i, List->value[i]);
234 if (maxlength < 0 || length < maxlength) {
235 G_debug(3,
" delete the chain (length=%g)", length);
237 for (i = 0; i < List->n_values; i++) {
249 G_debug(3,
" rewrite line %d", List->value[i]);