30 *zTile = tileIndex / map->nxy;
31 tileIndex2d = tileIndex % map->nxy;
32 *yTile = tileIndex2d / map->nx;
33 *xTile = tileIndex2d % map->nx;
54 return map->nxy * zTile + map->nx * yTile + xTile;
81 *x = map->tileX * xTile;
82 *y = map->tileY * yTile;
83 *z = map->tileZ * zTile;
105 int xTile, yTile, zTile;
137 int *yTile,
int *zTile,
int *xOffs,
int *yOffs,
140 *xTile = x / map->tileX;
141 *xOffs = x % map->tileX;
142 *yTile = y / map->tileY;
143 *yOffs = y % map->tileY;
144 *zTile = z / map->tileZ;
145 *zOffs = z % map->tileZ;
170 int xTile, yTile, zTile, xOffs, yOffs, zOffs;
173 &xTile, &yTile, &zTile, &xOffs, &yOffs, &zOffs);
175 *offset = zOffs * map->tileXY + yOffs * map->tileX + xOffs;
197 return (x >= 0) && (x < map->region.cols) && (y >= 0) &&
198 (y < map->region.rows) && (z >= 0) && (z < map->region.depths);
217 return (tileIndex < map->nTiles) && (tileIndex >= 0);
239 return (x >= 0) && (x < map->nx) && (y >= 0) && (y < map->ny) &&
240 (z >= 0) && (z < map->nz);
268 int *
cols,
int *depths,
int *xRedundant,
269 int *yRedundant,
int *zRedundant)
275 if ((x != map->clipX) && (y != map->clipY) && (z != map->clipZ)) {
276 return map->tileSize;
279 if (x != map->clipX) {
284 *cols = (map->region.cols - 1) % map->tileX + 1;
285 *xRedundant = map->tileX - *cols;
287 if (y != map->clipY) {
292 *rows = (map->region.rows - 1) % map->tileY + 1;
293 *yRedundant = map->tileY - *rows;
295 if (z != map->clipZ) {
296 *depths = map->tileZ;
300 *depths = (map->region.depths - 1) % map->tileZ + 1;
301 *zRedundant = map->tileZ - *depths;
308 return *depths * *cols * *rows;
329 return ((north >= map->region.south) && (north <= map->region.north) &&
330 (east >= map->region.west) && (east <= map->region.east) &&
331 (((top >= map->region.bottom) && (top <= map->region.top)) ||
332 ((top <= map->region.bottom) && (top >= map->region.top))));
356 int *x,
int *
y,
int *z)
361 *y = (north - map->region.south) / (map->region.north -
363 (map->region.rows - 1);
364 *x = (east - map->region.west) / (map->region.east -
365 map->region.west) * (map->region.cols -
367 *z = (top - map->region.bottom) / (map->region.top -
368 map->region.bottom) *
369 (map->region.depths - 1);
int G3d_isValidLocation(G3D_Map *map, double north, double east, double top)
Returns 1 if region-coordinates (north, west, bottom) are inside the region of map. Returns 0 otherwise.
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...
void G3d_tileCoordOrigin(G3D_Map *map, int xTile, int yTile, int zTile, int *x, int *y, int *z)
Computes the cell-coordinates (x, y, z) which correspond to the origin of the tile with tile-coordina...
void G3d_location2coord(G3D_Map *map, double north, double east, double top, int *x, int *y, int *z)
Converts region-coordinates (north, west, bottom) into cell-coordinates (x, y, z).
int G3d_tileIndexInRange(G3D_Map *map, int tileIndex)
Returns 1 if tileIndex is a valid index for map. Returns 0 otherwise.
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_coord2tileCoord(G3D_Map *map, int x, int y, int z, int *xTile, int *yTile, int *zTile, int *xOffs, int *yOffs, int *zOffs)
Converts cell-coordinates (x, y, z) into tile-coordinates (xTile, yTile, zTile) and the coordinate of...
int G3d_coordInRange(G3D_Map *map, int x, int y, int z)
Returns 1 if cell-coordinate (x, y, z) is a coordinate inside the region. Returns 0 otherwise...
int G3d_tile2tileIndex(G3D_Map *map, int xTile, int yTile, int zTile)
Returns tile-index corresponding to tile-coordinates (xTile, yTile, zTile).
void G3d_coord2tileIndex(G3D_Map *map, int x, int y, int z, int *tileIndex, int *offset)
Converts cell-coordinates (x, y, z) into tileIndex and the offset of the cell within the tile...
void G3d_fatalError(const char *,...)
This function prints the error message msg, and terminates the program with an error status...
void G3d_tileIndex2tile(G3D_Map *map, int tileIndex, int *xTile, int *yTile, int *zTile)
Converts index tileIndex into tile-coordinates (xTile, yTile, zTile).
int G3d_tileInRange(G3D_Map *map, int x, int y, int z)
Returns 1 if tile-coordinate (x, y, z) is a coordinate inside tile cube. Returns 0 otherwise...