Annotation of 41BSD/cmd/cifplot/plot.c, revision 1.1.1.1

1.1       root        1: /*******************************************************************
                      2: *                                                                  *
                      3: *    File: CIFPLOT/plot.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: #define CONST 4
                     17: 
                     18: IMPORT GetList();
                     19: IMPORT ICompare();
                     20: IMPORT instance *GetUnAct();
                     21: 
                     22: Plot()
                     23: {
                     24:      int i,j,k;
                     25: 
                     26:       vopen();
                     27:       Instanciate(prog,GlobalTransform,0);
                     28:       NextEdge = -INFINITY;
                     29:       for(i=CONVERT((real) prog->CBBox.xmin - 1); i<Bottom;i=Sift(i));
                     30:       for(j = Bottom; j<=Top+40; j += OUT_BUF_SIZE) {
                     31:        for(i = j; i < j+OUT_BUF_SIZE; i++) {
                     32:            Sift(i);
                     33:            if(i>=LastEdge) RemoveEdges(i);
                     34:            /*
                     35:            if(i>=NextEdge) 
                     36:            */
                     37:                AddEdges(i);
                     38:            Sort(i);
                     39:            ScanActives(i);
                     40:            }
                     41:        i = j + OUT_BUF_SIZE;
                     42:        /* We're at the end of output buffer, send remaining traps */
                     43:        finishBuf = 1;
                     44:        for(k=0;k<UsedLayers;k++) change[k] = 1;
                     45:        Sift(i);
                     46:        if(i>=LastEdge) RemoveEdges(i);
                     47:        /*
                     48:        if(i>=NextEdge) 
                     49:        */
                     50:            AddEdges(i);
                     51:        Sort(i);
                     52:        ScanActives(i);
                     53:        DumpBuf(i);
                     54:        finishBuf = 0;
                     55:        for(k=0;k<UsedLayers;k++) AddLine(k,i);
                     56:        }
                     57:     vclose();
                     58:     }
                     59: 
                     60: Sift(i)
                     61: register int i;
                     62: {
                     63:     register instance *p;
                     64: 
                     65:     while((p=GetUnAct(i)) != NIL) {
                     66:        Activate(p);
                     67:        }
                     68:     return(FindNext(i));
                     69:     }
                     70: 
                     71: InitPlotter()
                     72: {
                     73:     int i;
                     74:     Top = CONVERT((real) Window.xmax) + 1;
                     75:     xLast = Bottom = CONVERT((real) Window.xmin - 1) - 1;
                     76:     EdgeQueue = (Queue *) alloc(UsedLayers*sizeof(Queue));
                     77:     NEdgeQueue = (Queue *) alloc(UsedLayers*sizeof(Queue));
                     78:     ActiveEdges = (List *) alloc(UsedLayers*sizeof(List));
                     79:     NecEdgeQueue = (Queue *) alloc(UsedLayers*sizeof(Queue));
                     80:     EdgeEnd = (int *) alloc(UsedLayers*sizeof(int));
                     81:     EdgeStart = (int *) alloc(UsedLayers*sizeof(int));
                     82:     EdgeIntersection = (int *) alloc(UsedLayers*sizeof(int));
                     83:     Valid = (int *) alloc(UsedLayers*sizeof(int));
                     84:     Drawn = (int *) alloc(UsedLayers*sizeof(int));
                     85:     NextChange = (int *) alloc(UsedLayers*sizeof(int));
                     86:     EdgeHolder = (nedge **) alloc(UsedLayers*sizeof(nedge));
                     87:     change = (int *) alloc(UsedLayers*sizeof(int));
                     88:     xprev = (int *) alloc(UsedLayers*sizeof(int));
                     89:     NextEdge = LastEdge = INFINITY;
                     90:     finishBuf = 0;
                     91:     DummyPoly.level = 0;
                     92:     DummyPoly.count = 0;
                     93:     DummyPoly.refs = 0;
                     94:     for(i=0;i<UsedLayers;i++) {
                     95:        EdgeEnd[i] = INFINITY;
                     96:        EdgeStart[i] = Bottom;
                     97:        EdgeIntersection[i] = INFINITY;
                     98:        Valid[i] = INFINITY;
                     99:        Drawn[i] = -INFINITY;
                    100:        NextChange[i] = -INFINITY;
                    101:        EdgeHolder[i] = NIL;
                    102:        change[i] = 0;
                    103:        xprev[i] = -INFINITY;
                    104:        InitQueue(&(EdgeQueue[i]));
                    105:        InitQueue(&(NEdgeQueue[i]));
                    106:        InitQueue(&(NecEdgeQueue[i]));
                    107:        InitList(&(ActiveEdges[i]));
                    108:        }
                    109:     InitList(&TempList);
                    110:     InitUnAct();
                    111:     InitQueue(&FreeHolders);
                    112:     InitList(&TextList);
                    113:     InitScan();
                    114:     }
                    115: 
                    116: ReStartPlotter()
                    117: {
                    118:     int i;
                    119:     InitPlotter();
                    120:     NextEdge = LastEdge = INFINITY;
                    121:     DummyPoly.level = 0;
                    122:     DummyPoly.count = 0;
                    123:     DummyPoly.refs = 0;
                    124:     for(i=0;i<UsedLayers;i++) {
                    125:        EdgeEnd[i] = INFINITY;
                    126:        EdgeStart[i] = Bottom;
                    127:        EdgeIntersection[i] = INFINITY;
                    128:        Valid[i] = INFINITY;
                    129:        Drawn[i] = -INFINITY;
                    130:        NextChange[i] = -INFINITY;
                    131:        EdgeHolder[i] = NIL;
                    132:        change[i] = 0;
                    133:        InitQueue(&(EdgeQueue[i]));
                    134:        InitQueue(&(NEdgeQueue[i]));
                    135:        InitQueue(&(NecEdgeQueue[i]));
                    136:        InitList(&(ActiveEdges[i]));
                    137:        }
                    138:     }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.