[GRASS-SVN] r36804 - grass/branches/develbranch_6/vector/v.in.dxf

svn_grass at osgeo.org svn_grass at osgeo.org
Sun Apr 19 23:17:35 EDT 2009


Author: hcho
Date: 2009-04-19 23:17:35 -0400 (Sun, 19 Apr 2009)
New Revision: 36804

Modified:
   grass/branches/develbranch_6/vector/v.in.dxf/add_lwpolyline.c
   grass/branches/develbranch_6/vector/v.in.dxf/add_polyline.c
   grass/branches/develbranch_6/vector/v.in.dxf/make_arc.c
Log:
Support for LWPOLYLINE elevations

Modified: grass/branches/develbranch_6/vector/v.in.dxf/add_lwpolyline.c
===================================================================
--- grass/branches/develbranch_6/vector/v.in.dxf/add_lwpolyline.c	2009-04-20 03:08:01 UTC (rev 36803)
+++ grass/branches/develbranch_6/vector/v.in.dxf/add_lwpolyline.c	2009-04-20 03:17:35 UTC (rev 36804)
@@ -10,6 +10,7 @@
     int polyline_flag = 0;	/* indicates the type of polyline */
     int xflag = 0;		/* indicates if a x value has been found */
     int yflag = 0;		/* indicates if a y value has been found */
+    double elevation = 0.0;	/* elevation */
     int arr_size = 0;
 
     /* variables to create arcs */
@@ -18,7 +19,6 @@
 
     strcpy(layer, UNIDENTIFIED_LAYER);
 
-    zpnts[0] = 0.0;
     /* read in lines and process information until a 0 is read in */
     while ((code = dxf_get_code(dxf)) != 0) {
 	if (code == -2)
@@ -54,6 +54,9 @@
 	    ypnts[arr_size] = atof(dxf_buf);
 	    yflag = 1;
 	    break;
+	case 38:		/* elevation */
+	    elevation = atof(dxf_buf);
+	    break;
 	case 42:		/* bulge */
 	    bulge = atof(dxf_buf);
 	    break;
@@ -80,6 +83,13 @@
 	}
     }
 
+    {
+	int i;
+
+	for (i = 0; i < arr_size; i++)
+	    zpnts[i] = elevation;
+    }
+
     if (polyline_flag & 1) {
 	if (xpnts[0] != xpnts[arr_size - 1] ||
 	    ypnts[0] != ypnts[arr_size - 1]) {
@@ -87,25 +97,18 @@
 	    xpnts[arr_size] = xpnts[0];
 	    ypnts[arr_size] = ypnts[0];
 	    zpnts[arr_size] = zpnts[0];
+	    arr_size++;
 
 	    /* arr_size incremented to be consistent with polyline_flag != 1 */
-	    if (arr_size >= ARR_MAX - 1) {
+	    if (arr_size == ARR_MAX) {
 		ARR_MAX += ARR_INCR;
 		xpnts = (double *)G_realloc(xpnts, ARR_MAX * sizeof(double));
 		ypnts = (double *)G_realloc(ypnts, ARR_MAX * sizeof(double));
 		zpnts = (double *)G_realloc(zpnts, ARR_MAX * sizeof(double));
 	    }
-	    arr_size++;
 	}
     }
 
-    {
-	int i;
-
-	for (i = 0; i < arr_size; i++)
-	    zpnts[i] = 0.0;
-    }
-
     write_line(Map, layer, arr_size);
 
     return 0;

Modified: grass/branches/develbranch_6/vector/v.in.dxf/add_polyline.c
===================================================================
--- grass/branches/develbranch_6/vector/v.in.dxf/add_polyline.c	2009-04-20 03:08:01 UTC (rev 36803)
+++ grass/branches/develbranch_6/vector/v.in.dxf/add_polyline.c	2009-04-20 03:17:35 UTC (rev 36804)
@@ -253,15 +253,15 @@
 	    xpnts[arr_size] = xpnts[0];
 	    ypnts[arr_size] = ypnts[0];
 	    zpnts[arr_size] = zpnts[0];
+	    arr_size++;
 
 	    /* arr_size incremented to be consistent with polyline_flag != 1 */
-	    if (arr_size >= ARR_MAX - 1) {
+	    if (arr_size == ARR_MAX) {
 		ARR_MAX += ARR_INCR;
 		xpnts = (double *)G_realloc(xpnts, ARR_MAX * sizeof(double));
 		ypnts = (double *)G_realloc(ypnts, ARR_MAX * sizeof(double));
 		zpnts = (double *)G_realloc(zpnts, ARR_MAX * sizeof(double));
 	    }
-	    arr_size++;
 	}
     }
 

