9 static int verifyVolumeVertices(map, v)
 
   38 static int verifyVolumeEdges(nx, ny, nz)
 
   43     if ((nx <= 0) || (ny <= 0) || (nz <= 0))
 
   52                void *volumeBuf, 
int type)
 
   54     typedef double doubleArray[3];
 
   56     doubleArray *u000, *u001, *u010, *u011;
 
   57     doubleArray *u100, *u101, *u110, *u111;
 
   58     double v00[3], v01[3], v10[3], v11[3];
 
   61     double r, rp, 
s, sp, t, tp;
 
   63     int x, 
y, z, nxp, nyp, nzp;
 
   67     doubleBuf = (
double *)volumeBuf;
 
   68     floatBuf = (
float *)volumeBuf;
 
   70     verifyVolumeVertices(map, u);
 
   71     verifyVolumeEdges(nx, ny, nz);
 
   77     u000 = (doubleArray *) u[0][0][0];
 
   78     u001 = (doubleArray *) u[0][0][1];
 
   79     u010 = (doubleArray *) u[0][1][0];
 
   80     u011 = (doubleArray *) u[0][1][1];
 
   81     u100 = (doubleArray *) u[1][0][0];
 
   82     u101 = (doubleArray *) u[1][0][1];
 
   83     u110 = (doubleArray *) u[1][1][0];
 
   84     u111 = (doubleArray *) u[1][1][1];
 
   86     for (dz = 1; dz < nzp; dz += 2) {
 
   87         r = 1. - (rp = dz / nz / 2.);
 
   88         v00[0] = r * (*u000)[0] + rp * (*u100)[0];
 
   89         v00[1] = r * (*u000)[1] + rp * (*u100)[1];
 
   90         v00[2] = r * (*u000)[2] + rp * (*u100)[2];
 
   92         v01[0] = r * (*u001)[0] + rp * (*u101)[0];
 
   93         v01[1] = r * (*u001)[1] + rp * (*u101)[1];
 
   94         v01[2] = r * (*u001)[2] + rp * (*u101)[2];
 
   96         v10[0] = r * (*u010)[0] + rp * (*u110)[0];
 
   97         v10[1] = r * (*u010)[1] + rp * (*u110)[1];
 
   98         v10[2] = r * (*u010)[2] + rp * (*u110)[2];
 
  100         v11[0] = r * (*u011)[0] + rp * (*u111)[0];
 
  101         v11[1] = r * (*u011)[1] + rp * (*u111)[1];
 
  102         v11[2] = r * (*u011)[2] + rp * (*u111)[2];
 
  104         for (dy = 1; dy < nyp; dy += 2) {
 
  105             s = 1. - (sp = dy / ny / 2.);
 
  106             v0[0] = s * v00[0] + sp * v10[0];
 
  107             v0[1] = s * v00[1] + sp * v10[1];
 
  108             v0[2] = s * v00[2] + sp * v10[2];
 
  110             v1[0] = s * v01[0] + sp * v11[0];
 
  111             v1[1] = s * v01[1] + sp * v11[1];
 
  112             v1[2] = s * v01[2] + sp * v11[2];
 
  114             for (dx = 1; dx < nxp; dx += 2) {
 
  115                 t = 1. - (tp = dx / nx / 2.);
 
  116                 v[0] = t * v0[0] + tp * v1[0];
 
  117                 v[1] = t * v0[1] + tp * v1[1];
 
  118                 v[2] = t * v0[2] + tp * v1[2];
 
  128                 if (type == DCELL_TYPE)
 
  129                     *(doubleBuf + ((
int)dz / 2) * nx * ny +
 
  130                       ((
int)dy / 2) * nx + (
int)dx / 2) =
 
  133                     *(floatBuf + ((
int)dz / 2) * nx * ny +
 
  134                       ((
int)dy / 2) * nx + (
int)dx / 2) =
 
  145               double originNorth, 
double originWest, 
double originBottom,
 
  146               double vxNorth, 
double vxWest, 
double vxBottom,
 
  147               double vyNorth, 
double vyWest, 
double vyBottom,
 
  148               double vzNorth, 
double vzWest, 
double vzBottom,
 
  149               int nx, 
int ny, 
int nz, 
void *volumeBuf, 
int type)
 
  151     double u[2][2][2][3];
 
  153     u[0][0][0][0] = originNorth;
 
  154     u[0][0][0][1] = originWest;
 
  155     u[0][0][0][2] = originBottom;
 
  157     u[0][0][1][0] = vxNorth;
 
  158     u[0][0][1][1] = vxWest;
 
  159     u[0][0][1][2] = vxBottom;
 
  161     u[1][0][0][0] = vzNorth;
 
  162     u[1][0][0][1] = vzWest;
 
  163     u[1][0][0][2] = vzBottom;
 
  165     u[1][0][1][0] = (u[0][0][1][0] - u[0][0][0][0]) + u[1][0][0][0];
 
  166     u[1][0][1][1] = (u[0][0][1][1] - u[0][0][0][1]) + u[1][0][0][1];
 
  167     u[1][0][1][2] = (u[0][0][1][2] - u[0][0][0][2]) + u[1][0][0][2];
 
  169     u[0][1][0][0] = vyNorth;
 
  170     u[0][1][0][1] = vyWest;
 
  171     u[0][1][0][2] = vyBottom;
 
  173     u[0][1][1][0] = (u[0][0][1][0] - u[0][0][0][0]) + u[0][1][0][0];
 
  174     u[0][1][1][1] = (u[0][0][1][1] - u[0][0][0][1]) + u[0][1][0][1];
 
  175     u[0][1][1][2] = (u[0][0][1][2] - u[0][0][0][2]) + u[0][1][0][2];
 
  177     u[1][1][0][0] = (u[1][0][0][0] - u[0][0][0][0]) + u[0][1][0][0];
 
  178     u[1][1][0][1] = (u[1][0][0][1] - u[0][0][0][1]) + u[0][1][0][1];
 
  179     u[1][1][0][2] = (u[1][0][0][2] - u[0][0][0][2]) + u[0][1][0][2];
 
  181     u[1][1][1][0] = (u[1][0][0][0] - u[0][0][0][0]) + u[0][1][1][0];
 
  182     u[1][1][1][1] = (u[1][0][0][1] - u[0][0][0][1]) + u[0][1][1][1];
 
  183     u[1][1][1][2] = (u[1][0][0][2] - u[0][0][0][2]) + u[0][1][1][2];
 
  192                      double originNorth, 
double originWest,
 
  193                      double originBottom, 
double lengthNorth,
 
  194                      double lengthWest, 
double lengthBottom, 
int nx, 
int ny,
 
  195                      int nz, 
void *volumeBuf, 
int type)
 
  198                   originNorth, originWest, originBottom,
 
  199                   originNorth + lengthNorth, originWest, originBottom,
 
  200                   originNorth, originWest + lengthWest, originBottom,
 
  201                   originNorth, originWest, originBottom + lengthBottom,
 
  202                   nx, ny, nz, volumeBuf, type);
 
  209                           double originNorth, 
