Ejemplo n.º 1
0
int getClusterDesc(LifeList *cells, LifeList *working1,
                   LifeList *working2, int ngens, 
                   LifeList *clusters, 
                   ClusterDesc *clusterInfo) {
 int i, nClusters;


/* Warning: the calling procedure has to allocate space for
   the cluster information and an initialized array of LifeLists  */

    nClusters = independentUpTo(cells, working1, working2, ngens);

    /* First, partition the list into clusters, maintaining
       the original ordering of cells within clusters */
    for (i=0; i<nClusters; i++) clusters[i].ncells=0;

    for (i=0; i<cells->ncells; i++) {
        LifeList *thiscluster = &(clusters[cells->cellList[i].value]);

        resizeIfNeeded(thiscluster, (thiscluster->ncells)++);
        thiscluster->cellList[thiscluster->ncells-1]=cells->cellList[i];
        thiscluster->cellList[thiscluster->ncells-1].value=1;
    } 

    /* Now collect information about each cluster */
    for (i=0; i<nClusters; i++) {
       int period;

       clusterInfo[i].osc = simpleOscillation(&(clusters[i]), working1, ngens); 
 
       period=clusterInfo[i].osc.period;

       if (period>=1) {
          cumulativeImage(&(clusters[i]), working1, period); 
          clusterInfo[i].bb = makeBoundingBox(working1->cellList, 
                                              working1->ncells); 
       } else {
          clusterInfo[i].bb = makeBoundingBox(clusters[i].cellList, 
                                              clusters[i].ncells); 
       }

    }

    return nClusters;
}
Ejemplo n.º 2
0
void outPostScript(LifeList *cells, float cellsize, int spacing) {

   int i;
   int x, y;
   int extra;
   BoundingBox bb;

   bb=makeBoundingBox(cells->cellList, cells->ncells);

   if (spacing>0) {
      extra = (spacing-(bb.ux-bb.lx+1)%spacing)%spacing;
      bb.lx-=(extra/2+extra%2);
      bb.ux+=extra/2;

      extra = (spacing-(bb.uy-bb.ly+1)%spacing)%spacing;
      bb.ly-=(extra/2+extra%2);
      bb.uy+=extra/2;
   }

   printf("%%!PS-Adobe-2.0 EPSF-1.2\n");
   printf("%%%%DocumentFonts: Times-Bold\n");
   printf("%%%%Pages: 1\n");
   printf("%%%%BoundingBox: 0 0 %d %d\n", (int) ( cellsize*(float)(bb.ux-bb.lx)
                                                  +2*cellsize + 0.99),
                                          (int) ( cellsize*(float)(bb.uy-bb.ly)
                                                  +2*cellsize + 0.99) );
   printf("%%%%EndComments\n");
   printf("0.3 setlinewidth\n");
   printf("/cell {%f mul exch %f mul exch %f 0 360 arc fill} def\n",
          cellsize, cellsize, 0.3*cellsize);

   if (spacing>0) {
     for (x= -1; x<=bb.ux-bb.lx; x+=spacing)
        printf("%f %f moveto %f %f lineto stroke\n",
                  cellsize*x+1.5*cellsize, 0.5*cellsize,
                  cellsize*x+1.5*cellsize, cellsize*(bb.uy-bb.ly)+1.5*cellsize);

     for (y= -1; y<=bb.uy-bb.ly; y+=spacing)
        printf("%f %f moveto %f %f lineto stroke\n",
                  0.5*cellsize, cellsize*y+1.5*cellsize,
                  cellsize*(bb.ux-bb.lx)+1.5*cellsize, cellsize*y+1.5*cellsize);
   }

   for (i=0; i<cells->ncells; i++) {

      unpack(cells->cellList[i].position, &x, &y);

      printf("%d %d cell\n", (x-bb.lx)+1, (bb.uy-y)+1);
   }
}
Ejemplo n.º 3
0
void outFig(LifeList *cells, int cellboxlen) {
/* Outputs pattern as an Xfig compound object. */

   int i;
   int x, y;
   int extra;
   int cellrad;
   int xlen, ylen;
   int border=3;

   BoundingBox bb;

   cellrad=cellboxlen/3;

   printf("#FIG 3.1\n");
   printf("Landscape\n");
   printf("Center\n");
   printf("Inches\n");
   printf("1200 2\n");

   bb=makeBoundingBox(cells->cellList, cells->ncells);

   xlen = (bb.ux-bb.lx+1+2*border)*cellboxlen;
   ylen = (bb.uy-bb.ly+1+2*border)*cellboxlen;

   printf("6 0 0 %d %d\n", xlen, ylen);

   for (i=0; i<cells->ncells; i++) {
      int figx, figy;

      unpack(cells->cellList[i].position, &x, &y);
      figx=(x-bb.lx+border)*cellboxlen+cellboxlen/2;
      figy=(y-bb.ly+border)*cellboxlen+cellboxlen/2;

      printf("1 3 0 1 -1 7 0 0 0 0.000 1 0.0000 ");
      printf("%d %d %d %d %d %d %d %d\n", figx, figy,
                                        cellrad, cellrad,
                                        figx, figy,
                                        figx+cellrad, figy+cellrad);
   }
      printf("2 2 2 1 -1 7 0 0 -1 3.000 0 0 -1 0 0 5\n");
      printf("\t%d %d %d %d %d %d %d %d %d %d\n",     0,   0, xlen, 0,
                                                xlen, ylen,     0, ylen, 0, 0);
   printf("-6\n");
}
Ejemplo n.º 4
0
//------------------------------------------------------------------------------
Sky::Sky()
{
   id = TribesSkyId;

   dmlName = stringTable.insert("");
   itype = Background; 
   sortValue = BACKGROUND_SORTVALUE;
   //matListTag = 0;
   for (int i = 0; i < 16; i++)
      textures[i] = i%2;
   featurePosition = 0.0f;
   netFlags.set(SimNetObject::ScopeAlways);
   netFlags.set(SimNetObject::Ghostable);

   makeBoundingBox();
   size   = TEXTUREDSKY_HEIGHT;     // size/height 
   distance = TEXTUREDSKY_DISTANCE; // default drawing distance
   paletteKey = 0xffffffff;
   skyIndex  = -1;                  // force color reevaluation
   hazeIndex = -1;
   loaded = false;
   isInitialized = false;
}