|
FAUST compiler
0.9.9.6b8
|

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. | |
| schema * | makeSeqSchema (schema *s1, schema *s2) |
| Make a sequential schema. | |
| anonymous enum |
Definition at line 29 of file seqSchema.cpp.
| 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 325 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().
{
assert(a->outputs() == b->inputs());
if (a->outputs() == 0) {
return 0;
} else {
// store here the size of the largest group for each direction
int MaxGroupSize[3]; for(int i=0; i<3; i++) MaxGroupSize[i]=0;
// place a and b to have valid connection points
double ya = max(0.0, 0.5*(b->height() - a->height()));
double yb = max(0.0, 0.5*(a->height() - b->height()));
a->place(0,ya,kLeftRight);
b->place(0,yb,kLeftRight);
// init current group direction and size
int gdir = direction(a->outputPoint(0), b->inputPoint(0));
int gsize = 1;
// analyze direction of remaining points
for (unsigned int i=1; i<a->outputs(); i++) {
int d = direction(a->outputPoint(i), b->inputPoint(i));
if (d == gdir) {
gsize++;
} else {
if (gsize > MaxGroupSize[gdir]) MaxGroupSize[gdir]=gsize;
gsize = 1;
gdir = d;
}
}
// update for last group
if (gsize > MaxGroupSize[gdir]) MaxGroupSize[gdir]=gsize;
// the gap required for the connections
return dWire * max(MaxGroupSize[kUpDir],MaxGroupSize[kDownDir]);
}
}


Compute the direction of a connection.
Note that Y axis goes from top to bottom
Definition at line 313 of file seqSchema.cpp.
References kDownDir, kHorDir, kUpDir, and point::y.
Referenced by seqSchema::collectInternalWires(), computeHorzGap(), and seqSchema::drawInternalWires().
{
if (a.y > b.y) return kUpDir; // upward connections
if (a.y < b.y) return kDownDir; // downward connection
return kHorDir; // horizontal connections
}

| 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().
{
unsigned int o = s1->outputs();
unsigned int i = s2->inputs();
schema* a = (o < i) ? makeParSchema(s1, makeCableSchema(i-o)) : s1;
schema* b = (o > i) ? makeParSchema(s2, makeCableSchema(o-i)) : s2;
return new seqSchema(a, b, computeHorzGap(a,b));
}


1.8.0