[GRASS-SVN] r33381 - grass/trunk/raster/wildfire/r.spread

svn_grass at osgeo.org svn_grass at osgeo.org
Wed Sep 10 08:18:06 EDT 2008


Author: hamish
Date: 2008-09-10 08:18:05 -0400 (Wed, 10 Sep 2008)
New Revision: 33381

Modified:
   grass/trunk/raster/wildfire/r.spread/replaceHa.c
Log:
G_debug(), G_fatal_error() (merge from devbr6)

Modified: grass/trunk/raster/wildfire/r.spread/replaceHa.c
===================================================================
--- grass/trunk/raster/wildfire/r.spread/replaceHa.c	2008-09-10 12:08:08 UTC (rev 33380)
+++ grass/trunk/raster/wildfire/r.spread/replaceHa.c	2008-09-10 12:18:05 UTC (rev 33381)
@@ -11,6 +11,7 @@
  ************************************************************/
 #include <stdio.h>
 #include <stdlib.h>
+#include <grass/gis.h>
 #include "costHa.h"
 #include "local_proto.h"
 
@@ -20,23 +21,23 @@
 {
     long i, smaller_child = 0;
 
-    if (*heap_len < 1) {
-	printf("programming ERROR: can't delete a cell from an ampty list");
-	exit(1);
-    }
+    G_debug(4, "in replaceHa()");
 
+    if (*heap_len < 1)
+	G_fatal_error("Programming ERROR: can't delete a cell from an empty list");
+
     /* 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 (i == 0)
+	G_fatal_error("Programming ERROR: can't find the old_cell from the list");
 
     /* replace this cell, fix the heap */
     /*take care upward */
+
+    G_debug(4, "in replaceHa() before first while");
     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;
@@ -48,17 +49,26 @@
     /*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) &&
+
+
+    G_debug(4, "in replaceHa() before second while. smaller_child=%ld",
+	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++;
@@ -70,5 +80,7 @@
     heap[i].row = row;
     heap[i].col = col;
 
+    G_debug(4, "replaceHa() done");
+
     return;
 }



More information about the grass-commit mailing list