[GRASS-SVN] r33513 - grass/branches/releasebranch_6_3/raster/wildfire/r.spread

svn_grass at osgeo.org svn_grass at osgeo.org
Tue Sep 23 17:10:58 EDT 2008


Author: neteler
Date: 2008-09-23 17:10:57 -0400 (Tue, 23 Sep 2008)
New Revision: 33513

Modified:
   grass/branches/releasebranch_6_3/raster/wildfire/r.spread/replaceHa.c
Log:
applied grass64/tools/grass_indent.sh

Modified: grass/branches/releasebranch_6_3/raster/wildfire/r.spread/replaceHa.c
===================================================================
--- grass/branches/releasebranch_6_3/raster/wildfire/r.spread/replaceHa.c	2008-09-23 21:08:56 UTC (rev 33512)
+++ grass/branches/releasebranch_6_3/raster/wildfire/r.spread/replaceHa.c	2008-09-23 21:10:57 UTC (rev 33513)
@@ -1,3 +1,4 @@
+
 /***********************************************************
  *
  *                 replaceHa.c (for spread)
@@ -15,55 +16,59 @@
 
 void
 replaceHa(float new_min_cost, float angle, int row, int col,
-          struct costHa *heap, long *heap_len)
+	  struct costHa *heap, long *heap_len)
 {
-	long i, smaller_child = 0;
+    long i, smaller_child = 0;
 
-	if (*heap_len < 1) {
-		printf("programming ERROR: can't delete a cell from an ampty list");
-		exit(1);
-	}
-	
-	/* search the cell with row and col from the heap */
-	for (i = *heap_len; i >=0; i--) {
-		    if (heap[i].row == row && heap[i].col == col)
-			break;
-	}
-	if (i == 0) {
-		printf("programming ERROR: can't find the old_cell from the list");
-		exit(1);
-	}
+    if (*heap_len < 1) {
+	printf("programming ERROR: can't delete a cell from an ampty list");
+	exit(1);
+    }
 
-	/* replace this cell, fix the heap */
-	/*take care upward*/
-        while (i > 1 && new_min_cost < heap[i / 2].min_cost) {
-                heap[i].min_cost = heap[i / 2].min_cost;
-                heap[i].angle = heap[i / 2].angle;
-                heap[i].row = heap[i / 2].row;
-                heap[i].col = heap[i / 2].col;
-                i = i / 2;
-        }
+    /* search the cell with row and col from the heap */
+    for (i = *heap_len; i >= 0; i--) {
+	if (heap[i].row == row && heap[i].col == col)
+	    break;
+    }
+    if (i == 0) {
+	printf("programming ERROR: can't find the old_cell from the list");
+	exit(1);
+    }
 
-	/*take care downward*/ 
-	if (2*i <= *heap_len)
-		smaller_child = 2*i;
-	if ((2*i < *heap_len) && (heap[2*i].min_cost > heap[2*i + 1].min_cost))
-		smaller_child++;
-        while ((smaller_child <= *heap_len) && (new_min_cost > heap[smaller_child].min_cost)) {
-                heap[i].min_cost = heap[smaller_child].min_cost;
-                heap[i].angle = heap[smaller_child].angle;
-                heap[i].row = heap[smaller_child].row;
-	        heap[i].col = heap[smaller_child].col;
-                i = smaller_child;
-                smaller_child = 2*i;
-        	if ((2*i < *heap_len) && (heap[2*i].min_cost > heap[2*i + 1].min_cost))                 smaller_child++;
-	}
+    /* replace this cell, fix the heap */
+    /*take care upward */
+    while (i > 1 && new_min_cost < heap[i / 2].min_cost) {
+	heap[i].min_cost = heap[i / 2].min_cost;
+	heap[i].angle = heap[i / 2].angle;
+	heap[i].row = heap[i / 2].row;
+	heap[i].col = heap[i / 2].col;
+	i = i / 2;
+    }
 
-	/*now i is the right position*/	
-	heap[i].min_cost = new_min_cost;
-	heap[i].angle = angle;
- 	heap[i].row = row;
-        heap[i].col = col;
+    /*take care downward */
+    if (2 * i <= *heap_len)
+	smaller_child = 2 * i;
+    if ((2 * i < *heap_len) &&
+	(heap[2 * i].min_cost > heap[2 * i + 1].min_cost))
+	smaller_child++;
+    while ((smaller_child <= *heap_len) &&
+	   (new_min_cost > heap[smaller_child].min_cost)) {
+	heap[i].min_cost = heap[smaller_child].min_cost;
+	heap[i].angle = heap[smaller_child].angle;
+	heap[i].row = heap[smaller_child].row;
+	heap[i].col = heap[smaller_child].col;
+	i = smaller_child;
+	smaller_child = 2 * i;
+	if ((2 * i < *heap_len) &&
+	    (heap[2 * i].min_cost > heap[2 * i + 1].min_cost))
+	    smaller_child++;
+    }
 
-        return;
+    /*now i is the right position */
+    heap[i].min_cost = new_min_cost;
+    heap[i].angle = angle;
+    heap[i].row = row;
+    heap[i].col = col;
+
+    return;
 }



More information about the grass-commit mailing list