Loading...
Searching...
No Matches
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
#define | LINTERP(d, a, b)
#define | TINTERP(d, v)
#define | FOR_VAR i_for
#define | FOR_0_TO_N(n, cmd)
#define | WRITE(c)
| writing and reading isosurface data
#define | READ()
#define | SKIP(n)
#define | IS_IN_DATA(att)
| check and set data descriptor
#define | SET_IN_DATA(att)
#define | DISTANCE_2(x1, y1, x2, y2)
#define | SLICE_MODE_INTERP_NO 0
#define | SLICE_MODE_INTERP_YES 1

## Functions

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

## 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 31 of file gvl_calc.c.

Referenced by gvl_write_char().

## DISTANCE_2

#define DISTANCE_2 | ( |  | x1,
|  |  | y1,
|  |  | x2,
|  |  | y2 )

Value:
sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2))

Definition at line 806 of file gvl_calc.c.

Referenced by slice_calc().

## FOR_0_TO_N

#define FOR_0_TO_N | ( |  | n,
|  |  | cmd )

Value:
{ \
int FOR_VAR; \
for (FOR_VAR = 0; FOR_VAR < n; FOR_VAR++) { \
cmd; \
} \
}
FOR_VAR
#define FOR_VAR
Definition gvl_calc.c:46

Definition at line 47 of file gvl_calc.c.

Referenced by iso_calc_cube().

## FOR_VAR

#define FOR_VAR i_for

Definition at line 46 of file gvl_calc.c.

Referenced by iso_calc_cube().

## IS_IN_DATA

#define IS_IN_DATA | ( |  | att | ) |

Value:
((isosurf->data_desc >> att) & 1)

check and set data descriptor

Definition at line 65 of file gvl_calc.c.

Referenced by gvl_isosurf_calc(), and iso_calc_cube().

## LINTERP

#define LINTERP | ( |  | d,
|  |  | a,
|  |  | b )

Value:
(a + d * (b - a))
b
double b
Definition driver/set_window.c:5

Definition at line 36 of file gvl_calc.c.

Referenced by iso_calc_cube().

## READ

#define READ | ( |  | ) |

Value:
gvl_read_char(dbuff->ndx_old++, dbuff->old)
gvl_read_char
unsigned char gvl_read_char(int pos, const unsigned char *data)
Read char.
Definition gvl_calc.c:763

Definition at line 59 of file gvl_calc.c.

Referenced by iso_calc_cube(), and iso_r_cndx().

## SET_IN_DATA

#define SET_IN_DATA | ( |  | att | ) |

Value:
isosurf->data_desc = (isosurf->data_desc | (1 << att))

Definition at line 66 of file gvl_calc.c.

Referenced by gvl_isosurf_calc().

## SKIP

#define SKIP | ( |  | n | ) |

Value:
dbuff->ndx_old = dbuff->ndx_old + n

Definition at line 60 of file gvl_calc.c.

Referenced by iso_calc_cube().

## SLICE_MODE_INTERP_NO

#define SLICE_MODE_INTERP_NO 0

Definition at line 809 of file gvl_calc.c.

## SLICE_MODE_INTERP_YES

#define SLICE_MODE_INTERP_YES 1

Definition at line 810 of file gvl_calc.c.

Referenced by slice_calc().

## TINTERP

#define TINTERP | ( |  | d,
|  |  | v )

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 37 of file gvl_calc.c.

Referenced by iso_calc_cube().

## WRITE

#define WRITE | ( |  | c | ) |

Value:
gvl_write_char(dbuff->ndx_new++, &(dbuff->new), c)
gvl_write_char
void gvl_write_char(int pos, unsigned char **data, unsigned char c)
ADD.
Definition gvl_calc.c:736

writing and reading isosurface data

Definition at line 58 of file gvl_calc.c.

Referenced by iso_calc_cube(), 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

  pos | position index
  data | data buffer

Definition at line 777 of file gvl_calc.c.

References G_debug(), G_free(), and NULL.

Referenced by gvl_isosurf_calc(), and slice_calc().

## gvl_isosurf_calc()

int gvl_isosurf_calc | ( | geovol * | gvol | ) |

Fill data structure with computed isosurfaces polygons.

Parameters

  gvol | pointer to geovol struct

Returns
  1

Definition at line 585 of file gvl_calc.c.

References Cols, Depths, G_free(), gvl_align_data(), gvl_file_end_read(), gvl_file_get_volfile(), gvl_file_set_mode(), gvl_file_start_read(), gvl_write_char(), IS_IN_DATA, iso_calc_cube(), NULL, ResX, ResY, ResZ, Rows, SET_IN_DATA, and x.

Referenced by gvld_vol().

## gvl_read_char()

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

Read char.

Parameters

  pos | position index
  data | data buffer

Returns
  char on success
  NULL on failure

Definition at line 763 of file gvl_calc.c.

## gvl_slices_calc()

int gvl_slices_calc | ( | geovol * | gvol | ) |

Calculate slices for given volume set.

Parameters

  gvol | pointer to geovol struct

Returns
  1

Definition at line 1038 of file gvl_calc.c.

References Cols, Depths, G_debug(), gvl_file_get_name(), Gvl_load_colors_data(), Gvl_unload_colors_data(), ResX, ResY, ResZ, Rows, and slice_calc().

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 736 of file gvl_calc.c.

References BUFFER_SIZE, and G_debug().

Referenced by gvl_isosurf_calc(), and slice_calc().

## 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 328 of file gvl_calc.c.

