Main Page | Namespace List | Class Hierarchy | Compound List | File List | Namespace Members | Compound Members | File Members

ShiftBlock Class Reference

#include <plcompact.h>

Collaboration diagram for ShiftBlock:

Collaboration graph
[legend]
List of all members.

Public Types

enum  Directions {
  NORTH, EAST, SOUTH, WEST,
  DIR_NUM
}

Public Member Functions

 ShiftBlock (const vector< double > &xloc, const vector< double > &yloc, const vector< double > &widths, const vector< double > &heights, double left_bound, double right_bound, double top_bound, double bottom_bound)
void operator() (int currBlk, vector< ShiftInfo > &shiftinfo) const

Static Public Attributes

const double INFTY = basepacking_h::Dimension::INFTY
const double NEG_INFTY = -1 * ShiftBlock::INFTY
const int UNDEFINED = basepacking_h::Dimension::UNDEFINED

Private Attributes

int _blocknum
vector< double > _xStart
vector< double > _xEnd
vector< double > _yStart
vector< double > _yEnd
double _epsilon

Member Enumeration Documentation

enum ShiftBlock::Directions
 

Enumeration values:
NORTH 
EAST 
SOUTH 
WEST 
DIR_NUM 

Definition at line 70 of file plcompact.h.

Referenced by ShiftLegalizer::legalizeBlock(), and operator()().

00070 {NORTH, EAST, SOUTH, WEST, DIR_NUM};


Constructor & Destructor Documentation

ShiftBlock::ShiftBlock const vector< double > &  xloc,
const vector< double > &  yloc,
const vector< double > &  widths,
const vector< double > &  heights,
double  left_bound,
double  right_bound,
double  top_bound,
double  bottom_bound
 

Definition at line 258 of file plcompact.cxx.

References _blocknum, _epsilon, _xEnd, _xStart, _yEnd, _yStart, basepacking_h::Dimension::EPSILON_ACCURACY, INFTY, and NEG_INFTY.

00266    : _blocknum(xloc.size()),
00267      _xStart(_blocknum+4),
00268      _xEnd(_blocknum+4),
00269      _yStart(_blocknum+4),
00270      _yEnd(_blocknum+4),
00271      _epsilon(INFTY)
00272 {
00273    for (int i = 0; i < _blocknum; i++)
00274    {
00275       _xStart[i] = xloc[i];
00276       _xEnd[i] = xloc[i] + widths[i];
00277       _yStart[i] = yloc[i];
00278       _yEnd[i] = yloc[i] + heights[i];
00279 
00280       _epsilon = min(_epsilon, min(widths[i], heights[i]));
00281    } 
00282    _epsilon /= basepacking_h::Dimension::EPSILON_ACCURACY;  
00283 
00284    // LEFT-edge
00285    _xStart[_blocknum] = NEG_INFTY;
00286    _xEnd[_blocknum] = left_bound;
00287    _yStart[_blocknum] = NEG_INFTY;
00288    _yEnd[_blocknum] = INFTY;
00289 
00290    // BOTTOM-edge
00291    _xStart[_blocknum+1] = NEG_INFTY;
00292    _xEnd[_blocknum+1] = INFTY;
00293    _yStart[_blocknum+1] = NEG_INFTY;
00294    _yEnd[_blocknum+1] = bottom_bound;
00295 
00296    // RIGHT-edge
00297    _xStart[_blocknum+2] = right_bound;
00298    _xEnd[_blocknum+2] = INFTY;
00299    _yStart[_blocknum+2] = NEG_INFTY;
00300    _yEnd[_blocknum+2] = INFTY;
00301       
00302    // TOP-edge
00303    _xStart[_blocknum+3] = NEG_INFTY;
00304    _xEnd[_blocknum+3] = INFTY;
00305    _yStart[_blocknum+3] = top_bound;
00306    _yEnd[_blocknum+3] = INFTY;
00307 }


Member Function Documentation

void ShiftBlock::operator() int  currBlk,
vector< ShiftInfo > &  shiftinfo
const
 

Definition at line 309 of file plcompact.cxx.

References _blocknum, _epsilon, _xEnd, _xStart, _yEnd, _yStart, DIR_NUM, Directions, EAST, INFTY, NORTH, SOUTH, and WEST.

