forked from OSGeo/grass
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy paththresh_array.c
54 lines (47 loc) · 1.3 KB
/
thresh_array.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include <stdio.h>
#include "vizual.h"
/*
** return an array of struct cmndln_info of resulting
** thresholds based on in_out flag
*/
int build_thresh_arrays(D_spec, headp)
struct dspec *D_spec;
file_info *headp;
{
double min_thresh, max_thresh;
int a, b, i;
min_thresh = headp->linefax.tvalue[D_spec->low];
max_thresh = headp->linefax.tvalue[D_spec->hi];
/* initializations */
D_spec->threshes[0].nthres = 0;
D_spec->threshes[1].nthres = 0; /* for INSIDE CASE */
if (D_spec->in_out == INSIDE) {
b = 0;
for (a = 0; a < headp->linefax.nthres; a++) {
if (min_thresh <= headp->linefax.tvalue[a] &&
max_thresh >= headp->linefax.tvalue[a]) {
D_spec->threshes[0].tvalue[b++] = headp->linefax.tvalue[a];
D_spec->threshes[0].nthres++;
}
}
}
else { /* OUTSIDE */
for (i = 0; i < 2; i++) {
b = 0;
for (a = 0; a < headp->linefax.nthres; a++) {
if (!i) {
if (min_thresh >= headp->linefax.tvalue[a]) {
D_spec->threshes[i].tvalue[b++] =
headp->linefax.tvalue[a];
D_spec->threshes[i].nthres++;
}
else if (max_thresh <= headp->linefax.tvalue[a]) {
D_spec->threshes[i].tvalue[b++] =
headp->linefax.tvalue[a];
D_spec->threshes[i].nthres++;
}
} /* is this brace correct? MN 2001 */
}
}
}
}