[GRASS-SVN] r42876 - in grass/trunk: display/d.rast.num imagery/i.atcorr imagery/i.ifft imagery/i.rectify include lib/raster lib/rst/interp_float raster/r.coin raster/r.flow raster/r.horizon raster/r.proj raster/r.random.cells raster/r.resamp.filter raster/r.resamp.interp raster/r.resamp.stats raster/simwe/simlib

svn_grass at osgeo.org svn_grass at osgeo.org
Thu Jul 22 01:46:00 EDT 2010


Author: glynn
Date: 2010-07-22 05:46:00 +0000 (Thu, 22 Jul 2010)
New Revision: 42876

Modified:
   grass/trunk/display/d.rast.num/main.c
   grass/trunk/imagery/i.atcorr/main.cpp
   grass/trunk/imagery/i.ifft/main.c
   grass/trunk/imagery/i.rectify/rectify.c
   grass/trunk/imagery/i.rectify/write.c
   grass/trunk/include/rasterdefs.h
   grass/trunk/lib/raster/alloc_cell.c
   grass/trunk/lib/raster/closecell.c
   grass/trunk/lib/raster/get_row.c
   grass/trunk/lib/raster/set_window.c
   grass/trunk/lib/raster/zero_cell.c
   grass/trunk/lib/rst/interp_float/output2d.c
   grass/trunk/lib/rst/interp_float/resout2d.c
   grass/trunk/raster/r.coin/main.c
   grass/trunk/raster/r.flow/io.c
   grass/trunk/raster/r.horizon/main.c
   grass/trunk/raster/r.proj/main.c
   grass/trunk/raster/r.proj/readcell.c
   grass/trunk/raster/r.random.cells/init.c
   grass/trunk/raster/r.resamp.filter/main.c
   grass/trunk/raster/r.resamp.interp/main.c
   grass/trunk/raster/r.resamp.stats/main.c
   grass/trunk/raster/simwe/simlib/output.c
Log:
Implement split window


Modified: grass/trunk/display/d.rast.num/main.c
===================================================================
--- grass/trunk/display/d.rast.num/main.c	2010-07-21 21:10:11 UTC (rev 42875)
+++ grass/trunk/display/d.rast.num/main.c	2010-07-22 05:46:00 UTC (rev 42876)
@@ -126,12 +126,6 @@
     else
 	fixed_color = 1;
 
-    layer_fd = Rast_open_old(map_name, "");
-
-    /* determine the inputmap type (CELL/FCELL/DCELL) */
-    inmap_type = Rast_get_map_type(layer_fd);
-    map_type = DCELL_TYPE;
-
     /* Read in the map window associated with window */
 
     G_get_window(&window);
@@ -169,6 +163,12 @@
 	r = ncols;
     }
 
