GRASS GIS 7 Programmer's Manual  7.5.svn(2017)-r71933
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
mask.c File Reference
#include <stdio.h>
#include <grass/gis.h>
#include "raster3d_intern.h"
Include dependency graph for mask.c:

Go to the source code of this file.

Macros

#define RASTER3D_MASKNUM(map, Xmask, Ymask, Zmask, VALUEmask, TYPEmask)
 

Functions

int Rast3d_mask_close ()
 
int Rast3d_mask_file_exists (void)
 Returns 1 if the 3d mask file exists. More...
 
int Rast3d_mask_open_old (void)
 
int Rast3d_mask_reopen (int cache)
 This function should be used to adjust the cache size used for the 3d-mask. First the open 3d-mask is closed and then opened again with a cache size as specified with cache. More...
 
int Rast3d_is_masked (RASTER3D_Map *map, int x, int y, int z)
 Returns 1 if the cell with cell-coordinates (x, y, z) is masked out. Returns 0 otherwise. More...
 
void Rast3d_mask_num (RASTER3D_Map *map, int x, int y, int z, void *value, int type)
 Replaces the value stored in value with the NULL-value if Rast3d_is_masked (x, y, z) returns 1. Does nothing otherwise. value is assumed to be oftype. More...
 
void Rast3d_mask_float (RASTER3D_Map *map, int x, int y, int z, float *value)
 Same as Rast3d_mask_num (x, y, z, value, FCELL_TYPE). More...
 
void Rast3d_mask_double (RASTER3D_Map *map, int x, int y, int z, double *value)
 Same as Rast3d_mask_num (x, y, z, value, DCELL_TYPE). More...
 
void Rast3d_mask_tile (RASTER3D_Map *map, int tileIndex, void *tile, int type)
 Replaces the values stored in tile (with tileIndex) for which Rast3d_is_masked returns 1 with NULL-values. Does not change the remaining values. The values are assumed to be of type. Whether replacement is performed or not only depends on location of the cells of the tile and not on the status of the mask for map (i.e. turned on or off). More...
 
void Rast3d_mask_on (RASTER3D_Map *map)
 Turns on the mask for map. Do not invoke this function after the first tile has been read since the result might be inconsistent cell-values. More...
 
void Rast3d_mask_off (RASTER3D_Map *map)
 Turns off the mask for map. This is the default. Do not invoke this function after the first tile has been read since the result might be inconsistent cell-values. More...
 
int Rast3d_mask_is_on (RASTER3D_Map *map)
 Returns 1 if the mask for map is turned on. Returns 0 otherwise. More...
 
int Rast3d_mask_is_off (RASTER3D_Map *map)
 Returns 1 if the mask for map is turned off. Returns 0 otherwise. More...
 
const char * Rast3d_mask_file (void)
 Returns the name of the 3d mask file. More...
 
int Rast3d_mask_map_exists (void)
 Returns 1 if the 3d mask is loaded. More...
 

Macro Definition Documentation

#define RASTER3D_MASKNUM (   map,
  Xmask,
  Ymask,
  Zmask,
  VALUEmask,
  TYPEmask 
)
Value:
\
(RASTER3D_MASKNUMmaskValue = Rast3d_getMaskFloat (map, Xmask, Ymask, Zmask), \
((Rast3d_is_null_value_num (&RASTER3D_MASKNUMmaskValue, FCELL_TYPE)) ? \
Rast3d_set_null_value (VALUEmask, 1, TYPEmask) : dummy()))
int Rast3d_is_null_value_num(const void *n, int type)
Definition: null.c:12
void Rast3d_set_null_value(void *c, int nofElts, int type)
Fills the vector pointed to by c with nofElts NULL-values of type.
Definition: null.c:35
#define FCELL_TYPE
Definition: raster.h:12

Definition at line 28 of file mask.c.

Referenced by Rast3d_mask_double(), Rast3d_mask_float(), Rast3d_mask_num(), and Rast3d_mask_tile().

Function Documentation

int Rast3d_is_masked ( RASTER3D_Map map,
int  x,
int  y,
int  z 
)

Returns 1 if the cell with cell-coordinates (x, y, z) is masked out. Returns 0 otherwise.

Parameters
x
y
z
Returns
int

Definition at line 173 of file mask.c.

References FCELL_TYPE, and Rast3d_is_null_value_num().

int Rast3d_mask_close ( )

Definition at line 36 of file mask.c.

References Rast3d_close(), and Rast3d_error().

Referenced by Rast3d_mask_reopen().

void Rast3d_mask_double ( RASTER3D_Map map,
int  x,
int  y,
int  z,
double *  value 
)

