correction de bugs et amelioration du placement des connecteurs

option -c
This commit is contained in:
Christophe Alexandre 2002-08-26 14:04:50 +00:00
parent 2c0047ea19
commit a22ecd9738
1 changed files with 74 additions and 55 deletions

View File

@ -1048,7 +1048,8 @@ PPlacement::GenerateConsPlacement()
//creation d'un placement aleatoire des connecteurs. //creation d'un placement aleatoire des connecteurs.
unsigned faces[4]; unsigned faces[4];
double aspectRatio = GetWidth() / GetHeight(); double aspectRatio = GetWidth() / GetHeight();
unsigned nbConsNorthSouth = (unsigned)((_cons.size() / 2) * aspectRatio); double repartition = aspectRatio + 1.0;
unsigned nbConsNorthSouth = (unsigned)( aspectRatio * _cons.size() / repartition);
unsigned nbConsEastWest = _cons.size() - nbConsNorthSouth; unsigned nbConsEastWest = _cons.size() - nbConsNorthSouth;
//faces north est sud ouest //faces north est sud ouest
@ -1069,55 +1070,67 @@ PPlacement::GenerateConsPlacement()
int spaceLeft = 0; int spaceLeft = 0;
//placement au nord. //placement au nord.
interval = (maxx - minx) / faces[0]; if (faces[0])
spaceLeft = (maxx - minx) % faces[0];
pos = minx + interval / 2;
while(faces[0]--)
{ {
if (spaceLeft-- > 0) interval = (maxx - minx) / faces[0];
pos += 1; spaceLeft = (maxx - minx) % faces[0];
(*cit)->SetOrient(NORTH); pos = minx + interval / 2;
(*cit++)->SetPos(PPos(pos , maxy)); while(faces[0]--)
pos += interval; {
if (spaceLeft-- > 0)
pos += 1;
(*cit)->SetOrient(NORTH);
(*cit++)->SetPos(PPos(pos , maxy));
pos += interval;
}
} }
//placement a l'est. //placement a l'est.
interval = (maxy - miny) / faces[1]; if (faces[1])
spaceLeft = (maxx - minx) % faces[1];
pos = miny + interval / 2;
while(faces[1]--)
{ {
if (spaceLeft-- > 0) interval = (maxy - miny) / faces[1];
pos += 1; spaceLeft = (maxx - minx) % faces[1];
(*cit)->SetOrient(EAST); pos = miny + interval / 2;
(*cit++)->SetPos(PPos(maxx , pos)); while(faces[1]--)
pos += interval; {
if (spaceLeft-- > 0)
pos += 1;
(*cit)->SetOrient(EAST);
(*cit++)->SetPos(PPos(maxx , pos));
pos += interval;
}
} }
//placement au sud. //placement au sud.
interval = (maxx - minx) / faces[2]; if (faces[2])
spaceLeft = (maxx - minx) % faces[2];
pos = minx + interval / 2;
while(faces[2]--)
{ {
if (spaceLeft-- > 0) interval = (maxx - minx) / faces[2];
pos += 1; spaceLeft = (maxx - minx) % faces[2];
(*cit)->SetOrient(SOUTH); pos = minx + interval / 2;
(*cit++)->SetPos(PPos(pos , miny)); while(faces[2]--)
pos += interval; {
if (spaceLeft-- > 0)
pos += 1;
(*cit)->SetOrient(SOUTH);
(*cit++)->SetPos(PPos(pos , miny));
pos += interval;
}
} }
//placement a l'ouest. //placement a l'ouest.
interval = (maxy - miny) / faces[3]; if (faces[3])
spaceLeft = (maxx - minx) % faces[3];
pos = miny + interval / 2;
while(faces[3]--)
{ {
if (spaceLeft-- > 0) interval = (maxy - miny) / faces[3];
pos += 1; spaceLeft = (maxx - minx) % faces[3];
(*cit)->SetOrient(WEST); pos = miny + interval / 2;
(*cit++)->SetPos(PPos(minx , pos)); while(faces[3]--)
pos += interval; {
if (spaceLeft-- > 0)
pos += 1;
(*cit)->SetOrient(WEST);
(*cit++)->SetPos(PPos(minx , pos));
pos += interval;
}
} }
} }
@ -1150,29 +1163,35 @@ PPlacement::GenerateRingConsPlacement()
int spaceLeft = 0; int spaceLeft = 0;
//placement au nord. //placement au nord.
interval = (maxx - minx) / faces[0]; if (faces[0])
spaceLeft = (maxx - minx) % faces[0];
pos = minx + interval / 2;
while(faces[0]--)
{ {
if (spaceLeft-- > 0) interval = (maxx - minx) / faces[0];
pos += 1; spaceLeft = (maxx - minx) % faces[0];
(*cit)->SetOrient(NORTH); pos = minx + interval / 2;
(*cit++)->SetPos(PPos(pos , maxy)); while(faces[0]--)
pos += interval; {
if (spaceLeft-- > 0)
pos += 1;
(*cit)->SetOrient(NORTH);
(*cit++)->SetPos(PPos(pos , maxy));
pos += interval;
}
} }
//placement au sud. //placement au sud.
interval = (maxx - minx) / faces[1]; if (faces[1])
spaceLeft = (maxx - minx) % faces[1];
pos = minx + interval / 2;
while(faces[1]--)
{ {
if (spaceLeft-- > 0) interval = (maxx - minx) / faces[1];
pos += 1; spaceLeft = (maxx - minx) % faces[1];
(*cit)->SetOrient(SOUTH); pos = minx + interval / 2;
(*cit++)->SetPos(PPos(pos , miny)); while(faces[1]--)
pos += interval; {
if (spaceLeft-- > 0)
pos += 1;
(*cit)->SetOrient(SOUTH);
(*cit++)->SetPos(PPos(pos , miny));
pos += interval;
}
} }
} }