Modified: grass/branches/develbranch_6/vector/v.in.dxf/make_arc.c
===================================================================
--- grass/branches/develbranch_6/vector/v.in.dxf/make_arc.c	2009-04-20 03:08:01 UTC (rev 36803)
+++ grass/branches/develbranch_6/vector/v.in.dxf/make_arc.c	2009-04-20 03:17:35 UTC (rev 36804)
@@ -31,6 +31,7 @@
 	    xpnts[arr_size] = radius * cos(alpha) + centerx;
 	    ypnts[arr_size] = radius * sin(alpha) + centery;
 	    zpnts[arr_size] = zcoor;
+	    arr_size++;
 	    theta -= RSTEP;
 	    if (arr_size == ARR_MAX) {
 		ARR_MAX += ARR_INCR;
@@ -38,7 +39,6 @@
 		ypnts = (double *)G_realloc(ypnts, ARR_MAX * sizeof(double));
 		zpnts = (double *)G_realloc(zpnts, ARR_MAX * sizeof(double));
 	    }
-	    arr_size++;
 	}
     }
     else {
@@ -48,6 +48,7 @@
 	    xpnts[arr_size] = radius * cos(alpha) + centerx;
 	    ypnts[arr_size] = radius * sin(alpha) + centery;
 	    zpnts[arr_size] = zcoor;
+	    arr_size++;
 	    theta += RSTEP;
 	    if (arr_size == ARR_MAX) {
 		ARR_MAX += ARR_INCR;
@@ -55,7 +56,6 @@
 		ypnts = (double *)G_realloc(ypnts, ARR_MAX * sizeof(double));
 		zpnts = (double *)G_realloc(zpnts, ARR_MAX * sizeof(double));
 	    }
-	    arr_size++;
 	}
     }
     /* this insures that the last point will be correct */
@@ -63,13 +63,13 @@
     xpnts[arr_size] = radius * cos(alpha) + centerx;
     ypnts[arr_size] = radius * sin(alpha) + centery;
     zpnts[arr_size] = zcoor;
+    arr_size++;
     if (arr_size == ARR_MAX) {
 	ARR_MAX += ARR_INCR;
 	xpnts = (double *)G_realloc(xpnts, ARR_MAX * sizeof(double));
 	ypnts = (double *)G_realloc(ypnts, ARR_MAX * sizeof(double));
 	zpnts = (double *)G_realloc(zpnts, ARR_MAX * sizeof(double));
     }
-    arr_size++;
 
     return arr_size - offset;
 }
@@ -88,13 +88,13 @@
 	arc_tan = (-1.0) * prev_bulge;
 
     if (arc_tan == 0.0) {	/* straight line segment */
-	if (arr_size >= ARR_MAX - 1) {
+	arr_size++;
+	if (arr_size == ARR_MAX) {
 	    ARR_MAX += ARR_INCR;
 	    xpnts = (double *)G_realloc(xpnts, ARR_MAX * sizeof(double));
 	    ypnts = (double *)G_realloc(ypnts, ARR_MAX * sizeof(double));
 	    zpnts = (double *)G_realloc(zpnts, ARR_MAX * sizeof(double));
 	}
-	arr_size++;
     }
     else if (!(xpnts[arr_size - 1] == xpnts[arr_size] &&
 	       ypnts[arr_size - 1] == ypnts[arr_size]))



More information about the grass-commit mailing list