FAUST compiler  0.9.9.6b8
Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
recSchema Class Reference

place and connect two diagrams in recursive composition More...

#include <recSchema.h>

Inheritance diagram for recSchema:
Inheritance graph
[legend]
Collaboration diagram for recSchema:
Collaboration graph
[legend]

Public Member Functions

virtual void place (double ox, double oy, int orientation)
 The two subschema are placed centered vertically, s2 on top of s1. More...
 
virtual void draw (device &dev)
 Draw the two subschema s1 and s2 as well as the implicit feedback delays between s1 and s2. More...
 
virtual point inputPoint (unsigned int i) const
 The input points s1 ~ s2. More...
 
virtual point outputPoint (unsigned int i) const
 The output points s1 ~ s2. More...
 
virtual void collectTraits (collector &c)
 Draw the two subschema s1 and s2 as well as the feedback connections between s1 and s2, and the feedfrom connections beetween s2 and s1. More...
 
- Public Member Functions inherited from schema
 schema (unsigned int inputs, unsigned int outputs, double width, double height)
 
virtual ~schema ()
 
double width () const
 
double height () const
 
unsigned int inputs () const
 
unsigned int outputs () const
 
void beginPlace (double x, double y, int orientation)
 
void endPlace ()
 
bool placed () const
 
double x () const
 
double y () const
 
int orientation () const
 

Private Member Functions

 recSchema (schema *s1, schema *s2, double width)
 Constructor of a recursive schema (s1 ~ s2). More...
 
void drawDelaySign (device &dev, double x, double y, double size)
 Draw the delay sign of a feedback connection. More...
 
void collectFeedback (collector &c, const point &src, const point &dst, double dx, const point &out)
 Draw a feedback connection between two points with an horizontal displacement dx. More...
 
void collectFeedfront (collector &c, const point &src, const point &dst, double dx)
 Draw a feedfrom connection between two points with an horizontal displacement dx. More...
 

Private Attributes

schemafSchema1
 
schemafSchema2
 
vector< pointfInputPoint
 
vector< pointfOutputPoint
 

Friends

schemamakeRecSchema (schema *s1, schema *s2)
 Creates a new recursive schema (s1 ~ s2). More...
 

Detailed Description

place and connect two diagrams in recursive composition

Definition at line 33 of file recSchema.h.

Constructor & Destructor Documentation

recSchema::recSchema ( schema s1,
schema s2,
double  width 
)
private

Constructor of a recursive schema (s1 ~ s2).

The two components are supposed to have the same width.

Definition at line 48 of file recSchema.cpp.

References fInputPoint, fOutputPoint, schema::inputs(), schema::outputs(), and schema::width().

49  : schema( s1->inputs() - s2->outputs(),
50  s1->outputs(),
51  width,
52  s1->height() + s2->height() ),
53  fSchema1(s1),
54  fSchema2(s2)
55 {
56  // this version only accepts legal expressions of same width
57  assert(s1->inputs() >= s2->outputs());
58  assert(s1->outputs() >= s2->inputs());
59  assert(s1->width() >= s2->width());
60 
61  // create the input and output points
62  for (unsigned int i=0; i<inputs(); i++) fInputPoint.push_back(point(0,0));
63  for (unsigned int i=0; i<outputs(); i++) fOutputPoint.push_back(point(0,0));
64 
65 }
unsigned int outputs() const
Definition: schema.h:129
unsigned int inputs() const
Definition: schema.h:128
vector< point > fInputPoint
Definition: recSchema.h:37
double width() const
Definition: schema.h:126
schema(unsigned int inputs, unsigned int outputs, double width, double height)
Definition: schema.h:113
Definition: schema.h:40
double height() const
Definition: schema.h:127
schema * fSchema1
Definition: recSchema.h:35
schema * fSchema2
Definition: recSchema.h:36
vector< point > fOutputPoint
Definition: recSchema.h:38

Here is the call graph for this function:

Member Function Documentation

void recSchema::collectFeedback ( collector c,
const point src,
const point dst,
double  dx,
const point out 
)
private

Draw a feedback connection between two points with an horizontal displacement dx.

Definition at line 202 of file recSchema.cpp.

