[GRASS-SVN] r36448 - grass/trunk/lib/vector/diglib

svn_grass at osgeo.org svn_grass at osgeo.org
Sun Mar 22 16:34:01 EDT 2009


Author: mmetz
Date: 2009-03-22 16:34:01 -0400 (Sun, 22 Mar 2009)
New Revision: 36448

Modified:
   grass/trunk/lib/vector/diglib/poly.c
Log:
diglib bugfix and some tuning

Modified: grass/trunk/lib/vector/diglib/poly.c
===================================================================
--- grass/trunk/lib/vector/diglib/poly.c	2009-03-22 20:08:05 UTC (rev 36447)
+++ grass/trunk/lib/vector/diglib/poly.c	2009-03-22 20:34:01 UTC (rev 36448)
@@ -73,8 +73,8 @@
 	for (j = start; j != end; j += inc) {
 	    BPoints->x[point] = Points->x[j];
 	    BPoints->y[point] = Points->y[j];
+	    point++;
 	}
-	point++;
     }
     /* last point */
     BPoints->x[point] = Points->x[j];
@@ -117,7 +117,7 @@
 
 /*
  * find orientation of polygon
- * faster than signed area
+ * faster than signed area for > 4 vertices
  * 
  * return value is positive for CW, negative for CCW, 0 for degenerate
  *
@@ -150,33 +150,23 @@
     }
 
     /* Points are not pruned, so ... */
+    pprev = pnext = pcur;
 
     /* find next distinct point */
-    if (pcur == lastpoint)
-	pnext = 0;
-    else
-	pnext = pcur + 1;
-    while (pnext != pcur) {
-	if (x[pcur] != x[pnext] || y[pcur] != y[pnext])
-	    break;
+    do {
 	if (pnext < lastpoint - 1)
 	    pnext++;
 	else
 	    pnext = 0;
-    }
+    } while (pnext != pcur && x[pcur] == x[pnext] && y[pcur] == y[pnext]);
 
     /* find previous distinct point */
-    if (pcur == 0)
-	pcur = lastpoint;
-    pprev = pcur - 1;
-    while (pprev != pcur) {
-	if (x[pcur] != x[pprev] || y[pcur] != y[pprev])
-	    break;
-	if (pprev > 1)
+    do {
+	if (pprev > 0)
 	    pprev--;
 	else
-	    pprev = lastpoint;
-    }
+	    pprev = lastpoint - 1;
+    } while (pprev != pcur && x[pcur] == x[pprev] && y[pcur] == y[pprev]);
     
     /* orientation at vertex pcur == signed area for triangle pprev, pcur, pnext
      * rather use robust determinant of Olivier Devillers? */



More information about the grass-commit mailing list