GRASS GIS 8 Programmer's Manual
8.5.0dev(2024)-d6dec75dd4
|
OGSF library - loading and manipulating surfaces (lower level functions) More...
#include <stdlib.h>
#include <stdio.h>
#include <grass/ogsf.h>
#include <grass/glocale.h>
#include "gsget.h"
#include "rowcol.h"
Go to the source code of this file.
Macros | |
#define | FIRST_SURF_ID 110658 |
Functions | |
void | gs_err (const char *msg) |
void | gs_init (void) |
Initialize library. More... | |
geosurf * | gs_get_surf (int id) |
Get geosurf struct. More... | |
geosurf * | gs_get_prev_surface (int id) |
Get previous geosurf struct. More... | |
int | gs_getall_surfaces (geosurf **gsurfs) |
Get array of geosurf structs. More... | |
int | gs_num_surfaces (void) |
Get number of surfaces. More... | |
int | gs_att_is_set (geosurf *surf, IFLAG att) |
Check if attribute is set. More... | |
geosurf * | gs_get_last_surface (void) |
Get last allocated geosurf struct from list. More... | |
geosurf * | gs_get_new_surface (void) |
Allocate new geosurf struct. More... | |
int | gs_init_surf (geosurf *gs, double ox, double oy, int rows, int cols, double xres, double yres) |
Initialize allocated geosurf struct. More... | |
int | gs_init_normbuff (geosurf *gs) |
Init geosurf normbuff. More... | |
void | print_frto (float(*ft)[4]) |
Debugging, print 'from/to' model coordinates to stderr. More... | |
void | print_realto (float *rt) |
Debugging, print 'to' real coordinates to stderr. More... | |
void | print_256lookup (int *buff) |
Debugging, 256 integer values from buffer. More... | |
void | print_surf_fields (geosurf *s) |
Debugging, print geosurf fields to stderr. More... | |
void | print_view_fields (geoview *gv) |
Debugging, print geoview fields to stderr. More... | |
void | gs_set_defaults (geosurf *gs, float *defs, float *null_defs) |
Set default attribute values. More... | |
void | gs_delete_surf (int id) |
Remove geosurf struct from list. More... | |
int | gs_free_surf (geosurf *fs) |
Free geosurf struct. More... | |
void | gs_free_unshared_buffs (geosurf *fs) |
Free unshared buffers of geosurf struct. More... | |
int | gs_num_datah_reused (int dh) |
Get number of reused values. More... | |
int | gs_get_att_type (geosurf *gs, int desc) |
Get attribute type. More... | |
int | gs_get_att_src (geosurf *gs, int desc) |
Get attribute source. More... | |
typbuff * | gs_get_att_typbuff (geosurf *gs, int desc, int to_write) |
Get attribute data buffer. More... | |
size_t | gs_malloc_att_buff (geosurf *gs, int desc, int type) |
Allocate attribute buffer. More... | |
int | gs_malloc_lookup (geosurf *gs, int desc) |
Allocate attribute lookup. More... | |
int | gs_set_att_type (geosurf *gs, int desc, int type) |
Set attribute type. More... | |
int | gs_set_att_src (geosurf *gs, int desc, int src) |
Set attribute source. More... | |
int | gs_set_att_const (geosurf *gs, int desc, float constant) |
Set attribute constant value. More... | |
void | gs_set_maskmode (int invert) |
Set geosurf mask mode. More... | |
int | gs_mask_defined (geosurf *gs) |
Check if mask is defined. More... | |
int | gs_masked (typbuff *tb, int col, int row, int offset) |
Should only be called when setting up the current mask (gs_bm.c) More... | |
int | gs_mapcolor (typbuff *cobuff, gsurf_att *coloratt, int offset) |
Call this one when you already know att_src is MAP_ATT. More... | |
int | gs_get_zextents (geosurf *gs, float *min, float *max, float *mid) |
Get z-extent values. More... | |
int | gs_get_xextents (geosurf *gs, float *min, float *max) |
Get x-extent values. More... | |
int | gs_get_yextents (geosurf *gs, float *min, float *max) |
Get y-extent values. More... | |
int | gs_get_zrange0 (float *min, float *max) |
Get z-range. More... | |
int | gs_get_zrange (float *min, float *max) |
Get z-range. More... | |
int | gs_get_xrange (float *min, float *max) |
Get x-range. More... | |
int | gs_get_yrange (float *min, float *max) |
Get y-range. More... | |
int | gs_get_data_avg_zmax (float *azmax) |
Get average z-max value. More... | |
int | gs_get_datacenter (float *cen) |
Get data center point. More... | |
int | gs_setall_norm_needupdate (void) |
Set for geosurf need-to-update mark. More... | |
int | gs_point_is_masked (geosurf *gs, float *pt) |
Check if point is masked. More... | |
int | gs_distance_onsurf (geosurf *gs, float *p1, float *p2, float *dist, int use_exag) |
Calculate distance on surface. More... | |
OGSF library - loading and manipulating surfaces (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.
Definition in file gs.c.
Check if attribute is set.
surf | pointer to gsurf or NULL to look at all geosurfs |
att | attribute id |
Definition at line 150 of file gs.c.
References g_surf::att, gsurf_att::att_src, and NOTSET_ATT.
Referenced by GS_transp_is_set().
void gs_delete_surf | ( | int | id | ) |
Remove geosurf struct from list.
id | surface id |
Definition at line 463 of file gs.c.
References G_debug(), gs_free_surf(), and gs_get_surf().
Referenced by GS_delete_surface().
int gs_distance_onsurf | ( | geosurf * | gs, |
float * | p1, | ||
float * | p2, | ||
float * | dist, | ||
int | use_exag | ||
) |
void gs_err | ( | const char * | msg | ) |
Definition at line 35 of file gs.c.
References G_warning().
int gs_free_surf | ( | geosurf * | fs | ) |
Free geosurf struct.
fs | pointer to geosurf struct |
Definition at line 487 of file gs.c.
References G_debug().
Referenced by gs_delete_surf().
void gs_free_unshared_buffs | ( | geosurf * | fs | ) |
int gs_get_att_src | ( | geosurf * | gs, |
int | desc | ||
) |
Get attribute source.
gs | pointer to geosurf struct |
desc | attribute id (descriptor) |
Definition at line 656 of file gs.c.
References g_surf::att, gsurf_att::att_src, G_debug(), g_surf::gsurf_id, and LEGAL_ATT.
Referenced by GS_draw_X(), GS_get_att(), GS_get_cat_at_xy(), GS_get_exag_guess(), GS_get_val_at_xy(), gs_set_att_src(), Gs_update_attrange(), gsd_surf(), gsd_wire_surf(), gsdrape_get_segments(), gvd_vect(), and viewcell_tri_interp().
Get attribute data buffer.
gs | pointer to geosurf struct |
desc | attribute id (descriptor) |
to_write | non-zero value for 'write' |
Definition at line 681 of file gs.c.
References g_surf::att, ATT_TOPO, G_debug(), gsdiff_do_SD(), gsdiff_get_SDref(), gsds_get_typbuff(), g_surf::gsurf_id, gsurf_att::hdata, NULL, and typbuff::tfunc.
Referenced by _viewcell_tri_interp(), GS_get_cat_at_xy(), GS_get_val_at_xy(), gs_update_curmask(), gsd_fringe_horiz_line(), gsd_fringe_horiz_line2(), gsd_fringe_horiz_poly(), gsd_fringe_vert_line(), gsd_fringe_vert_poly(), gsd_wire_arrows(), gsd_wire_surf_const(), and gsd_wire_surf_map().
int gs_get_att_type | ( | geosurf * | gs, |
int | desc | ||
) |
Get attribute type.
gs | pointer to geosurf struct |
desc | attribute id |
Definition at line 630 of file gs.c.
References g_surf::att, gsurf_att::att_src, gsurf_att::att_type, G_debug(), LEGAL_ATT, and NOTSET_ATT.
int gs_get_data_avg_zmax | ( | float * | azmax | ) |
Get average z-max value.
Useful for setting position of cplane, lighting ball, etc.
[out] | azmax | average z-max value |
Definition at line 1201 of file gs.c.
Referenced by GS_get_modelposition1().
int gs_get_datacenter | ( | float * | cen | ) |
Get data center point.
[out] | center | (array X,Y,Z) |
Definition at line 1230 of file gs.c.
Referenced by GS_get_modelposition1(), and gsd_set_view().
geosurf* gs_get_last_surface | ( | void | ) |
Get last allocated geosurf struct from list.
Definition at line 173 of file gs.c.
Referenced by gs_get_new_surface().
geosurf* gs_get_new_surface | ( | void | ) |
Allocate new geosurf struct.
Definition at line 194 of file gs.c.
References G_malloc, gs_get_last_surface(), g_surf::gsurf_id, g_surf::next, and NULL.
geosurf* gs_get_prev_surface | ( | int | id | ) |
Get previous geosurf struct.
id | current surface id |
Definition at line 87 of file gs.c.
Referenced by gs_init_surf().
geosurf* gs_get_surf | ( | int | id | ) |
Get geosurf struct.
id | surface id |
Definition at line 63 of file gs.c.
References G_debug().
Referenced by GP_draw_site(), gs_delete_surf(), GS_draw_cplane_fence(), GS_draw_fringe(), GS_draw_surf(), GS_draw_wire(), GS_draw_X(), GS_get_att(), GS_get_cat_at_xy(), GS_Get_ClientData(), GS_get_dims(), GS_get_drawres(), GS_get_exag_guess(), GS_get_norm_at_xy(), GS_get_trans(), GS_get_val_at_xy(), GS_get_wire_color(), GS_get_zextents(), GS_look_here(), GS_set_att_const(), GS_Set_ClientData(), GS_set_drawres(), GS_set_exag(), GS_set_focus_center_map(), GS_set_Narrow(), GS_set_SDsurf(), GS_set_trans(), GS_set_wire_color(), GS_surf_exists(), GS_unset_att(), GS_update_curmask(), GS_update_normals(), GV_draw_fastvect(), and GV_draw_vect().
int gs_get_xextents | ( | geosurf * | gs, |
float * | min, | ||
float * | max | ||
) |
Get x-extent values.
gs | pointer to geosurf struct | |
[out] | min | x-min value |
[out] | max | x-max value |
Definition at line 1015 of file gs.c.
References max, min, g_surf::x_trans, g_surf::xmax, and g_surf::xmin.
int gs_get_xrange | ( | float * | min, |
float * | max | ||
) |
int gs_get_yextents | ( | geosurf * | gs, |
float * | min, | ||
float * | max | ||
) |
Get y-extent values.
gs | pointer to geosurf struct | |
[out] | min | y-min value |
[out] | max | y-max value |
Definition at line 1032 of file gs.c.
References max, min, g_surf::y_trans, g_surf::ymax, and g_surf::ymin.
int gs_get_yrange | ( | float * | min, |
float * | max | ||
) |
int gs_get_zextents | ( | geosurf * | gs, |
float * | min, | ||
float * | max, | ||
float * | mid | ||
) |
Get z-extent values.
gs | pointer to geosurf struct | |
[out] | min | z-min value |
[out] | max | z-max value |
[out] | mid | z-middle value |
Definition at line 997 of file gs.c.
References max, min, g_surf::z_trans, g_surf::zmax, and g_surf::zmin.
Referenced by GS_get_zextents().
int gs_get_zrange | ( | float * | min, |
float * | max | ||
) |
Get z-range.
[out] | min | z-min value |
[out] | max | z-max value |
Definition at line 1086 of file gs.c.
Referenced by GS_get_zrange(), and gvd_vect().
int gs_get_zrange0 | ( | float * | min, |
float * | max | ||
) |
int gs_getall_surfaces | ( | geosurf ** | gsurfs | ) |
Get array of geosurf structs.
gsurfs | pointer to array |
Definition at line 109 of file gs.c.
Referenced by GS_draw_cplane().
void gs_init | ( | void | ) |
int gs_init_normbuff | ( | geosurf * | gs | ) |
Init geosurf normbuff.
gs | pointer to geosurf struct |
Definition at line 308 of file gs.c.
References g_surf::cols, G_free(), G_malloc, g_surf::norm_needupdate, g_surf::norms, and g_surf::rows.
int gs_init_surf | ( | geosurf * | gs, |
double | ox, | ||
double | oy, | ||
int | rows, | ||
int | cols, | ||
double | xres, | ||
double | yres | ||
) |
Initialize allocated geosurf struct.
gs | pointer to geosurf struct |
ox,oy | x/y origin coordinates |
rows | number of rows |
cols | number of cols |
xres,yres | x/y resolution value |
Definition at line 234 of file gs.c.
References g_surf::att, gsurf_att::att_src, gsurf_att::att_type, ATTY_INT, g_surf::cols, gsurf_att::constant, g_surf::curmask, gsurf_att::default_null, DM_GOURAUD, g_surf::draw_mode, FIRST_SURF_ID, G_debug(), gs_get_prev_surface(), g_surf::gsurf_id, gsurf_att::hdata, gsurf_att::lookup, g_surf::mask_needupdate, MAX_ATTS, gsurf_att::max_nz, gsurf_att::min_nz, g_surf::norm_needupdate, g_surf::norms, NOTSET_ATT, NULL, g_surf::nz_color, g_surf::nz_topo, g_surf::ox, g_surf::oy, ps, gsurf_att::range_nz, g_surf::rows, gsurf_att::user_func, g_surf::wire_color, g_surf::x_mod, g_surf::x_modw, g_surf::x_trans, g_surf::xmax, g_surf::xmin, g_surf::xrange, g_surf::xres, g_surf::y_mod, g_surf::y_modw, g_surf::y_trans, g_surf::ymax, g_surf::ymin, g_surf::yrange, g_surf::yres, g_surf::z_exag, g_surf::z_trans, g_surf::zmax, g_surf::zmax_nz, g_surf::zmin, g_surf::zmin_nz, g_surf::zminmasked, g_surf::zrange, and g_surf::zrange_nz.
size_t gs_malloc_att_buff | ( | geosurf * | gs, |
int | desc, | ||
int | type | ||
) |
int gs_malloc_lookup | ( | geosurf * | gs, |
int | desc | ||
) |
Allocate attribute lookup.
gs | pointer to geosurf struct |
desc | attribute id |
Definition at line 746 of file gs.c.
References g_surf::att, gsurf_att::att_type, ATTY_CHAR, ATTY_SHORT, G_debug(), G_free(), G_malloc, G_warning(), gsurf_att::lookup, and NULL.
Call this one when you already know att_src is MAP_ATT.
cobuff | |
coloratt | color attribute |
offset | offset value |
Definition at line 968 of file gs.c.
References typbuff::cb, typbuff::ib, and gsurf_att::lookup.
Referenced by GS_get_val_at_xy(), gs_update_curmask(), gsd_wire_arrows(), gsd_wire_surf_const(), and gsd_wire_surf_map().
int gs_mask_defined | ( | geosurf * | gs | ) |
Check if mask is defined.
gs | pointer to geosurf struct |
Definition at line 914 of file gs.c.
References g_surf::att, ATT_MASK, gsurf_att::att_src, and NOTSET_ATT.
Referenced by gs_update_curmask().
int gs_masked | ( | typbuff * | tb, |
int | col, | ||
int | row, | ||
int | offset | ||
) |
Should only be called when setting up the current mask (gs_bm.c)
tb | pointer to typbuff |
col | number of cols |
row | number of rows |
offset | offset value |
Definition at line 932 of file gs.c.
References typbuff::bm, BM_get(), typbuff::cb, typbuff::fb, typbuff::ib, and typbuff::sb.
Referenced by gs_update_curmask().
int gs_num_datah_reused | ( | int | dh | ) |
Get number of reused values.
dh | value |
Definition at line 597 of file gs.c.
References G_debug().
Referenced by gs_set_att_src().
int gs_num_surfaces | ( | void | ) |
Get number of surfaces.
Definition at line 128 of file gs.c.
Referenced by GS_draw_cplane(), and GS_num_surfs().
int gs_point_is_masked | ( | geosurf * | gs, |
float * | pt | ||
) |
Check if point is masked.
gs | pointer to geosurf struct |
pt | point coordinates (X,Y,Z) |
Definition at line 1314 of file gs.c.
References BM_get(), g_surf::curmask, MASK_BL, MASK_BR, MASK_TL, MASK_TR, VCOL2DCOL, VCOL2X, VCOLS, VROW2DROW, VROW2Y, VROWS, VXRES, VYRES, X, X2VCOL, Y, and Y2VROW.
Referenced by GS_get_cat_at_xy(), GS_get_norm_at_xy(), GS_get_val_at_xy(), gvd_draw_lineonsurf(), gvd_vect(), and viewcell_tri_interp().
int gs_set_att_const | ( | geosurf * | gs, |
int | desc, | ||
float | constant | ||
) |
Set attribute constant value.
gs | pointer to geosurf struct |
desc | attribute id |
constant | constant value |
Definition at line 871 of file gs.c.
References g_surf::att, ATT_MASK, CONST_ATT, gsurf_att::constant, G_debug(), gs_set_att_src(), Gs_update_attrange(), g_surf::gsurf_id, and g_surf::mask_needupdate.
Referenced by GS_set_att_const().
int gs_set_att_src | ( | geosurf * | gs, |
int | desc, | ||
int | src | ||
) |
Set attribute source.
gs | pointer to geosurf struct |
desc | attribute id (descriptor) |
src | source id |
Definition at line 826 of file gs.c.
References g_surf::att, gsurf_att::att_src, ATT_TOPO, G_debug(), G_free(), gs_get_att_src(), gs_num_datah_reused(), gsds_free_datah(), g_surf::gsurf_id, gsurf_att::hdata, LEGAL_SRC, MAP_ATT, g_surf::norm_needupdate, g_surf::norms, NULL, and src.
Referenced by gs_set_att_const(), and GS_unset_att().
int gs_set_att_type | ( | geosurf * | gs, |
int | desc, | ||
int | type | ||
) |
void gs_set_defaults | ( | geosurf * | gs, |
float * | defs, | ||
float * | null_defs | ||
) |
Set default attribute values.
gs | pointer to geosurf struct |
defs | array of default values (dim MAX_ATTRS) |
null_defs | array of null default values (dim MAX_ATTRS) |
Definition at line 441 of file gs.c.
References g_surf::att, gsurf_att::att_src, gsurf_att::constant, gsurf_att::default_null, G_debug(), g_surf::gsurf_id, gsurf_att::hdata, gsurf_att::lookup, MAX_ATTS, NOTSET_ATT, and NULL.
void gs_set_maskmode | ( | int | invert | ) |
Set geosurf mask mode.
invert | invert mask |
Definition at line 899 of file gs.c.
Referenced by gs_update_curmask().
int gs_setall_norm_needupdate | ( | void | ) |
void print_256lookup | ( | int * | buff | ) |
void print_frto | ( | float(*) | ft[4] | ) |
void print_realto | ( | float * | rt | ) |
void print_surf_fields | ( | geosurf * | s | ) |
void print_view_fields | ( | geoview * | gv | ) |
Debugging, print geoview fields to stderr.
gv | pointer to geoview struct |
Definition at line 419 of file gs.c.
References geoview::coord_sys, geoview::fov, geoview::from_to, geoview::incl, geoview::infocus, geoview::look, print_frto(), geoview::real_to, geoview::scale, geoview::twist, geoview::vert_exag, geoview::view_proj, X, Y, and Z.