References BLU_MASK, cell_table, FOR_0_TO_N, FOR_VAR, GRN_MASK, GS_v3norm(), Gvl_get_color_for_value(), IS_IN_DATA, iso_get_cube_grads(), iso_get_cube_values(), iso_get_range(), iso_r_cndx(), iso_w_cndx(), LINTERP, max, mc33_process_cube(), min, READ, RED_MASK, SKIP, TINTERP, WRITE, and x.

Referenced by gvl_isosurf_calc().

## 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 251 of file gvl_calc.c.

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

Referenced by iso_calc_cube().

## 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] | v | value

Returns
  0
  ?

Definition at line 161 of file gvl_calc.c.

References gvl_file_get_data_type(), gvl_file_get_value(), gvl_file_get_volfile(), gvl_file_is_null_value(), ResX, ResY, ResZ, and x.

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 228 of file gvl_calc.c.

References iso_get_cube_value(), and x.

Referenced by iso_calc_cube().

## 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 212 of file gvl_calc.c.

References gvl_file_get_min_max(), gvl_file_get_volfile(), max, and min.

Referenced by iso_calc_cube().

## iso_r_cndx()

int iso_r_cndx | ( | data_buffer * | dbuff | ) |

Read cube index.

Parameters

  dbuff |

Definition at line 126 of file gvl_calc.c.

References READ, and WRITE.

Referenced by iso_calc_cube().

## iso_w_cndx()

void iso_w_cndx | ( | int | ndx,
|  | data_buffer * | dbuff )

Write cube index.

Parameters

  ndx |
  dbuff |

Definition at line 91 of file gvl_calc.c.

References WRITE.

Referenced by iso_calc_cube().

## 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, m_config, m_subconfig, mc33_test_face(), mc33_test_interior(), OFFSET_T1, OFFSET_T10_1_1_S1, OFFSET_T10_1_1_S2, OFFSET_T10_1_2, OFFSET_T10_2_S1, OFFSET_T10_2_S2, OFFSET_T11, OFFSET_T12_1_1_S1, OFFSET_T12_1_1_S2, OFFSET_T12_1_2, OFFSET_T12_2_S1, OFFSET_T12_2_S2, OFFSET_T13_1_S1, OFFSET_T13_1_S2, OFFSET_T13_2_S1, OFFSET_T13_2_S2, OFFSET_T13_3_S1, OFFSET_T13_3_S2, OFFSET_T13_4, OFFSET_T13_5_1, OFFSET_T13_5_2, OFFSET_T14, OFFSET_T2, OFFSET_T3_1, OFFSET_T3_2, OFFSET_T4_1, OFFSET_T4_2, OFFSET_T5, OFFSET_T6_1_1, OFFSET_T6_1_2, OFFSET_T6_2, OFFSET_T7_1, OFFSET_T7_2_S1, OFFSET_T7_2_S2, OFFSET_T7_2_S3, OFFSET_T7_3_S1, OFFSET_T7_3_S2, OFFSET_T7_3_S3, OFFSET_T7_4_1, OFFSET_T7_4_2, OFFSET_T8, OFFSET_T9, OFFSET_TEST10, OFFSET_TEST12, OFFSET_TEST13, OFFSET_TEST3, OFFSET_TEST4, OFFSET_TEST6, and OFFSET_TEST7.

Referenced by iso_calc_cube().

## slice_calc()

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

Calculate slices.

Parameters

  gvl | pointer to geovol struct
  ndx_slc |
  colors |

Returns
  1

Definition at line 859 of file gvl_calc.c.

References BLU_MASK, DISTANCE_2, GRN_MASK, gvl_align_data(), gvl_file_end_read(), gvl_file_get_volfile(), gvl_file_set_mode(), gvl_file_start_read(), Gvl_get_color_for_value(), gvl_write_char(), r, RED_MASK, ResX, ResY, ResZ, slice_get_value(), SLICE_MODE_INTERP_YES, X, x, and Y.

Referenced by gvl_slices_calc().

## slice_get_value()

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

Get volume value.

Parameters

  gvl | pointer to geovol struct
  x,y,z |

Returns
  value

Definition at line 820 of file gvl_calc.c.

References gvl_file_get_data_type(), gvl_file_get_value(), gvl_file_get_volfile(), and x.

Referenced by slice_calc().

## Variable Documentation

## Cols

int Cols

Definition at line 79 of file gvl_calc.c.

Referenced by alloc_slice_buff(), alloc_vol_buff(), get_slice_value(), get_vol_value(), gvl_isosurf_calc(), gvl_slices_calc(), iso_get_cube_grads(), read_g3d_slice(), and read_g3d_vol().

## Depths

int Depths

Definition at line 79 of file gvl_calc.c.

Referenced by alloc_vol_buff(), gvl_isosurf_calc(), gvl_slices_calc(), iso_get_cube_grads(), and read_g3d_vol().

## ResX

double ResX

Definition at line 80 of file gvl_calc.c.

Referenced by gvl_isosurf_calc(), gvl_slices_calc(), iso_get_cube_value(), and slice_calc().

## ResY

double ResY

Definition at line 80 of file gvl_calc.c.

Referenced by gvl_isosurf_calc(), gvl_slices_calc(), iso_get_cube_value(), and slice_calc().

## ResZ

double ResZ

Definition at line 80 of file gvl_calc.c.

Referenced by gvl_isosurf_calc(), gvl_slices_calc(), iso_get_cube_value(), and slice_calc().

## Rows

int Rows

Definition at line 79 of file gvl_calc.c.

Referenced by alloc_slice_buff(), alloc_vol_buff(), get_vol_value(), gvl_isosurf_calc(), gvl_slices_calc(), iso_get_cube_grads(), read_g3d_slice(), and read_g3d_vol().