22 #include <grass/gstypes.h>
25 #define FIRST_VECT_ID 20656
27 static geovect *Vect_top =
NULL;
41 G_debug(5,
"gv_get_vect() id=%d",
id);
43 for (gv = Vect_top; gv; gv = gv->next) {
44 if (gv->gvect_id ==
id) {
64 G_debug(5,
"gv_get_prev_vect(): id=%d",
id);
66 for (pv = Vect_top; pv; pv = pv->next) {
67 if (pv->gvect_id ==
id - 1) {
85 for (i = 0, gv = Vect_top; gv; gv = gv->next, i++) ;
87 G_debug(5,
"gv_num_vects(): num=%d", i);
106 for (lv = Vect_top; lv->next; lv = lv->next) ;
108 G_debug(5,
"gv_get_last_vect(): id=%d", lv->gvect_id);
123 nv = (geovect *) G_malloc(
sizeof(geovect));
131 nv->gvect_id = lv->gvect_id + 1;
140 G_debug(5,
"gv_get_new_vect() id=%d", nv->gvect_id);
155 for (gv = Vect_top; gv; gv = gv->next) {
157 for (i = 0; i < gv->n_surfs; i++) {
158 if (gv->drape_surf_id[i]) {
160 for (j = i; j < gv->n_surfs - 1; j++) {
161 gv->drape_surf_id[j] = gv->drape_surf_id[j + 1];
164 gv->n_surfs = gv->n_surfs - 1;
188 G_debug(5,
"gv_set_defaults() id=%d", gv->gvect_id);
191 gv->n_lines = gv->n_surfs = gv->use_mem = 0;
192 gv->x_trans = gv->y_trans = gv->z_trans = 0.0;
194 gv->fastlines =
NULL;
196 gv->color = 0xFFFFFF;
199 for (i = 0; i < MAX_SURFS; i++) {
200 gv->drape_surf_id[i] = 0;
220 G_debug(5,
"gv_init_vect() id=%d", gv->gvect_id);
234 G_debug(5,
"gv_delete_vect(): id=%d",
id);
259 if (fv == Vect_top) {
260 if (Vect_top->next) {
272 for (gv = Vect_top; gv && !found; gv = gv->next) {
275 if (gv->next == fv) {
284 G_debug(5,
"gv_free_vect(): id=%d", fv->gvect_id);
303 geoline *gln, *tmpln;
305 G_free((
void *)fv->filename);
309 for (gln = fv->lines; gln;) {
310 if (gln->dims == 2) {
315 if (gln->dims == 3) {
343 for (i = 0; i < nsurfs && i < MAX_SURFS; i++) {
344 gv->drape_surf_id[i] = hsurfs[i];
void G_free(void *buf)
Free allocated memory.
void gv_delete_vect(int id)
Delete vector set (unload)
geovect * gv_get_prev_vect(int id)
Get previous vector set.
int gv_free_vect(geovect *fv)
Free allocated memory for geovect struct.
void gv_update_drapesurfs(void)
Update drape surfaces.
int gv_set_defaults(geovect *gv)
Set attributes of vector set to default values.
geosurf * gs_get_surf(int id)
Get geosurf struct.
geovect * gv_get_vect(int id)
Get vector set.
geovect * gv_get_last_vect(void)
Get last loaded vector set.
int G_debug(int level, const char *msg,...)
Print debugging message.
geovect * gv_get_new_vect(void)
Allocate memory for new vector set.
int gv_num_vects(void)
Get number of loaded vector sets.
int gv_init_vect(geovect *gv)
Initialize geovect struct.
void gv_free_vectmem(geovect *fv)
Free allocated memory.
void gv_set_drapesurfs(geovect *gv, int *hsurfs, int nsurfs)
Set drape surfaces for vector set.
void sub_Vectmem(int minus)
Tracking memory.