Debian Codegraph @

src/gen/lib/label/split_q__c.java

raw symbols SCIP
1 /* ========================================================================
2 * PlantUML : a free UML diagram generator
3 * ========================================================================
4 *
5 * Project Info: http://plantuml.com
6 *
7 * If you like this project or if you find it useful, you can support us at:
8 *
9 * http://plantuml.com/patreon (only 1$ per month!)
10 * http://plantuml.com/paypal
11 *
12 * This file is part of Smetana.
13 * Smetana is a partial translation of Graphviz/Dot sources from C to Java.
14 *
15 * (C) Copyright 2009-2020, Arnaud Roques
16 *
17 * This translation is distributed under the same Licence as the original C program:
18 *
19 *************************************************************************
20 * Copyright (c) 2011 AT&T Intellectual Property
21 * All rights reserved. This program and the accompanying materials
22 * are made available under the terms of the Eclipse Public License v1.0
23 * which accompanies this distribution, and is available at
24 * http://www.eclipse.org/legal/epl-v10.html
25 *
26 * Contributors: See CVS logs. Details at http://www.graphviz.org/
27 *************************************************************************
28 *
29 * THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC
30 * LICENSE ("AGREEMENT"). [Eclipse Public License - v 1.0]
31 *
32 * ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES
33 * RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
34 *
35 * You may obtain a copy of the License at
36 *
37 * http://www.eclipse.org/legal/epl-v10.html
38 *
39 * Unless required by applicable law or agreed to in writing, software
40 * distributed under the License is distributed on an "AS IS" BASIS,
41 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
42 * See the License for the specific language governing permissions and
43 * limitations under the License.
44 *
45 */
46 package gen.lib.label;
47 import static gen.lib.label.node__c.AddBranch;
48 import static gen.lib.label.node__c.InitNode;
49 import static gen.lib.label.node__c.RTreeNewNode;
50 import static gen.lib.label.rectangle__c.CombineRect;
51 import static gen.lib.label.rectangle__c.NullRect;
52 import static gen.lib.label.rectangle__c.RectArea;
53 import static smetana.core.JUtilsDebug.ENTERING;
54 import static smetana.core.JUtilsDebug.LEAVING;
55 import static smetana.core.Macro.N;
56 import static smetana.core.Macro.UNSUPPORTED;
57 import h.Branch_t;
58 import h.ST_Branch_t;
59 import h.ST_Node_t___;
60 import h.ST_PartitionVars;
61 import h.ST_RTree;
62 import h.ST_Rect_t;
63
64 public class split_q__c {
65
66
67 //3 6vl3snxd6k95gamfkwfsfdguc
68 // void SplitNode(RTree_t * rtp, Node_t * n, Branch_t * b, Node_t ** nn)
69 public static void SplitNode(ST_RTree rtp, ST_Node_t___ n, ST_Branch_t b, ST_Node_t___ nn[]) {
70 ENTERING("6vl3snxd6k95gamfkwfsfdguc","SplitNode");
71 try {
72 ST_PartitionVars p;
73 int level;
74 int area;
75 // assert(n);
76 // assert(b);
77 if (rtp.StatFlag!=0) {
78 UNSUPPORTED("akhni40ndam0u9c6i7raxw4mp"); // if (rtp->Deleting)
79 UNSUPPORTED("4g80zdlbvunm838x8g3ic9tex"); // rtp->DeSplitCount++;
80 UNSUPPORTED("9352ql3e58qs4fzapgjfrms2s"); // else
81 UNSUPPORTED("2cjo6wz1rmxfm5k7u7rw5dqpj"); // rtp->InSplitCount++;
82 }
83 /* load all the branches into a buffer, initialize old node */
84 level = n.level;
85 GetBranches(rtp, n, b);
86 /* find partition */
87 p = rtp.split.Partitions[0];
88 MethodZero(rtp);
89 area = RectArea((ST_Rect_t)p.cover[0]) + RectArea((ST_Rect_t)p.cover[1]);
90 /* record how good the split was for statistics */
91 if (rtp.StatFlag!=0 && N(rtp.Deleting) && area!=0)
92 UNSUPPORTED("z7xk6s3hzi3qcoiq2exj9hpv"); // rtp->SplitMeritSum += (float) rtp->split.CoverSplitArea / area;
93 /* put branches from buffer into 2 nodes according to chosen partition */
94 nn[0] = RTreeNewNode(rtp);
95 n.setInt("level", level);
96 nn[0].setInt("level", level);
97 LoadNodes(rtp, n, nn[0], p);
98 // assert(n->count + (*nn)->count == 64 + 1);
99 } finally {
100 LEAVING("6vl3snxd6k95gamfkwfsfdguc","SplitNode");
101 }
102 }
103
104
105
106
107 //3 al7lyin008m7kvrvuxhcuvn61
108 // static void GetBranches(RTree_t * rtp, Node_t * n, Branch_t * b)
109 public static void GetBranches(ST_RTree rtp, ST_Node_t___ n, ST_Branch_t b) {
110 ENTERING("al7lyin008m7kvrvuxhcuvn61","GetBranches");
111 try {
112 int i;
113 // assert(n);
114 // assert(b);
115 /* load the branch buffer */
116 for (i = 0; i < 64; i++) {
117 // assert(n->branch[i].child); /* node should have every entry full */
118 rtp.split.BranchBuf[i].___(n.branch[i]);
119 }
120 rtp.split.BranchBuf[64].___(b);
121 /* calculate rect containing all in the set */
122 rtp.split.CoverSplit.___(rtp.split.BranchBuf[0].rect);
123 for (i = 1; i < 64 + 1; i++) {
124 rtp.split.setStruct("CoverSplit",
125 CombineRect((ST_Rect_t)rtp.split.CoverSplit,
126 (ST_Rect_t)rtp.split.BranchBuf[i].castTo(ST_Rect_t.class)));
127 }
128 rtp.split.setInt("CoverSplitArea", RectArea((ST_Rect_t)rtp.split.CoverSplit));
129 InitNode(n);
130 } finally {
131 LEAVING("al7lyin008m7kvrvuxhcuvn61","GetBranches");
132 }
133 }
134
135
136
137
138 //3 4woz5xy4gjlahoj7no3ljxmex
139 // static void MethodZero(RTree_t * rtp)
140 public static void MethodZero(ST_RTree rtp) {
141 ENTERING("4woz5xy4gjlahoj7no3ljxmex","MethodZero");
142 try {
143 ST_Rect_t r;
144 int i, growth0, growth1, diff, biggestDiff;
145 int group, chosen=0, betterGroup=0;
146 InitPVars(rtp);
147 PickSeeds(rtp);
148 while (rtp.split.Partitions[0].count[0] +
149 rtp.split.Partitions[0].count[1] < 64 + 1 &&
150 rtp.split.Partitions[0].count[0] < 64 + 1 - rtp.MinFill
151 && rtp.split.Partitions[0].count[1] <
152 64 + 1 - rtp.MinFill) {
153 biggestDiff = -1;
154 for (i = 0; i < 64 + 1; i++) {
155 if (N(rtp.split.Partitions[0].taken[i])) {
156 final ST_Rect_t rect = new ST_Rect_t();
157 r = (ST_Rect_t) rtp.split.BranchBuf[i].castTo(ST_Rect_t.class);
158 /* growth0 = RectArea(&CombineRect(r,
159 &rtp->split.Partitions[0].cover[0])) -
160 rtp->split.Partitions[0].area[0];
161 */
162 /* growth1 = RectArea(&CombineRect(r,
163 &rtp->split.Partitions[0].cover[1])) -
164 rtp->split.Partitions[0].area[1];
165 */
166 rect.___(CombineRect(r, (ST_Rect_t) rtp.split.Partitions[0].cover[0]));
167 growth0 =
168 RectArea((ST_Rect_t)rect) - rtp.split.Partitions[0].area[0];
169 rect.___(CombineRect(r, (ST_Rect_t) rtp.split.Partitions[0].cover[1]));
170 growth1 =
171 RectArea((ST_Rect_t)rect) - rtp.split.Partitions[0].area[1];
172 diff = growth1 - growth0;
173 if (diff >= 0)
174 group = 0;
175 else {
176 group = 1;
177 diff = -diff;
178 }
179 if (diff > biggestDiff) {
180 biggestDiff = diff;
181 chosen = i;
182 betterGroup = group;
183 } else if (diff == biggestDiff &&
184 rtp.split.Partitions[0].count[group] <
185 rtp.split.Partitions[0].count[betterGroup]) {
186 chosen = i;
187 betterGroup = group;
188 }
189 }
190 }
191 Classify(rtp, chosen, betterGroup);
192 }
193 /* if one group too full, put remaining rects in the other */
194 if (rtp.split.Partitions[0].count[0] +
195 rtp.split.Partitions[0].count[1] < 64 + 1) {
196 group = 0;
197 UNSUPPORTED("4edp65b21liyii0fj1ikco7o0"); // if (rtp->split.Partitions[0].count[0] >=
198 UNSUPPORTED("20lpsuiyepr2ujozaf6gp4cc"); // 64 + 1 - rtp->MinFill)
199 UNSUPPORTED("9qtt6i40h8vtjp2cvqyb8ycaz"); // group = 1;
200 UNSUPPORTED("2x1nx9nsne4x3ygmcywl1m3og"); // for (i = 0; i < 64 + 1; i++) {
201 UNSUPPORTED("jdepsnmrs3ghh78ql301sfvu"); // if (!rtp->split.Partitions[0].taken[i])
202 UNSUPPORTED("gqfhorilvtlogp6f2ozx5akf"); // Classify(rtp, i, group);
203 UNSUPPORTED("flupwh3kosf3fkhkxllllt1"); // }
204 }
205 // assert(rtp->split.Partitions[0].count[0] +
206 // rtp->split.Partitions[0].count[1] == 64 + 1);
207 // assert(rtp->split.Partitions[0].count[0] >= rtp->MinFill
208 // && rtp->split.Partitions[0].count[1] >= rtp->MinFill);
209 } finally {
210 LEAVING("4woz5xy4gjlahoj7no3ljxmex","MethodZero");
211 }
212 }
213
214
215
216
217 //3 8rui4cun4tvq5xy6ke6r3p55e
218 // static void PickSeeds(RTree_t * rtp)
219 public static void PickSeeds(ST_RTree rtp) {
220 ENTERING("8rui4cun4tvq5xy6ke6r3p55e","PickSeeds");
221 try {
222 int i, j;
223 int waste, worst;
224 int seed0=0, seed1=0;
225 int area[] = new int[64 + 1];
226 for (i = 0; i < 64 + 1; i++)
227 area[i] = RectArea((ST_Rect_t) rtp.split.BranchBuf[i].rect);
228 //worst = -rtp->split.CoverSplitArea - 1;
229 worst=0;
230 for (i = 0; i < 64; i++) {
231 for (j = i + 1; j < 64 + 1; j++) {
232 final ST_Rect_t rect = new ST_Rect_t();
233 /* waste = RectArea(&CombineRect(&rtp->split.BranchBuf[i].rect,
234 &rtp->split.BranchBuf[j].rect)) - area[i] - area[j];
235 */
236 rect.___(
237 CombineRect((ST_Rect_t)rtp.split.BranchBuf[i].rect,
238 (ST_Rect_t)rtp.split.BranchBuf[j].rect));
239 waste = RectArea((ST_Rect_t)rect) - area[i] - area[j];
240 if (waste > worst) {
241 worst = waste;
242 seed0 = i;
243 seed1 = j;
244 }
245 }
246 }
247 Classify(rtp, seed0, 0);
248 Classify(rtp, seed1, 1);
249 } finally {
250 LEAVING("8rui4cun4tvq5xy6ke6r3p55e","PickSeeds");
251 }
252 }
253
254
255
256
257 //3 4qyy2dpbkziuubssvfwb8u1sh
258 // static void Classify(RTree_t * rtp, int i, int group)
259 public static void Classify(ST_RTree rtp, int i, int group) {
260 ENTERING("4qyy2dpbkziuubssvfwb8u1sh","Classify");
261 try {
262 // assert(!rtp->split.Partitions[0].taken[i]);
263 rtp.split.Partitions[0].partition[i]=group;
264 rtp.split.Partitions[0].taken[i]=1;
265 if (rtp.split.Partitions[0].count[group] == 0)
266 rtp.split.Partitions[0].cover[group].___(
267 rtp.split.BranchBuf[i].rect);
268 else
269 rtp.split.Partitions[0].cover[group].___(
270 CombineRect((ST_Rect_t)rtp.split.BranchBuf[i].rect,
271 (ST_Rect_t)rtp.split.Partitions[0].cover[group]));
272 rtp.split.Partitions[0].area[group]=
273 RectArea((ST_Rect_t)rtp.split.Partitions[0].cover[group]);
274
275 rtp.split.Partitions[0].count[group]=
276 rtp.split.Partitions[0].count[group]+1;
277 } finally {
278 LEAVING("4qyy2dpbkziuubssvfwb8u1sh","Classify");
279 }
280 }
281
282
283
284
285 //3 ay7l4setwyl3hbx4o2jpa7vyz
286 // static void LoadNodes(RTree_t * rtp, Node_t * n, Node_t * q, struct PartitionVars *p)
287 public static void LoadNodes(ST_RTree rtp, ST_Node_t___ n, ST_Node_t___ q, ST_PartitionVars p) {
288 ENTERING("ay7l4setwyl3hbx4o2jpa7vyz","LoadNodes");
289 try {
290 int i;
291 // assert(n);
292 // assert(q);
293 // assert(p);
294 for (i = 0; i < 64 + 1; i++) {
295 // assert(rtp->split.Partitions[0].partition[i] == 0 ||
296 // rtp->split.Partitions[0].partition[i] == 1);
297 if (rtp.split.Partitions[0].partition[i] == 0)
298 AddBranch(rtp, (ST_Branch_t)rtp.split.BranchBuf[i].castTo(Branch_t.class), n, null);
299 else if (rtp.split.Partitions[0].partition[i] == 1)
300 AddBranch(rtp, (ST_Branch_t)rtp.split.BranchBuf[i].castTo(Branch_t.class), q, null);
301 }
302 } finally {
303 LEAVING("ay7l4setwyl3hbx4o2jpa7vyz","LoadNodes");
304 }
305 }
306
307
308
309
310 //3 dvgjc83sogjhzf5kxpir405rh
311 // static void InitPVars(RTree_t * rtp)
312 public static void InitPVars(ST_RTree rtp) {
313 ENTERING("dvgjc83sogjhzf5kxpir405rh","InitPVars");
314 int i;
315 rtp.split.Partitions[0].count[0]=0;
316 rtp.split.Partitions[0].count[1]=0;
317 rtp.split.Partitions[0].cover[0].___(NullRect());
318 rtp.split.Partitions[0].cover[1].___(NullRect());
319 rtp.split.Partitions[0].area[0]=0;
320 rtp.split.Partitions[0].area[1]=0;
321 for (i = 0; i < 64 + 1; i++) {
322 rtp.split.Partitions[0].taken[i]=0;
323 rtp.split.Partitions[0].partition[i]=-1;
324 }
325 try {
326 } finally {
327 LEAVING("dvgjc83sogjhzf5kxpir405rh","InitPVars");
328 }
329 }
330
331
332 }