[GRASS-SVN] r64484 - grass/branches/releasebranch_6_4/vector/v.generalize
svn_grass at osgeo.org
svn_grass at osgeo.org
Fri Feb 6 12:14:28 PST 2015
Author: mmetz
Date: 2015-02-06 12:14:28 -0800 (Fri, 06 Feb 2015)
New Revision: 64484
Modified:
grass/branches/releasebranch_6_4/vector/v.generalize/misc.c
Log:
v.generalize: add test for self-intersection
Modified: grass/branches/releasebranch_6_4/vector/v.generalize/misc.c
===================================================================
--- grass/branches/releasebranch_6_4/vector/v.generalize/misc.c 2015-02-06 20:08:21 UTC (rev 64483)
+++ grass/branches/releasebranch_6_4/vector/v.generalize/misc.c 2015-02-06 20:14:28 UTC (rev 64484)
@@ -88,12 +88,10 @@
int ttype, ntabs = 0;
struct field_info *IFi, *OFi;
struct line_cats *Cats;
- struct line_pnts *Points;
int **ocats, *nocats, *fields;
int i;
/* Collect list of output cats */
- Points = Vect_new_line_struct();
Cats = Vect_new_cats_struct();
nfields = Vect_cidx_get_num_fields(In);
ocats = (int **)G_malloc(nfields * sizeof(int *));
@@ -258,26 +256,49 @@
int check_topo(struct Map_info *Out, int line, struct line_pnts *APoints,
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;
struct bound_box box;
static struct line_pnts *BPoints = NULL;
static struct ilist *List = NULL;
+ struct line_pnts **AXLines, **BXLines;
+ int naxlines, nbxlines;
if (!BPoints)
BPoints = Vect_new_line_struct();
if (!List)
List = Vect_new_list();
+ /* Check the modified boundary for self-intersection */
+ AXLines = BXLines = NULL;
+ Vect_line_intersection(Points, Points, &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 (nbxlines > 0) {
+ for (j = 0; j < nbxlines; j++) {
+ Vect_destroy_line_struct(BXLines[j]);
+ }
+ }
+ if (BXLines)
+ G_free(BXLines);
+
+ if (naxlines > 0 || nbxlines > 0)
+ return 0;
+
/* Check intersection of the modified boundary with other boundaries */
Vect_line_box(Points, &box);
Vect_select_lines_by_box(Out, &box, GV_BOUNDARY, List);
intersect = 0;
for (i = 0; i < List->n_values; i++) {
- int j, bline;
- struct line_pnts **AXLines, **BXLines;
- int naxlines, nbxlines;
+ int bline;
bline = List->value[i];
if (bline == line)
More information about the grass-commit
mailing list