56 {
57
58 int c, c2, c3, x, y;
59 float totalArea = 0;
60 int moveableCells = 0;
61 float yBinArea = 0, yCumArea = 0;
62 int yBinStart = 0, yBinCount = 0;
63 int xBinCount, xBinStart;
64 float xBinArea, xCumArea;
65 float lastOldEdge;
66 float lastNewEdge;
67 float curOldEdge, curNewEdge;
68 float stretch, w;
72
75
79 allCells[moveableCells++] = cell;
81 }
82 }
83
84
86
87 y = 0;
88
89
90 for(c=0; c<moveableCells; c++) {
91 yCell = allCells[c];
94 yBinCount++;
95
96
97 if (yCumArea >= totalArea*(y+1)/numBins && yBinArea > 0) {
100
101#if defined(DEBUG)
102 printf("y-bin %d count=%d area=%f\n",y,yBinCount, yBinArea);
103#endif
104
105 x = 0;
106 xBinCount = 0, xBinStart = 0;
107 xBinArea = 0, xCumArea = 0;
110
111
112 for(c2=0; c2<yBinCount; c2++) {
113 xCell = binCells[c2];
116 xBinCount++;
117 curOldEdge = xCell->
m_x;
118
119 printf(
"%.3f ", xCell->
m_x);
120
121
122 if (xCumArea >= yBinArea*(x+1)/numBins && xBinArea > 0) {
124
127 if ((curNewEdge-curOldEdge)>maxMovement) curNewEdge = curOldEdge + maxMovement;
128 if ((curOldEdge-curNewEdge)>maxMovement) curNewEdge = curOldEdge - maxMovement;
129
130#if defined(DEBUG)
131 printf("->\tx-bin %d count=%d area=%f (%f,%f)->(%f,%f)\n",x, xBinCount, xBinArea,
132 curOldEdge, lastOldEdge, curNewEdge, lastNewEdge);
133#endif
134
135 stretch = (curNewEdge-lastNewEdge)/(curOldEdge-lastOldEdge);
136
137
138 for(c3=xBinStart; c3<xBinStart+xBinCount; c3++) {
139 if (curOldEdge == lastOldEdge)
140 binCells[c3]->
m_x = lastNewEdge+(c3-xBinStart)*(curNewEdge-lastNewEdge);
141 else
142 binCells[c3]->
m_x = lastNewEdge+(binCells[c3]->
m_x-lastOldEdge)*stretch;
143
144
150 }
151
152 lastOldEdge = curOldEdge;
153 lastNewEdge = curNewEdge;
154 x++;
155 xBinCount = 0;
156 xBinArea = 0;
157 xBinStart = c2+1;
158 }
159 }
160
161 y++;
162 yBinCount = 0;
163 yBinArea = 0;
164 yBinStart = c+1;
165 }
166 }
167
170}
ConcreteCell ** g_place_concreteCells
float getCellArea(const ConcreteCell *cell)
int cellSortByY(const void *a, const void *b)
ABC_NAMESPACE_IMPL_START int g_place_numCells
int cellSortByX(const void *a, const void *b)
Sorts cells by either position coordinate.