depoussierage des poilus du 11 Novembre ....

PAPAM PAPAM PAPAM ....
This commit is contained in:
Christophe Alexandre 2002-11-11 16:51:10 +00:00
parent aa3ffa2048
commit b9f5507598
11 changed files with 184 additions and 137 deletions

View File

@ -4,6 +4,13 @@
#include "PDetPlacement.h"
#include <algorithm>
PDetSubRow::~PDetSubRow()
{
for (PDetInsVector::iterator iit = _detInsVector.begin();
iit != _detInsVector.end(); iit++)
delete *iit;
}
PDetSubRow::PDetSubRow(PSubRow& subrow):
PContainer(subrow.GetBBox()),
_orientation(subrow.GetOrientation())
@ -14,7 +21,7 @@ PDetSubRow::PDetSubRow(PSubRow& subrow):
bit != subrow.GetBins().end();
bit++)
{
nbins += bit->GetToPlaceInss().size();
nbins += (*bit)->GetToPlaceInss().size();
}
_detInsVector.reserve(nbins);
@ -23,11 +30,11 @@ PDetSubRow::PDetSubRow(PSubRow& subrow):
bit != subrow.GetBins().end();
bit++)
{
for (PBin::PToPlaceInss::iterator iit = bit->GetToPlaceInss().begin();
iit != bit->GetToPlaceInss().end();
for (PBin::PToPlaceInss::iterator iit = (*bit)->GetToPlaceInss().begin();
iit != (*bit)->GetToPlaceInss().end();
iit++)
{
_detInsVector.push_back(PDetToPlaceIns(*iit));
_detInsVector.push_back(new PDetToPlaceIns(*iit));
}
}
}
@ -41,7 +48,7 @@ PDetSubRow::ExpandInstances(const bool eqmargin)
iit != _detInsVector.end();
iit++)
{
totalinssize += iit->GetWidth();
totalinssize += (*iit)->GetWidth();
}
//xtof: 06 05 2002
//changing the white space repartition
@ -67,26 +74,26 @@ PDetSubRow::ExpandInstances(const bool eqmargin)
iit != _detInsVector.end();
iit++)
{
iit->SetMarginWidth(iit->GetWidth() + inswhitespace);
(*iit)->SetMarginWidth((*iit)->GetWidth() + inswhitespace);
}
PDetInsVector::iterator iit = _detInsVector.begin();
if (eqmargin)
{
while (whitespaceremain-- > 0.0)
{
(iit++)->AddWhiteSpace();
(*iit++)->AddWhiteSpace();
}
}
else
{
while (whitespaceremain >= 2.0)
{
(iit++)->AddDoubleWhiteSpace();
(*iit++)->AddDoubleWhiteSpace();
whitespaceremain -= 2.0;
}
if (whitespaceremain > 0.0)
{
(iit)->AddWhiteSpace();
(*iit)->AddWhiteSpace();
}
}
@ -95,8 +102,8 @@ PDetSubRow::ExpandInstances(const bool eqmargin)
iit != _detInsVector.end();
iit++)
{
iit->SetLeftCornerX(XPos);
XPos += iit->GetMarginWidth();
(*iit)->SetLeftCornerX(XPos);
XPos += (*iit)->GetMarginWidth();
}
}
@ -126,7 +133,7 @@ PDetSubRow::FinalOptimize()
for (PDetInsVector::iterator iit = _detInsVector.begin();
iit != _detInsVector.end(); iit++)
{
insvector.push_back(&(*iit));
insvector.push_back(*iit);
}
sort(insvector.begin(), insvector.end(), CompareInsPosition(insvector));
PDetPlacement::Problem problem;

View File

