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 #ifndef BTREESLACKEVAL_H 00036 #define BTREESLACKEVAL_H 00037 00038 #include "basepacking.h" 00039 #include "btree.h" 00040 #include "btreecompact.h" 00041 00042 #include <vector> 00043 using namespace std; 00044 00045 // -------------------------------------------------------- 00046 class BTreeSlackEval 00047 { 00048 public: 00049 inline BTreeSlackEval(const BTree& newBTree); 00050 00051 inline void evaluateSlacks(const BTree& newBTree); 00052 const vector<double>& evaluateXSlacks(const BTree& orig_btree); 00053 const vector<double>& evaluateYSlacks(const BTree& orig_btree); 00054 00055 inline const vector<double>& xSlack() const; 00056 inline const vector<double>& ySlack() const; 00057 00058 inline const vector<double>& xlocRight() const; // xloc from Right 00059 inline const vector<double>& ylocTop() const; // yloc from Top 00060 00061 inline const BTreeCompactor& btree() const; 00062 inline const vector<BTree::BTreeNode>& rev_tree() const; 00063 inline const vector<BTree::BTreeNode>& rev_orth_tree() const; 00064 00065 static void reverse_tree(const vector<BTree::BTreeNode>& tree, 00066 vector<BTree::BTreeNode>& rev_tree); 00067 00068 private: 00069 BTreeCompactor _btree; 00070 vector<double> _xSlack; 00071 vector<double> _ySlack; 00072 00073 vector<double> _xlocRight; 00074 vector<double> _ylocTop; 00075 00076 vector<BTree::BTreeNode> _rev_tree; 00077 vector<BTree::BTreeNode> _rev_orth_tree; 00078 00079 BTreeSlackEval(const BTreeSlackEval&); // copy forbidden 00080 }; 00081 // -------------------------------------------------------- 00082 00083 // =============== 00084 // IMPLEMENTATIONS 00085 // =============== 00086 BTreeSlackEval::BTreeSlackEval(const BTree& newBTree) 00087 : _btree(newBTree), 00088 _xSlack(newBTree.NUM_BLOCKS), 00089 _ySlack(newBTree.NUM_BLOCKS), 00090 _xlocRight(newBTree.NUM_BLOCKS), 00091 _ylocTop(newBTree.NUM_BLOCKS), 00092 _rev_tree(newBTree.tree.size()), 00093 _rev_orth_tree(newBTree.tree.size()) 00094 { 00095 BTree::clean_tree(_rev_tree); 00096 BTree::clean_tree(_rev_orth_tree); 00097 } 00098 // -------------------------------------------------------- 00099 void BTreeSlackEval::evaluateSlacks(const BTree& newBTree) 00100 { 00101 _btree.slimAssign(newBTree); 00102 evaluateXSlacks(newBTree); // mess with "_btree" only 00103 evaluateYSlacks(newBTree); 00104 } 00105 // -------------------------------------------------------- 00106 const vector<double>& BTreeSlackEval::xSlack() const 00107 { return _xSlack; } 00108 // -------------------------------------------------------- 00109 const vector<double>& BTreeSlackEval::ySlack() const 00110 { return _ySlack; } 00111 // -------------------------------------------------------- 00112 const BTreeCompactor& BTreeSlackEval::btree() const 00113 { return _btree; } 00114 // -------------------------------------------------------- 00115 const vector<BTree::BTreeNode>& BTreeSlackEval::rev_tree() const 00116 { return _rev_tree; } 00117 // -------------------------------------------------------- 00118 const vector<BTree::BTreeNode>& BTreeSlackEval::rev_orth_tree() const 00119 { return _rev_orth_tree; } 00120 // -------------------------------------------------------- 00121 00122 #endif