seqSchema.cpp File Reference

#include "seqSchema.h"
#include "schema.h"
#include <iostream>
#include <assert.h>
Include dependency graph for seqSchema.cpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Enumerations

enum  { kHorDir, kUpDir, kDownDir }

Functions

static double computeHorzGap (schema *a, schema *b)
 Compute the horizontal gap needed to draw the internal wires.
static int direction (const point &a, const point &b)
 Compute the direction of a connection.
schemamakeSeqSchema (schema *s1, schema *s2)
 Make a sequential schema.

Enumeration Type Documentation

anonymous enum
Enumerator:
kHorDir 
kUpDir 
kDownDir 

Definition at line 29 of file seqSchema.cpp.

00029 {kHorDir, kUpDir, kDownDir}; 


Function Documentation

static double computeHorzGap ( schema a,
schema b 
) [static]

Compute the horizontal gap needed to draw the internal wires.

It depends on the largest group of connections that go in the same direction.

Definition at line 230 of file seqSchema.cpp.

References direction(), dWire, schema::height(), schema::inputPoint(), schema::inputs(), kDownDir, kLeftRight, kUpDir, max(), schema::outputPoint(), schema::outputs(), and schema::place().

Referenced by makeSeqSchema().

00231 {
00232     assert(a->outputs() == b->inputs());
00233 
00234     if (a->outputs() == 0) {
00235         return 0;
00236     } else {
00237         // store here the size of the largest group for each direction
00238         int MaxGroupSize[3]; for(int i=0; i<3; i++) MaxGroupSize[i]=0;
00239 
00240         // place a and b to have valid connection points
00241         double ya = max(0.0, 0.5*(b->height() - a->height()));
00242         double yb = max(0.0, 0.5*(a->height() - b->height()));
00243         a->place(0,ya,kLeftRight);
00244         b->place(0,yb,kLeftRight);
00245 
00246         // init current group direction and size
00247         int gdir    = direction(a->outputPoint(0), b->inputPoint(0));
00248         int gsize   = 1;
00249 
00250         // analyze direction of remaining points
00251         for (unsigned int i=1; i<a->outputs(); i++) {
00252             int d = direction(a->outputPoint(i), b->inputPoint(i));
00253             if (d == gdir) {
00254                 gsize++;
00255             } else {
00256                 if (gsize > MaxGroupSize[gdir])  MaxGroupSize[gdir]=gsize;
00257                 gsize = 1;
00258                 gdir = d;
00259             }
00260         }
00261 
00262         // update for last group
00263         if (gsize > MaxGroupSize[gdir])  MaxGroupSize[gdir]=gsize;
00264 
00265         // the gap required for the connections
00266         return dWire * max(MaxGroupSize[kUpDir],MaxGroupSize[kDownDir]);
00267     }
00268 }

Here is the call graph for this function:

Here is the caller graph for this function:

static int direction ( const point a,
const point b 
) [static]

Compute the direction of a connection.

Note that Y axis goes from top to bottom

Definition at line 218 of file seqSchema.cpp.

References kDownDir, kHorDir, kUpDir, and point::y.

Referenced by computeHorzGap(), and seqSchema::drawInternalWires().

00219 {
00220     if (a.y > b.y) return kUpDir;       // upward connections
00221     if (a.y < b.y) return kDownDir;     // downward connection
00222     return kHorDir;                     // horizontal connections
00223 }

Here is the caller graph for this function:

schema* makeSeqSchema ( schema s1,
schema s2 
)

Make a sequential schema.

May add cables to ensure the internal connections are between the same number of outputs and inputs. Compute an horizontal gap based on the number of upward and downward connections.

Definition at line 43 of file seqSchema.cpp.

References computeHorzGap(), schema::inputs(), makeCableSchema(), makeParSchema(), and schema::outputs().

Referenced by generateAbstractionSchema(), and generateInsideSchema().

00044 {
00045     unsigned int o = s1->outputs();
00046     unsigned int i = s2->inputs();
00047 
00048     schema* a = (o < i) ? makeParSchema(s1, makeCableSchema(i-o)) : s1;
00049     schema* b = (o > i) ? makeParSchema(s2, makeCableSchema(o-i)) : s2;
00050 
00051     return new seqSchema(a, b, computeHorzGap(a,b));
00052 }

Here is the call graph for this function:

Here is the caller graph for this function:

Generated on Thu Apr 29 00:00:11 2010 for FAUST compiler by  doxygen 1.6.3