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

PlSP2BTree Class Reference

#include <plsptobtree.h>

Collaboration diagram for PlSP2BTree:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 PlSP2BTree (const vector< double > &n_xloc, const vector< double > &n_yloc, const vector< double > &n_widths, const vector< double > &n_heights, const vector< int > &XX, const vector< int > &YY)
 PlSP2BTree (const vector< double > &n_xloc, const vector< double > &n_yloc, const vector< double > &n_widths, const vector< double > &n_heights, const vector< unsigned int > &XX, const vector< unsigned int > &YY)
const vector< BTree::BTreeNode > & btree () const
const vector< int > & SP_XX () const
const vector< int > & SP_YY () const
const vector< int > & SP_XXinverse () const
const vector< int > & SP_YYinverse () const
bool SPleftof (int i, int j) const
bool SPrightof (int i, int j) const
bool SPabove (int i, int j) const
bool SPbelow (int i, int j) const

Public Attributes

const vector< double > & xloc
const vector< double > & yloc
const vector< double > & widths
const vector< double > & heights

Static Public Attributes

const double INFTY = basepacking_h::Dimension::INFTY
const int UNDEFINED = BTree::UNDEFINED

Private Member Functions

void constructor_core ()
void initializeTree ()
void build_tree ()
void build_tree_add_block (int currBlock, int otree_parent)

Private Attributes

int _blocknum
vector< int > _XX
vector< int > _YY
vector< int > _XXinverse
vector< int > _YYinverse
vector< BTree::BTreeNode_btree

Constructor & Destructor Documentation

PlSP2BTree::PlSP2BTree const vector< double > &  n_xloc,
const vector< double > &  n_yloc,
const vector< double > &  n_widths,
const vector< double > &  n_heights,
const vector< int > &  XX,
const vector< int > &  YY
 

Definition at line 48 of file plsptobtree.cxx.

References constructor_core().

00054    : xloc(n_xloc),
00055      yloc(n_yloc),
00056      widths(n_widths),
00057      heights(n_heights),
00058      _blocknum(n_xloc.size()),
00059      _XX(XX),
00060      _YY(YY),
00061      _XXinverse(_blocknum),
00062      _YYinverse(_blocknum),
00063      _btree(_blocknum+2)
00064 {
00065    constructor_core();
00066 }

Here is the call graph for this function:

PlSP2BTree::PlSP2BTree const vector< double > &  n_xloc,
const vector< double > &  n_yloc,
const vector< double > &  n_widths,
const vector< double > &  n_heights,
const vector< unsigned int > &  XX,
const vector< unsigned int > &  YY
 

Definition at line 68 of file plsptobtree.cxx.

References _blocknum, _XX, _YY, and constructor_core().

00074    : xloc(n_xloc),
00075      yloc(n_yloc),
00076      widths(n_widths),
00077      heights(n_heights),
00078      _blocknum(n_xloc.size()),
00079      _XX(_blocknum),
00080      _YY(_blocknum),
00081      _XXinverse(_blocknum),
00082      _YYinverse(_blocknum),
00083      _btree(_blocknum+2)
00084 {
00085    for (int i = 0; i < _blocknum; i++)
00086    {
00087       _XX[i] = int(XX[i]);
00088       _YY[i] = int(YY[i]);
00089    }
00090    constructor_core();
00091 }

Here is the call graph for this function:


Member Function Documentation

const vector< BTree::BTreeNode > & PlSP2BTree::btree  )  const [inline]
 

Definition at line 99 of file plsptobtree.h.

References _btree.

Referenced by Pl2BTree::TCG_build_tree().

00100 {   return _btree; }

void PlSP2BTree::build_tree  )  [private]
 

Definition at line 93 of file plsptobtree.cxx.

References _blocknum, _XXinverse, _YY, build_tree_add_block(), SPleftof(), widths, and xloc.

Referenced by constructor_core().

