GRASS Programmer's Manual  6.5.svn(2014)-r66266
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
GVL2.c File Reference

OGSF library - loading and manipulating volumes. More...

#include <grass/gis.h>
#include <grass/G3d.h>
#include <grass/gstypes.h>
#include <grass/glocale.h>
#include "gsget.h"
Include dependency graph for GVL2.c:

Go to the source code of this file.

Functions

void GVL_libinit (void)
 Library intialization for volumes. More...
 
int GVL_get_region (float *n, float *s, float *w, float *e, float *t, float *b)
 Get region extent settings. More...
 
void * GVL_get_window ()
 Get window. More...
 
int GVL_vol_exists (int id)
 Check if volume set exists. More...
 
int GVL_new_vol (void)
 Create new volume set. More...
 
int GVL_num_vols (void)
 Get number of loaded volume sets. More...
 
intGVL_get_vol_list (int *numvols)
 Get list of loaded volume sets. More...
 
int GVL_delete_vol (int id)
 Delete volume set from list. More...
 
int GVL_load_vol (int id, const char *filename)
 Load 3d raster map to volume set. More...
 
int GVL_get_volname (int id, char *filename)
 Get volume set name. More...
 
void GVL_get_dims (int id, int *rows, int *cols, int *depths)
 Get volume dimensions. More...
 
void GVL_set_trans (int id, float xtrans, float ytrans, float ztrans)
 Set trans ? More...
 
int GVL_get_trans (int id, float *xtrans, float *ytrans, float *ztrans)
 Get trans ? More...
 
void GVL_draw_vol (int vid)
 Draw volume set. More...
 
void GVL_draw_wire (int id)
 Draw volume in wire mode. More...
 
void GVL_alldraw_vol (void)
 Draw all volume sets. More...
 
void GVL_alldraw_wire (void)
 Draw all volume sets in wire mode. More...
 
int GVL_Set_ClientData (int id, void *clientd)
 Set client data for volume set. More...
 
void * GVL_Get_ClientData (int id)
 Get client data. More...
 
void GVL_set_focus_center_map (int id)
 Set focus on map center. More...
 
void GVL_isosurf_get_drawres (int id, int *xres, int *yres, int *zres)
 Get draw resolution for isosurface. More...
 
int GVL_isosurf_set_drawres (int id, int xres, int yres, int zres)
 Set isosurface draw resolution. More...
 
int GVL_isosurf_get_drawmode (int id, int *mode)
 Get isosurface draw mode. More...
 
int GVL_isosurf_set_drawmode (int id, int mode)
 Set isosurface draw mode. More...
 
int GVL_isosurf_add (int id)
 Add isosurface. More...
 
int GVL_isosurf_del (int id, int isosurf_id)
 Delete isosurface. More...
 
int GVL_isosurf_move_up (int id, int isosurf_id)
 Move up isosurface in list. More...
 
int GVL_isosurf_move_down (int id, int isosurf_id)
 Move down isosurface in list. More...
 
int GVL_isosurf_get_att (int id, int isosurf_id, int att, int *set, float *constant, char *mapname)
 Get isosurface attributes. More...
 
int GVL_isosurf_unset_att (int id, int isosurf_id, int att)
 Unset isosurface attributes. More...
 
int GVL_isosurf_set_att_const (int id, int isosurf_id, int att, float constant)
 Set constant isosurface attribute. More...
 
int GVL_isosurf_set_att_map (int id, int isosurf_id, int att, const char *filename)
 Set isosurface map attribute. More...
 
int GVL_isosurf_get_flags (int id, int isosurf_id, int *inout)
 Get isosurface flags. More...
 
int GVL_isosurf_set_flags (int id, int isosurf_id, int inout)
 Set isosurface flags. More...
 
int GVL_isosurf_num_isosurfs (int id)
 Get number of available isosurfaces. More...
 
int GVL_isosurf_set_maskmode (int id, int isosurf_id, int mode)
 Set mask attribute mode. More...
 
int GVL_isosurf_get_maskmode (int id, int isosurf_id, int *mode)
 Get isosurface mask mode. More...
 
