diff options
author | Joseph Hunkeler <jhunkeler@gmail.com> | 2015-07-08 20:46:52 -0400 |
---|---|---|
committer | Joseph Hunkeler <jhunkeler@gmail.com> | 2015-07-08 20:46:52 -0400 |
commit | fa080de7afc95aa1c19a6e6fc0e0708ced2eadc4 (patch) | |
tree | bdda434976bc09c864f2e4fa6f16ba1952b1e555 /sys/plio/plsectne.x | |
download | iraf-linux-fa080de7afc95aa1c19a6e6fc0e0708ced2eadc4.tar.gz |
Initial commit
Diffstat (limited to 'sys/plio/plsectne.x')
-rw-r--r-- | sys/plio/plsectne.x | 101 |
1 files changed, 101 insertions, 0 deletions
diff --git a/sys/plio/plsectne.x b/sys/plio/plsectne.x new file mode 100644 index 00000000..c8ca8f6d --- /dev/null +++ b/sys/plio/plsectne.x @@ -0,0 +1,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 |