References collector::addInput(), collector::addOutput(), collector::addTrait(), dWire, kLeftRight, schema::orientation(), point::x, and point::y.

Referenced by collectTraits().

203 {
204  double ox = src.x + ((orientation()==kLeftRight) ? dx : -dx);
205  double ct = (orientation()==kLeftRight) ? dWire/2 : -dWire/2;
206 
207  point up(ox, src.y-ct);
208  point br(ox+ct/2.0, src.y);
209 
210  c.addOutput(up);
211  c.addOutput(br);
212  c.addInput(br);
213 
214  c.addTrait(trait(up, point(ox, dst.y)));
215  c.addTrait(trait(point(ox, dst.y), point(dst.x, dst.y)));
216  c.addTrait(trait(src,br));
217  c.addTrait(trait(br,out));
218 
219 }
void addOutput(const point &p)
Definition: schema.h:82
void addTrait(const trait &t)
Definition: schema.h:84
Definition: schema.h:56
const double dWire
distance between two wires
Definition: schema.h:33
double y
Definition: schema.h:43
int orientation() const
Definition: schema.h:140
double x
Definition: schema.h:42
Definition: schema.h:40
void addInput(const point &p)
Definition: schema.h:83

Here is the call graph for this function:

Here is the caller graph for this function:

void recSchema::collectFeedfront ( collector c,
const point src,
const point dst,
double  dx 
)
private

Draw a feedfrom connection between two points with an horizontal displacement dx.

Definition at line 226 of file recSchema.cpp.

References collector::addTrait(), kLeftRight, schema::orientation(), point::x, and point::y.

Referenced by collectTraits().

227 {
228  double ox = src.x + ((orientation()==kLeftRight) ? -dx : dx);
229 
230  c.addTrait(trait(point(src.x, src.y), point(ox, src.y)));
231  c.addTrait(trait(point(ox, src.y), point(ox, dst.y)));
232  c.addTrait(trait(point(ox, dst.y), point(dst.x, dst.y)));
233 }
void addTrait(const trait &t)
Definition: schema.h:84
Definition: schema.h:56
double y
Definition: schema.h:43
int orientation() const
Definition: schema.h:140
double x
Definition: schema.h:42
Definition: schema.h:40

Here is the call graph for this function:

Here is the caller graph for this function:

void recSchema::collectTraits ( collector c)
virtual

Draw the two subschema s1 and s2 as well as the feedback connections between s1 and s2, and the feedfrom connections beetween s2 and s1.

Implements schema.

Definition at line 162 of file recSchema.cpp.

References collector::addTrait(), collectFeedback(), collectFeedfront(), schema::collectTraits(), dWire, fSchema1, fSchema2, inputPoint(), schema::inputPoint(), schema::inputs(), outputPoint(), schema::outputPoint(), schema::outputs(), and schema::placed().

163 {
164  assert(placed());
165 
166  // draw the two subdiagrams
169 
170  // draw the feedback connections to each fSchema2 input
171  for (unsigned int i=0; i<fSchema2->inputs(); i++) {
173  }
174 
175  // draw the non recursive output lines
176  for (unsigned int i=fSchema2->inputs(); i<outputs(); i++) {
177  point p = fSchema1->outputPoint(i);
178  point q = outputPoint(i);
179  c.addTrait(trait(p,q)); // in->out order
180  }
181 
182  // draw the input lines
183  unsigned int skip = fSchema2->outputs();
184  for (unsigned int i=0; i<inputs(); i++) {
185  point p = inputPoint(i);
186  point q = fSchema1->inputPoint(i+skip);
187  c.addTrait(trait(p,q)); // in->out order
188  }
189 
190  // draw the feedfront connections from each fSchema2 output
191  for (unsigned int i=0; i<fSchema2->outputs(); i++) {
193  }
194 }
void addTrait(const trait &t)
Definition: schema.h:84
Definition: schema.h:56
unsigned int outputs() const
Definition: schema.h:129
const double dWire
distance between two wires
Definition: schema.h:33
virtual point inputPoint(unsigned int i) const =0
virtual void collectTraits(collector &c)=0
void collectFeedback(collector &c, const point &src, const point &dst, double dx, const point &out)
Draw a feedback connection between two points with an horizontal displacement dx. ...
Definition: recSchema.cpp:202
unsigned int inputs() const
Definition: schema.h:128
void collectFeedfront(collector &c, const point &src, const point &dst, double dx)
Draw a feedfrom connection between two points with an horizontal displacement dx. ...
Definition: recSchema.cpp:226
bool placed() const
Definition: schema.h:137
virtual point inputPoint(unsigned int i) const
The input points s1 ~ s2.
Definition: recSchema.cpp:110
Definition: schema.h:40
virtual point outputPoint(unsigned int i) const =0
schema * fSchema1
Definition: recSchema.h:35
schema * fSchema2
Definition: recSchema.h:36
virtual point outputPoint(unsigned int i) const
The output points s1 ~ s2.
Definition: recSchema.cpp:119