00311 {
00312    // -----initialize the output-----
00313    shiftinfo.resize(DIR_NUM);
00314    for (int i = 0; i < int(DIR_NUM); i++)
00315    {
00316       Directions currDir = Directions(i);
00317       shiftinfo[currDir].shiftRangeMin = 0;
00318       shiftinfo[currDir].shiftRangeMax = INFTY;      
00319       shiftinfo[currDir].overlapMin = INFTY;
00320       shiftinfo[currDir].overlapMax = 0;
00321    }
00322 
00323    // -----determine the overlap's and/or shiftRange-----
00324    for (int tempBlk = 0; tempBlk < _blocknum+4; tempBlk++)
00325    {
00326       // printf("-----tempBlk %d-----\n", tempBlk);
00327       if (tempBlk != currBlk)
00328       {
00329          if (_xStart[tempBlk] < _xEnd[currBlk] - _epsilon &&
00330              _xStart[currBlk] < _xEnd[tempBlk] - _epsilon)
00331          {
00332             // horizontal overlap, relevant for dir's N and S
00333             if (_yStart[tempBlk] < _yEnd[currBlk] - _epsilon &&
00334                 _yStart[currBlk] < _yEnd[tempBlk] - _epsilon)
00335             {
00336                // real overlaps, "shiftRange(Min/Max)" must be +ve
00337                shiftinfo[NORTH].shiftRangeMin =
00338                   max(shiftinfo[NORTH].shiftRangeMin,
00339                       _yEnd[tempBlk] - _yStart[currBlk]);
00340                
00341                shiftinfo[SOUTH].shiftRangeMin =
00342                   max(shiftinfo[SOUTH].shiftRangeMin,
00343                       _yEnd[currBlk] - _yStart[tempBlk]);
00344 
00345                shiftinfo[EAST].shiftRangeMin =
00346                   max(shiftinfo[EAST].shiftRangeMin,
00347                       _xEnd[currBlk] - _xStart[tempBlk]);
00348 
00349                shiftinfo[WEST].shiftRangeMin =
00350                   max(shiftinfo[WEST].shiftRangeMin,
00351                       _xEnd[tempBlk] - _xStart[currBlk]);
00352                
00353                // handle "overlap(Min/Max)"
00354                shiftinfo[NORTH].overlapMin =
00355                   min(shiftinfo[NORTH].overlapMin, _xStart[tempBlk]);
00356                
00357                shiftinfo[NORTH].overlapMax =
00358                   max(shiftinfo[NORTH].overlapMax, _xEnd[tempBlk]);
00359 
00360                shiftinfo[SOUTH].overlapMin = shiftinfo[NORTH].overlapMin;
00361                shiftinfo[SOUTH].overlapMax = shiftinfo[NORTH].overlapMax;
00362 
00363                shiftinfo[EAST].overlapMin =
00364                   min(shiftinfo[EAST].overlapMin, _yStart[tempBlk]);
00365 
00366                shiftinfo[EAST].overlapMax =
00367                   max(shiftinfo[EAST].overlapMax, _yEnd[tempBlk]);
00368 
00369                shiftinfo[WEST].overlapMin = shiftinfo[EAST].overlapMin;
00370                shiftinfo[WEST].overlapMax = shiftinfo[EAST].overlapMax;
00371                // cout << "here -1- real overlap" << endl;
00372             }
00373             else if (_yStart[tempBlk] < _yEnd[currBlk] - _epsilon) 
00374             {
00375                // "tempBlk" below "currBlk"
00376                shiftinfo[SOUTH].shiftRangeMax =
00377                   min(shiftinfo[SOUTH].shiftRangeMax,
00378                       max(_yStart[currBlk]-_yEnd[tempBlk], 0.0));
00379                // cout << "here -2- tempBlk below currBlk" << endl;
00380             }
00381             else
00382             {
00383                // "tempBlk" above "currBlk"
00384                shiftinfo[NORTH].shiftRangeMax =
00385                   min(shiftinfo[NORTH].shiftRangeMax,
00386                       max(_yStart[tempBlk]-_yEnd[currBlk], 0.0));
00387                // cout << "here -3- tempBlk above currBlk" << endl;
00388             }
00389          }
00390          else if (_yStart[tempBlk] < _yEnd[currBlk] - _epsilon &&
00391                   _yStart[currBlk] < _yEnd[tempBlk] - _epsilon)
00392          {
00393             // vertical overlap, but not horizontal
00394             if (_xStart[tempBlk] < _xEnd[currBlk] - _epsilon)
00395             {
00396                // "tempBlk" left of "currBlk"
00397                shiftinfo[EAST].shiftRangeMax =
00398                   min(shiftinfo[EAST].shiftRangeMax,
00399                       max(_xStart[currBlk]-_xEnd[tempBlk], 0.0));
00400                // cout << "here -4- tempBlk left of currBlk" << endl;
00401             }
00402             else
00403             {
00404                // "tempBlk" right of "currBlk"
00405                shiftinfo[WEST].shiftRangeMax =
00406                   min(shiftinfo[WEST].shiftRangeMax,
00407                       max(_xStart[tempBlk]-_xEnd[currBlk], 0.0));
00408                // cout << "here -5- tempBlk right of currBlk" << endl;
00409             }
00410          }
00411       }
00412    }
00413 }


Member Data Documentation

int ShiftBlock::_blocknum [private]
 

Definition at line 76 of file plcompact.h.

Referenced by operator()(), and ShiftBlock().

double ShiftBlock::_epsilon [private]
 

Definition at line 82 of file plcompact.h.

Referenced by operator()(), and ShiftBlock().

vector<double> ShiftBlock::_xEnd [private]
 

Definition at line 78 of file plcompact.h.

Referenced by operator()(), and ShiftBlock().

vector<double> ShiftBlock::_xStart [private]
 

Definition at line 77 of file plcompact.h.

Referenced by operator()(), and ShiftBlock().

vector<double> ShiftBlock::_yEnd [private]
 

Definition at line 80 of file plcompact.h.

Referenced by operator()(), and ShiftBlock().

vector<double> ShiftBlock::_yStart [private]
 

Definition at line 79 of file plcompact.h.

Referenced by operator()(), and ShiftBlock().

const double ShiftBlock::INFTY = basepacking_h::Dimension::INFTY [static]
 

Definition at line 48 of file plcompact.cxx.

Referenced by operator()(), and ShiftBlock().

const double ShiftBlock::NEG_INFTY = -1 * ShiftBlock::INFTY [static]
 

Definition at line 49 of file plcompact.cxx.

Referenced by ShiftBlock().

const int ShiftBlock::UNDEFINED = basepacking_h::Dimension::UNDEFINED [static]
 

Definition at line 50 of file plcompact.cxx.


The documentation for this class was generated from the following files:
Generated on Mon Apr 25 01:15:39 2005 for Parquete by doxygen 1.3.2