00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 #ifndef PLSPTOBTREE_H
00036 #define PLSPTOBTREE_H
00037
00038 #include "btree.h"
00039
00040 #include <vector>
00041 using namespace std;
00042
00043
00044 class PlSP2BTree
00045 {
00046 public:
00047 PlSP2BTree(const vector<double>& n_xloc,
00048 const vector<double>& n_yloc,
00049 const vector<double>& n_widths,
00050 const vector<double>& n_heights,
00051 const vector<int>& XX,
00052 const vector<int>& YY);
00053
00054 PlSP2BTree(const vector<double>& n_xloc,
00055 const vector<double>& n_yloc,
00056 const vector<double>& n_widths,
00057 const vector<double>& n_heights,
00058 const vector<unsigned int>& XX,
00059 const vector<unsigned int>& YY);
00060
00061 inline const vector<BTree::BTreeNode>& btree() const;
00062 inline const vector<int>& SP_XX() const;
00063 inline const vector<int>& SP_YY() const;
00064 inline const vector<int>& SP_XXinverse() const;
00065 inline const vector<int>& SP_YYinverse() const;
00066
00067 const vector<double>& xloc;
00068 const vector<double>& yloc;
00069 const vector<double>& widths;
00070 const vector<double>& heights;
00071
00072 inline bool SPleftof(int i, int j) const;
00073 inline bool SPrightof(int i , int j) const;
00074 inline bool SPabove(int i, int j) const;
00075 inline bool SPbelow(int i, int j) const;
00076
00077 static const double INFTY;
00078 static const int UNDEFINED;
00079
00080 private:
00081 int _blocknum;
00082 vector<int> _XX;
00083 vector<int> _YY;
00084 vector<int> _XXinverse;
00085 vector<int> _YYinverse;
00086 vector<BTree::BTreeNode> _btree;
00087
00088 void constructor_core();
00089 void initializeTree();
00090
00091 void build_tree();
00092 void build_tree_add_block(int currBlock, int otree_parent);
00093 };
00094
00095
00096
00097
00098
00099 inline const vector<BTree::BTreeNode>& PlSP2BTree::btree() const
00100 { return _btree; }
00101
00102 inline const vector<int>& PlSP2BTree::SP_XX() const
00103 { return _XX; }
00104
00105 inline const vector<int>& PlSP2BTree::SP_YY() const
00106 { return _YY; }
00107
00108 inline const vector<int>& PlSP2BTree::SP_XXinverse() const
00109 { return _XXinverse; }
00110
00111 inline const vector<int>& PlSP2BTree::SP_YYinverse() const
00112 { return _YYinverse; }
00113
00114 inline bool PlSP2BTree::SPleftof(int i, int j) const
00115 { return (_XXinverse[i] < _XXinverse[j] &&
00116 _YYinverse[i] < _YYinverse[j]); }
00117
00118 inline bool PlSP2BTree::SPrightof(int i, int j) const
00119 { return SPleftof(j, i); }
00120
00121 inline bool PlSP2BTree::SPabove(int i, int j) const
00122 { return (_XXinverse[i] < _XXinverse[j] &&
00123 _YYinverse[i] > _YYinverse[j]); }
00124
00125 inline bool PlSP2BTree::SPbelow(int i, int j) const
00126 { return SPabove(j, i); }
00127
00128
00129 #endif