[GRASS-SVN] r61533 - grass-addons/grass7/raster3d/r3.flow
svn_grass at osgeo.org
svn_grass at osgeo.org
Tue Aug 5 11:48:33 PDT 2014
Author: annakrat
Date: 2014-08-05 11:48:33 -0700 (Tue, 05 Aug 2014)
New Revision: 61533
Removed:
grass-addons/grass7/raster3d/r3.flow/gradient.c
grass-addons/grass7/raster3d/r3.flow/gradient.h
Modified:
grass-addons/grass7/raster3d/r3.flow/interpolate.c
grass-addons/grass7/raster3d/r3.flow/r3flow_structs.h
Log:
r3.flow: update after changes in library
Deleted: grass-addons/grass7/raster3d/r3.flow/gradient.c
===================================================================
--- grass-addons/grass7/raster3d/r3.flow/gradient.c 2014-08-05 18:43:31 UTC (rev 61532)
+++ grass-addons/grass7/raster3d/r3.flow/gradient.c 2014-08-05 18:48:33 UTC (rev 61533)
@@ -1,84 +0,0 @@
-/*!
- \file gradient.c
-
- \brief Gradient computation
-
- Gradient computation (second order approximation)
- using central differencing scheme (plus forward and backward
- difference of second order approx.)
-
- (C) 2014 by the GRASS Development Team
-
- This program is free software under the GNU General Public
- License (>=v2). Read the file COPYING that comes with GRASS
- for details.
-
- \author Anna Petrasova
- */
-#include "r3flow_structs.h"
-
-void gradient(struct Array *array, double *step,
- struct Array *grad_x, struct Array *grad_y,
- struct Array *grad_z)
-{
- int col, row, depth;
-
- for (depth = 0; depth < array->sz; depth++) {
- for (row = 0; row < array->sy; row++) {
- ACCESS(grad_x, 0, row, depth) =
- (-3 * ACCESS(array, 0, row, depth) +
- 4 * ACCESS(array, 1, row, depth) -
- ACCESS(array, 2, row, depth)) / (2 * step[0]);
-
- ACCESS(grad_x, array->sx - 1, row, depth) =
- (3 * ACCESS(array, array->sx - 1, row, depth) -
- 4 * ACCESS(array, array->sx - 2, row, depth) +
- ACCESS(array, array->sx - 3, row, depth)) / (2 * step[0]);
-
- for (col = 1; col < array->sx - 1; col++) {
- ACCESS(grad_x, col, row, depth) =
- (ACCESS(array, col + 1, row, depth) -
- ACCESS(array, col - 1, row, depth)) / (2 * step[0]);
- }
- }
- }
- for (depth = 0; depth < array->sz; depth++) {
- for (col = 0; col < array->sx; col++) {
- ACCESS(grad_y, col, 0, depth) =
- -(-3 * ACCESS(array, col, 0, depth) +
- 4 * ACCESS(array, col, 1, depth) -
- ACCESS(array, col, 2, depth)) / (2 * step[1]);
-
- ACCESS(grad_y, col, array->sy - 1, depth) =
- -(3 * ACCESS(array, col, array->sy - 1, depth) -
- 4 * ACCESS(array, col, array->sy - 2, depth) +
- ACCESS(array, col, array->sy - 3, depth)) / (2 * step[1]);
-
- for (row = 1; row < array->sy - 1; row++) {
- /* is minus here? */
- ACCESS(grad_y, col, row, depth) =
- -(ACCESS(array, col, row + 1, depth) -
- ACCESS(array, col, row - 1, depth)) / (2 * step[1]);
- }
- }
- }
- for (row = 0; row < array->sy; row++) {
- for (col = 0; col < array->sx; col++) {
- ACCESS(grad_z, col, row, 0) =
- (-3 * ACCESS(array, col, row, 0) +
- 4 * ACCESS(array, col, row, 1) -
- ACCESS(array, col, row, 2)) / (2 * step[2]);
-
- ACCESS(grad_z, col, row, array->sz - 1) =
- (3 * ACCESS(array, col, row, array->sz - 1) -
- 4 * ACCESS(array, col, row, array->sz - 2) +
- ACCESS(array, col, row, array->sz - 3)) / (2 * step[2]);
-
- for (depth = 1; depth < array->sz - 1; depth++) {
- ACCESS(grad_z, col, row, depth) =
- (ACCESS(array, col, row, depth + 1) -
- ACCESS(array, col, row, depth - 1)) / (2 * step[2]);
- }
- }
- }
-}
Deleted: grass-addons/grass7/raster3d/r3.flow/gradient.h
===================================================================
--- grass-addons/grass7/raster3d/r3.flow/gradient.h 2014-08-05 18:43:31 UTC (rev 61532)
+++ grass-addons/grass7/raster3d/r3.flow/gradient.h 2014-08-05 18:48:33 UTC (rev 61533)
@@ -1,9 +0,0 @@
-#ifndef GRADIENT_H
-#define GRADIENT_H
-
-#include "r3flow_structs.h"
-
-void gradient(struct Array *array, double *step,
- struct Array *grad_x, struct Array *grad_y,
- struct Array *grad_z);
-#endif // GRADIENT_H
Modified: grass-addons/grass7/raster3d/r3.flow/interpolate.c
===================================================================
--- grass-addons/grass7/raster3d/r3.flow/interpolate.c 2014-08-05 18:43:31 UTC (rev 61532)
+++ grass-addons/grass7/raster3d/r3.flow/interpolate.c 2014-08-05 18:48:33 UTC (rev 61533)
@@ -16,7 +16,6 @@
#include <grass/raster3d.h>
#include "r3flow_structs.h"
-#include "gradient.h"
/*!
\brief Finds 8 nearest voxels from a point.
@@ -208,9 +207,9 @@
double rel_x, rel_y, rel_z;
double scalar_map_array[64];
double grad_x_map_array[64], grad_y_map_array[64], grad_z_map_array[64];
- struct Array array;
- struct Array grad_x, grad_y, grad_z;
- struct Array *grad_xyz[3];
+ RASTER3D_Array_double array;
+ RASTER3D_Array_double grad_x, grad_y, grad_z;
+ RASTER3D_Array_double *grad_xyz[3];
double step[3];
double interpolated[3];
@@ -298,7 +297,7 @@
/* get the 4x4x4 block of the array */
Rast3d_get_block(gradient_info->scalar_map, minx, miny, minz,
4, 4, 4, array.array, DCELL_TYPE);
- gradient(&array, step, &grad_x, &grad_y, &grad_z);
+ Rast3d_gradient_double(&array, step, &grad_x, &grad_y, &grad_z);
grad_xyz[0] = &grad_x;
grad_xyz[1] = &grad_y;
grad_xyz[2] = &grad_z;
@@ -316,8 +315,8 @@
0;
else
gradient_info->neighbors_values[i * 8 + count] =
- ACCESS(grad_xyz[i], c + xshift, r + yshift,
- d + zshift);
+ RASTER3D_ARRAY_ACCESS(grad_xyz[i], c + xshift,
+ r + yshift, d + zshift);
count++;
}
}
Modified: grass-addons/grass7/raster3d/r3.flow/r3flow_structs.h
===================================================================
--- grass-addons/grass7/raster3d/r3.flow/r3flow_structs.h 2014-08-05 18:43:31 UTC (rev 61532)
+++ grass-addons/grass7/raster3d/r3.flow/r3flow_structs.h 2014-08-05 18:48:33 UTC (rev 61533)
@@ -27,14 +27,6 @@
double min_step;
};
-struct Array
-{
- double *array;
- int sx;
- int sy;
- int sz;
-};
-
struct Gradient_info
{
int compute_gradient;
@@ -45,6 +37,4 @@
int initialized;
};
-#define ACCESS(arr, x, y, z) ((arr)->array[(arr)->sx * (arr)->sy * (z) + (arr)->sx * (y) + (x)])
-
#endif // R3FLOW_STRUCTS_H
More information about the grass-commit
mailing list