24#include <grass/ogsf.h>
28#define FIRST_VOL_ID 81721
30static geovol *Vol_top =
NULL;
46 for (gvl = Vol_top; gvl; gvl = gvl->next) {
47 if (gvl->gvol_id ==
id) {
70 for (pv = Vol_top; pv; pv = pv->next) {
71 if (pv->gvol_id ==
id - 1) {
93 for (i = 0, gvl = Vol_top; gvl; gvl = gvl->next, i++) {
110 for (i = 0, gvl = Vol_top; gvl; gvl = gvl->next, i++)
113 G_debug(5,
"gvl_num_vols(): num=%d", i);
128 G_debug(5,
"gvl_get_last_vol");
134 for (lvl = Vol_top; lvl->next; lvl = lvl->next)
137 G_debug(5,
" last vol id: %d", lvl->gvol_id);
152 G_debug(5,
"gvl_get_new_vol()");
154 nvl = (geovol *)G_malloc(
sizeof(geovol));
161 nvl->gvol_id = lvl->gvol_id + 1;
170 G_debug(5,
" id=%d", nvl->gvol_id);
187int gvl_init_vol(geovol *gvl,
double ox,
double oy,
double oz,
int rows,
188 int cols,
int depths,
double xres,
double yres,
double zres)
190 G_debug(5,
"gvl_init_vol() id=%d", gvl->gvol_id);
201 gvl->depths = depths;
207 gvl->xmax = ox + (cols - 1) * xres;
208 gvl->xrange = gvl->xmax - gvl->xmin;
210 gvl->ymax = oy + (rows - 1) * yres;
211 gvl->yrange = gvl->ymax - gvl->ymin;
213 gvl->zmax = oz + (depths - 1) * zres;
214 gvl->zrange = gvl->zmax - gvl->zmin;
216 gvl->x_trans = gvl->y_trans = gvl->z_trans = 0.0;
220 G_zero(gvl->isosurf,
sizeof(geovol_isosurf *) * MAX_ISOSURFS);
221 gvl->isosurf_x_mod = 1;
222 gvl->isosurf_y_mod = 1;
223 gvl->isosurf_z_mod = 1;
224 gvl->isosurf_draw_mode = DM_GOURAUD;
227 G_zero(gvl->slice,
sizeof(geovol_slice *) * MAX_SLICES);
228 gvl->slice_x_mod = 1;
229 gvl->slice_y_mod = 1;
230 gvl->slice_z_mod = 1;
231 gvl->slice_draw_mode = DM_GOURAUD;
234 gvl->clientdata =
NULL;
275 if (fvl == Vol_top) {
288 for (gvl = Vol_top; gvl && !found; gvl = gvl->next) {
291 if (gvl->next == fvl) {
293 gvl->next = fvl->next;
331 G_debug(5,
"ID: %d", gvl->gvol_id);
332 G_debug(5,
"cols: %d rows: %d depths: %d", gvl->cols, gvl->rows,
334 G_debug(5,
"ox: %lf oy: %lf oz: %lf", gvl->ox, gvl->oy, gvl->oz);
335 G_debug(5,
"xres: %lf yres: %lf zres: %lf", gvl->xres, gvl->yres,
337 G_debug(5,
"xmin: %f ymin: %f zmin: %f", gvl->xmin, gvl->ymin, gvl->zmin);
338 G_debug(5,
"xmax: %f ymax: %f zmax: %f", gvl->xmax, gvl->ymax, gvl->zmax);
339 G_debug(5,
"x_trans: %f y_trans: %f z_trans: %f", gvl->x_trans,
340 gvl->y_trans, gvl->z_trans);
356 *
min = gvl->xmin + gvl->x_trans;
357 *
max = gvl->xmax + gvl->x_trans;
373 *
min = gvl->ymin + gvl->y_trans;
374 *
max = gvl->ymax + gvl->y_trans;
390 *
min = gvl->zmin + gvl->z_trans;
391 *
max = gvl->zmax + gvl->z_trans;
418 for (gvl = Vol_top->next; gvl; gvl = gvl->next) {
455 for (gvl = Vol_top->next; gvl; gvl = gvl->next) {
492 for (gvl = Vol_top->next; gvl; gvl = gvl->next) {
524 G_debug(5,
"gvl_isosurf_init");
529 for (i = 0; i < MAX_ATTS; i++) {
530 isosurf->att[i].att_src = NOTSET_ATT;
531 isosurf->att[i].constant = 0.;
532 isosurf->att[i].hfile = -1;
533 isosurf->att[i].user_func =
NULL;
534 isosurf->att[i].att_data =
NULL;
535 isosurf->att[i].changed = 0;
538 isosurf->data =
NULL;
539 isosurf->data_desc = 0;
540 isosurf->inout_mode = 0;
557 G_debug(5,
"gvl_isosurf_freemem");
562 for (i = 0; i < MAX_ATTS; i++) {
584 G_debug(5,
"gvl_isosurf_get_isosurf(): id=%d isosurf=%d",
id, isosurf_id);
589 if ((isosurf_id < 0) || (isosurf_id > (gvl->n_isosurfs - 1)))
592 return gvl->isosurf[isosurf_id];
609 G_debug(5,
"isosurf_get_att_src");
611 if (!LEGAL_ATT(desc)) {
616 return (isosurf->att[desc].att_src);
634 G_debug(5,
"gvl_isosurf_set_att_src");
640 if (desc == ATT_COLOR) {
645 if (isosurf && LEGAL_SRC(src)) {
646 isosurf->att[desc].att_src = src;
667 G_debug(5,
"gvl_isosurf_set_att_const(): att=%d, const=%f", desc, constant);
670 isosurf->att[desc].constant = constant;
691 const char *filename)
695 G_debug(5,
"gvl_isosurf_set_att_map(): att=%d map=%s", desc, filename);
698 if (0 > (hfile =
gvl_file_newh(filename, VOL_FTYPE_RASTER3D)))
703 isosurf->att[desc].hfile = hfile;
705 if (ATT_COLOR == desc) {
727 G_debug(5,
"gvl_isosurf_set_att_changed");
729 if (isosurf && LEGAL_ATT(desc)) {
730 isosurf->att[desc].changed = 1;
732 if ((desc == ATT_TOPO) || (desc == ATT_MASK)) {
733 for (i = 1; i < MAX_ATTS; i++)
734 isosurf->att[i].changed = 1;
784 G_debug(5,
"gvl_slice_freemem");
810 if ((slice_id < 0) || (slice_id > (gvl->n_slices - 1)))
813 return gvl->slice[slice_id];
void G_free(void *buf)
Free allocated memory.
int G_debug(int level, const char *msg,...)
Print debugging message.
int Gvl_unload_colors_data(void *color_data)
Unload color table.
int Gvl_load_colors_data(void **color_data, const char *name)
Load color table.
void gvl_free_volmem(geovol *fvl)
Free geovol struct memory.
geovol * gvl_get_new_vol(void)
Allocate new volume set and add it to the list.
int gvl_get_yrange(float *min, float *max)
Get volume y-range value.
int gvl_get_xextents(geovol *gvl, float *min, float *max)
Get volume x-extent value.
int gvl_isosurf_init(geovol_isosurf *isosurf)
Initialize geovol_isosurf struct.
int gvl_init_vol(geovol *gvl, double ox, double oy, double oz, int rows, int cols, int depths, double xres, double yres, double zres)
Initialize geovol structure.
geovol * gvl_get_prev_vol(int id)
Get previous volume.
int gvl_getall_vols(geovol **gvols)
Get all volumes.
void print_vol_fields(geovol *gvl)
Debug volume fields.
int gvl_isosurf_set_att_map(geovol_isosurf *isosurf, int desc, const char *filename)
Set attribute map.
int gvl_slice_freemem(geovol_slice *slice)
Free geovol_slice struct.
geovol * gvl_get_vol(int id)
Get volume set structure.
int gvl_isosurf_get_att_src(geovol_isosurf *isosurf, int desc)
Get attribute source.
int gvl_isosurf_freemem(geovol_isosurf *isosurf)
Free geovol_isosurf struct.
geovol_slice * gvl_slice_get_slice(int id, int slice_id)
Get geovol_slice struct.
geovol_isosurf * gvl_isosurf_get_isosurf(int id, int isosurf_id)
Get isosurface of given volume set.
int gvl_get_zrange(float *min, float *max)
Get volume z-range value.
int gvl_isosurf_set_att_src(geovol_isosurf *isosurf, int desc, int src)
Set attribute source.
int gvl_get_xrange(float *min, float *max)
Get volume x-range value.
int gvl_isosurf_set_att_changed(geovol_isosurf *isosurf, int desc)
Set attribute changed.
int gvl_get_zextents(geovol *gvl, float *min, float *max)
Get volume z-extent value.
int gvl_isosurf_set_att_const(geovol_isosurf *isosurf, int desc, float constant)
Set isosurface attribute constant.
geovol * gvl_get_last_vol(void)
Get last volume set from the list.
int gvl_get_yextents(geovol *gvl, float *min, float *max)
Get volume y-extent value.
int gvl_slice_init(geovol_slice *slice)
Initialize geovol_slice struct.
void gvl_delete_vol(int id)
Remove volume set from list.
int gvl_num_vols(void)
Get number of loaded volume sets.
int gvl_free_vol(geovol *fvl)
Free geovol struct.
int gvl_file_free_datah(int id)
Free geovol_file structure for given handle.
int gvl_file_newh(const char *name, IFLAG file_type)
Get handle for given file name and type.
void G_zero(void *buf, int i)
Zero out a buffer, buf, of length i.