Debian Codegraph @

src/gen/lib/pathplan/shortest__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.pathplan;
47 import static smetana.core.JUtils.EQ;
48 import static smetana.core.JUtils.LOG2;
49 import static smetana.core.JUtils.NEQ;
50 import static smetana.core.JUtils.setjmp;
51 import static smetana.core.JUtilsDebug.ENTERING;
52 import static smetana.core.JUtilsDebug.LEAVING;
53 import static smetana.core.Macro.HUGE_VAL;
54 import static smetana.core.Macro.N;
55 import static smetana.core.Macro.UNSUPPORTED;
56 import h.ST_Ppoly_t;
57 import h.ST_pointf;
58 import h.ST_pointnlink_t;
59 import h.ST_triangle_t;
60 import smetana.core.Z;
61 import smetana.core.__ptr__;
62 import smetana.core.jmp_buf;
63
64 public class shortest__c {
65 //1 baedz5i9est5csw3epz3cv7z
66 // typedef Ppoly_t Ppolyline_t
67
68
69 //1 7pb9zum2n4wlgil34lvh8i0ts
70 // typedef double COORD
71
72
73 //1 540u5gu9i0x1wzoxqqx5n2vwp
74 // static jmp_buf jbuf
75 private static jmp_buf jbuf = new jmp_buf();
76
77 //1 3gj35j1owzho1bj8qrr8j520a
78 // static pointnlink_t *pnls, **pnlps
79 //private static pointnlink_t pnls;
80 //private static __ptr__ pnlps;
81
82 //1 6r0oj01m6zabkua5f5x778wq6
83 // static int pnln, pnll
84 //private static int pnln, pnll;
85
86 //1 aywrlzd2nea9kkv8kzuctk7pt
87 // static triangle_t *tris
88 //private static __ptr__ tris;
89
90 //1 a6aizijrgkmhf8hoyeqj49b60
91 // static int trin, tril
92 //private static int trin, tril;
93
94 //1 cc2hmcygbtg3adbwgkunssdhx
95 // static deque_t dq
96 //private final static __struct__<deque_t> dq = JUtils.from(deque_t.class);
97
98 //1 3k2f2er3efsrl0210su710vf
99 // static Ppoint_t *ops
100 //static private __ptr__ ops;
101
102 //1 68lm8qk1d212p1ngzu26gudjc
103 // static int opn
104 //private static int opn;
105
106
107
108 //3 2gub5b19vo2qexn56nw23wage
109 // int Pshortestpath(Ppoly_t * polyp, Ppoint_t * eps, Ppolyline_t * output)
110 public static int Pshortestpath(ST_Ppoly_t polyp, ST_pointf.Array eps, ST_Ppoly_t output) {
111 ENTERING("2gub5b19vo2qexn56nw23wage","Pshortestpath");
112 try {
113 int pi, minpi;
114 double minx;
115 final ST_pointf p1 = new ST_pointf(), p2 = new ST_pointf(), p3 = new ST_pointf();
116 int trii, trij, ftrii, ltrii;
117 int ei;
118 final ST_pointnlink_t[] epnls = new ST_pointnlink_t[] {new ST_pointnlink_t(),new ST_pointnlink_t()};
119 ST_pointnlink_t lpnlp=null, rpnlp=null, pnlp=null;
120 ST_triangle_t.Array trip;
121 int splitindex;
122 if (setjmp(jbuf)!=0)
123 return -2;
124 /* make space */
125 growpnls(polyp.pn);
126 Z.z().pnll = 0;
127 Z.z().tril = 0;
128 growdq(polyp.pn * 2);
129 Z.z().dq.fpnlpi = Z.z().dq.pnlpn / 2;
130 Z.z().dq.lpnlpi = Z.z().dq.fpnlpi - 1;
131 /* make sure polygon is CCW and load pnls array */
132 for (pi = 0, minx = HUGE_VAL, minpi = -1; pi < polyp.pn; pi++) {
133 if (minx > polyp.ps.get(pi).x)
134 { minx = polyp.ps.get(pi).x;
135 minpi = pi; }
136 }
137 p2.____(polyp.ps.plus(minpi));
138 p1.____(polyp.ps.plus(((minpi == 0) ? polyp.pn - 1 : minpi - 1)));
139 p3.____(polyp.ps.plus(((minpi == polyp.pn - 1) ? 0 : minpi + 1)));
140 if (((p1.x == p2.x && p2.x == p3.x) && (p3.y > p2.y)) ||
141 ccw(p1, p2, p3) != 1) {
142 for (pi = polyp.pn - 1; pi >= 0; pi--) {
143 if (pi < polyp.pn - 1
144 && polyp.ps.get(pi).x == polyp.ps.get(pi+1).x
145 && polyp.ps.get(pi).y == polyp.ps.get(pi+1).y)
146 continue;
147 Z.z().pnls[Z.z().pnll].pp = (ST_pointf) ((ST_pointf)polyp.ps.get(pi));
148 Z.z().pnls[Z.z().pnll].link = Z.z().pnls[Z.z().pnll % polyp.pn];
149 Z.z().pnlps[Z.z().pnll] = Z.z().pnls[Z.z().pnll];
150 Z.z().pnll++;
151 }
152 } else {
153 for (pi = 0; pi < polyp.pn; pi++) {
154 if (pi > 0 && polyp.ps.get(pi).x == polyp.ps.get(pi - 1).x &&
155 polyp.ps.get(pi).y == polyp.ps.get(pi - 1).y)
156 continue;
157 Z.z().pnls[Z.z().pnll].pp = (ST_pointf) ((ST_pointf)polyp.ps.get(pi));
158 Z.z().pnls[Z.z().pnll].link = Z.z().pnls[Z.z().pnll % polyp.pn];
159 Z.z().pnlps[Z.z().pnll] = Z.z().pnls[Z.z().pnll];
160 Z.z().pnll++;
161 }
162 }
163 /* generate list of triangles */
164 triangulate(Z.z().pnlps, Z.z().pnll);
165 /* connect all pairs of triangles that share an edge */
166 for (trii = 0; trii < Z.z().tril; trii++)
167 for (trij = trii + 1; trij < Z.z().tril; trij++)
168 connecttris(trii, trij);
169 /* find first and last triangles */
170 for (trii = 0; trii < Z.z().tril; trii++)
171 if (pointintri(trii, eps.plus(0).getStruct()))
172 break;
173 if (trii == Z.z().tril) {
174 UNSUPPORTED("4ma3y8l4lmjcsw49kmsgknig6"); // fprintf (stderr, "libpath/%s:%d: %s\n", "graphviz-2.38.0\\lib\\pathplan\\shortest.c", 26, ("source point not in any triangle"));
175 UNSUPPORTED("8d9xfgejx5vgd6shva5wk5k06"); // return -1;
176 }
177 ftrii = trii;
178 for (trii = 0; trii < Z.z().tril; trii++)
179 if (pointintri(trii, eps.plus(1).getStruct()))
180 break;
181 if (trii == Z.z().tril) {
182 System.err.println("libpath/%s:%d: %s\n" + "graphviz-2.38.0\\lib\\pathplan\\shortest.c" + 26 + ("destination point not in any triangle"));
183 return -1;
184 }
185 ltrii = trii;
186 /* mark the strip of triangles from eps[0] to eps[1] */
187 if (N(marktripath(ftrii, ltrii))) {
188 System.err.println("libpath/%s:%d: %s" + "graphviz-2.38.0\\lib\\pathplan\\shortest.c" + 26 + ("cannot find triangle path"));
189 /* a straight line is better than failing */
190 growops(2);
191 output.pn = 2;
192 Z.z().ops_shortest.plus(0).setStruct(eps.plus(0).getStruct());
193 Z.z().ops_shortest.plus(1).setStruct(eps.plus(1).getStruct());
194 output.setPtr("ps", Z.z().ops_shortest);
195 return 0;
196 }
197 /* if endpoints in same triangle, use a single line */
198 if (ftrii == ltrii) {
199 UNSUPPORTED("2nnkwrdxg0ma2m482dqarlbz6"); // growops(2);
200 UNSUPPORTED("5penbn9ky80i7jw02belk2zoj"); // output->pn = 2;
201 UNSUPPORTED("8i925e1tnbqn909027lqcg3fi"); // ops[0] = eps[0], ops[1] = eps[1];
202 UNSUPPORTED("3rcg6c9s9nmostq9c3r5n6x4h"); // output->ps = ops;
203 UNSUPPORTED("c9ckhc8veujmwcw0ar3u3zld4"); // return 0;
204 }
205 /* build funnel and shortest path linked list (in add2dq) */
206 epnls[0].pp = eps.get(0);
207 epnls[0].link = null;
208 epnls[1].pp = eps.get(1);
209 epnls[1].link = null;
210 add2dq(1, epnls[0]);
211 Z.z().dq.apex = Z.z().dq.fpnlpi;
212 trii = ftrii;
213 while (trii != -1) {
214 trip = Z.z().tris.plusJ(trii);
215 trip.get(0).mark = 2;
216 /* find the left and right points of the exiting edge */
217 for (ei = 0; ei < 3; ei++)
218 if (trip.get(0).e[ei].rtp!=null &&
219 trip.get(0).e[ei].rtp.get(0).mark == 1)
220 break;
221 if (ei == 3) { /* in last triangle */
222 if (ccw(eps.get(1), Z.z().dq.pnlps[Z.z().dq.fpnlpi].pp,
223 Z.z().dq.pnlps[Z.z().dq.lpnlpi].pp) == 1)
224 {
225 lpnlp = Z.z().dq.pnlps[Z.z().dq.lpnlpi];
226 rpnlp = epnls[1];
227 } else {
228 lpnlp = epnls[1];
229 rpnlp = Z.z().dq.pnlps[Z.z().dq.lpnlpi];
230 }
231 } else {
232 pnlp = trip.get(0).e[(ei + 1) % 3].pnl1p;
233 if (ccw(trip.get(0).e[ei].pnl0p.pp, pnlp.pp,
234 trip.get(0).e[ei].pnl1p.pp) == 1)
235 UNSUPPORTED("2cii65lhw4wb8nyvjv702v7md"); // lpnlp = trip->e[ei].pnl1p, rpnlp = trip->e[ei].pnl0p;
236 else
237 {
238 lpnlp = trip.get(0).e[ei].pnl0p;
239 rpnlp = trip.get(0).e[ei].pnl1p;
240 }
241 }
242 /* update deque */
243 if (trii == ftrii) {
244 add2dq(2, lpnlp);
245 add2dq(1, rpnlp);
246 } else {
247 if (NEQ(Z.z().dq.pnlps[Z.z().dq.fpnlpi], rpnlp)
248 && NEQ(Z.z().dq.pnlps[Z.z().dq.lpnlpi], rpnlp)) {
249 /* add right point to deque */
250 splitindex = finddqsplit(rpnlp);
251 splitdq(2, splitindex);
252 add2dq(1, rpnlp);
253 /* if the split is behind the apex, then reset apex */
254 if (splitindex > Z.z().dq.apex)
255 Z.z().dq.apex = splitindex;
256 } else {
257 /* add left point to deque */
258 splitindex = finddqsplit(lpnlp);
259 splitdq(1, splitindex);
260 add2dq(2, lpnlp);
261 /* if the split is in front of the apex, then reset apex */
262 if (splitindex < Z.z().dq.apex)
263 Z.z().dq.apex = splitindex;
264 }
265 }
266 trii = -1;
267 for (ei = 0; ei < 3; ei++)
268 if (trip.get(0).e[ei].rtp!=null &&
269 trip.get(0).e[ei].rtp.get(0).mark == 1) {
270 trii = trip.get(0).e[ei].rtp.minus(Z.z().tris);
271 break;
272 }
273 }
274 for (pi = 0, pnlp = epnls[1]; pnlp!=null; pnlp = pnlp.link)
275 pi++;
276 growops(pi);
277 output.pn = pi;
278 for (pi = pi - 1, pnlp = epnls[1]; pnlp!=null; pi--, pnlp = pnlp.link)
279 Z.z().ops_shortest.get(pi).____(pnlp.pp);
280 output.ps = Z.z().ops_shortest;
281 return 0;
282 } finally {
283 LEAVING("2gub5b19vo2qexn56nw23wage","Pshortestpath");
284 }
285 }
286
287
288
289
290 //3 73cr7m3mqvtuotpzrmaw2y8zm
291 // static void triangulate(pointnlink_t ** pnlps, int pnln)
292 public static void triangulate(ST_pointnlink_t pnlps[], int pnln) {
293 ENTERING("73cr7m3mqvtuotpzrmaw2y8zm","triangulate");
294 try {
295 int pnli, pnlip1, pnlip2;
296 LOG2("triangulate "+pnln);
297 if (pnln > 3)
298 {
299 for (pnli = 0; pnli < pnln; pnli++)
300 {
301 pnlip1 = (pnli + 1) % pnln;
302 pnlip2 = (pnli + 2) % pnln;
303 if (isdiagonal(pnli, pnlip2, pnlps, pnln))
304 {
305 loadtriangle(pnlps[pnli], pnlps[pnlip1], pnlps[pnlip2]);
306 for (pnli = pnlip1; pnli < pnln - 1; pnli++)
307 pnlps[pnli] = pnlps[pnli + 1];
308 triangulate(pnlps, pnln - 1);
309 return;
310 }
311 }
312 throw new IllegalStateException("libpath/%s:%d: %s\n" + "graphviz-2.38.0\\lib\\pathplan\\shortest.c" + 26 + ("triangulation failed"));
313 }
314 else
315 loadtriangle(pnlps[0], pnlps[1], pnlps[2]);
316 } finally {
317 LEAVING("73cr7m3mqvtuotpzrmaw2y8zm","triangulate");
318 }
319 }
320
321
322
323
324 //3 72of3cd7shtwokglxapw04oe9
325 // static int isdiagonal(int pnli, int pnlip2, pointnlink_t ** pnlps, int pnln)
326 public static boolean isdiagonal(int pnli, int pnlip2, ST_pointnlink_t[] pnlps, int pnln) {
327 ENTERING("72of3cd7shtwokglxapw04oe9","isdiagonal");
328 try {
329 int pnlip1, pnlim1, pnlj, pnljp1;
330 boolean res;
331 /* neighborhood test */
332 pnlip1 = (pnli + 1) % pnln;
333 pnlim1 = (pnli + pnln - 1) % pnln;
334 /* If P[pnli] is a convex vertex [ pnli+1 left of (pnli-1,pnli) ]. */
335 if (ccw(pnlps[pnlim1].pp, pnlps[pnli].pp, pnlps[pnlip1].pp) ==
336 1)
337 res =
338 (ccw(pnlps[pnli].pp, pnlps[pnlip2].pp, pnlps[pnlim1].pp) ==
339 1)
340 && (ccw(pnlps[pnlip2].pp, pnlps[pnli].pp, pnlps[pnlip1].pp)
341 == 1);
342 /* Assume (pnli - 1, pnli, pnli + 1) not collinear. */
343 else
344 res = (ccw(pnlps[pnli].pp, pnlps[pnlip2].pp,
345 pnlps[pnlip1].pp) == 2);
346 if (N(res))
347 return false;
348 /* check against all other edges */
349 for (pnlj = 0; pnlj < pnln; pnlj++) {
350 pnljp1 = (pnlj + 1) % pnln;
351 if (N((pnlj == pnli) || (pnljp1 == pnli) ||
352 (pnlj == pnlip2) || (pnljp1 == pnlip2)))
353 if (intersects(pnlps[pnli].pp, pnlps[pnlip2].pp,
354 pnlps[pnlj].pp, pnlps[pnljp1].pp))
355 return false;
356 }
357 return ((N(false)));
358 } finally {
359 LEAVING("72of3cd7shtwokglxapw04oe9","isdiagonal");
360 }
361 }
362
363
364
365
366 //3 7vf9jtj9i8rg0cxrstbqswuck
367 // static void loadtriangle(pointnlink_t * pnlap, pointnlink_t * pnlbp, pointnlink_t * pnlcp)
368 public static void loadtriangle(__ptr__ pnlap, __ptr__ pnlbp, __ptr__ pnlcp) {
369 ENTERING("7vf9jtj9i8rg0cxrstbqswuck","loadtriangle");
370 try {
371 ST_triangle_t.Array trip;
372 int ei;
373 /* make space */
374 if (Z.z().tril >= Z.z().trin)
375 growtris(Z.z().trin + 20);
376 trip = Z.z().tris.plusJ(Z.z().tril++);
377 trip.get(0).mark = 0;
378 trip.get(0).e[0].pnl0p = (ST_pointnlink_t) pnlap;
379 trip.get(0).e[0].pnl1p = (ST_pointnlink_t) pnlbp;
380 trip.get(0).e[0].rtp = null;
381 trip.get(0).e[1].pnl0p = (ST_pointnlink_t) pnlbp;
382 trip.get(0).e[1].pnl1p = (ST_pointnlink_t) pnlcp;
383 trip.get(0).e[1].rtp = null;
384 trip.get(0).e[2].pnl0p = (ST_pointnlink_t) pnlcp;
385 trip.get(0).e[2].pnl1p = (ST_pointnlink_t) pnlap;
386 trip.get(0).e[2].rtp = null;
387 for (ei = 0; ei < 3; ei++)
388 trip.get(0).e[ei].lrp = trip;
389 } finally {
390 LEAVING("7vf9jtj9i8rg0cxrstbqswuck","loadtriangle");
391 }
392 }
393
394
395
396
397 //3 6coujw0qksrgu5sxj0r39qm1u
398 // static void connecttris(int tri1, int tri2)
399 public static void connecttris(int tri1, int tri2) {
400 ENTERING("6coujw0qksrgu5sxj0r39qm1u","connecttris");
401 try {
402 ST_triangle_t.Array tri1p;
403 ST_triangle_t.Array tri2p;
404 int ei, ej;
405 for (ei = 0; ei < 3; ei++) {
406 for (ej = 0; ej < 3; ej++) {
407 tri1p = Z.z().tris.plusJ(tri1);
408 tri2p = Z.z().tris.plusJ(tri2);
409 if ((EQ(tri1p.get(0).e[ei].pnl0p.pp,
410 tri2p.get(0).e[ej].pnl0p.pp) &&
411 EQ(tri1p.get(0).e[ei].pnl1p.pp,
412 tri2p.get(0).e[ej].pnl1p.pp)) ||
413 (EQ(tri1p.get(0).e[ei].pnl0p.pp,
414 tri2p.get(0).e[ej].pnl1p.pp) &&
415 EQ(tri1p.get(0).e[ei].pnl1p.pp,
416 tri2p.get(0).e[ej].pnl0p.pp)))
417 {
418 tri1p.get(0).e[ei].rtp = tri2p;
419 tri2p.get(0).e[ej].rtp = tri1p;
420 }
421 }
422 }
423 } finally {
424 LEAVING("6coujw0qksrgu5sxj0r39qm1u","connecttris");
425 }
426 }
427
428
429
430
431 //3 3waxf5wy3mwt12wpg5hxg3o9c
432 // static int marktripath(int trii, int trij)
433 public static boolean marktripath(int trii, int trij) {
434 ENTERING("3waxf5wy3mwt12wpg5hxg3o9c","marktripath");
435 try {
436 int ei;
437 if (Z.z().tris.plusJ(trii).get(0).mark!=0)
438 return false;
439 Z.z().tris.plusJ(trii).get(0).mark = 1;
440 if (trii == trij)
441 return ((!(false)));
442 for (ei = 0; ei < 3; ei++)
443 if ((Z.z().tris.plusJ(trii).get(0).e[ei].rtp!=null &&
444 marktripath(Z.z().tris.plusJ(trii).get(0).e[ei].rtp.minus(Z.z().tris), trij)))
445 return ((!(false)));
446 Z.z().tris.plusJ(trii).get(0).mark = 0;
447 return false;
448 } finally {
449 LEAVING("3waxf5wy3mwt12wpg5hxg3o9c","marktripath");
450 }
451 }
452
453
454
455
456 //3 44szdl31mg8mt5qrfj70kb2sn
457 // static void add2dq(int side, pointnlink_t * pnlp)
458 public static void add2dq(int side, ST_pointnlink_t pnlp) {
459 ENTERING("44szdl31mg8mt5qrfj70kb2sn","add2dq");
460 try {
461 if (side == 1) {
462 if (Z.z().dq.lpnlpi - Z.z().dq.fpnlpi >= 0)
463 pnlp.link = Z.z().dq.pnlps[Z.z().dq.fpnlpi];
464 /* shortest path links */
465 Z.z().dq.fpnlpi = Z.z().dq.fpnlpi-1;
466 Z.z().dq.pnlps[Z.z().dq.fpnlpi] = pnlp;
467 } else {
468 if (Z.z().dq.lpnlpi - Z.z().dq.fpnlpi >= 0)
469 pnlp.link = Z.z().dq.pnlps[Z.z().dq.lpnlpi];
470 /* shortest path links */
471 Z.z().dq.lpnlpi = Z.z().dq.lpnlpi+1;
472 Z.z().dq.pnlps[Z.z().dq.lpnlpi] = pnlp;
473 }
474 } finally {
475 LEAVING("44szdl31mg8mt5qrfj70kb2sn","add2dq");
476 }
477 }
478
479
480
481
482 //3 572sssdz1se16w790xceiy5vr
483 // static void splitdq(int side, int index)
484 public static void splitdq(int side, int index) {
485 ENTERING("572sssdz1se16w790xceiy5vr","splitdq");
486 try {
487 if (side == 1)
488 Z.z().dq.lpnlpi = index;
489 else
490 Z.z().dq.fpnlpi = index;
491 } finally {
492 LEAVING("572sssdz1se16w790xceiy5vr","splitdq");
493 }
494 }
495
496
497
498
499 //3 9dnrc8vqpffp5t3bmsackgqtl
500 // static int finddqsplit(pointnlink_t * pnlp)
501 public static int finddqsplit(ST_pointnlink_t pnlp) {
502 ENTERING("9dnrc8vqpffp5t3bmsackgqtl","finddqsplit");
503 try {
504 int index;
505 for (index = Z.z().dq.fpnlpi; index < Z.z().dq.apex; index++)
506 if (ccw(Z.z().dq.pnlps[index + 1].pp, Z.z().dq.pnlps[index].pp, pnlp.pp) ==
507 1)
508 return index;
509 for (index = Z.z().dq.lpnlpi; index > Z.z().dq.apex; index--)
510 if (ccw(Z.z().dq.pnlps[index - 1].pp, Z.z().dq.pnlps[index].pp, pnlp.pp) ==
511 2)
512 return index;
513 return Z.z().dq.apex;
514 } finally {
515 LEAVING("9dnrc8vqpffp5t3bmsackgqtl","finddqsplit");
516 }
517 }
518
519
520
521
522 //3 72h03s8inxtto2ekvmuqjtj3d
523 // static int ccw(Ppoint_t * p1p, Ppoint_t * p2p, Ppoint_t * p3p)
524 public static int ccw(ST_pointf p1p, ST_pointf p2p, ST_pointf p3p) {
525 ENTERING("72h03s8inxtto2ekvmuqjtj3d","ccw");
526 try {
527 double d;
528 d = ((p1p.y - p2p.y) * (p3p.x - p2p.x)) -
529 ((p3p.y - p2p.y) * (p1p.x - p2p.x));
530 return (d > 0) ? 1 : ((d < 0) ? 2 : 3);
531 } finally {
532 LEAVING("72h03s8inxtto2ekvmuqjtj3d","ccw");
533 }
534 }
535
536
537
538
539 //3 22a9ajg9t8ovqsigk3tyu3rkd
540 // static int intersects(Ppoint_t * pap, Ppoint_t * pbp, Ppoint_t * pcp, Ppoint_t * pdp)
541 public static boolean intersects(ST_pointf pap, ST_pointf pbp, ST_pointf pcp, ST_pointf pdp) {
542 ENTERING("22a9ajg9t8ovqsigk3tyu3rkd","intersects");
543 try {
544 int ccw1, ccw2, ccw3, ccw4;
545 if (ccw(pap, pbp, pcp) == 3 || ccw(pap, pbp, pdp) == 3 ||
546 ccw(pcp, pdp, pap) == 3 || ccw(pcp, pdp, pbp) == 3) {
547 if (between(pap, pbp, pcp) || between(pap, pbp, pdp) ||
548 between(pcp, pdp, pap) || between(pcp, pdp, pbp))
549 return ((!(false)));
550 } else {
551 ccw1 = (ccw(pap, pbp, pcp) == 1) ? 1 : 0;
552 ccw2 = (ccw(pap, pbp, pdp) == 1) ? 1 : 0;
553 ccw3 = (ccw(pcp, pdp, pap) == 1) ? 1 : 0;
554 ccw4 = (ccw(pcp, pdp, pbp) == 1) ? 1 : 0;
555 return (ccw1 ^ ccw2)!=0 && (ccw3 ^ ccw4)!=0;
556 }
557 return false;
558 } finally {
559 LEAVING("22a9ajg9t8ovqsigk3tyu3rkd","intersects");
560 }
561 }
562
563
564
565
566 //3 uh5n18rzyevtb4cwpni70qpc
567 // static int between(Ppoint_t * pap, Ppoint_t * pbp, Ppoint_t * pcp)
568 public static boolean between(ST_pointf pap, ST_pointf pbp, ST_pointf pcp) {
569 ENTERING("uh5n18rzyevtb4cwpni70qpc","between");
570 try {
571 final ST_pointf p1 = new ST_pointf(), p2 = new ST_pointf();
572 p1.setDouble("x", pbp.x - pap.x);
573 p1.setDouble("y", pbp.y - pap.y);
574 p2.setDouble("x", pcp.x - pap.x);
575 p2.setDouble("y", pcp.y - pap.y);
576 if (ccw(pap, pbp, pcp) != 3)
577 return false;
578 return (p2.x * p1.x + p2.y * p1.y >= 0) &&
579 (p2.x * p2.x + p2.y * p2.y <= p1.x * p1.x + p1.y * p1.y);
580 } finally {
581 LEAVING("uh5n18rzyevtb4cwpni70qpc","between");
582 }
583 }
584
585
586
587
588 //3 zti1mzm2m7tr2xwnbf7e8u3d
589 // static int pointintri(int trii, Ppoint_t * pp)
590 public static boolean pointintri(int trii, ST_pointf pp) {
591 ENTERING("zti1mzm2m7tr2xwnbf7e8u3d","pointintri");
592 try {
593 int ei, sum;
594 for (ei = 0, sum = 0; ei < 3; ei++)
595 if (ccw(Z.z().tris.plusJ(trii).get(0).e[ei].pnl0p.pp,
596 Z.z().tris.plusJ(trii).get(0).e[ei].pnl1p.pp, pp) != 2)
597 sum++;
598 return (sum == 3 || sum == 0);
599 } finally {
600 LEAVING("zti1mzm2m7tr2xwnbf7e8u3d","pointintri");
601 }
602 }
603
604
605
606
607 //3 85wstb60jkjd0kbh9tyninm4h
608 // static void growpnls(int newpnln)
609 public static void growpnls(int newpnln) {
610 ENTERING("85wstb60jkjd0kbh9tyninm4h","growpnls");
611 try {
612 if (newpnln <= Z.z().pnln)
613 return;
614 if (N(Z.z().pnls)) {
615 if (N(Z.z().pnls = malloc(newpnln))) {
616 UNSUPPORTED("9zyfc4bjg3i6rrna9vqf8doys"); // fprintf (stderr, "libpath/%s:%d: %s\n", "graphviz-2.38.0\\lib\\pathplan\\shortest.c", 26, ("cannot malloc pnls"));
617 UNSUPPORTED("1r6uhbnmxv8c6msnscw07w0qx"); // longjmp(jbuf,1);
618 }
619 if (N(Z.z().pnlps = malloc(newpnln))) {
620 UNSUPPORTED("1etar0wd2cbbvqo4jnmbvjiz4"); // fprintf (stderr, "libpath/%s:%d: %s\n", "graphviz-2.38.0\\lib\\pathplan\\shortest.c", 26, ("cannot malloc pnlps"));
621 UNSUPPORTED("1r6uhbnmxv8c6msnscw07w0qx"); // longjmp(jbuf,1);
622 }
623 } else {
624 if (N(Z.z().pnls = realloc(Z.z().pnls, newpnln))) {
625 UNSUPPORTED("105nogpkt0qqut0yu4alvkk1u"); // fprintf (stderr, "libpath/%s:%d: %s\n", "graphviz-2.38.0\\lib\\pathplan\\shortest.c", 26, ("cannot realloc pnls"));
626 UNSUPPORTED("1r6uhbnmxv8c6msnscw07w0qx"); // longjmp(jbuf,1);
627 }
628 if (N(Z.z().pnlps = realloc(Z.z().pnlps, newpnln))) {
629 UNSUPPORTED("be84alh84ub40x4um989aj20d"); // fprintf (stderr, "libpath/%s:%d: %s\n", "graphviz-2.38.0\\lib\\pathplan\\shortest.c", 26, ("cannot realloc pnlps"));
630 UNSUPPORTED("1r6uhbnmxv8c6msnscw07w0qx"); // longjmp(jbuf,1);
631 }
632 }
633 Z.z().pnln = newpnln;
634 } finally {
635 LEAVING("85wstb60jkjd0kbh9tyninm4h","growpnls");
636 }
637 }
638
639 private static ST_pointnlink_t[] malloc(int nb) {
640 ST_pointnlink_t result[] = new ST_pointnlink_t[nb];
641 for (int i = 0; i < result.length; i++) {
642 result[i] = new ST_pointnlink_t();
643 }
644 return result;
645 }
646 private static ST_pointnlink_t[] realloc(ST_pointnlink_t orig[], int nb) {
647 if (orig.length >= nb) {
648 return orig;
649 }
650 ST_pointnlink_t result[] = malloc(nb);
651 for (int i = 0; i < orig.length; i++) {
652 result[i] = orig[i];
653 }
654 return result;
655 }
656
657
658
659 //3 c5q8ult6w26jppe5ifzgcoq82
660 // static void growtris(int newtrin)
661 public static void growtris(int newtrin) {
662 ENTERING("c5q8ult6w26jppe5ifzgcoq82","growtris");
663 try {
664 if (newtrin <= Z.z().trin)
665 return;
666 if (N(Z.z().tris)) {
667 if (N(Z.z().tris = new ST_triangle_t.Array(newtrin))) {
668 UNSUPPORTED("5782e28cjpaa3dpf8up4zmtq7"); // fprintf (stderr, "libpath/%s:%d: %s\n", "graphviz-2.38.0\\lib\\pathplan\\shortest.c", 26, ("cannot malloc tris"));
669 UNSUPPORTED("1r6uhbnmxv8c6msnscw07w0qx"); // longjmp(jbuf,1);
670 }
671 } else {
672 if (N(Z.z().tris = Z.z().tris.reallocJ(newtrin))) {
673 UNSUPPORTED("d3fgu54pn5tydfhn7z73v73ra"); // fprintf (stderr, "libpath/%s:%d: %s\n", "graphviz-2.38.0\\lib\\pathplan\\shortest.c", 26, ("cannot realloc tris"));
674 UNSUPPORTED("1r6uhbnmxv8c6msnscw07w0qx"); // longjmp(jbuf,1);
675 }
676 }
677 Z.z().trin = newtrin;
678 } finally {
679 LEAVING("c5q8ult6w26jppe5ifzgcoq82","growtris");
680 }
681 }
682
683
684 private static ST_triangle_t[] malloc2(int nb) {
685 ST_triangle_t result[] = new ST_triangle_t[nb];
686 for (int i = 0; i < result.length; i++) {
687 result[i] = new ST_triangle_t();
688 }
689 return result;
690 }
691 private static ST_triangle_t[] realloc2(ST_triangle_t orig[], int nb) {
692 if (orig.length >= nb) {
693 return orig;
694 }
695 ST_triangle_t result[] = malloc2(nb);
696 for (int i = 0; i < orig.length; i++) {
697 result[i] = orig[i];
698 }
699 return result;
700 }
701
702
703
704 //3 bzym9u6dtatii1vp4hcmofc80
705 // static void growdq(int newdqn)
706 public static void growdq(int newdqn) {
707 ENTERING("bzym9u6dtatii1vp4hcmofc80","growdq");
708 try {
709 if (newdqn <= Z.z().dq.pnlpn)
710 return;
711 if (N(Z.z().dq.pnlps)) {
712 if (N
713 (Z.z().dq.malloc(newdqn))) {
714 UNSUPPORTED("88fwpb40wz9jc8jiz7u032s4t"); // fprintf (stderr, "libpath/%s:%d: %s\n", "graphviz-2.38.0\\lib\\pathplan\\shortest.c", 26, ("cannot malloc dq.pnls"));
715 UNSUPPORTED("1r6uhbnmxv8c6msnscw07w0qx"); // longjmp(jbuf,1);
716 }
717 } else {
718 if (N(Z.z().dq.realloc(newdqn))) {
719 UNSUPPORTED("exqx4ck7h15m8whgip6xpnhoo"); // fprintf (stderr, "libpath/%s:%d: %s\n", "graphviz-2.38.0\\lib\\pathplan\\shortest.c", 26, ("cannot realloc dq.pnls"));
720 UNSUPPORTED("1r6uhbnmxv8c6msnscw07w0qx"); // longjmp(jbuf,1);
721 }
722 }
723 Z.z().dq.pnlpn = newdqn;
724 } finally {
725 LEAVING("bzym9u6dtatii1vp4hcmofc80","growdq");
726 }
727 }
728
729
730
731
732 //3 d7vtt8xqxbdnx9kwtt1zzof75
733 // static void growops(int newopn)
734 public static void growops(int newopn) {
735 ENTERING("d7vtt8xqxbdnx9kwtt1zzof75","growops");
736 try {
737 if (newopn <= Z.z().opn_shortest)
738 return;
739 if (N(Z.z().ops_shortest)) {
740 if (N(Z.z().ops_shortest = new ST_pointf.Array(newopn))) {
741 UNSUPPORTED("7wxgcgah7iy6vetj5yszoq4k4"); // fprintf (stderr, "libpath/%s:%d: %s\n", "graphviz-2.38.0\\lib\\pathplan\\shortest.c", 26, ("cannot malloc ops"));
742 UNSUPPORTED("1r6uhbnmxv8c6msnscw07w0qx"); // longjmp(jbuf,1);
743 }
744 } else {
745 if (N(Z.z().ops_shortest = Z.z().ops_shortest.reallocJ(newopn))) {
746 UNSUPPORTED("7azrdo5s3kc44taqmtmeu1s33"); // fprintf (stderr, "libpath/%s:%d: %s\n", "graphviz-2.38.0\\lib\\pathplan\\shortest.c", 26, ("cannot realloc ops"));
747 UNSUPPORTED("1r6uhbnmxv8c6msnscw07w0qx"); // longjmp(jbuf,1);
748 }
749 }
750 Z.z().opn_shortest = newopn;
751 } finally {
752 LEAVING("d7vtt8xqxbdnx9kwtt1zzof75","growops");
753 }
754 }
755
756
757 }