[GRASS-SVN] r36817 -
grass/branches/releasebranch_6_4/vector/v.in.dxf
svn_grass at osgeo.org
svn_grass at osgeo.org
Mon Apr 20 08:49:52 EDT 2009
Author: neteler
Date: 2009-04-20 08:49:52 -0400 (Mon, 20 Apr 2009)
New Revision: 36817
Modified:
grass/branches/releasebranch_6_4/vector/v.in.dxf/add_lwpolyline.c
grass/branches/releasebranch_6_4/vector/v.in.dxf/add_polyline.c
grass/branches/releasebranch_6_4/vector/v.in.dxf/make_arc.c
Log:
hcho: Support for LWPOLYLINE elevations (merge from develbranch_6, r36804)
Modified: grass/branches/releasebranch_6_4/vector/v.in.dxf/add_lwpolyline.c
===================================================================
--- grass/branches/releasebranch_6_4/vector/v.in.dxf/add_lwpolyline.c 2009-04-20 12:41:31 UTC (rev 36816)
+++ grass/branches/releasebranch_6_4/vector/v.in.dxf/add_lwpolyline.c 2009-04-20 12:49:52 UTC (rev 36817)
@@ -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/releasebranch_6_4/vector/v.in.dxf/add_polyline.c
===================================================================
--- grass/branches/releasebranch_6_4/vector/v.in.dxf/add_polyline.c 2009-04-20 12:41:31 UTC (rev 36816)
+++ grass/branches/releasebranch_6_4/vector/v.in.dxf/add_polyline.c 2009-04-20 12:49:52 UTC (rev 36817)
@@ -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/releasebranch_6_4/vector/v.in.dxf/make_arc.c
===================================================================
--- grass/branches/releasebranch_6_4/vector/v.in.dxf/make_arc.c 2009-04-20 12:41:31 UTC (rev 36816)
+++ grass/branches/releasebranch_6_4/vector/v.in.dxf/make_arc.c 2009-04-20 12:49:52 UTC (rev 36817)
@@ -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