GRASS Programmer's Manual  6.5.svn(2014)-r66266
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
GVL2.c
Go to the documentation of this file.
1 
19 #include <grass/gis.h>
20 #include <grass/G3d.h>
21 #include <grass/gstypes.h>
22 #include <grass/glocale.h>
23 #include "gsget.h"
24 
25 static int Vol_ID[MAX_VOLS];
26 static int Next_vol = 0;
27 
28 static G3D_Region wind3;
29 static double Region[6];
30 
36 void GVL_libinit(void)
37 {
39  G3d_getWindow(&wind3);
40 
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;
47 
48  return;
49 }
50 
59 int GVL_get_region(float *n, float *s, float *w, float *e, float *t, float *b)
60 {
61  *n = Region[0];
62  *s = Region[1];
63  *w = Region[2];
64  *e = Region[3];
65  *t = Region[4];
66  *b = Region[5];
67 
68  return (1);
69 }
70 
79 {
80  return &wind3;
81 }
82 
91 int GVL_vol_exists(int id)
92 {
93  int i, found = 0;
94 
95  G_debug(3, "GVL_vol_exists");
96 
97  if (NULL == gvl_get_vol(id)) {
98  return (0);
99  }
100 
101  for (i = 0; i < Next_vol && !found; i++) {
102  if (Vol_ID[i] == id) {
103  found = 1;
104  }
105  }
106 
107  return (found);
108 }
109 
116 int GVL_new_vol(void)
117 {
118  geovol *nvl;
119 
120  G_debug(3, "GVL_new_vol():");
121 
122  if (Next_vol < MAX_VOLS) {
123  nvl = gvl_get_new_vol();
124 
125  gvl_init_vol(nvl, wind3.west + wind3.ew_res / 2.,
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);
129 
130  Vol_ID[Next_vol] = nvl->gvol_id;
131  ++Next_vol;
132 
133  G_debug(3, " id=%d", nvl->gvol_id);
134 
135  return (nvl->gvol_id);
136  }
137 
138  return (-1);
139 }
140 
146 int GVL_num_vols(void)
147 {
148  return (gvl_num_vols());
149 }
150 
161 int *GVL_get_vol_list(int *numvols)
162 {
163  int i, *ret;
164 
165  *numvols = Next_vol;
166 
167  if (Next_vol) {
168  ret = (int *)G_malloc(Next_vol * sizeof(int));
169  if (!ret)
170  return (NULL);
171 
172  for (i = 0; i < Next_vol; i++) {
173  ret[i] = Vol_ID[i];
174  }
175 
176  return (ret);
177  }
178 
179  return (NULL);
180 }
181 
190 int GVL_delete_vol(int id)
191 {
192  int i, j, found = 0;
193 
194  G_debug(3, "GVL_delete_vol");
195 
196  if (GVL_vol_exists(id)) {
197 
198  for (i = 0; i < GVL_isosurf_num_isosurfs(id); i++) {
199  GVL_isosurf_del(id, 0);
200  }
201 
202  for (i = 0; i < GVL_slice_num_slices(id); i++) {
203  GVL_slice_del(id, 0);
204  }
205 
206  gvl_delete_vol(id);
207 
208  for (i = 0; i < Next_vol && !found; i++) {
209  if (Vol_ID[i] == id) {
210  found = 1;
211  for (j = i; j < Next_vol; j++) {
212  Vol_ID[j] = Vol_ID[j + 1];
213  }
214  }
215  }
216 
217  if (found) {
218  --Next_vol;
219 
220  return (1);
221  }
222  }
223 
224  return (-1);
225 }
226 
236 int GVL_load_vol(int id, const char *filename)
237 {
238  geovol *gvl;
239  int handle;
240 
241  G_debug(3, "GVL_load_vol(): id=%d, name=%s",
242  id, filename);
243 
244  if (NULL == (gvl = gvl_get_vol(id))) {
245  return (-1);
246  }
247 
248  G_message(_("Loading 3d raster map <%s>..."), filename);
249 
250  if (0 > (handle = gvl_file_newh(filename, VOL_FTYPE_G3D)))
251  return (-1);
252 
253  gvl->hfile = handle;
254 
255  return (0);
256 }
257 
267 int GVL_get_volname(int id, char *filename)
268 {
269  geovol *gvl;
270 
271  if (NULL == (gvl = gvl_get_vol(id))) {
272  return (-1);
273  }
274 
275  if (0 > gvl->hfile) {
276  return (-1);
277  }
278 
279  G_strcpy(filename, gvl_file_get_name(gvl->hfile));
280 
281  return (1);
282 }
283 
290 void GVL_get_dims(int id, int *rows, int *cols, int *depths)
291 {
292  geovol *gvl;
293 
294  gvl = gvl_get_vol(id);
295 
296  if (gvl) {
297  *rows = gvl->rows;
298  *cols = gvl->cols;
299  *depths = gvl->depths;
300 
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);
303  }
304 
305  return;
306 }
307 
314 void GVL_set_trans(int id, float xtrans, float ytrans, float ztrans)
315 {
316  geovol *gvl;
317 
318  G_debug(3, "GVL_set_trans");
319 
320  gvl = gvl_get_vol(id);
321 
322  if (gvl) {
323  gvl->x_trans = xtrans;
324  gvl->y_trans = ytrans;
325  gvl->z_trans = ztrans;
326  }
327 
328  return;
329 }
330 
340 int GVL_get_trans(int id, float *xtrans, float *ytrans, float *ztrans)
341 {
342  geovol *gvl;
343 
344  gvl = gvl_get_vol(id);
345 
346  if (gvl) {
347  *xtrans = gvl->x_trans;
348  *ytrans = gvl->y_trans;
349  *ztrans = gvl->z_trans;
350 
351  return (1);
352  }
353 
354  return (-1);
355 }
356 
362 void GVL_draw_vol(int vid)
363 {
364  geovol *gvl;
365 
366  gvl = gvl_get_vol(vid);
367 
368  if (gvl) {
369  gvld_vol(gvl);
370  }
371 
372  return;
373 }
374 
380 void GVL_draw_wire(int id)
381 {
382  geovol *gvl;
383 
384  G_debug(3, "GVL_draw_wire(): id=%d", id);
385 
386  gvl = gvl_get_vol(id);
387 
388  if (gvl) {
389  gvld_wire_vol(gvl);
390  }
391 
392  return;
393 }
394 
398 void GVL_alldraw_vol(void)
399 {
400  int id;
401 
402  for (id = 0; id < Next_vol; id++) {
403  GVL_draw_vol(Vol_ID[id]);
404  }
405 
406  return;
407 }
408 
413 {
414  int id;
415 
416  for (id = 0; id < Next_vol; id++) {
417  GVL_draw_wire(Vol_ID[id]);
418  }
419 
420  return;
421 }
422 
432 int GVL_Set_ClientData(int id, void *clientd)
433 {
434  geovol *gvl;
435 
436  gvl = gvl_get_vol(id);
437 
438  if (gvl) {
439  gvl->clientdata = clientd;
440 
441  return (1);
442  }
443 
444  return (-1);
445 }
446 
455 void *GVL_Get_ClientData(int id)
456 {
457  geovol *gvl;
458 
459  gvl = gvl_get_vol(id);
460 
461  if (gvl) {
462  return (gvl->clientdata);
463  }
464 
465  return (NULL);
466 }
467 
474 {
475  float center[3];
476  geovol *gvl;
477 
478  G_debug(3, "GS_set_focus_center_map");
479 
480  gvl = gvl_get_vol(id);
481 
482  if (gvl) {
483  center[X] = (gvl->xmax - gvl->xmin) / 2.;
484  center[Y] = (gvl->ymax - gvl->ymin) / 2.;
485  center[Z] = (gvl->zmax - gvl->zmin) / 2.;
486 
487  GS_set_focus(center);
488  }
489 
490  return;
491 }
492 
493 /************************************************************************/
494 /* ISOSURFACES */
495 
496 /************************************************************************/
497 
506 void GVL_isosurf_get_drawres(int id, int *xres, int *yres, int *zres)
507 {
508  geovol *gvl;
509 
510  G_debug(3, "GVL_isosurf_get_drawres");
511 
512  gvl = gvl_get_vol(id);
513 
514  if (gvl) {
515  *xres = gvl->isosurf_x_mod;
516  *yres = gvl->isosurf_y_mod;
517  *zres = gvl->isosurf_z_mod;
518  }
519 
520  return;
521 }
522 
532 int GVL_isosurf_set_drawres(int id, int xres, int yres, int zres)
533 {
534  geovol *gvl;
535  int i;
536 
537  G_debug(3, "GVL_isosurf_set_drawres(): id=%d", id);
538 
539  if (xres < 1 || yres < 1 || zres < 1) {
540  return (-1);
541  }
542 
543  gvl = gvl_get_vol(id);
544 
545  if (gvl) {
546  gvl->isosurf_x_mod = xres;
547  gvl->isosurf_y_mod = yres;
548  gvl->isosurf_z_mod = zres;
549 
550  for (i = 0; i < gvl->n_isosurfs; i++) {
551  gvl_isosurf_set_att_changed(gvl->isosurf[i], ATT_TOPO);
552  }
553 
554  return (0);
555  }
556 
557  return (-1);
558 }
559 
570 {
571  geovol *gvl;
572 
573  gvl = gvl_get_vol(id);
574 
575  if (gvl) {
576  *mode = gvl->isosurf_draw_mode;
577 
578  return (1);
579  }
580 
581  return (-1);
582 }
583 
594 {
595  geovol *gvl;
596 
597  G_debug(3, "GVL_isosurf_set_drawmode(): id=%d mode=%d", id, mode);
598 
599  gvl = gvl_get_vol(id);
600 
601  if (gvl) {
602  gvl->isosurf_draw_mode = mode;
603 
604  return (0);
605  }
606 
607  return (-1);
608 }
609 
618 int GVL_isosurf_add(int id)
619 {
620  geovol *gvl;
621  geovol_isosurf *isosurf;
622 
623  G_debug(3, "GVL_isosurf_add() id=%d", id);
624 
625  gvl = gvl_get_vol(id);
626 
627  if (!gvl)
628  return (-1);
629 
630  if (gvl->n_isosurfs == MAX_ISOSURFS)
631  return (-1);
632 
633  isosurf = (geovol_isosurf *) G_malloc(sizeof(geovol_isosurf));
634  if (!isosurf) {
635  return (-1);
636  }
637 
638  gvl_isosurf_init(isosurf);
639 
640  gvl->n_isosurfs++;
641  gvl->isosurf[gvl->n_isosurfs - 1] = (geovol_isosurf *) isosurf;
642 
643  return (1);
644 }
645 
655 int GVL_isosurf_del(int id, int isosurf_id)
656 {
657  geovol *gvl;
658  geovol_isosurf *isosurf;
659  int i;
660 
661  G_debug(3, "GVL_isosurf_del");
662 
663  isosurf = gvl_isosurf_get_isosurf(id, isosurf_id);
664 
665  if (!isosurf)
666  return (-1);
667 
668  if (!gvl_isosurf_freemem(isosurf)) {
669  return (-1);
670  }
671 
672  gvl = gvl_get_vol(id);
673 
674  G_free(gvl->isosurf[isosurf_id]);
675 
676  for (i = isosurf_id + 1; i < gvl->n_isosurfs; i++) {
677  gvl->isosurf[i - 1] = gvl->isosurf[i];
678  }
679 
680  gvl->n_isosurfs--;
681 
682  return (1);
683 }
684 
694 int GVL_isosurf_move_up(int id, int isosurf_id)
695 {
696  geovol *gvl;
697  geovol_isosurf *tmp;
698 
699  G_debug(3, "GVL_isosurf_move_up");
700 
701  gvl = gvl_get_vol(id);
702 
703  if (!gvl)
704  return (-1);
705 
706  if (isosurf_id < 0 || isosurf_id > (gvl->n_isosurfs - 1))
707  return (-1);
708 
709  if (isosurf_id == 0)
710  return (1);
711 
712  tmp = gvl->isosurf[isosurf_id - 1];
713  gvl->isosurf[isosurf_id - 1] = gvl->isosurf[isosurf_id];
714  gvl->isosurf[isosurf_id] = tmp;
715 
716  return (1);
717 }
718 
728 int GVL_isosurf_move_down(int id, int isosurf_id)
729 {
730  geovol *gvl;
731  geovol_isosurf *tmp;
732 
733  G_debug(3, "GVL_isosurf_move_up");
734 
735  gvl = gvl_get_vol(id);
736 
737  if (!gvl)
738  return (-1);
739 
740  if (isosurf_id < 0 || isosurf_id > (gvl->n_isosurfs - 1))
741  return (-1);
742 
743  if (isosurf_id == (gvl->n_isosurfs - 1))
744  return (1);
745 
746  tmp = gvl->isosurf[isosurf_id + 1];
747  gvl->isosurf[isosurf_id + 1] = gvl->isosurf[isosurf_id];
748  gvl->isosurf[isosurf_id] = tmp;
749 
750  return (1);
751 }
752 
766 int GVL_isosurf_get_att(int id, int isosurf_id,
767  int att, int *set, float *constant, char *mapname)
768 {
769  int src;
770  geovol_isosurf *isosurf;
771 
772  G_debug(3, "GVL_isosurf_get_att");
773 
774  isosurf = gvl_isosurf_get_isosurf(id, isosurf_id);
775 
776  if (isosurf) {
777  if (-1 != (src = gvl_isosurf_get_att_src(isosurf, att))) {
778  *set = src;
779 
780  if (src == CONST_ATT) {
781  *constant = isosurf->att[att].constant;
782  }
783  else if (src == MAP_ATT) {
784  G_strcpy(mapname, gvl_file_get_name(isosurf->att[att].hfile));
785  }
786 
787  return (1);
788  }
789 
790  return (-1);
791  }
792 
793  return (-1);
794 }
795 
806 int GVL_isosurf_unset_att(int id, int isosurf_id, int att)
807 {
808  geovol_isosurf *isosurf;
809 
810  G_debug(3, "GVL_isosurf_unset_att");
811 
812  isosurf = gvl_isosurf_get_isosurf(id, isosurf_id);
813 
814  if (isosurf) {
815  return (gvl_isosurf_set_att_src(isosurf, att, NOTSET_ATT));
816  }
817 
818  return (-1);
819 }
820 
841 int GVL_isosurf_set_att_const(int id, int isosurf_id, int att, float constant)
842 {
843  geovol_isosurf *isosurf;
844 
845  G_debug(3, "GVL_isosurf_set_att_const() id=%d isosurf_id=%d "
846  "att=%d const=%f", id, isosurf_id, att, constant);
847 
848  isosurf = gvl_isosurf_get_isosurf(id, isosurf_id);
849 
850  if (isosurf) {
851  return (gvl_isosurf_set_att_const(isosurf, att, constant));
852  }
853 
854  return (-1);
855 }
856 
877 int GVL_isosurf_set_att_map(int id, int isosurf_id, int att,
878  const char *filename)
879 {
880  geovol_isosurf *isosurf;
881 
882  G_debug(3, "GVL_isosurf_set_att_map(): id=%d, isosurf_id=%d "
883  "att=%d map=%s", id, isosurf_id, att, filename);
884 
885  isosurf = gvl_isosurf_get_isosurf(id, isosurf_id);
886 
887  if (isosurf) {
888  return gvl_isosurf_set_att_map(isosurf, att, filename);
889  }
890 
891  return (-1);
892 }
893 
904 int GVL_isosurf_get_flags(int id, int isosurf_id, int *inout)
905 {
906  geovol_isosurf *isosurf;
907 
908  G_debug(3, "GVL_isosurf_get_flags");
909 
910  isosurf = gvl_isosurf_get_isosurf(id, isosurf_id);
911 
912  if (isosurf) {
913  *inout = isosurf->inout_mode;
914 
915  return (1);
916  }
917  return (-1);
918 }
919 
930 int GVL_isosurf_set_flags(int id, int isosurf_id, int inout)
931 {
932  geovol_isosurf *isosurf;
933 
934  G_debug(3, "GVL_isosurf_get_flags");
935 
936  isosurf = gvl_isosurf_get_isosurf(id, isosurf_id);
937 
938  if (isosurf) {
939  isosurf->inout_mode = inout;
940 
941  return (1);
942  }
943 
944  return (-1);
945 }
946 
956 {
957  geovol *gvl;
958 
959  G_debug(3, "GVL_isosurf_num_isosurfs");
960 
961  gvl = gvl_get_vol(id);
962 
963  if (gvl) {
964  return gvl->n_isosurfs;
965  }
966 
967  return (-1);
968 }
969 
982 int GVL_isosurf_set_maskmode(int id, int isosurf_id, int mode)
983 {
984  geovol_isosurf *isosurf;
985 
986  G_debug(3, "GVL_isosurf_set_att_const");
987 
988  isosurf = gvl_isosurf_get_isosurf(id, isosurf_id);
989 
990  if (isosurf) {
991  isosurf->att[ATT_MASK].constant = mode;
992 
993  return (mode);
994  }
995 
996  return (-1);
997 }
998 
1009 int GVL_isosurf_get_maskmode(int id, int isosurf_id, int *mode)
1010 {
1011  geovol_isosurf *isosurf;
1012 
1013  isosurf = gvl_isosurf_get_isosurf(id, isosurf_id);
1014 
1015  if (isosurf) {
1016  *mode = isosurf->att[ATT_MASK].constant;
1017 
1018  return (1);
1019  }
1020 
1021  return (-1);
1022 }
1023 
1024 /************************************************************************/
1025 /* SLICES */
1026 
1027 /************************************************************************/
1028 
1035 void GVL_slice_get_drawres(int id, int *xres, int *yres, int *zres)
1036 {
1037  geovol *gvl;
1038 
1039  G_debug(3, "GVL_slice_get_drawres");
1040 
1041  gvl = gvl_get_vol(id);
1042 
1043  if (gvl) {
1044  *xres = gvl->slice_x_mod;
1045  *yres = gvl->slice_y_mod;
1046  *zres = gvl->slice_z_mod;
1047  }
1048 
1049  return;
1050 }
1051 
1061 int GVL_slice_set_drawres(int id, int xres, int yres, int zres)
1062 {
1063  geovol *gvl;
1064  int i;
1065 
1066  G_debug(3, "GVL_slice_set_drawres(): id=%d", id);
1067 
1068  if (xres < 1 || yres < 1 || zres < 1) {
1069  return (-1);
1070  }
1071 
1072  gvl = gvl_get_vol(id);
1073 
1074  if (gvl) {
1075  gvl->slice_x_mod = xres;
1076  gvl->slice_y_mod = yres;
1077  gvl->slice_z_mod = zres;
1078 
1079  for (i = 0; i < gvl->n_slices; i++) {
1080  gvl->slice[i]->changed = 1;
1081  }
1082 
1083  return (0);
1084  }
1085 
1086  return (-1);
1087 }
1088 
1098 int GVL_slice_get_drawmode(int id, int *mode)
1099 {
1100  geovol *gvl;
1101 
1102  gvl = gvl_get_vol(id);
1103 
1104  if (gvl) {
1105  *mode = gvl->slice_draw_mode;
1106 
1107  return (1);
1108  }
1109 
1110  return (-1);
1111 }
1112 
1123 {
1124  geovol *gvl;
1125 
1126  G_debug(3, "GVL_slice_set_drawmode(): id=%d, mode=%d", id, mode);
1127 
1128  gvl = gvl_get_vol(id);
1129 
1130  if (gvl) {
1131  gvl->slice_draw_mode = mode;
1132 
1133  return (0);
1134  }
1135 
1136  return (-1);
1137 }
1138 
1147 int GVL_slice_add(int id)
1148 {
1149  geovol *gvl;
1150  geovol_slice *slice;
1151 
1152  G_debug(3, "GVL_slice_add");
1153 
1154  gvl = gvl_get_vol(id);
1155 
1156  if (!gvl)
1157  return (-1);
1158 
1159  if (gvl->n_slices == MAX_SLICES)
1160  return (-1);
1161 
1162  if (NULL == (slice = (geovol_slice *) G_malloc(sizeof(geovol_slice)))) {
1163  return (-1);
1164  }
1165 
1166  gvl_slice_init(slice);
1167 
1168  gvl->n_slices++;
1169  gvl->slice[gvl->n_slices - 1] = (geovol_slice *) slice;
1170 
1171  return (1);
1172 }
1173 
1183 int GVL_slice_del(int id, int slice_id)
1184 {
1185  geovol *gvl;
1186  geovol_slice *slice;
1187  int i;
1188 
1189  G_debug(3, "GVL_slice_del");
1190 
1191  slice = gvl_slice_get_slice(id, slice_id);
1192 
1193  if (!slice)
1194  return (-1);
1195 
1196  if (!gvl_slice_freemem(slice)) {
1197  return (-1);
1198  }
1199 
1200  gvl = gvl_get_vol(id);
1201 
1202  G_free(gvl->slice[slice_id]);
1203 
1204  for (i = slice_id + 1; i < gvl->n_slices; i++) {
1205  gvl->slice[i - 1] = gvl->slice[i];
1206  }
1207 
1208  gvl->n_slices--;
1209 
1210  return (1);
1211 }
1212 
1222 int GVL_slice_move_up(int id, int slice_id)
1223 {
1224  geovol *gvl;
1225  geovol_slice *tmp;
1226 
1227  G_debug(3, "GVL_slice_move_up");
1228 
1229  gvl = gvl_get_vol(id);
1230 
1231  if (!gvl)
1232  return (-1);
1233 
1234  if (slice_id < 0 || slice_id > (gvl->n_slices - 1))
1235  return (-1);
1236 
1237  if (slice_id == 0)
1238  return (1);
1239 
1240  tmp = gvl->slice[slice_id - 1];
1241  gvl->slice[slice_id - 1] = gvl->slice[slice_id];
1242  gvl->slice[slice_id] = tmp;
1243 
1244  return (1);
1245 }
1246 
1256 int GVL_slice_move_down(int id, int slice_id)
1257 {
1258  geovol *gvl;
1259  geovol_slice *tmp;
1260 
1261  G_debug(3, "GVL_slice_move_up");
1262 
1263  gvl = gvl_get_vol(id);
1264 
1265  if (!gvl)
1266  return (-1);
1267 
1268  if (slice_id < 0 || slice_id > (gvl->n_slices - 1))
1269  return (-1);
1270 
1271  if (slice_id == (gvl->n_slices - 1))
1272  return (1);
1273 
1274  tmp = gvl->slice[slice_id + 1];
1275  gvl->slice[slice_id + 1] = gvl->slice[slice_id];
1276  gvl->slice[slice_id] = tmp;
1277 
1278  return (1);
1279 }
1280 
1290 {
1291  geovol *gvl;
1292 
1293  G_debug(3, "GVL_isosurf_num_isosurfs");
1294 
1295  gvl = gvl_get_vol(id);
1296 
1297  if (gvl) {
1298  return gvl->n_slices;
1299  }
1300 
1301  return (-1);
1302 }
1303 
1316 int GVL_slice_get_pos(int id, int slice_id,
1317  float *x1, float *x2, float *y1, float *y2, float *z1,
1318  float *z2, int *dir)
1319 {
1320  geovol *gvl;
1321  geovol_slice *slice;
1322  int cols, rows, depths;
1323 
1324  gvl = gvl_get_vol(id);
1325 
1326  if (!gvl)
1327  return (-1);
1328 
1329  slice = gvl_slice_get_slice(id, slice_id);
1330 
1331  if (!slice)
1332  return (-1);
1333 
1334  if (slice->dir == X) {
1335  cols = gvl->rows;
1336  rows = gvl->depths;
1337  depths = gvl->cols;
1338  }
1339  else if (slice->dir == Y) {
1340  cols = gvl->cols;
1341  rows = gvl->depths;
1342  depths = gvl->rows;
1343  }
1344  else if (slice->dir == Z) {
1345  cols = gvl->cols;
1346  rows = gvl->rows;
1347  depths = gvl->depths;
1348  }
1349  else {
1350  return (-1);
1351  }
1352 
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);
1359 
1360  *dir = slice->dir;
1361 
1362  return (1);
1363 }
1364 
1377 int GVL_slice_set_pos(int id, int slice_id,
1378  float x1, float x2, float y1, float y2, float z1,
1379  float z2, int dir)
1380 {
1381  geovol *gvl;
1382  geovol_slice *slice;
1383  int cols, rows, depths;
1384 
1385  gvl = gvl_get_vol(id);
1386 
1387  if (!gvl)
1388  return (-1);
1389 
1390  slice = gvl_slice_get_slice(id, slice_id);
1391 
1392  if (!slice)
1393  return (-1);
1394 
1395  if (dir == X) {
1396  cols = gvl->rows;
1397  rows = gvl->depths;
1398  depths = gvl->cols;
1399  }
1400  else if (dir == Y) {
1401  cols = gvl->cols;
1402  rows = gvl->depths;
1403  depths = gvl->rows;
1404  }
1405  else if (dir == Z) {
1406  cols = gvl->cols;
1407  rows = gvl->rows;
1408  depths = gvl->depths;
1409  }
1410  else {
1411  return (-1);
1412  }
1413 
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);
1420 
1421  slice->dir = dir;
1422 
1423  slice->changed = 1;
1424 
1425  return (1);
1426 }
1427 
1438 int GVL_slice_get_transp(int id, int slice_id, int *transp)
1439 {
1440  geovol_slice *slice;
1441 
1442  G_debug(3, "GVL_get_transp");
1443 
1444  slice = gvl_slice_get_slice(id, slice_id);
1445 
1446  if (!slice)
1447  return (-1);
1448 
1449  *transp = slice->transp;
1450 
1451  return (1);
1452 }
1453 
1464 int GVL_slice_set_transp(int id, int slice_id, int transp)
1465 {
1466  geovol_slice *slice;
1467 
1468  G_debug(3, "GVL_set_transp");
1469 
1470  slice = gvl_slice_get_slice(id, slice_id);
1471 
1472  if (!slice)
1473  return (-1);
1474 
1475  slice->transp = transp;
1476 
1477  return (1);
1478 }
int GVL_slice_move_down(int id, int slice_id)
Move down slice.
Definition: GVL2.c:1256
int GVL_slice_get_transp(int id, int slice_id, int *transp)
Get slice trans ?
Definition: GVL2.c:1438
int GVL_isosurf_move_up(int id, int isosurf_id)
Move up isosurface in list.
Definition: GVL2.c:694
void G_free(void *buf)
Free allocated memory.
Definition: gis/alloc.c:142
int GVL_delete_vol(int id)
Delete volume set from list.
Definition: GVL2.c:190
float b
Definition: named_colr.c:8
int GVL_new_vol(void)
Create new volume set.
Definition: GVL2.c:116
int GVL_get_trans(int id, float *xtrans, float *ytrans, float *ztrans)
Get trans ?
Definition: GVL2.c:340
int GVL_slice_move_up(int id, int slice_id)
Move up slice.
Definition: GVL2.c:1222
void * GVL_Get_ClientData(int id)
Get client data.
Definition: GVL2.c:455
int gvl_num_vols(void)
Get number of loaded volume sets.
Definition: gvl.c:104
int GVL_slice_del(int id, int slice_id)
Delete slice.
Definition: GVL2.c:1183
void GS_set_focus(float *realto)
Set focus.
Definition: GS2.c:2518
int GVL_slice_get_drawmode(int id, int *mode)
Get slice draw mode.
Definition: GVL2.c:1098
int GVL_isosurf_unset_att(int id, int isosurf_id, int att)
Unset isosurface attributes.
Definition: GVL2.c:806
#define Y(x)
Definition: display/draw.c:246
void GVL_get_dims(int id, int *rows, int *cols, int *depths)
Get volume dimensions.
Definition: GVL2.c:290
int GVL_isosurf_num_isosurfs(int id)
Get number of available isosurfaces.
Definition: GVL2.c:955
int gvl_isosurf_set_att_map(geovol_isosurf *isosurf, int desc, const char *filename)
Set attribute map.
Definition: gvl.c:690
int GVL_num_vols(void)
Get number of loaded volume sets.
Definition: GVL2.c:146
#define X(y)
Definition: display/draw.c:248
char * gvl_file_get_name(int id)
Get file name for given handle.
Definition: gvl_file.c:166
char * G_strcpy(char *T, const char *F)
Copies characters from the string F into the string T.
Definition: strings.c:46
void GVL_draw_wire(int id)
Draw volume in wire mode.
Definition: GVL2.c:380
void GVL_slice_get_drawres(int id, int *xres, int *yres, int *zres)
Get draw resolution of slice.
Definition: GVL2.c:1035
void GVL_alldraw_wire(void)
Draw all volume sets in wire mode.
Definition: GVL2.c:412
void G3d_getWindow(G3D_Region *window)
Stores the current default window in window.
Definition: g3dwindow.c:61
int gvl_isosurf_set_att_src(geovol_isosurf *isosurf, int desc, int src)
Set attribute source.
Definition: gvl.c:630
geovol * gvl_get_new_vol(void)
Allocate new volume set and add it to the list.
Definition: gvl.c:145
int GVL_Set_ClientData(int id, void *clientd)
Set client data for volume set.
Definition: GVL2.c:432
void GVL_draw_vol(int vid)
Draw volume set.
Definition: GVL2.c:362
void GVL_libinit(void)
Library intialization for volumes.
Definition: GVL2.c:36
int GVL_load_vol(int id, const char *filename)
Load 3d raster map to volume set.
Definition: GVL2.c:236
int GVL_isosurf_get_drawmode(int id, int *mode)
Get isosurface draw mode.
Definition: GVL2.c:569
int GVL_isosurf_set_drawmode(int id, int mode)
Set isosurface draw mode.
Definition: GVL2.c:593
tuple id
self.OnVectorSurface(event)
Definition: tools.py:3426
int gvl_slice_init(geovol_slice *slice)
Initialize geovol_slice struct.
Definition: gvl.c:756
int gvl_isosurf_get_att_src(geovol_isosurf *isosurf, int desc)
Get attribute source.
Definition: gvl.c:605
void G_message(const char *msg,...)
Print a message to stderr.
Definition: lib/gis/error.c:74
int GVL_isosurf_get_att(int id, int isosurf_id, int att, int *set, float *constant, char *mapname)
Get isosurface attributes.
Definition: GVL2.c:766
int gvl_file_newh(const char *name, IFLAG file_type)
Get handle for given file name and type.
Definition: gvl_file.c:270
void GVL_alldraw_vol(void)
Draw all volume sets.
Definition: GVL2.c:398
int GVL_slice_add(int id)
Add slice.
Definition: GVL2.c:1147
int GVL_slice_set_drawmode(int id, int mode)
Set slice draw mode.
Definition: GVL2.c:1122
int gvl_isosurf_set_att_changed(geovol_isosurf *isosurf, int desc)
Set attribute changed.
Definition: gvl.c:723
int GVL_get_region(float *n, float *s, float *w, float *e, float *t, float *b)
Get region extent settings.
Definition: GVL2.c:59
int gvld_wire_vol(geovol *gvl)
Draw volume in wire mode (bounding box)
Definition: gvld.c:68
void GVL_set_trans(int id, float xtrans, float ytrans, float ztrans)
Set trans ?
Definition: GVL2.c:314
void GVL_set_focus_center_map(int id)
Set focus on map center.
Definition: GVL2.c:473
int gvl_init_vol(geovol *gvl, double ox, double oy, double oz, int rows, int cols, int depths, double xres, double yres, double zres)
Initialize geovol structure.
Definition: gvl.c:184
void GVL_isosurf_get_drawres(int id, int *xres, int *yres, int *zres)
Get draw resolution for isosurface.
Definition: GVL2.c:506
geovol * gvl_get_vol(int id)
Get volume set structure.
Definition: gvl.c:39
geovol_slice * gvl_slice_get_slice(int id, int slice_id)
Get geovol_slice struct.
Definition: gvl.c:803
int GVL_isosurf_get_flags(int id, int isosurf_id, int *inout)
Get isosurface flags.
Definition: GVL2.c:904
int gvl_slice_freemem(geovol_slice *slice)
Free geovol_slice struct.
Definition: gvl.c:782
int GVL_slice_num_slices(int id)
Get number or slices.
Definition: GVL2.c:1289
int gvl_isosurf_init(geovol_isosurf *isosurf)
Initialize geovol_isosurf struct.
Definition: gvl.c:517
int GVL_slice_set_transp(int id, int slice_id, int transp)
Set slice trans ?
Definition: GVL2.c:1464
geovol_isosurf * gvl_isosurf_get_isosurf(int id, int isosurf_id)
Get isosurface of given volume set.
Definition: gvl.c:577
int gvl_isosurf_set_att_const(geovol_isosurf *isosurf, int desc, float constant)
Set isosurface attribute constant.
Definition: gvl.c:663
return NULL
Definition: dbfopen.c:1394
void G3d_initDefaults(void)
Initializes the default values described in G3D Defaults. Applications have to use this function only...
Definition: g3ddefaults.c:347
int gvl_isosurf_freemem(geovol_isosurf *isosurf)
Free geovol_isosurf struct.
Definition: gvl.c:550
int GVL_isosurf_get_maskmode(int id, int isosurf_id, int *mode)
Get isosurface mask mode.
Definition: GVL2.c:1009
tuple cols
int G_debug(int level, const char *msg,...)
Print debugging message.
Definition: gis/debug.c:51
void * GVL_get_window()
Get window.
Definition: GVL2.c:78
int GVL_isosurf_set_att_map(int id, int isosurf_id, int att, const char *filename)
Set isosurface map attribute.
Definition: GVL2.c:877
int gvld_vol(geovol *gvl)
Draw volume set (slices and isosurfaces)
Definition: gvld.c:37
int * GVL_get_vol_list(int *numvols)
Get list of loaded volume sets.
Definition: GVL2.c:161
int GVL_slice_get_pos(int id, int slice_id, float *x1, float *x2, float *y1, float *y2, float *z1, float *z2, int *dir)
Get slice position.
Definition: GVL2.c:1316
int GVL_isosurf_set_drawres(int id, int xres, int yres, int zres)
Set isosurface draw resolution.
Definition: GVL2.c:532
int GVL_slice_set_pos(int id, int slice_id, float x1, float x2, float y1, float y2, float z1, float z2, int dir)
Get slice position.
Definition: GVL2.c:1377
int GVL_isosurf_set_flags(int id, int isosurf_id, int inout)
Set isosurface flags.
Definition: GVL2.c:930
int GVL_isosurf_move_down(int id, int isosurf_id)
Move down isosurface in list.
Definition: GVL2.c:728
int GVL_vol_exists(int id)
Check if volume set exists.
Definition: GVL2.c:91
int GVL_isosurf_set_maskmode(int id, int isosurf_id, int mode)
Set mask attribute mode.
Definition: GVL2.c:982
int n
Definition: dataquad.c:291
int GVL_get_volname(int id, char *filename)
Get volume set name.
Definition: GVL2.c:267
int GVL_isosurf_add(int id)
Add isosurface.
Definition: GVL2.c:618
string set
void gvl_delete_vol(int id)
Remove volume set from list.
Definition: gvl.c:241
int GVL_isosurf_set_att_const(int id, int isosurf_id, int att, float constant)
Set constant isosurface attribute.
Definition: GVL2.c:841
tuple mode
Definition: tools.py:1481
int GVL_slice_set_drawres(int id, int xres, int yres, int zres)
Set slice draw resolution.
Definition: GVL2.c:1061
int GVL_isosurf_del(int id, int isosurf_id)
Delete isosurface.
Definition: GVL2.c:655