(* LAYER SPLITTING HEURISTIC *) PROCEDURE SplitLayers( dr: Dwg.T; rnd: Random.T; <*UNUSED*> inertia: LONG; count: NAT; <*UNUSED*> name: TEXT; ): Dwg.T = (* Splits layers of "dr" that are too crowded Adds new joint nodes where necessary. *) VAR changed: BOOL := FALSE; BEGIN Wr.PutText(stderr, "AdjustYGen..."); WITH G = dr.G, nV = G.nV, posOld = SUBARRAY(dr.pos^, 0, nV), posNew = NEW(REF Points, G.nV)^ DO posNew := posOld; FOR ct := 1 TO count DO (* Relax the "y" coordinates: *) FOR i := 0 TO nV-1 DO WITH ui = u[i], xCur = posNew[ui][0] + 0, yCur = posNew[ui][1] + 0, yNew = HTools.ChooseLayer(ui, G, posNew, yRef, rnd, method, inertia) DO (* Wr.PutText(stderr, " " & FII(ui,yCur) & "->" FI(yNew) & "\n"); *) posNew[ui] := Point{xCur, yNew}; IF yNew # yCur THEN changed := TRUE END; END END END; IF NOT changed THEN RETURN NIL END; (* Make a copy of the drawing and move the nodes to the new positions: *) WITH dc = dr.copy() DO FOR i := 0 TO nV-1 DO u[i] := i END; LDwg.MoveBaseNodes(dc, u, posNew, FreeX, AddPoly); Wr.PutText(stderr, "\n"); RETURN dc END END; END SplitLayers; (* Last edited on 2000-01-11 11:32:59 by stolfi *)