+    layer_fd = Rast_open_old(map_name, "");
+
+    /* determine the inputmap type (CELL/FCELL/DCELL) */
+    inmap_type = Rast_get_map_type(layer_fd);
+    map_type = DCELL_TYPE;
+
     /* number of rows and cols in window */
 
     if ((nrows > 75) || (ncols > 75)) {

Modified: grass/trunk/imagery/i.atcorr/main.cpp
===================================================================
--- grass/trunk/imagery/i.atcorr/main.cpp	2010-07-21 21:10:11 UTC (rev 42875)
+++ grass/trunk/imagery/i.atcorr/main.cpp	2010-07-22 05:46:00 UTC (rev 42876)
@@ -77,7 +77,7 @@
 int mis = 0;
 
 /* function prototypes */
-static void adjust_region (char *, const char *);
+static void adjust_region (const char *);
 static CELL round_c (FCELL);
 static void write_fp_to_cell (int, FCELL *);
 static void process_raster (int, InputMask, ScaleRange, int, int, int, bool, ScaleRange, bool);
@@ -92,11 +92,11 @@
    Atmospheric corrections should be done on the whole
    satelite image, not just portions.
 */
-static void adjust_region (char *name, const char *mapset)
+static void adjust_region (const char *name)
 {
     struct Cell_head iimg_head;	/* the input image header file */
 
-    Rast_get_cellhd(name, mapset, &iimg_head);
+    Rast_get_cellhd(name, "", &iimg_head);
 
     Rast_set_window(&iimg_head);
 }
@@ -409,11 +409,11 @@
 
 
 /* Copy the colors from map named iname to the map named oname */
-static void copy_colors (char *iname, const char *imapset, char *oname)
+static void copy_colors (const char *iname, char *oname)
 {
     struct Colors colors;
 
-    Rast_read_colors(iname, imapset, &colors);
+    Rast_read_colors(iname, "", &colors);
     Rast_write_colors(oname, G_mapset(), &colors);
 }
 
@@ -564,7 +564,6 @@
     int oimg_fd;	        /* output image's file descriptor */
     int ialt_fd = -1;       /* input elevation map's file descriptor */
     int ivis_fd = -1;       /* input visibility map's file descriptor */
-    const char *iimg_mapset, *ialt_mapset, *iviz_mapset;
     struct History hist;
     
     /* Define module */
@@ -578,29 +577,23 @@
     if (G_parser(argc, argv) < 0)
 	exit (EXIT_FAILURE);
 
+    adjust_region(opts.iimg->answer);
+
     /* open input raster */
-    if ( (iimg_mapset = G_find_raster2 ( opts.iimg->answer, "") ) == NULL )
-	G_fatal_error ( _("Raster map <%s> not found"), opts.iimg->answer);
-    if((iimg_fd = Rast_open_old(opts.iimg->answer, iimg_mapset)) < 0)
+    if((iimg_fd = Rast_open_old(opts.iimg->answer, "")) < 0)
 	G_fatal_error (_("Unable to open raster map <%s>"),
-		       G_fully_qualified_name(opts.iimg->answer, iimg_mapset));
-
-    adjust_region(opts.iimg->answer, iimg_mapset);
+		       opts.iimg->answer);
         
     if(opts.ialt->answer) {
-	if ( (ialt_mapset = G_find_raster2 ( opts.ialt->answer, "") ) == NULL )
-	    G_fatal_error ( _("Raster map <%s> not found"), opts.ialt->answer);
-	if((ialt_fd = Rast_open_old(opts.ialt->answer, ialt_mapset)) < 0)
+	if((ialt_fd = Rast_open_old(opts.ialt->answer, "")) < 0)
             G_fatal_error (_("Unable to open raster map <%s>"),
-			   G_fully_qualified_name(opts.ialt->answer, ialt_mapset));
+			   opts.ialt->answer);
     }
 
     if(opts.ivis->answer) {
-	if ( (iviz_mapset = G_find_raster2 ( opts.ivis->answer, "") ) == NULL )
-	    G_fatal_error ( _("Raster map <%s> not found"), opts.ivis->answer);
-	if((ivis_fd = Rast_open_old(opts.ivis->answer, iviz_mapset)) < 0)
+	if((ivis_fd = Rast_open_old(opts.ivis->answer, "")) < 0)
             G_fatal_error (_("Unable to open raster map <%s>"),
-			   G_fully_qualified_name(opts.ivis->answer, iviz_mapset));
+			   opts.ivis->answer);
     }
                 
     /* open a floating point raster or not? */
@@ -648,7 +641,7 @@
 
     /* Copy the colors of the input raster to the output raster.
        Scaling is ignored and color ranges might not be correct. */
-    copy_colors(opts.iimg->answer, iimg_mapset, opts.oimg->answer);
+    copy_colors(opts.iimg->answer, opts.oimg->answer);
 
     exit (EXIT_SUCCESS);
 }

Modified: grass/trunk/imagery/i.ifft/main.c
===================================================================
--- grass/trunk/imagery/i.ifft/main.c	2010-07-21 21:10:11 UTC (rev 42875)
+++ grass/trunk/imagery/i.ifft/main.c	2010-07-22 05:46:00 UTC (rev 42876)
@@ -100,10 +100,6 @@
     Cellmap_imag = opt.imag->answer;
     Cellmap_orig = opt.orig->answer;
 
-    /* open input raster map */
-    realfd = Rast_open_old(Cellmap_real, "");
-    imagfd = Rast_open_old(Cellmap_imag, "");
-
     /* get and compare the original window data */
     Rast_get_cellhd(Cellmap_real, "", &realhead);
     Rast_get_cellhd(Cellmap_imag, "", &imaghead);
@@ -120,6 +116,10 @@
 
     Rast_set_window(&realhead);	/* set the window to the whole cell map */
 
+    /* open input raster map */
+    realfd = Rast_open_old(Cellmap_real, "");
+    imagfd = Rast_open_old(Cellmap_imag, "");
+
     /* get the rows and columns in the current window */
     rows = Rast_window_rows();
     cols = Rast_window_cols();

