aboutsummaryrefslogtreecommitdiff
path: root/sys/plio/plrseg.h
diff options
context:
space:
mode:
authorJoe Hunkeler <jhunkeler@gmail.com>2015-08-11 16:51:37 -0400
committerJoe Hunkeler <jhunkeler@gmail.com>2015-08-11 16:51:37 -0400
commit40e5a5811c6ffce9b0974e93cdd927cbcf60c157 (patch)
tree4464880c571602d54f6ae114729bf62a89518057 /sys/plio/plrseg.h
downloadiraf-osx-40e5a5811c6ffce9b0974e93cdd927cbcf60c157.tar.gz
Repatch (from linux) of OSX IRAF
Diffstat (limited to 'sys/plio/plrseg.h')
-rw-r--r--sys/plio/plrseg.h58
1 files changed, 58 insertions, 0 deletions
diff --git a/sys/plio/plrseg.h b/sys/plio/plrseg.h
new file mode 100644
index 00000000..f37372c3
--- /dev/null
+++ b/sys/plio/plrseg.h
@@ -0,0 +1,58 @@
+# PLRSEG.H -- Macros for sequentially reading segments of a range list.
+#
+# plr_init (rl, descriptor)
+# npix = plr_nleft (descriptor)
+# val = plr_getseg (rl, descriptor, npix, value)
+#
+# plr_init Initialize descriptor for sequential i/o from the rangelist RL.
+# plr_nleft Number of pixels left in the current line segment of constant
+# value. Zero is returned at the EOL.
+# plr_getseg Read NPIX pixels from the current segment, advancing to the
+# next segment automatically when the the current segment is
+# exhausted.
+#
+# The descriptor is an integer array, the contents of which are hidden from
+# the application using these macros.
+
+# Range list i/o descriptor.
+define LEN_PLRDES 4
+define rd_nleft $1[1]
+define rd_value $1[2]
+define rd_x $1[3]
+define rd_rn $1[4]
+
+# PLR_INIT -- Initialize the rangelist descriptor.
+define (plr_init, { # $1=rl $2=des
+ rd_x($2) = 1
+ rd_rn($2) = RL_FIRST
+ plr_nextseg ($1, $2)
+})
+
+# PLR_NLEFT -- Number of pixels left in the current segment.
+define plr_nleft rd_nleft($1)
+
+# PLR_GETSEG -- Read pixels from the current segment.
+define (plr_getseg, { # $1=rl $2=des $3=npix $4=value
+ $4 = rd_value($2)
+ rd_x($2) = rd_x($2) + $3
+ rd_nleft($2) = rd_nleft($2) - $3
+ if (rd_nleft($2) <= 0)
+ plr_nextseg ($1, $2)
+})
+
+# PLR_NEXTSEG -- Set up the next segment (internal routine).
+define (plr_nextseg, { # $1=rl $2=des
+ if (rd_rn($2) <= RL_LEN($1)) {
+ if ($1[1,rd_rn($2)] > rd_x($2)) {
+ rd_value($2) = 0
+ rd_nleft($2) = $1[1,rd_x($2)] - rd_x($2)
+ } else {
+ rd_value($2) = $1[3,rd_rn($2)]
+ rd_nleft($2) = $1[2,rd_rn($2)]
+ rd_rn($2) = rd_rn($2) + 1
+ }
+ } else if (rd_x($2) <= RL_AXLEN($1)) {
+ rd_value($2) = 0
+ rd_nleft($2) = RL_AXLEN($1) - rd_x($2) + 1
+ }
+})