@ -12,7 +12,7 @@ class PSubRow;
class PDetSubRow : public PContainer {
public:
typedef vector<PDetToPlaceIns> PDetInsVector;
typedef vector<PDetToPlaceIns*> PDetInsVector;
private:
@ -22,6 +22,7 @@ class PDetSubRow : public PContainer {
public:
PDetSubRow(PSubRow& subrow);
~PDetSubRow();
bool GetOrientation() const { return _orientation; }
PDetInsVector& GetInssVector() { return _detInsVector; }
const PDetInsVector& GetConstInssVector() const { return _detInsVector; }

View File

@ -30,7 +30,7 @@ class PElem {
double GetPosY() const { return GetPos().GetY(); }
virtual ostream& Print(ostream& os) const = 0;
void DescribeOn(ostream& os) const;
void DescribeOn(ostream& os) const;
};
static inline ostream& operator<<(ostream& os, const PElem& elem) {

View File

@ -54,6 +54,20 @@ PPlacement::~PPlacement()
{
delete *nit;
}
for (PRows::iterator rit = _rows.begin();
rit != _rows.end();
rit++)
{
delete *rit;
}
for (PDetSubRows::iterator srit = _detSubRows.begin();
srit != _detSubRows.end();
srit++)
{
delete *srit;
}
}
void
@ -391,7 +405,7 @@ PPlacement::Init(lofig* fig, int NbRows)
// Insertion of instances on rows
vector<PToPlaceIns*>::iterator iptfirst = ClassedInss.begin();
PRows::iterator rfirst = _rows.begin();
PRow::PSubRows::iterator subrfirst = rfirst->GetSubRows().begin();
PRow::PSubRows::iterator subrfirst = (*rfirst)->GetSubRows().begin();
PIns* InsInserting = *iptfirst;
while(1) {
@ -405,10 +419,10 @@ PPlacement::Init(lofig* fig, int NbRows)
// end of insertion
}
if (subrfirst == rfirst->GetSubRows().end()
if (subrfirst == (*rfirst)->GetSubRows().end()
&& (++rfirst != _rows.end()))
{
subrfirst = rfirst->GetSubRows().begin();
subrfirst = (*rfirst)->GetSubRows().begin();
}
if (rfirst == _rows.end())
@ -417,21 +431,21 @@ PPlacement::Init(lofig* fig, int NbRows)
{
InsInserting = *iptfirst;
rfirst = _rows.begin();
subrfirst = rfirst->GetSubRows().begin();
subrfirst = (*rfirst)->GetSubRows().begin();
}
else
{
// insertion of instances with respect of Bins margin
// did not succed, inserting what's left.
rfirst = _rows.begin();
subrfirst = rfirst->GetSubRows().begin();
NbOfBins = subrfirst->GetNBins();
subrfirst = (*rfirst)->GetSubRows().begin();
NbOfBins = (*subrfirst)->GetNBins();
BinNumber = 0;
while (iptfirst != ClassedInss.end()) {
if ((*iptfirst)->GetWidth() <=
subrfirst->GetWidth() - subrfirst->GetSize())
(*subrfirst)->GetWidth() - (*subrfirst)->GetSize())
{
subrfirst->ForceIns(**(iptfirst++), BinNumber++);
(*subrfirst)->ForceIns(**(iptfirst++), BinNumber++);
}
else
BinNumber++;
@ -439,15 +453,15 @@ PPlacement::Init(lofig* fig, int NbRows)
{
subrfirst++;
BinNumber = 0;
if (subrfirst != rfirst->GetSubRows().end())
NbOfBins = subrfirst->GetNBins();
if (subrfirst != (*rfirst)->GetSubRows().end())
NbOfBins = (*subrfirst)->GetNBins();
}
if (subrfirst == rfirst->GetSubRows().end()
if (subrfirst == (*rfirst)->GetSubRows().end()
&& (++rfirst != _rows.end()))
{
subrfirst = rfirst->GetSubRows().begin();
NbOfBins = subrfirst->GetNBins();
subrfirst = (*rfirst)->GetSubRows().begin();
NbOfBins = (*subrfirst)->GetNBins();
}
if (rfirst == _rows.end())
@ -462,19 +476,19 @@ PPlacement::Init(lofig* fig, int NbRows)
exit(1);
}
rfirst = _rows.begin();
subrfirst = rfirst->GetSubRows().begin();
subrfirst = (*rfirst)->GetSubRows().begin();
InsInserting = *iptfirst;
}
}
}
}
NbOfBins = subrfirst->GetNBins();
NbOfBins = (*subrfirst)->GetNBins();
BinNumber = 0;
while ((iptfirst != ClassedInss.end())
&& (BinNumber < NbOfBins)
&& ((*iptfirst)->GetWidth() <= subrfirst->GetCapa() - subrfirst->GetSize()))
&& ((*iptfirst)->GetWidth() <= (*subrfirst)->GetCapa() - (*subrfirst)->GetSize()))
{
if (subrfirst->InsertIns(**iptfirst, BinNumber++))
if ((*subrfirst)->InsertIns(**iptfirst, BinNumber++))
{
iptfirst++;
}
@ -839,9 +853,9 @@ PPlacement::PlotInstances(ofstream& out) const
{
out << "#rows" << endl;
for (PRows::const_iterator RowIt=_rows.begin(); RowIt!=_rows.end(); RowIt++)
for (PRows::const_iterator rit=_rows.begin(); rit!=_rows.end(); rit++)
{
RowIt->Plot(out);
(*rit)->Plot(out);
}
out << "EOF" << endl;
out << "#to place instances" << endl;
@ -885,9 +899,9 @@ PPlacement::PlotAll(char* output) const
PlotInstances(out);
out << "#nets" << endl;
for (PONets::const_iterator NetIt=_nets.begin(); NetIt!=_nets.end(); NetIt++)
for (PONets::const_iterator nit=_nets.begin(); nit!=_nets.end(); nit++)
{
(*NetIt)->Plot(out);
(*nit)->Plot(out);
}
out << "EOF" << endl << "pause -1 'press any key'" << endl;
}
@ -924,33 +938,33 @@ PPlacement::PlotFinal(char* output) const
out << "EOF" << endl;
out << "#subrows" << endl;
for (PDetSubRows::const_iterator SRowIt = _detSubRows.begin() ;
SRowIt != _detSubRows.end() ;
SRowIt++)
for (PDetSubRows::const_iterator srit = _detSubRows.begin() ;
srit != _detSubRows.end() ;
srit++)
{
SRowIt->Plot(out);
(*srit)->Plot(out);
}
out << "EOF" << endl;
out << "#instances" << endl;
for (PDetSubRows::const_iterator SRowIt = _detSubRows.begin() ;
SRowIt != _detSubRows.end() ;
SRowIt++)
for (PDetSubRows::const_iterator srit = _detSubRows.begin() ;
srit != _detSubRows.end() ;
srit++)
{
for (PDetSubRow::PDetInsVector::const_iterator InsIt = SRowIt->GetConstInssVector().begin() ;
InsIt != SRowIt->GetConstInssVector().end() ;
InsIt++)
for (PDetSubRow::PDetInsVector::const_iterator iit = (*srit)->GetConstInssVector().begin() ;
iit != (*srit)->GetConstInssVector().end() ;
iit++)
{
InsIt->Plot(out);
(*iit)->Plot(out);
}
}
out << "EOF" << endl;
out << "#nets" << endl;
for (PONets::const_iterator NetIt=_nets.begin(); NetIt!=_nets.end(); NetIt++)
for (PONets::const_iterator nit=_nets.begin(); nit!=_nets.end(); nit++)
{
(*NetIt)->Plot(out);
(*nit)->Plot(out);
}
out << "EOF" << endl << "pause -1 'press any key'" << endl;
}
@ -996,24 +1010,24 @@ PPlacement::PlotOnlyBins(char* output) const
if (_totalMoves != 0)
{
for (PRows::const_iterator RowIt=_rows.begin(); RowIt!=_rows.end(); RowIt++)
for (PRows::const_iterator rit=_rows.begin(); rit!=_rows.end(); rit++)
{
RowIt->PlotLabel(out, _totalMoves);
(*rit)->PlotLabel(out, _totalMoves);
}
}
out << "plot [:][:] '-' w l 1, '-' w l 2" << endl << "#bins" << endl;
for (PRows::const_iterator RowIt=_rows.begin(); RowIt!=_rows.end(); RowIt++)
for (PRows::const_iterator rit=_rows.begin(); rit!=_rows.end(); rit++)
{
RowIt->Plot(out);
(*rit)->Plot(out);
}
out << "EOF" << endl;
out << "#preplaced instances" << endl;
for (PFixedInss::const_iterator insit = _fixedInss.begin();
insit != _fixedInss.end(); insit++)
for (PFixedInss::const_iterator iit = _fixedInss.begin();
iit != _fixedInss.end(); iit++)
{
(*insit)->Plot(out);
(*iit)->Plot(out);
}
out << "EOF" << endl;
out << "pause -1 'press any key'" << endl;
@ -1233,27 +1247,27 @@ PPlacement::InitPlace(int NbRows)
_rowZeroOrientation = RowOrientation;
for (int i = 0; i < NRows; i++)
{
_rows.push_back(PRow(1));
_rows.push_back(new PRow(1));
double XMin = 0.0;
_rows.back().Init(Y, XMin, *this, RowOrientation);
_rows.back()->Init(Y, XMin, *this, RowOrientation);
_rowsYMax[Y + ROWHEIGHT] = rowidx;
_rowsYMinInv[Y] = rowidx;
++rowidx;
PSubRow& subrow = _rows.back()._subRows[0];
subrow.Init(&(_rows.back()), Y, XMin, rowwidth, _margin,
PSubRow& subrow = *(_rows.back()->_subRows[0]);
subrow.Init(_rows.back(), Y, XMin, rowwidth, _margin,
_binsMaxWidth, _binsMinWidth);
_rows.back()._subRowsXMax[rowwidth + XMin] = 0;
_rows.back()._subRowsXMaxInv[rowwidth + XMin] = 0;
_rows.back()->_subRowsXMax[rowwidth + XMin] = 0;
_rows.back()->_subRowsXMaxInv[rowwidth + XMin] = 0;
Y += ROWHEIGHT;
RowOrientation = !RowOrientation;
}
// Computing Placement BBox
double MaxX = 0.0, MaxY = 0.0, RowMaxX, RowMaxY;
for (PRows::iterator rfirst = _rows.begin(); rfirst != _rows.end(); rfirst++)
for (PRows::iterator rit = _rows.begin(); rit != _rows.end(); rit++)
{
RowMaxX = rfirst->GetMaxX();
RowMaxY = rfirst->GetMaxY();
RowMaxX = (*rit)->GetMaxX();
RowMaxY = (*rit)->GetMaxY();
if (MaxX < RowMaxX)
MaxX = RowMaxX;
if (MaxY < RowMaxY)
@ -1414,11 +1428,11 @@ PPlacement::InitPlaceWithPrePlace()
int numsubrows = CheckCreateRow(tabpreplace, yit, Width);
if (numsubrows > 0)
{
_rows.push_back(PRow(*this, (double)(yit * ROWHEIGHT), Width, numsubrows, orientation));
_rows.push_back(new PRow(*this, (double)(yit * ROWHEIGHT), Width, numsubrows, orientation));
_rowsYMax[(yit + 1) * ROWHEIGHT] = numrows;
_rowsYMinInv[yit * ROWHEIGHT] = numrows;
++numrows;
CreateSubRows(&_rows.back(), tabpreplace, yit, numsubrows, Width);
CreateSubRows(_rows.back(), tabpreplace, yit, numsubrows, Width);
}
orientation = !orientation;
}
@ -1459,7 +1473,7 @@ PPlacement::CreateSubRows(PRow* row, PrePlaceTab& tabpreplace,
if ( (xmax - xmin) >= _binsMinWidth)
{
row->_subRows[subrowscreated].Init(row, (double)(coordy * ROWHEIGHT), (double)xmin,(double)xmax,
row->_subRows[subrowscreated]->Init(row, (double)(coordy * ROWHEIGHT), (double)xmin,(double)xmax,
(double)_margin, _binsMaxWidth, _binsMinWidth);
row->_subRowsXMax[(double)xmax] = subrowscreated;
++subrowscreated;
@ -1529,5 +1543,5 @@ PPlacement::GetRow(const PRow* row, const double dist)
PRowsYMax::iterator rsup = _rowsYMinInv.upper_bound(bornesup);
unsigned randidx = rinf->second + (unsigned)((double)(rsup->second - rinf->second + 1) * (rand() / (RAND_MAX+1.0)));
return _rows[randidx];
return *_rows[randidx];
}

View File

@ -27,14 +27,14 @@ struct eqstr
class PPlacement {
public:
typedef vector<PRow> PRows;
typedef vector<PRow*> PRows;
typedef vector<PONet*> PONets;
typedef vector<PToPlaceIns*> PToPlaceInss;
typedef vector<PFixedIns*> PFixedInss;
typedef vector<PCon*> PCons;
typedef vector <bool> PrePlaceRow;
typedef vector<PrePlaceRow> PrePlaceTab;
typedef vector<PDetSubRow> PDetSubRows;
typedef vector<PDetSubRow*> PDetSubRows;
private:
typedef map<double, unsigned, less<double> > PRowsYMax;
@ -47,8 +47,8 @@ class PPlacement {
typedef hash_map<const char*, PDetToPlaceIns*, hash<const char*>, eqstr> PDetInsMap;
PBBox BBox;
int _dx;
int _dy;
int _dx;
int _dy;
lofig* _fig;
phfig* _prePlaceFig;

View File

@ -69,11 +69,11 @@ PPlacement::FinalInitialize()
unsigned nbsubrows = 0;
for (PRows::iterator rit = _rows.begin(); rit != _rows.end(); rit++)
{
for (PRow::PSubRows::iterator srit = rit->GetSubRows().begin();
srit != rit->GetSubRows().end();
for (PRow::PSubRows::iterator srit = (*rit)->GetSubRows().begin();
srit != (*rit)->GetSubRows().end();
srit++)
{
if (srit->GetNIns() > 0)
if ((*srit)->GetNIns() > 0)
++nbsubrows;
}
}
@ -81,12 +81,12 @@ PPlacement::FinalInitialize()
for (PRows::iterator rit = _rows.begin(); rit != _rows.end(); rit++)
{
for (PRow::PSubRows::iterator srit = rit->GetSubRows().begin();
srit != rit->GetSubRows().end();
for (PRow::PSubRows::iterator srit = (*rit)->GetSubRows().begin();
srit != (*rit)->GetSubRows().end();
srit++)
{
if (srit->GetNIns() > 0)
_detSubRows.push_back(PDetSubRow(*srit));
if ((*srit)->GetNIns() > 0)
_detSubRows.push_back(new PDetSubRow(**srit));
}
}
@ -95,11 +95,12 @@ PPlacement::FinalInitialize()
for (PDetSubRows::iterator dsrit = _detSubRows.begin();
dsrit != _detSubRows.end(); dsrit++)
{
for (PDetSubRow::PDetInsVector::iterator it = dsrit->GetInssVector().begin();
it != dsrit->GetInssVector().end(); it++)
for (PDetSubRow::PDetInsVector::iterator it = (*dsrit)->GetInssVector().begin();
it != (*dsrit)->GetInssVector().end();
it++)
{
pdetinsmap[it->GetInstance()->INSNAME] = &(*it);
it->SetSubRow(&(*dsrit));
pdetinsmap[(*it)->GetInstance()->INSNAME] = *it;
(*it)->SetSubRow(*dsrit);
}
}
@ -144,7 +145,7 @@ PPlacement::FinalInitialize()
for (PDetSubRows::iterator dsrit = _detSubRows.begin();
dsrit != _detSubRows.end(); dsrit++)
{
dsrit->ExpandInstances(_eqMargin);
(*dsrit)->ExpandInstances(_eqMargin);
}
// Updating All _nets BBoxs
@ -195,7 +196,7 @@ PPlacement::FinalOptimize()
for (PDetSubRows::iterator dsrit = _detSubRows.begin();
dsrit != _detSubRows.end(); dsrit++)
{
if (dsrit->FinalOptimize())
if ((*dsrit)->FinalOptimize())
{
ContinueCondition = true;
OptimizationResult = true;
@ -238,10 +239,10 @@ PPlacement::Save()
for (PDetSubRows::iterator dsrit = _detSubRows.begin();
dsrit != _detSubRows.end(); dsrit++)
{
for (PDetSubRow::PDetInsVector::iterator it = dsrit->GetInssVector().begin();
it != dsrit->GetInssVector().end(); it++)
for (PDetSubRow::PDetInsVector::iterator it = (*dsrit)->GetInssVector().begin();
it != (*dsrit)->GetInssVector().end(); it++)
{
it->Save(physicalfig, _dx, _dy);
(*it)->Save(physicalfig, _dx, _dy);
}
}

View File

@ -88,9 +88,9 @@ double
PPlacement::GetRowCost()
{
double RowCost = 0.0;
for (PRows::iterator RowIt = _rows.begin(); RowIt != _rows.end(); RowIt++)
for (PRows::iterator rit = _rows.begin(); rit != _rows.end(); rit++)
{
RowCost += RowIt->GetSubRowCost();
RowCost += (*rit)->GetSubRowCost();
}
return RowCost;
}
@ -100,9 +100,9 @@ PPlacement::GetBinCost()
{
double BinCost = 0.0;
for (PRows::iterator RowIt = _rows.begin(); RowIt != _rows.end(); RowIt++)
for (PRows::iterator rit = _rows.begin(); rit != _rows.end(); rit++)
{
BinCost += RowIt->GetBinCost();
BinCost += (*rit)->GetBinCost();
}
return BinCost;
}

View File

@ -6,6 +6,12 @@
PRow::PRow(unsigned nbofsubrows)
: PContainer(), _subRows(nbofsubrows)
{
for (PSubRows::iterator srit=_subRows.begin();
srit!=_subRows.end();
srit++)
{
*srit = new PSubRow();
}
}
PRow::PRow(PPlacement& placement,
@ -17,6 +23,18 @@ PRow::PRow(PPlacement& placement,
_subRows(nbofsubrows),
_orientation(orientation)
{
for (PSubRows::iterator srit=_subRows.begin();
srit!=_subRows.end();
srit++)
*srit = new PSubRow();
}
PRow::~PRow()
{
for (PSubRows::iterator srit=_subRows.begin();
srit!=_subRows.end();
srit++)
delete *srit;
}
void
@ -41,7 +59,7 @@ PRow::GetBinCost() const
double bincost = 0.0;
for (PSubRows::const_iterator srit = _subRows.begin(); srit != _subRows.end(); srit++)
{
bincost += srit->GetBinCost();
bincost += (*srit)->GetBinCost();
}
return bincost;
}
@ -52,7 +70,7 @@ PRow::GetSubRowCost() const
double subrowcost = 0.0;
for (PSubRows::const_iterator srit = _subRows.begin(); srit != _subRows.end(); srit++)
{
subrowcost += Abs(srit->GetSize() - srit->GetCapa());
subrowcost += Abs((*srit)->GetSize() - (*srit)->GetCapa());
}
return subrowcost;
}
@ -62,7 +80,7 @@ PRow::GetSubRow(const double X)
{
// s'il y a un seul subrow on le renvoie direct
if (_subRows.size() == 1)
return _subRows[0];
return *_subRows[0];
// si il n'y a rien a droite
PSubRowsXMax::iterator right = _subRowsXMax.lower_bound(X);
@ -71,33 +89,33 @@ PRow::GetSubRow(const double X)
if (right == _subRowsXMax.end())
{
assert(left != _subRowsXMaxInv.end());
return _subRows[left->second];
return *_subRows[left->second];
}
// si on est tombe direct dans un subrow...
double rightminx = _subRows[right->second].GetMinX();
double rightminx = _subRows[right->second]->GetMinX();
if (X > rightminx)
return _subRows[right->second];
return *_subRows[right->second];
// si il n'y a rien a gauche...
if (left == _subRowsXMaxInv.end())
{
assert(right != _subRowsXMax.end());
return _subRows[right->second];
return *_subRows[right->second];
}
// on est au milieu de deux subrows, on
// renvoie le plus proche.
if ((X - _subRows[left->second].GetMaxX())
> (_subRows[right->second].GetMinX() - X))
if ((X - _subRows[left->second]->GetMaxX())
> (_subRows[right->second]->GetMinX() - X))
{
return _subRows[right->second];
return *_subRows[right->second];
}
else
{
return _subRows[left->second];
return *_subRows[left->second];
}
}
@ -106,7 +124,7 @@ PRow::Plot(ofstream& out) const
{
for (PSubRows::const_iterator srit=_subRows.begin(); srit!=_subRows.end(); srit++)
{
srit->Plot(out);
(*srit)->Plot(out);
}
return out;
}
@ -115,10 +133,10 @@ ofstream&
PRow::PlotLabel(ofstream& out, unsigned TotalMoves) const
{
for (PSubRows::const_iterator srit=_subRows.begin(); srit!=_subRows.end(); srit++)
{
srit->PlotLabel(out, TotalMoves);
}
return out;
{
(*srit)->PlotLabel(out, TotalMoves);
}
return out;
}
ostream&
PRow::Print(ostream& os) const

View File

@ -17,7 +17,7 @@ class PRow : public PContainer
friend class PPlacement;
public:
typedef vector <PSubRow> PSubRows;
typedef vector <PSubRow*> PSubRows;
typedef map<double, unsigned, less<double> > PSubRowsXMax;
typedef map<double, unsigned, greater<double> > PSubRowsXMaxInv;
@ -32,6 +32,7 @@ class PRow : public PContainer
PRow(unsigned nbofsubrows);
PRow(PPlacement& placement, const double ymin, const double xmax,
const unsigned nbofsubrows, const bool orientation);
~PRow();
void Init(double Y, double MinX, PPlacement &Placement, const bool RowOrientation);
bool GetOrientation() const { return _orientation; }

View File

@ -9,7 +9,12 @@ PSubRow::PSubRow()
{}
PSubRow::~PSubRow()
{}
{
for (PBins::iterator bit = _bins.begin();
bit !=_bins.end();
bit++)
delete *bit;
}
unsigned
PSubRow::GetNBins() const
@ -52,21 +57,21 @@ PSubRow::Init(PRow* row, double y, double minx, double maxx, double margin, doub
_bins.reserve(_nBins);
for (unsigned binnumber = 0; binnumber < _nBins; binnumber++)
{
_bins.push_back(PBin());
_bins.push_back(new PBin());
binbbox.SetMinX(xpos);
if (modulo > 0)
{
xpos += (binswidth+1);
binbbox.SetMaxX(xpos);
modulo--;
xpos += (binswidth+1);
binbbox.SetMaxX(xpos);
modulo--;
}
else
{
xpos += binswidth;
binbbox.SetMaxX(xpos);
xpos += binswidth;
binbbox.SetMaxX(xpos);
}
_binsXMax[xpos] = binnumber;
_bins.back().Init(binbbox, binscapa, *this);
_bins.back()->Init(binbbox, binscapa, *this);
}
_row->MergeBBox(_bBox);
}
@ -74,25 +79,25 @@ PSubRow::Init(PRow* row, double y, double minx, double maxx, double margin, doub
PBin&
PSubRow::GetBin(const double X)
{
if (X >= _bins.rbegin()->GetMaxX())
return *(_bins.rbegin());
if (X >= (*_bins.rbegin())->GetMaxX())
return **(_bins.rbegin());
if (X <= _bins.begin()->GetMinX())
return *(_bins.begin());
if (X <= (*_bins.begin())->GetMinX())
return **(_bins.begin());
PBinsXMax::iterator srpos = _binsXMax.upper_bound(X);
return _bins[srpos->second];
return *_bins[srpos->second];
}
bool
PSubRow::InsertIns(PToPlaceIns& Ins, int BinNumber)
{
if ((_bins[BinNumber].GetCapa() - _bins[BinNumber].GetSize())
if ((_bins[BinNumber]->GetCapa() - _bins[BinNumber]->GetSize())
< Ins.GetWidth())
return false;
else
{
_bins[BinNumber].AddIns(&Ins);
_bins[BinNumber]->AddIns(&Ins);
return true;
}
}
@ -101,15 +106,15 @@ unsigned
PSubRow::GetNIns() const
{
unsigned nins = 0;
for (PBins::const_iterator BinIt=_bins.begin(); BinIt!=_bins.end(); BinIt++)
nins += BinIt->GetNIns();
for (PBins::const_iterator bit =_bins.begin(); bit !=_bins.end(); bit++)
nins += (*bit)->GetNIns();
return nins;
}
void
PSubRow::ForceIns(PToPlaceIns& Ins, int BinNumber)
{
_bins[BinNumber].AddIns(&Ins);
_bins[BinNumber]->AddIns(&Ins);
}
#ifndef Abs
@ -119,9 +124,9 @@ double
PSubRow::GetBinCost() const
{
double BinCost = 0.0;
for (PBins::const_iterator BinIt = _bins.begin(); BinIt != _bins.end(); BinIt++)
for (PBins::const_iterator bit = _bins.begin(); bit != _bins.end(); bit++)
{
BinCost += Abs(BinIt->GetSize() - BinIt->GetCapa());
BinCost += Abs((*bit)->GetSize() - (*bit)->GetCapa());
}
return BinCost;
}
@ -129,9 +134,9 @@ PSubRow::GetBinCost() const
ofstream&
PSubRow::Plot(ofstream& out) const
{
for (PBins::const_iterator BinIt=_bins.begin(); BinIt!=_bins.end(); BinIt++)
for (PBins::const_iterator bit=_bins.begin(); bit!=_bins.end(); bit++)
{
BinIt->Plot(out);
(*bit)->Plot(out);
}
return out;
}
@ -139,11 +144,11 @@ PSubRow::Plot(ofstream& out) const
ofstream&
PSubRow::PlotLabel(ofstream& out, unsigned TotalMoves) const
{
for (PBins::const_iterator BinIt=_bins.begin(); BinIt!=_bins.end(); BinIt++)
{
BinIt->PlotLabel(out, TotalMoves);
}
return out;
for (PBins::const_iterator bit=_bins.begin(); bit!=_bins.end(); bit++)
{
(*bit)->PlotLabel(out, TotalMoves);
}
return out;
}
ostream&

View File

@ -16,7 +16,7 @@ class PSubRow : public PContainer {
friend class PRow;
public:
typedef vector <PBin> PBins;
typedef vector <PBin*> PBins;
typedef map <double, unsigned> PBinsXMax;
private: