22 #include <grass/gis.h> 
   23 #include <grass/gstypes.h> 
   27 #define FIRST_VOL_ID 81721 
   29 static geovol *Vol_top = 
NULL;
 
   45     for (gvl = Vol_top; gvl; gvl = gvl->next) {
 
   46         if (gvl->gvol_id == 
id) {
 
   69     for (pv = Vol_top; pv; pv = pv->next) {
 
   70         if (pv->gvol_id == 
id - 1) {
 
   92     for (i = 0, gvl = Vol_top; gvl; gvl = gvl->next, i++) {
 
  109     for (i = 0, gvl = Vol_top; gvl; gvl = gvl->next, i++) ;
 
  111     G_debug(5, 
"gvl_num_vols(): num=%d", i);
 
  126     G_debug(5, 
"gvl_get_last_vol");
 
  132     for (lvl = Vol_top; lvl->next; lvl = lvl->next) ;
 
  134     G_debug(5, 
"  last vol id: %d", lvl->gvol_id);
 
  149     G_debug(5, 
"gvl_get_new_vol()");
 
  151     nvl = (geovol *) G_malloc(
sizeof(geovol));  
 
  158         nvl->gvol_id = lvl->gvol_id + 1;
 
  167     G_debug(5, 
"    id=%d", nvl->gvol_id);
 
  185                  int rows, 
int cols, 
int depths, 
double xres, 
double yres,
 
  188     G_debug(5, 
"gvl_init_vol() id=%d", gvl->gvol_id);
 
  199     gvl->depths = depths;
 
  205     gvl->xmax = ox + (cols - 1) * xres;
 
  206     gvl->xrange = gvl->xmax - gvl->xmin;
 
  208     gvl->ymax = oy + (rows - 1) * yres;
 
  209     gvl->yrange = gvl->ymax - gvl->ymin;
 
  211     gvl->zmax = oz + (depths - 1) * zres;
 
  212     gvl->zrange = gvl->zmax - gvl->zmin;
 
  214     gvl->x_trans = gvl->y_trans = gvl->z_trans = 0.0;
 
  217     G_zero(gvl->isosurf, 
sizeof(geovol_isosurf *) * MAX_ISOSURFS);
 
  218     gvl->isosurf_x_mod = 1;
 
  219     gvl->isosurf_y_mod = 1;
 
  220     gvl->isosurf_z_mod = 1;
 
  221     gvl->isosurf_draw_mode = DM_GOURAUD;
 
  224     G_zero(gvl->slice, 
sizeof(geovol_slice *) * MAX_SLICES);
 
  225     gvl->slice_x_mod = 1;
 
  226     gvl->slice_y_mod = 1;
 
  227     gvl->slice_z_mod = 1;
 
  228     gvl->slice_draw_mode = DM_GOURAUD;
 
  231     gvl->clientdata = 
NULL;
 
  272         if (fvl == Vol_top) {
 
  285             for (gvl = Vol_top; gvl && !found; gvl = gvl->next) {
 
  288                     if (gvl->next == fvl) {
 
  290                         gvl->next = fvl->next;
 
  328     G_debug(5, 
"ID: %d", gvl->gvol_id);
 
  329     G_debug(5, 
"cols: %d rows: %d depths: %d", gvl->cols, gvl->rows,
 
  331     G_debug(5, 
"ox: %lf oy: %lf oz: %lf", gvl->ox, gvl->oy, gvl->oz);
 
  332     G_debug(5, 
"xres: %lf yres: %lf zres: %lf", gvl->xres, gvl->yres,
 
  334     G_debug(5, 
"xmin: %f ymin: %f zmin: %f", gvl->xmin, gvl->ymin, gvl->zmin);
 
  335     G_debug(5, 
"xmax: %f ymax: %f zmax: %f", gvl->xmax, gvl->ymax, gvl->zmax);
 
  336     G_debug(5, 
"x_trans: %f y_trans: %f z_trans: %f", gvl->x_trans,
 
  337             gvl->y_trans, gvl->z_trans);
 
  353     *min = gvl->xmin + gvl->x_trans;
 
  354     *max = gvl->xmax + gvl->x_trans;
 
  370     *min = gvl->ymin + gvl->y_trans;
 
  371     *max = gvl->ymax + gvl->y_trans;
 
  387     *min = gvl->zmin + gvl->z_trans;
 
  388     *max = gvl->zmax + gvl->z_trans;
 
  415     for (gvl = Vol_top->next; gvl; gvl = gvl->next) {
 
  452     for (gvl = Vol_top->next; gvl; gvl = gvl->next) {
 
  489     for (gvl = Vol_top->next; gvl; gvl = gvl->next) {
 
  521     G_debug(5, 
"gvl_isosurf_init");
 
  526     for (i = 0; i < MAX_ATTS; i++) {
 
  527         isosurf->att[i].att_src = NOTSET_ATT;
 
  528         isosurf->att[i].constant = 0.;
 
  529         isosurf->att[i].hfile = -1;
 
  530         isosurf->att[i].user_func = 
NULL;
 
  531         isosurf->att[i].att_data = 
NULL;
 
  532         isosurf->att[i].changed = 0;
 
  535     isosurf->data = 
NULL;
 
  536     isosurf->data_desc = 0;
 
  537     isosurf->inout_mode = 0;
 
  554     G_debug(5, 
"gvl_isosurf_freemem");
 
  559     for (i = 0; i < MAX_ATTS; i++) {
 
  581     G_debug(5, 
"gvl_isosurf_get_isosurf(): id=%d isosurf=%d",
 
  587         if ((isosurf_id < 0) || (isosurf_id > (gvl->n_isosurfs - 1)))
 
  590         return gvl->isosurf[isosurf_id];
 
  607     G_debug(5, 
"isosurf_get_att_src");
 
  609     if (!LEGAL_ATT(desc)) {
 
  614         return (isosurf->att[desc].att_src);
 
  632     G_debug(5, 
"gvl_isosurf_set_att_src");
 
  638         if (desc == ATT_COLOR) {
 
  643     if (isosurf && LEGAL_SRC(src)) {
 
  644         isosurf->att[desc].att_src = src;
 
  666     G_debug(5, 
"gvl_isosurf_set_att_const(): att=%d, const=%f",
 
  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);
 
  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];
 
int gvl_get_yrange(float *min, float *max)
Get volume y-range value. 
void G_free(void *buf)
Free allocated memory. 
int gvl_getall_vols(geovol **gvols)
Get all volumes. 
geovol * gvl_get_prev_vol(int id)
Get previous volume. 
int gvl_get_xrange(float *min, float *max)
Get volume x-range value. 
int gvl_num_vols(void)
Get number of loaded volume sets. 
int Gvl_unload_colors_data(void *color_data)
Unload color table. 
int gvl_isosurf_set_att_map(geovol_isosurf *isosurf, int desc, const char *filename)
Set attribute map. 
int gvl_get_zrange(float *min, float *max)
Get volume z-range value. 
int G_zero(void *buf, int i)
Zero out a buffer, buf, of length i. 
int gvl_isosurf_set_att_src(geovol_isosurf *isosurf, int desc, int src)
Set attribute source. 
geovol * gvl_get_last_vol(void)
Get last volume set from the list. 
geovol * gvl_get_new_vol(void)
Allocate new volume set and add it to the list. 
int Gvl_load_colors_data(void **color_data, const char *name)
Load color table. 
int gvl_slice_init(geovol_slice *slice)
Initialize geovol_slice struct. 
int gvl_isosurf_get_att_src(geovol_isosurf *isosurf, int desc)
Get attribute source. 
void print_vol_fields(geovol *gvl)
Debug volume fields. 
int gvl_file_newh(const char *name, IFLAG file_type)
Get handle for given file name and type. 
int gvl_isosurf_set_att_changed(geovol_isosurf *isosurf, int desc)
Set attribute changed. 
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_vol(int id)
Get volume set structure. 
geovol_slice * gvl_slice_get_slice(int id, int slice_id)
Get geovol_slice struct. 
int gvl_slice_freemem(geovol_slice *slice)
Free geovol_slice struct. 
int gvl_free_vol(geovol *fvl)
Free geovol struct. 
int gvl_get_xextents(geovol *gvl, float *min, float *max)
Get volume x-extent value. 
int gvl_file_free_datah(int id)
Free geovol_file structure for given handle. 
void gvl_free_volmem(geovol *fvl)
Free geovol struct memory. 
int gvl_get_zextents(geovol *gvl, float *min, float *max)
Get volume z-extent value. 
int gvl_isosurf_init(geovol_isosurf *isosurf)
Initialize geovol_isosurf struct. 
geovol_isosurf * gvl_isosurf_get_isosurf(int id, int isosurf_id)
Get isosurface of given volume set. 
int gvl_isosurf_set_att_const(geovol_isosurf *isosurf, int desc, float constant)
Set isosurface attribute constant. 
int gvl_get_yextents(geovol *gvl, float *min, float *max)
Get volume y-extent value. 
int gvl_isosurf_freemem(geovol_isosurf *isosurf)
Free geovol_isosurf struct. 
int G_debug(int level, const char *msg,...)
Print debugging message. 
void gvl_delete_vol(int id)
Remove volume set from list.