Loading...
Searching...
No Matches
gvl3.c
Go to the documentation of this file.
/*!
\file lib/ogsf/gvl3.c
\brief OGSF library - loading volumes (lower level functions)
GRASS OpenGL gsurf OGSF Library
(C) 1999-2008 by the GRASS Development Team
This program is free software under the
GNU General Public License (>=v2).
Read the file COPYING that comes with GRASS
for details.
\author Tomas Paudits (December 2003)
\author Doxygenized by Martin Landa <landa.martin gmail.com> (May 2008)
*/
#include <grass/gis.h>
#include <grass/raster.h>
#include <grass/raster3d.h>
#include <grass/ogsf.h>
#include <grass/glocale.h>
/*!
\brief Load color table
\param[out] color_data color data buffer
\param name 3D raster map name
\return -1 on failure
\return 1 on success
*/
int Gvl_load_colors_data(void **color_data, const char *name)
{
const char *mapset;
struct Colors *colors;
if (NULL == (mapset = G_find_raster3d(name, ""))) {
G_warning(_("3D raster map <%s> not found"), name);
return (-1);
}
if (NULL == (colors = (struct Colors *)G_malloc(sizeof(struct Colors))))
return (-1);
if (0 > Rast3d_read_colors(name, mapset, colors)) {
G_free(colors);
return (-1);
}
*color_data = colors;
return (1);
}
/*!
\brief Unload color table
\param color_data color data buffer
\return -1 on failure
\return 1 on success
*/
int Gvl_unload_colors_data(void *color_data)
{
Rast_free_colors(color_data);
G_free(color_data);
return (1);
}
/*!
\brief Get color for value
\param color_data color data value
\param value data value
\return color value
*/
int Gvl_get_color_for_value(void *color_data, float *value)
{
int r, g, b;
Rast_get_f_color((FCELL *)value, &r, &g, &b, color_data);
return ((r & 0xff) | ((g & 0xff) << 8) | ((b & 0xff) << 16));
}
G_free
void G_free(void *buf)
Free allocated memory.
Definition alloc.c:147
NULL
#define NULL
Definition ccmath.h:32
b
double b
Definition driver/set_window.c:5
r
double r
Definition driver/set_window.c:5
G_find_raster3d
const char * G_find_raster3d(const char *name, const char *mapset)
Definition find_rast3d.c:28
G_warning
void G_warning(const char *msg,...)
Print a warning message to stderr.
Definition gis/error.c:203
Gvl_unload_colors_data
int Gvl_unload_colors_data(void *color_data)
Unload color table.
Definition gvl3.c:65
Gvl_load_colors_data
int Gvl_load_colors_data(void **color_data, const char *name)
Load color table.
Definition gvl3.c:34
Gvl_get_color_for_value
int Gvl_get_color_for_value(void *color_data, float *value)
Get color for value.
Definition gvl3.c:82
g
float g
Definition named_colr.c:7
name
const char * name
Definition named_colr.c:6