Same as Rast3d_mask_num (x, y, z, value, DCELL_TYPE).

Parameters
x
y
z
value
Returns
void

Definition at line 244 of file mask.c.

References DCELL_TYPE, and RASTER3D_MASKNUM.

const char* Rast3d_mask_file ( void  )

Returns the name of the 3d mask file.

Returns
char *

Definition at line 394 of file mask.c.

References RASTER3D_MASK_MAP.

int Rast3d_mask_file_exists ( void  )

Returns 1 if the 3d mask file exists.

Returns
int

Definition at line 64 of file mask.c.

References G_find_file_misc(), G_mapset(), NULL, RASTER3D_CELL_ELEMENT, RASTER3D_DIRECTORY, and RASTER3D_MASK_MAP.

Referenced by N_read_rast3d_to_array_3d(), N_write_array_3d_to_rast3d(), and Rast3d_mask_open_old().

void Rast3d_mask_float ( RASTER3D_Map map,
int  x,
int  y,
int  z,
float *  value 
)

Same as Rast3d_mask_num (x, y, z, value, FCELL_TYPE).

Parameters
x
y
z
value
Returns
void

Definition at line 222 of file mask.c.

References FCELL_TYPE, and RASTER3D_MASKNUM.

int Rast3d_mask_is_off ( RASTER3D_Map map)

Returns 1 if the mask for map is turned off. Returns 0 otherwise.

Parameters
map
Returns
int

Definition at line 380 of file mask.c.

References RASTER3D_Map::useMask.

Referenced by N_read_rast3d_to_array_3d(), N_write_array_3d_to_rast3d(), and Rast3d_read_tile().

int Rast3d_mask_is_on ( RASTER3D_Map map)

Returns 1 if the mask for map is turned on. Returns 0 otherwise.

Parameters
map
Returns
int

Definition at line 365 of file mask.c.

References RASTER3D_Map::useMask.

Referenced by N_read_rast3d_to_array_3d(), and N_write_array_3d_to_rast3d().

int Rast3d_mask_map_exists ( void  )

Returns 1 if the 3d mask is loaded.

Returns
int

Definition at line 408 of file mask.c.

void Rast3d_mask_num ( RASTER3D_Map map,
int  x,
int  y,
int  z,
void *  value,
int  type 
)

Replaces the value stored in value with the NULL-value if Rast3d_is_masked (x, y, z) returns 1. Does nothing otherwise. value is assumed to be oftype.

Parameters
x
y
z
value
type
Returns
void

Definition at line 200 of file mask.c.

References RASTER3D_MASKNUM.

void Rast3d_mask_off ( RASTER3D_Map map)

Turns off the mask for map. This is the default. Do not invoke this function after the first tile has been read since the result might be inconsistent cell-values.

Parameters
map
Returns
void

Definition at line 349 of file mask.c.

References RASTER3D_Map::useMask.

Referenced by N_read_rast3d_to_array_3d(), N_write_array_3d_to_rast3d(), Rast3d_open_cell_new(), and Rast3d_open_cell_old_no_header().

void Rast3d_mask_on ( RASTER3D_Map map)

Turns on the mask for map. Do not invoke this function after the first tile has been read since the result might be inconsistent cell-values.

Parameters
map
Returns
void

Definition at line 332 of file mask.c.

References RASTER3D_Map::useMask.

Referenced by N_read_rast3d_to_array_3d(), and N_write_array_3d_to_rast3d().

int Rast3d_mask_reopen ( int  cache)

This function should be used to adjust the cache size used for the 3d-mask. First the open 3d-mask is closed and then opened again with a cache size as specified with cache.

Parameters
cache
Returns
1 ... if successful 0 ... otherwise.

Definition at line 134 of file mask.c.

References Rast3d_error(), Rast3d_mask_close(), and Rast3d_mask_open_old().

void Rast3d_mask_tile ( RASTER3D_Map map,
int  tileIndex,
void *  tile,
int  type 
)

Replaces the values stored in tile (with tileIndex) for which Rast3d_is_masked returns 1 with NULL-values. Does not change the remaining values. The values are assumed to be of type. Whether replacement is performed or not only depends on location of the cells of the tile and not on the status of the mask for map (i.e. turned on or off).

Parameters
map
tileIndex
tile
type
Returns
void

Definition at line 271 of file mask.c.

References Rast3d_compute_clipped_tile_dimensions(), Rast3d_get_tile_dimensions_map(), Rast3d_length(), Rast3d_tile_index_origin(), RASTER3D_MASKNUM, RASTER3D_Map::tileSize, RASTER3D_Map::tileX, and x.

Referenced by Rast3d_read_tile().