diff options
author | Joe Hunkeler <jhunkeler@gmail.com> | 2015-08-11 16:51:37 -0400 |
---|---|---|
committer | Joe Hunkeler <jhunkeler@gmail.com> | 2015-08-11 16:51:37 -0400 |
commit | 40e5a5811c6ffce9b0974e93cdd927cbcf60c157 (patch) | |
tree | 4464880c571602d54f6ae114729bf62a89518057 /sys/plio/tf/plr2pl.x | |
download | iraf-osx-40e5a5811c6ffce9b0974e93cdd927cbcf60c157.tar.gz |
Repatch (from linux) of OSX IRAF
Diffstat (limited to 'sys/plio/tf/plr2pl.x')
-rw-r--r-- | sys/plio/tf/plr2pl.x | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/sys/plio/tf/plr2pl.x b/sys/plio/tf/plr2pl.x new file mode 100644 index 00000000..763bb8d2 --- /dev/null +++ b/sys/plio/tf/plr2pl.x @@ -0,0 +1,74 @@ +# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc. + +include <plset.h> +include <plio.h> + +# PL_R2P -- Convert a range list to a pixel array. The number of pixels +# output (always npix) is returned as the function value. + +int procedure pl_r2pl (rl_src, xs, px_dst, npix) + +long rl_src[3,ARB] #I input range list +int xs #I starting pixel index in range list +long px_dst[ARB] #O output pixel array +int npix #I number of pixels to convert + +long hi, pv +int xe, x1, x2, iz, op, np, nz, nr, i, j +define done_ 91 + +begin + # No input pixels? + nr = RL_LEN(rl_src) + if (npix <= 0 || nr <= 0) + return (0) + + xe = xs + npix - 1 + iz = xs + op = 1 + hi = 1 + + # Process the array of range lists. + do i = RL_FIRST, nr { + x1 = rl_src[1,i] + np = rl_src[2,i] + pv = rl_src[3,i] + x2 = x1 + np - 1 + + # Get an inbounds range. + if (x1 > xe) + break + else if (xs > x2) + next + else if (x1 < xs) + x1 = xs + else if (x2 > xe) + x2 = xe + + nz = x1 - iz + np = x2 - x1 + 1 + if (np <= 0) + next + + # Output range of zeros to catch up to current range? + if (nz > 0) { + do j = 1, nz + px_dst[op+j-1] = 0 + op = op + nz + } + + # Output the pixels. + do j = 1, np + px_dst[op+j-1] = pv + op = op + np +done_ + x1 = x2 + 1 + iz = x1 + } + + # Zero any remaining output range. + do i = op, npix + px_dst[i] = 0 + + return (npix) +end |