CDMEBESDropInImpl.mesa
Copyright © 1985 by Xerox Corporation. All rights reserved.
written by E. McCreight, November 2, 1983 6:03 pm
McCreight, June 25, 1986 4:48:55 pm PDT
This module drops a MEBES file into another MEBES file, one stripe at a time.
DIRECTORY
Atom, BasicTime, CDBasics, CDMEBES, CDMEBESScan, CStitching, FS, IO, Rope;
CDMEBESDropInImpl: CEDAR PROGRAM IMPORTS Atom, BasicTime, CDBasics, CDMEBES, CDMEBESScan, CStitching, FS, IO EXPORTS CDMEBES =
BEGIN OPEN CDMEBES;
InsertDropIn: PUBLIC PROC [ ms: MaskState, rects: Tesselation, di: DropIn, data: REF ] RETURNS [ newData: REF ] =
This procedure incorporates the mask information referenced in data, translated by di.pos and then clipped to ms.mebesStripeClip, into the MEBES stream in ms.s.
BEGIN
IF data = NIL THEN
newData ← InsertDropIn[ms, rects, di, CDMEBESScan.ScanMebesPatternFile[
IO.PutFR[di.fileNamePattern, IO.rope[NARROW[ms.toolingSpec.GetPropFromList[ms.curMask.maskId], ToolingMaskSpec].maskNo]]]]
ELSE WITH data SELECT FROM
fileName: Rope.ROPE =>
newData ← InsertDropIn[ms, rects, di, CDMEBESScan.ScanMebesPatternFile[fileName]];
dd: CDMEBESScan.DropInDescriptor => {
did: CDMEBESScan.DropInDescriptor ← dd;
scaleFactor: Rational = [num: 1, denom: ms.mebesPixelPitch]; -- from Nm to MEBESPixels
dropInClip: MEBESRect; -- the current output stripe, translated to drop-in space and clipped to drop-in boundary
dropInOffsetToReticleClip: MEBESPosition; -- position of drop-in file's [0,0] in reticleClip
mebesStripeClipFromDropIn: MEBESRect;
IF BasicTime.Period[did.lastChecked, BasicTime.Now[]] > 5*60 THEN {
WHILE FS.FileInfo[did.fileName].created # did.created DO
did ← CDMEBESScan.ScanMebesPatternFile[did.fileName]; -- needs updating
ENDLOOP;
did.lastChecked ← BasicTime.Now[];
};
IF ms.mebesPixelPitch -- nm -- *1.0E-9 > did.pixelSize -- Meters -- +5.0E-10 OR
ms.mebesPixelPitch*1.0E-9 < did.pixelSize-5.0E-10 THEN
ERROR; -- pixel sizes incompatible
dropInOffsetToReticleClip ← ScalePoint[CDBasics.AddPoints[CDBasics.AddPoints[di.pos, ms.dieOffset], CDBasics.BaseOfRect[ms.nmReticleClip]], scaleFactor];
mebesStripeClipFromDropIn ← CDBasics.MoveRect[ms.mebesStripeClip, CDBasics.NegOffset[dropInOffsetToReticleClip]];
dropInClip ← CDBasics.Intersection[did.clip, mebesStripeClipFromDropIn];
IF CDBasics.NonEmpty[dropInClip] THEN {
s: IO.STREAM;
IF di.clearBackground THEN
rects.ChangeRect[CDBasics.MoveRect[dropInClip, dropInOffsetToReticleClip], NIL];
FOR segment: CARDINAL ← dropInClip.x1/CDMEBES.maskWidth, segment+1 WHILE segment*CDMEBES.maskWidth < dropInClip.x2 DO
FOR stripe: CARDINAL ← dropInClip.y1/did.stripeHeight, stripe+1 WHILE stripe*did.stripeHeight < dropInClip.y2 DO
offset: MEBESPosition = [x: segment*CDMEBES.maskWidth, y: stripe*did.stripeHeight];
IF did[segment][stripe] = [0, 0] THEN LOOP;
IF s = NIL THEN
s ← FS.StreamOpen[fileName: did.fileName, remoteCheck: FALSE];
s.SetIndex[CDMEBES.mebesBlockSize*(did[segment][stripe].firstBlock-1)+2*(did[segment][stripe].firstWordWithinBlock-1)];
ProcessStripe[source: s, dest: ms.s,
stripeClip: CDBasics.Intersection[
[x1: 0, y1: 0, x2: CDMEBES.maskWidth, y2: did.stripeHeight],
CDBasics.MoveRect[r: dropInClip, offset: CDBasics.NegOffset[offset]]
],
destTrans: CDBasics.AddPoints[offset, CDBasics.SubPoints[dropInOffsetToReticleClip, CDBasics.BaseOfRect[ms.mebesStripeClip]]]
];
ENDLOOP; -- stripe
ENDLOOP; -- segment
s.Close[]; s ← NIL;
};
newData ← did;
};
ENDCASE => ERROR;
END;
ProcessStripe: PROC [ source, dest: IO.STREAM, stripeClip: MEBESRect, destTrans: MEBESPosition ] =
BEGIN
rectCmd: REF DrawRectangle = NEW[DrawRectangle];
DO
t1: CARDINAL ← CDMEBESScan.ReadMebesWord[source];
SELECT t1 MOD 100B FROM
16 => { -- Manhattan Rectangle
destRect: MEBESRect;
x, width, y, height: INT;
height ← t1/100B + 1;
width ← CDMEBESScan.ReadMebesWord[source];
x ← CDMEBESScan.ReadMebesWord[source];
y ← CDMEBESScan.ReadMebesWord[source];
destRect ← CDBasics.Intersection[stripeClip, [x1: x, y1: y, x2: x+width, y2: y+height]];
IF CDBasics.NonEmpty[destRect] THEN {
rectCmd.h ← destRect.y2-destRect.y1;
rectCmd.w ← destRect.x2-destRect.x1;
rectCmd.x ← destRect.x1+destTrans.x;
rectCmd.y ← destRect.y1+destTrans.y;
SendCommand[dest, rectCmd];
};
};
17, 18, 19 => { -- Parallelogram, Trapezoid 1/2
UnimplementedGeom[];
source.SetIndex[source.GetIndex[]+10];
};
20 => { -- Trapezoid 3
UnimplementedGeom[];
source.SetIndex[source.GetIndex[]+12];
};
10, 7 => NULL; -- start of segment or small stripe number
2 => [] ← CDMEBESScan.ReadMebesWord[source]; -- start of large stripe number
8 => RETURN; -- end of stripe
4 => RETURN; -- end of drawing
9 => { -- end of buffer
i: INT = source.GetIndex[]+CDMEBES.mebesBlockSize-1;
source.SetIndex[i - (i MOD CDMEBES.mebesBlockSize)];
};
ENDCASE => ERROR CDMEBESScan.NotMEBESFormat;
ENDLOOP;
END;
warnIfUnimplGeom: BOOLTRUE;
UnimplementedGeom: PROC =
{IF warnIfUnimplGeom THEN SIGNAL UnImplementedGeometry};
UnImplementedGeometry: SIGNAL = CODE;
Module START code...
END. -- of CDMEBESDropInImpl