Modified: grass/trunk/imagery/i.rectify/rectify.c
===================================================================
--- grass/trunk/imagery/i.rectify/rectify.c	2010-07-21 21:10:11 UTC (rev 42875)
+++ grass/trunk/imagery/i.rectify/rectify.c	2010-07-22 05:46:00 UTC (rev 42876)
@@ -32,14 +32,13 @@
      */
 
     select_target_env();
-    Rast_set_window(&target_window);
     Rast_set_cell_format(cellhd.format);
     select_current_env();
 
     /* open the file to be rectified
      * set window to cellhd first to be able to read file exactly
      */
-    Rast_set_window(&cellhd);
+    Rast_set_input_window(&cellhd);
     infd = Rast_open_old(name, mapset);
     map_type = Rast_get_map_type(infd);
     rast = (void *)G_calloc(Rast_window_cols() + 1, Rast_cell_size(map_type));

Modified: grass/trunk/imagery/i.rectify/write.c
===================================================================
--- grass/trunk/imagery/i.rectify/write.c	2010-07-21 21:10:11 UTC (rev 42875)
+++ grass/trunk/imagery/i.rectify/write.c	2010-07-22 05:46:00 UTC (rev 42876)
@@ -41,7 +41,7 @@
     int fd, row;
     void *rast;
 
-    Rast_set_window(&target_window);
+    Rast_set_output_window(&target_window);
 
     rast = Rast_allocate_buf(map_type);
     close(temp_fd);

Modified: grass/trunk/include/rasterdefs.h
===================================================================
--- grass/trunk/include/rasterdefs.h	2010-07-21 21:10:11 UTC (rev 42875)
+++ grass/trunk/include/rasterdefs.h	2010-07-22 05:46:00 UTC (rev 42876)
@@ -18,6 +18,18 @@
 unsigned char *Rast__allocate_null_bits(int);
 int Rast__null_bitstream_size(int);
 
+void *Rast_allocate_input_buf(RASTER_MAP_TYPE);
+CELL *Rast_allocate_c_input_buf(void);
+FCELL *Rast_allocate_f_input_buf(void);
+DCELL *Rast_allocate_d_input_buf(void);
+char *Rast_allocate_null_input_buf(void);
+
+void *Rast_allocate_output_buf(RASTER_MAP_TYPE);
+CELL *Rast_allocate_c_output_buf(void);
+FCELL *Rast_allocate_f_output_buf(void);
+DCELL *Rast_allocate_d_output_buf(void);
+char *Rast_allocate_null_output_buf(void);
+
 /* auto_mask.c */
 int Rast__check_for_auto_masking(void);
 void Rast_suppress_masking(void);
@@ -556,7 +568,8 @@
 int Rast_row_repeat_nomask(int, int);
 
 /* zero_cell.c */
-void Rast_zero_c_buf(CELL *);
 void Rast_zero_buf(void *, RASTER_MAP_TYPE);
+void Rast_zero_input_buf(void *, RASTER_MAP_TYPE);
+void Rast_zero_output_buf(void *, RASTER_MAP_TYPE);
 
 #endif /* GRASS_RASTERDEFS_H */

Modified: grass/trunk/lib/raster/alloc_cell.c
===================================================================
--- grass/trunk/lib/raster/alloc_cell.c	2010-07-21 21:10:11 UTC (rev 42875)
+++ grass/trunk/lib/raster/alloc_cell.c	2010-07-22 05:46:00 UTC (rev 42876)
@@ -153,3 +153,54 @@
 
     return (cols + 7) / 8;
 }
+
+void *Rast_allocate_input_buf(RASTER_MAP_TYPE data_type)
+{
+    return G_calloc(Rast_input_window_cols() + 1, Rast_cell_size(data_type));
+}
+
+CELL *Rast_allocate_c_input_buf(void)
+{
+    return (CELL *) G_calloc(Rast_input_window_cols() + 1, sizeof(CELL));
+}
+
+FCELL *Rast_allocate_f_input_buf(void)
+{
+    return (FCELL *) G_calloc(Rast_input_window_cols() + 1, sizeof(FCELL));
+}
+
+DCELL *Rast_allocate_d_input_buf(void)
+{
+    return (DCELL *) G_calloc(Rast_input_window_cols() + 1, sizeof(DCELL));
+}
+
+char *Rast_allocate_null_input_buf(void)
+{
+    return (char *)G_calloc(Rast_input_window_cols() + 1, sizeof(char));
+}
+
+
+void *Rast_allocate_output_buf(RASTER_MAP_TYPE data_type)
+{
+    return G_calloc(Rast_output_window_cols() + 1, Rast_cell_size(data_type));
+}
+
+CELL *Rast_allocate_c_output_buf(void)
+{
+    return (CELL *) G_calloc(Rast_output_window_cols() + 1, sizeof(CELL));
+}
+
+FCELL *Rast_allocate_f_output_buf(void)
+{
+    return (FCELL *) G_calloc(Rast_output_window_cols() + 1, sizeof(FCELL));
+}
+
+DCELL *Rast_allocate_d_output_buf(void)
+{
+    return (DCELL *) G_calloc(Rast_output_window_cols() + 1, sizeof(DCELL));
+}
+
+char *Rast_allocate_null_output_buf(void)
+{
+    return (char *)G_calloc(Rast_output_window_cols() + 1, sizeof(char));
+}

