浏览代码

code cleanup

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@36805 15284696-431f-4ddb-bdfa-cd5b030d7da7
Huidae Cho 16 年之前
父节点
当前提交
9ccd19ef0e
共有 3 个文件被更改,包括 13 次插入13 次删除
  1. 3 3
      vector/v.in.dxf/add_lwpolyline.c
  2. 2 2
      vector/v.in.dxf/add_polyline.c
  3. 8 8
      vector/v.in.dxf/make_arc.c

+ 3 - 3
vector/v.in.dxf/add_lwpolyline.c

@@ -56,7 +56,7 @@ void add_lwpolyline(struct dxf_file *dxf, struct Map_info *Map)
 	    ypnts[arr_size] = atof(dxf_buf);
 	    yflag = 1;
 	    break;
-	case 38:
+	case 38:		/* elevation */
 	    elevation = atof(dxf_buf);
 	    break;
 	case 42:		/* bulge */
@@ -100,15 +100,15 @@ void add_lwpolyline(struct dxf_file *dxf, struct Map_info *Map)
 	    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++;
 	}
     }
 

+ 2 - 2
vector/v.in.dxf/add_polyline.c

@@ -257,15 +257,15 @@ static void write_pnts(struct Map_info *Map, char *layer, char *handle,
 	    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++;
 	}
     }
 

+ 8 - 8
vector/v.in.dxf/make_arc.c

@@ -31,14 +31,14 @@ int make_arc(int offset,	/* offset into array of points */
 	    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 - 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++;
 	}
     }
     else {
@@ -48,14 +48,14 @@ int make_arc(int offset,	/* offset into array of points */
 	    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 - 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++;
 	}
     }
     /* this insures that the last point will be correct */
@@ -63,13 +63,13 @@ int make_arc(int offset,	/* offset into array of points */
     xpnts[arr_size] = radius * cos(alpha) + centerx;
     ypnts[arr_size] = radius * sin(alpha) + centery;
     zpnts[arr_size] = zcoor;
-    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++;
 
     return arr_size - offset;
 }
@@ -88,13 +88,13 @@ int make_arc_from_polyline(int arr_size, double bulge, double prev_bulge)
 	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]))