|
@@ -1,7 +1,7 @@
|
|
|
/*!
|
|
|
\file gvl.c
|
|
|
|
|
|
- \brief OGSF library - loading and manipulating volumes
|
|
|
+ \brief OGSF library - loading and manipulating volumes (lower level functions)
|
|
|
|
|
|
GRASS OpenGL gsurf OGSF Library
|
|
|
|
|
@@ -13,160 +13,175 @@
|
|
|
for details.
|
|
|
|
|
|
\author Bill Brown, UI-GMSL (May 1997)
|
|
|
- Tomas Paudits (February 2004)
|
|
|
+ \author Tomas Paudits (February 2004)
|
|
|
+ \author Doxygenized by Martin Landa <landa.martin gmail.com> (May 2008)
|
|
|
*/
|
|
|
|
|
|
-#include <stdio.h>
|
|
|
#include <stdlib.h>
|
|
|
+
|
|
|
+#include <grass/gis.h>
|
|
|
#include <grass/gstypes.h>
|
|
|
+
|
|
|
#include "gsget.h"
|
|
|
|
|
|
#define FIRST_VOL_ID 81721
|
|
|
|
|
|
static geovol *Vol_top = NULL;
|
|
|
|
|
|
-/***********************************************************************/
|
|
|
+/*!
|
|
|
+ \brief Get volume
|
|
|
+
|
|
|
+ \param id volume set id
|
|
|
+
|
|
|
+ \return pointer to geovol struct
|
|
|
+ \return NULL on failure
|
|
|
+*/
|
|
|
geovol *gvl_get_vol(int id)
|
|
|
{
|
|
|
geovol *gvl;
|
|
|
|
|
|
-#ifdef TRACE_FUNCS
|
|
|
- {
|
|
|
- Gs_status("gvl_get_vol");
|
|
|
- }
|
|
|
-#endif
|
|
|
+ G_debug (3, "gvl_get_vol");
|
|
|
|
|
|
for (gvl = Vol_top; gvl; gvl = gvl->next) {
|
|
|
- if (gvl->gvol_id == id) {
|
|
|
- return (gvl);
|
|
|
- }
|
|
|
+ if (gvl->gvol_id == id) {
|
|
|
+ return (gvl);
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
return (NULL);
|
|
|
}
|
|
|
|
|
|
-/***********************************************************************/
|
|
|
+/*!
|
|
|
+ \brief Get previous volume
|
|
|
+
|
|
|
+ \param id current volume set id
|
|
|
+
|
|
|
+ \return pointer to geovol struct
|
|
|
+ \return NULL on failure
|
|
|
+*/
|
|
|
geovol *gvl_get_prev_vol(int id)
|
|
|
{
|
|
|
geovol *pv;
|
|
|
|
|
|
-#ifdef TRACE_FUNCS
|
|
|
- {
|
|
|
- Gs_status("gvl_get_prev_vol");
|
|
|
- }
|
|
|
-#endif
|
|
|
+ G_debug (3, "gvl_get_prev_vol");
|
|
|
|
|
|
for (pv = Vol_top; pv; pv = pv->next) {
|
|
|
- if (pv->gvol_id == id - 1) {
|
|
|
- return (pv);
|
|
|
- }
|
|
|
+ if (pv->gvol_id == id - 1) {
|
|
|
+ return (pv);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
return (NULL);
|
|
|
}
|
|
|
|
|
|
-/***********************************************************************/
|
|
|
+/*!
|
|
|
+ \brief Get all volumes
|
|
|
+
|
|
|
+ \param[out] list of geovol structs
|
|
|
+
|
|
|
+ \return number of available volume sets
|
|
|
+*/
|
|
|
int gvl_getall_vols(geovol ** gvols)
|
|
|
{
|
|
|
geovol *gvl;
|
|
|
int i;
|
|
|
|
|
|
-#ifdef TRACE_FUNCS
|
|
|
- {
|
|
|
- Gs_status("gvl_getall_vols");
|
|
|
- }
|
|
|
-#endif
|
|
|
+ G_debug(3, "gvl_getall_vols");
|
|
|
|
|
|
for (i = 0, gvl = Vol_top; gvl; gvl = gvl->next, i++) {
|
|
|
- gvols[i] = gvl;
|
|
|
+ gvols[i] = gvl;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
return (i);
|
|
|
}
|
|
|
|
|
|
-/***********************************************************************/
|
|
|
+/*!
|
|
|
+ \brief Get number of registrated volume sets
|
|
|
+
|
|
|
+ \return number of volumes
|
|
|
+*/
|
|
|
int gvl_num_vols(void)
|
|
|
{
|
|
|
geovol *gvl;
|
|
|
int i;
|
|
|
|
|
|
-#ifdef TRACE_FUNCS
|
|
|
- {
|
|
|
- Gs_status("gvl_num_vols");
|
|
|
- }
|
|
|
-#endif
|
|
|
+ G_debug (3, "gvl_num_vols");
|
|
|
|
|
|
for (i = 0, gvl = Vol_top; gvl; gvl = gvl->next, i++);
|
|
|
|
|
|
return (i);
|
|
|
}
|
|
|
|
|
|
-/***********************************************************************/
|
|
|
+/*!
|
|
|
+ \brief Get last volume
|
|
|
+
|
|
|
+ \return pointer to geovol struct
|
|
|
+ \return NULL on failure
|
|
|
+*/
|
|
|
geovol *gvl_get_last_vol(void)
|
|
|
{
|
|
|
geovol *lvl;
|
|
|
|
|
|
-#ifdef TRACE_FUNCS
|
|
|
- {
|
|
|
- Gs_status("gvl_get_last_vol");
|
|
|
- }
|
|
|
-#endif
|
|
|
+ G_debug(3, "gvl_get_last_vol");
|
|
|
|
|
|
if (!Vol_top) {
|
|
|
- return (NULL);
|
|
|
+ return (NULL);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
for (lvl = Vol_top; lvl->next; lvl = lvl->next);
|
|
|
-
|
|
|
-#ifdef DEBUG
|
|
|
- {
|
|
|
- fprintf(stderr, "last vol id: %d\n", lvl->gvol_id);
|
|
|
- }
|
|
|
-#endif
|
|
|
+
|
|
|
+ G_debug (3, " last vol id: %d", lvl->gvol_id);
|
|
|
|
|
|
return (lvl);
|
|
|
}
|
|
|
|
|
|
-/***********************************************************************/
|
|
|
+/*!
|
|
|
+ \brief Allocate new volume set and add it to the list
|
|
|
+
|
|
|
+ \return pointer to new geovol struct
|
|
|
+ \return NULL on failure
|
|
|
+*/
|
|
|
geovol *gvl_get_new_vol(void)
|
|
|
{
|
|
|
geovol *nvl, *lvl;
|
|
|
|
|
|
-#ifdef TRACE_FUNCS
|
|
|
- {
|
|
|
- Gs_status("gvl_get_new_vol");
|
|
|
- }
|
|
|
-#endif
|
|
|
-
|
|
|
- if (NULL == (nvl = (geovol *) malloc(sizeof(geovol)))) {
|
|
|
- gs_err("gvl_get_new_vol");
|
|
|
+ G_debug(3, "gvl_get_new_vol");
|
|
|
|
|
|
+ nvl = (geovol *) G_malloc(sizeof(geovol)); /* G_fatal_error */
|
|
|
+ if (!nvl) {
|
|
|
return (NULL);
|
|
|
}
|
|
|
|
|
|
if ((lvl = gvl_get_last_vol())) {
|
|
|
- lvl->next = nvl;
|
|
|
- nvl->gvol_id = lvl->gvol_id + 1;
|
|
|
+ lvl->next = nvl;
|
|
|
+ nvl->gvol_id = lvl->gvol_id + 1;
|
|
|
}
|
|
|
else {
|
|
|
- Vol_top = nvl;
|
|
|
- nvl->gvol_id = FIRST_VOL_ID;
|
|
|
+ Vol_top = nvl;
|
|
|
+ nvl->gvol_id = FIRST_VOL_ID;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
nvl->next = NULL;
|
|
|
-
|
|
|
+
|
|
|
return (nvl);
|
|
|
}
|
|
|
|
|
|
-/***********************************************************************/
|
|
|
+/*!
|
|
|
+ \brief Initialize volume
|
|
|
+
|
|
|
+ \param gvl pointer to geovol struct
|
|
|
+ \param ox,oy,oz
|
|
|
+ \param rows number of rows
|
|
|
+ \param cols number of cols
|
|
|
+ \param xres,yres,zres x/y/z resolution value
|
|
|
+
|
|
|
+ \return -1 on failure
|
|
|
+ \return 1 on success
|
|
|
+*/
|
|
|
int gvl_init_vol(geovol * gvl, double ox, double oy, double oz,
|
|
|
int rows, int cols, int depths, double xres, double yres, double zres)
|
|
|
{
|
|
|
-#ifdef TRACE_FUNCS
|
|
|
- {
|
|
|
- Gs_status("gvl_init_vol");
|
|
|
- }
|
|
|
-#endif
|
|
|
+ G_debug(3, "gvl_init_vol");
|
|
|
|
|
|
if (!gvl) {
|
|
|
return (-1);
|
|
@@ -199,7 +214,7 @@ int gvl_init_vol(geovol * gvl, double ox, double oy, double oz,
|
|
|
gvl->isosurf_y_mod = 1;
|
|
|
gvl->isosurf_z_mod = 1;
|
|
|
|
|
|
- gvl->n_slices = 0;
|
|
|
+ gvl->n_slices = 0;
|
|
|
gvl->slice_x_mod = 1;
|
|
|
gvl->slice_y_mod = 1;
|
|
|
gvl->slice_z_mod = 1;
|
|
@@ -210,76 +225,83 @@ int gvl_init_vol(geovol * gvl, double ox, double oy, double oz,
|
|
|
return (1);
|
|
|
}
|
|
|
|
|
|
-/***********************************************************************/
|
|
|
+/*!
|
|
|
+ \brief Remove volume set from list
|
|
|
+
|
|
|
+ \param id volume set id
|
|
|
+*/
|
|
|
void gvl_delete_vol(int id)
|
|
|
{
|
|
|
geovol *fvl;
|
|
|
|
|
|
-#ifdef TRACE_FUNCS
|
|
|
- {
|
|
|
- Gs_status("gvl_delete_vol");
|
|
|
- }
|
|
|
-#endif
|
|
|
+ G_debug (3, "gvl_delete_vol");
|
|
|
|
|
|
fvl = gvl_get_vol(id);
|
|
|
-
|
|
|
+
|
|
|
if (fvl) {
|
|
|
- gvl_free_vol(fvl);
|
|
|
+ gvl_free_vol(fvl);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
-/***********************************************************************/
|
|
|
+/*!
|
|
|
+ \brief Free geovol struct
|
|
|
+
|
|
|
+ \param fvl pointer to geovol struct
|
|
|
+
|
|
|
+ \return -1 on failure
|
|
|
+ \return 1 on success
|
|
|
+*/
|
|
|
int gvl_free_vol(geovol * fvl)
|
|
|
{
|
|
|
geovol *gvl;
|
|
|
int found = 0;
|
|
|
|
|
|
-#ifdef TRACE_FUNCS
|
|
|
- {
|
|
|
- Gs_status("gvl_free_vol");
|
|
|
- }
|
|
|
-#endif
|
|
|
+ G_debug(3, "gvl_free_vol");
|
|
|
|
|
|
if (Vol_top) {
|
|
|
- if (fvl == Vol_top) {
|
|
|
- if (Vol_top->next) {
|
|
|
- /* can't free top if last */
|
|
|
- found = 1;
|
|
|
- Vol_top = fvl->next;
|
|
|
- }
|
|
|
- else {
|
|
|
- gvl_free_volmem(fvl);
|
|
|
- free(fvl);
|
|
|
- Vol_top = NULL;
|
|
|
- }
|
|
|
- }
|
|
|
- else {
|
|
|
- for (gvl = Vol_top; gvl && !found; gvl = gvl->next) {
|
|
|
- /* can't free top */
|
|
|
- if (gvl->next) {
|
|
|
- if (gvl->next == fvl) {
|
|
|
- found = 1;
|
|
|
- gvl->next = fvl->next;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if (found) {
|
|
|
- gvl_free_volmem(fvl);
|
|
|
- free(fvl);
|
|
|
- fvl = NULL;
|
|
|
- }
|
|
|
-
|
|
|
- return (1);
|
|
|
- }
|
|
|
-
|
|
|
+ if (fvl == Vol_top) {
|
|
|
+ if (Vol_top->next) {
|
|
|
+ /* can't free top if last */
|
|
|
+ found = 1;
|
|
|
+ Vol_top = fvl->next;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ gvl_free_volmem(fvl);
|
|
|
+ G_free(fvl);
|
|
|
+ Vol_top = NULL;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ for (gvl = Vol_top; gvl && !found; gvl = gvl->next) {
|
|
|
+ /* can't free top */
|
|
|
+ if (gvl->next) {
|
|
|
+ if (gvl->next == fvl) {
|
|
|
+ found = 1;
|
|
|
+ gvl->next = fvl->next;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (found) {
|
|
|
+ gvl_free_volmem(fvl);
|
|
|
+ G_free(fvl);
|
|
|
+ fvl = NULL;
|
|
|
+ }
|
|
|
+
|
|
|
+ return (1);
|
|
|
+ }
|
|
|
+
|
|
|
return (-1);
|
|
|
}
|
|
|
|
|
|
-/***********************************************************************/
|
|
|
+/*!
|
|
|
+ \brief Free geovol struct memory
|
|
|
+
|
|
|
+ \param fvl pointer to geovol struct
|
|
|
+*/
|
|
|
void gvl_free_volmem(geovol * fvl)
|
|
|
{
|
|
|
if (0 < fvl->hfile)
|
|
@@ -288,21 +310,33 @@ void gvl_free_volmem(geovol * fvl)
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
-/***********************************************************************/
|
|
|
+/*!
|
|
|
+ \brief Debug volume fields
|
|
|
+
|
|
|
+ \param gvl pointer to geovol struct
|
|
|
+*/
|
|
|
void print_vol_fields(geovol *gvl)
|
|
|
{
|
|
|
- fprintf(stderr, "ID: %d\n", gvl->gvol_id);
|
|
|
- fprintf(stderr, "cols: %d rows: %d depths: %d\n", gvl->cols, gvl->rows, gvl->depths);
|
|
|
- fprintf(stderr, "ox: %lf oy: %lf oz: %lf\n", gvl->ox, gvl->oy, gvl->oz);
|
|
|
- fprintf(stderr, "xres: %lf yres: %lf zres: %lf\n", gvl->xres, gvl->yres, gvl->zres);
|
|
|
- fprintf(stderr, "xmin: %f ymin: %f zmin: %f\n", gvl->xmin, gvl->ymin, gvl->zmin);
|
|
|
- fprintf(stderr, "xmax: %f ymax: %f zmax: %f\n", gvl->xmax, gvl->ymax, gvl->zmax);
|
|
|
- fprintf(stderr, "x_trans: %f y_trans: %f z_trans: %f\n", gvl->x_trans, gvl->y_trans, gvl->z_trans);
|
|
|
+ G_debug(4, "ID: %d", gvl->gvol_id);
|
|
|
+ G_debug(4, "cols: %d rows: %d depths: %d", gvl->cols, gvl->rows, gvl->depths);
|
|
|
+ G_debug(4, "ox: %lf oy: %lf oz: %lf", gvl->ox, gvl->oy, gvl->oz);
|
|
|
+ G_debug(4, "xres: %lf yres: %lf zres: %lf", gvl->xres, gvl->yres, gvl->zres);
|
|
|
+ G_debug(4, "xmin: %f ymin: %f zmin: %f", gvl->xmin, gvl->ymin, gvl->zmin);
|
|
|
+ G_debug(4, "xmax: %f ymax: %f zmax: %f", gvl->xmax, gvl->ymax, gvl->zmax);
|
|
|
+ G_debug(4, "x_trans: %f y_trans: %f z_trans: %f", gvl->x_trans, gvl->y_trans, gvl->z_trans);
|
|
|
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
-/***********************************************************************/
|
|
|
+/*!
|
|
|
+ \brief Get volume x-extent value
|
|
|
+
|
|
|
+ \param gvl pointer to geovol struct
|
|
|
+ \param[out] min x-min value
|
|
|
+ \param[out] max y-max value
|
|
|
+
|
|
|
+ \return 1
|
|
|
+*/
|
|
|
int gvl_get_xextents(geovol * gvl, float *min, float *max)
|
|
|
{
|
|
|
*min = gvl->xmin + gvl->x_trans;
|
|
@@ -311,7 +345,15 @@ int gvl_get_xextents(geovol * gvl, float *min, float *max)
|
|
|
return (1);
|
|
|
}
|
|
|
|
|
|
-/***********************************************************************/
|
|
|
+/*!
|
|
|
+ \brief Get volume y-extent value
|
|
|
+
|
|
|
+ \param gvl pointer to geovol struct
|
|
|
+ \param[out] min y-min value
|
|
|
+ \param[out] max y-max value
|
|
|
+
|
|
|
+ \return 1
|
|
|
+*/
|
|
|
int gvl_get_yextents(geovol * gvl, float *min, float *max)
|
|
|
{
|
|
|
*min = gvl->ymin + gvl->y_trans;
|
|
@@ -320,7 +362,15 @@ int gvl_get_yextents(geovol * gvl, float *min, float *max)
|
|
|
return (1);
|
|
|
}
|
|
|
|
|
|
-/***********************************************************************/
|
|
|
+/*!
|
|
|
+ \brief Get volume z-extent value
|
|
|
+
|
|
|
+ \param gvl pointer to geovol struct
|
|
|
+ \param[out] min z-min value
|
|
|
+ \param[out] max z-max value
|
|
|
+
|
|
|
+ \return 1
|
|
|
+*/
|
|
|
int gvl_get_zextents(geovol * gvl, float *min, float *max)
|
|
|
{
|
|
|
*min = gvl->zmin + gvl->z_trans;
|
|
@@ -329,7 +379,14 @@ int gvl_get_zextents(geovol * gvl, float *min, float *max)
|
|
|
return (1);
|
|
|
}
|
|
|
|
|
|
-/***********************************************************************/
|
|
|
+/*!
|
|
|
+ \brief Get volume x-range value
|
|
|
+
|
|
|
+ \param[out] min x-min value
|
|
|
+ \param[out] max x-max value
|
|
|
+
|
|
|
+ \return 1
|
|
|
+*/
|
|
|
int gvl_get_xrange(float *min, float *max)
|
|
|
{
|
|
|
geovol *gvl;
|
|
@@ -359,7 +416,14 @@ int gvl_get_xrange(float *min, float *max)
|
|
|
return (1);
|
|
|
}
|
|
|
|
|
|
-/***********************************************************************/
|
|
|
+/*!
|
|
|
+ \brief Get volume y-range value
|
|
|
+
|
|
|
+ \param[out] min y-min value
|
|
|
+ \param[out] max y-max value
|
|
|
+
|
|
|
+ \return 1
|
|
|
+*/
|
|
|
int gvl_get_yrange(float *min, float *max)
|
|
|
{
|
|
|
geovol *gvl;
|
|
@@ -389,7 +453,14 @@ int gvl_get_yrange(float *min, float *max)
|
|
|
return (1);
|
|
|
}
|
|
|
|
|
|
-/***********************************************************************/
|
|
|
+/*!
|
|
|
+ \brief Get volume z-range value
|
|
|
+
|
|
|
+ \param[out] min z-min value
|
|
|
+ \param[out] max z-max value
|
|
|
+
|
|
|
+ \return 1
|
|
|
+*/
|
|
|
int gvl_get_zrange(float *min, float *max)
|
|
|
{
|
|
|
geovol *gvl;
|
|
@@ -423,16 +494,19 @@ int gvl_get_zrange(float *min, float *max)
|
|
|
/* ISOSURFACES */
|
|
|
/************************************************************************/
|
|
|
|
|
|
-/************************************************************************/
|
|
|
+/*!
|
|
|
+ \brief Initialize geovol_isosurf struct
|
|
|
+
|
|
|
+ \param isosurf pointer to geovol_isosurf struct
|
|
|
+
|
|
|
+ \return -1 on failure
|
|
|
+ \return 1 on success
|
|
|
+*/
|
|
|
int gvl_isosurf_init(geovol_isosurf *isosurf)
|
|
|
{
|
|
|
int i;
|
|
|
|
|
|
-#ifdef TRACE_FUNCS
|
|
|
- {
|
|
|
- Gs_status("gvl_isosurf_init");
|
|
|
- }
|
|
|
-#endif
|
|
|
+ G_debug (3, "gvl_isosurf_init");
|
|
|
|
|
|
if (!isosurf)
|
|
|
return (-1);
|
|
@@ -444,23 +518,25 @@ int gvl_isosurf_init(geovol_isosurf *isosurf)
|
|
|
}
|
|
|
|
|
|
isosurf->data = NULL;
|
|
|
- isosurf->data_desc = 0;
|
|
|
+ isosurf->data_desc = 0;
|
|
|
isosurf->inout_mode = 0;
|
|
|
|
|
|
return (1);
|
|
|
}
|
|
|
|
|
|
+/*!
|
|
|
+ \brief Free geovol_isosurf struct
|
|
|
|
|
|
-/************************************************************************/
|
|
|
+ \param isosurf pointer to geovol_isosurf struct
|
|
|
+
|
|
|
+ \return -1 on failure
|
|
|
+ \return 1 on success
|
|
|
+*/
|
|
|
int gvl_isosurf_freemem(geovol_isosurf *isosurf)
|
|
|
{
|
|
|
int i;
|
|
|
|
|
|
-#ifdef TRACE_FUNCS
|
|
|
- {
|
|
|
- Gs_status("gvl_isosurf_freemem");
|
|
|
- }
|
|
|
-#endif
|
|
|
+ G_debug (3, "gvl_isosurf_freemem");
|
|
|
|
|
|
if (!isosurf)
|
|
|
return (-1);
|
|
@@ -469,12 +545,20 @@ int gvl_isosurf_freemem(geovol_isosurf *isosurf)
|
|
|
gvl_isosurf_set_att_src(isosurf, i, NOTSET_ATT);
|
|
|
}
|
|
|
|
|
|
- free(isosurf->data);
|
|
|
+ G_free(isosurf->data);
|
|
|
|
|
|
return (1);
|
|
|
}
|
|
|
|
|
|
-/***********************************************************************/
|
|
|
+/*!
|
|
|
+ \brief Get geovol_isosurf struct of given volume set
|
|
|
+
|
|
|
+ \param id volume set id
|
|
|
+ \param isosurf_id isosurface id
|
|
|
+
|
|
|
+ \return pointer to geovol_isosurf struct
|
|
|
+ \return NULL on failure
|
|
|
+*/
|
|
|
geovol_isosurf* gvl_isosurf_get_isosurf(int id, int isosurf_id)
|
|
|
{
|
|
|
geovol *gvl;
|
|
@@ -491,36 +575,43 @@ geovol_isosurf* gvl_isosurf_get_isosurf(int id, int isosurf_id)
|
|
|
return (NULL);
|
|
|
}
|
|
|
|
|
|
-/***********************************************************************/
|
|
|
+/*!
|
|
|
+ \brief Get attribute source
|
|
|
+
|
|
|
+ \param isosurf pointer to geovol_isosurf struct
|
|
|
+ \param desc attribute id
|
|
|
+
|
|
|
+ \return -1 on failure
|
|
|
+ \return attribute value
|
|
|
+*/
|
|
|
int gvl_isosurf_get_att_src(geovol_isosurf *isosurf, int desc)
|
|
|
{
|
|
|
-
|
|
|
-#ifdef TRACE_FUNCS
|
|
|
- {
|
|
|
- Gs_status("gvl_isosurf_get_att_src");
|
|
|
- }
|
|
|
-#endif
|
|
|
+ G_debug(3, "isosurf_get_att_src");
|
|
|
|
|
|
if (!LEGAL_ATT(desc)) {
|
|
|
- return (-1);
|
|
|
+ return (-1);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
if (isosurf) {
|
|
|
- return (isosurf->att[desc].att_src);
|
|
|
+ return (isosurf->att[desc].att_src);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
return (-1);
|
|
|
}
|
|
|
|
|
|
-/***********************************************************************/
|
|
|
+/*!
|
|
|
+ \brief Set attribute source
|
|
|
+
|
|
|
+ \param isosurf pointer to geovol_isosurf struct
|
|
|
+ \param desc attribute id
|
|
|
+ \param src attribute value
|
|
|
+
|
|
|
+ \return -1 on failure
|
|
|
+ \return 1 on success
|
|
|
+*/
|
|
|
int gvl_isosurf_set_att_src(geovol_isosurf *isosurf, int desc, int src)
|
|
|
{
|
|
|
-
|
|
|
-#ifdef TRACE_FUNCS
|
|
|
- {
|
|
|
- Gs_status("gvl_isosurf_set_att_src");
|
|
|
- }
|
|
|
-#endif
|
|
|
+ G_debug(3, "gvl_isosurf_set_att_src");
|
|
|
|
|
|
/* check if old source was MAP_ATT, deattach volfile */
|
|
|
if (MAP_ATT == gvl_isosurf_get_att_src(isosurf, desc)) {
|
|
@@ -529,92 +620,99 @@ int gvl_isosurf_set_att_src(geovol_isosurf *isosurf, int desc, int src)
|
|
|
if (desc == ATT_COLOR) {
|
|
|
Gvl_unload_colors_data(isosurf->att[desc].att_data);
|
|
|
}
|
|
|
- }
|
|
|
-
|
|
|
+ }
|
|
|
+
|
|
|
if (isosurf && LEGAL_SRC(src)) {
|
|
|
isosurf->att[desc].att_src = src;
|
|
|
- gvl_isosurf_set_att_changed(isosurf, desc);
|
|
|
-
|
|
|
+ gvl_isosurf_set_att_changed(isosurf, desc);
|
|
|
+
|
|
|
return (1);
|
|
|
}
|
|
|
|
|
|
return (-1);
|
|
|
}
|
|
|
|
|
|
-/***********************************************************************/
|
|
|
+/*!
|
|
|
+ \brief Set attribute constant
|
|
|
+
|
|
|
+ \param isosurf pointer to geovol_isosurf struct
|
|
|
+ \param desc attribute id
|
|
|
+ \param constant attribute value
|
|
|
+
|
|
|
+ \return -1 on failure
|
|
|
+ \return 1 on success
|
|
|
+*/
|
|
|
int gvl_isosurf_set_att_const(geovol_isosurf *isosurf, int desc, float constant)
|
|
|
{
|
|
|
-
|
|
|
-#ifdef TRACE_FUNCS
|
|
|
- {
|
|
|
- Gs_status("gvl_isosurf_set_att_const");
|
|
|
- }
|
|
|
-#endif
|
|
|
+ G_debug(3, "gvl_isosurf_set_att_const");
|
|
|
|
|
|
if (isosurf) {
|
|
|
- isosurf->att[desc].constant = constant;
|
|
|
-
|
|
|
- gvl_isosurf_set_att_src(isosurf, desc, CONST_ATT);
|
|
|
-
|
|
|
- return (1);
|
|
|
+ isosurf->att[desc].constant = constant;
|
|
|
+
|
|
|
+ gvl_isosurf_set_att_src(isosurf, desc, CONST_ATT);
|
|
|
+
|
|
|
+ return (1);
|
|
|
}
|
|
|
|
|
|
return (-1);
|
|
|
}
|
|
|
|
|
|
-/***********************************************************************/
|
|
|
+/*!
|
|
|
+ \brief Set attribute map
|
|
|
+
|
|
|
+ \param isosurf pointer to geovol_isosurf struct
|
|
|
+ \param desc attribute id
|
|
|
+ \param filename filename
|
|
|
+
|
|
|
+ \return -1 on failure
|
|
|
+ \return 1 on success
|
|
|
+*/
|
|
|
int gvl_isosurf_set_att_map(geovol_isosurf *isosurf, int desc, char *filename)
|
|
|
{
|
|
|
int hfile;
|
|
|
|
|
|
-#ifdef TRACE_FUNCS
|
|
|
- {
|
|
|
- Gs_status("gvl_isosurf_set_att_map");
|
|
|
- }
|
|
|
-#endif
|
|
|
-
|
|
|
-#ifdef DEBUG_MSG
|
|
|
- {
|
|
|
- fprintf(stderr, "att_map: %s\n", filename);
|
|
|
- }
|
|
|
-#endif
|
|
|
+ G_debug(3, "gvl_isosurf_set_att_map(): att_map: %s", filename);
|
|
|
|
|
|
if (isosurf) {
|
|
|
- if (0 > (hfile = gvl_file_newh(filename, VOL_FTYPE_G3D)))
|
|
|
- return (-1);
|
|
|
-
|
|
|
- gvl_isosurf_set_att_src(isosurf, desc, MAP_ATT);
|
|
|
-
|
|
|
- isosurf->att[desc].hfile = hfile;
|
|
|
-
|
|
|
- if (ATT_COLOR == desc) {
|
|
|
- Gvl_load_colors_data(&(isosurf->att[desc].att_data), filename);
|
|
|
- }
|
|
|
- return (1);
|
|
|
- }
|
|
|
-
|
|
|
+ if (0 > (hfile = gvl_file_newh(filename, VOL_FTYPE_G3D)))
|
|
|
+ return (-1);
|
|
|
+
|
|
|
+ gvl_isosurf_set_att_src(isosurf, desc, MAP_ATT);
|
|
|
+
|
|
|
+ isosurf->att[desc].hfile = hfile;
|
|
|
+
|
|
|
+ if (ATT_COLOR == desc) {
|
|
|
+ Gvl_load_colors_data(&(isosurf->att[desc].att_data), filename);
|
|
|
+ }
|
|
|
+ return (1);
|
|
|
+ }
|
|
|
+
|
|
|
return (-1);
|
|
|
}
|
|
|
|
|
|
-/***********************************************************************/
|
|
|
+/*!
|
|
|
+ \brief Set attribute changed
|
|
|
+
|
|
|
+ \param isosurf pointer to geovol_isosurf struct
|
|
|
+ \param desc attribute id
|
|
|
+
|
|
|
+ \return -1 on failure
|
|
|
+ \return 1 on success
|
|
|
+*/
|
|
|
int gvl_isosurf_set_att_changed(geovol_isosurf *isosurf, int desc)
|
|
|
{
|
|
|
- int i;
|
|
|
+ int i;
|
|
|
|
|
|
-#ifdef TRACE_FUNCS
|
|
|
- {
|
|
|
- Gs_status("gvl_isosurf_set_att_changed");
|
|
|
- }
|
|
|
-#endif
|
|
|
+ G_debug(3, "gvl_isosurf_set_att_changed");
|
|
|
|
|
|
if (isosurf && LEGAL_ATT(desc)) {
|
|
|
isosurf->att[desc].changed = 1;
|
|
|
-
|
|
|
- if ((desc == ATT_TOPO) || (desc == ATT_MASK)) {
|
|
|
- for (i = 1; i < MAX_ATTS; i++)
|
|
|
- isosurf->att[i].changed = 1;
|
|
|
- }
|
|
|
-
|
|
|
+
|
|
|
+ if ((desc == ATT_TOPO) || (desc == ATT_MASK)) {
|
|
|
+ for (i = 1; i < MAX_ATTS; i++)
|
|
|
+ isosurf->att[i].changed = 1;
|
|
|
+ }
|
|
|
+
|
|
|
return (1);
|
|
|
}
|
|
|
|
|
@@ -625,47 +723,61 @@ int gvl_isosurf_set_att_changed(geovol_isosurf *isosurf, int desc)
|
|
|
/* SLICES */
|
|
|
/************************************************************************/
|
|
|
|
|
|
-/************************************************************************/
|
|
|
+/*!
|
|
|
+ \brief Initialize geovol_slice struct
|
|
|
+
|
|
|
+ \param slice pointer to geovol_slice struct
|
|
|
+
|
|
|
+ \return -1 on failure
|
|
|
+ \return 1 on success
|
|
|
+*/
|
|
|
int gvl_slice_init(geovol_slice *slice)
|
|
|
{
|
|
|
-#ifdef TRACE_FUNCS
|
|
|
- {
|
|
|
- Gs_status("gvl_slice_init");
|
|
|
- }
|
|
|
-#endif
|
|
|
+ G_debug(3, "gvl_slice_init");
|
|
|
|
|
|
if (!slice)
|
|
|
return (-1);
|
|
|
|
|
|
slice->data = NULL;
|
|
|
- slice->changed = 0;
|
|
|
- slice->mode = 1;
|
|
|
- slice->transp = 0;
|
|
|
-
|
|
|
- slice->z1 = 0;
|
|
|
- slice->z2 = 99;
|
|
|
-
|
|
|
+ slice->changed = 0;
|
|
|
+ slice->mode = 1;
|
|
|
+ slice->transp = 0;
|
|
|
+
|
|
|
+ slice->z1 = 0;
|
|
|
+ slice->z2 = 99;
|
|
|
+
|
|
|
return (1);
|
|
|
}
|
|
|
|
|
|
-/************************************************************************/
|
|
|
+/*!
|
|
|
+ \brief Free geovol_slice struct
|
|
|
+
|
|
|
+ \param slice pointer to geovol_slice struct
|
|
|
+
|
|
|
+ \return -1 on failure
|
|
|
+ \return 1 on success
|
|
|
+*/
|
|
|
int gvl_slice_freemem(geovol_slice *slice)
|
|
|
{
|
|
|
-#ifdef TRACE_FUNCS
|
|
|
- {
|
|
|
- Gs_status("gvl_slice_freemem");
|
|
|
- }
|
|
|
-#endif
|
|
|
+ G_debug(3, "gvl_slice_freemem");
|
|
|
|
|
|
if (!slice)
|
|
|
return (-1);
|
|
|
|
|
|
- free(slice->data);
|
|
|
+ G_free(slice->data);
|
|
|
|
|
|
return (1);
|
|
|
}
|
|
|
|
|
|
-/***********************************************************************/
|
|
|
+/*!
|
|
|
+ \brief Get geovol_slice struct
|
|
|
+
|
|
|
+ \param id volume set id
|
|
|
+ \param slice_id slice id
|
|
|
+
|
|
|
+ \return pointer to geovol_slice struct
|
|
|
+ \return NULL on failure
|
|
|
+*/
|
|
|
geovol_slice* gvl_slice_get_slice(int id, int slice_id)
|
|
|
{
|
|
|
geovol *gvl;
|
|
@@ -675,7 +787,7 @@ geovol_slice* gvl_slice_get_slice(int id, int slice_id)
|
|
|
if (gvl) {
|
|
|
if ((slice_id < 0) || (slice_id > (gvl->n_slices - 1)))
|
|
|
return (NULL);
|
|
|
-
|
|
|
+
|
|
|
return gvl->slice[slice_id];
|
|
|
}
|
|
|
|