Modified: grass/trunk/lib/raster/closecell.c
===================================================================
--- grass/trunk/lib/raster/closecell.c	2010-07-21 21:10:11 UTC (rev 42875)
+++ grass/trunk/lib/raster/closecell.c	2010-07-22 05:46:00 UTC (rev 42876)
@@ -266,7 +266,7 @@
 	if (fcb->cur_row < fcb->cellhd.rows) {
 	    int row;
 
-	    Rast_zero_buf(fcb->data, fcb->map_type);
+	    Rast_zero_output_buf(fcb->data, fcb->map_type);
 	    for (row = fcb->cur_row; row < fcb->cellhd.rows; row++)
 		Rast_put_row(fd, fcb->data, fcb->map_type);
 	    G_free(fcb->data);
@@ -357,7 +357,7 @@
 	}
 
 	if (fcb->cur_row < fcb->cellhd.rows) {
-	    Rast_zero_buf(fcb->data, fcb->map_type);
+	    Rast_zero_output_buf(fcb->data, fcb->map_type);
 	    for (row = fcb->cur_row; row < fcb->cellhd.rows; row++)
 		Rast_put_row(fd, fcb->data, fcb->map_type);
 	    G_free(fcb->data);

Modified: grass/trunk/lib/raster/get_row.c
===================================================================
--- grass/trunk/lib/raster/get_row.c	2010-07-21 21:10:11 UTC (rev 42875)
+++ grass/trunk/lib/raster/get_row.c	2010-07-22 05:46:00 UTC (rev 42876)
@@ -588,7 +588,7 @@
 
     if (!row_status) {
 	fcb->cur_row = -1;
-	Rast_zero_buf(rast, data_type);
+	Rast_zero_input_buf(rast, data_type);
 	return 0;
     }
 

Modified: grass/trunk/lib/raster/set_window.c
===================================================================
--- grass/trunk/lib/raster/set_window.c	2010-07-21 21:10:11 UTC (rev 42875)
+++ grass/trunk/lib/raster/set_window.c	2010-07-22 05:46:00 UTC (rev 42876)
@@ -19,6 +19,7 @@
 #include "R.h"
 
 static void update_window_mappings(void);
+static void check_write_window(void);
 
 void Rast__init_window(void)
 {
@@ -29,6 +30,7 @@
 
     R__.rd_window = G__.window;
     R__.wr_window = G__.window;
+    R__.split_window = 0;
 
     G_initialize_done(&R__.window_set);
 }
@@ -45,6 +47,8 @@
     if (R__.split_window)
 	G_warning(_("Rast_set_window() called while window split"));
 
+    check_write_window();
+
     G_adjust_Cell_head(window, 0, 0);
 
     R__.wr_window = *window;
@@ -63,6 +67,8 @@
 {
     Rast__init();
 
+    check_write_window();
+
     G_adjust_Cell_head(window, 0, 0);
 
     R__.wr_window = *window;
@@ -140,11 +146,26 @@
 	    fcb->open_mode != OPEN_NEW_COMPRESSED)
 	    continue;
 
-	if (fcb->open_mode == OPEN_OLD)
+	if (fcb->open_mode == OPEN_OLD) {
+	    G_fatal_error(_("Input window changed while maps are open for read"));
 	    Rast__create_window_mapping(i);
+	}
     }
 
     /* turn masking (back) on if necessary */
     Rast__check_for_auto_masking();
 }
 
+static void check_write_window(void)
+{
+    int i;
+
+    for (i = 0; i < R__.fileinfo_count; i++) {
+	struct fileinfo *fcb = &R__.fileinfo[i];
+
+	if (fcb->open_mode == OPEN_NEW_UNCOMPRESSED ||
+	    fcb->open_mode == OPEN_NEW_COMPRESSED)
+	    G_fatal_error(_("Output window changed while maps are open for write"));
+    }
+}
+

