GRASS Programmer's Manual  6.4.2(2012)
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Gvl3.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 
33 int Gvl_load_colors_data(void **color_data, const char *name)
34 {
35  const char *mapset;
36  struct Colors *colors;
37 
38  if (NULL == (mapset = G_find_grid3(name, ""))) {
39  G_warning(_("3D raster map <%s> not found"), name);
40  return (-1);
41  }
42 
43  if (NULL == (colors = (struct Colors *)G_malloc(sizeof(struct Colors))))
44  return (-1);
45 
46  if (0 > G3d_readColors(name, mapset, colors)) {
47  G_free(colors);
48  return (-1);
49  }
50 
51  *color_data = colors;
52 
53  return (1);
54 }
55 
64 int Gvl_unload_colors_data(void *color_data)
65 {
66  if (!G_free_colors(color_data))
67  return (-1);
68 
69  G_free(color_data);
70 
71  return (1);
72 }
73 
82 int Gvl_get_color_for_value(void *color_data, float *value)
83 {
84  int r, g, b;
85 
86  G_get_f_raster_color((FCELL *) value, &r, &g, &b, color_data);
87  return ((r & 0xff) | ((g & 0xff) << 8) | ((b & 0xff) << 16));
88 }