00094 {
00095    for (int i = 0; i < _blocknum; i++)
00096    {
00097       int currBlock = _YY[i];
00098       int otree_parent = _blocknum; // left-edge initially
00099 
00100       double currXStart = xloc[currBlock];
00101       double minDistance = currXStart;
00102       int parentMaxIndex = _blocknum;
00103       for (int j = i-1; j >= 0; j--)
00104       {
00105          int tempBlock = _YY[j];
00106          if (SPleftof(tempBlock, currBlock))
00107          {
00108             if (_XXinverse[tempBlock] < parentMaxIndex)
00109             {
00110                double tempDistance =
00111                   currXStart - xloc[tempBlock] - widths[tempBlock];
00112                if (tempDistance < minDistance)
00113                {
00114                   minDistance = tempDistance;
00115                   otree_parent = tempBlock;
00116                }
00117             }
00118          }
00119          else // SPbelow(tempBlock, currBlock)
00120             parentMaxIndex = min(parentMaxIndex, _XXinverse[tempBlock]);
00121       }
00122       build_tree_add_block(currBlock, otree_parent);
00123    }
00124 }

Here is the call graph for this function:

void PlSP2BTree::build_tree_add_block int  currBlock,
int  otree_parent
[private]
 

Definition at line 126 of file plsptobtree.cxx.

References _btree, UNDEFINED, and yloc.

Referenced by build_tree().

00128 {
00129 //    printf("block %d added with block %d as its otree-parent\n",
00130 //           currBlock, otree_parent);
00131    
00132    if (_btree[otree_parent].left == UNDEFINED)
00133    {
00134       _btree[otree_parent].left = currBlock;
00135       _btree[currBlock].parent = otree_parent;
00136    }
00137    else
00138    {
00139       int tree_prev = otree_parent;
00140       int tree_curr = _btree[otree_parent].left;
00141       while ((tree_curr != UNDEFINED) &&
00142              (yloc[tree_curr] < yloc[currBlock]))
00143       {
00144          tree_prev = tree_curr;
00145          tree_curr = _btree[tree_curr].right;
00146       }
00147 
00148 //       printf("tree_curr: %d tree_prev: %d\n", tree_curr, tree_prev);
00149 //       printf("YLOC: tree_curr: %.2lf currBlock: %.2lf tree_prev: %.2lf\n",
00150 //              (tree_curr != UNDEFINED)? yloc[tree_curr] : -1,
00151 //              yloc[currBlock], yloc[tree_prev]);
00152       
00153       if ((tree_curr != UNDEFINED) &&
00154           (tree_curr == _btree[tree_prev].left))
00155          _btree[tree_prev].left = currBlock;
00156       else
00157          _btree[tree_prev].right = currBlock;
00158       _btree[currBlock].parent = tree_prev;
00159 
00160       _btree[currBlock].right = tree_curr; // possibly UNDEFINED
00161       if (tree_curr != UNDEFINED)
00162          _btree[tree_curr].parent = currBlock;
00163    }
00164 }

void PlSP2BTree::constructor_core  )  [private]
 

Definition at line 166 of file plsptobtree.cxx.

References _blocknum, _XX, _XXinverse, _YY, _YYinverse, build_tree(), and initializeTree().

Referenced by PlSP2BTree().

00167 {
00168    initializeTree();
00169    for (int i = 0; i < _blocknum; i++)
00170    {
00171       _XXinverse[_XX[i]] = i;
00172       _YYinverse[_YY[i]] = i;
00173    }
00174    build_tree();
00175 }

Here is the call graph for this function:

void PlSP2BTree::initializeTree  )  [private]
 

Definition at line 177 of file plsptobtree.cxx.

References _blocknum, _btree, and UNDEFINED.

Referenced by constructor_core().

00178 {
00179    int vec_size = int(_btree.size());
00180    for (int i = 0; i < vec_size; i++)
00181    {
00182       _btree[i].parent = _blocknum;
00183       _btree[i].left = UNDEFINED;
00184       _btree[i].right = UNDEFINED;
00185       _btree[i].block_index = i;
00186       _btree[i].orient = 0;
00187    }
00188 
00189    _btree[_blocknum].parent = UNDEFINED;
00190    _btree[_blocknum].left = UNDEFINED;
00191    _btree[_blocknum].right = UNDEFINED;
00192    _btree[_blocknum].block_index = _blocknum;
00193    _btree[_blocknum].orient = UNDEFINED;
00194 
00195    _btree[_blocknum+1].parent = _blocknum;
00196    _btree[_blocknum+1].left = UNDEFINED;
00197    _btree[_blocknum+1].right = UNDEFINED;
00198    _btree[_blocknum+1].block_index = _blocknum+1;
00199    _btree[_blocknum+1].orient = UNDEFINED;
00200 }