double originWest,
 
  210                           double originBottom, 
double lengthNorth,
 
  211                           double lengthWest, 
double lengthBottom, 
int nx,
 
  216     int x, 
y, z, eltLength;
 
  220     if (volumeBuf == 
NULL)
 
  224                          originNorth, originWest, originBottom,
 
  225                          lengthNorth, lengthWest, lengthBottom,
 
  228     region.north = originNorth;
 
  229     region.south = originNorth + lengthNorth;
 
  230     region.east = originWest;
 
  231     region.west = originWest + lengthWest;
 
  232     region.top = originBottom;
 
  233     region.bottom = originBottom + lengthBottom;
 
  240                                 G3D_USE_CACHE_DEFAULT, ®ion);
 
  241     if (mapVolume == 
NULL)
 
  242         G3d_fatalError(
"G3d_makeAlignedVolumeFile: error in G3d_openCellNew");
 
  246     for (z = 0; z < nz; z++) {
 
  247         for (y = 0; y < ny; y++) {
 
  248             for (x = 0; x < nx; x++) {
 
  252                                                   (z * ny * nx + y * nx +
 
  256                         (
"G3d_makeAlignedVolumeFile: error in G3d_putValue");
 
  262         G3d_fatalError(
"G3d_makeAlignedVolumeFile: error in G3d_closeCell");
 
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_free(void *buf)
Same as free (ptr). 
void G3d_getVolume(void *map, double originNorth, double originWest, double originBottom, double vxNorth, double vxWest, double vxBottom, double vyNorth, double vyWest, double vyBottom, double vzNorth, double vzWest, double vzBottom, int nx, int ny, int nz, void *volumeBuf, int type)
void * G_incr_void_ptr(const void *ptr, const size_t size)
Advance void pointer. 
void G3d_getAlignedVolume(void *map, double originNorth, double originWest, double originBottom, double lengthNorth, double lengthWest, double lengthBottom, int nx, int ny, int nz, void *volumeBuf, int type)
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_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...
void G3d_makeAlignedVolumeFile(void *map, const char *fileName, double originNorth, double originWest, double originBottom, double lengthNorth, double lengthWest, double lengthBottom, int nx, int ny, int nz)
double G3d_getDoubleRegion()
Is equivalent to G3d_getValueRegion (map, x, y, z, &value, DCELL_TYPE); return value. 
void * G3d_malloc(int nBytes)
Same as malloc (nBytes), except that in case of error G3d_error() is invoked. 
void G3d_getVolumeA(void *map, double u[2][2][2][3], int nx, int ny, int nz, void *volumeBuf, int type)
void G3d_fatalError(const char *,...)
This function prints the error message msg, and terminates the program with an error status...
float G3d_getFloatRegion(G3D_Map *map, int x, int y, int z)
Is equivalent to G3d_getValueRegion (map, x, y, z, &value, FCELL_TYPE); return value. 
int G3d_putValue(G3D_Map *map, int x, int y, int z, const void *value, int type)
After converting *value of type into the type specified at the initialization time (i...
void * G3d_openCellNew(const char *name, int typeIntern, int cache, G3D_Region *region)
Opens new g3d-file with name in the current mapset. Tiles are stored in memory with type which must b...
int G3d_getFileType()
get G3d file type