Modified: grass/trunk/lib/raster/zero_cell.c
===================================================================
--- grass/trunk/lib/raster/zero_cell.c	2010-07-21 21:10:11 UTC (rev 42875)
+++ grass/trunk/lib/raster/zero_cell.c	2010-07-22 05:46:00 UTC (rev 42876)
@@ -16,24 +16,6 @@
 #include <grass/raster.h>
 
 /*!
- * \brief Zero a raster CELL buffer.
- *
- * This routines assigns each member of the raster buffer array
- * <i>buf</i> to zero. It assumes that <i>buf</i> has been allocated
- * using Rast_allocate_c_buf().
- *
- * \param buf data buffer
- */
-
-void Rast_zero_c_buf(CELL * buf)
-{
-    int i = Rast_window_cols();
-
-    while (i--)
-	*buf++ = 0;
-}
-
-/*!
  * \brief Zero a raster buffer.
  *
  * This routines assigns each member of the raster buffer array
@@ -47,3 +29,13 @@
 {
     memset(rast, 0, Rast_window_cols() * Rast_cell_size(data_type));
 }
+
+void Rast_zero_input_buf(void *rast, RASTER_MAP_TYPE data_type)
+{
+    memset(rast, 0, Rast_input_window_cols() * Rast_cell_size(data_type));
+}
+
+void Rast_zero_output_buf(void *rast, RASTER_MAP_TYPE data_type)
+{
+    memset(rast, 0, Rast_output_window_cols() * Rast_cell_size(data_type));
+}

Modified: grass/trunk/lib/rst/interp_float/output2d.c
===================================================================
--- grass/trunk/lib/rst/interp_float/output2d.c	2010-07-21 21:10:11 UTC (rev 42875)
+++ grass/trunk/lib/rst/interp_float/output2d.c	2010-07-22 05:46:00 UTC (rev 42876)
@@ -76,6 +76,8 @@
 	     || (params->mcurv != NULL));
     cond1 = ((params->slope != NULL) || (params->aspect != NULL) || cond2);
 
+    Rast_set_window(cellhd);
+
     cell1 = Rast_allocate_f_buf();
 
     /*
@@ -113,20 +115,6 @@
 	return -1;
     }
 
-    Rast_set_window(cellhd);
-
-    if (nrows != Rast_window_rows()) {
-	G_warning(_("Rows changed from %d to %d"), nrows,
-		  Rast_window_rows());
-	return -1;
-    }
-
-    if (ncols != Rast_window_cols()) {
-	G_warning(_("Cols changed from %d to %d"), ncols,
-		  Rast_window_cols());
-	return -1;
-    }
-
     if (params->elev != NULL) {
 	G_fseek(params->Tmp_fd_z, 0L, 0);	/* seek to the beginning */
 	for (i = 0; i < params->nsizr; i++) {

Modified: grass/trunk/lib/rst/interp_float/resout2d.c
===================================================================
--- grass/trunk/lib/rst/interp_float/resout2d.c	2010-07-21 21:10:11 UTC (rev 42875)
+++ grass/trunk/lib/rst/interp_float/resout2d.c	2010-07-22 05:46:00 UTC (rev 42876)
@@ -75,7 +75,7 @@
 
     /* change region to output cell file region */
     G_verbose_message(_("Temporarily changing the region to desired resolution..."));
-    Rast_set_window(outhd);
+    Rast_set_output_window(outhd);
     mapset = G_mapset();
 
     cell1 = Rast_allocate_f_buf();
@@ -456,7 +456,7 @@
 
 /* change region to initial region */
     G_verbose_message(_("Changing the region back to initial..."));
-    Rast_set_window(winhd);
+    Rast_set_output_window(winhd);
 
     return 1;
 }

Modified: grass/trunk/raster/r.coin/main.c
===================================================================
--- grass/trunk/raster/r.coin/main.c	2010-07-21 21:10:11 UTC (rev 42875)
+++ grass/trunk/raster/r.coin/main.c	2010-07-22 05:46:00 UTC (rev 42876)
@@ -105,7 +105,7 @@
     window.rows = 1;
     window.cols = 1;
     G_adjust_Cell_head(&window, 1, 1);
-    Rast_set_window(&window);
+    G_set_window(&window);
 
     G_begin_cell_area_calculations();
     window_area = G_area_of_cell_at_row(0);

Modified: grass/trunk/raster/r.flow/io.c
===================================================================
--- grass/trunk/raster/r.flow/io.c	2010-07-21 21:10:11 UTC (rev 42875)
+++ grass/trunk/raster/r.flow/io.c	2010-07-22 05:46:00 UTC (rev 42876)
@@ -199,7 +199,7 @@
     struct Colors colors;
     CELL val1, val2;
 
