--Write Contour --Written by M.Stone --Last changed by M.Stone 8-Jan-82 14:49:20 DIRECTORY CurveDefs, GriffinFig, Rope USING [Ref], Vector USING[Add,Mul,Vec]; CurveFitIO: PROGRAM IMPORTS GriffinFig,Vector EXPORTS CurveDefs = BEGIN OPEN CurveDefs; lineStyleID: GriffinFig.LineStyleID; OpenFile: PUBLIC PROC [file: Rope.Ref] = { black: GriffinFig.ColorID; GriffinFig.NewFile[file]; black ← GriffinFig.Color[0,0,0,177777B]; lineStyleID ← GriffinFig.LineStyle[black,1]; }; CloseFile: PUBLIC PROC = {GriffinFig.CloseFile}; WriteContour: PUBLIC PROC[contour: ContourHandle, s: REAL, t: Vector.Vec] = { sl: SListHandle ← contour.sLists; enter: PROC[sa: SampleHandle] = {GriffinFig.EnterPoint[XFormPt[sa.xy]]}; scale ← s; translate ← t; GriffinFig.StartPath[]; ForAllSamples[contour,enter]; GriffinFig.EnterPoint[XFormPt[sl.samples.xy]]; [] ← GriffinFig.LineObject[lineStyleID, GriffinFig.EndPath[]]; }; WriteSamples: PUBLIC PROC[samples: SampleHandle] = { s: SampleHandle ← samples; GriffinFig.StartPath[]; DO GriffinFig.EnterPoint[s.xy]; s ← s.next; IF s=NIL OR s=samples THEN EXIT; ENDLOOP; [] ← GriffinFig.EndPath[]; }; WriteTraj: PUBLIC PROCEDURE[t: TrajHandle, first: BOOLEAN ← FALSE] = { l: LinkHandle ← t.links; IF first THEN GriffinFig.StartPath[] ELSE GriffinFig.NewBoundary[]; DO GriffinFig.EnterCubic[l.cubic]; IF l=t.lastLink THEN EXIT ELSE l ← l.next; ENDLOOP; [] ← GriffinFig.EndPath[]; }; scale: REAL ← 1; translate: Vector.Vec ← [0,0]; XFormPt: PROC[p: Vector.Vec] RETURNS [Vector.Vec] = { RETURN[Vector.Mul[Vector.Add[translate,p],scale]]; }; ForAllSamples: PROC [c: ContourHandle,proc: PROC[sa: SampleHandle]] = { sl: SListHandle ← c.sLists; sa: SampleHandle ← NIL; UNTIL sl=NIL DO sa ← sl.samples; UNTIL sa=NIL DO proc[sa]; IF sa=sl.lastSample THEN EXIT ELSE sa ← sa.next; ENDLOOP; IF sl=c.lastSList THEN EXIT ELSE sl ← sl.next; ENDLOOP }; END.