BEGIN
data: CellInfoRef ← NEW[CellInfo] ;
ap: CD.ApplicationPtr;
cornerCell: CD.ObPtr;
cellPtr: CD.CellPtr;
dr: CD.DrawRef = CD.NewNullDeviceDrawRef[design] ;
tes ← CornerStitching.NewTesselation[] ;
dr.minimalSize ← 0;
dr.drawRect ← dr.saveRect ← NoteMetalRectangle;
dr.worldClip ← CDInline.universe;
place cell in design so that it can be cornerstitched
ap ← DrawCell[cell] ;
mark all the metal rectangles for stitching
CDOps.DrawDesign[design, dr] ;
create and include new cell, with baseLine
{
cornerCell ← CDCells.CreateEmptyCell[];
cellPtr ← NARROW[cornerCell.specificRef, CD.CellPtr] ;
cellPtr.name ← Rope.Replace[ base: NARROW[cell.specificRef, CD.CellPtr].name, start: 0, len: 1, with: NIL];
cornerCell.size ← [x: l, y: l] ;
[] ← CDDirectory.Include[design: design, object: cornerCell] ;
[] ← CDCells.IncludeApplication[design: design, cell: cornerCell, aptr: baseLine, draw: FALSE] ;
};
include new cornerstitched applications for cell
data.cell ← cornerCell;
data.relOrigin ← baseLine;
[] ← tes.EnumerateArea[rect: [x1: 0, y1: 0, x2: cell.size.x, y2: cell.size.y] , perTile: IncludeTile, data: data] ;
CornerStitching.FreeTesselation[plane: tes] ;
move baseLine of new cell
[] ← CDCells.IncludeApplication[design: design, cell: cornerCell,
aptr: finalBaseLine,
draw: FALSE, relativeTo: baseLine] ;
[] ← CDCells.RemoveApplication[design: design, cell: cornerCell, aptr: baseLine, draw: FALSE] ;
remove old cell from design
CDOps.RemoveApplication[design: design, aptr: ap, draw: FALSE] ;