-    Rast_set_window(&region);
+    Rast_set_output_window(&region);
 
     G_message(_("Writing density file"));
     dsfd = Rast_open_new(parm.dsout, DCELL_TYPE);

Modified: grass/trunk/raster/r.horizon/main.c
===================================================================
--- grass/trunk/raster/r.horizon/main.c	2010-07-21 21:10:11 UTC (rev 42875)
+++ grass/trunk/raster/r.horizon/main.c	2010-07-22 05:46:00 UTC (rev 42876)
@@ -500,8 +500,6 @@
 	      (int)(wbufferZone / stepx), (int)(sbufferZone / stepy),
 	      (int)(nbufferZone / stepy));
 
-    Rast_set_window(&cellhd);
-
     exit(EXIT_SUCCESS);
 }
 

Modified: grass/trunk/raster/r.proj/main.c
===================================================================
--- grass/trunk/raster/r.proj/main.c	2010-07-21 21:10:11 UTC (rev 42875)
+++ grass/trunk/raster/r.proj/main.c	2010-07-22 05:46:00 UTC (rev 42876)
@@ -307,7 +307,7 @@
     /* this call causes r.proj to read the entire map into memeory */
     Rast_get_cellhd(inmap->answer, setname, &incellhd);
 
-    Rast_set_window(&incellhd);
+    Rast_set_input_window(&incellhd);
 
     if (G_projection() == PROJECTION_XY)
 	G_fatal_error(_("Unable to work with unprojected data (xy location)"));
@@ -380,7 +380,7 @@
     if (incellhd.west < iwest)
 	incellhd.west = iwest;
 
-    Rast_set_window(&incellhd);
+    Rast_set_input_window(&incellhd);
 
     /* And switch back to original location */
 
@@ -415,7 +415,7 @@
 	outcellhd.ns_res = outcellhd.ew_res = atof(res->answer);
 
     G_adjust_Cell_head(&outcellhd, 0, 0);
-    Rast_set_window(&outcellhd);
+    Rast_set_output_window(&outcellhd);
 
     G_message("");
     G_message(_("Input:"));
@@ -442,23 +442,23 @@
 
     /* open and read the relevant parts of the input map and close it */
     G__switch_env();
-    Rast_set_window(&incellhd);
+    Rast_set_input_window(&incellhd);
     fdi = Rast_open_old(inmap->answer, setname);
     cell_type = Rast_get_map_type(fdi);
     ibuffer = readcell(fdi, memory->answer);
     Rast_close(fdi);
 
     G__switch_env();
-    Rast_set_window(&outcellhd);
+    Rast_set_output_window(&outcellhd);
 
     if (strcmp(interpol->answer, "nearest") == 0) {
 	fdo = Rast_open_new(mapname, cell_type);
-	obuffer = (CELL *) Rast_allocate_buf(cell_type);
+	obuffer = (CELL *) Rast_allocate_output_buf(cell_type);
     }
     else {
 	fdo = Rast_open_fp_new(mapname);
 	cell_type = FCELL_TYPE;
-	obuffer = (FCELL *) Rast_allocate_buf(cell_type);
+	obuffer = (FCELL *) Rast_allocate_output_buf(cell_type);
     }
 
     cell_size = Rast_cell_size(cell_type);

Modified: grass/trunk/raster/r.proj/readcell.c
===================================================================
--- grass/trunk/raster/r.proj/readcell.c	2010-07-21 21:10:11 UTC (rev 42875)
+++ grass/trunk/raster/r.proj/readcell.c	2010-07-22 05:46:00 UTC (rev 42876)
@@ -27,8 +27,8 @@
     int nblocks;
     int i;
 
-    nrows = Rast_window_rows();
-    ncols = Rast_window_cols();
+    nrows = Rast_input_window_rows();
+    ncols = Rast_input_window_cols();
 
     ny = (nrows + BDIM - 1) / BDIM;
     nx = (ncols + BDIM - 1) / BDIM;

Modified: grass/trunk/raster/r.random.cells/init.c
===================================================================
--- grass/trunk/raster/r.random.cells/init.c	2010-07-21 21:10:11 UTC (rev 42875)
+++ grass/trunk/raster/r.random.cells/init.c	2010-07-22 05:46:00 UTC (rev 42876)
@@ -36,7 +36,7 @@
     Out = (CELL **) G_malloc(sizeof(CELL *) * Rs);
     for (row = 0; row < Rs; row++) {
 	Out[row] = Rast_allocate_c_buf();
-	Rast_zero_c_buf(Out[row]);
+	Rast_zero_buf(Out[row], CELL_TYPE);
     }
 
     Cells = FlagCreate(Rs, Cs);

