Ejemplo n.º 1
0
void
update(struct costHa *pres_cell, int row, int col, double angle,
       float min_cost)
{
    if (DATA(map_out, row, col) < -1.0) {
	G_debug(2, "	insert: out(%d,%d)=%f min_cost=%f", row, col,
		DATA(map_out, row, col), min_cost);
	DATA(map_out, row, col) = min_cost;
	if (x_out)
	    DATA(map_x_out, row, col) = pres_cell->col;
	if (y_out)
	    DATA(map_y_out, row, col) = pres_cell->row;

	insertHa(min_cost, angle, row, col, heap, &heap_len);
#if 0
	if (display && min_cost < init_time + time_lag + 1.0)
	    draw_a_burning_cell(row, col);
#endif
    }
    else {
	if (DATA(map_out, row, col) > min_cost + 0.001) {
	    G_debug(2, "	replace: out(%d,%d)=%f min_cost=%f", row, col,
		    DATA(map_out, row, col), min_cost);
	    DATA(map_out, row, col) = min_cost;
	    if (x_out)
		DATA(map_x_out, row, col) = pres_cell->col;
	    if (y_out)
		DATA(map_y_out, row, col) = pres_cell->row;

	    replaceHa(min_cost, angle, row, col, heap, &heap_len);
#if 0
	    if (display && min_cost < init_time + time_lag + 1.0)
		draw_a_burning_cell(row, col);
#endif
	}
    }
}
Ejemplo n.º 2
0
void collect_ori(int start_fd)
{
    extern CELL *cell;
    extern CELL *map_base, *map_x_out, *map_y_out, *map_visit;
    extern float *map_out;
    extern char buf[];
    extern float neg, zero;
    extern int BARRIER;
    extern int nrows, ncols;
    extern long heap_len;
    extern struct costHa *heap;
    int row, col;

    for (row = 0; row < nrows; row++) {
	G_percent(row, nrows, 2);

	Rast_get_c_row(start_fd, cell, row);

	for (col = 0; col < ncols; col++) {
	    if (*(cell + col) > 0) {
		/*Check if starting sources legally ? */
		if (DATA(map_base, row, col) <= 0) {
		    G_warning("Can't start from a BARRIER at cell (%d,%d), request ignored",
			    col, row);
		    continue;
		}

		DATA(map_out, row, col) = (float)init_time;
		insertHa((float)init_time, zero, row, col, heap, &heap_len);
		/*mark it to avoid redundant computing */
		DATA(map_visit, row, col) = 1;

		if (x_out)
		    DATA(map_x_out, row, col) = col;
		if (y_out)
		    DATA(map_y_out, row, col) = row;
		G_debug(4, "origin: row=%d col=%d", row, col);
#if 0
		if (display)
		    draw_a_burning_cell(row, col);
#endif
	    }
	    else {
		DATA(map_out, row, col) = neg;
		DATA(map_visit, row, col) = BARRIER;
	    }
	}
    }

    G_percent(row, nrows, 2);

#ifdef DEBUG
    {
	int i;

	printf("\nheap_len=%d  ", heap_len);
	for (i = 1; i <= heap_len; i++)
	    printf("(%d,%d) ", heap[i].row, heap[i].col);
    }
#endif
}