GRASS Programmer's Manual  6.5.svn(2014)-r66266
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
gvl_file.c
Go to the documentation of this file.
1 
19 #include <string.h>
20 #include <stdlib.h>
21 
22 #include <grass/gis.h>
23 #include <grass/gstypes.h>
24 #include <grass/gsurf.h>
25 #include <grass/G3d.h>
26 #include <grass/glocale.h>
27 
28 #define LUCKY 33
29 
30 #define MODE_DIRECT 0
31 #define MODE_SLICE 1
32 #define MODE_FULL 2
33 #define MODE_PRELOAD 3
34 
35 #define MODE_DEFAULT 0
36 
37 #define STATUS_READY 0
38 #define STATUS_BUSY 1
39 
43 typedef struct
44 {
45  int num, skip;
46  int crnt, base;
47 
48  void *slice[MAX_VOL_SLICES];
49 } slice_data;
50 
51 static geovol_file *Data[MAX_VOL_FILES];
52 static geovol_file Df[MAX_VOL_FILES]; /* trying to avoid allocation */
53 
54 static int Numfiles = 0;
55 
56 static int Cur_id = LUCKY;
57 static int Cur_max;
58 
59 static int Rows, Cols, Depths;
60 
61 /* local functions prototypes */
62 void *open_g3d_file(const char *, IFLAG *, double *, double *);
63 int close_g3d_file(void *);
64 
70 static int init_volfiles(void)
71 {
72  int i;
73  G3D_Region *w3;
74 
75  for (i = 0; i < MAX_VOL_FILES; i++) {
76  /* avoiding dynamic allocation */
77  Data[i] = &(Df[i]);
78  }
79 
80  Cur_max = MAX_VOL_FILES;
81 
82  /* get window */
83  w3 = GVL_get_window();
84 
85  /* set cols, rows, depths from window */
86  Cols = w3->cols;
87  Rows = w3->rows;
88  Depths = w3->depths;
89 
90  return (1);
91 }
92 
98 static int check_num_volfiles(void)
99 {
100  if (Numfiles < Cur_max) {
101  return (0);
102  }
103 
104  G_fatal_error(_("Maximum number of datafiles exceeded"));
105 
106  /* This return statement keeps compilers happy, it is never executed */
107  return (0);
108 }
109 
118 geovol_file *gvl_file_get_volfile(int id)
119 {
120  int i;
121 
122  for (i = 0; i < Numfiles; i++) {
123  if (Data[i]->data_id == id) {
124  return (Data[i]);
125  }
126  }
127 
128  return (NULL);
129 }
130 
140 int find_datah(const char *name, IFLAG type, int begin)
141 {
142  static int i;
143  int start;
144 
145  start = begin ? 0 : i + 1;
146 
147  for (i = start; i < Numfiles; i++) {
148  if (!strcmp(Data[i]->file_name, name)) {
149  if (Data[i]->file_type == type) {
150  return (Data[i]->data_id);
151  }
152  }
153  }
154 
155  return (-1);
156 }
157 
166 char *gvl_file_get_name(int id)
167 {
168  int i;
169  geovol_file *fvf;
170  static char retstr[GPATH_MAX];
171 
172  for (i = 0; i < Numfiles; i++) {
173  if (Data[i]->data_id == id) {
174  fvf = Data[i];
175  strcpy(retstr, fvf->file_name);
176 
177  return (retstr);
178  }
179  }
180 
181  return (NULL);
182 }
183 
191 int gvl_file_get_file_type(geovol_file * vf)
192 {
193  return (vf->file_type);
194 }
195 
203 int gvl_file_get_data_type(geovol_file * vf)
204 {
205  return (vf->data_type);
206 }
207 
215 void gvl_file_get_min_max(geovol_file * vf, double *min, double *max)
216 {
217  *min = vf->min;
218  *max = vf->max;
219 }
220 
233 void *open_volfile(const char *name, IFLAG file_type, IFLAG * data_type,
234  double *min, double *max)
235 {
236  if (file_type == VOL_FTYPE_G3D) {
237  return open_g3d_file(name, data_type, min, max);
238  }
239 
240  return (NULL);
241 }
242 
252 int close_volfile(void *map, IFLAG type)
253 {
254  if (type == VOL_FTYPE_G3D) {
255  return close_g3d_file(map);
256  }
257 
258  return (-1);
259 }
260 
270 int gvl_file_newh(const char *name, IFLAG file_type)
271 {
272  geovol_file *new;
273  static int first = 1;
274  int i, id;
275  void *m;
276  IFLAG data_type;
277  double min, max;
278 
279  if (first) {
280  if (0 > init_volfiles()) {
281  return (-1);
282  }
283 
284  first = 0;
285  }
286 
287  if (0 <= (id = find_datah(name, file_type, 1))) {
288  for (i = 0; i < Numfiles; i++) {
289  if (Data[i]->data_id == id) {
290  new = Data[i];
291  new->count++;
292 
293  return (id);
294  }
295  }
296  }
297 
298  if (0 > check_num_volfiles()) {
299  return (-1);
300  }
301 
302  if (!name) {
303  return (-1);
304  }
305 
306  if ((m = open_volfile(name, file_type, &data_type, &min, &max)) == NULL) {
307  return (-1);
308  }
309 
310  new = Data[Numfiles];
311 
312  if (new) {
313  Numfiles++;
314  new->data_id = Cur_id++;
315 
316  new->file_name = G_store(name);
317  new->file_type = file_type;
318  new->count = 1;
319  new->map = m;
320  new->min = min;
321  new->max = max;
322  new->data_type = data_type;
323 
324  new->status = STATUS_READY;
325  new->buff = NULL;
326 
327  new->mode = 255;
329 
330  return (new->data_id);
331  }
332 
333  return (-1);
334 }
335 
343 int free_volfile_buffs(geovol_file * vf)
344 {
345  if (vf->mode == MODE_SLICE) {
346  G_free(vf->buff);
347  vf->buff = NULL;
348  }
349 
350  if (vf->mode == MODE_PRELOAD) {
351  G_free(vf->buff);
352  vf->buff = NULL;
353  }
354 
355  return (1);
356 }
357 
366 {
367  int i, j, found = -1;
368  geovol_file *fvf;
369 
370  G_debug(5, "gvl_file_free_datah(): id=%d", id);
371 
372  for (i = 0; i < Numfiles; i++) {
373  if (Data[i]->data_id == id) {
374  found = 1;
375  fvf = Data[i];
376 
377  if (fvf->count > 1) {
378  fvf->count--;
379  }
380  else {
381  close_volfile(fvf->map, fvf->file_type);
382  free_volfile_buffs(fvf);
383 
384  G_free(fvf->file_name);
385  fvf->file_name = NULL;
386 
387  fvf->data_id = 0;
388 
389  for (j = i; j < (Numfiles - 1); j++) {
390  Data[j] = Data[j + 1];
391  }
392 
393  Data[j] = fvf;
394 
395  --Numfiles;
396  }
397  }
398  }
399 
400  return (found);
401 }
402 
403 /******************************************************************/
404 /* reading from G3D raster volume files */
405 
406 /******************************************************************/
407 
418 void *open_g3d_file(const char *filename, IFLAG * type, double *min,
419  double *max)
420 {
421  const char *mapset;
422  int itype;
423  void *map;
424 
425  /* search for g3d file a return his mapset */
426  mapset = G_find_grid3(filename, "");
427  if (!mapset) {
428  G_warning(_("3D raster map <%s> not found"), filename);
429  return (NULL);
430  }
431 
432  /* open g3d file */
433  map =
434  G3d_openCellOld(filename, mapset, G3D_DEFAULT_WINDOW,
435  G3D_TILE_SAME_AS_FILE, G3D_USE_CACHE_DEFAULT);
436  if (!map) {
437  G_warning(_("Unable to open 3D raster map <%s>"), filename);
438  return (NULL);
439  }
440 
441  /* load range into range structure of map */
442  if (!G3d_range_load(map)) {
443  G_warning(_("Unable to read range of 3D raster map <%s>"), filename);
444  return (NULL);
445  }
446 
447  G3d_range_min_max(map, min, max);
448 
449  /* get file data type */
450  itype = G3d_fileTypeMap(map);
451  if (itype == FCELL_TYPE)
452  *type = VOL_DTYPE_FLOAT;
453  if (itype == DCELL_TYPE)
454  *type = VOL_DTYPE_DOUBLE;
455 
456  return (map);
457 }
458 
467 int close_g3d_file(void *map)
468 {
469  /* close opened g3d file */
470  if (G3d_closeCell((G3D_Map *) map) != 1) {
471  G_warning(_("Unable to close 3D raster map <%s>"),
472  ((G3D_Map *) map)->fileName);
473  return (-1);
474  }
475 
476  return (1);
477 }
478 
490 int read_g3d_value(IFLAG type, void *map, int x, int y, int z, void *value)
491 {
492  switch (type) {
493  /* float data type */
494  case (VOL_DTYPE_FLOAT):
495  *((float *)value) = G3d_getFloat(map, x, y, z);
496  break;
497 
498  /* double data type */
499  case (VOL_DTYPE_DOUBLE):
500  *((double *)value) = G3d_getDouble(map, x, y, z);
501  break;
502 
503  /* unsupported data type */
504  default:
505  return (-1);
506  }
507 
508  return (1);
509 }
510 
522 int read_g3d_slice(IFLAG type, void *map, int level, void *data)
523 {
524  int x, y;
525 
526  switch (type) {
527  /* float data type */
528  case (VOL_DTYPE_FLOAT):
529  for (x = 0; x < Cols; x++) {
530  for (y = 0; y < Rows; y++) {
531  ((float *)data)[x + y * Cols] =
532  G3d_getFloat(map, x, y, level);
533  }
534  }
535 
536  break;
537 
538  /* double data type */
539  case (VOL_DTYPE_DOUBLE):
540  for (x = 0; x < Cols; x++) {
541  for (y = 0; y < Rows; y++) {
542  ((double *)data)[x + y * Cols] =
543  G3d_getDouble(map, x, y, level);
544  }
545  }
546 
547  break;
548 
549  /* unsupported data type */
550  default:
551  return (-1);
552  }
553 
554  return (1);
555 }
556 
567 int read_g3d_vol(IFLAG type, void *map, void *data)
568 {
569  int x, y, z;
570 
571  switch (type) {
572  /* float data type */
573  case (VOL_DTYPE_FLOAT):
574  for (x = 0; x < Cols; x++) {
575  for (y = 0; y < Rows; y++) {
576  for (z = 0; z < Depths; z++) {
577  ((float *)data)[x + y * Cols + z * Rows * Cols] =
578  G3d_getFloat(map, x, y, z);
579  }
580  }
581  }
582 
583  break;
584 
585  /* double data type */
586  case (VOL_DTYPE_DOUBLE):
587  for (x = 0; x < Cols; x++) {
588  for (y = 0; y < Rows; y++) {
589  for (z = 0; z < Depths; z++) {
590  ((double *)data)[x + y * Cols + z * Rows * Cols] =
591  G3d_getDouble(map, x, y, z);
592  }
593  }
594  }
595 
596  break;
597 
598  /* unsupported data type */
599  default:
600  return (-1);
601  }
602 
603  return (1);
604 }
605 
616 int is_null_g3d_value(IFLAG type, void *value)
617 {
618  switch (type) {
619  /* float data type */
620  case (VOL_DTYPE_FLOAT):
621  return G3d_isNullValueNum(value, FCELL_TYPE);
622  break;
623 
624  /* double data type */
625  case (VOL_DTYPE_DOUBLE):
626  return G3d_isNullValueNum(value, DCELL_TYPE);
627  break;
628 
629  /* unsupported data type */
630  default:
631  return (-1);
632  }
633 
634  return (-1);
635 }
636 
637 /******************************************************************/
638 /* reading from buffer */
639 
640 /******************************************************************/
641 
653 int get_buff_value(IFLAG type, void *data, int offset, void *value)
654 {
655  switch (type) {
656  /* float data type */
657  case (VOL_DTYPE_FLOAT):
658  *((float *)value) = ((float *)data)[offset];
659  break;
660 
661  /* double data type */
662  case (VOL_DTYPE_DOUBLE):
663  *((double *)value) = ((double *)data)[offset];
664  break;
665 
666  /* unsupported data type */
667  default:
668  return (-1);
669  }
670 
671  return (1);
672 }
673 
674 /******************************************************************/
675 /* direct mode reading from volume file */
676 
677 /******************************************************************/
678 
689 int get_direct_value(geovol_file * vf, int x, int y, int z, void *value)
690 {
691  switch (vf->file_type) {
692  /* G3D file type */
693  case (VOL_FTYPE_G3D):
694  if (0 > read_g3d_value(vf->data_type, vf->map, x, y, z, value))
695  return (-1);
696  break;
697 
698  default:
699  return (-1);
700  }
701 
702  return (1);
703 }
704 
705 /******************************************************************/
706 /* full mode reading from volume file */
707 
708 /******************************************************************/
709 
718 int alloc_vol_buff(geovol_file * vf)
719 {
720  switch (vf->data_type) {
721  /* float data type */
722  case (VOL_DTYPE_FLOAT):
723  if ((vf->buff =
724  (float *)G_malloc(sizeof(float) * Cols * Rows * Depths)) == NULL)
725  return (-1);
726  break;
727 
728  /* double data type */
729  case (VOL_DTYPE_DOUBLE):
730  if ((vf->buff =
731  (double *)G_malloc(sizeof(double) * Cols * Rows * Depths)) ==
732  NULL)
733  return (-1);
734  break;
735 
736  /* unsupported data type */
737  default:
738  return (-1);
739  }
740 
741  return (1);
742 }
743 
751 int free_vol_buff(geovol_file * vf)
752 {
753  G_free(vf->buff);
754 
755  return (1);
756 }
757 
766 int read_vol(geovol_file * vf)
767 {
768  switch (vf->file_type) {
769  /* G3D file format */
770  case (VOL_FTYPE_G3D):
771  if (0 > read_g3d_vol(vf->data_type, vf->map, vf->buff))
772  return (-1);
773  break;
774  /* unsupported file format */
775  default:
776  return (-1);
777  }
778 
779  return (1);
780 }
781 
791 int get_vol_value(geovol_file * vf, int x, int y, int z, void *value)
792 {
793  get_buff_value(vf->data_type, vf->buff, z * Rows * Cols + y * Cols + x,
794  value);
795 
796  return (1);
797 }
798 
799 /******************************************************************/
800 /* slice mode reading from volume file */
801 
802 /******************************************************************/
803 
812 int alloc_slice_buff(geovol_file * vf)
813 {
814  int i;
815  slice_data *sd = (slice_data *) vf->buff;
816 
817  switch (vf->data_type) {
818  /* float data type */
819  case (VOL_DTYPE_FLOAT):
820  for (i = 0; i < sd->num; i++) {
821  if ((sd->slice[i] =
822  (float *)G_malloc(sizeof(float) * Cols * Rows)) == NULL)
823  return (-1);
824  }
825  break;
826 
827  /* double data type */
828  case (VOL_DTYPE_DOUBLE):
829  for (i = 0; i < sd->num; i++) {
830  if ((sd->slice[i] =
831  (double *)G_malloc(sizeof(double) * Cols * Rows)) == NULL)
832  return (-1);
833  }
834  break;
835 
836  /* unsupported data type */
837  default:
838  return (-1);
839  }
840 
841  return (1);
842 }
843 
851 int free_slice_buff(geovol_file * vf)
852 {
853  int i;
854  slice_data *sd = (slice_data *) vf->buff;
855 
856  for (i = 0; i < sd->num; i++) {
857  G_free(sd->slice[i]);
858  }
859 
860  return (1);
861 }
862 
873 int read_slice(geovol_file * vf, int s, int l)
874 {
875  /* get slice structure */
876  slice_data *sd = (slice_data *) vf->buff;
877 
878  switch (vf->file_type) {
879  /* G3D file format */
880  case (VOL_FTYPE_G3D):
881  if (0 > read_g3d_slice(vf->data_type, vf->map, l, sd->slice[s]))
882  return (-1);
883  break;
884  /* unsupported file format */
885  default:
886  return (-1);
887  }
888 
889  return (1);
890 }
891 
897 void shift_slices(geovol_file * vf)
898 {
899  void *tmp;
900  int i;
901 
902  slice_data *sd = (slice_data *) vf->buff;
903 
904  /* change pointers to slices */
905  tmp = sd->slice[0];
906  for (i = 0; i < sd->num - 1; i++) {
907  sd->slice[i] = sd->slice[i + 1];
908  }
909  sd->slice[sd->num - 1] = tmp;
910 
911  /* read new slice data */
912  read_slice(vf, sd->num, sd->crnt + 1 + (sd->num - sd->base));
913 
914  /* increase current slice value */
915  sd->crnt++;
916 }
917 
928 int get_slice_value(geovol_file * vf, int x, int y, int z, void *value)
929 {
930  slice_data *sd = (slice_data *) vf->buff;
931 
932  /* value is in loaded slices */
933  if ((z >= sd->crnt - (sd->base - 1)) &&
934  (z <= sd->crnt + sd->num - sd->base)) {
935 
936  get_buff_value(vf->data_type, sd->slice[(z - sd->crnt)], y * Cols + x,
937  value);
938  }
939 
940  /* if value isn't in loaded slices, need read new data slice */
941  else if (z == sd->crnt - (sd->base - 1) + 1) {
942  shift_slices(vf);
943  get_buff_value(vf->data_type, sd->slice[(z - sd->crnt)], y * Cols + x,
944  value);
945  }
946 
947  /* value out of range */
948  else {
949  return (-1);
950  }
951 
952  return (1);
953 }
954 
955 /******************************************************************/
956 /* reading from volume file */
957 
958 /******************************************************************/
959 
968 int gvl_file_start_read(geovol_file * vf)
969 {
970  int i;
971  slice_data *sd;
972 
973  /* check status */
974  if (vf->status == STATUS_BUSY)
975  return (-1);
976 
977  switch (vf->mode) {
978  /* read whole volume into memory */
979  case (MODE_FULL):
980  /* allocate memory */
981  if (0 > alloc_vol_buff(vf))
982  return (-1);
983 
984  /* read volume */
985  read_vol(vf);
986  break;
987 
988  /* read first data slices into memory */
989  case (MODE_SLICE):
990  /* allocate slices buffer memory */
991  if (0 > alloc_slice_buff(vf))
992  return (-1);
993 
994  /* read volume */
995  sd = (slice_data *) vf->buff;
996  /* set current slice to 0 */
997  sd->crnt = 0;
998 
999  /* read first slices into buffer */
1000  for (i = 0; i < (sd->num - sd->base + 1); i++)
1001  read_slice(vf, (sd->base - 1) + i, i);
1002  break;
1003  }
1004 
1005  /* set status */
1006  vf->status = STATUS_BUSY;
1007 
1008  return (1);
1009 }
1010 
1019 int gvl_file_end_read(geovol_file * vf)
1020 {
1021  /* check status */
1022  if (vf->status == STATUS_READY)
1023  return (-1);
1024 
1025  switch (vf->mode) {
1026  case (MODE_FULL):
1027  if (0 > free_vol_buff(vf))
1028  return (-1);
1029  break;
1030 
1031  case (MODE_SLICE):
1032  /* allocate slices buffer memory */
1033  if (0 > free_slice_buff(vf))
1034  return (-1);
1035  }
1036 
1037  /* set status */
1038  vf->status = STATUS_READY;
1039 
1040  return (1);
1041 }
1042 
1051 int gvl_file_get_value(geovol_file * vf, int x, int y, int z, void *value)
1052 {
1053  /* check status */
1054  if (vf->status != STATUS_BUSY) {
1055  return (-1);
1056  }
1057 
1058  switch (vf->mode) {
1059  /* read value direct from g3d file */
1060  case (MODE_DIRECT):
1061  if (0 > get_direct_value(vf, x, y, z, value))
1062  return (-1);
1063  break;
1064 
1065  case (MODE_SLICE):
1066  if (0 > get_slice_value(vf, x, y, z, value))
1067  return (-1);
1068  break;
1069 
1070  case (MODE_FULL):
1071  case (MODE_PRELOAD):
1072  if (0 > get_vol_value(vf, x, y, z, value))
1073  return (-1);
1074  break;
1075  }
1076  return (1);
1077 }
1078 
1088 int gvl_file_is_null_value(geovol_file * vf, void *value)
1089 {
1090  switch (vf->file_type) {
1091  /* G3D file format */
1092  case (VOL_FTYPE_G3D):
1093  return is_null_g3d_value(vf->file_type, value);
1094  break;
1095  /* unsupported file format */
1096  default:
1097  return (-1);
1098  }
1099 
1100  return (-1);
1101 }
1102 
1103 /******************************************************************/
1104 /* set parameters for reading volumes */
1105 
1106 /******************************************************************/
1107 
1117 int gvl_file_set_mode(geovol_file * vf, IFLAG mode)
1118 {
1119  slice_data *sd;
1120 
1121  if (vf->status == STATUS_BUSY)
1122  return (-1);
1123 
1124  if (vf->mode == mode)
1125  return (1);
1126 
1127  if (vf->mode == MODE_SLICE)
1128  G_free(vf->buff);
1129 
1130  if (vf->mode == MODE_PRELOAD)
1131  G_free(vf->buff);
1132 
1133  if (mode == MODE_SLICE) {
1134  if ((vf->buff = (slice_data *) G_malloc(sizeof(slice_data))) == NULL)
1135  return (-1);
1136 
1137  sd = (slice_data *) vf->buff;
1138  sd->num = 1;
1139  sd->crnt = 0;
1140  sd->base = 1;
1141  }
1142 
1143  if (mode == MODE_PRELOAD) {
1144  /* allocate memory */
1145  if (0 > alloc_vol_buff(vf))
1146  return (-1);
1147 
1148  /* read volume */
1149  read_vol(vf);
1150  }
1151 
1152  vf->mode = mode;
1153 
1154  return (1);
1155 }
1156 
1167 int gvl_file_set_slices_param(geovol_file * vf, int n, int b)
1168 {
1169  slice_data *sd;
1170 
1171  if (vf->status == STATUS_BUSY)
1172  return (-1);
1173 
1174  if (!(vf->mode == MODE_SLICE))
1175  return (-1);
1176 
1177  sd = (slice_data *) vf->buff;
1178  sd->num = n;
1179  sd->base = b;
1180 
1181  return (1);
1182 }
int is_null_g3d_value(IFLAG type, void *value)
Check for null value.
Definition: gvl_file.c:616
int Rows
Definition: gvl_calc.c:73
void G_free(void *buf)
Free allocated memory.
Definition: gis/alloc.c:142
int l
Definition: dataquad.c:292
float b
Definition: named_colr.c:8
int close_g3d_file(void *)
Close g3d file.
Definition: gvl_file.c:467
char * G_store(const char *s)
Copy string to allocated memory.
Definition: store.c:32
int alloc_vol_buff(geovol_file *vf)
Allocate buffer memory for full mode reading.
Definition: gvl_file.c:718
geovol_file * gvl_file_get_volfile(int id)
Get geovol_file structure for given handle.
Definition: gvl_file.c:118
string name
Definition: render.py:1314
int base
Definition: gvl_file.c:46
double G3d_getDouble(G3D_Map *map, int x, int y, int z)
Is equivalent to G3d_getValue (map, x, y, z, &amp;value, DCELL_TYPE); return value.
Definition: g3dwindow.c:205
#define min(x, y)
Definition: draw2.c:68
void * slice[MAX_VOL_SLICES]
Definition: gvl_file.c:48
int G3d_isNullValueNum(const void *n, int type)
Definition: g3dnull.c:9
long num
Definition: g3dcats.c:93
int gvl_file_get_data_type(geovol_file *vf)
Get data type for given handle.
Definition: gvl_file.c:203
structure for slice mode reading from volume file
Definition: gvl_file.c:43
return
Definition: g3dcats.c:169
#define MODE_DIRECT
Definition: gvl_file.c:30
int read_vol(geovol_file *vf)
Read all values from volume file.
Definition: gvl_file.c:766
char * gvl_file_get_name(int id)
Get file name for given handle.
Definition: gvl_file.c:166
int gvl_file_get_file_type(geovol_file *vf)
Get file type for given handle.
Definition: gvl_file.c:191
int y
Definition: plot.c:34
#define max(x, y)
Definition: draw2.c:69
int get_buff_value(IFLAG type, void *data, int offset, void *value)
Get value from buffer.
Definition: gvl_file.c:653
int close_volfile(void *map, IFLAG type)
Close volume file.
Definition: gvl_file.c:252
#define MODE_SLICE
Definition: gvl_file.c:31
#define STATUS_BUSY
Definition: gvl_file.c:38
switch(read_cats(name, mapset, pcats))
Definition: g3dcats.c:198
int read_g3d_value(IFLAG type, void *map, int x, int y, int z, void *value)
Eead value from g3d file.
Definition: gvl_file.c:490
#define LUCKY
Definition: gvl_file.c:28
int gvl_file_set_slices_param(geovol_file *vf, int n, int b)
Set parameters for slice reading.
Definition: gvl_file.c:1167
int get_slice_value(geovol_file *vf, int x, int y, int z, void *value)
Get value from slice buffer.
Definition: gvl_file.c:928
tuple data
void G3d_range_min_max(G3D_Map *map, double *min, double *max)
Returns in min and max the minimum and maximum values of the range.
Definition: g3drange.c:149
tuple id
self.OnVectorSurface(event)
Definition: tools.py:3426
int free_volfile_buffs(geovol_file *vf)
Free allocated buffers.
Definition: gvl_file.c:343
char * file_name
int G3d_range_load(G3D_Map *map)
Loads the range into the range structure of map.
Definition: g3drange.c:123
int gvl_file_newh(const char *name, IFLAG file_type)
Get handle for given file name and type.
Definition: gvl_file.c:270
int alloc_slice_buff(geovol_file *vf)
Allocate buffer for slice mode reading.
Definition: gvl_file.c:812
void shift_slices(geovol_file *vf)
Read new slice into buffer.
Definition: gvl_file.c:897
char * value
Definition: env.c:30
int gvl_file_start_read(geovol_file *vf)
Start read - allocate memory buffer a read first data into buffer.
Definition: gvl_file.c:968
int G3d_closeCell(G3D_Map *map)
Closes g3d-file. If map is new and cache-mode is used for map then every tile which is not flushed be...
Definition: g3dclose.c:144
int first
Definition: form/open.c:25
int get_direct_value(geovol_file *vf, int x, int y, int z, void *value)
Read value direct from volume file.
Definition: gvl_file.c:689
if(!YY_CURRENT_BUFFER)
Definition: lex.yy.c:799
int gvl_file_free_datah(int id)
Free geovol_file structure for given handle.
Definition: gvl_file.c:365
int get_vol_value(geovol_file *vf, int x, int y, int z, void *value)
Get value from volume buffer.
Definition: gvl_file.c:791
#define MODE_FULL
Definition: gvl_file.c:32
int num
Definition: gvl_file.c:45
void * open_g3d_file(const char *, IFLAG *, double *, double *)
Open 3d raster file.
Definition: gvl_file.c:418
return NULL
Definition: dbfopen.c:1394
int gvl_file_end_read(geovol_file *vf)
End read - free buffer memory.
Definition: gvl_file.c:1019
G_warning("category support for [%s] in mapset [%s] %s", name, mapset, type)
void * G3d_openCellOld(const char *name, const char *mapset, G3D_Region *window, int typeIntern, int cache)
Opens existing g3d-file name in mapset. Tiles are stored in memory with type which must be any of FCE...
Definition: g3dopen.c:85
int G_debug(int level, const char *msg,...)
Print debugging message.
Definition: gis/debug.c:51
#define STATUS_READY
Definition: gvl_file.c:37
void * GVL_get_window()
Get window.
Definition: GVL2.c:78
int read_g3d_vol(IFLAG type, void *map, void *data)
Read all values from g3d file.
Definition: gvl_file.c:567
int gvl_file_is_null_value(geovol_file *vf, void *value)
Check for null value.
Definition: gvl_file.c:1088
void gvl_file_get_min_max(geovol_file *vf, double *min, double *max)
Get minimum and maximum value in volume file.
Definition: gvl_file.c:215
for(cat=0;;cat++)
Definition: g3dcats.c:140
int G3d_fileTypeMap(G3D_Map *map)
Returns the type with which tiles of map are stored on file.
Definition: headerinfo.c:178
char * G_find_grid3(const char *name, const char *mapset)
Definition: find_grid3.c:21
#define MODE_PRELOAD
Definition: gvl_file.c:33
int free_slice_buff(geovol_file *vf)
Free buffer for slice mode reading.
Definition: gvl_file.c:851
int file_type
int G_fatal_error(const char *msg,...)
Print a fatal error message to stderr.
void * open_volfile(const char *name, IFLAG file_type, IFLAG *data_type, double *min, double *max)
Open 3d raster file.
Definition: gvl_file.c:233
int skip
Definition: gvl_file.c:45
int free_vol_buff(geovol_file *vf)
Free memory buffer memory.
Definition: gvl_file.c:751
#define MODE_DEFAULT
Definition: gvl_file.c:35
int Cols
Definition: gvl_calc.c:73
int find_datah(const char *name, IFLAG type, int begin)
Find file with name and type in geovol_file array an return handle.
Definition: gvl_file.c:140
int gvl_file_set_mode(geovol_file *vf, IFLAG mode)
Set read mode.
Definition: gvl_file.c:1117
int read_g3d_slice(IFLAG type, void *map, int level, void *data)
Read slice of values at level from g3d file.
Definition: gvl_file.c:522
int n
Definition: dataquad.c:291
int gvl_file_get_value(geovol_file *vf, int x, int y, int z, void *value)
Get value for volume file at x, y, z.
Definition: gvl_file.c:1051
int crnt
Definition: gvl_file.c:46
float G3d_getFloat(G3D_Map *map, int x, int y, int z)
Is equivalent to G3d_getValue (map, x, y, z, &amp;value, FCELL_TYPE); return value.
Definition: g3dwindow.c:181
tuple mode
Definition: tools.py:1481
int Depths
Definition: gvl_calc.c:73
int read_slice(geovol_file *vf, int s, int l)
Read slice of values at level from volume file.
Definition: gvl_file.c:873