|
|
1.1 ! root 1: /******************************************************************* ! 2: * * ! 3: * File: CIFPLOT/print.c * ! 4: * Written by Dan Fitzpatrick * ! 5: * copyright 1980 -- Regents of the University of California * ! 6: * * ! 7: ********************************************************************/ ! 8: ! 9: #include <stdio.h> ! 10: #include "defs.h" ! 11: #include "globals.h" ! 12: #include "parser_defs.h" ! 13: #include "structs.h" ! 14: #include "out_structs.h" ! 15: ! 16: IMPORT struct LCell *GetLayer(); ! 17: IMPORT long time(); ! 18: IMPORT char *ctime(); ! 19: ! 20: FILE *inter; ! 21: ! 22: int SymbCount = 0; ! 23: ! 24: #define PRINTED 113 ! 25: ! 26: Intermediate() ! 27: { ! 28: long t; ! 29: if(NULL == (inter = fopen(outfile,"w"))) { ! 30: char a[128]; ! 31: sprintf(a,"Can't create %s",outfile); ! 32: Error(a,RUNTIME); ! 33: } ! 34: ! 35: fprintf(inter,"(CIF 2.UCB-1);\n"); ! 36: t = time(0); ! 37: fprintf(inter,"(%s: %s%s);\n",getlogin(),ctime(&t),banner); ! 38: fprintf(inter,"();\n"); ! 39: fprintf(inter,"();\n"); ! 40: PrintBBox(&(prog->CBBox),inter); ! 41: ! 42: PrintSymbol(prog,inter); ! 43: fprintf(inter,"C %d;\nE\n",SymbCount-1); ! 44: exit(0); ! 45: } ! 46: ! 47: PrintSymbol(symb,inter) ! 48: Command *symb; ! 49: FILE *inter; ! 50: { ! 51: Command *p; ! 52: ! 53: if(symb->type != SYMBOL) ! 54: Error("PrintSymbol call with non-symbol",INTERNAL); ! 55: if(symb->Ctype.Symbl.status == PRINTED) ! 56: return; ! 57: ! 58: for(p=symb->Ctype.Symbl.CStart; p!=NIL; p=p->CLink) { ! 59: if( p->type == CALL) ! 60: PrintSymbol(p->Ctype.Call.CSymb,inter); ! 61: if(p->type == ARRAY) { ! 62: PrintSymbol(p->Ctype.Array.ACom->Ctype.Call.CSymb,inter); ! 63: CreateArray(p,inter); ! 64: } ! 65: } ! 66: ! 67: fprintf(inter,"DS %d;\n",SymbCount); ! 68: PrintBBox(&(symb->CBBox),inter); ! 69: fprintf(inter,"(Symbol #%d);\n",symb->Ctype.Symbl.SymNo); ! 70: fprintf(inter,"(9 %s);\n",symb->Ctype.Symbl.SName); ! 71: symb->Ctype.Symbl.Sid = SymbCount++; ! 72: symb->Ctype.Symbl.status = PRINTED; ! 73: ! 74: for(p=symb->Ctype.Symbl.CStart; p!=NIL; p=p->CLink) ! 75: PrintCommand(p,inter); ! 76: fprintf(inter,"DF;\n"); ! 77: } ! 78: ! 79: CreateArray(com,inter) ! 80: Command *com; ! 81: FILE *inter; ! 82: { ! 83: int i; ! 84: ! 85: fprintf(inter,"DS %d;\n",SymbCount++); ! 86: PrintBBox(&(com->CBBox),inter); ! 87: for(i=0;i<com->Ctype.Array.Am;i++) ! 88: fprintf(inter,"C %d T %d 0;\n", ! 89: com->Ctype.Array.ACom->Ctype.Call.CSymb->Ctype.Symbl.Sid, ! 90: i*(int) com->Ctype.Array.Adx); ! 91: fprintf(inter,"DF;\n"); ! 92: fprintf(inter,"DS %d;\n",SymbCount++); ! 93: PrintBBox(&(com->CBBox),inter); ! 94: for(i=0;i<com->Ctype.Array.An;i++) ! 95: fprintf(inter,"C %d T 0 %d;\n", ! 96: SymbCount-2,i*(int) com->Ctype.Array.Ady); ! 97: fprintf(inter,"DF;\n"); ! 98: com->Ctype.Array.As = SymbCount-1; ! 99: } ! 100: ! 101: PrintCommand(com,inter) ! 102: Command *com; ! 103: FILE *inter; ! 104: { ! 105: switch(com->type) { ! 106: case POLYGON: ! 107: PrintLayer(com->level,inter); ! 108: fprintf(inter,"P"); ! 109: PrintPath(com->Ctype.Path,inter); ! 110: fprintf(inter,";\n"); ! 111: /* ! 112: PrintBBox(&(com->CBBox),inter); ! 113: */ ! 114: break; ! 115: case WIRE: ! 116: PrintLayer(com->level,inter); ! 117: fprintf(inter,"W"); ! 118: /* Print the width */ ! 119: fprintf(inter," %d",(int) com->Ctype.Wire.WWidth); ! 120: PrintPath(com->Ctype.Wire.WPath,inter); ! 121: fprintf(inter,";\n"); ! 122: /* ! 123: PrintBBox(&(com->CBBox),inter); ! 124: */ ! 125: break; ! 126: case FLASH: ! 127: PrintLayer(com->level,inter); ! 128: fprintf(inter,"R %d %d,%d;\n", ! 129: (int) com->Ctype.Flash.fdia, ! 130: (int) com->Ctype.Flash.fcenter.x, ! 131: (int) com->Ctype.Flash.fcenter.y); ! 132: break; ! 133: case BOX: ! 134: PrintLayer(com->level,inter); ! 135: fprintf(inter,"B %d %d %d,%d %d,%d;\n", ! 136: (int) com->Ctype.Box.blength, ! 137: (int) com->Ctype.Box.bwidth, ! 138: (int) com->Ctype.Box.bcenter.x, ! 139: (int) com->Ctype.Box.bcenter.y, ! 140: (int) com->Ctype.Box.bdirect.x, ! 141: (int) com->Ctype.Box.bdirect.y); ! 142: /* ! 143: PrintBBox(&(com->CBBox),inter); ! 144: */ ! 145: break; ! 146: case TEXT: ! 147: fprintf(inter,"2 \"%s\" ",com->Ctype.Text.TString); ! 148: PrintTransform(com->Ctype.Text.TTrans,inter); ! 149: fprintf(inter,";\n"); ! 150: break; ! 151: case POINTNAME: ! 152: fprintf(inter,"94 %s %d %d",com->Ctype.PointName.Name, ! 153: (int) com->Ctype.PointName.loc.x, ! 154: (int) com->Ctype.PointName.loc.y); ! 155: if(strcmp(com->Ctype.PointName.Label,"all") != 0) ! 156: fprintf(inter," %s",com->Ctype.PointName.Label); ! 157: fprintf(inter,";\n"); ! 158: break; ! 159: case ARRAY: ! 160: fprintf(inter,"C %d;\n",com->Ctype.Array.As); ! 161: /* ! 162: fprintf(inter,"0A %d %d,%d %d,%d;\n", ! 163: com->Ctype.Array.ACom->Ctype.Call.CSymb->Ctype.Symbl.Sid, ! 164: com->Ctype.Array.An,com->Ctype.Array.Am, ! 165: (int) com->Ctype.Array.Adx, ! 166: (int) com->Ctype.Array.Ady); ! 167: */ ! 168: /* ! 169: PrintBBox(&(com->CBBox),inter); ! 170: */ ! 171: break; ! 172: case CALL: ! 173: fprintf(inter,"C %d",com->Ctype.Call.CSymb->Ctype.Symbl.Sid); ! 174: PrintTransform(com->Ctype.Call.trans,inter); ! 175: fprintf(inter,";\n"); ! 176: /* ! 177: PrintBBox(&(com->CBBox),inter); ! 178: */ ! 179: break; ! 180: case SYMBOL: ! 181: PrintSymbol(com,inter); ! 182: break; ! 183: default: ! 184: Error("Unknown type of command in PrintCommand",INTERNAL); ! 185: } ! 186: } ! 187: ! 188: PrintPath(p,f) ! 189: PointList *p; ! 190: FILE *f; ! 191: { ! 192: for(; p != NIL; p = p->PLink) { ! 193: fprintf(f," %d,%d",(int)p->pt.x,(int)p->pt.y); ! 194: } ! 195: } ! 196: ! 197: PrintBBox(bbox,f) ! 198: struct BBox *bbox; ! 199: FILE *f; ! 200: { ! 201: fprintf(f,"(BB %d %d %d %d);\n", ! 202: (int) bbox->xmin,(int) bbox->xmax, ! 203: (int) bbox->ymin,(int) bbox->ymax); ! 204: } ! 205: ! 206: PrintTransform(trans,f) ! 207: transform *trans; ! 208: FILE *f; ! 209: { ! 210: int i,j; ! 211: ! 212: /* ! 213: fprintf(f," MT"); ! 214: for(i=0;i<3;i++) { ! 215: for(j=0;j<2;j++) ! 216: fprintf(f," %f", trans->t[i][j]); ! 217: } ! 218: */ ! 219: fprintf(f,"%s",trans->TransString); ! 220: } ! 221: ! 222: PrintLayer(n,f) ! 223: int n; ! 224: FILE *f; ! 225: { ! 226: struct LCell *p; ! 227: ! 228: p = GetLayer(n); ! 229: if(p == NIL) ! 230: Error("Can't find layer name in PrintLayer",INTERNAL); ! 231: fprintf(f,"L %s;\n",p->LName); ! 232: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.