|
@@ -29,7 +29,8 @@
|
|
|
*/
|
|
|
int load_rasters3d(const struct GParams *params, nv_data *data)
|
|
|
{
|
|
|
- int i, nvol, id;
|
|
|
+ int i, nvol, id;
|
|
|
+ float x, y, z;
|
|
|
char *mapset;
|
|
|
|
|
|
nvol = opt_get_num_answers(params->volume);
|
|
@@ -45,6 +46,20 @@ int load_rasters3d(const struct GParams *params, nv_data *data)
|
|
|
G_fully_qualified_name(params->volume->answers[i],
|
|
|
mapset),
|
|
|
0.0, data);
|
|
|
+
|
|
|
+ /* set position */
|
|
|
+ if (opt_get_num_answers(params->volume_pos) != 3 * nvol) {
|
|
|
+ x = atof(params->volume_pos->answers[0]);
|
|
|
+ y = atof(params->volume_pos->answers[1]);
|
|
|
+ z = atof(params->volume_pos->answers[2]);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ x = atof(params->volume_pos->answers[i*3+0]);
|
|
|
+ y = atof(params->volume_pos->answers[i*3+1]);
|
|
|
+ z = atof(params->volume_pos->answers[i*3+2]);
|
|
|
+ }
|
|
|
+
|
|
|
+ GVL_set_trans(id, x, y, z);
|
|
|
}
|
|
|
|
|
|
return 1;
|
|
@@ -62,7 +77,10 @@ int add_isosurfs(const struct GParams *params, nv_data *data)
|
|
|
{
|
|
|
int i;
|
|
|
int num, level, nvols, *vol_list, id, nisosurfs;
|
|
|
+ int ncolor_map, ncolor_const, ntransp_map, ntransp_const, nshine_map, nshine_const;
|
|
|
+ int res, draw_mode;
|
|
|
char **tokens;
|
|
|
+ const char *mapset, *style;
|
|
|
|
|
|
vol_list = GVL_get_vol_list(&nvols);
|
|
|
|
|
@@ -94,12 +112,98 @@ int add_isosurfs(const struct GParams *params, nv_data *data)
|
|
|
nisosurfs-1, ATT_TOPO, id);
|
|
|
}
|
|
|
|
|
|
+ /* set resolution */
|
|
|
+ if (opt_get_num_answers(params->volume_res) != nvols)
|
|
|
+ res = atof(params->volume_res->answers[0]);
|
|
|
+ else
|
|
|
+ res = atof(params->volume_res->answers[i]);
|
|
|
+
|
|
|
+ GVL_isosurf_set_drawres(id, res, res, res);
|
|
|
+
|
|
|
+ /* set shading */
|
|
|
+ if (opt_get_num_answers(params->volume_shade) != nvols)
|
|
|
+ style = params->volume_shade->answers[0];
|
|
|
+ else
|
|
|
+ style = params->volume_shade->answers[i];
|
|
|
+
|
|
|
+ draw_mode = 0;
|
|
|
+
|
|
|
+ if (strcmp(style, "flat") == 0) {
|
|
|
+ draw_mode |= DM_FLAT;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ draw_mode |= DM_GOURAUD;
|
|
|
+ }
|
|
|
+
|
|
|
+ GVL_isosurf_set_drawmode(id, draw_mode);
|
|
|
+
|
|
|
/* color */
|
|
|
- if (GVL_isosurf_set_att_map(id, nisosurfs-1, ATT_COLOR, params->volume->answers[0]) < 0) {
|
|
|
- G_fatal_error(_("Unable to set isosurface (%d) attribute (%d) of volume %d"),
|
|
|
- nisosurfs-1, ATT_COLOR, id);
|
|
|
+ ncolor_map = opt_get_num_answers(params->isosurf_color_map);
|
|
|
+ ncolor_const = opt_get_num_answers(params->isosurf_color_const);
|
|
|
+
|
|
|
+ if (i < ncolor_map && strcmp(params->isosurf_color_map->answers[i], "")) {
|
|
|
+ mapset = G_find_grid3(params->isosurf_color_map->answers[i], "");
|
|
|
+
|
|
|
+ if (mapset == NULL) {
|
|
|
+ G_fatal_error(_("3d raster map <%s> not found"),
|
|
|
+ params->isosurf_color_map->answers[i]);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (GVL_isosurf_set_att_map(id, nisosurfs-1, ATT_COLOR,
|
|
|
+ params->isosurf_color_map->answers[i]) < 0)
|
|
|
+ G_fatal_error(_("Unable to set isosurface (%d) attribute (%d) of volume %d"),
|
|
|
+ nisosurfs-1, ATT_COLOR, id);
|
|
|
+ }
|
|
|
+ else if (i-ncolor_map < ncolor_const &&
|
|
|
+ strcmp(params->isosurf_color_const->answers[i-ncolor_map], "")) {
|
|
|
+
|
|
|
+ if (GVL_isosurf_set_att_const(id, nisosurfs-1, ATT_COLOR,
|
|
|
+ Nviz_color_from_str(params->isosurf_color_const->answers[i-ncolor_map])) < 0)
|
|
|
+ G_fatal_error(_("Unable to set isosurface (%d) attribute (%d) of volume %d"),
|
|
|
+ nisosurfs-1, ATT_COLOR, id);
|
|
|
+ }
|
|
|
+ else { /* use by default 3d raster map for coloring */
|
|
|
+ GVL_isosurf_set_att_map(id, nisosurfs-1, ATT_COLOR, params->volume->answers[num-1]);
|
|
|
+ G_verbose_message(_("Color attribute not defined, using default <%s>"),
|
|
|
+ params->volume->answers[num-1]);
|
|
|
+ }
|
|
|
+
|
|
|
+ /* transparency */
|
|
|
+ ntransp_map = opt_get_num_answers(params->isosurf_transp_map);
|
|
|
+ ntransp_const = opt_get_num_answers(params->isosurf_transp_const);
|
|
|
+
|
|
|
+ if (i < ntransp_map && strcmp(params->isosurf_transp_map->answers[i], "")) {
|
|
|
+ if (GVL_isosurf_set_att_map(id, nisosurfs-1, ATT_TRANSP,
|
|
|
+ params->isosurf_transp_map->answers[i]) < 0)
|
|
|
+ G_fatal_error(_("Unable to set isosurface (%d) attribute (%d) of volume %d"),
|
|
|
+ nisosurfs-1, ATT_TRANSP, id);
|
|
|
+ }
|
|
|
+ else if (i-ntransp_map < ntransp_const &&
|
|
|
+ strcmp(params->isosurf_transp_const->answers[i-ntransp_map], "")) {
|
|
|
+ if (GVL_isosurf_set_att_const(id, nisosurfs-1, ATT_TRANSP,
|
|
|
+ atof(params->isosurf_transp_const->answers[i-ntransp_map])) < 0)
|
|
|
+ G_fatal_error(_("Unable to set isosurface (%d) attribute (%d) of volume %d"),
|
|
|
+ nisosurfs-1, ATT_TRANSP, id);
|
|
|
+ }
|
|
|
+
|
|
|
+ /* shine */
|
|
|
+ nshine_map = opt_get_num_answers(params->isosurf_shine_map);
|
|
|
+ nshine_const = opt_get_num_answers(params->isosurf_shine_const);
|
|
|
+
|
|
|
+ if (i < nshine_map && strcmp(params->isosurf_shine_map->answers[i], "")) {
|
|
|
+ if (GVL_isosurf_set_att_map(id, nisosurfs-1, ATT_SHINE,
|
|
|
+ params->isosurf_shine_map->answers[i]) < 0)
|
|
|
+ G_fatal_error(_("Unable to set isosurface (%d) attribute (%d) of volume %d"),
|
|
|
+ nisosurfs-1, ATT_SHINE, id);
|
|
|
+ }
|
|
|
+ else if (i-nshine_map < nshine_const &&
|
|
|
+ strcmp(params->isosurf_shine_const->answers[i-nshine_map], "")) {
|
|
|
+ if (GVL_isosurf_set_att_const(id, nisosurfs-1, ATT_SHINE,
|
|
|
+ atof(params->isosurf_shine_const->answers[i-nshine_map])) < 0)
|
|
|
+ G_fatal_error(_("Unable to set isosurface (%d) attribute (%d) of volume %d"),
|
|
|
+ nisosurfs-1, ATT_SHINE, id);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
return 1;
|
|
|
}
|