|
@@ -192,9 +192,11 @@ int copy_tables_by_cats(struct Map_info *In, struct Map_info *Out)
|
|
int check_topo(struct Map_info *Out, int line, struct line_pnts *APoints,
|
|
int check_topo(struct Map_info *Out, int line, struct line_pnts *APoints,
|
|
struct line_pnts *Points, struct line_cats *Cats)
|
|
struct line_pnts *Points, struct line_cats *Cats)
|
|
{
|
|
{
|
|
- int i, intersect, newline, left_old, right_old,
|
|
|
|
|
|
+ int i, j, intersect, newline, left_old, right_old,
|
|
left_new, right_new;
|
|
left_new, right_new;
|
|
struct bound_box box;
|
|
struct bound_box box;
|
|
|
|
+ struct line_pnts **AXLines, **BXLines;
|
|
|
|
+ int naxlines, nbxlines;
|
|
static struct line_pnts *BPoints = NULL;
|
|
static struct line_pnts *BPoints = NULL;
|
|
static struct boxlist *List = NULL;
|
|
static struct boxlist *List = NULL;
|
|
|
|
|
|
@@ -203,15 +205,29 @@ int check_topo(struct Map_info *Out, int line, struct line_pnts *APoints,
|
|
if (!List)
|
|
if (!List)
|
|
List = Vect_new_boxlist(1);
|
|
List = Vect_new_boxlist(1);
|
|
|
|
|
|
- /* Check intersection of the modified boundary with other boundaries */
|
|
|
|
Vect_line_box(Points, &box);
|
|
Vect_line_box(Points, &box);
|
|
|
|
+
|
|
|
|
+ /* Check the modified boundary for self-intersection */
|
|
|
|
+ AXLines = BXLines = NULL;
|
|
|
|
+ Vect_line_intersection2(Points, NULL, &box, &box, &AXLines, &BXLines,
|
|
|
|
+ &naxlines, &nbxlines, 0);
|
|
|
|
+ /* Free */
|
|
|
|
+ if (naxlines > 0) {
|
|
|
|
+ for (j = 0; j < naxlines; j++) {
|
|
|
|
+ Vect_destroy_line_struct(AXLines[j]);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (AXLines)
|
|
|
|
+ G_free(AXLines);
|
|
|
|
+ if (naxlines > 0)
|
|
|
|
+ return 0;
|
|
|
|
+
|
|
|
|
+ /* Check intersection of the modified boundary with other boundaries */
|
|
Vect_select_lines_by_box(Out, &box, GV_BOUNDARY, List);
|
|
Vect_select_lines_by_box(Out, &box, GV_BOUNDARY, List);
|
|
|
|
|
|
intersect = 0;
|
|
intersect = 0;
|
|
for (i = 0; i < List->n_values; i++) {
|
|
for (i = 0; i < List->n_values; i++) {
|
|
- int j, bline;
|
|
|
|
- struct line_pnts **AXLines, **BXLines;
|
|
|
|
- int naxlines, nbxlines;
|
|
|
|
|
|
+ int bline;
|
|
|
|
|
|
bline = List->id[i];
|
|
bline = List->id[i];
|
|
if (bline == line)
|
|
if (bline == line)
|
|
@@ -223,8 +239,9 @@ int check_topo(struct Map_info *Out, int line, struct line_pnts *APoints,
|
|
* intersections should be found if any */
|
|
* intersections should be found if any */
|
|
|
|
|
|
AXLines = BXLines = NULL;
|
|
AXLines = BXLines = NULL;
|
|
- Vect_line_intersection(Points, BPoints, &box, &List->box[i], &AXLines, &BXLines,
|
|
|
|
- &naxlines, &nbxlines, 0);
|
|
|
|
|
|
+ Vect_line_intersection2(Points, BPoints, &box, &List->box[i],
|
|
|
|
+ &AXLines, &BXLines,
|
|
|
|
+ &naxlines, &nbxlines, 0);
|
|
|
|
|
|
G_debug(4,
|
|
G_debug(4,
|
|
"bline = %d intersect = %d naxlines = %d nbxlines = %d",
|
|
"bline = %d intersect = %d naxlines = %d nbxlines = %d",
|