<> <> <> <> <> <> DIRECTORY Cubic, Complex, FitState, SafeStorage USING [ReclaimCollectibleObjects], JaM, FitJaM, FitBasic, FitStateUtils, FitIO, Real, Rope, Seq, Vector; FitEditJaM: CEDAR PROGRAM IMPORTS Complex, JaM, Real, Vector, FitState, FitJaM, FitIO, FitStateUtils, SafeStorage = { State: TYPE = JaM.State; GetVec: PROC [state: JaM.State] RETURNS [z:Complex.Vec] = { z.y _ JaM.PopReal[state]; z.x _ JaM.PopReal[state]; }; ResetSa: PROC[state: State] = {FitState.ResetData[FitJaM.defaultFitState, samples]}; StartSa: PROC[state: State] = { y: REAL _ JaM.PopReal[state]; x: REAL _ JaM.PopReal[state]; FitState.StartSamples[FitJaM.defaultFitState, x,y]; }; AddSa: PROC[state: State] = { y: REAL _ JaM.PopReal[state]; x: REAL _ JaM.PopReal[state]; FitState.AddSample[FitJaM.defaultFitState, x,y]; }; CountSa: PROC[state: State] = { n: INT _ 0; count: FitStateUtils.SampleProc = {n _ n+1}; FitStateUtils.ForAllSamples[FitJaM.defaultFitState.slist,count]; JaM.PushInt[state,n]; }; SelectSa: PROC [state: JaM.State] = { closest: FitBasic.SampleHandle; z: Complex.Vec; z.y _ JaM.PopReal[state]; z.x _ JaM.PopReal[state]; [closest,] _ FindSa[z]; IF closest#NIL THEN FitJaM.defaultFitState.slist.selectedSample _ closest; }; TheSa: PROC [state: JaM.State] = { JaM.PushReal[state,FitJaM.defaultFitState.slist.selectedSample.xy.x]; JaM.PushReal[state,FitJaM.defaultFitState.slist.selectedSample.xy.y]; }; FindSa: PROC [z: Complex.Vec] RETURNS[found: FitBasic.SampleHandle, index: NAT] = { closest,d: REAL _ 10.0E+30; i: NAT _ 0; do: FitStateUtils.SampleProc = { p: Complex.Vec _ FitIO.MagnifyPoint[s.xy]; IF ABS[p.x-z.x]k DO v: Complex.Vec _ Complex.Add[s.xy, Vector.Mul[delta, i/(k+1)]]; FitState.InsertBeforeSample[FitJaM.defaultFitState, v.x,v.y]; ENDLOOP; from _ to; }; }; FitStateUtils.ForAllSamples[slist, do]; IF closed THEN [] _ do[slist.header.next]; slist.selectedSample _ selected; }; Subrange: PROC [state: JaM.State] = {OPEN FitJaM.defaultFitState; first,last: FitBasic.SampleHandle; p0,p1: Complex.Vec; i0,i1: NAT; p1.y _ JaM.PopReal[state]; p1.x _ JaM.PopReal[state]; [last,i1] _ FindSa[p1]; p0.y _ JaM.PopReal[state]; p0.x _ JaM.PopReal[state]; [first,i0] _ FindSa[p0]; IF i0 CONTINUE]; }; FitStateUtils.ForAllLinks[FitJaM.defaultFitState.traj,do]; }; ResetCon: PROC[state: State] = {FitState.ResetData[FitJaM.defaultFitState, contour, TRUE]}; CountCon: PROC[state: State] = { JaM.PushInt[state, FitState.CountContours[FitJaM.defaultFitState]]}; AddCon: PROC[state: State] = {FitState.NewContour[FitJaM.defaultFitState]}; NextCon: PROC[state: State] = {FitState.NextContour[FitJaM.defaultFitState]}; SetSLen: PROC[state: State] = {[] _ FitState.MinDist[FitJaM.defaultFitState,JaM.PopReal[state]]}; CollectGarbage: PROC[state: State] = { SafeStorage.ReclaimCollectibleObjects[suspendMe: TRUE, traceAndSweep: TRUE]; }; Init: FitJaM.InitProc = { <> JaM.Register[state,".startsa", StartSa]; JaM.Register[state,".resetsa", ResetSa]; JaM.Register[state,".addsa", AddSa]; JaM.Register[state,".countsa", CountSa]; JaM.Register[state,".selectsa", SelectSa]; -- x y => . Selects a sample point for editing JaM.Register[state,".interpolatesa", InterpolateSa]; -- d => . Interpolates samples to make deltas no larger than about d JaM.Register[state,".thesa", TheSa]; -- => x y . Returns the current sample JaM.Register[state,".thetan", TheTan]; -- => x y boolean . Returns the tangent of the current sample, and whether it is a node JaM.Register[state,".deletesa", DeleteSa]; -- => . Deletes the current sample JaM.Register[state,".insertsa", InsertSa]; -- x y => . Inserts before the current sample JaM.Register[state,".insertbetween", InsertBetween]; -- x y => . Inserts between the current sample and the neighbor nearest the new point JaM.Register[state,".nodesa", NodeSa]; -- boolean => . Makes or unmakes a node JaM.Register[state,".tansa", TanSa]; -- deltax deltay => . Sets the tangent at a sample JaM.Register[state,".cuspsa", CuspSa]; -- boolean => . Makes or unmakes a cusp JaM.Register[state,".cuspnode", CuspNode]; -- boolean => . Makes or unmakes a cusp ONLY on a node JaM.Register[state,".tanoutsa", TanOutSa]; -- deltax deltay => . Sets the outgoing tangent JaM.Register[state,".homesa", HomeSa]; -- => . Selects the header JaM.Register[state,".makefirstsa", MakeFirstSa]; -- => . Selects the header JaM.Register[state,".nextsa", NextSa]; -- => x y . Moves selection to the next sample JaM.Register[state,".prevsa", PrevSa]; -- => x y . Moves selection to the previous sample JaM.Register[state,".scalesa", ScaleSa]; -- x y => . Scales/rotates all samples by multiplying by x+iy JaM.Register[state,".transa", TranSa]; -- x y => . Translates all samples by adding x+iy JaM.Register[state,".subrange", Subrange]; -- change CurrentSamples so it returns a subrange JaM.Register[state,".allsa", NoSubrange]; -- remove the subrange JaM.Register[state,".resetnodes", ResetDefaultNodes]; -- remove the nodes JaM.Register[state,".resetcusps", ResetDefaultCusps]; -- remove the cusps JaM.Register[state,".foralllinks", ForAllLinks]; JaM.Register[state,".nextcon", NextCon]; JaM.Register[state,".resetcon", ResetCon]; JaM.Register[state,".addcon", AddCon]; JaM.Register[state,".countcon", CountCon]; JaM.Register[state,".setslen", SetSLen]; JaM.Register[state,".collectgarbage", CollectGarbage]; }; FitJaM.RegisterInit[$FitEditJaM, Init]; }. <> <> <> <> <> <

> <> <> <<};>> < . moves the selected sample so it is colinear with its two left neightbors and with its two right neighbors>> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <<};>> <<>>