瀏覽代碼

raster3d: split base into r3.mask and r3.null

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@47528 15284696-431f-4ddb-bdfa-cd5b030d7da7
Martin Landa 13 年之前
父節點
當前提交
1125984cca

+ 0 - 14
raster3d/base/Makefile

@@ -1,14 +0,0 @@
-
-MODULE_TOPDIR = ../..
-
-LIBES = $(G3DLIB) $(GISLIB)
-DEPENDENCIES = $(G3DDEP) $(GISDEP)
-
-PROGRAMS = r3.mask r3.null
-
-r3_mask_OBJS = r3.mask.main.o mask_functions.o
-r3_null_OBJS = r3.null.main.o mask_functions.o
-
-include $(MODULE_TOPDIR)/include/Make/Multi.make
-
-default: multi

+ 0 - 143
raster3d/base/mask_functions.c

@@ -1,143 +0,0 @@
-
-/***************************************************************************
-* MODULE:       this structs/functions are used by r3.mask and r3.null
-*
-* AUTHOR(S):    Roman Waupotitsch, Michael Shapiro, Helena Mitasova,
-*		Bill Brown, Lubos Mitas, Jaro Hofierka
-*
-* COPYRIGHT:    (C) 2005 by the GRASS Development Team
-*
-*               This program is free software under the GNU General Public
-*               License (>=v2). Read the file COPYING that comes with GRASS
-*               for details.
-*
-*****************************************************************************/
-/*Helperfunctions */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <grass/gis.h>
-#include <grass/glocale.h>
-#include "mask_functions.h"
-
-/*local prototypes */
-static void add_d_mask_rule(d_Mask * d_mask, double a, double b, int inf);
-static void parse_d_mask_rule(char *vallist, d_Mask * d_mask, char *where);
-static void init_d_mask_rules(d_Mask * d_mask);
-
-/*******************************************************************/
-static void init_d_mask_rules(d_Mask * d_mask)
-{
-    d_mask->list = NULL;
-}
-
-/*******************************************************************/
-static void add_d_mask_rule(d_Mask * d_mask, double a, double b, int inf)
-{
-    d_Interval *I;
-
-    I = (d_Interval *) G_malloc(sizeof(d_Interval));
-    I->low = a <= b ? a : b;
-    I->high = a >= b ? a : b;
-    I->inf = inf;
-    I->next = d_mask->list;
-    d_mask->list = I;
-}
-
-/*******************************************************************/
-int mask_d_select(DCELL * x, d_Mask * mask)
-{
-    d_Interval *I;
-
-    if (mask->list == NULL)
-	return 0;
-    for (I = mask->list; I; I = I->next) {
-	if (mask_match_d_interval(*x, I))
-	    return 1;
-    }
-    return 0;
-}
-
-/*******************************************************************/
-extern DCELL mask_match_d_interval(DCELL x, d_Interval * I)
-{
-    if (I->inf < 0)
-	return x <= I->low;
-
-    if (I->inf > 0)
-	return x >= I->high;
-
-    return x >= I->low && x <= I->high;
-}
-
-/*******************************************************************/
-static void parse_d_mask_rule(char *vallist, d_Mask * d_mask, char *where)
-{
-    double a, b;
-    char junk[128];
-
-    /* #-# */
-    if (sscanf(vallist, "%lf-%lf", &a, &b) == 2) {
-	G_message(_("Adding rule: %lf - %lf"), a, b);
-	add_d_mask_rule(d_mask, a, b, 0);
-    }
-    /* inf-# */
-    else if (sscanf(vallist, "%[^ -\t]-%lf", junk, &a) == 2)
-	add_d_mask_rule(d_mask, a, a, -1);
-
-    /* #-inf */
-    else if (sscanf(vallist, "%lf-%[^ \t]", &a, junk) == 2)
-	add_d_mask_rule(d_mask, a, a, 1);
-
-    /* # */
-    else if (sscanf(vallist, "%lf", &a) == 1)
-	add_d_mask_rule(d_mask, a, a, 0);
-
-    else {
-	if (where)
-	    G_message("%s: ", where);
-	G_warning(_("%s: illegal value spec"), vallist);
-	G_usage();
-	exit(EXIT_FAILURE);
-    }
-}
-
-/*******************************************************************/
-void parse_vallist(char **vallist, d_Mask ** d_mask)
-{
-    char buf[1024];
-    char x[2];
-    FILE *fd;
-
-    *d_mask = (d_Mask *) G_malloc(sizeof(d_Mask));
-
-    init_d_mask_rules(*d_mask);
-    if (vallist == NULL)
-	return;
-
-    for (; *vallist; vallist++) {
-	if (*vallist[0] == '/') {
-	    fd = fopen(*vallist, "r");
-	    if (fd == NULL) {
-		perror(*vallist);
-		G_usage();
-		exit(EXIT_FAILURE);
-	    }
-	    while (fgets(buf, sizeof buf, fd)) {
-		if (sscanf(buf, "%1s", x) != 1 || *x == '#')
-		    continue;
-		parse_d_mask_rule(buf, *d_mask, *vallist);
-	    }
-	    fclose(fd);
-	}
-	else
-	    parse_d_mask_rule(*vallist, *d_mask, (char *)NULL);
-    }
-}
-
-/*******************************************************************/
-
-/*******************************************************************/
-
-/*******************************************************************/

+ 0 - 40
raster3d/base/mask_functions.h

