AIS.mesa
Last changed by Maureen Stone, 17-Nov-81 14:11:11
Last changed by Doug Wyatt, 18-Aug-81 17:46:12
Last changed by Michael Plass, December 27, 1983 9:19 am
DIRECTORY
AISFormat,
CountedVM,
FS,
PrincOps,
Rope
;
AIS:
CEDAR
DEFINITIONS ~ {
FRef: TYPE ~ REF FRep; -- AIS File
FRep:
TYPE ~
RECORD [
file: FS.OpenFile, -- the AIS file
write: BOOLEAN ← FALSE,
abase: PrincOps.PageNumber ← 0, -- first page of attribute part
rbase: PrincOps.PageNumber ← 0, -- first page of raster part
raster: Raster, -- the raster information
attributes: ARef, -- modify using procs only
wordsPerLine: CARDINAL ← 0, -- words per scan line
buffersize: PrincOps.PageCount ← 0, -- raster buffer size
outputBuffer: BRef ← NIL -- Unwritten output buffers.
];
ARef: TYPE = REF ARep;
ARep:
TYPE =
PRIVATE
RECORD [
header: REF AISFormat.Header ← NIL,
raster: REF uca AISFormat.RasterPart ← NIL,
placement: REF AISFormat.PlacementPart ← NIL,
photometry: REF AISFormat.PhotometryPart ← NIL,
comment: REF AISFormat.CommentPart ← NIL
];
WRef: TYPE ~ REF WRep; -- AIS Window
WRep:
TYPE ~
RECORD [
fref: FRef ← NIL, --file descriptor
bref: BRef ← NIL, --file buffer descriptor (mess with this at your own risk!)
firstScan: CARDINAL ← 0,
lastScan: CARDINAL ← 0,
firstPixel: CARDINAL ← 0,
lastPixel: CARDINAL ← 0,
wordsPerLine: CARDINAL ← 0, --the number of words for one windowed scan line
pixelsPerWord: CARDINAL ← 0,
nextScanLine: CARDINAL ← 0,
currline: CARDINAL ← 177777B,
clineaddr: LONG POINTER ← NIL
];
BRef: TYPE ~ REF BRep; --AIS file buffer
BRep:
TYPE ~
RECORD [
countedVM: CountedVM.Handle,
addr: LONG POINTER ← NIL, -- points to first scan line
first, last: CARDINAL ← 0, -- first and last scan line numbers
firstPage, nPages: CARDINAL -- Where the bufferload belongs in the file
];
ScanMode: TYPE ~ {ru, ul, ld, dr, rd, ur, lu, dl};
Scan direction for pixels and lines; for example, "rd" means:
successive pixels move rightward in the image
successive scanlines move downward in the image
attribute definitions
Raster: TYPE ~ REF RasterPart;
RasterPart:
TYPE ~
RECORD [
scanCount: CARDINAL, -- number of scan lines
scanLength: CARDINAL, -- number of pixels per scan line
scanMode: ScanMode, -- scanning directions
bitsPerPixel: [0..16], -- number of bits per pixel
linesPerBlock: INTEGER, -- for blocked AIS files. -1~no blocks
paddingPerBlock: CARDINAL --in words
];
Placement: TYPE ~ REF PlacementPart;
PlacementPart:
TYPE ~
RECORD [
xLeft: INTEGER,
yBottom: INTEGER,
xWidth: INTEGER,
yHeight: INTEGER
];
Photometry: TYPE ~ REF PhotometryPart;
PhotometryPart:
TYPE ~
RECORD [
signal: AISFormat.SignalType,
sense: AISFormat.Sense,
scaleType: AISFormat.ScaleType,
pointA: AISFormat.Point,
pointB: AISFormat.Point,
pointC: AISFormat.Point,
spotType: AISFormat.SpotType,
spotWidth: INTEGER, -- in units of 100*(width in pixels)
spotLength: INTEGER, -- in units of 100*(length in scanlines)
sampleMin: INTEGER,
sampleMax: INTEGER,
histogramLength: INTEGER --0 or -1 means no histogram
];
Histogram: TYPE ~ REF HistogramRep;
HistogramRep: TYPE ~ RECORD [SEQUENCE length: NAT OF INTEGER];
Errors
Error:
SIGNAL [type: ErrorType];
ErrorType: TYPE ~ {bufferTooSmall, outOfRange, invalidParameter, notImplemented, badWindow, attributesTooLong, readOnlyFile, invalidFile};
CreateFile:
PROC [name:
ROPE, raster: Raster, attributeLength:
CARDINAL ← 0]
RETURNS [f: FRef];
attributeLength is in AIS pages (1024 word blocks).
DeleteFile:
PROC [name:
ROPE];
OpenFile:
PROC [name:
ROPE, write:
BOOLEAN ←
FALSE]
RETURNS [f: FRef];
CloseFile:
PROC [f: FRef];
read and write attribute information
For everthing but raster, client passes pointers to records of the correct type.
A RETURN of FALSE from a Read indicates that the attribute was not present
maxComment: CARDINAL ~ 256;
If string buffer is too short, will truncate
ReadComment:
PROC [f: FRef]
RETURNS [
ROPE];
WriteComment:
PROC [f: FRef, comment:
ROPE];
ReadPlacement:
PROC [f: FRef]
RETURNS [placement: Placement];
WritePlacement:
PROC [f: FRef, placement: Placement];
histogram is separate from the rest of the photometry info because it is variable length
Histogram Length is in Photometry. (0 or -1 means no histogram)
ReadPhotometry: PROC [f: FRef] RETURNS [Photometry];
ReadHistogram: PROC [f: FRef] RETURNS [Histogram];
Error is histogram length # photometry.histogramLength
WritePhotometry: PROC [f: FRef, photometry: Photometry, histogram: Histogram ← NIL];
raster info always present
raster info can only be written when doing a CreateFile;
ReadRaster:
PROC [f: FRef]
RETURNS [Raster];
values will default to file values
OpenWindow:
PROC [f: FRef, firstScan:
CARDINAL ← 0, lastScan:
CARDINAL ←
LAST[
CARDINAL],
firstPixel: CARDINAL ← 0, lastPixel: CARDINAL ← LAST[CARDINAL]]
RETURNS [w: WRef];
For an output file, opening more than one window is not recommended due to the possibility of strange buffering effects.
CloseWindow:
PROC [w: WRef];
GetWindowParams:
PROC [w: WRef]
RETURNS [firstScan:
CARDINAL, lastScan:
CARDINAL,
firstPixel: CARDINAL, lastPixel: CARDINAL];
the minimum number of words in a scan line buffer for a given window
MinBufferSize:
PROC [w: WRef]
RETURNS [length:
CARDINAL];
returns TRUE if the current scan line is the last scan line in the window
EndOfWindow:
PROC [w: WRef]
RETURNS [
BOOLEAN];
Buffer: TYPE ~ RECORD [length: LONG CARDINAL, addr: LONG POINTER];
UnsafeReadLine: UNSAFE PROC [w: WRef, buffer: Buffer, line: INTEGER ← -1];
UnsafeWriteLine:
UNSAFE
PROC [w: WRef, buffer: Buffer, line:
INTEGER ← -1];
ReadSample: PROC [w: WRef, line, pixel: CARDINAL] RETURNS [value: CARDINAL];
WriteSample:
PROC [w: WRef, value:
CARDINAL, line, pixel:
CARDINAL];
}.