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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
|
# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
include <plset.h>
include "pllseg.h"
include <plio.h>
# PL_SECTNOTEMPTY -- Test whether the indicated mask image section is empty.
bool procedure pl_sectnotempty (pl_src, v1, v2, ndim)
pointer pl_src #I mask descriptor
long v1[PL_MAXDIM] #I starting coordinates of section
long v2[PL_MAXDIM] #I ending coordinates of section
int ndim
pointer lp
int ll_src, i
long v[PL_MAXDIM], vs[PL_MAXDIM], ve[PL_MAXDIM], vn[PL_MAXDIM]
bool pll_empty()
int pl_reference(), plloop()
errchk plvalid, plsslv, pl_reference
begin
call plvalid (pl_src)
# Initialize the N-dimensional loop counters.
do i = 1, PL_MAXDIM
if (i <= ndim) {
if (v1[i] <= v2[i]) {
vs[i] = v1[i]
vn[i] = v2[i] - v1[i] + 1
} else {
vs[i] = v2[i]
vn[i] = v1[i] - v2[i] + 1
}
} else {
vs[i] = 1
vn[i] = 1
}
call plsslv (pl_src, vs, vn, v, ve)
# Test each line segment in the section.
repeat {
ll_src = pl_reference (pl_src, v)
if (ll_src != PL_EMPTYLINE) {
lp = Ref (pl_src, ll_src)
if (!pll_empty (Mems[lp], vs[1], vn[1]))
return (true)
}
} until (plloop (v, vs, ve, PL_NAXES(pl_src)) == LOOP_DONE)
return (false)
end
# PLL_EMPTY -- Test whether a section of a line list is empty.
bool procedure pll_empty (ll_src, xs, npix)
short ll_src[ARB] #I input line list
int xs #I first pixel to test
int npix #I length of region to be tested
int nleft, x1, np, v_src, i
int d_src[LEN_PLLDES]
begin
# Advance to the indicated position in the source list.
x1 = 1
pll_init (ll_src, d_src)
do i = 1, ARB {
np = min (pll_nleft(d_src), xs - x1)
pll_getseg (ll_src, d_src, np, v_src)
x1 = x1 + np
if (x1 >= xs || np == 0)
break
}
# Test if the next npix pixels are zero.
if (pll_nleft(d_src) < npix)
return (false)
else {
pll_getseg (ll_src, d_src, npix, v_src)
return (v_src == 0)
}
# Test if the next npix pixels are zero. Note the line list is
# segmented and we have to read segments until we have examined NPIX
# pixels, or until a nonzero mask pixel is encountered.
for (nleft=npix; nleft > 0; nleft = nleft - np) {
np = min (pll_nleft(d_src), nleft)
pll_getseg (ll_src, d_src, np, v_src)
if (v_src != 0)
return (false)
}
return (true)
end
|