Modified: grass/trunk/raster/r.resamp.filter/main.c
===================================================================
--- grass/trunk/raster/r.resamp.filter/main.c	2010-07-21 21:10:11 UTC (rev 42875)
+++ grass/trunk/raster/r.resamp.filter/main.c	2010-07-22 05:46:00 UTC (rev 42876)
@@ -346,8 +346,6 @@
 	    num_rows = 0;
 	}
 
-	Rast_set_window(&src_w);
-
 	for (i = num_rows; i < rows; i++) {
 	    G_debug(5, "read: %p = %d", bufs[i], row0 + i);
 	    Rast_get_d_row(infile, inbuf, row0 + i);
@@ -358,7 +356,6 @@
 
 	v_filter(outbuf, bufs, row, rows);
 
-	Rast_set_window(&dst_w);
 	Rast_put_d_row(outfile, outbuf);
 	G_debug(5, "write: %d", row);
     }
@@ -514,19 +511,15 @@
     for (i = 0; i < row_scale; i++)
 	bufs[i] = Rast_allocate_d_buf();
 
-    Rast_set_window(&src_w);
+    Rast_set_input_window(&src_w);
+    Rast_set_output_window(&dst_w);
 
-    infile = Rast_open_old(parm.rastin->answer, "");
-    inbuf = Rast_allocate_d_buf();
+    inbuf = Rast_allocate_d_input_buf();
+    outbuf = Rast_allocate_d_output_buf();
 
-    Rast_set_window(&dst_w);
-
+    infile = Rast_open_old(parm.rastin->answer, "");
     outfile = Rast_open_new(parm.rastout->answer, DCELL_TYPE);
-    outbuf = Rast_allocate_d_buf();
 
-    /* prevent complaints about window changes */
-    G_suppress_warnings(1);
-
     filter();
 
     Rast_close(infile);

Modified: grass/trunk/raster/r.resamp.interp/main.c
===================================================================
--- grass/trunk/raster/r.resamp.interp/main.c	2010-07-21 21:10:11 UTC (rev 42875)
+++ grass/trunk/raster/r.resamp.interp/main.c	2010-07-22 05:46:00 UTC (rev 42876)
@@ -121,11 +121,11 @@
 	src_w.cols = c1 - c0;
     }
 
-    Rast_set_window(&src_w);
+    Rast_set_input_window(&src_w);
 
     /* allocate buffers for input rows */
     for (row = 0; row < neighbors; row++)
-	bufs[row] = Rast_allocate_d_buf();
+	bufs[row] = Rast_allocate_d_input_buf();
 
     cur_row = -100;
 
@@ -133,16 +133,13 @@
     infile = Rast_open_old(rastin->answer, "");
 
     /* reset window to current region */
-    Rast_set_window(&dst_w);
+    Rast_set_output_window(&dst_w);
 
-    outbuf = Rast_allocate_d_buf();
+    outbuf = Rast_allocate_d_output_buf();
 
     /* open new map */
     outfile = Rast_open_new(rastout->answer, DCELL_TYPE);
 
-    G_suppress_warnings(1);
-    /* otherwise get complaints about window changes */
-
     switch (neighbors) {
     case 1:			/* nearest */
 	for (row = 0; row < dst_w.rows; row++) {
@@ -152,7 +149,6 @@
 
 	    G_percent(row, dst_w.rows, 2);
 
-	    Rast_set_window(&src_w);
 	    read_rows(infile, maprow0);
 
 	    for (col = 0; col < dst_w.cols; col++) {
@@ -170,7 +166,6 @@
 		}
 	    }
 
-	    Rast_set_window(&dst_w);
 	    Rast_put_d_row(outfile, outbuf);
 	}
 	break;
@@ -184,7 +179,6 @@
 
 	    G_percent(row, dst_w.rows, 2);
 
-	    Rast_set_window(&src_w);
 	    read_rows(infile, maprow0);
 
 	    for (col = 0; col < dst_w.cols; col++) {
@@ -209,7 +203,6 @@
 		}
 	    }
 
-	    Rast_set_window(&dst_w);
 	    Rast_put_d_row(outfile, outbuf);
 	}
 	break;