const vector< int > & PlSP2BTree::SP_XX  )  const [inline]
 

Definition at line 102 of file plsptobtree.h.

References _XX.

00103 {   return _XX; }

const vector< int > & PlSP2BTree::SP_XXinverse  )  const [inline]
 

Definition at line 108 of file plsptobtree.h.

References _XXinverse.

00109 {   return _XXinverse; }

const vector< int > & PlSP2BTree::SP_YY  )  const [inline]
 

Definition at line 105 of file plsptobtree.h.

References _YY.

00106 {   return _YY; }

const vector< int > & PlSP2BTree::SP_YYinverse  )  const [inline]
 

Definition at line 111 of file plsptobtree.h.

References _YYinverse.

00112 {   return _YYinverse; }

bool PlSP2BTree::SPabove int  i,
int  j
const [inline]
 

Definition at line 121 of file plsptobtree.h.

References _XXinverse, and _YYinverse.

Referenced by SPbelow().

00122 {   return (_XXinverse[i] < _XXinverse[j] &&
00123             _YYinverse[i] > _YYinverse[j]); }

bool PlSP2BTree::SPbelow int  i,
int  j
const [inline]
 

Definition at line 125 of file plsptobtree.h.

References SPabove().

00126 {   return SPabove(j, i); }

Here is the call graph for this function:

bool PlSP2BTree::SPleftof int  i,
int  j
const [inline]
 

Definition at line 114 of file plsptobtree.h.

References _XXinverse, and _YYinverse.

Referenced by build_tree(), and SPrightof().

00115 {   return (_XXinverse[i] < _XXinverse[j] &&
00116             _YYinverse[i] < _YYinverse[j]); }

bool PlSP2BTree::SPrightof int  i,
int  j
const [inline]
 

Definition at line 118 of file plsptobtree.h.

References SPleftof().

00119 {   return SPleftof(j, i); }

Here is the call graph for this function:


Member Data Documentation

int PlSP2BTree::_blocknum [private]
 

Definition at line 81 of file plsptobtree.h.

Referenced by build_tree(), constructor_core(), initializeTree(), and PlSP2BTree().

vector<BTree::BTreeNode> PlSP2BTree::_btree [private]
 

Definition at line 86 of file plsptobtree.h.

Referenced by btree(), build_tree_add_block(), and initializeTree().

vector<int> PlSP2BTree::_XX [private]
 

Definition at line 82 of file plsptobtree.h.

Referenced by constructor_core(), PlSP2BTree(), and SP_XX().

vector<int> PlSP2BTree::_XXinverse [private]
 

Definition at line 84 of file plsptobtree.h.

Referenced by build_tree(), constructor_core(), SP_XXinverse(), SPabove(), and SPleftof().

vector<int> PlSP2BTree::_YY [private]
 

Definition at line 83 of file plsptobtree.h.

Referenced by build_tree(), constructor_core(), PlSP2BTree(), and SP_YY().

vector<int> PlSP2BTree::_YYinverse [private]
 

Definition at line 85 of file plsptobtree.h.

Referenced by constructor_core(), SP_YYinverse(), SPabove(), and SPleftof().

const vector<double>& PlSP2BTree::heights
 

Definition at line 70 of file plsptobtree.h.

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

Definition at line 45 of file plsptobtree.cxx.

const int PlSP2BTree::UNDEFINED = BTree::UNDEFINED [static]
 

Definition at line 46 of file plsptobtree.cxx.

Referenced by build_tree_add_block(), and initializeTree().

const vector<double>& PlSP2BTree::widths
 

Definition at line 69 of file plsptobtree.h.

Referenced by build_tree().

const vector<double>& PlSP2BTree::xloc
 

Definition at line 67 of file plsptobtree.h.

Referenced by build_tree().

const vector<double>& PlSP2BTree::yloc
 

Definition at line 68 of file plsptobtree.h.

Referenced by build_tree_add_block().


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