Here is the call graph for this function:

void recSchema::draw ( device dev)
virtual

Draw the two subschema s1 and s2 as well as the implicit feedback delays between s1 and s2.

Implements schema.

Definition at line 129 of file recSchema.cpp.

References schema::draw(), drawDelaySign(), dWire, fSchema1, fSchema2, schema::inputs(), kLeftRight, schema::orientation(), schema::outputPoint(), schema::placed(), point::x, and point::y.

130 {
131  assert(placed());
132 
133  // draw the two subdiagrams
134  fSchema1->draw(dev);
135  fSchema2->draw(dev);
136 
137  // draw the implicit feedback delay to each fSchema2 input
138  double dw = (orientation()==kLeftRight) ? dWire : -dWire;
139  for (unsigned int i=0; i<fSchema2->inputs(); i++) {
140  const point& p = fSchema1->outputPoint(i);
141  drawDelaySign(dev, p.x + i*dw, p.y, dw/2);
142 
143  }
144 }
void drawDelaySign(device &dev, double x, double y, double size)
Draw the delay sign of a feedback connection.
Definition: recSchema.cpp:149
const double dWire
distance between two wires
Definition: schema.h:33
virtual void draw(device &dev)=0
unsigned int inputs() const
Definition: schema.h:128
double y
Definition: schema.h:43
bool placed() const
Definition: schema.h:137
int orientation() const
Definition: schema.h:140
double x
Definition: schema.h:42
Definition: schema.h:40
virtual point outputPoint(unsigned int i) const =0
schema * fSchema1
Definition: recSchema.h:35
schema * fSchema2
Definition: recSchema.h:36

Here is the call graph for this function:

void recSchema::drawDelaySign ( device dev,
double  x,
double  y,
double  size 
)
private

Draw the delay sign of a feedback connection.

Definition at line 149 of file recSchema.cpp.

References device::trait().

Referenced by draw().

150 {
151  dev.trait(x-size/2, y, x-size/2, y-size);
152  dev.trait(x-size/2, y-size, x+size/2, y-size);
153  dev.trait(x+size/2, y-size, x+size/2, y);
154 }
double y() const
Definition: schema.h:139
double x() const
Definition: schema.h:138
virtual void trait(double x1, double y1, double x2, double y2)=0

Here is the call graph for this function:

Here is the caller graph for this function:

point recSchema::inputPoint ( unsigned int  i) const
virtual

The input points s1 ~ s2.

Implements schema.

Definition at line 110 of file recSchema.cpp.

References fInputPoint.

Referenced by collectTraits().

111 {
112  return fInputPoint[i];
113 }
vector< point > fInputPoint
Definition: recSchema.h:37

Here is the caller graph for this function:

point recSchema::outputPoint ( unsigned int  i) const
virtual

The output points s1 ~ s2.

Implements schema.

Definition at line 119 of file recSchema.cpp.

References fOutputPoint.

Referenced by collectTraits().

120 {
121  return fOutputPoint[i];
122 }
vector< point > fOutputPoint
Definition: recSchema.h:38

Here is the caller graph for this function:

void recSchema::place ( double  ox,
double  oy,
int  orientation 
)
virtual

The two subschema are placed centered vertically, s2 on top of s1.

The input and output points are computed.

Implements schema.