@@ -224,7 +217,6 @@
 
 	    G_percent(row, dst_w.rows, 2);
 
-	    Rast_set_window(&src_w);
 	    read_rows(infile, maprow0);
 
 	    for (col = 0; col < dst_w.cols; col++) {
@@ -282,7 +274,6 @@
 		}
 	    }
 
-	    Rast_set_window(&dst_w);
 	    Rast_put_d_row(outfile, outbuf);
 	}
 	break;

Modified: grass/trunk/raster/r.resamp.stats/main.c
===================================================================
--- grass/trunk/raster/r.resamp.stats/main.c	2010-07-21 21:10:11 UTC (rev 42875)
+++ grass/trunk/raster/r.resamp.stats/main.c	2010-07-22 05:46:00 UTC (rev 42876)
@@ -117,8 +117,6 @@
 
 	G_percent(row, dst_w.rows, 2);
 
-	Rast_set_window(&src_w);
-
 	for (i = 0; i < count; i++)
 	    Rast_get_d_row(infile, bufs[i], maprow0 + i);
 
@@ -148,7 +146,6 @@
 		(*method_fn) (&outbuf[col], values, n, closure);
 	}
 
-	Rast_set_window(&dst_w);
 	Rast_put_d_row(outfile, outbuf);
     }
 }
@@ -190,8 +187,6 @@
 
 	G_percent(row, dst_w.rows, 2);
 
-	Rast_set_window(&src_w);
-
 	for (i = 0; i < count; i++)
 	    Rast_get_d_row(infile, bufs[i], maprow0 + i);
 
@@ -234,7 +229,6 @@
 		(*method_fn) (&outbuf[col], values, n, closure);
 	}
 
-	Rast_set_window(&dst_w);
 	Rast_put_d_row(outfile, outbuf);
     }
 }
@@ -326,7 +320,8 @@
 	src_w.cols = c1 - c0;
     }
 
-    Rast_set_window(&src_w);
+    Rast_set_input_window(&src_w);
+    Rast_set_output_window(&dst_w);
 
     row_scale = 2 + ceil(dst_w.ns_res / src_w.ns_res);
     col_scale = 2 + ceil(dst_w.ew_res / src_w.ew_res);
@@ -334,23 +329,17 @@
     /* allocate buffers for input rows */
     bufs = G_malloc(row_scale * sizeof(DCELL *));
     for (row = 0; row < row_scale; row++)
-	bufs[row] = Rast_allocate_d_buf();
+	bufs[row] = Rast_allocate_d_input_buf();
 
     /* open old map */
     infile = Rast_open_old(parm.rastin->answer, "");
 
-    /* reset window to current region */
-    Rast_set_window(&dst_w);
-
     /* allocate output buffer */
-    outbuf = Rast_allocate_d_buf();
+    outbuf = Rast_allocate_d_output_buf();
 
     /* open new map */
     outfile = Rast_open_new(parm.rastout->answer, DCELL_TYPE);
 
-    /* prevent complaints about window changes */
-    G_suppress_warnings(1);
-
     if (flag.weight->answer && menu[method].method_w)
 	resamp_weighted();
     else

Modified: grass/trunk/raster/simwe/simlib/output.c
===================================================================
--- grass/trunk/raster/simwe/simlib/output.c	2010-07-21 21:10:11 UTC (rev 42875)
+++ grass/trunk/raster/simwe/simlib/output.c	2010-07-22 05:46:00 UTC (rev 42876)
@@ -47,6 +47,8 @@
     if (timesec >= 10000)
 	ndigit = 6;
 
+    Rast_set_window(&cellhd);
+
 /*
     if (outwalk) {
 	if (ts == 1) {
@@ -154,8 +156,6 @@
 	    erdep_fd = Rast_open_fp_new(erdep);
     }
 
-    Rast_set_window(&cellhd);
-
     if (my != Rast_window_rows())
 	G_fatal_error("OOPS: rows changed from %d to %d\n", mx,
 		      Rast_window_rows());
@@ -595,6 +595,8 @@
 
     /*   float a1,a2; */
 
+    Rast_set_window(&cellhd);
+
     if (et) {
 	et_cell = Rast_allocate_f_buf();
 	/*      if (ts == 1) {
@@ -617,8 +619,6 @@
 	tc_fd = Rast_open_fp_new(tc);
     }
 
-    Rast_set_window(&cellhd);
-
     if (my != Rast_window_rows())
 	G_fatal_error("OOPS: rows changed from %d to %d\n", mx,
 		      Rast_window_rows());



More information about the grass-commit mailing list