[GRASS-SVN] r46813 - grass/trunk/visualization/nviz2/cmd
svn_grass at osgeo.org
svn_grass at osgeo.org
Tue Jun 28 03:04:41 EDT 2011
Author: annakrat
Date: 2011-06-28 00:04:41 -0700 (Tue, 28 Jun 2011)
New Revision: 46813
Modified:
grass/trunk/visualization/nviz2/cmd/args.c
grass/trunk/visualization/nviz2/cmd/surface.c
Log:
nviz_cmd: fixed segmentation fault when loading more surfaces
Modified: grass/trunk/visualization/nviz2/cmd/args.c
===================================================================
--- grass/trunk/visualization/nviz2/cmd/args.c 2011-06-27 20:57:48 UTC (rev 46812)
+++ grass/trunk/visualization/nviz2/cmd/args.c 2011-06-28 07:04:41 UTC (rev 46813)
@@ -690,7 +690,7 @@
void check_parameters(const struct GParams *params)
{
int nelev_map, nelev_const, nelevs;
- int nmaps, nconsts;
+ int nmaps, nconsts, ncoords;
int nvlines;
@@ -779,6 +779,13 @@
G_fatal_error(_("Inconsistent number of attributes (<%s/%s> %d: <%s> %d)"),
params->elev_map->key, params->elev_const->key,
nelevs, params->wire_color->key, nconsts);
+
+ /* position */
+ ncoords = opt_get_num_answers(params->surface_pos);
+ if (ncoords > 0 && 3 * nelevs != ncoords)
+ G_fatal_error(_("Inconsistent number of attributes (<%s/%s> %d: <%s> %d)"),
+ params->elev_map->key, params->elev_const->key, nelevs,
+ params->surface_pos->key, ncoords);
}
/*
Modified: grass/trunk/visualization/nviz2/cmd/surface.c
===================================================================
--- grass/trunk/visualization/nviz2/cmd/surface.c 2011-06-27 20:57:48 UTC (rev 46812)
+++ grass/trunk/visualization/nviz2/cmd/surface.c 2011-06-28 07:04:41 UTC (rev 46813)
@@ -74,9 +74,9 @@
}
/* set position */
- x = atof(params->surface_pos->answers[i]);
- y = atof(params->surface_pos->answers[i+1]);
- z = atof(params->surface_pos->answers[i+2]);
+ x = atof(params->surface_pos->answers[i*3+0]);
+ y = atof(params->surface_pos->answers[i*3+1]);
+ z = atof(params->surface_pos->answers[i*3+2]);
GS_set_trans(id, x, y, z);
}
@@ -229,7 +229,7 @@
}
/* style */
- if (strcmp(params->style->answers[i], "wire") == 0) {
+ if (strcmp(style, "wire") == 0) {
draw_mode |= DM_GRID_WIRE;
}
else { /* surface */
@@ -237,7 +237,7 @@
}
/* shading */
- if (strcmp(params->shade->answers[i], "flat") == 0) {
+ if (strcmp(shade, "flat") == 0) {
draw_mode |= DM_FLAT;
}
else { /* gouraud */
More information about the grass-commit
mailing list