GRASS 8 Programmer's Manual 8.6.0dev(2026)-0f6a7341fc
Loading...
Searching...
No Matches
gvl3.c
Go to the documentation of this file.
1/*!
2 \file lib/ogsf/gvl3.c
3
4 \brief OGSF library - loading volumes (lower level functions)
5
6 GRASS OpenGL gsurf OGSF Library
7
8 SPDX-FileCopyrightText: 1999-2008 GRASS Development Team
9 SPDX-License-Identifier: GPL-2.0-or-later
10
11 \author Tomas Paudits (December 2003)
12 \author Doxygenized by Martin Landa <landa.martin gmail.com> (May 2008)
13 */
14
15#include <grass/gis.h>
16#include <grass/raster.h>
17#include <grass/raster3d.h>
18#include <grass/ogsf.h>
19#include <grass/glocale.h>
20
21/*!
22 \brief Load color table
23
24 \param[out] color_data color data buffer
25 \param name 3D raster map name
26
27 \return -1 on failure
28 \return 1 on success
29 */
30int Gvl_load_colors_data(void **color_data, const char *name)
31{
32 const char *mapset;
33 struct Colors *colors;
34
35 if (NULL == (mapset = G_find_raster3d(name, ""))) {
36 G_warning(_("3D raster map <%s> not found"), name);
37 return (-1);
38 }
39
40 if (NULL == (colors = (struct Colors *)G_malloc(sizeof(struct Colors))))
41 return (-1);
42
43 if (0 > Rast3d_read_colors(name, mapset, colors)) {
44 G_free(colors);
45 return (-1);
46 }
47
48 *color_data = colors;
49
50 return (1);
51}
52
53/*!
54 \brief Unload color table
55
56 \param color_data color data buffer
57
58 \return -1 on failure
59 \return 1 on success
60 */
62{
64
66
67 return (1);
68}
69
70/*!
71 \brief Get color for value
72
73 \param color_data color data value
74 \param value data value
75
76 \return color value
77 */
78int Gvl_get_color_for_value(void *color_data, float *value)
79{
80 int r, g, b;
81
82 Rast_get_f_color((FCELL *)value, &r, &g, &b, color_data);
83 return ((r & 0xff) | ((g & 0xff) << 8) | ((b & 0xff) << 16));
84}
#define NULL
Definition ccmath.h:32
void G_free(void *)
Free allocated memory.
Definition gis/alloc.c:145
const char * G_find_raster3d(const char *, const char *)
Search for a 3D raster map in current search path or in a specified mapset.
Definition find_rast3d.c:26
void G_warning(const char *,...) __attribute__((format(printf
#define G_malloc(n)
Definition defs/gis.h:136
int Rast3d_read_colors(const char *, const char *, struct Colors *)
Reads color file for map name in mapset into the Colors structure.
void Rast_free_colors(struct Colors *)
Free color structure memory.
Definition color_free.c:28
int Rast_get_f_color(const FCELL *, int *, int *, int *, struct Colors *)
Gets color from raster map (FCELL)
Definition color_get.c:86
float FCELL
Definition gis.h:633
#define _(str)
Definition glocale.h:10
int Gvl_unload_colors_data(void *color_data)
Unload color table.
Definition gvl3.c:61
int Gvl_load_colors_data(void **color_data, const char *name)
Load color table.
Definition gvl3.c:30
int Gvl_get_color_for_value(void *color_data, float *value)
Get color for value.
Definition gvl3.c:78
float g
Definition named_colr.c:7
const char * name
Definition named_colr.c:6
OGSF header file (structures)
double b
Definition r_raster.c:37
double r
Definition r_raster.c:37
Definition gis.h:689