GetRay

GetRay - Get one ray of data

BOOLE GetRay(cdb, dataptr, ray)

CDB cdb ;

int dataptr ;

RAY ray ;

PURPOSE

GetRay returns the ray at the current position.

INPUTS

cdb

compressed data block

dataptr

offset within block to start at

OUTPUTS

dataptr

offset within block past end of ray

ray

returned ray of data

CODE

/* * getray - return ray at current position as main channel raw power */ #include #include "rad.h" /* * movefor -- move pointer forward * to the next valid word in CDB */ #define movefor(ptr) while (cdb[++(ptr)] == HARDWERR) ++(ptr) BOOLE getray (cdb, dataptr, ray) CDB cdb ; int dataptr ; RAY ray ; /* the returned ray */ { int bin ; /* bin number index into output ray*/ int channels ; short temp ; for (bin = 0; bin < BINNUM; bin++) { ray[bin] = 0 ; } /* move pointer forward in CDB */ movefor(dataptr) ; /* to elevation */ movefor(dataptr) ; /* to first time word */ movefor(dataptr) ; /* to second time word, which contains channel flags as well as time */ /* * Check for the number of channels in this ray - this number may * change from ray to ray. */ if ( (cdb[dataptr] & 0200) != 0 ) { channels = 4 ; } else { if ( (cdb[dataptr] & 0100) != 0 ) { channels = 1 ; } else { channels = 2 ; } } /* * Check to see if we are at the end of this ray by checking to see * if we are at the end of the buffer or the start of the next ray. */ movefor(dataptr) ; while ( (cdb[dataptr] != EOB) && !(BIT15SET(cdb[dataptr]) && BIT15SET(cdb[dataptr+1])) ) { temp = cdb[dataptr] ; bin = BINNUM + temp ; /* convert a pointer to a bin number */ movefor(dataptr) ; /* * Contiguous data will have the high bit clear, otherwise leave this loop * and check for the end of the ray. */ while ( !BIT15SET(cdb[dataptr]) ) { switch ( channels ) { case 1: /* 1 chan - two main power values per word */ ray[bin] = cdb[dataptr]&0177 ; bin++ ; if (bin < BINNUM) ray[bin] = (cdb[dataptr]&077400) >> 8 ; bin++ ; movefor(dataptr) ; break ; case 2: /* 2 chan - one main power value, one depolarized power value per word */ ray[bin] = cdb[dataptr]&0177 ; bin++ ; movefor(dataptr) ; break ; case 4: /* 4 chan - one main power value, one depolarized power value in first word, two additional channels in second word */ ray[bin] = cdb[dataptr]&0177 ; bin++ ; movefor(dataptr) ; movefor(dataptr) ; break ; } } } return YES; }