11 static int verifyVolumeVertices(
void *map,
double v[2][2][2][3])
36 static int verifyVolumeEdges(
int nx,
int ny,
int nz)
38 if ((nx <= 0) || (ny <= 0) || (nz <= 0))
47 void *volumeBuf,
int type)
49 typedef double doubleArray[3];
51 doubleArray *u000, *u001, *u010, *u011;
52 doubleArray *u100, *u101, *u110, *u111;
53 double v00[3], v01[3], v10[3], v11[3];
56 double r, rp, s, sp,
t, tp;
58 int x, y, z, nxp, nyp, nzp;
62 doubleBuf = (
double *)volumeBuf;
63 floatBuf = (
float *)volumeBuf;
65 verifyVolumeVertices(map, u);
66 verifyVolumeEdges(nx, ny, nz);
72 u000 = (doubleArray *) u[0][0][0];
73 u001 = (doubleArray *) u[0][0][1];
74 u010 = (doubleArray *) u[0][1][0];
75 u011 = (doubleArray *) u[0][1][1];
76 u100 = (doubleArray *) u[1][0][0];
77 u101 = (doubleArray *) u[1][0][1];
78 u110 = (doubleArray *) u[1][1][0];
79 u111 = (doubleArray *) u[1][1][1];
81 for (dz = 1; dz < nzp; dz += 2) {
82 r = 1. - (rp = dz / nz / 2.);
83 v00[0] = r * (*u000)[0] + rp * (*u100)[0];
84 v00[1] = r * (*u000)[1] + rp * (*u100)[1];
85 v00[2] = r * (*u000)[2] + rp * (*u100)[2];
87 v01[0] = r * (*u001)[0] + rp * (*u101)[0];
88 v01[1] = r * (*u001)[1] + rp * (*u101)[1];
89 v01[2] = r * (*u001)[2] + rp * (*u101)[2];
91 v10[0] = r * (*u010)[0] + rp * (*u110)[0];
92 v10[1] = r * (*u010)[1] + rp * (*u110)[1];
93 v10[2] = r * (*u010)[2] + rp * (*u110)[2];
95 v11[0] = r * (*u011)[0] + rp * (*u111)[0];
96 v11[1] = r * (*u011)[1] + rp * (*u111)[1];
97 v11[2] = r * (*u011)[2] + rp * (*u111)[2];
99 for (dy = 1; dy < nyp; dy += 2) {
100 s = 1. - (sp = dy / ny / 2.);
101 v0[0] = s * v00[0] + sp * v10[0];
102 v0[1] = s * v00[1] + sp * v10[1];
103 v0[2] = s * v00[2] + sp * v10[2];
105 v1[0] = s * v01[0] + sp * v11[0];
106 v1[1] = s * v01[1] + sp * v11[1];
107 v1[2] = s * v01[2] + sp * v11[2];
109 for (dx = 1; dx < nxp; dx += 2) {
110 t = 1. - (tp = dx / nx / 2.);
111 v[0] = t * v0[0] + tp * v1[0];
112 v[1] = t * v0[1] + tp * v1[1];
113 v[2] = t * v0[2] + tp * v1[2];
124 *(doubleBuf + ((int)dz / 2) * nx * ny +
125 ((int)dy / 2) * nx + (int)dx / 2) =
128 *(floatBuf + ((int)dz / 2) * nx * ny +
129 ((int)dy / 2) * nx + (int)dx / 2) =
140 double originNorth,
double originWest,
double originBottom,
141 double vxNorth,
double vxWest,
double vxBottom,
142 double vyNorth,
double vyWest,
double vyBottom,
143 double vzNorth,
double vzWest,
double vzBottom,
144 int nx,
int ny,
int nz,
void *volumeBuf,
int type)
146 double u[2][2][2][3];
148 u[0][0][0][0] = originNorth;
149 u[0][0][0][1] = originWest;
150 u[0][0][0][2] = originBottom;
152 u[0][0][1][0] = vxNorth;
153 u[0][0][1][1] = vxWest;
154 u[0][0][1][2] = vxBottom;
156 u[1][0][0][0] = vzNorth;
157 u[1][0][0][1] = vzWest;
158 u[1][0][0][2] = vzBottom;
160 u[1][0][1][0] = (u[0][0][1][0] - u[0][0][0][0]) + u[1][0][0][0];
161 u[1][0][1][1] = (u[0][0][1][1] - u[0][0][0][1]) + u[1][0][0][1];
162 u[1][0][1][2] = (u[0][0][1][2] - u[0][0][0][2]) + u[1][0][0][2];
164 u[0][1][0][0] = vyNorth;
165 u[0][1][0][1] = vyWest;
166 u[0][1][0][2] = vyBottom;
168 u[0][1][1][0] = (u[0][0][1][0] - u[0][0][0][0]) + u[0][1][0][0];
169 u[0][1][1][1] = (u[0][0][1][1] - u[0][0][0][1]) + u[0][1][0][1];
170 u[0][1][1][2] = (u[0][0][1][2] - u[0][0][0][2]) + u[0][1][0][2];
172 u[1][1][0][0] = (u[1][0][0][0] - u[0][0][0][0]) + u[0][1][0][0];
173 u[1][1][0][1] = (u[1][0][0][1] - u[0][0][0][1]) + u[0][1][0][1];
174 u[1][1][0][2] = (u[1][0][0][2] - u[0][0][0][2]) + u[0][1][0][2];
176 u[1][1][1][0] = (u[1][0][0][0] - u[0][0][0][0]) + u[0][1][1][0];
177 u[1][1][1][1] = (u[1][0][0][1] - u[0][0][0][1]) + u[0][1][1][1];
178 u[1][1][1][2] = (u[1][0][0][2] - u[0][0][0][2]) + u[0][1][1][2];
187 double originNorth,
double originWest,
188 double originBottom,
double lengthNorth,
189 double lengthWest,
double lengthBottom,
int nx,
int ny,
190 int nz,
void *volumeBuf,
int type)
193 originNorth, originWest, originBottom,
194 originNorth + lengthNorth, originWest, originBottom,
195 originNorth, originWest + lengthWest, originBottom,
196 originNorth, originWest, originBottom + lengthBottom,
197 nx, ny, nz, volumeBuf, type);
204 double originNorth,
double originWest,
205 double originBottom,
double lengthNorth,
206 double lengthWest,
double lengthBottom,
int nx,
211 int x, y, z, eltLength;
215 if (volumeBuf ==
NULL)
219 originNorth, originWest, originBottom,
220 lengthNorth, lengthWest, lengthBottom,
223 region.
north = originNorth;
224 region.
south = originNorth + lengthNorth;
225 region.
east = originWest;
226 region.
west = originWest + lengthWest;
227 region.
top = originBottom;
228 region.
bottom = originBottom + lengthBottom;
236 if (mapVolume ==
NULL)
241 for (z = 0; z < nz; z++) {
242 for (y = 0; y < ny; y++) {
243 for (x = 0; x < nx; x++) {
247 (z * ny * nx + y * nx +
251 (
"Rast3d_make_aligned_volume_file: error in Rast3d_put_value");
#define RASTER3D_USE_CACHE_DEFAULT
int Rast3d_put_value(RASTER3D_Map *, int, int, int, const void *, int)
After converting *value of type into the type specified at the initialization time (i...
int Rast3d_file_type_map(RASTER3D_Map *)
Returns the type with which tiles of map are stored on file.
void * Rast3d_malloc(int)
Same as malloc (nBytes), except that in case of error Rast3d_error() is invoked.
int Rast3d_is_valid_location(RASTER3D_Region *, double, double, double)
Returns 1 if region-coordinates (north, east, top) are inside the region of map. Returns 0 otherwise...
int Rast3d_close(RASTER3D_Map *)
Close 3D raster map files.
#define G_incr_void_ptr(ptr, size)
void * Rast3d_open_cell_new(const char *, int, int, RASTER3D_Region *)
Opens new g3d-file with name in the current mapset. Tiles are stored in memory with type which must b...
void Rast3d_get_aligned_volume(void *map, double originNorth, double originWest, double originBottom, double lengthNorth, double lengthWest, double lengthBottom, int nx, int ny, int nz, void *volumeBuf, int type)
float Rast3d_get_float_region(RASTER3D_Map *, int, int, int)
Is equivalent to Rast3d_get_value_region (map, x, y, z, &value, FCELL_TYPE); return value...
void Rast3d_fatal_error(const char *,...) __attribute__((format(printf
void Rast3d_get_volume(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 Rast3d_location2coord2(RASTER3D_Region *, double, double, double, int *, int *, int *)
Converts region-coordinates (north, east, top) into cell-coordinates (x, y, z). This function calls R...
double Rast3d_get_double_region(RASTER3D_Map *, int, int, int)
Is equivalent to Rast3d_get_value_region (map, x, y, z, &value, DCELL_TYPE); return value...
int Rast3d_get_file_type(void)
get G3d file type
void Rast3d_get_volume_a(void *map, double u[2][2][2][3], int nx, int ny, int nz, void *volumeBuf, int type)
void Rast3d_make_aligned_volume_file(void *map, const char *fileName, double originNorth, double originWest, double originBottom, double lengthNorth, double lengthWest, double lengthBottom, int nx, int ny, int nz)
void Rast3d_free(void *)
Same as free (ptr).