فهرست منبع

ogsflib: initial doxygen strings
fprintf -> G_m/w/e/d
minor indentation fixes
[sync'ed with devbr6]


git-svn-id: https://svn.osgeo.org/grass/grass/trunk@31356 15284696-431f-4ddb-bdfa-cd5b030d7da7

Martin Landa 17 سال پیش
والد
کامیت
4e61a2bdae
7فایلهای تغییر یافته به همراه1191 افزوده شده و 694 حذف شده
  1. 121 86
      lib/ogsf/gs_query.c
  2. 12 1
      lib/ogsf/gsget.c
  3. 356 244
      lib/ogsf/gvl.c
  4. 128 50
      lib/ogsf/gvl_calc.c
  5. 26 4
      lib/ogsf/gvl_calc2.c
  6. 469 237
      lib/ogsf/gvl_file.c
  7. 79 72
      lib/ogsf/gvld.c

+ 121 - 86
lib/ogsf/gs_query.c

@@ -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@eye.com
- */
+/*!
+  \brief Values needed for Ray-Convex Polyhedron Intersection Test below
+  originally by Eric Haines, erich@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 @@ int gs_los_intersect1(int surfid, float (*los)[3], float *point)
     geosurf *gs;
     typbuff *buf;
 
+    G_debug (3, "gs_los_intersect1():");
+
     if (NULL == (gs = gs_get_surf(surfid))) {
 	return (0);
     }
@@ -149,7 +162,7 @@ int gs_los_intersect1(int surfid, float (*los)[3], float *point)
     }
 
     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 @@ int gs_los_intersect1(int surfid, float (*los)[3], float *point)
     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 @@ int gs_los_intersect(int surfid, float **los, float *point)
     typbuff *buf;
     Point3 *points;
 
+    G_debug (3, "gs_los_intersect");
+
     if (NULL == (gs = gs_get_surf(surfid))) {
 	return (0);
     }
@@ -200,41 +224,40 @@ int gs_los_intersect(int surfid, float **los, float *point)
     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 @@ fprintf(stderr,"all points above surf\n");
     }
 
 /* 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 @@ fprintf(stderr,
 	/*  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 @@ fprintf(stderr,"aZ= %.6f point0 = %.6f %.6f %.6f FT =%.6f %.6f %.6f\n",
 	    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@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@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 @@ int RayCvxPolyhedronInt(Point3 org, Point3 dir, double tmax, Point4 * phdrn,
     }
 }
 
-/***********************************************************************/
+/*!
+  \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 @@ void gs_get_databounds_planes(Point4 * planes)
     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)
 {

+ 12 - 1
lib/ogsf/gsget.c

@@ -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) {

+ 356 - 244
lib/ogsf/gvl.c

@@ -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];
     }
 

+ 128 - 50
lib/ogsf/gvl_calc.c

@@ -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 @@ double ResX, ResY, ResZ;
 /************************************************************************/
 /* 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 @@ void iso_w_cndx(int ndx, data_buffer * dbuff)
     }
 }
 
-/************************************************************************/
-/* read cube index */
+/*!
+  \brief Read cube index
+
+  \param dbuff
+*/
 int iso_r_cndx(data_buffer * dbuff)
 {
     int ndx, ndx2;
@@ -130,8 +141,17 @@ int iso_r_cndx(data_buffer * dbuff)
     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 @@ int iso_get_cube_value(geovol_isosurf * isosurf, int desc, int x, int y, int z,
     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 @@ int iso_get_cube_values(geovol_isosurf * isosurf, int desc, int x, int y, int z,
     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 @@ void iso_get_cube_grads(geovol_isosurf * isosurf, int x, int y, int z,
     }
 }
 
-/************************************************************************/
-/* 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 @@ void iso_calc_cube(geovol_isosurf * isosurf, int x, int y, int z,
     }
 }
 
-/************************************************************************/
-/* 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 @@ int gvl_isosurf_calc(geovol * gvol)
     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 @@ void gvl_align_data(int pos, unsigned char *data)
 #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 @@ float slice_get_value(geovol * gvl, int x, int y, int z)
     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 @@ int slice_calc(geovol * gvl, int ndx_slc, void *colors)
     return (1);
 }
 
-/************************************************************************/
+/*!
+  \brief Calculate slices
+
+  \param gvol pointer to geovol struct
+
+  \return 1
+*/
 int gvl_slices_calc(geovol * gvol)
 {
     int i;

+ 26 - 4
lib/ogsf/gvl_calc2.c

@@ -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 @@ int mc33_test_face( char face , float *v)
 	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 @@ int mc33_test_interior( char s, float *v)
 	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] ;

تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 469 - 237
lib/ogsf/gvl_file.c


+ 79 - 72
lib/ogsf/gvld.c

@@ -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 @@ int gvld_vol(geovol * gvl)
     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 @@ int gvld_wire_vol(geovol * gvl)
     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 @@ int gvld_isosurf(geovol * gvl)
     nz = G_malloc(n_i * sizeof(int));
     e_dl = G_malloc(n_i * sizeof(int));
 
-#ifdef TRACE_DFUNCS
-    {
-	Gs_status("gvld_isosurf");
-    }
-#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);
-	}
+    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
-
+    
     /* shade */
     gsd_shademodel(gvl->isosurf_draw_mode & DM_GOURAUD);
 
@@ -233,24 +238,17 @@ int gvld_isosurf(geovol * gvl)
 	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 @@ int gvld_isosurf(geovol * gvl)
 
     }
 
-#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 @@ int gvld_isosurf(geovol * gvl)
     return (0);
 }
 
-/************************************************************************/
+/*!
+  \brief ADD
+
+  \param gvl pointer to geovol struct
+
+  \return 0
+*/
 int gvld_wire_isosurf(geovol * gvl)
 {
     return (0);
@@ -417,9 +417,13 @@ int gvld_wire_isosurf(geovol * gvl)
 
 #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 @@ int gvld_slices(geovol * gvl)
     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 @@ int gvld_slices(geovol * gvl)
     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 @@ int gvld_slice(geovol * gvl, int ndx)
     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 @@ int gvld_wire_slices(geovol * gvl)
 
     geovol_slice *slice;
 
-#ifdef TRACE_DFUNCS
-    {
-	Gs_status("gvld_wire_slices");
-    }
-#endif
+    G_debug (3, "gvld_wire_slices");
 
     gsd_pushmatrix();
 
@@ -749,17 +755,18 @@ int gvld_wire_slices(geovol * gvl)
     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();