[GRASS5] r.showdspf

Helena hmitaso at unity.ncsu.edu
Mon Jun 21 09:59:42 EDT 2004

Peter and others,

Tomas Paudits has implemented volume visualization within nviz for 5.3 and 5.7.
The code for GRASS5.3 and GRASS5.7 with these changes is here:


We will appreciate any help with testing before it is submitted to CVS.
Below are some notes from Tomas about the changes.
When this is tested and submitted, r3.showdspf can be retired.


I appended new functionality to NVIZ - visualization volumes (G3D).
New sources are currently merged with old CVS version of GRASS 5.3
and GRASS 5.7.

Short description of source code modification:

G3D library:

I modified one file - g3dcolor.c, because i had problem with
reading color file for G3D data. I'm not sure, that this modification is

OGSF library:

*** geovol_file ***

- new structure geovol_file for reading from volume files
geovol_file type is defined in gstypes.h

geovol_file is designed for reading volume raster data at x,y,z
from volume file. Currently I have implemented a support for G3D files.
There are some modes of reading data from vol_file :
1. direct reading from volume file - (G3d_getValue)
2. slice reading - read rows*cols at depth into memory, and then
read from the memory
3. the whole volume loaded into memory and then read from memory

functions manipulating with geovol_file are in gvl_file.c. Description
of basic functions :

gvl_file_newh - return handle of created / existing geovol_file for
   given file name and  file type.
gvl_file_free_datah - free gvl_file for given handle
gvl_file_set_mode - set read mode from volume file
gvl_file_start/end_read - initialize/deinitialize reading from
gvl_file_get_value - read value at x,y,z

*** geovol ***

- replace old geovol struct with new - gstypes.h

I replace old geovol struct with new geovol. The new geovol has some
new fields as geosurf surf, handle to geovol_file and new fields for
visualization  volume in many forms - isosurfaces and slices.

Fuctions manipulating with geovol structs are in gvl.c, GVL2.c and

*** geovol_isosurf ***

- new struct for visualization volumes as isosurfaces  - gstypes.h

geovol object can have some isosurfaces objects. Each isosurface object
has own attributes (threshold, color, mask, trasp, shin and emit).
There are also some common attibutes for all isosurfaces for one geovol object -
defined  in geovol struct :

polygon resolution
draw mode - gouraud, flat shading

Each isosurface struct has these fields :

inout flag - change direction of normals
att - isosurface attributes
data_desc - data desription for fast change att data
data - isosurface data for drawing

Isosurfaces are calculated with Marching Cubes 33 algorithm (gvl_calc.c, gvl_calc2.c).
Implementation use precalculated tables and some code published by
Thomas Lewiner,  Mat Depth, PUC-Rio. (www-sop.inria.fr/geometrica/team/Thomas.Lewiner/JGT.pdf)
The result of calculation isosurfaces are data, which contains
information about cells of MC 33 algorithm (vert position, normals, color, etc).
When isosurface is drawing - isosurface data with information about tiling of each cube in
the cell_tables (mc33_table.h) are treated as polygons(triangles)(gvld.c).

*** geovol_slices ***

- new struct for visualization volumes as slices of volume

Common attributes for slices are same as for isosurfaces. Each slice
object has own attributes :

dir - direction
x1,x2,y1,y2 - position (x1,x2,y1,y2)
z1,z2 - size
transparency (trasp)
data - slice data

Color of slice is defined by geovol object -> geovol_file -> G3D color

*** other ***

I also modified some existing files in ogsf lib for volume support ...


*** tcl/tk scripts ***

created new volume panel (control widgets and procedures) -
created attIsosurfPopup.tcl - setting attributes for isosurfaces
modified widgets.tcl - add volume support

*** c ***

modified some source files - mainly map_obj.c, draw.c and some others
created new file - volume.c - manipulation with isosurfaces, slices -
call functions of ogsf library


this is a modification of existing r.stats for volume statistics.
I had there some problems with quant functionality, therefore I changed one procedure in
quant.c in GIS library. I will describe this problem later...

  Löwe wrote:
> dear list,
> i am trying to visualize true three-d data through r3.showdspf.
> However, the colortable-option leaves me puzzled.
> Is there a way to make use of the predefined colortables, like in r.colors ?
> regards,
> peter

More information about the grass-dev mailing list