GRASS Programmer's Manual  6.5.svn(2014)-r66266
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
exag.c
Go to the documentation of this file.
1 
15 #include <grass/nviz.h>
16 
28 int Nviz_get_exag_height(double *val, double *min, double *max)
29 {
30  float longdim, exag, texag, hmin, hmax, fmin, fmax;
31  int nsurfs, i, *surf_list;
32 
33  surf_list = GS_get_surf_list(&nsurfs);
34  if (nsurfs) {
35  GS_get_longdim(&longdim);
36  GS_get_zrange_nz(&hmin, &hmax);
37 
38  exag = 0.0;
39  for (i = 0; i < nsurfs; i++) {
40  if (GS_get_exag_guess(surf_list[i], &texag) > -1)
41  if (texag)
42  exag = texag > exag ? texag : exag;
43  }
44  if (exag == 0.0)
45  exag = 1.0;
46 
47  fmin = hmin - (2. * longdim / exag);
48  fmax = hmin + (3 * longdim / exag);
49  }
50  else {
51  fmax = 10000.0;
52  fmin = 0.0;
53  }
54 
55  *val = fmin + (fmax - fmin) / 2.0;
56 
57  if (min)
58  *min = fmin;
59 
60  if (max)
61  *max = fmax;
62 
63  G_debug(1, "Nviz_get_exag_height(): value = %f min = %f max = %f",
64  *val, min ? *min : 0.0 , max ? *max : 0.0);
65 
66  return 1;
67 }
68 
76 double Nviz_get_exag()
77 {
78  float exag, texag;
79  int nsurfs, i, *surf_list;
80 
81  surf_list = GS_get_surf_list(&nsurfs);
82 
83  exag = 0.0;
84  for (i = 0; i < nsurfs; i++) {
85  if (GS_get_exag_guess(surf_list[i], &texag) > -1) {
86  if (texag)
87  exag = (texag > exag) ? texag : exag;
88  }
89  }
90 
91  if (exag == 0.0)
92  exag = 1.0;
93 
94  if (nsurfs > 0)
95  G_free(surf_list);
96 
97  G_debug(1, "Nviz_get_exag(): value = %f", exag);
98  return exag;
99 }
void G_free(void *buf)
Free allocated memory.
Definition: gis/alloc.c:142
#define min(x, y)
Definition: draw2.c:68
int Nviz_get_exag_height(double *val, double *min, double *max)
Get view height.
Definition: exag.c:28
#define max(x, y)
Definition: draw2.c:69
void GS_get_zrange_nz(float *min, float *max)
Get Z extents for all loaded surfaces.
Definition: GS2.c:2354
int G_debug(int level, const char *msg,...)
Print debugging message.
Definition: gis/debug.c:51
int GS_get_longdim(float *dim)
Get largest dimension.
Definition: GS2.c:140
int * GS_get_surf_list(int *numsurfs)
Get surface list.
Definition: GS2.c:1536
int GS_get_exag_guess(int id, float *exag)
Get exag-value guess.
Definition: GS2.c:2303
double Nviz_get_exag()
Get view z-exag value.
Definition: exag.c:76