15 static int G3d_maskMapExistsVar = 0;
16 static G3D_Map *G3d_maskMap;
19 static void dummy(
void)
25 static float G3D_MASKNUMmaskValue;
28 #define G3D_MASKNUM(map,Xmask,Ymask,Zmask,VALUEmask,TYPEmask) \
30 (G3D_MASKNUMmaskValue = G3d_getMaskFloat (map, Xmask, Ymask, Zmask), \
31 ((G3d_isNullValueNum (&G3D_MASKNUMmaskValue, FCELL_TYPE)) ? \
32 G3d_setNullValue (VALUEmask, 1, TYPEmask) : dummy()))
39 if (!G3d_maskMapExistsVar)
42 G3d_maskMapExistsVar = 0;
45 G3d_error(
"G3d_maskClose: error closing mask");
68 sprintf(buf,
"%s/%s", G3D_DIRECTORY, G3D_MASK_MAP);
74 static int maskOpenOldCacheDefault = G3D_USE_CACHE_DEFAULT;
81 if (G3d_maskMapExistsVar)
86 if (!G3d_maskMapExistsVar)
90 G3D_DEFAULT_WINDOW, FCELL_TYPE,
91 maskOpenOldCacheDefault))
93 G3d_error(
"G3d_maskOpenOld: cannot open mask");
106 static float G3d_getMaskFloat(G3D_Map * map,
int x,
int y,
int z)
108 double north, east, top;
111 north = ((double)map->window.rows - y - 0.5) / (double)map->window.rows *
112 (map->window.north - map->window.south) + map->window.south;
113 east = ((double)x + 0.5) / (double)map->window.cols *
114 (map->window.east - map->window.west) + map->window.west;
115 top = ((double)z + 0.5) / (double)map->window.depths *
116 (map->window.top - map->window.bottom) + map->window.bottom;
141 if (G3d_maskMapExistsVar)
143 G3d_error(
"G3d_maskReopen: error closing mask");
148 tmp = maskOpenOldCacheDefault;
149 maskOpenOldCacheDefault = cache;
152 G3d_error(
"G3d_maskReopen: error opening mask");
157 maskOpenOldCacheDefault = tmp;
178 if (!G3d_maskMapExistsVar)
181 G3D_MASKNUMmaskValue = G3d_getMaskFloat(map, x, y, z);
205 if (!G3d_maskMapExistsVar)
227 if (!G3d_maskMapExistsVar)
249 if (!G3d_maskMapExistsVar)
276 int nofNum, rows,
cols, depths, xRedundant, yRedundant, zRedundant;
277 int x,
y, z, xLength, yLength, dx, dy, dz, length;
279 if (!G3d_maskMapExistsVar)
283 &rows, &cols, &depths,
284 &xRedundant, &yRedundant,
288 if (nofNum == map->tileSize) {
298 xRedundant = yRedundant = 0;
305 xLength = xRedundant * length;
306 yLength = map->tileX * yRedundant * length;
308 for (dz = z; dz < depths; dz++) {
309 for (dy = y; dy < rows; dy++) {
310 for (dx = x; dx <
cols; dx++) {
385 return !map->useMask;
413 return G3d_maskMapExistsVar;
char * G_mapset(void)
current mapset name
sprintf(buf2,"%s", G3D_CATS_ELEMENT)
void G3d_maskFloat(G3D_Map *map, int x, int y, int z, float *value)
Same as G3d_maskNum (x, y, z, value, FCELL_TYPE).
void G3d_maskOff(G3D_Map *map)
Turns off the mask for map. This is the default. Do not invoke this function after the first tile has...
void G3d_getRegionValue(G3D_Map *map, double north, double east, double top, void *value, int type)
Returns in value the value of the map which corresponds to region coordinates (north, east, top). The value is resampled using the resampling function specified for map. The value is of type.
void G3d_error(const char *msg,...)
void G3d_tileIndexOrigin(G3D_Map *map, int tileIndex, int *x, int *y, int *z)
Computes the cell-coordinates (x, y, z) which correspond to the origin of the tile with tileIndex...
const char * G3d_maskFile(void)
Returns the name of the 3d mask file.
int G3d_isNullValueNum(const void *n, int type)
void G3d_maskNum(G3D_Map *map, int x, int y, int z, void *value, int type)
Replaces the value stored in value with the NULL-value if G3d_isMasked (x, y, z) returns 1...
#define G3D_MASKNUM(map, Xmask, Ymask, Zmask, VALUEmask, TYPEmask)
void G3d_maskOn(G3D_Map *map)
Turns on the mask for map. Do not invoke this function after the first tile has been read since the r...
int G3d_maskMapExists(void)
Returns 1 if the 3d mask is loaded.
int G3d_maskIsOff(G3D_Map *map)
Returns 1 if the mask for map is turned off. Returns 0 otherwise.
int G3d_closeCell(G3D_Map *map)
Closes g3d-file. If map is new and cache-mode is used for map then every tile which is not flushed be...
int G3d_maskReopen(int cache)
This function should be used to adjust the cache size used for the 3d-mask. First the open 3d-mask is...
int G3d_maskIsOn(G3D_Map *map)
Returns 1 if the mask for map is turned on. Returns 0 otherwise.
char buf[GNAME_MAX+sizeof(G3D_DIRECTORY)+2]
int G3d_computeClippedTileDimensions(G3D_Map *map, int tileIndex, int *rows, int *cols, int *depths, int *xRedundant, int *yRedundant, int *zRedundant)
Computes the dimensions of the tile when clipped to fit the region of map. The clipped dimensions are...
void G3d_setWindowMap(G3D_Map *map, G3D_Region *window)
Sets the window for map to window. Can be used multiple times for the same map.
void * G3d_openCellOld(const char *name, const char *mapset, G3D_Region *window, int typeIntern, int cache)
Opens existing g3d-file name in mapset. Tiles are stored in memory with type which must be any of FCE...
int G3d_isMasked(G3D_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.
int G3d_maskFileExists()
Returns 1 if the 3d mask file exists.
char * G_find_file(const char *element, char *name, const char *mapset)
searches for a file from the mapset search list or in a specified mapset. returns the mapset name whe...
void G3d_maskDouble(G3D_Map *map, int x, int y, int z, double *value)
Same as G3d_maskNum (x, y, z, value, DCELL_TYPE).
void G3d_maskTile(G3D_Map *map, int tileIndex, void *tile, int type)
Replaces the values stored in tile (with tileIndex) for which G3d_isMasked returns 1 with NULL-values...