[GRASS-SVN] r61264 - grass-addons/grass7/raster3d/r3.flow
svn_grass at osgeo.org
svn_grass at osgeo.org
Wed Jul 16 10:31:15 PDT 2014
Author: annakrat
Date: 2014-07-16 10:31:15 -0700 (Wed, 16 Jul 2014)
New Revision: 61264
Modified:
grass-addons/grass7/raster3d/r3.flow/flowline.c
grass-addons/grass7/raster3d/r3.flow/voxel_traversal.c
Log:
r3.flow: fix flowaccumulation computation
Modified: grass-addons/grass7/raster3d/r3.flow/flowline.c
===================================================================
--- grass-addons/grass7/raster3d/r3.flow/flowline.c 2014-07-16 15:57:30 UTC (rev 61263)
+++ grass-addons/grass7/raster3d/r3.flow/flowline.c 2014-07-16 17:31:15 UTC (rev 61264)
@@ -98,19 +98,22 @@
if (!(last_col == col && last_row == row && last_depth == depth)) {
value = Rast3d_get_float(flowacc, col, row, depth);
Rast3d_put_float(flowacc, col, row, depth, value + 1);
- coor_diff = (fabs(last_col - col) + fabs(last_row - row) + fabs(last_row - row));
- /* if not run for the 1. time and previous and next point coordinates
+ if (last_col >= 0) {
+ coor_diff = (abs(last_col - col) + abs(last_row - row) +
+ abs(last_depth - depth));
+ /* if not run for the 1. time and previous and next point coordinates
differ by more than 1 voxel coordinate */
- if (last_col >= 0 && coor_diff > 1) {
- traverse(region, point, new_point, trav_coords, &size, &trav_count);
- for (j = 0; j < trav_count; j++) {
- value = Rast3d_get_float(flowacc, trav_coords[3 * j + 0],
- trav_coords[3 * j + 1],
- trav_coords[3 * j + 2]);
- Rast3d_put_float(flowacc, trav_coords[3 * j + 0],
- trav_coords[3 * j + 1],
- trav_coords[3 * j + 2],
- value + 1);
+ if (coor_diff > 1) {
+ traverse(region, point, new_point, trav_coords, &size, &trav_count);
+ for (j = 0; j < trav_count; j++) {
+ value = Rast3d_get_float(flowacc, trav_coords[3 * j + 0],
+ trav_coords[3 * j + 1],
+ trav_coords[3 * j + 2]);
+ Rast3d_put_float(flowacc, trav_coords[3 * j + 0],
+ trav_coords[3 * j + 1],
+ trav_coords[3 * j + 2],
+ value + 1);
+ }
}
}
last_col = col;
Modified: grass-addons/grass7/raster3d/r3.flow/voxel_traversal.c
===================================================================
--- grass-addons/grass7/raster3d/r3.flow/voxel_traversal.c 2014-07-16 15:57:30 UTC (rev 61263)
+++ grass-addons/grass7/raster3d/r3.flow/voxel_traversal.c 2014-07-16 17:31:15 UTC (rev 61264)
@@ -5,7 +5,7 @@
int *coordinates, int *size, int *coor_count)
{
double dx, dy, dz;
- double step_x, step_y, step_z;
+ int step_x, step_y, step_z;
int x, y, z;
int x_end, y_end, z_end;
double t_delta_x, t_delta_y, t_delta_z;
@@ -72,10 +72,6 @@
z = z + step_z;
}
}
- coordinates[count * 3 + 0] = x;
- coordinates[count * 3 + 1] = region->rows - y - 1;
- coordinates[count * 3 + 2] = z;
- count++;
if ((x == x_end && y == y_end && z == z_end) ||
/* just to make sure it breaks */
(step_x * (x - x_end) > 0 || step_y * (y - y_end) > 0 ||
@@ -83,6 +79,11 @@
break;
+ coordinates[count * 3 + 0] = x;
+ coordinates[count * 3 + 1] = region->rows - y - 1;
+ coordinates[count * 3 + 2] = z;
+ count++;
+
/* reallocation for cases when the steps would be too big */
if (*size <= count) {
*size = 2 * (*size);
More information about the grass-commit
mailing list