void GVL_slice_get_drawres (int id, int *xres, int *yres, int *zres)
 Get draw resolution of slice. More...
 
int GVL_slice_set_drawres (int id, int xres, int yres, int zres)
 Set slice draw resolution. More...
 
int GVL_slice_get_drawmode (int id, int *mode)
 Get slice draw mode. More...
 
int GVL_slice_set_drawmode (int id, int mode)
 Set slice draw mode. More...
 
int GVL_slice_add (int id)
 Add slice. More...
 
int GVL_slice_del (int id, int slice_id)
 Delete slice. More...
 
int GVL_slice_move_up (int id, int slice_id)
 Move up slice. More...
 
int GVL_slice_move_down (int id, int slice_id)
 Move down slice. More...
 
int GVL_slice_num_slices (int id)
 Get number or slices. More...
 
int GVL_slice_get_pos (int id, int slice_id, float *x1, float *x2, float *y1, float *y2, float *z1, float *z2, int *dir)
 Get slice position. More...
 
int GVL_slice_set_pos (int id, int slice_id, float x1, float x2, float y1, float y2, float z1, float z2, int dir)
 Get slice position. More...
 
int GVL_slice_get_transp (int id, int slice_id, int *transp)
 Get slice trans ? More...
 
int GVL_slice_set_transp (int id, int slice_id, int transp)
 Set slice trans ? More...
 

Detailed Description

OGSF library - loading and manipulating volumes.

GRASS OpenGL gsurf OGSF Library

(C) 1999-2008 by the GRASS Development Team

This program is free software under the GNU General Public License (>=v2). Read the file COPYING that comes with GRASS for details.

Author
Bill Brown UI-GMSL (May 1997) Tomas Paudits (February 2004)

Definition in file GVL2.c.

Function Documentation

void GVL_alldraw_vol ( void  )

Draw all volume sets.

Definition at line 398 of file GVL2.c.

References GVL_draw_vol(), and tools::id.

Referenced by gk_follow_frames(), and GK_show_vol().

void GVL_alldraw_wire ( void  )

Draw all volume sets in wire mode.

Definition at line 412 of file GVL2.c.

References GVL_draw_wire(), and tools::id.

Referenced by Nviz_draw_quick().

int GVL_delete_vol ( int  id)

Delete volume set from list.

Parameters
idvolume set id
Returns
1 on success
-1 on error (invalid volume set id)

Definition at line 190 of file GVL2.c.

References G_debug(), gvl_delete_vol(), GVL_isosurf_del(), GVL_isosurf_num_isosurfs(), GVL_slice_del(), GVL_slice_num_slices(), and GVL_vol_exists().

Referenced by wxnviz.Nviz::LoadVolume(), Nviz_new_map_obj(), and wxnviz.Nviz::UnloadVolume().

void GVL_draw_vol ( int  vid)

Draw volume set.

Parameters
vidvolume set id

Definition at line 362 of file GVL2.c.

References gvl_get_vol(), and gvld_vol().

Referenced by GVL_alldraw_vol(), and Nviz_draw_all_vol().

void GVL_draw_wire ( int  id)

Draw volume in wire mode.

Parameters
idvolume set id

Definition at line 380 of file GVL2.c.

References G_debug(), gvl_get_vol(), and gvld_wire_vol().

Referenced by GVL_alldraw_wire().

void* GVL_Get_ClientData ( int  id)

Get client data.

Parameters
idvolume set id
Returns
pointer to client data
NULL on error

Definition at line 455 of file GVL2.c.

References gvl_get_vol(), and NULL.

void GVL_get_dims ( int  id,
int rows,
int cols,
int depths 
)

Get volume dimensions.

Parameters
idvolume set id
[out]rows,cols,depthsnumber of rows, cols, depths

Definition at line 290 of file GVL2.c.

References G_debug(), and gvl_get_vol().

Referenced by Nviz_set_volume_attr_default().

int GVL_get_region ( float *  n,
float *  s,
float *  w,
float *  e,
float *  t,
float *  b 
)

Get region extent settings.

Parameters
[out]n,s,w,enorth, south, west, east
[out]t,btop, bottom
Returns
1

Definition at line 59 of file GVL2.c.

