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

PlToSP.h

Go to the documentation of this file.
00001 /**************************************************************************
00002 ***    
00003 *** Copyright (c) 1995-2000 Regents of the University of California,
00004 ***               Andrew E. Caldwell, Andrew B. Kahng and Igor L. Markov
00005 *** Copyright (c) 2000-2004 Regents of the University of Michigan,
00006 ***               Saurabh N. Adya, Jarrod A. Roy and Igor L. Markov
00007 ***
00008 ***  Contact author(s): abk@cs.ucsd.edu, imarkov@umich.edu
00009 ***  Original Affiliation:   UCLA, Computer Science Department,
00010 ***                          Los Angeles, CA 90095-1596 USA
00011 ***
00012 ***  Permission is hereby granted, free of charge, to any person obtaining 
00013 ***  a copy of this software and associated documentation files (the
00014 ***  "Software"), to deal in the Software without restriction, including
00015 ***  without limitation 
00016 ***  the rights to use, copy, modify, merge, publish, distribute, sublicense, 
00017 ***  and/or sell copies of the Software, and to permit persons to whom the 
00018 ***  Software is furnished to do so, subject to the following conditions:
00019 ***
00020 ***  The above copyright notice and this permission notice shall be included
00021 ***  in all copies or substantial portions of the Software.
00022 ***
00023 *** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 
00024 *** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
00025 *** OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 
00026 *** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
00027 *** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
00028 *** OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
00029 *** THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00030 ***
00031 ***
00032 ***************************************************************************/
00033 
00034 
00035 
00036 
00037 #ifndef PLTOSP_H
00038 #define PLTOSP_H
00039 
00040 #include <fstream>
00041 #include <vector>
00042 #include <algorithm>
00043 #include <math.h>
00044 #include <stdlib.h>
00045 
00046 using namespace std;
00047 
00048 namespace parquetfp
00049 {
00050    enum PL2SP_ALGO{NAIVE_ALGO, TCG_ALGO};
00051 
00052    class Pl2SP
00053    {
00054    private:
00055       vector<double> _xloc;
00056       vector<double> _yloc;
00057       vector<double> _widths;
00058       vector<double> _heights;
00059 
00060       vector<unsigned> _XX;
00061       vector<unsigned> _YY;
00062 
00063       int _cnt;
00064    public:
00065       Pl2SP(vector<double>& xloc, vector<double>& yloc, vector<double>& widths,
00066             vector<double>& heights, PL2SP_ALGO whichAlgo);
00067 
00068       ~Pl2SP() {}
00069     
00070       void naiveAlgo(void);
00071       void TCGAlgo(void);
00072 
00073       //Floyd Marshal to find TCG
00074       void TCG_FM(vector< vector <bool> >& TCGMatrixHoriz, 
00075                   vector< vector <bool> >& TCGMatrixVert);
00076 
00077       //DP to find TCG
00078       void TCG_DP(vector< vector <bool> >& TCGMatrixHoriz, 
00079                   vector< vector <bool> >& TCGMatrixVert);
00080       void TCGDfs(vector< vector <bool> >& TCGMatrix, 
00081                   vector< vector <bool> >& adjMatrix, int v, 
00082                   vector<int>& pre);
00083 
00084       const vector<unsigned>& getXSP(void) const
00085          { return _XX; }
00086      
00087       const vector<unsigned>& getYSP(void) const
00088          { return _YY; }
00089 
00090       void print(void) const;
00091 
00092    };
00093 
00094    struct RowElem
00095    {
00096       unsigned index;
00097       double xloc;
00098    };
00099 
00100 
00101    struct less_mag 
00102    {
00103       bool operator()(const RowElem &elem1, const RowElem &elem2) 
00104          { return(elem1.xloc < elem2.xloc); }
00105    };
00106 
00107    class SPXRelation
00108    {
00109       vector< vector<bool> >& TCGMatrixHoriz;
00110       vector< vector<bool> >& TCGMatrixVert;
00111 
00112    public:
00113       SPXRelation(vector< vector<bool> >& TCGMatrixHorizIP, 
00114                   vector< vector<bool> >& TCGMatrixVertIP) : 
00115          TCGMatrixHoriz(TCGMatrixHorizIP), TCGMatrixVert(TCGMatrixVertIP)
00116          {}
00117 
00118       bool operator()(unsigned i, unsigned j) 
00119          {
00120             if(TCGMatrixHoriz[i][j] == 1)
00121                return 1;
00122             else if(TCGMatrixHoriz[j][i] == 1)
00123                return 0;
00124             else if(TCGMatrixVert[j][i] == 1)
00125                return 1;
00126             else if(TCGMatrixVert[i][j] == 1)
00127                return 0;
00128             else
00129             {
00130                //cout<<"ERROR IN PL2SP SPX "<<i<<"\t"<<j<<endl;
00131                if(i<j)
00132                   return 1;
00133                else
00134                   return 0;
00135             }
00136          }
00137    };
00138 
00139    class SPYRelation
00140    {
00141       vector< vector<bool> >& TCGMatrixHoriz;
00142       vector< vector<bool> >& TCGMatrixVert;
00143 
00144    public:
00145       SPYRelation(vector< vector<bool> >& TCGMatrixHorizIP, 
00146                   vector< vector<bool> >& TCGMatrixVertIP) : 
00147          TCGMatrixHoriz(TCGMatrixHorizIP), TCGMatrixVert(TCGMatrixVertIP)
00148          {}
00149       bool operator()(unsigned i, unsigned j) 
00150          {
00151             if(TCGMatrixHoriz[i][j] == 1)
00152                return 1;
00153             else if(TCGMatrixHoriz[j][i] == 1)
00154                return 0;
00155             else if(TCGMatrixVert[j][i] == 1)
00156                return 0;
00157             else if(TCGMatrixVert[i][j] == 1)
00158                return 1;
00159             else
00160             {
00161                //cout<<"ERROR IN PL2SP SPY "<<i<<"\t"<<j<<endl;
00162                if(i<j)
00163                   return 1 ;
00164                else
00165                   return 0;
00166             }
00167          }
00168    };
00169 }
00170 //using namespace parquetfp;
00171 
00172 #endif 

Generated on Mon Apr 25 01:09:25 2005 for Parquete by doxygen 1.3.2