1 
2 // This file is part of the Alliance Project.
3 // Copyright (C) Laboratoire LIP6 - Departement ASIM
4 // Universite Pierre et Marie Curie
5 //
6 // The Alliance Project  is free software;  you can  redistribute it and/or
7 // modify  it  under the  terms  of  the  GNU  General  Public License  as
8 // published by  the Free  Software Foundation; either  version 2  of  the
9 // License, or (at your option) any later version.
10 //
11 // The Alliance Project  is distributed in the hope that it will be useful,
12 // but  WITHOUT  ANY  WARRANTY;  without  even  the  implied  warranty  of
13 // MERCHANTABILITY  or  FITNESS  FOR A  PARTICULAR PURPOSE.   See  the GNU
14 // General Public License for more details.
15 //
16 // You should have received a copy  of  the  GNU  General  Public  License
17 // along with  the Alliance Project;  if  not,  write to the  Free Software
18 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 //
20 //
21 // License-Tag
22 //
23 // Date   : 29/01/2004
24 // Author : Christophe Alexandre  <Christophe.Alexandre@lip6.fr>
25 //
26 // Authors-Tag
27 #ifndef __PBIN_H
28 #define __PBIN_H
29 
30 #include <iostream>
31 #include <fstream>
32 #include <list>
33 #include "PSubRow.h"
34 using namespace std;
35 
36 class PToPlaceIns;
37 
38 class PBin : public PContainer{
39     friend class PSubRow;
40 
41   public:
42     typedef list<PToPlaceIns*> PToPlaceInss;
43 
44   private:
45     PSubRow*		_subRow;
46     double		_capa;   	// Objective Occupation of the bin
47     double		_size;   	// Sum of instances widths
48     PToPlaceInss	_toPlaceInss;  	// Instances of bin.
49     PPos		_pos;		// Position of the center of the bin
50     unsigned		_sourceHits;
51     unsigned		_targetHits;
52 
53   public:
54 			PBin();
55 
56     void		Init(const PBBox& bbox, double margin, PSubRow &subrow);
57 
GetSubRow()58     PSubRow*		GetSubRow() const	{ return _subRow; }
GetOrientation()59     bool		GetOrientation() const	{ return _subRow->GetOrientation(); }
GetCapa()60     double		GetCapa() const        	{ return _capa; }
GetSize()61     double		GetSize() const        	{ return _size; }
GetToPlaceInss()62     PToPlaceInss&	GetToPlaceInss()       	{ return _toPlaceInss; }
GetNIns()63     unsigned		GetNIns() const		{ return _toPlaceInss.size(); }
GetPos()64     PPos		GetPos() const          { return _pos; }
IncrementSourceHits()65     void		IncrementSourceHits() { ++_sourceHits; }
IncrementTargetHits()66     void		IncrementTargetHits() { ++_targetHits; }
67 
AddSize(const double value)68     void		AddSize(const double value) { _size += value; _subRow->AddSize(value); }
69 
70     bool		UnderOccupied(const double margin) const;
71     void		AddIns(PToPlaceIns *ins);
72     void		RemoveIns(PToPlaceIns *ins);
73     void		RemoveFrontIns(PToPlaceIns *ins);
74     void		RemoveBackIns(PToPlaceIns *ins);
75 
76     ostream&	Print(ostream& os) const;
77     ofstream&	Plot(ofstream& out) const;
78     ofstream&	PlotLabel(ofstream& out, unsigned totalMoves) const;
79 };
80 #endif /* __PBIN_H */
81