[GRASS-SVN] r31356 - grass/trunk/lib/ogsf
svn_grass at osgeo.org
svn_grass at osgeo.org
Thu May 15 12:34:04 EDT 2008
Author: martinl
Date: 2008-05-15 12:34:04 -0400 (Thu, 15 May 2008)
New Revision: 31356
Modified:
grass/trunk/lib/ogsf/gs_query.c
grass/trunk/lib/ogsf/gsget.c
grass/trunk/lib/ogsf/gvl.c
grass/trunk/lib/ogsf/gvl_calc.c
grass/trunk/lib/ogsf/gvl_calc2.c
grass/trunk/lib/ogsf/gvl_file.c
grass/trunk/lib/ogsf/gvld.c
Log:
ogsflib: initial doxygen strings
fprintf -> G_m/w/e/d
minor indentation fixes
[sync'ed with devbr6]
Modified: grass/trunk/lib/ogsf/gs_query.c
===================================================================
--- grass/trunk/lib/ogsf/gs_query.c 2008-05-15 16:32:49 UTC (rev 31355)
+++ grass/trunk/lib/ogsf/gs_query.c 2008-05-15 16:34:04 UTC (rev 31356)
@@ -1,7 +1,7 @@
/*!
\file gs_query.c
- \brief OGSF library -
+ \brief OGSF library - query (lower level functions)
GRASS OpenGL gsurf OGSF Library
@@ -13,16 +13,18 @@
for details.
\author Bill Brown USACERL (January 1994)
+ \author Doxygenized by Martin Landa <landa.martin gmail.com> (May 2008)
*/
#include <math.h>
-#include <stdio.h>
+#include <grass/gis.h>
#include <grass/gstypes.h>
-/* Values needed for Ray-Convex Polyhedron Intersection Test below
- * originally by Eric Haines, erich at eye.com
- */
+/*!
+ \brief Values needed for Ray-Convex Polyhedron Intersection Test below
+ originally by Eric Haines, erich at eye.com
+*/
#ifndef HUGE_VAL
#define HUGE_VAL 1.7976931348623157e+308
#endif
@@ -33,11 +35,20 @@
#define BACKFACE -1
/* end Ray-Convex Polyhedron Intersection Test values */
-/***********************************************************************/
-/* Crude method of intersecting line of sight with closest part of surface.
- Uses los vector to determine the point of first intersection
- which is returned in point. Returns 0 if los doesn't intersect. */
-/* los should ALREADY be in surf-world coordinates */
+
+/*!
+ \biref Crude method of intersecting line of sight with closest part of surface.
+
+ Uses los vector to determine the point of first intersection
+ which is returned in point. Returns 0 if los doesn't intersect.
+
+ \param surfid surface id
+ \param los should be in surf-world coordinates
+ \param[out] point intersect point (real)
+
+ \return 0 on failure
+ \return 1 on success
+*/
int gs_los_intersect1(int surfid, float (*los)[3], float *point)
{
float dx, dy, dz, u_d[3];
@@ -47,6 +58,8 @@
geosurf *gs;
typbuff *buf;
+ G_debug (3, "gs_los_intersect1():");
+
if (NULL == (gs = gs_get_surf(surfid))) {
return (0);
}
@@ -149,7 +162,7 @@
}
if ((edge) && (b[Z] - (a[Z] + dz * 2.0) > incr * u_d[Z])) {
- fprintf(stderr, "looking under surface\n");
+ G_debug (3, " looking under surface");
return 0;
}
@@ -161,10 +174,19 @@
return (1);
}
-/*
- * This version uses the shadow of the los projected down to
- * the surface to generate a line_on_surf, then follows each
- * point in that line until the los intersects it.
+/*!
+ \biref Crude method of intersecting line of sight with closest part of surface.
+
+ This version uses the shadow of the los projected down to
+ the surface to generate a line_on_surf, then follows each
+ point in that line until the los intersects it.
+
+ \param surfid surface id
+ \param los should be in surf-world coordinates
+ \param[out] point intersect point (real)
+
+ \return 0 on failure
+ \return 1 on success
*/
int gs_los_intersect(int surfid, float **los, float *point)
{
@@ -177,6 +199,8 @@
typbuff *buf;
Point3 *points;
+ G_debug (3, "gs_los_intersect");
+
if (NULL == (gs = gs_get_surf(surfid))) {
return (0);
}
@@ -200,41 +224,40 @@
points = gsdrape_get_allsegments(gs, bgn, end, &num);
/* DEBUG
-{
-float t1[3], t2[3];
-
-t1[X] = los[FROM][X] ;
-t1[Y] = los[FROM][Y] ;
-
-t2[X] = los[TO][X] ;
-t2[Y] = los[TO][Y] ;
-
-GS_set_draw(GSD_FRONT);
-gsd_pushmatrix();
-gsd_do_scale(1);
-gsd_translate(gs->x_trans, gs->y_trans, gs->z_trans);
-gsd_linewidth(1);
-gsd_color_func(GS_default_draw_color());
-gsd_line_onsurf(gs, t1, t2);
-gsd_popmatrix();
-GS_set_draw(GSD_BACK);
-gsd_flush();
-}
-fprintf(stderr,"%d points to check\n", num);
-fprintf(stderr,"point0 = %.6lf %.6lf %.6lf FT =%.6lf %.6lf %.6lf\n",
+ {
+ float t1[3], t2[3];
+
+ t1[X] = los[FROM][X] ;
+ t1[Y] = los[FROM][Y] ;
+
+ t2[X] = los[TO][X] ;
+ t2[Y] = los[TO][Y] ;
+
+ GS_set_draw(GSD_FRONT);
+ gsd_pushmatrix();
+ gsd_do_scale(1);
+ gsd_translate(gs->x_trans, gs->y_trans, gs->z_trans);
+ gsd_linewidth(1);
+ gsd_color_func(GS_default_draw_color());
+ gsd_line_onsurf(gs, t1, t2);
+ gsd_popmatrix();
+ GS_set_draw(GSD_BACK);
+ gsd_flush();
+ }
+ fprintf(stderr,"%d points to check\n", num);
+ fprintf(stderr,"point0 = %.6lf %.6lf %.6lf FT =%.6lf %.6lf %.6lf\n",
points[0][X],points[0][Y],points[0][Z],
los[FROM][X],los[FROM][Y],los[FROM][Z]);
-fprintf(stderr,"incr1 = %.6lf: %.6lf %.6lf %.6lf\n",incr,u_d[X],u_d[Y],u_d[Z]);
-fprintf(stderr,"first point below surf\n");
-fprintf(stderr,"incr2 = %f\n", (float)incr);
-fprintf(stderr,"(%d/%d) %f > %f\n", i,num, a[Z], points[i][Z]);
-fprintf(stderr,"incr3 = %f\n", (float)incr);
-fprintf(stderr,"all points above surf\n");
+ fprintf(stderr,"incr1 = %.6lf: %.6lf %.6lf %.6lf\n",incr,u_d[X],u_d[Y],u_d[Z]);
+ fprintf(stderr,"first point below surf\n");
+ fprintf(stderr,"incr2 = %f\n", (float)incr);
+ fprintf(stderr,"(%d/%d) %f > %f\n", i,num, a[Z], points[i][Z]);
+ fprintf(stderr,"incr3 = %f\n", (float)incr);
+ fprintf(stderr,"all points above surf\n");
*/
if (num < 2) {
- fprintf(stderr, "-----------------------------\n");
- fprintf(stderr, "%d points to check\n", num);
+ G_debug (3, " %d points to check", num);
return (0);
}
@@ -255,16 +278,16 @@
}
/* DEBUG
-fprintf(stderr,"-----------------------------\n");
-fprintf(stderr,"%d points to check\n", num);
-fprintf(stderr,"incr1 = %.6lf: %.9f %.9f %.9f\n",incr,u_d[X],u_d[Y],u_d[Z]);
-fprintf(stderr,
-"\tpoint0 = %.6f %.6f %.6f\n\tFT = %.6f %.6f %.6f\n\tpoint%d = %.6f %.6f\n",
- points[0][X],points[0][Y],points[0][Z],
- los[FROM][X],los[FROM][Y],los[FROM][Z],
- num-1, points[num-1][X],points[num-1][Y]);
+ fprintf(stderr,"-----------------------------\n");
+ fprintf(stderr,"%d points to check\n", num);
+ fprintf(stderr,"incr1 = %.6lf: %.9f %.9f %.9f\n",incr,u_d[X],u_d[Y],u_d[Z]);
+ fprintf(stderr,
+ "\tpoint0 = %.6f %.6f %.6f\n\tFT = %.6f %.6f %.6f\n\tpoint%d = %.6f %.6f\n",
+ points[0][X],points[0][Y],points[0][Z],
+ los[FROM][X],los[FROM][Y],los[FROM][Z],
+ num-1, points[num-1][X],points[num-1][Y]);
*/
-
+
/* This should bring us right above (or below) the first point */
a[X] = los[FROM][X] + incr * u_d[X] - gs->x_trans;
a[Y] = los[FROM][Y] + incr * u_d[Y] - gs->y_trans;
@@ -274,14 +297,14 @@
/* viewing from below surface */
/* don't use this method */
/* DEBUG
-fprintf(stderr,"first point below surf\n");
-fprintf(stderr,"aZ= %.6f point0 = %.6f %.6f %.6f FT =%.6f %.6f %.6f\n",
- a[Z], points[0][X],points[0][Y],points[0][Z],
- los[FROM][X],los[FROM][Y],los[FROM][Z]);
+ fprintf(stderr,"first point below surf\n");
+ fprintf(stderr,"aZ= %.6f point0 = %.6f %.6f %.6f FT =%.6f %.6f %.6f\n",
+ a[Z], points[0][X],points[0][Y],points[0][Z],
+ los[FROM][X],los[FROM][Y],los[FROM][Z]);
*/
return (0);
}
-
+
GS_v3eq(a1, a);
GS_v3eq(b, a);
@@ -327,34 +350,36 @@
return (1);
}
- fprintf(stderr, "line of sight error %d\n", ret);
-
+ G_debug (3, " line of sight error %d", ret);
+
return 0;
}
-
+
/* over surface */
return 0;
}
-/***********************************************************************/
-/* Ray-Convex Polyhedron Intersection Test
- * originally by Eric Haines, erich at eye.com
- *
- * This test checks the ray against each face of a polyhedron, checking whether
- * the set of intersection points found for each ray-plane intersection
- * overlaps the previous intersection results. If there is no overlap (i.e.
- * no line segment along the ray that is inside the polyhedron), then the
- * ray misses and returns 0; else 1 is returned if the ray is entering the
- * polyhedron, -1 if the ray originates inside the polyhedron. If there is
- * an intersection, the distance and the nunber of the face hit is returned.
- *
- * org, dir origin and direction of ray
- * tmax maximum useful distance along ray
- * phdrn[] list of planes in convex polyhedron
- * ph_num number of planes in convex polyhedron
- * *tresult returned: distance of intersection along ray
- * *pn returned: number of face hit (0 to ph_num-1)
- *
+/*!
+ \brief Ray-Convex Polyhedron Intersection Test
+
+ Originally by Eric Haines, erich at eye.com
+
+ This test checks the ray against each face of a polyhedron, checking whether
+ the set of intersection points found for each ray-plane intersection
+ overlaps the previous intersection results. If there is no overlap (i.e.
+ no line segment along the ray that is inside the polyhedron), then the
+ ray misses and returns 0; else 1 is returned if the ray is entering the
+ polyhedron, -1 if the ray originates inside the polyhedron. If there is
+ an intersection, the distance and the nunber of the face hit is returned.
+
+ \param org,dir origin and direction of ray
+ \param tmax maximum useful distance along ray
+ \param phdrn list of planes in convex polyhedron
+ \param ph_num number of planes in convex polyhedron
+ \param[out] tresult distance of intersection along ray
+ \param[out] pn number of face hit (0 to ph_num-1)
+
+ \return FACE code
*/
int RayCvxPolyhedronInt(Point3 org, Point3 dir, double tmax, Point4 * phdrn,
int ph_num, double *tresult, int *pn)
@@ -436,7 +461,11 @@
}
}
-/***********************************************************************/
+/*!
+ \brief Get data bounds for plane
+
+ \param[out] planes
+*/
void gs_get_databounds_planes(Point4 * planes)
{
float n, s, w, e, b, t;
@@ -486,10 +515,16 @@
return;
}
-/***********************************************************************/
-/* Gets all current cutting planes & data bounding planes, intersects
- los with resulting convex polyhedron, then replaces los[FROM] with
- first point on ray inside data.
+/*!
+ Gets all current cutting planes & data bounding planes
+
+ Intersects los with resulting convex polyhedron, then replaces los[FROM] with
+ first point on ray inside data.
+
+ \param[out] los
+
+ \return 0 on failure
+ \return 1 on success
*/
int gs_setlos_enterdata(Point3 * los)
{
Modified: grass/trunk/lib/ogsf/gsget.c
===================================================================
--- grass/trunk/lib/ogsf/gsget.c 2008-05-15 16:32:49 UTC (rev 31355)
+++ grass/trunk/lib/ogsf/gsget.c 2008-05-15 16:34:04 UTC (rev 31356)
@@ -1,7 +1,7 @@
/*!
\file gsd_get.c
- \brief OGSF library -
+ \brief OGSF library - get map attribute (lower level functions)
GRASS OpenGL gsurf OGSF Library
@@ -13,10 +13,21 @@
for details.
\author Bill Brown USACERL (January 1993)
+ \author Doxygenized by Martin Landa <landa.martin gmail.com> (May 2008)
*/
#include <grass/gstypes.h>
+/*!
+ \brief Get map attributes
+
+ \param buff
+ \param offset
+ \param[out] att
+
+ \return 0 on failure
+ \return 1 on success
+*/
int get_mapatt(typbuff * buff, int offset, float *att)
{
if (buff->nm) {
Modified: grass/trunk/lib/ogsf/gvl.c
===================================================================
--- grass/trunk/lib/ogsf/gvl.c 2008-05-15 16:32:49 UTC (rev 31355)
+++ grass/trunk/lib/ogsf/gvl.c 2008-05-15 16:34:04 UTC (rev 31356)
@@ -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);
+
+ G_debug (3, " last vol id: %d", lvl->gvol_id);
-#ifdef DEBUG
- {
- fprintf(stderr, "last vol id: %d\n", lvl->gvol_id);
- }
-#endif
-
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
+ G_debug(3, "gvl_get_new_vol");
- if (NULL == (nvl = (geovol *) malloc(sizeof(geovol)))) {
- gs_err("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 @@
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 @@
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;
- }
+ 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);
}
- 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);
- }
-
+
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
/* 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 @@
}
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 @@
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,37 +575,44 @@
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)
{
+ G_debug(3, "isosurf_get_att_src");
-#ifdef TRACE_FUNCS
- {
- Gs_status("gvl_isosurf_get_att_src");
- }
-#endif
-
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)
{
+ G_debug(3, "gvl_isosurf_set_att_src");
-#ifdef TRACE_FUNCS
- {
- Gs_status("gvl_isosurf_set_att_src");
- }
-#endif
-
/* check if old source was MAP_ATT, deattach volfile */
if (MAP_ATT == gvl_isosurf_get_att_src(isosurf, desc)) {
gvl_file_free_datah(isosurf->att[desc].hfile);
@@ -529,92 +620,99 @@
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)
{
+ G_debug(3, "gvl_isosurf_set_att_const");
-#ifdef TRACE_FUNCS
- {
- Gs_status("gvl_isosurf_set_att_const");
- }
-#endif
-
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
+ G_debug(3, "gvl_isosurf_set_att_map(): att_map: %s", filename);
-#ifdef DEBUG_MSG
- {
- fprintf(stderr, "att_map: %s\n", filename);
- }
-#endif
-
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);
+ 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);
- }
-
+
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 @@
/* 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 @@
if (gvl) {
if ((slice_id < 0) || (slice_id > (gvl->n_slices - 1)))
return (NULL);
-
+
return gvl->slice[slice_id];
}
Modified: grass/trunk/lib/ogsf/gvl_calc.c
===================================================================
--- grass/trunk/lib/ogsf/gvl_calc.c 2008-05-15 16:32:49 UTC (rev 31355)
+++ grass/trunk/lib/ogsf/gvl_calc.c 2008-05-15 16:34:04 UTC (rev 31356)
@@ -1,7 +1,7 @@
/*!
\file gvl_calc.c
- \brief OGSF library - loading and manipulating volumes
+ \brief OGSF library - loading and manipulating volumes (lower level functions)
GRASS OpenGL gsurf OGSF Library
@@ -13,9 +13,9 @@
for details.
\author Tomas Paudits (February 2004)
+ \author Doxygenized by Martin Landa <landa.martin gmail.com> (May 2008)
*/
-#include <stdio.h>
#include <math.h>
#include <grass/gis.h>
@@ -24,7 +24,9 @@
#include "rgbpack.h"
#include "mc33_table.h"
-/* memory buffer for writing */
+/*!
+ \brief memory buffer for writing
+*/
#define BUFFER_SIZE 1000000
/* USEFUL MACROS */
@@ -43,12 +45,16 @@
#define FOR_VAR i_for
#define FOR_0_TO_N(n, cmd) { int FOR_VAR; for (FOR_VAR = 0; FOR_VAR < n; FOR_VAR++) {cmd;} }
-/* writing and reading isosurface data */
+/*!
+ \brief writing and reading isosurface data
+*/
#define WRITE(c) gvl_write_char(dbuff->ndx_new++, &(dbuff->new), c)
#define READ() gvl_read_char(dbuff->ndx_old++, dbuff->old)
#define SKIP(n) dbuff->ndx_old = dbuff->ndx_old + n
-/* check and set data descriptor */
+/*!
+ \brief check and set data descriptor
+*/
#define IS_IN_DATA(att) ((isosurf->data_desc >> att) & 1)
#define SET_IN_DATA(att) isosurf->data_desc = (isosurf->data_desc | (1 << att))
@@ -70,10 +76,12 @@
/************************************************************************/
/* ISOSURFACES */
-/************************************************************************/
+/*!
+ \brief Write cube index
-/************************************************************************/
-/* write cube index */
+ \param ndx
+ \param dbuff
+*/
void iso_w_cndx(int ndx, data_buffer * dbuff)
{
/* cube don't contains polys */
@@ -104,8 +112,11 @@
}
}
-/************************************************************************/
-/* read cube index */
+/*!
+ \brief Read cube index
+
+ \param dbuff
+*/
int iso_r_cndx(data_buffer * dbuff)
{
int ndx, ndx2;
@@ -130,8 +141,17 @@
return ndx;
}
-/************************************************************************/
-/* get value from data input */
+/*!
+ \brief Get value from data input
+
+ \param isosurf
+ \param desc
+ \param x,y,z
+ \param[out] value
+
+ \return 0
+ \return ?
+*/
int iso_get_cube_value(geovol_isosurf * isosurf, int desc, int x, int y, int z,
float *v)
{
@@ -175,16 +195,30 @@
return ret;
}
-/************************************************************************/
-/* get volume file values range */
+/*!
+ \brief Get volume file values range
+
+ \param isosurf
+ \param desc
+ \param[out] min
+ \param[out] max
+*/
void iso_get_range(geovol_isosurf * isosurf, int desc, double *min, double *max)
{
gvl_file_get_min_max(gvl_file_get_volfile(isosurf->att[desc].hfile), min,
max);
}
-/************************************************************************/
-/* read values for cube */
+/*!
+ \brief Read values for cube
+
+ \param isosurf
+ \param desc
+ \param x,y,z
+ \param[out] v
+
+ \return
+*/
int iso_get_cube_values(geovol_isosurf * isosurf, int desc, int x, int y, int z,
float *v)
{
@@ -201,8 +235,13 @@
return ret;
}
-/************************************************************************/
-/* calc cube grads */
+/*!
+ \brief Calculate cube grads
+
+ \param isosurf
+ \param x,y,z
+ \param grad
+*/
void iso_get_cube_grads(geovol_isosurf * isosurf, int x, int y, int z,
float (*grad)[3])
{
@@ -273,8 +312,13 @@
}
}
-/************************************************************************/
-/* process cube */
+/*!
+ \brief Process cube
+
+ \param isosurf
+ \param x,y,z
+ \param dbuff
+*/
void iso_calc_cube(geovol_isosurf * isosurf, int x, int y, int z,
data_buffer * dbuff)
{
@@ -526,8 +570,13 @@
}
}
-/************************************************************************/
-/* fill data structure with computed isosurfaces polygons */
+/*!
+ \brief Fill data structure with computed isosurfaces polygons
+
+ \param gvol pointer to geovol struct
+
+ \return 1
+*/
int gvl_isosurf_calc(geovol * gvol)
{
int x, y, z;
@@ -665,51 +714,60 @@
return (1);
}
-/************************************************************************/
+/*!
+ \brief ADD
+
+ \param pos
+ \param data
+ \param c
+*/
void gvl_write_char(int pos, unsigned char **data, unsigned char c)
{
/* check to need allocation memory */
if ((pos % BUFFER_SIZE) == 0) {
- if ((*data =
- (char *)G_realloc(*data,
- sizeof(char) * ((pos / BUFFER_SIZE) +
- 1) * BUFFER_SIZE)) == NULL) {
- gs_err("can't malloc");
+ *data = (char *) G_realloc(*data,
+ sizeof(char) * ((pos / BUFFER_SIZE) +
+ 1) * BUFFER_SIZE);
+ if (!(*data)) {
return;
}
-
-#ifdef DEBUG
- {
- fprintf(stderr, "reallocate memory for pos : %d to : %d B\n", pos,
- sizeof(char) * ((pos / BUFFER_SIZE) + 1) * BUFFER_SIZE);
- }
-#endif
-
+
+ G_debug (3, "gvl_write_char(): reallocate memory for pos : %d to : %d B", pos,
+ sizeof(char) * ((pos / BUFFER_SIZE) + 1) * BUFFER_SIZE);
}
-
+
(*data)[pos] = c;
}
-/************************************************************************/
+/*!
+ \brief Read char
+
+ \param pos position index
+ \param data data buffer
+
+ \param char
+*/
unsigned char gvl_read_char(int pos, unsigned char *data)
{
return data[pos];
}
-/************************************************************************/
+/*!
+ \brief Append data to buffer
+
+ \param pos position index
+ \param data data buffer
+*/
void gvl_align_data(int pos, unsigned char *data)
{
/* realloc memory to fit in data length */
- if ((data = (char *)G_realloc(data, sizeof(char) * pos)) == NULL) {
- gs_err("can't malloc");
+ data = (char *) G_realloc(data, sizeof(char) * pos); /* G_fatal_error */
+ if (!data) {
return;
}
-#ifdef DEBUG
- {
- fprintf(stderr, "reallocate memory finally to : %d B\n", pos);
- }
-#endif
+ G_debug(3, "gvl_align_data(): reallocate memory finally to : %d B", pos);
+
return;
}
@@ -723,8 +781,14 @@
#define SLICE_MODE_INTERP_NO 0
#define SLICE_MODE_INTERP_YES 1
-/************************************************************************/
-/* get value from geovol file */
+/*!
+ \brief Get volume value
+
+ \param gvl pointer to geovol struct
+ \param x,y,z
+
+ \return value
+*/
float slice_get_value(geovol * gvl, int x, int y, int z)
{
static double d;
@@ -755,7 +819,15 @@
return value;
}
-/************************************************************************/
+/*!
+ \brief Calculate slices
+
+ \param gvl pointer to geovol struct
+ \param ndx_slc
+ \param colors
+
+ \return 1
+*/
int slice_calc(geovol * gvl, int ndx_slc, void *colors)
{
int cols, rows, c, r;
@@ -929,7 +1001,13 @@
return (1);
}
-/************************************************************************/
+/*!
+ \brief Calculate slices
+
+ \param gvol pointer to geovol struct
+
+ \return 1
+*/
int gvl_slices_calc(geovol * gvol)
{
int i;
Modified: grass/trunk/lib/ogsf/gvl_calc2.c
===================================================================
--- grass/trunk/lib/ogsf/gvl_calc2.c 2008-05-15 16:32:49 UTC (rev 31355)
+++ grass/trunk/lib/ogsf/gvl_calc2.c 2008-05-15 16:34:04 UTC (rev 31356)
@@ -1,7 +1,7 @@
/*!
\file gvl_calc2.c
- \brief OGSF library - loading and manipulating volumes
+ \brief OGSF library - loading and manipulating volumes, MarchingCubes 33 Algorithm (lower level functions)
GRASS OpenGL gsurf OGSF Library
@@ -16,6 +16,7 @@
for details.
\author Tomas Paudits, 2004
+ \author Doxygenized by Martin Landa <landa.martin gmail.com> (May 2008)
*/
#include <float.h>
@@ -27,7 +28,14 @@
unsigned char m_case, m_config, m_subconfig;
-/************************************************************************/
+/*!
+ \brief ADD
+
+ \param face
+ \param v
+
+ \return
+*/
int mc33_test_face( char face , float *v)
{
float A,B,C,D ;
@@ -72,7 +80,14 @@
return face * A * ( A*C - B*D ) >= 0;
}
-/************************************************************************/
+/*!
+ \brief ADD
+
+ \param s
+ \param v
+
+ \return
+*/
int mc33_test_interior( char s, float *v)
{
float t, At = 0, Bt = 0, Ct = 0, Dt = 0, a, b ;
@@ -242,7 +257,14 @@
return s < 0;
}
-/************************************************************************/
+/*!
+ \brief ADD
+
+ \param c_ndx
+ \param v
+
+ \return
+*/
int mc33_process_cube(int c_ndx, float *v)
{
m_case = cases[c_ndx][0] ;
Modified: grass/trunk/lib/ogsf/gvl_file.c
===================================================================
--- grass/trunk/lib/ogsf/gvl_file.c 2008-05-15 16:32:49 UTC (rev 31355)
+++ grass/trunk/lib/ogsf/gvl_file.c 2008-05-15 16:34:04 UTC (rev 31356)
@@ -1,7 +1,7 @@
/*!
\file gvl_file.c
- \brief OGSF library - loading and manipulating volumes
+ \brief OGSF library - loading and manipulating volumes (lower level functions)
GRASS OpenGL gsurf OGSF Library
@@ -11,12 +11,15 @@
GNU General Public License (>=v2).
Read the file COPYING that comes with GRASS
for details.
+
+ \author Tomas Paudits (February 2004)
+ \author Doxygenized by Martin Landa <landa.martin gmail.com> (May 2008)
*/
-#include <stdio.h>
#include <string.h>
#include <stdlib.h>
+#include <grass/gis.h>
#include <grass/gstypes.h>
#include <grass/gsurf.h>
#include <grass/G3d.h>
@@ -34,7 +37,9 @@
#define STATUS_READY 0
#define STATUS_BUSY 1
-/* structure for slice mode reading from volume file*/
+/*!
+ \brief structure for slice mode reading from volume file
+*/
typedef struct
{
int num, skip;
@@ -57,126 +62,174 @@
void *open_g3d_file(char *, IFLAG *, double *, double *);
int close_g3d_file(void *);
-/******************************************************************/
-/* initialize */
+/*!
+ \brief Initialize volume files
+
+ \return 1
+*/
static int init_volfiles(void)
{
int i;
G3D_Region *w3;
-
+
for (i = 0; i < MAX_VOL_FILES; i++) {
- /* avoiding dynamic allocation */
- Data[i] = &(Df[i]);
+ /* avoiding dynamic allocation */
+ Data[i] = &(Df[i]);
}
-
+
Cur_max = MAX_VOL_FILES;
-
+
/* get window */
w3 = GVL_get_window();
-
+
/* set cols, rows, depths from window */
Cols = w3->cols;
Rows = w3->rows;
Depths = w3->depths;
-
+
return (1);
}
-/******************************************************************/
-/* check number of files */
+/*!
+ \brief Check number of files
+
+ \return 0
+*/
static int check_num_volfiles(void)
{
if (Numfiles < Cur_max) {
- return (0);
+ return (0);
}
+
+ G_fatal_error (_("Maximum number of datafiles exceeded"));
- fprintf(stderr, "maximum number of datafiles exceeded\n");
-
- exit(0);
-
/* This return statement keeps compilers happy, it is never executed */
return (0);
}
-/******************************************************************/
-/* get geovol_file structure for given handle */
+/*!
+ \brief Get geovol_file structure for given handle
+
+ \param id
+
+ \return pointer to geovol_file struct
+ \return NULL on failure
+*/
geovol_file *gvl_file_get_volfile(int id)
{
int i;
-
+
for (i = 0; i < Numfiles; i++) {
- if (Data[i]->data_id == id) {
- return (Data[i]);
+ if (Data[i]->data_id == id) {
+ return (Data[i]);
+ }
}
- }
-
+
return (NULL);
}
-/******************************************************************/
-/* find file with name and type in geovol_file array an return handle*/
+/*!
+ \brief Find file with name and type in geovol_file array an return handle
+
+ \param name file name
+ \para begin
+
+ \param data id
+ \param -1 not found
+*/
int find_datah(char *name, IFLAG type, int begin)
{
static int i;
int start;
-
+
start = begin ? 0 : i + 1;
-
+
for (i = start; i < Numfiles; i++) {
- if (!strcmp(Data[i]->file_name, name)) {
- if (Data[i]->file_type == type) {
- return (Data[i]->data_id);
- }
+ if (!strcmp(Data[i]->file_name, name)) {
+ if (Data[i]->file_type == type) {
+ return (Data[i]->data_id);
+ }
+ }
}
- }
-
+
return (-1);
}
-/******************************************************************/
-/* return file name for given handle */
+/*!
+ \brief Get file name for given handle
+
+ \param id handle id
+
+ \return file name
+ \return NULL on failure
+*/
char *gvl_file_get_name(int id)
{
int i;
geovol_file *fvf;
static char retstr[NAME_SIZ];
-
+
for (i = 0; i < Numfiles; i++) {
- if (Data[i]->data_id == id) {
- fvf = Data[i];
- strcpy(retstr, fvf->file_name);
-
- return (retstr);
+ if (Data[i]->data_id == id) {
+ fvf = Data[i];
+ strcpy(retstr, fvf->file_name);
+
+ return (retstr);
+ }
}
- }
-
+
return (NULL);
}
-/******************************************************************/
-/* return file type for given handle */
+/*!
+ \brief Get file type for given handle
+
+ \param vf pointer to geovol_file struct
+
+ \return file type
+*/
int gvl_file_get_file_type(geovol_file *vf)
{
return (vf->file_type);
}
-/******************************************************************/
-/* return data type for given handle */
+/*!
+ \brief Get data type for given handle
+
+ \param vf pointer to geovol_file struct
+
+ \return data type
+*/
int gvl_file_get_data_type(geovol_file *vf)
{
return (vf->data_type);
}
-/******************************************************************/
-/* return minimum and maximum value in volume file */
+/*!
+ \brief Get minimum and maximum value in volume file
+
+ \param vf pointer to geovol_file struct
+ \param[out] min min value
+ \param[out] max max value
+*/
void gvl_file_get_min_max(geovol_file *vf, double *min, double *max)
{
*min = vf->min;
*max = vf->max;
}
-/******************************************************************/
-/* open volume file */
+/*!
+ \brief Open volume file
+
+ \param name file name
+ \param file_type file type
+ \param data_type data type
+ \param[out] min min value
+ \param[out] max max value
+
+ \return pointer to file
+ \return NULL on failure
+*/
void *open_volfile(char *name, IFLAG file_type, IFLAG *data_type, double *min, double *max)
{
if (file_type == VOL_FTYPE_G3D) {
@@ -186,8 +239,15 @@
return (NULL);
}
-/******************************************************************/
-/* close volume file */
+/*!
+ \brief Close volume file
+
+ \param map volume filename
+ \param type file type
+
+ \return
+ \return -1 on failure
+*/
int close_volfile(void *map, IFLAG type)
{
if (type == VOL_FTYPE_G3D) {
@@ -197,8 +257,15 @@
return (-1);
}
-/******************************************************************/
-/* get handle for given file name and type */
+/*!
+ \brief Get handle for given file name and type
+
+ \param name volume filename
+ \param file_type file type
+
+ \return data id
+ \return -1 on failure
+*/
int gvl_file_newh(char *name, IFLAG file_type)
{
geovol_file *new;
@@ -209,116 +276,122 @@
double min, max;
if (first) {
- if (0 > init_volfiles()) {
- return (-1);
+ if (0 > init_volfiles()) {
+ return (-1);
+ }
+
+ first = 0;
}
-
- first = 0;
- }
-
+
if ( 0 <= (id = find_datah(name, file_type, 1))) {
for (i = 0; i < Numfiles; i++) {
- if (Data[i]->data_id == id) {
- new = Data[i];
- new->count++;
-
- return (id);
+ if (Data[i]->data_id == id) {
+ new = Data[i];
+ new->count++;
+
+ return (id);
+ }
}
- }
}
-
+
if (0 > check_num_volfiles()) {
- return (-1);
+ return (-1);
}
if (!name) {
- return (-1);
+ return (-1);
}
-
+
if ((m = open_volfile(name, file_type, &data_type, &min, &max)) == NULL) {
- return (-1);
+ return (-1);
}
-
+
new = Data[Numfiles];
-
+
if (new) {
- Numfiles++;
- new->data_id = Cur_id++;
-
- strcpy(new->file_name, name);
- new->file_type = file_type;
- new->count = 1;
- new->map = m;
- new->min = min;
- new->max = max;
- new->data_type = data_type;
-
- new->status = STATUS_READY;
- new->buff = NULL;
-
+ Numfiles++;
+ new->data_id = Cur_id++;
+
+ strcpy(new->file_name, name);
+ new->file_type = file_type;
+ new->count = 1;
+ new->map = m;
+ new->min = min;
+ new->max = max;
+ new->data_type = data_type;
+
+ new->status = STATUS_READY;
+ new->buff = NULL;
+
new->mode = 255;
gvl_file_set_mode(new, MODE_DEFAULT);
-
- return (new->data_id);
+
+ return (new->data_id);
}
-
+
return (-1);
}
-/******************************************************************/
-/* free allocated buffers */
+/*!
+ \brief Free allocated buffers
+
+ \param vf pointer to geovol_file struct
+
+ \return 1
+*/
int free_volfile_buffs(geovol_file * vf)
{
if (vf->mode == MODE_SLICE) {
- free(vf->buff);
+ G_free(vf->buff);
vf->buff = NULL;
}
-
- if (vf->mode == MODE_PRELOAD) {
- free(vf->buff);
- vf->buff = NULL;
+
+ if (vf->mode == MODE_PRELOAD) {
+ G_free(vf->buff);
+ vf->buff = NULL;
}
-
+
return (1);
}
-/******************************************************************/
-/* free geovol_file structure for given handle */
+/*!
+ \brief Free geovol_file structure for given handle
+
+ \param id
+
+ \return
+*/
int gvl_file_free_datah(int id)
{
int i, j, found = -1;
geovol_file *fvf;
-#ifdef TRACE_FUNCS
- {
- fprintf(stderr, "gvl_file_free_datah\n");
- }
-#endif
+ G_debug (3, "gvl_file_free_datah");
for (i = 0; i < Numfiles; i++) {
- if (Data[i]->data_id == id) {
- found = 1;
- fvf = Data[i];
-
- if (fvf->count > 1) {
- fvf->count--;
- } else {
- close_volfile(fvf->map, fvf->file_type);
- free_volfile_buffs(fvf);
- strcpy(fvf->file_name, "");
- fvf->data_id = 0;
-
- for (j = i; j < (Numfiles - 1); j++) {
- Data[j] = Data[j + 1];
- }
-
- Data[j] = fvf;
-
- --Numfiles;
- }
+ if (Data[i]->data_id == id) {
+ found = 1;
+ fvf = Data[i];
+
+ if (fvf->count > 1) {
+ fvf->count--;
+ } else {
+ close_volfile(fvf->map, fvf->file_type);
+ free_volfile_buffs(fvf);
+ strcpy(fvf->file_name, "");
+ fvf->data_id = 0;
+
+ for (j = i; j < (Numfiles - 1); j++) {
+ Data[j] = Data[j + 1];
+ }
+
+ Data[j] = fvf;
+
+ --Numfiles;
+ }
+ }
}
- }
-
+
return (found);
}
@@ -326,8 +399,16 @@
/* reading from G3D raster volume files */
/******************************************************************/
-/******************************************************************/
-/* open g3d file */
+/*!
+ \brief Open g3d file
+
+ \param filename file name
+ \param type data type
+ \param[out] min min value
+ \param[out] max max value
+
+ \pointer to data
+*/
void *open_g3d_file(char *filename, IFLAG *type, double *min, double *max)
{
char *mapset;
@@ -335,80 +416,100 @@
void *map;
/* search for g3d file a return his mapset */
- if (NULL == (mapset = G_find_grid3(filename,""))) {
+ mapset = G_find_grid3(filename, "");
+ if (!mapset) {
G_warning (_("3D raster map <%s> not found"),
filename);
return (NULL);
}
/* open g3d file */
- if (NULL == (map = G3d_openCellOld(filename, mapset, G3D_DEFAULT_WINDOW, G3D_TILE_SAME_AS_FILE, G3D_USE_CACHE_DEFAULT))) {
-#ifdef DEBUG_MSG
- fprintf(stderr, "error opening grid3 file : %s\n", filename);
-#endif
+ map = G3d_openCellOld(filename, mapset, G3D_DEFAULT_WINDOW, G3D_TILE_SAME_AS_FILE, G3D_USE_CACHE_DEFAULT);
+ if (!map) {
+ G_warning (_("Unable to open 3D raster map <%s>"), filename);
return (NULL);
}
/* load range into range structure of map */
if (!G3d_range_load(map)) {
-#ifdef DEBUG_MSG
- fprintf(stderr, "error reading range for file : %s\n", filename);
-#endif
+ G_warning ("Unable to read range of 3D raster map <%s>", filename);
return (NULL);
}
G3d_range_min_max(map, min, max);
-
+
/* get file data type */
itype = G3d_fileTypeMap(map);
if (itype == FCELL_TYPE)
*type = VOL_DTYPE_FLOAT;
if (itype == DCELL_TYPE)
*type = VOL_DTYPE_DOUBLE;
-
+
return (map);
}
-/******************************************************************/
-/* close g3d file */
+/*!
+ \brief Close g3d file
+
+ \param map 3d raster map
+
+ \return -1 on failure
+ \return 1 on success
+*/
int close_g3d_file(void *map)
{
/* close opened g3d file */
- if (G3d_closeCell(map) != 1) {
-#ifdef DEBUG_MSG
- fprintf(stderr, "error closing grid3 file");
-#endif
- return (-1);
+ if (G3d_closeCell((G3D_Map *)map) != 1) {
+ G_warning (_("Unable to close 3D raster map <%s>"), ((G3D_Map *)map)->fileName);
+ return (-1);
}
-
+
return (1);
}
-/******************************************************************/
-/* read value from g3d file */
+/*!
+ \brief Eead value from g3d file
+
+ \param type data type
+ \param map 3D raster map
+ \param x,y,z real coordinates
+ \param[out] value data value
+
+ \return -1 on failure
+ \return 1 on success
+*/
int read_g3d_value(IFLAG type, void *map, int x, int y, int z, void *value)
{
switch (type) {
/* float data type */
- case (VOL_DTYPE_FLOAT) :
- *((float *)value) = G3d_getFloat(map, x, y, z);
- break;
-
+ case (VOL_DTYPE_FLOAT) :
+ *((float *)value) = G3d_getFloat(map, x, y, z);
+ break;
+
/* double data type */
- case (VOL_DTYPE_DOUBLE) :
- *((double *)value) = G3d_getDouble(map, x, y, z);
- break;
-
+ case (VOL_DTYPE_DOUBLE) :
+ *((double *)value) = G3d_getDouble(map, x, y, z);
+ break;
+
/* unsupported data type */
- default :
- return (-1);
+ default :
+ return (-1);
}
-
+
return (1);
}
-/******************************************************************/
-/* read slice of values at level from g3d file */
+/*!
+ \brief Read slice of values at level from g3d file
+
+ \param type data type
+ \param map 3D raster map
+ \param level
+ \param[out] data
+
+ \return -1 on failure
+ \return 0 on success
+*/
int read_g3d_slice(IFLAG type, void *map, int level, void *data)
{
int x, y;
@@ -444,8 +545,16 @@
return (1);
}
-/******************************************************************/
-/* read all values from g3d file */
+/*!
+ \brief Read all values from g3d file
+
+ \param type data type
+ \param map 3D raster map
+ \param[out] data data buffer
+
+ \return -1 on failure
+ \return 1 on success
+*/
int read_g3d_vol(IFLAG type, void *map, void *data)
{
int x, y, z;
@@ -485,7 +594,16 @@
return (1);
}
-/******************************************************************/
+/*!
+ \brief Check for null value
+
+ \param type data type
+ \param value
+
+ \return 1 if value is null
+ \return 0 if value is not null
+ \return -1 on failure (unsupported data type
+*/
int is_null_g3d_value(IFLAG type, void *value)
{
switch (type) {
@@ -503,14 +621,25 @@
default :
return (-1);
}
+
+ return (-1);
}
/******************************************************************/
/* reading from buffer */
/******************************************************************/
-/******************************************************************/
-/* get value from buffer */
+/*!
+ \brief Get value from buffer
+
+ \param type data type
+ \param data data buffer
+ \param offset
+ \param value
+
+ \return -1 on failure (unsupported data type)
+ \return 1 on success
+*/
int get_buff_value(IFLAG type, void *data, int offset, void *value)
{
switch (type) {
@@ -536,8 +665,16 @@
/* direct mode reading from volume file */
/******************************************************************/
-/******************************************************************/
-/* read value direct from volume file */
+/*!
+ \brief Read value direct from volume file
+
+ \param vf pointer to geovol_file struct
+ \param x,y,z real point
+ \oaram[out] value data value
+
+ \return -1 on failure
+ \return 1 on success
+*/
int get_direct_value(geovol_file *vf, int x, int y, int z, void *value)
{
switch (vf->file_type) {
@@ -558,20 +695,26 @@
/* full mode reading from volume file */
/******************************************************************/
-/******************************************************************/
-/* allocate buffer memory for full mode reading */
+/*!
+ \brief Allocate buffer memory for full mode reading
+
+ \param vf pointer to geovol_file
+
+ \return -1 on failure
+ \return 1 on success
+*/
int alloc_vol_buff(geovol_file *vf)
{
switch (vf->data_type) {
/* float data type */
case (VOL_DTYPE_FLOAT) :
- if ((vf->buff = (float*) malloc(sizeof(float) * Cols * Rows * Depths)) == NULL)
+ if ((vf->buff = (float*) G_malloc(sizeof(float) * Cols * Rows * Depths)) == NULL)
return (-1);
break;
/* double data type */
case (VOL_DTYPE_DOUBLE) :
- if ((vf->buff = (double*) malloc(sizeof(double) * Cols * Rows * Depths)) == NULL)
+ if ((vf->buff = (double*) G_malloc(sizeof(double) * Cols * Rows * Depths)) == NULL)
return (-1);
break;
@@ -583,17 +726,28 @@
return (1);
}
-/******************************************************************/
-/* free memory buffer memory */
+/*!
+ \brief Free memory buffer memory
+
+ \param vf pointer to geovol_file struct
+
+ \return 1
+*/
int free_vol_buff(geovol_file *vf)
{
- free(vf->buff);
+ G_free(vf->buff);
return (1);
}
-/******************************************************************/
-/* read all values from volume file */
+/*!
+ \brief Read all values from volume file
+
+ \param vf pointer to geovol_file struct
+
+ \return -1 on failure
+ \return 1 on success
+*/
int read_vol(geovol_file *vf)
{
switch (vf->file_type) {
@@ -610,8 +764,15 @@
return (1);
}
-/******************************************************************/
-/* get value from volume buffer */
+/*!
+ \brief Get value from volume buffer
+
+ \param vf pointer to geovol_file struct
+ \param x,y,z real point
+ \param[out] value data value
+
+ \return 1
+*/
int get_vol_value(geovol_file *vf, int x, int y, int z, void *value)
{
get_buff_value(vf->data_type, vf->buff, z * Rows * Cols + y * Cols + x, value);
@@ -623,8 +784,14 @@
/* slice mode reading from volume file */
/******************************************************************/
-/******************************************************************/
-/* allocate buffer for slice mode reading */
+/*!
+ \brief Allocate buffer for slice mode reading
+
+ \param vf pointer to geovol_file struct
+
+ \return -1 on failure
+ \return 1 on success
+*/
int alloc_slice_buff(geovol_file *vf)
{
int i;
@@ -634,7 +801,7 @@
/* float data type */
case (VOL_DTYPE_FLOAT) :
for (i = 0; i < sd->num; i++) {
- if ((sd->slice[i] = (float*) malloc(sizeof(float) * Cols * Rows)) == NULL)
+ if ((sd->slice[i] = (float*) G_malloc(sizeof(float) * Cols * Rows)) == NULL)
return (-1);
}
break;
@@ -642,7 +809,7 @@
/* double data type */
case (VOL_DTYPE_DOUBLE) :
for (i = 0; i < sd->num; i++) {
- if ((sd->slice[i] = (double*) malloc(sizeof(double) * Cols * Rows)) == NULL)
+ if ((sd->slice[i] = (double*) G_malloc(sizeof(double) * Cols * Rows)) == NULL)
return (-1);
}
break;
@@ -655,22 +822,35 @@
return (1);
}
-/******************************************************************/
-/* free buffer for slice mode reading */
+/*!
+ \brief Free buffer for slice mode reading
+
+ \param vf pointer to geovol_file struct
+
+ \return 1
+*/
int free_slice_buff(geovol_file *vf)
{
int i;
slice_data *sd = (slice_data *) vf->buff;
for (i = 0; i < sd->num; i++) {
- free(sd->slice[i]);
+ G_free(sd->slice[i]);
}
return (1);
}
-/******************************************************************/
-/* read slice of values at level from volume file */
+/*!
+ \brief Read slice of values at level from volume file
+
+ \param vf pointer to geovol_file struct
+ \param s
+ \param l
+
+ \return -1 on failure
+ \return 1 on success
+*/
int read_slice(geovol_file *vf, int s, int l)
{
/* get slice structure */
@@ -680,7 +860,7 @@
/* G3D file format */
case (VOL_FTYPE_G3D) :
if (0 > read_g3d_slice(vf->data_type, vf->map, l, sd->slice[s]))
- return (-1);
+ return (-1);
break;
/* unsupported file format */
default :
@@ -690,8 +870,11 @@
return (1);
}
-/******************************************************************/
-/* read new slice into buffer */
+/*!
+ \brief Read new slice into buffer
+
+ \param vf pointer to geovol_file struct
+*/
void shift_slices(geovol_file *vf)
{
void *tmp;
@@ -713,8 +896,16 @@
sd->crnt++;
}
-/******************************************************************/
-/* get value from slice buffer */
+/*!
+ \brief Get value from slice buffer
+
+ \param vf pointer to geovol_file struct
+ \param x,y,z real point
+ \param[out] value data value
+
+ \return -1 on failure
+ \return 1 on success
+*/
int get_slice_value(geovol_file *vf, int x, int y, int z, void *value)
{
slice_data *sd = (slice_data *) vf->buff;
@@ -744,8 +935,14 @@
/* reading from volume file */
/******************************************************************/
-/******************************************************************/
-/* start read - allocate memory buffer a read first data into buffer */
+/*!
+ \brief Start read - allocate memory buffer a read first data into buffer
+
+ \param vf pointer to geovol_file struct
+
+ \return -1 on failure
+ \return 1 on success
+*/
int gvl_file_start_read(geovol_file *vf)
{
int i;
@@ -789,8 +986,14 @@
return (1);
}
-/******************************************************************/
-/* end read - free buffer memory */
+/*!
+ \brief End read - free buffer memory
+
+ \param vf pointer to geovol_file struct
+
+ \return -1 on failure
+ \return 1 on success
+*/
int gvl_file_end_read(geovol_file *vf)
{
/* check status */
@@ -815,8 +1018,14 @@
return (1);
}
-/******************************************************************/
-/* get value for volume file at x, y, z */
+/*!
+ \brief Get value for volume file at x, y, z
+
+ \param vf pointer to geovol_file struct
+
+ \return -1 on failure
+ \return 1 on success
+*/
int gvl_file_get_value(geovol_file *vf, int x, int y, int z, void *value)
{
/* check status */
@@ -845,7 +1054,15 @@
return (1);
}
-/******************************************************************/
+/*!
+ \brief Check for null value
+
+ \param vf pointer to geovol_file struct
+ \param value data value
+
+ \return -1 on failure
+ \return 1 on success
+*/
int gvl_file_is_null_value(geovol_file *vf, void *value)
{
switch (vf->file_type) {
@@ -857,57 +1074,73 @@
default :
return (-1);
}
+
+ return (-1);
}
/******************************************************************/
/* set parameters for reading volumes */
/******************************************************************/
-/******************************************************************/
-/* set read mode */
+/*!
+ \brief Set read mode
+
+ \param vf pointer to geovol_file struct
+ \param mode
+
+ \return -1 on failure
+ \return 1 on success
+*/
int gvl_file_set_mode(geovol_file *vf, IFLAG mode)
{
slice_data *sd;
-
+
if (vf->status == STATUS_BUSY)
return (-1);
-
+
if (vf->mode == mode)
return (1);
-
+
if (vf->mode == MODE_SLICE)
- free(vf->buff);
-
- if (vf->mode == MODE_PRELOAD)
- free(vf->buff);
-
-
- if (mode == MODE_SLICE) {
- if ((vf->buff = (slice_data *) malloc(sizeof(slice_data))) == NULL)
- return (-1);
-
- sd = (slice_data *) vf->buff;
- sd->num = 1;
- sd->crnt = 0;
- sd->base = 1;
+ G_free(vf->buff);
+
+ if (vf->mode == MODE_PRELOAD)
+ G_free(vf->buff);
+
+ if (mode == MODE_SLICE) {
+ if ((vf->buff = (slice_data *) G_malloc(sizeof(slice_data))) == NULL)
+ return (-1);
+
+ sd = (slice_data *) vf->buff;
+ sd->num = 1;
+ sd->crnt = 0;
+ sd->base = 1;
}
-
- if (mode == MODE_PRELOAD) {
- /* allocate memory */
- if (0 > alloc_vol_buff(vf))
- return (-1);
-
- /* read volume */
- read_vol(vf);
- }
-
+
+ if (mode == MODE_PRELOAD) {
+ /* allocate memory */
+ if (0 > alloc_vol_buff(vf))
+ return (-1);
+
+ /* read volume */
+ read_vol(vf);
+ }
+
vf->mode = mode;
return (1);
}
-/******************************************************************/
-/* set parameters for slice reading */
+/*!
+ \brief Set parameters for slice reading
+
+ \param vf pointer to geovol_file struct
+ \param n
+ \param b
+
+ \return -1 on failure
+ \return 1 on success
+*/
int gvl_file_set_slices_param(geovol_file *vf, int n, int b)
{
slice_data *sd;
@@ -924,4 +1157,3 @@
return (1);
}
-
Modified: grass/trunk/lib/ogsf/gvld.c
===================================================================
--- grass/trunk/lib/ogsf/gvld.c 2008-05-15 16:32:49 UTC (rev 31355)
+++ grass/trunk/lib/ogsf/gvld.c 2008-05-15 16:34:04 UTC (rev 31356)
@@ -1,7 +1,7 @@
/*!
\file gvld.c
- \brief OGSF library - loading and manipulating volumes
+ \brief OGSF library - loading and manipulating volumes (lower level functions)
GRASS OpenGL gsurf OGSF Library
@@ -13,26 +13,30 @@
for details.
\author Tomas Paudits (February 2004)
+ \author Doxygenized by Martin Landa <landa.martin gmail.com> (May 2008)
*/
-#include <stdio.h>
#include <math.h>
#include <grass/gis.h>
#include <grass/gstypes.h>
+
#include "mc33_table.h"
/* usefull macros */
#define READ() gvl_read_char(pos[i]++, gvl->isosurf[i]->data)
-/************************************************************************/
+/*!
+ \brief ADD
+
+ \param gvl pointer to geovol struct
+
+ \return -1 on failure
+ \return 1 on success
+*/
int gvld_vol(geovol * gvl)
{
-#ifdef TRACE_DFUNCS
- {
- Gs_status("gvld_vol");
- }
-#endif
+ G_debug(3, "gvld_vol");
/* SLICES */
/* calculate slices data, if slices changed */
@@ -53,14 +57,17 @@
return (1);
}
-/************************************************************************/
+/*!
+ \brief ADD
+
+ \param gvl pointer to geovol struct
+
+ \return -1 on failure
+ \return 1 on success
+*/
int gvld_wire_vol(geovol * gvl)
{
-#ifdef TRACE_DFUNCS
- {
- Gs_status("gvld_vol");
- }
-#endif
+ G_debug(3, "gvld_vol");
gvld_wind3_box(gvl);
@@ -73,7 +80,14 @@
return (1);
}
-/************************************************************************/
+/*!
+ \brief ADD
+
+ \param gvl pointer to geovol struct
+
+ \return -1 on failure
+ \return 1 on success
+*/
int gvld_isosurf(geovol * gvl)
{
float tx, ty, tz;
@@ -118,21 +132,12 @@
nz = G_malloc(n_i * sizeof(int));
e_dl = G_malloc(n_i * sizeof(int));
-#ifdef TRACE_DFUNCS
- {
- Gs_status("gvld_isosurf");
+ G_debug(3, "gvld_isosurf():");
+ for (i = 0; i < gvl->n_isosurfs; i++) {
+ G_debug(4, " start : gvl: %s isosurf : %d\n",
+ gvl_file_get_name(gvl->hfile), i);
}
-#endif
-
-#ifdef DEBUG
- {
- for (i = 0; i < gvl->n_isosurfs; i++) {
- fprintf(stderr, "start : gvl: %s isosurf : %d\n",
- gvl_file_get_name(gvl->hfile), i);
- }
- }
-#endif
-
+
/* shade */
gsd_shademodel(gvl->isosurf_draw_mode & DM_GOURAUD);
@@ -233,24 +238,17 @@
nz[i] = 0;
}
-#ifdef DEBUG
- {
- fprintf(stderr, "intialize OK\n", gvl_file_get_name(gvl->hfile), i);
- }
-#endif
+ G_debug (3, " intialize OK", gvl_file_get_name(gvl->hfile), i);
for (z = 0; z < depths - 1; z++) {
zc = z * zres;
if (GS_check_cancel()) {
-#ifdef DEBUG
- {
- for (i = 0; i < gvl->n_isosurfs; i++) {
- fprintf(stderr, "break : isosurf : %d datalength : %d B\n",
- i, pos[i]);
- }
+ for (i = 0; i < gvl->n_isosurfs; i++) {
+ G_debug(4, " break : isosurf : %d datalength : %d B\n",
+ i, pos[i]);
}
-#endif
+
gsd_set_material(1, 1, 0., 0., 0x0);
gsd_popmatrix();
gsd_blend(0);
@@ -387,14 +385,10 @@
}
-#ifdef DEBUG
- {
- for (i = 0; i < gvl->n_isosurfs; i++) {
- fprintf(stderr, "end : isosurf : %d datalength : %d B\n", i,
- pos[i]);
- }
+ for (i = 0; i < gvl->n_isosurfs; i++) {
+ G_debug(4, " end : isosurf : %d datalength : %d B\n", i,
+ pos[i]);
}
-#endif
gsd_set_material(1, 1, 0., 0., 0x0);
gsd_popmatrix();
@@ -404,7 +398,13 @@
return (0);
}
-/************************************************************************/
+/*!
+ \brief ADD
+
+ \param gvl pointer to geovol struct
+
+ \return 0
+*/
int gvld_wire_isosurf(geovol * gvl)
{
return (0);
@@ -417,9 +417,13 @@
#define DISTANCE_2(x1, y1, x2, y2) sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2))
-/* draw slices */
+/*!
+ \brief Draw slices
-/************************************************************************/
+ \param gvl pointer to geovol struct
+
+ \return 0
+*/
int gvld_slices(geovol * gvl)
{
float tx, ty, tz;
@@ -429,11 +433,7 @@
GLint viewport[4];
GLint window[4];
-#ifdef TRACE_DFUNCS
- {
- Gs_status("gvld_slices");
- }
-#endif
+ G_debug(3, "gvld_slices");
/* shade */
gsd_shademodel(gvl->slice_draw_mode & DM_GOURAUD);
@@ -473,9 +473,14 @@
return (0);
}
-/* draw slice */
+/*!
+ \brief Draw slice
-/************************************************************************/
+ \param gvl pointer to geovol struct
+ \param ndx
+
+ \return 1
+*/
int gvld_slice(geovol * gvl, int ndx)
{
geovol_slice *slice;
@@ -647,8 +652,13 @@
return (1);
}
-/************************************************************************/
-/* draw wire slices */
+/*!
+ \brief Draw wire slices
+
+ \param gvl pointer to geovol struct
+
+ \return 0
+*/
int gvld_wire_slices(geovol * gvl)
{
float pt[3];
@@ -657,11 +667,7 @@
geovol_slice *slice;
-#ifdef TRACE_DFUNCS
- {
- Gs_status("gvld_wire_slices");
- }
-#endif
+ G_debug (3, "gvld_wire_slices");
gsd_pushmatrix();
@@ -749,17 +755,18 @@
return (0);
}
-/************************************************************************/
-/* draw wind3 box */
+/*!
+ \brief Draw wind3 box
+
+ \param gvl pointer to geovol struct
+
+ \return 0
+*/
int gvld_wind3_box(geovol * gvl)
{
float pt[3];
-#ifdef TRACE_DFUNCS
- {
- Gs_status("gvld_wind3_box");
- }
-#endif
+ G_debug(3, "gvld_wind3_box");
gsd_pushmatrix();
More information about the grass-commit
mailing list