aboutsummaryrefslogtreecommitdiff
path: root/sys/plio/tf/plr2pl.x
diff options
context:
space:
mode:
authorJoseph Hunkeler <jhunkeler@gmail.com>2015-07-08 20:46:52 -0400
committerJoseph Hunkeler <jhunkeler@gmail.com>2015-07-08 20:46:52 -0400
commitfa080de7afc95aa1c19a6e6fc0e0708ced2eadc4 (patch)
treebdda434976bc09c864f2e4fa6f16ba1952b1e555 /sys/plio/tf/plr2pl.x
downloadiraf-linux-fa080de7afc95aa1c19a6e6fc0e0708ced2eadc4.tar.gz
Initial commit
Diffstat (limited to 'sys/plio/tf/plr2pl.x')
-rw-r--r--sys/plio/tf/plr2pl.x74
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