int GVL_get_trans ( int  id,
float *  xtrans,
float *  ytrans,
float *  ztrans 
)

Get trans ?

Parameters
idvolume set id
[out]xtrans,ytrans,ztransx/y/z trans values
Returns
1 on success
-1 on error

Definition at line 340 of file GVL2.c.

References gvl_get_vol().

Referenced by wxnviz.Nviz::GetVolumePosition().

int* GVL_get_vol_list ( int numvols)

Get list of loaded volume sets.

Must be freed if not needed!

Parameters
[out]numvolsnumber of volume sets
Returns
pointer to list of volume sets
NULL on error

Definition at line 161 of file GVL2.c.

References NULL.

Referenced by Nviz_draw_all_vol(), and Nviz_set_focus_map().

int GVL_get_volname ( int  id,
char *  filename 
)

Get volume set name.

Parameters
idvolume set id
[out]filenamename (must be allocated)
Returns
-1 on error
1 on success

Definition at line 267 of file GVL2.c.

References G_strcpy(), gvl_file_get_name(), gvl_get_vol(), and NULL.

void* GVL_get_window ( )

Get window.

Todo:
gvl_file.c use this - change
Returns
pointer to G3D_Region struct (static)

Definition at line 78 of file GVL2.c.

int GVL_isosurf_add ( int  id)

Add isosurface.