Definition at line 71 of file recSchema.cpp.

References schema::beginPlace(), schema::endPlace(), fInputPoint, fOutputPoint, fSchema1, fSchema2, schema::height(), schema::inputPoint(), schema::inputs(), kLeftRight, kRightLeft, schema::outputPoint(), schema::outputs(), schema::place(), schema::width(), point::x, and point::y.

72 {
73  beginPlace(ox, oy, orientation);
74 
75  double dx1 = (width() - fSchema1->width())/2;
76  double dx2 = (width() - fSchema2->width())/2;
77 
78  // place the two sub diagrams
79  if (orientation == kLeftRight) {
80  fSchema2->place(ox+dx2, oy, kRightLeft);
81  fSchema1->place(ox+dx1, oy+fSchema2->height(), kLeftRight);
82  } else {
83  fSchema1->place(ox+dx1, oy, kRightLeft);
84  fSchema2->place(ox+dx2, oy+fSchema1->height(), kLeftRight);
85  }
86 
87 
88  // adjust delta space to orientation
89  if (orientation == kRightLeft) { dx1 = -dx1; }
90 
91  // place input points
92  for (unsigned int i=0; i<inputs(); i++) {
94  fInputPoint[i] = point(p.x-dx1, p.y);
95  }
96 
97  // place output points
98  for (unsigned int i=0; i<outputs(); i++) {
99  point p = fSchema1->outputPoint(i);
100  fOutputPoint[i] = point(p.x+dx1, p.y);
101  }
102 
103  endPlace();
104 }
void endPlace()
Definition: schema.h:134
unsigned int outputs() const
Definition: schema.h:129
virtual point inputPoint(unsigned int i) const =0
void beginPlace(double x, double y, int orientation)
Definition: schema.h:132
unsigned int inputs() const
Definition: schema.h:128
vector< point > fInputPoint
Definition: recSchema.h:37
double width() const
Definition: schema.h:126
double y
Definition: schema.h:43
int orientation() const
Definition: schema.h:140
virtual void place(double x, double y, int orientation)=0
double x
Definition: schema.h:42
Definition: schema.h:40
virtual point outputPoint(unsigned int i) const =0
double height() const
Definition: schema.h:127
schema * fSchema1
Definition: recSchema.h:35
schema * fSchema2
Definition: recSchema.h:36
vector< point > fOutputPoint
Definition: recSchema.h:38

Here is the call graph for this function:

Friends And Related Function Documentation

schema* makeRecSchema ( schema s1,
schema s2 
)
friend

Creates a new recursive schema (s1 ~ s2).

The smallest component is enlarged to the width of the other. The left and right horizontal margins are computed according to the number of internal connections.

Definition at line 34 of file recSchema.cpp.

35 {
36  schema* a = makeEnlargedSchema(s1, s2->width());
37  schema* b = makeEnlargedSchema(s2, s1->width());
38  double m = dWire * max(b->inputs(), b->outputs());
39  double w = a->width() + 2*m;
40 
41  return new recSchema(a,b,w);
42 }
const double dWire
distance between two wires
Definition: schema.h:33
double max(double x, double y)
Definition: interval.hh:60
double width() const
Definition: schema.h:126
An abstract block diagram schema.
Definition: schema.h:97
recSchema(schema *s1, schema *s2, double width)
Constructor of a recursive schema (s1 ~ s2).
Definition: recSchema.cpp:48
schema * makeEnlargedSchema(schema *s, double width)
Returns an enlarged schema, but only if really needed that is if the requiered width is greater that ...

Member Data Documentation

vector<point> recSchema::fInputPoint
private

Definition at line 37 of file recSchema.h.

Referenced by inputPoint(), place(), and recSchema().

vector<point> recSchema::fOutputPoint
private

Definition at line 38 of file recSchema.h.

Referenced by outputPoint(), place(), and recSchema().

schema* recSchema::fSchema1
private

Definition at line 35 of file recSchema.h.

Referenced by collectTraits(), draw(), and place().

schema* recSchema::fSchema2
private

Definition at line 36 of file recSchema.h.

Referenced by collectTraits(), draw(), and place().


The documentation for this class was generated from the following files: