IntTransDefs: CEDAR DEFINITIONS = BEGIN ContextStack: TYPE = LIST OF Transform _ NIL; Transform: TYPE = REF TransformRecord; TransformRecord: TYPE = RECORD[ type: [ident..translate+rotscale], a11,a21,a31,a12,a22,a32,a33: REAL]; ident: INTEGER = 0; translate: INTEGER = 1; rotscale: INTEGER = 2; CoordName: TYPE = {x,y}; InitTransformation: PUBLIC PROCEDURE RETURNS [BOOL]; FinishTransformation: PUBLIC PROCEDURE RETURNS [BOOL]; FreezeContext: PUBLIC PROCEDURE RETURNS [cs: ContextStack]; SwapContext: PUBLIC PROCEDURE [cs: ContextStack]; Push: PUBLIC PROCEDURE; Pop: PUBLIC PROCEDURE; Rotate: PUBLIC PROCEDURE[xRot,yRot: INT]; Translate: PUBLIC PROCEDURE[xTrans,yTrans: INT]; Mirror: PUBLIC PROCEDURE[coord: CoordName]; Scale: PUBLIC PROCEDURE[numerator,denominator: INT]; GetLocal: PUBLIC PROCEDURE RETURNS[localTransform: TransformRecord]; ApplyLocal: PUBLIC PROCEDURE[transform: TransformRecord]; GetCurrent: PUBLIC PROCEDURE RETURNS[currentTransform: TransformRecord]; TransformPoint: PUBLIC PROCEDURE[x,y: INT] RETURNS[xT,yT: INT]; TransformVector: PUBLIC PROCEDURE[x,y: INT] RETURNS[xT,yT: INT]; RTransformPoint: PUBLIC PROCEDURE[x,y: REAL] RETURNS[xT,yT: REAL]; RTransformVector: PUBLIC PROCEDURE[x,y: REAL] RETURNS[xT,yT: REAL]; TransformationStackUnderflow: PUBLIC ERROR; TransformationBadContext: PUBLIC ERROR; END. ŠFile: IntTransDefs.mesa Written by Martin Newell, July 1979 Last edited June 10, 1981 11:12 AM Last Edited by: McCreight, January 30, 1985 3:15:41 pm PST ************************************************************************************* This package of transformation procedures is designed to support the processing of CalTech Intermediate Form files on an Alto computer. The impact of these requirements are threefold: 1) nesting of transformations involves post-multiplication of the incremental transformation and premultiplication of the current transformation; 2) input parameters specified in (long) integers (no reals); and 3) slow floating point support. The package supports the tree structure of transformations found in nested calls to CIF symbols by implementing a stack of transformations. In addition to the stack there is a "Current Transformation" and a "Local Transformation". The Current transformation represents the accumulated effect of all the transformations invoked. The Local transformation describes the relationship of the current transformation, or coordinate system, to the previous one. A new coordinate system is started by calling Push. This pushes the Current transformation onto the stack, and sets the Local transformation to the identity; the Current transformation is not changed yet. Subsequent calls to transformation procedures such as Rotate, Translate, etc. cause the Local transformation to be post-multiplied by appropriate matrices. As soon as a call is made to a procedure that needs to use the Current transformation (e.g. TransformPoint) the Current transformation is pre-multiplied by the Local transformation to yield a new Current transformation describing the current coordinate system. The current coordinate system is terminated by a call to Pop which simply pops the top of the stack into the Current transformation. Calls to procedures in the package must be arranged (sequentially) into nested "Blocks", where a Block has the form: Push; ; ; Pop; Failure to conform to this sequence will result in the ERROR TransformationBadContext, e.g. by calling Rotate after TransformPoint without an intervening Push. The only other ERROR generated by the package is TransformationStackUnderflow. For use with CIF it is expected that direct execution of a call to a CIF symbol would result in a Push, calls to the relevant transformations in the same order as they are given in the CIF line, invocation of the CIF symbol, Pop. e.g. the CIF statement: CS100 MX R-1,1 T10,20 would be executed by: Push; Mirror[x]; Rotate[-1,1]; Translate[10,20]; "InvokeSymbol[100]"; Pop; For generating the compiled form of a symbol, the above statement would generate: Push; Mirror[x]; Rotate[-1,1]; Translate[10,20]; T_GetLocal[]; "SaveCompiledFormOfInvokeSymbol[100]WithTransformation[T]"; Pop; The compiled form would then be executed by the sequence: Push; ApplyLocal[@T]; "InvokeSymbol[100]"; Pop; New addition - March 1980 - Contexts The package supports multiple transformation contexts, for use in processing CIF files in an order different from a walk of the symbol structure. This is for use with an Interpreter that does sorting based on geometry. The current transformation can be "frozen" to produce a new context, on which the usual Push, Pop, Rotate etc. operations can be performed. See FreezeContext and SwapContext. ************************************************************************************* Initialize (or re-initialize) Transformations package Create new context based on existing context state Change context to cs, formerly returned by FreezeContext Push current transformation - start a new relative coordinate system Pop current transformation - return to previous coordinate system Rotate x axis to direction of (xRot,yRot) Translate by (xTrans,yTrans) Mirror the indicated coordinates Scale by numerator/denominator Return incremental transformation built since last Push Apply transformation to current local transformation Return current cumulative transformation Transform the point (x,y) by current cumulative transformation Transform the direction (x,y) by current cumulative transformation Transform the point (x,y) by current cumulative transformation - in REALs Transform the direction (x,y) by current cumulative transformation - in REALs ʼ˜J˜Jšœ™Jšœ#™#Jšœ#™#Jšœ:™:J™JšœÏkœ œ˜!J˜JšœU™UJ˜JšœR™RJšœV™VJšœP™PJšœO™OJšœW™WJšœ™J˜JšœW™WJšœV™VJšœT™TJšœP™PJšœV™VJšœ™J˜JšœM™MJšœU™UJšœN™NJšœO™OJšœR™RJšœN™NJšœS™SJšœW™WJšœV™VJšœ™J˜JšœX™XJšœ™J˜Jšœ™JšœH™HJšœS™SJšœ™J˜JšœV™VJšœH™HJ˜JšœN™NJ˜JšœU™UJšœU™UJšœQ™QJ˜Jšœ™J˜Jšœ™J˜JšœJ™JJ˜J˜JšœQ™QJ˜Jšœ>™>Jšœ;™;Jšœ™J˜Jšœ9™9J˜Jšœ/™/J˜Jšœ$™$JšœP™PJšœQ™QJšœE™EJšœQ™QJšœQ™QJ˜JšœU™UJ˜Jš˜J˜Jš œœœœ œ˜-Jšœ œœ˜&šœœœ˜J˜"Jšœœ˜#J˜Jšœœ˜Jšœ œ˜Jšœ œ˜J˜—Jšœ œ ˜J˜Jš Ïnœœ œœœ˜4Jšœ5™5J˜Jš žœœ œœœ˜6J˜Jšž œœ œœ˜;Jšœ2™2J˜Jšž œœ œ˜1Jšœ8™8J˜Jšžœœ œ˜JšœD™DJ˜Jšžœœ œ˜JšœA™AJ˜Jšžœœ œ œ˜)Jšœ)™)J˜Jšž œœ œœ˜0Jšœ™J˜Jšžœœ œ˜+Jšœ ™ J˜Jšžœœ œœ˜4Jšœ™J˜Jšžœœ œœ"˜DJšœ7™7J˜Jšž œœ œ˜9Jšœ4™4J˜Jšž œœ œœ$˜HJšœ(™(J˜Jš žœœ œœœœ˜?Jšœ>™>J˜Jš žœœ œœœœ˜@JšœB™BJ˜Jš žœœ œœœœ˜BJšœI™IJ˜Jš žœœ œœœœ˜CJšœM™MJ˜Jšœœœ˜+Jšœœœ˜'J˜Jšœ˜J˜J˜—…—^¤