Parameters
idvolume set id
Returns
-1 on error (invalid volume set id
1 on success

Definition at line 618 of file GVL2.c.

References G_debug(), gvl_get_vol(), and gvl_isosurf_init().

Referenced by wxnviz.Nviz::AddIsosurface().

int GVL_isosurf_del ( int  id,
int  isosurf_id 
)

Delete isosurface.

Parameters
idvolume set id
isosurf_idisosurface id
Returns
-1 on error
1 on success

Definition at line 655 of file GVL2.c.

References G_debug(), G_free(), gvl_get_vol(), gvl_isosurf_freemem(), and gvl_isosurf_get_isosurf().

Referenced by wxnviz.Nviz::DeleteIsosurface(), and GVL_delete_vol().

int GVL_isosurf_get_att ( int  id,
int  isosurf_id,
int  att,
int set,
float *  constant,
char *  mapname 
)

Get isosurface attributes.

Parameters
idvolume set id
isosurf_idsurface id
attattribute id
[out]set
[out]constant
[out]mapname
Returns
-1 on error
1 on success

Definition at line 766 of file GVL2.c.

References G_debug(), G_strcpy(), gvl_file_get_name(), gvl_isosurf_get_att_src(), and gvl_isosurf_get_isosurf().

int GVL_isosurf_get_drawmode ( int  id,
int mode 
)

Get isosurface draw mode.

Parameters
idvolume set id
[out]modedraw-mode
Returns
1 on success
-1 on error

Definition at line 569 of file GVL2.c.

References gvl_get_vol().

void GVL_isosurf_get_drawres ( int  id,
int xres,
int yres,
int zres 
)

Get draw resolution for isosurface.

Todo:
error handling
Parameters
idvolume set id
[out]xres,yres,zresx/y/z resolution value

Definition at line 506 of file GVL2.c.

References G_debug(), and gvl_get_vol().

int GVL_isosurf_get_flags ( int  id,
int  isosurf_id,
int inout 
)

Get isosurface flags.

Parameters
idvolume set id
isosurf_idisosurface id
[out]inoutmap name
Returns
1 on success
-1 on error

Definition at line 904 of file GVL2.c.

References G_debug(), and gvl_isosurf_get_isosurf().

int GVL_isosurf_get_maskmode ( int  id,
int  isosurf_id,
int mode 
)

Get isosurface mask mode.

Parameters
idvolume set id
isosurf_idisosurface id
modeattribute mode
Returns
1 on success
-1 on error

Definition at line 1009 of file GVL2.c.

References gvl_isosurf_get_isosurf().

int GVL_isosurf_move_down ( int  id,
int  isosurf_id 
)

Move down isosurface in list.

Parameters
idvolume set id
isosurf_idisosurface id
Returns
-1 on error
1 on success

Definition at line 728 of file GVL2.c.

References G_debug(), and gvl_get_vol().

Referenced by wxnviz.Nviz::MoveIsosurface().

int GVL_isosurf_move_up ( int  id,
int  isosurf_id 
)

Move up isosurface in list.

Parameters
idvolume set id
isosurf_idisosurface id
Returns
-1 on error
1 on success

Definition at line 694 of file GVL2.c.

References G_debug(), and gvl_get_vol().

Referenced by wxnviz.Nviz::MoveIsosurface().

int GVL_isosurf_num_isosurfs ( int  id)

Get number of available isosurfaces.

Parameters
idvolume set id
Returns
number of isosurfaces
-1 on error

Definition at line 955 of file GVL2.c.

References G_debug(), and gvl_get_vol().

Referenced by wxnviz.Nviz::AddIsosurface(), wxnviz.Nviz::DeleteIsosurface(), GVL_delete_vol(), wxnviz.Nviz::MoveIsosurface(), wxnviz.Nviz::SetIsosurfaceAttr(), wxnviz.Nviz::SetIsosurfaceInOut(), and wxnviz.Nviz::UnsetIsosurfaceAttr().

int GVL_isosurf_set_att_const ( int  id,
int  isosurf_id,
int  att,
float  constant 
)

Set constant isosurface attribute.

Attributes:

  • ATT_NORM
  • ATT_TOPO topography (level) constant
  • ATT_COLOR color map/constant
  • ATT_MASK mask map
  • ATT_TRANSP transparency map/constant
  • ATT_SHINE shininess map/constant
  • ATT_EMIT emission map/constant
Parameters
idvolume set id
isosurf_idisosurface id (0 - MAX_ISOSURFS)
attattribute descriptor
constantconstant value
Returns
1 on success
-1 on error

Definition at line 841 of file GVL2.c.

References G_debug(), gvl_isosurf_get_isosurf(), and gvl_isosurf_set_att_const().

Referenced by wxnviz.Nviz::AddIsosurface(), and wxnviz.Nviz::SetIsosurfaceAttr().

int GVL_isosurf_set_att_map ( int  id,
int  isosurf_id,
int  att,
const char *  filename 
)

Set isosurface map attribute.

Attributes:

  • ATT_NORM
  • ATT_TOPO topography (level) constant
  • ATT_COLOR color map/constant
  • ATT_MASK mask map
  • ATT_TRANSP transparency map/constant
  • ATT_SHINE shininess map/constant
  • ATT_EMIT emission map/constant
Parameters
idvolume set id
isosurf_idisosurface id (0 - MAX_ISOSURFS)
attattribute descriptor
filenamemap name
Returns
1 on success
-1 on error

Definition at line 877 of file GVL2.c.

References G_debug(), gvl_isosurf_get_isosurf(), and gvl_isosurf_set_att_map().

Referenced by wxnviz.Nviz::SetIsosurfaceAttr().

int GVL_isosurf_set_drawmode ( int  id,
int  mode 
)

Set isosurface draw mode.

Parameters
idvolume set id
modedraw mode
Returns
0 on success
-1 on error (invalid volume set id)

Definition at line 593 of file GVL2.c.

References G_debug(), gvl_get_vol(), and tools::mode.

Referenced by Nviz_set_volume_attr_default(), and wxnviz.Nviz::SetIsosurfaceMode().

int GVL_isosurf_set_drawres ( int  id,
int  xres,
int  yres,
int  zres 
)

Set isosurface draw resolution.

Parameters
idvolume set id
xres,yres,zresx/y/z resolution value
Returns
-1 on error (invalid values/volume set id)
0 on success

Definition at line 532 of file GVL2.c.

References G_debug(), gvl_get_vol(), and gvl_isosurf_set_att_changed().

Referenced by Nviz_set_volume_attr_default(), and wxnviz.Nviz::SetIsosurfaceRes().

int GVL_isosurf_set_flags ( int  id,
int  isosurf_id,
int  inout 
)

Set isosurface flags.

Parameters
idvolume set id
isosurf_idisosurface id
inoutmap name
Returns
1 on success
-1 on error

Definition at line 930 of file GVL2.c.

References G_debug(), and gvl_isosurf_get_isosurf().

Referenced by wxnviz.Nviz::SetIsosurfaceInOut().

int GVL_isosurf_set_maskmode ( int  id,
int  isosurf_id,
int  mode 
)

Set mask attribute mode.

Mask attribute special: constant is set to indicate invert or no

Parameters
idvolume set id
isosurf_idisosurface id
modeattribute mode
Returns
mode id
-1 on error

Definition at line 982 of file GVL2.c.

References G_debug(), gvl_isosurf_get_isosurf(), and tools::mode.

int GVL_isosurf_unset_att ( int  id,
int  isosurf_id,
int  att 
)

Unset isosurface attributes.

Parameters
idvolume set id
isosurface_idisosurface id
attattribute id
Returns
?
-1 on error

Definition at line 806 of file GVL2.c.

References G_debug(), gvl_isosurf_get_isosurf(), and gvl_isosurf_set_att_src().

Referenced by wxnviz.Nviz::UnsetIsosurfaceAttr().

void GVL_libinit ( void  )

Library intialization for volumes.

Set region extent (N,S,W,E,T,B)

Definition at line 36 of file GVL2.c.

References G3d_getWindow(), and G3d_initDefaults().

Referenced by wxnviz.Nviz::Init().

int GVL_load_vol ( int  id,
const char *  filename 
)

Load 3d raster map to volume set.

Parameters
idvolume set id
filename3d raster map name
Returns
-1 on error
0 on success

Definition at line 236 of file GVL2.c.

References G_debug(), G_message(), gvl_file_newh(), gvl_get_vol(), and NULL.

Referenced by Nviz_new_map_obj().

int GVL_new_vol ( void  )

Create new volume set.

Returns
volume set id
-1 on error

Definition at line 116 of file GVL2.c.

References G_debug(), gvl_get_new_vol(), and gvl_init_vol().

Referenced by Nviz_new_map_obj().

int GVL_num_vols ( void  )

Get number of loaded volume sets.

Returns
number of volume sets

Definition at line 146 of file GVL2.c.

References gvl_num_vols().

Referenced by Nviz_new_map_obj(), and Nviz_set_focus_map().

int GVL_Set_ClientData ( int  id,
void *  clientd 
)

Set client data for volume set.

Parameters
idvolume set id
clientdpointer to client data
Returns
1 on success
-1 on error

Definition at line 432 of file GVL2.c.

References gvl_get_vol().

void GVL_set_focus_center_map ( int  id)

Set focus on map center.

Parameters
idvolume set id

Definition at line 473 of file GVL2.c.

References G_debug(), GS_set_focus(), gvl_get_vol(), X, and Y.

Referenced by Nviz_set_focus_map().

void GVL_set_trans ( int  id,
float  xtrans,
float  ytrans,
float  ztrans 
)

Set trans ?

Parameters
idvolume set id
xtrans,ytrans,ztransx/y/z trans values

Definition at line 314 of file GVL2.c.

References G_debug(), and gvl_get_vol().

Referenced by wxnviz.Nviz::SetVolumePosition().

int GVL_slice_add ( int  id)

Add slice.

Parameters
idvolume set id
Returns
-1 on error
1 on success

Definition at line 1147 of file GVL2.c.

References G_debug(), gvl_get_vol(), gvl_slice_init(), and NULL.

Referenced by wxnviz.Nviz::AddSlice().

int GVL_slice_del ( int  id,
int  slice_id 
)

Delete slice.

Parameters
idvolume set id
slice_idslice id
Returns
-1 on error
1 on success

Definition at line 1183 of file GVL2.c.

References G_debug(), G_free(), gvl_get_vol(), gvl_slice_freemem(), and gvl_slice_get_slice().

Referenced by wxnviz.Nviz::DeleteSlice(), and GVL_delete_vol().

int GVL_slice_get_drawmode ( int  id,
int mode 
)

Get slice draw mode.

Parameters
idvolume set id
[out]modedraw mode
Returns
1 on success
-1 on error (invalid id)

Definition at line 1098 of file GVL2.c.

References gvl_get_vol().

void GVL_slice_get_drawres ( int  id,
int xres,
int yres,
int zres 
)

Get draw resolution of slice.

Parameters
idvolume set id
[out]xres,yres,zresx/y/z resolution value

Definition at line 1035 of file GVL2.c.

References G_debug(), and gvl_get_vol().

int GVL_slice_get_pos ( int  id,
int  slice_id,
float *  x1,
float *  x2,
float *  y1,
float *  y2,
float *  z1,
float *  z2,
int dir 
)

Get slice position.

Parameters
idvolume set id
slice_idslice id
[out]x1,y1,z1coordinates ?
[out]x2,y2,z2coordinates ?
[out]dirdirection
Returns
-1 on error
1 on success

Definition at line 1316 of file GVL2.c.

References dialogs::cols, gvl_get_vol(), gvl_slice_get_slice(), X, and Y.

int GVL_slice_get_transp ( int  id,
int  slice_id,
int transp 
)

Get slice trans ?

Parameters
idvolume set id
slice_idslice id
[out]transptransp value
Returns
-1 on error
1 on success

Definition at line 1438 of file GVL2.c.

References G_debug(), and gvl_slice_get_slice().

int GVL_slice_move_down ( int  id,
int  slice_id 
)

Move down slice.

Parameters
idvolume set id
slice_idslice id
Returns
-1 on error
1 on success

Definition at line 1256 of file GVL2.c.

References G_debug(), and gvl_get_vol().

Referenced by wxnviz.Nviz::MoveSlice().

int GVL_slice_move_up ( int  id,
int  slice_id 
)

Move up slice.

Parameters
idvolume set id
slice_idslice id
Returns
-1 on error
1 on success

Definition at line 1222 of file GVL2.c.

References G_debug(), and gvl_get_vol().

Referenced by wxnviz.Nviz::MoveSlice().

int GVL_slice_num_slices ( int  id)

Get number or slices.

Parameters
idvolume set id
Returns
number of slices
-1 on error

Definition at line 1289 of file GVL2.c.

References G_debug(), and gvl_get_vol().

Referenced by wxnviz.Nviz::AddSlice(), wxnviz.Nviz::DeleteSlice(), GVL_delete_vol(), wxnviz.Nviz::MoveSlice(), wxnviz.Nviz::SetSlicePosition(), and wxnviz.Nviz::SetSliceTransp().

int GVL_slice_set_drawmode ( int  id,
int  mode 
)

Set slice draw mode.

Parameters
idvolume set id
modedraw mode
Returns
0 on success
-1 on error (invalid id)

Definition at line 1122 of file GVL2.c.

References G_debug(), gvl_get_vol(), and tools::mode.

Referenced by Nviz_set_volume_attr_default(), and wxnviz.Nviz::SetSliceMode().

int GVL_slice_set_drawres ( int  id,
int  xres,
int  yres,
int  zres 
)

Set slice draw resolution.

Parameters
idvolume set id
xres,yres,zresx/y/z resolution value
Returns
0 on success
-1 on error (invalid value or id)

Definition at line 1061 of file GVL2.c.

References G_debug(), and gvl_get_vol().

Referenced by Nviz_set_volume_attr_default(), and wxnviz.Nviz::SetSliceRes().

int GVL_slice_set_pos ( int  id,
int  slice_id,
float  x1,
float  x2,
float  y1,
float  y2,
float  z1,
float  z2,
int  dir 
)

Get slice position.

Parameters
idvolume set id
slice_idslice id
x1,y1,z1coordinates ?
x2,y2,z2coordinates ?
dirdirection
Returns
-1 on error
1 on success

Definition at line 1377 of file GVL2.c.

References dialogs::cols, gvl_get_vol(), gvl_slice_get_slice(), X, and Y.

Referenced by wxnviz.Nviz::SetSlicePosition().

int GVL_slice_set_transp ( int  id,
int  slice_id,
int  transp 
)

Set slice trans ?

Parameters
idvolume set id
slice_idslice id
transptransp value
Returns
-1 on error
1 on success

Definition at line 1464 of file GVL2.c.

References G_debug(), and gvl_slice_get_slice().

Referenced by wxnviz.Nviz::SetSliceTransp().