19 #include <grass/gis.h>
20 #include <grass/G3d.h>
21 #include <grass/gstypes.h>
22 #include <grass/glocale.h>
25 static int Vol_ID[MAX_VOLS];
26 static int Next_vol = 0;
28 static G3D_Region wind3;
29 static double Region[6];
41 Region[0] = wind3.north;
42 Region[1] = wind3.south;
43 Region[2] = wind3.west;
44 Region[3] = wind3.east;
45 Region[4] = wind3.top;
46 Region[5] = wind3.bottom;
101 for (i = 0; i < Next_vol && !found; i++) {
102 if (Vol_ID[i] ==
id) {
122 if (Next_vol < MAX_VOLS) {
126 wind3.south + wind3.ns_res / 2., wind3.bottom,
127 wind3.rows, wind3.cols, wind3.depths,
128 wind3.ew_res, wind3.ns_res, wind3.tb_res);
130 Vol_ID[Next_vol] = nvl->gvol_id;
133 G_debug(3,
" id=%d", nvl->gvol_id);
135 return (nvl->gvol_id);
168 ret = (
int *)G_malloc(Next_vol *
sizeof(
int));
172 for (i = 0; i < Next_vol; i++) {
208 for (i = 0; i < Next_vol && !found; i++) {
209 if (Vol_ID[i] ==
id) {
211 for (j = i; j < Next_vol; j++) {
212 Vol_ID[j] = Vol_ID[j + 1];
241 G_debug(3,
"GVL_load_vol(): id=%d, name=%s",
248 G_message(_(
"Loading 3d raster map <%s>..."), filename);
275 if (0 > gvl->hfile) {
299 *depths = gvl->depths;
301 G_debug(3,
"GVL_get_dims() id=%d, rows=%d, cols=%d, depths=%d",
302 gvl->gvol_id, gvl->rows, gvl->cols, gvl->depths);
323 gvl->x_trans = xtrans;
324 gvl->y_trans = ytrans;
325 gvl->z_trans = ztrans;
347 *xtrans = gvl->x_trans;
348 *ytrans = gvl->y_trans;
349 *ztrans = gvl->z_trans;
384 G_debug(3,
"GVL_draw_wire(): id=%d",
id);
402 for (
id = 0;
id < Next_vol;
id++) {
416 for (
id = 0;
id < Next_vol;
id++) {
439 gvl->clientdata = clientd;
462 return (gvl->clientdata);
478 G_debug(3,
"GS_set_focus_center_map");
483 center[
X] = (gvl->xmax - gvl->xmin) / 2.;
484 center[
Y] = (gvl->ymax - gvl->ymin) / 2.;
485 center[Z] = (gvl->zmax - gvl->zmin) / 2.;
510 G_debug(3,
"GVL_isosurf_get_drawres");
515 *xres = gvl->isosurf_x_mod;
516 *yres = gvl->isosurf_y_mod;
517 *zres = gvl->isosurf_z_mod;
537 G_debug(3,
"GVL_isosurf_set_drawres(): id=%d",
id);
539 if (xres < 1 || yres < 1 || zres < 1) {
546 gvl->isosurf_x_mod = xres;
547 gvl->isosurf_y_mod = yres;
548 gvl->isosurf_z_mod = zres;
550 for (i = 0; i < gvl->n_isosurfs; i++) {
576 *mode = gvl->isosurf_draw_mode;
597 G_debug(3,
"GVL_isosurf_set_drawmode(): id=%d mode=%d",
id, mode);
602 gvl->isosurf_draw_mode =
mode;
621 geovol_isosurf *isosurf;
623 G_debug(3,
"GVL_isosurf_add() id=%d",
id);
630 if (gvl->n_isosurfs == MAX_ISOSURFS)
633 isosurf = (geovol_isosurf *) G_malloc(
sizeof(geovol_isosurf));
641 gvl->isosurf[gvl->n_isosurfs - 1] = (geovol_isosurf *) isosurf;
658 geovol_isosurf *isosurf;
674 G_free(gvl->isosurf[isosurf_id]);
676 for (i = isosurf_id + 1; i < gvl->n_isosurfs; i++) {
677 gvl->isosurf[i - 1] = gvl->isosurf[i];
699 G_debug(3,
"GVL_isosurf_move_up");
706 if (isosurf_id < 0 || isosurf_id > (gvl->n_isosurfs - 1))
712 tmp = gvl->isosurf[isosurf_id - 1];
713 gvl->isosurf[isosurf_id - 1] = gvl->isosurf[isosurf_id];
714 gvl->isosurf[isosurf_id] = tmp;
733 G_debug(3,
"GVL_isosurf_move_up");
740 if (isosurf_id < 0 || isosurf_id > (gvl->n_isosurfs - 1))
743 if (isosurf_id == (gvl->n_isosurfs - 1))
746 tmp = gvl->isosurf[isosurf_id + 1];
747 gvl->isosurf[isosurf_id + 1] = gvl->isosurf[isosurf_id];
748 gvl->isosurf[isosurf_id] = tmp;
767 int att,
int *
set,
float *constant,
char *mapname)
770 geovol_isosurf *isosurf;
772 G_debug(3,
"GVL_isosurf_get_att");
780 if (src == CONST_ATT) {
781 *constant = isosurf->att[att].constant;
783 else if (src == MAP_ATT) {
808 geovol_isosurf *isosurf;
810 G_debug(3,
"GVL_isosurf_unset_att");
843 geovol_isosurf *isosurf;
845 G_debug(3,
"GVL_isosurf_set_att_const() id=%d isosurf_id=%d "
846 "att=%d const=%f",
id, isosurf_id, att, constant);
878 const char *filename)
880 geovol_isosurf *isosurf;
882 G_debug(3,
"GVL_isosurf_set_att_map(): id=%d, isosurf_id=%d "
883 "att=%d map=%s",
id, isosurf_id, att, filename);
906 geovol_isosurf *isosurf;
908 G_debug(3,
"GVL_isosurf_get_flags");
913 *inout = isosurf->inout_mode;
932 geovol_isosurf *isosurf;
934 G_debug(3,
"GVL_isosurf_get_flags");
939 isosurf->inout_mode = inout;
959 G_debug(3,
"GVL_isosurf_num_isosurfs");
964 return gvl->n_isosurfs;
984 geovol_isosurf *isosurf;
986 G_debug(3,
"GVL_isosurf_set_att_const");
991 isosurf->att[ATT_MASK].constant =
mode;
1011 geovol_isosurf *isosurf;
1016 *mode = isosurf->att[ATT_MASK].constant;
1039 G_debug(3,
"GVL_slice_get_drawres");
1044 *xres = gvl->slice_x_mod;
1045 *yres = gvl->slice_y_mod;
1046 *zres = gvl->slice_z_mod;
1066 G_debug(3,
"GVL_slice_set_drawres(): id=%d",
id);
1068 if (xres < 1 || yres < 1 || zres < 1) {
1075 gvl->slice_x_mod = xres;
1076 gvl->slice_y_mod = yres;
1077 gvl->slice_z_mod = zres;
1079 for (i = 0; i < gvl->n_slices; i++) {
1080 gvl->slice[i]->changed = 1;
1105 *mode = gvl->slice_draw_mode;
1126 G_debug(3,
"GVL_slice_set_drawmode(): id=%d, mode=%d",
id, mode);
1131 gvl->slice_draw_mode =
mode;
1150 geovol_slice *slice;
1159 if (gvl->n_slices == MAX_SLICES)
1162 if (
NULL == (slice = (geovol_slice *) G_malloc(
sizeof(geovol_slice)))) {
1169 gvl->slice[gvl->n_slices - 1] = (geovol_slice *) slice;
1186 geovol_slice *slice;
1202 G_free(gvl->slice[slice_id]);
1204 for (i = slice_id + 1; i < gvl->n_slices; i++) {
1205 gvl->slice[i - 1] = gvl->slice[i];
1227 G_debug(3,
"GVL_slice_move_up");
1234 if (slice_id < 0 || slice_id > (gvl->n_slices - 1))
1240 tmp = gvl->slice[slice_id - 1];
1241 gvl->slice[slice_id - 1] = gvl->slice[slice_id];
1242 gvl->slice[slice_id] = tmp;
1261 G_debug(3,
"GVL_slice_move_up");
1268 if (slice_id < 0 || slice_id > (gvl->n_slices - 1))
1271 if (slice_id == (gvl->n_slices - 1))
1274 tmp = gvl->slice[slice_id + 1];
1275 gvl->slice[slice_id + 1] = gvl->slice[slice_id];
1276 gvl->slice[slice_id] = tmp;
1293 G_debug(3,
"GVL_isosurf_num_isosurfs");
1298 return gvl->n_slices;
1317 float *x1,
float *x2,
float *y1,
float *y2,
float *z1,
1318 float *z2,
int *dir)
1321 geovol_slice *slice;
1322 int cols, rows, depths;
1334 if (slice->dir ==
X) {
1339 else if (slice->dir ==
Y) {
1344 else if (slice->dir == Z) {
1347 depths = gvl->depths;
1353 *x1 = slice->x1 / (cols - 1);
1354 *x2 = slice->x2 / (cols - 1);
1355 *y1 = slice->y1 / (rows - 1);
1356 *y2 = slice->y2 / (rows - 1);
1357 *z1 = slice->z1 / (depths - 1);
1358 *z2 = slice->z2 / (depths - 1);
1378 float x1,
float x2,
float y1,
float y2,
float z1,
1382 geovol_slice *slice;
1383 int cols, rows, depths;
1400 else if (dir ==
Y) {
1405 else if (dir == Z) {
1408 depths = gvl->depths;
1414 slice->x1 = ((x1 < 0.) ? 0. : ((x1 > 1.) ? 1. : x1)) * (cols - 1);
1415 slice->x2 = ((x2 < 0.) ? 0. : ((x2 > 1.) ? 1. : x2)) * (cols - 1);
1416 slice->y1 = ((y1 < 0.) ? 0. : ((y1 > 1.) ? 1. : y1)) * (rows - 1);
1417 slice->y2 = ((y2 < 0.) ? 0. : ((y2 > 1.) ? 1. : y2)) * (rows - 1);
1418 slice->z1 = ((z1 < 0.) ? 0. : ((z1 > 1.) ? 1. : z1)) * (depths - 1);
1419 slice->z2 = ((z2 < 0.) ? 0. : ((z2 > 1.) ? 1. : z2)) * (depths - 1);
1440 geovol_slice *slice;
1449 *transp = slice->transp;
1466 geovol_slice *slice;
1475 slice->transp = transp;