GRASS Programmer's Manual
6.4.2(2012)
Main Page
Related Pages
Namespaces
Data Structures
Files
File List
Globals
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Pages
input2d.c
Go to the documentation of this file.
1
2
/*-
3
* Written by H. Mitasova, I. Kosinovsky, D. Gerdes Fall 1993
4
* University of Illinois
5
* US Army Construction Engineering Research Lab
6
* Copyright 1993, H. Mitasova (University of Illinois),
7
* I. Kosinovsky, (USA-CERL), and D.Gerdes (USA-CERL)
8
*
9
* modified by McCauley in August 1995
10
* modified by Mitasova in August 1995
11
* modified by Mitasova in November 1996 to include variable smoothing
12
* modified by Brown in June 1999 - added elatt & smatt
13
*
14
*/
15
16
17
#include <stdio.h>
18
#include <stdlib.h>
19
#include <math.h>
20
#include <grass/gis.h>
21
#include <grass/site.h>
22
#include <grass/bitmap.h>
23
#include <grass/linkm.h>
24
#include <grass/interpf.h>
25
#include <grass/glocale.h>
26
27
struct
BM *
IL_create_bitmask
(
struct
interp_params
*params)
28
29
30
{
31
int
i, j, cfmask = 0, irev, MASKfd;
32
char
*mapsetm;
33
CELL *cellmask, *MASK;
34
struct
BM *bitmask;
35
36
if
((MASKfd =
G_maskfd
()) >= 0)
37
MASK =
G_allocate_cell_buf
();
38
else
39
MASK =
NULL
;
40
41
if
(params->
maskmap
!=
NULL
|| MASK !=
NULL
) {
42
bitmask =
BM_create
(params->
nsizc
, params->
nsizr
);
43
44
if
(params->
maskmap
!=
NULL
) {
45
mapsetm =
G_find_cell2
(params->
maskmap
,
""
);
46
if
(!mapsetm)
47
G_fatal_error
(_(
"Mask raster map <%s> not found"
),
48
params->
maskmap
);
49
50
cellmask =
G_allocate_cell_buf
();
51
cfmask =
G_open_cell_old
(params->
maskmap
, mapsetm);
52
}
53
else
54
cellmask =
NULL
;
55
56
for
(i = 0; i < params->
nsizr
; i++) {
57
irev = params->
nsizr
- i - 1;
58
if
(cellmask)
59
G_get_map_row
(cfmask, cellmask, i);
60
if
(MASK)
61
G_get_map_row
(MASKfd, MASK, i);
62
for
(j = 0; j < params->
nsizc
; j++) {
63
if
((cellmask && cellmask[j] == 0) || (MASK && MASK[j] == 0))
64
BM_set
(bitmask, j, irev, 0);
65
else
66
BM_set
(bitmask, j, irev, 1);
67
}
68
}
69
G_message
(_(
"Bitmap mask created"
));
70
}
71
else
72
bitmask =
NULL
;
73
74
return
bitmask;
75
}
76
77
int
translate_quad
(
struct
multtree
*tree,
78
double
numberx,
79
double
numbery,
double
numberz,
int
n_leafs)
80
{
81
int
total = 0, i, ii;
82
83
if
(tree ==
NULL
)
84
return
0;
85
if
(tree->
data
==
NULL
)
86
return
0;
87
88
if
(tree->
leafs
!=
NULL
) {
89
((
struct
quaddata
*)(tree->
data
))->
x_orig
-= numberx;
90
((
struct
quaddata
*)(tree->
data
))->
y_orig
-= numbery;
91
((
struct
quaddata
*)(tree->
data
))->
xmax
-= numberx;
92
((
struct
quaddata
*)(tree->
data
))->
ymax
-= numbery;
93
for
(ii = 0; ii < n_leafs; ii++)
94
total +=
95
translate_quad
(tree->
leafs
[ii], numberx, numbery, numberz,
96
n_leafs);
97
}
98
else
{
99
((
struct
quaddata
*)(tree->
data
))->
x_orig
-= numberx;
100
((
struct
quaddata
*)(tree->
data
))->
y_orig
-= numbery;
101
((
struct
quaddata
*)(tree->
data
))->
xmax
-= numberx;
102
((
struct
quaddata
*)(tree->
data
))->
ymax
-= numbery;
103
for
(i = 0; i < ((
struct
quaddata
*)(tree->
data
))->
n_points
; i++) {
104
((
struct
quaddata
*)(tree->
data
))->
points
[i].x -= numberx;
105
((
struct
quaddata
*)(tree->
data
))->
points
[i].y -= numbery;
106
((
struct
quaddata
*)(tree->
data
))->
points
[i].z -= numberz;
107
}
108
109
return
1;
110
}
111
112
return
total;
113
}
lib
rst
interp_float
input2d.c
Generated on Sun Mar 16 2014 05:07:46 for GRASS Programmer's Manual by
1.8.1.2