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;