@@ -1,40 +0,0 @@
-
-/***************************************************************************
-* MODULE:       this structs/functions are used by r3.mask and r3.null
-*
-* AUTHOR(S):    Roman Waupotitsch, Michael Shapiro, Helena Mitasova,
-*		Bill Brown, Lubos Mitas, Jaro Hofierka
-*
-* COPYRIGHT:    (C) 2005 by the GRASS Development Team
-*
-*               This program is free software under the GNU General Public
-*               License (>=v2). Read the file COPYING that comes with GRASS
-*               for details.
-*
-*****************************************************************************/
-/*Headerfile for global structs and funcktions */
-
-#ifndef __MASK_FUNCTIONS_H__
-#define __MASK_FUNCTIONS_H__
-
-#include <grass/raster.h>
-
-/*Structures */
-typedef struct _d_interval
-{
-    double low, high;
-    int inf;
-    struct _d_interval *next;
-} d_Interval;
-
-typedef struct _d_mask
-{
-    d_Interval *list;
-} d_Mask;
-
-/*Prototypes for mask_functions.c */
-int mask_d_select(DCELL * x, d_Mask * mask);
-extern DCELL mask_match_d_interval(DCELL x, d_Interval * I);
-void parse_vallist(char **vallist, d_Mask ** d_mask);
-
-#endif

+ 10 - 0
raster3d/r3.mask/Makefile

@@ -0,0 +1,10 @@
+MODULE_TOPDIR = ../..
+
+PGM=r3.mask
+
+LIBES = $(GPDELIB) $(G3DLIB) $(GISLIB)
+DEPENDENCIES = $(GPDEDEP) $(G3DDEP) $(GISDEP)
+
+include $(MODULE_TOPDIR)/include/Make/Module.make
+
+default: cmd

+ 2 - 3
raster3d/base/r3.mask.main.c

@@ -21,7 +21,6 @@
 #include <grass/gis.h>
 #include <grass/G3d.h>
 #include <grass/glocale.h>
-#include "mask_functions.h"
 
 /*--------------------------------------------------------------------------*/
 
@@ -37,7 +36,7 @@ static paramType params;
 void getParams(char **name, d_Mask ** maskRules)
 {
     *name = params.map->answer;
-    parse_vallist(params.maskVals->answers, maskRules);
+    G3d_parse_vallist(params.maskVals->answers, maskRules);
 }
 
 /*-------------------------------------------------------------------------*/
@@ -92,7 +91,7 @@ static void makeMask(char *name, d_Mask * maskRules)
 	for (y = 0; y < region.rows; y++)	/* We count from north to south in the cube coordinate system */
 	    for (x = 0; x < region.cols; x++) {
 		value = G3d_getDoubleRegion(map, x, y, z);
-		if (mask_d_select((DCELL *) & value, maskRules))
+		if (G3d_mask_d_select((DCELL *) & value, maskRules))
 		    G3d_putFloat(mask, x, y, z, (float)floatNull);	/* mask-out value */
 		else
 		    G3d_putFloat(mask, x, y, z, (float)0.0);	/* not mask-out value */

raster3d/base/r3.mask.html → raster3d/r3.mask/r3.mask.html


+ 10 - 0
raster3d/r3.null/Makefile

@@ -0,0 +1,10 @@
+MODULE_TOPDIR = ../..
+
+PGM=r3.null
+
+LIBES = $(GPDELIB) $(G3DLIB) $(GISLIB)
+DEPENDENCIES = $(GPDEDEP) $(G3DDEP) $(GISDEP)
+
+include $(MODULE_TOPDIR)/include/Make/Module.make
+
+default: cmd

+ 2 - 3
raster3d/base/r3.null.main.c

@@ -21,7 +21,6 @@
 #include <string.h>
 #include <grass/gis.h>
 #include <grass/G3d.h>
-#include "mask_functions.h"
 #include <grass/glocale.h>
 
 
@@ -77,7 +76,7 @@ getParams(char **name, d_Mask ** maskRules, int *changeNull,
 	  double *newNullVal)
 {
     *name = params.map->answer;
-    parse_vallist(params.setNull->answers, maskRules);
+    G3d_parse_vallist(params.setNull->answers, maskRules);
 
     *changeNull = (params.null->answer != NULL);
     if (*changeNull)
@@ -143,7 +142,7 @@ modifyNull(char *name, d_Mask * maskRules, int changeNull, double newNullVal)
 			value = newNullVal;
 		    }
 		}
-		else if (mask_d_select((DCELL *) & value, maskRules)) {
+		else if (G3d_mask_d_select((DCELL *) & value, maskRules)) {
 		    G3d_setNullValue(&value, 1, DCELL_TYPE);
 		}
 

raster3d/base/r3.null.html → raster3d/r3.null/r3.null.html


raster3d/base/test.r3.null.sh → raster3d/r3.null/test.r3.null.sh


raster3d/base/test_volume_double_1.ref → raster3d/r3.null/test_volume_double_1.ref


raster3d/base/test_volume_double_2.ref → raster3d/r3.null/test_volume_double_2.ref


raster3d/base/test_volume_double_null_1.ref → raster3d/r3.null/test_volume_double_null_1.ref


raster3d/base/test_volume_double_null_2.ref → raster3d/r3.null/test_volume_double_null_2.ref


raster3d/base/test_volume_float_1.ref → raster3d/r3.null/test_volume_float_1.ref


raster3d/base/test_volume_float_2.ref → raster3d/r3.null/test_volume_float_2.ref


raster3d/base/test_volume_float_null_1.ref → raster3d/r3.null/test_volume_float_null_1.ref


raster3d/base/test_volume_float_null_2.ref → raster3d/r3.null/test_volume_float_null_2.ref