GRASS GIS 7 Programmer's Manual  7.9.dev(2021)-e5379bbd7
gvl_calc.c File Reference

OGSF library - loading and manipulating volumes (lower level functions) More...

#include <math.h>
#include <grass/gis.h>
#include <grass/ogsf.h>
#include "rgbpack.h"
#include "mc33_table.h"
Include dependency graph for gvl_calc.c:

Go to the source code of this file.

Macros

#define BUFFER_SIZE   1000000
 memory buffer for writing More...
 
#define LINTERP(d, a, b)   (a + d * (b - a))
 
#define TINTERP(d, v)
 
#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;} }
 
#define WRITE(c)   gvl_write_char(dbuff->ndx_new++, &(dbuff->new), c)
 writing and reading isosurface data More...
 
#define READ()   gvl_read_char(dbuff->ndx_old++, dbuff->old)
 
#define SKIP(n)   dbuff->ndx_old = dbuff->ndx_old + n
 
#define IS_IN_DATA(att)   ((isosurf->data_desc >> att) & 1)
 check and set data descriptor More...
 
#define SET_IN_DATA(att)   isosurf->data_desc = (isosurf->data_desc | (1 << att))
 
#define DISTANCE_2(x1, y1, x2, y2)   sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2))
 
#define SLICE_MODE_INTERP_NO   0
 
#define SLICE_MODE_INTERP_YES   1
 

Functions

int mc33_process_cube (int c_ndx, float *v)
 ADD. More...
 
void iso_w_cndx (int ndx, data_buffer *dbuff)
 Write cube index. More...
 
int iso_r_cndx (data_buffer *dbuff)
 Read cube index. More...
 
int iso_get_cube_value (geovol_isosurf *isosurf, int desc, int x, int y, int z, float *v)
 Get value from data input. More...
 
void iso_get_range (geovol_isosurf *isosurf, int desc, double *min, double *max)
 Get volume file values range. More...
 
int iso_get_cube_values (geovol_isosurf *isosurf, int desc, int x, int y, int z, float *v)
 Read values for cube. More...
 
void iso_get_cube_grads (geovol_isosurf *isosurf, int x, int y, int z, float(*grad)[3])
 Calculate cube grads. More...
 
void iso_calc_cube (geovol_isosurf *isosurf, int x, int y, int z, data_buffer *dbuff)
 Process cube. More...
 
int gvl_isosurf_calc (geovol *gvol)
 Fill data structure with computed isosurfaces polygons. More...
 
void gvl_write_char (int pos, unsigned char **data, unsigned char c)
 ADD. More...
 
unsigned char gvl_read_char (int pos, const unsigned char *data)
 Read char. More...
 
void gvl_align_data (int pos, unsigned char **data)
 Append data to buffer. More...
 
float slice_get_value (geovol *gvl, int x, int y, int z)
 Get volume value. More...
 
int slice_calc (geovol *gvl, int ndx_slc, void *colors)
 Calculate slices. More...
 
int gvl_slices_calc (geovol *gvol)
 Calculate slices for given volume set. More...
 

Variables

int Rows
 
int Cols
 
int Depths
 
double ResX
 
double ResY
 
double ResZ
 

Detailed Description

OGSF library - loading and manipulating volumes (lower level functions)

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
Tomas Paudits (February 2004)
Doxygenized by Martin Landa <landa.martin gmail.com> (May 2008)

Definition in file gvl_calc.c.

Macro Definition Documentation

◆ BUFFER_SIZE

#define BUFFER_SIZE   1000000

memory buffer for writing

Definition at line 30 of file gvl_calc.c.

◆ DISTANCE_2

#define DISTANCE_2 (   x1,
  y1,
  x2,
  y2 
)    sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2))

Definition at line 805 of file gvl_calc.c.

◆ FOR_0_TO_N

#define FOR_0_TO_N (   n,
  cmd 
)    { int FOR_VAR; for (FOR_VAR = 0; FOR_VAR < n; FOR_VAR++) {cmd;} }

Definition at line 46 of file gvl_calc.c.

◆ FOR_VAR

#define FOR_VAR   i_for

Definition at line 45 of file gvl_calc.c.

◆ IS_IN_DATA

#define IS_IN_DATA (   att)    ((isosurf->data_desc >> att) & 1)

check and set data descriptor

Definition at line 58 of file gvl_calc.c.

◆ LINTERP

#define LINTERP (   d,
  a,
  b 
)    (a + d * (b - a))

Definition at line 35 of file gvl_calc.c.

◆ READ

#define READ ( )    gvl_read_char(dbuff->ndx_old++, dbuff->old)

Definition at line 52 of file gvl_calc.c.

Referenced by iso_r_cndx().

◆ SET_IN_DATA

#define SET_IN_DATA (   att)    isosurf->data_desc = (isosurf->data_desc | (1 << att))

Definition at line 59 of file gvl_calc.c.

◆ SKIP

#define SKIP (   n)    dbuff->ndx_old = dbuff->ndx_old + n

Definition at line 53 of file gvl_calc.c.

◆ SLICE_MODE_INTERP_NO

#define SLICE_MODE_INTERP_NO   0

Definition at line 807 of file gvl_calc.c.

◆ SLICE_MODE_INTERP_YES

#define SLICE_MODE_INTERP_YES   1

Definition at line 808 of file gvl_calc.c.

◆ TINTERP

