DIRECTORY CD, CDInstances, CDBasics, CDRects, CDSequencer, CDCallSpecific, CDOps, CDOrient, CDProperties, TerminalIO; CDSplitWireCommands: CEDAR PROGRAM IMPORTS CDInstances, CDBasics, CDOps, CDOrient, CDProperties, CDSequencer, TerminalIO, CDRects = BEGIN SplitApplication: PROC [design: CD.Design, inst: CD.Instance, from, to: CD.Position] = BEGIN NearlyRoundToLambda: PROC[x: CD.Number] RETURNS[r: CD.Number] = BEGIN lambda: CD.Number = design.technology.lambda; r _ (x/lambda)*lambda; END; cutPos: CD.Position; L1, L2, W1, W2: CD.Number; wireLeft, wireRight: CD.Object; inter: CD.Position; -- the intersection of the two lines, if any, and the center of the wire oldRect: CD.Rect _ CDInstances.InstRectI[inst]; -- the bounding box oldSize: CD.Position _ CDBasics.SizeOfRect[oldRect]; vertical: BOOL _ oldSize.y > oldSize.x; dx: CD.Number _ to.x-from.x; dy: CD.Number _ to.y-from.y; ctr: CD.Position _ CDBasics.Center[oldRect]; IF vertical AND (dx=0) OR (NOT vertical) AND (dy=0) THEN RETURN; inter _ IF vertical THEN [ctr.x, NearlyRoundToLambda[from.y+(dy*(ctr.x-from.x)/dx)]] ELSE [NearlyRoundToLambda[dx*(ctr.y-from.y)/dy+from.x], ctr.y]; IF NOT (CDBasics.InsidePos[inter, CDBasics.ToRect[from, to]] AND CDBasics.InsidePos[inter, CDBasics.Extend[oldRect, -1]]) THEN RETURN; cutPos _ IF vertical THEN [oldRect.x1, inter.y] ELSE [inter.x, oldRect.y1]; IF vertical THEN { L1 _ cutPos.y - oldRect.y1; L2 _ oldSize.y - L1; W1 _ W2 _ oldSize.x; } ELSE { L1 _ L2 _ oldSize.y; W1 _ cutPos.x - oldRect.x1; W2 _ oldSize.x - W1; }; wireLeft _ CDRects.CreateRect[CDOrient.OrientedSize[[W1, L1], inst.orientation], inst.ob.layer]; wireRight _ CDRects.CreateRect[CDOrient.OrientedSize[[W2, L2], inst.orientation], inst.ob.layer]; CDOps.IncludeInstance[design, CDInstances.NewInstI[wireLeft, CDBasics.BaseOfRect[oldRect], inst.orientation, TRUE, CDProperties.DCopyProps[inst.properties]], FALSE]; CDOps.IncludeInstance[design, CDInstances.NewInstI[wireRight, cutPos, inst.orientation, TRUE, CDProperties.DCopyProps[inst.properties]], FALSE]; CDOps.RemoveInstance[design, inst]; END; DoAllSplits: PROC [design: CD.Design, from, to: CD.Position, pointed: BOOL_FALSE] = BEGIN FOR list: CD.InstanceList _ CDOps.InstList[design], list.rest WHILE list#NIL DO IF list.first.selected AND list.first.ob.class.wireTyped THEN SplitApplication[design, list.first, from, to]; ENDLOOP; END; SplitWireCommandS: PROC [comm: CDSequencer.Command] = BEGIN TerminalIO.WriteRope["Split selected\n"]; DoAllSplits[design: comm.design, from: comm.sPos, to: comm.pos, pointed: FALSE] END; CDSequencer.ImplementCommand[$SplitWireS, SplitWireCommandS]; END. κCDSplitWireCommands.mesa (part of ChipNDale) Copyright c 1984, 1985 by Xerox Corporation. All rights reserved. Last Edited by: Monier, July 24, 1984 11:31:03 am PDT Last Edited by: Jacobi, Jacobi, April 11, 1985 9:18:19 am PST Last Edited by: Bertrand Serlet October 6, 1985 6:44:38 pm PDT Last Edited by: Jacobi, March 12, 1986 1:05:30 pm PST --Test if vector parallel to wire --Now we can divide and find the intersection of lines (not yet segments) --Monier-Sindhu theorem: if inter is in cursorBox and in oldRect, then it is the intersection of segments --The mouse track defines the cut vector. Let's define the "spine" of a wire as the centerline, roughly in the middle (lambda) and following the visible length, i.e. the longer edge, not the CD length. Then we cut the wire at the position where the spine meets the cut vector. The cut always reduces the visible length of the wire. (Pff, not easy to describe without drawing!) --A vertical wire freshly drawn has even (0) orientation. Κ,˜codešœ.™.Kšœ Οmœ7™BK™5K™=K™>K™5K˜—šΟk ˜ Kšžœ˜K˜ Kšœ ˜ K˜K˜ K˜Kšœ˜K˜ K˜ K˜ —K˜šΠblœžœž˜"KšžœZ˜a—Kšž˜K˜š Οnœžœ žœžœžœ ˜VKšž˜š  œžœžœ žœžœ ˜?Kšž˜Kšœžœ#˜-Kšœ˜Kšžœ˜—K˜Kšœžœ ˜Kšœžœ˜Kšœžœ˜Kšœžœ ΟcH˜\Kšœ žœ%‘˜CKšœ žœ)˜4Kšœ žœ˜'Kšœžœžœ˜9Kšœžœ%˜,Kšœ!™!Kšžœ žœžœžœ žœžœžœ˜@KšœI™Išœžœ ˜Kšžœ<˜@Kšžœ;˜?—Kšœi™iKš žœžœ7žœ:žœžœ˜†Kšœ žœ žœžœ˜Kšžœ žœ˜Kšœ˜Kšœ˜Kšœ˜K˜—šžœ˜Kšœ˜Kšœ˜Kšœ˜K˜—Kšœ`˜`Kšœa˜aKšœmžœ-žœ˜₯KšœXžœ-žœ˜Kšœ#˜#Kšžœ˜—K˜š   œžœ žœžœžœžœ˜SKšž˜Kšœψ™ψK™9š žœžœ2žœžœž˜OKšžœžœžœ0˜mKšžœ˜—Kšžœ˜—K˜š œžœ˜5Kšž˜K˜)KšœIžœ˜OKšžœ˜—K˜Kšœ=˜=Kšžœ˜K˜J˜J˜—…— J`