Mercurial > hg > truffle
annotate test/compiler/7047069/Test7047069.java @ 6476:64d6e2343a68
removed CallPositionListener, another XIR remnant
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Mon, 01 Oct 2012 22:38:44 +0200 |
parents | ea0da5474c23 |
children |
rev | line source |
---|---|
3411
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
1 /* |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
2 * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
4 * |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
8 * |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
13 * accompanied this code). |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
14 * |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
18 * |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
21 * questions. |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
22 * |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
23 */ |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
24 |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
25 /** |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
26 * @test |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
27 * @bug 7047069 |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
28 * @summary Array can dynamically change size when assigned to an object field |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
29 * |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
30 * @run main/othervm -Xbatch Test7047069 |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
31 */ |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
32 |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
33 import java.util.*; |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
34 import java.awt.geom.*; |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
35 |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
36 public class Test7047069 { |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
37 static boolean verbose; |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
38 |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
39 static final int GROW_SIZE = 24; // Multiple of cubic & quad curve size |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
40 |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
41 float squareflat; // Square of the flatness parameter |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
42 // for testing against squared lengths |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
43 |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
44 int limit; // Maximum number of recursion levels |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
45 |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
46 float hold[] = new float[14]; // The cache of interpolated coords |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
47 // Note that this must be long enough |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
48 // to store a full cubic segment and |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
49 // a relative cubic segment to avoid |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
50 // aliasing when copying the coords |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
51 // of a curve to the end of the array. |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
52 // This is also serendipitously equal |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
53 // to the size of a full quad segment |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
54 // and 2 relative quad segments. |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
55 |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
56 int holdEnd; // The index of the last curve segment |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
57 // being held for interpolation |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
58 |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
59 int holdIndex; // The index of the curve segment |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
60 // that was last interpolated. This |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
61 // is the curve segment ready to be |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
62 // returned in the next call to |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
63 // currentSegment(). |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
64 |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
65 int levels[]; // The recursion level at which |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
66 // each curve being held in storage |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
67 // was generated. |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
68 |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
69 int levelIndex; // The index of the entry in the |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
70 // levels array of the curve segment |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
71 // at the holdIndex |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
72 |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
73 public static void subdivide(float src[], int srcoff, |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
74 float left[], int leftoff, |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
75 float right[], int rightoff) |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
76 { |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
77 float x1 = src[srcoff + 0]; |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
78 float y1 = src[srcoff + 1]; |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
79 float ctrlx = src[srcoff + 2]; |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
80 float ctrly = src[srcoff + 3]; |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
81 float x2 = src[srcoff + 4]; |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
82 float y2 = src[srcoff + 5]; |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
83 if (left != null) { |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
84 left[leftoff + 0] = x1; |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
85 left[leftoff + 1] = y1; |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
86 } |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
87 if (right != null) { |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
88 right[rightoff + 4] = x2; |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
89 right[rightoff + 5] = y2; |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
90 } |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
91 x1 = (x1 + ctrlx) / 2f; |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
92 y1 = (y1 + ctrly) / 2f; |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
93 x2 = (x2 + ctrlx) / 2f; |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
94 y2 = (y2 + ctrly) / 2f; |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
95 ctrlx = (x1 + x2) / 2f; |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
96 ctrly = (y1 + y2) / 2f; |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
97 if (left != null) { |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
98 left[leftoff + 2] = x1; |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
99 left[leftoff + 3] = y1; |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
100 left[leftoff + 4] = ctrlx; |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
101 left[leftoff + 5] = ctrly; |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
102 } |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
103 if (right != null) { |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
104 right[rightoff + 0] = ctrlx; |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
105 right[rightoff + 1] = ctrly; |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
106 right[rightoff + 2] = x2; |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
107 right[rightoff + 3] = y2; |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
108 } |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
109 } |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
110 |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
111 public static double getFlatnessSq(float coords[], int offset) { |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
112 return Line2D.ptSegDistSq(coords[offset + 0], coords[offset + 1], |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
113 coords[offset + 4], coords[offset + 5], |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
114 coords[offset + 2], coords[offset + 3]); |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
115 } |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
116 |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
117 public Test7047069() { |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
118 this.squareflat = .0001f * .0001f; |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
119 holdIndex = hold.length - 6; |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
120 holdEnd = hold.length - 2; |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
121 hold[holdIndex + 0] = (float) (Math.random() * 100); |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
122 hold[holdIndex + 1] = (float) (Math.random() * 100); |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
123 hold[holdIndex + 2] = (float) (Math.random() * 100); |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
124 hold[holdIndex + 3] = (float) (Math.random() * 100); |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
125 hold[holdIndex + 4] = (float) (Math.random() * 100); |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
126 hold[holdIndex + 5] = (float) (Math.random() * 100); |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
127 levelIndex = 0; |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
128 this.limit = 10; |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
129 this.levels = new int[limit + 1]; |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
130 } |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
131 |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
132 /* |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
133 * Ensures that the hold array can hold up to (want) more values. |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
134 * It is currently holding (hold.length - holdIndex) values. |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
135 */ |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
136 void ensureHoldCapacity(int want) { |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
137 if (holdIndex - want < 0) { |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
138 int have = hold.length - holdIndex; |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
139 int newsize = hold.length + GROW_SIZE; |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
140 float newhold[] = new float[newsize]; |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
141 System.arraycopy(hold, holdIndex, |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
142 newhold, holdIndex + GROW_SIZE, |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
143 have); |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
144 if (verbose) System.err.println("old hold = "+hold+"["+hold.length+"]"); |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
145 if (verbose) System.err.println("replacement hold = "+newhold+"["+newhold.length+"]"); |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
146 hold = newhold; |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
147 if (verbose) System.err.println("new hold = "+hold+"["+hold.length+"]"); |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
148 if (verbose) System.err.println("replacement hold still = "+newhold+"["+newhold.length+"]"); |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
149 holdIndex += GROW_SIZE; |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
150 holdEnd += GROW_SIZE; |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
151 } |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
152 } |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
153 |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
154 private boolean next() { |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
155 if (holdIndex >= holdEnd) { |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
156 return false; |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
157 } |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
158 |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
159 int level = levels[levelIndex]; |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
160 while (level < limit) { |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
161 if (getFlatnessSq(hold, holdIndex) < squareflat) { |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
162 break; |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
163 } |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
164 |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
165 ensureHoldCapacity(4); |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
166 subdivide(hold, holdIndex, |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
167 hold, holdIndex - 4, |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
168 hold, holdIndex); |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
169 holdIndex -= 4; |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
170 |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
171 // Now that we have subdivided, we have constructed |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
172 // two curves of one depth lower than the original |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
173 // curve. One of those curves is in the place of |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
174 // the former curve and one of them is in the next |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
175 // set of held coordinate slots. We now set both |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
176 // curves level values to the next higher level. |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
177 level++; |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
178 levels[levelIndex] = level; |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
179 levelIndex++; |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
180 levels[levelIndex] = level; |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
181 } |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
182 |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
183 // This curve segment is flat enough, or it is too deep |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
184 // in recursion levels to try to flatten any more. The |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
185 // two coordinates at holdIndex+4 and holdIndex+5 now |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
186 // contain the endpoint of the curve which can be the |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
187 // endpoint of an approximating line segment. |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
188 holdIndex += 4; |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
189 levelIndex--; |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
190 return true; |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
191 } |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
192 |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
193 public static void main(String argv[]) { |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
194 verbose = (argv.length > 0); |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
195 for (int i = 0; i < 100000; i++) { |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
196 Test7047069 st = new Test7047069(); |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
197 while (st.next()) {} |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
198 } |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
199 } |
ea0da5474c23
7047069: Array can dynamically change size when assigned to an object field
kvn
parents:
diff
changeset
|
200 } |