#define TINTERP (   d,
 
)
Value:
((v[0]*(1.-d[0])*(1.-d[1])*(1.-d[2])) +\
(v[1]*d[0]*(1.-d[1])*(1.-d[2])) + \
(v[2]*d[0]*d[1]*(1.-d[2])) + \
(v[3]*(1.-d[0])*d[1]*(1.-d[2])) + \
(v[4]*(1.-d[0])*(1.-d[1])*d[2]) + \
(v[5]*d[0]*(1.-d[1])*d[2]) + \
(v[6]*d[0]*d[1]*d[2]) + \
(v[7]*(1.-d[0])*d[1]*d[2]))

Definition at line 36 of file gvl_calc.c.

◆ WRITE

#define WRITE (   c)    gvl_write_char(dbuff->ndx_new++, &(dbuff->new), c)

writing and reading isosurface data

Definition at line 51 of file gvl_calc.c.

Referenced by iso_r_cndx(), and iso_w_cndx().

Function Documentation

◆ gvl_align_data()

void gvl_align_data ( int  pos,
unsigned char **  data 
)

Append data to buffer.

Parameters
posposition index
datadata buffer

Definition at line 779 of file gvl_calc.c.

◆ gvl_isosurf_calc()

int gvl_isosurf_calc ( geovol gvol)

Fill data structure with computed isosurfaces polygons.

Parameters
gvolpointer to geovol struct
Returns
1

Definition at line 585 of file gvl_calc.c.

References x.

Referenced by gvld_vol().

◆ gvl_read_char()

unsigned char gvl_read_char ( int  pos,
const unsigned char *  data 
)

Read char.

Parameters
posposition index
datadata buffer
Returns
char on success
NULL on failure

Definition at line 765 of file gvl_calc.c.

◆ gvl_slices_calc()

int gvl_slices_calc ( geovol gvol)

Calculate slices for given volume set.

Parameters
gvolpointer to geovol struct
Returns
1

Definition at line 1037 of file gvl_calc.c.

Referenced by gvld_vol().

◆ gvl_write_char()

void gvl_write_char ( int  pos,
unsigned char **  data,
unsigned char  c 
)

ADD.

Parameters
pos
data
c

Definition at line 737 of file gvl_calc.c.

◆ iso_calc_cube()

void iso_calc_cube ( geovol_isosurf isosurf,
int  x,
int  y,
int  z,
data_buffer *  dbuff 
)

Process cube.

Parameters
isosurf
x,y,z
dbuff

Definition at line 323 of file gvl_calc.c.

◆ iso_get_cube_grads()

void iso_get_cube_grads ( geovol_isosurf isosurf,
int  x,
int  y,
int  z,
float(*)  grad[3] 
)

Calculate cube grads.

Parameters
isosurf
x,y,z
grad

Definition at line 246 of file gvl_calc.c.

References ATT_TOPO, Cols, Depths, iso_get_cube_value(), and Rows.

◆ iso_get_cube_value()

int iso_get_cube_value ( geovol_isosurf isosurf,
int  desc,
int  x,
int  y,
int  z,
float *  v 
)

Get value from data input.

Parameters
isosurf
desc
x,y,z
[out]value
Returns
0
?

Definition at line 155 of file gvl_calc.c.

Referenced by iso_get_cube_grads(), and iso_get_cube_values().

◆ iso_get_cube_values()

int iso_get_cube_values ( geovol_isosurf isosurf,
int  desc,
int  x,
int  y,
int  z,
float *  v 
)

Read values for cube.

Parameters
isosurf
desc
x,y,z
[out]v
Returns

Definition at line 223 of file gvl_calc.c.

References iso_get_cube_value().

◆ iso_get_range()

void iso_get_range ( geovol_isosurf isosurf,
int  desc,
double *  min,
double *  max 
)

Get volume file values range.

Parameters
isosurf
desc
[out]min
[out]max

Definition at line 206 of file gvl_calc.c.

References geovol_isosurf::att, gvl_file_get_min_max(), gvl_file_get_volfile(), and geovol_isosurf_att::hfile.

◆ iso_r_cndx()

int iso_r_cndx ( data_buffer *  dbuff)

Read cube index.

Parameters
dbuff

Definition at line 120 of file gvl_calc.c.

References READ, and WRITE.

◆ iso_w_cndx()

void iso_w_cndx ( int  ndx,
data_buffer *  dbuff 
)

Write cube index.

Parameters
ndx
dbuff

Definition at line 85 of file gvl_calc.c.

References WRITE.

◆ mc33_process_cube()

int mc33_process_cube ( int  c_ndx,
float *  v 
)

ADD.

Parameters
c_ndx
v
Returns

Definition at line 307 of file gvl_calc2.c.

References m_case.

◆ slice_calc()

int slice_calc ( geovol gvl,
int  ndx_slc,
void *  colors 
)

Calculate slices.

Parameters
gvlpointer to geovol struct
ndx_slc
colors
Returns
1

Definition at line 857 of file gvl_calc.c.

◆ slice_get_value()

float slice_get_value ( geovol gvl,
int  x,
int  y,
int  z 
)

Get volume value.

Parameters
gvlpointer to geovol struct
x,y,z
Returns
value

Definition at line 818 of file gvl_calc.c.

Variable Documentation

◆ Cols

int Cols

◆ Depths

int Depths

Definition at line 73 of file gvl_calc.c.

Referenced by alloc_vol_buff(), and iso_get_cube_grads().

◆ ResX

double ResX

Definition at line 74 of file gvl_calc.c.

◆ ResY

double ResY

Definition at line 74 of file gvl_calc.c.

◆ ResZ

double ResZ

Definition at line 74 of file gvl_calc.c.

◆ Rows

int Rows

Definition at line 73 of file gvl_calc.c.

Referenced by alloc_slice_buff(), alloc_vol_buff(), get_vol_value(), and iso_get_cube_grads().