@turf/isobands 7.0.0-alpha.0 → 7.0.0-alpha.110

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3453 +0,0 @@
1
- /*!
2
- * @license GNU Affero General Public License.
3
- * Copyright (c) 2015, 2015 Ronny Lorenz <ronny@tbi.univie.ac.at>
4
- * v. 1.2.0
5
- * https://github.com/RaumZeit/MarchingSquares.js
6
- *
7
- * MarchingSquaresJS is free software: you can redistribute it and/or modify
8
- * it under the terms of the GNU Affero General Public License as published by
9
- * the Free Software Foundation, either version 3 of the License, or
10
- * (at your option) any later version.
11
- *
12
- * MarchingSquaresJS is distributed in the hope that it will be useful,
13
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
- * GNU Affero General Public License for more details.
16
- *
17
- * As additional permission under GNU Affero General Public License version 3
18
- * section 7, third-party projects (personal or commercial) may distribute,
19
- * include, or link against UNMODIFIED VERSIONS of MarchingSquaresJS without the
20
- * requirement that said third-party project for that reason alone becomes
21
- * subject to any requirement of the GNU Affero General Public License version 3.
22
- * Any modifications to MarchingSquaresJS, however, must be shared with the public
23
- * and made available.
24
- *
25
- * In summary this:
26
- * - allows you to use MarchingSquaresJS at no cost
27
- * - allows you to use MarchingSquaresJS for both personal and commercial purposes
28
- * - allows you to distribute UNMODIFIED VERSIONS of MarchingSquaresJS under any
29
- * license as long as this license notice is included
30
- * - enables you to keep the source code of your program that uses MarchingSquaresJS
31
- * undisclosed
32
- * - forces you to share any modifications you have made to MarchingSquaresJS,
33
- * e.g. bug-fixes
34
- *
35
- * You should have received a copy of the GNU Affero General Public License
36
- * along with MarchingSquaresJS. If not, see <http://www.gnu.org/licenses/>.
37
- */
38
- var defaultSettings = {
39
- successCallback: null,
40
- verbose: false,
41
- polygons: false,
42
- };
43
- var settings = {};
44
- /*
45
- Compute isobands(s) of a scalar 2D field given a certain
46
- threshold and a bandwidth by applying the Marching Squares
47
- Algorithm. The function returns a list of path coordinates
48
- either for individual polygons within each grid cell, or the
49
- outline of connected polygons.
50
- */
51
- export default function isoBands(data, minV, bandwidth, options) {
52
- /* process options */
53
- options = options ? options : {};
54
- var optionKeys = Object.keys(defaultSettings);
55
- for (var i = 0; i < optionKeys.length; i++) {
56
- var key = optionKeys[i];
57
- var val = options[key];
58
- val =
59
- typeof val !== "undefined" && val !== null ? val : defaultSettings[key];
60
- settings[key] = val;
61
- }
62
- if (settings.verbose)
63
- console.log("MarchingSquaresJS-isoBands: computing isobands for [" +
64
- minV +
65
- ":" +
66
- (minV + bandwidth) +
67
- "]");
68
- var grid = computeBandGrid(data, minV, bandwidth);
69
- var ret;
70
- if (settings.polygons) {
71
- if (settings.verbose)
72
- console.log("MarchingSquaresJS-isoBands: returning single polygons for each grid cell");
73
- ret = BandGrid2Areas(grid);
74
- }
75
- else {
76
- if (settings.verbose)
77
- console.log("MarchingSquaresJS-isoBands: returning polygon paths for entire data grid");
78
- ret = BandGrid2AreaPaths(grid);
79
- }
80
- if (typeof settings.successCallback === "function")
81
- settings.successCallback(ret);
82
- return ret;
83
- }
84
- /*
85
- Thats all for the public interface, below follows the actual
86
- implementation
87
- */
88
- /* Some private variables */
89
- var Node0 = 64, Node1 = 16, Node2 = 4, Node3 = 1;
90
- /*
91
- The look-up tables for tracing back the contour path
92
- of isoBands
93
- */
94
- var isoBandNextXTL = [];
95
- var isoBandNextYTL = [];
96
- var isoBandNextOTL = [];
97
- var isoBandNextXTR = [];
98
- var isoBandNextYTR = [];
99
- var isoBandNextOTR = [];
100
- var isoBandNextXRT = [];
101
- var isoBandNextYRT = [];
102
- var isoBandNextORT = [];
103
- var isoBandNextXRB = [];
104
- var isoBandNextYRB = [];
105
- var isoBandNextORB = [];
106
- var isoBandNextXBL = [];
107
- var isoBandNextYBL = [];
108
- var isoBandNextOBL = [];
109
- var isoBandNextXBR = [];
110
- var isoBandNextYBR = [];
111
- var isoBandNextOBR = [];
112
- var isoBandNextXLT = [];
113
- var isoBandNextYLT = [];
114
- var isoBandNextOLT = [];
115
- var isoBandNextXLB = [];
116
- var isoBandNextYLB = [];
117
- var isoBandNextOLB = [];
118
- isoBandNextXRT[85] = isoBandNextXRB[85] = -1;
119
- isoBandNextYRT[85] = isoBandNextYRB[85] = 0;
120
- isoBandNextORT[85] = isoBandNextORB[85] = 1;
121
- isoBandNextXLT[85] = isoBandNextXLB[85] = 1;
122
- isoBandNextYLT[85] = isoBandNextYLB[85] = 0;
123
- isoBandNextOLT[85] = isoBandNextOLB[85] = 1;
124
- isoBandNextXTL[85] = isoBandNextXTR[85] = 0;
125
- isoBandNextYTL[85] = isoBandNextYTR[85] = -1;
126
- isoBandNextOTL[85] = isoBandNextOBL[85] = 0;
127
- isoBandNextXBR[85] = isoBandNextXBL[85] = 0;
128
- isoBandNextYBR[85] = isoBandNextYBL[85] = 1;
129
- isoBandNextOTR[85] = isoBandNextOBR[85] = 1;
130
- /* triangle cases */
131
- isoBandNextXLB[1] = isoBandNextXLB[169] = 0;
132
- isoBandNextYLB[1] = isoBandNextYLB[169] = -1;
133
- isoBandNextOLB[1] = isoBandNextOLB[169] = 0;
134
- isoBandNextXBL[1] = isoBandNextXBL[169] = -1;
135
- isoBandNextYBL[1] = isoBandNextYBL[169] = 0;
136
- isoBandNextOBL[1] = isoBandNextOBL[169] = 0;
137
- isoBandNextXRB[4] = isoBandNextXRB[166] = 0;
138
- isoBandNextYRB[4] = isoBandNextYRB[166] = -1;
139
- isoBandNextORB[4] = isoBandNextORB[166] = 1;
140
- isoBandNextXBR[4] = isoBandNextXBR[166] = 1;
141
- isoBandNextYBR[4] = isoBandNextYBR[166] = 0;
142
- isoBandNextOBR[4] = isoBandNextOBR[166] = 0;
143
- isoBandNextXRT[16] = isoBandNextXRT[154] = 0;
144
- isoBandNextYRT[16] = isoBandNextYRT[154] = 1;
145
- isoBandNextORT[16] = isoBandNextORT[154] = 1;
146
- isoBandNextXTR[16] = isoBandNextXTR[154] = 1;
147
- isoBandNextYTR[16] = isoBandNextYTR[154] = 0;
148
- isoBandNextOTR[16] = isoBandNextOTR[154] = 1;
149
- isoBandNextXLT[64] = isoBandNextXLT[106] = 0;
150
- isoBandNextYLT[64] = isoBandNextYLT[106] = 1;
151
- isoBandNextOLT[64] = isoBandNextOLT[106] = 0;
152
- isoBandNextXTL[64] = isoBandNextXTL[106] = -1;
153
- isoBandNextYTL[64] = isoBandNextYTL[106] = 0;
154
- isoBandNextOTL[64] = isoBandNextOTL[106] = 1;
155
- /* single trapezoid cases */
156
- isoBandNextXLT[2] = isoBandNextXLT[168] = 0;
157
- isoBandNextYLT[2] = isoBandNextYLT[168] = -1;
158
- isoBandNextOLT[2] = isoBandNextOLT[168] = 1;
159
- isoBandNextXLB[2] = isoBandNextXLB[168] = 0;
160
- isoBandNextYLB[2] = isoBandNextYLB[168] = -1;
161
- isoBandNextOLB[2] = isoBandNextOLB[168] = 0;
162
- isoBandNextXBL[2] = isoBandNextXBL[168] = -1;
163
- isoBandNextYBL[2] = isoBandNextYBL[168] = 0;
164
- isoBandNextOBL[2] = isoBandNextOBL[168] = 0;
165
- isoBandNextXBR[2] = isoBandNextXBR[168] = -1;
166
- isoBandNextYBR[2] = isoBandNextYBR[168] = 0;
167
- isoBandNextOBR[2] = isoBandNextOBR[168] = 1;
168
- isoBandNextXRT[8] = isoBandNextXRT[162] = 0;
169
- isoBandNextYRT[8] = isoBandNextYRT[162] = -1;
170
- isoBandNextORT[8] = isoBandNextORT[162] = 0;
171
- isoBandNextXRB[8] = isoBandNextXRB[162] = 0;
172
- isoBandNextYRB[8] = isoBandNextYRB[162] = -1;
173
- isoBandNextORB[8] = isoBandNextORB[162] = 1;
174
- isoBandNextXBL[8] = isoBandNextXBL[162] = 1;
175
- isoBandNextYBL[8] = isoBandNextYBL[162] = 0;
176
- isoBandNextOBL[8] = isoBandNextOBL[162] = 1;
177
- isoBandNextXBR[8] = isoBandNextXBR[162] = 1;
178
- isoBandNextYBR[8] = isoBandNextYBR[162] = 0;
179
- isoBandNextOBR[8] = isoBandNextOBR[162] = 0;
180
- isoBandNextXRT[32] = isoBandNextXRT[138] = 0;
181
- isoBandNextYRT[32] = isoBandNextYRT[138] = 1;
182
- isoBandNextORT[32] = isoBandNextORT[138] = 1;
183
- isoBandNextXRB[32] = isoBandNextXRB[138] = 0;
184
- isoBandNextYRB[32] = isoBandNextYRB[138] = 1;
185
- isoBandNextORB[32] = isoBandNextORB[138] = 0;
186
- isoBandNextXTL[32] = isoBandNextXTL[138] = 1;
187
- isoBandNextYTL[32] = isoBandNextYTL[138] = 0;
188
- isoBandNextOTL[32] = isoBandNextOTL[138] = 0;
189
- isoBandNextXTR[32] = isoBandNextXTR[138] = 1;
190
- isoBandNextYTR[32] = isoBandNextYTR[138] = 0;
191
- isoBandNextOTR[32] = isoBandNextOTR[138] = 1;
192
- isoBandNextXLB[128] = isoBandNextXLB[42] = 0;
193
- isoBandNextYLB[128] = isoBandNextYLB[42] = 1;
194
- isoBandNextOLB[128] = isoBandNextOLB[42] = 1;
195
- isoBandNextXLT[128] = isoBandNextXLT[42] = 0;
196
- isoBandNextYLT[128] = isoBandNextYLT[42] = 1;
197
- isoBandNextOLT[128] = isoBandNextOLT[42] = 0;
198
- isoBandNextXTL[128] = isoBandNextXTL[42] = -1;
199
- isoBandNextYTL[128] = isoBandNextYTL[42] = 0;
200
- isoBandNextOTL[128] = isoBandNextOTL[42] = 1;
201
- isoBandNextXTR[128] = isoBandNextXTR[42] = -1;
202
- isoBandNextYTR[128] = isoBandNextYTR[42] = 0;
203
- isoBandNextOTR[128] = isoBandNextOTR[42] = 0;
204
- /* single rectangle cases */
205
- isoBandNextXRB[5] = isoBandNextXRB[165] = -1;
206
- isoBandNextYRB[5] = isoBandNextYRB[165] = 0;
207
- isoBandNextORB[5] = isoBandNextORB[165] = 0;
208
- isoBandNextXLB[5] = isoBandNextXLB[165] = 1;
209
- isoBandNextYLB[5] = isoBandNextYLB[165] = 0;
210
- isoBandNextOLB[5] = isoBandNextOLB[165] = 0;
211
- isoBandNextXBR[20] = isoBandNextXBR[150] = 0;
212
- isoBandNextYBR[20] = isoBandNextYBR[150] = 1;
213
- isoBandNextOBR[20] = isoBandNextOBR[150] = 1;
214
- isoBandNextXTR[20] = isoBandNextXTR[150] = 0;
215
- isoBandNextYTR[20] = isoBandNextYTR[150] = -1;
216
- isoBandNextOTR[20] = isoBandNextOTR[150] = 1;
217
- isoBandNextXRT[80] = isoBandNextXRT[90] = -1;
218
- isoBandNextYRT[80] = isoBandNextYRT[90] = 0;
219
- isoBandNextORT[80] = isoBandNextORT[90] = 1;
220
- isoBandNextXLT[80] = isoBandNextXLT[90] = 1;
221
- isoBandNextYLT[80] = isoBandNextYLT[90] = 0;
222
- isoBandNextOLT[80] = isoBandNextOLT[90] = 1;
223
- isoBandNextXBL[65] = isoBandNextXBL[105] = 0;
224
- isoBandNextYBL[65] = isoBandNextYBL[105] = 1;
225
- isoBandNextOBL[65] = isoBandNextOBL[105] = 0;
226
- isoBandNextXTL[65] = isoBandNextXTL[105] = 0;
227
- isoBandNextYTL[65] = isoBandNextYTL[105] = -1;
228
- isoBandNextOTL[65] = isoBandNextOTL[105] = 0;
229
- isoBandNextXRT[160] = isoBandNextXRT[10] = -1;
230
- isoBandNextYRT[160] = isoBandNextYRT[10] = 0;
231
- isoBandNextORT[160] = isoBandNextORT[10] = 1;
232
- isoBandNextXRB[160] = isoBandNextXRB[10] = -1;
233
- isoBandNextYRB[160] = isoBandNextYRB[10] = 0;
234
- isoBandNextORB[160] = isoBandNextORB[10] = 0;
235
- isoBandNextXLB[160] = isoBandNextXLB[10] = 1;
236
- isoBandNextYLB[160] = isoBandNextYLB[10] = 0;
237
- isoBandNextOLB[160] = isoBandNextOLB[10] = 0;
238
- isoBandNextXLT[160] = isoBandNextXLT[10] = 1;
239
- isoBandNextYLT[160] = isoBandNextYLT[10] = 0;
240
- isoBandNextOLT[160] = isoBandNextOLT[10] = 1;
241
- isoBandNextXBR[130] = isoBandNextXBR[40] = 0;
242
- isoBandNextYBR[130] = isoBandNextYBR[40] = 1;
243
- isoBandNextOBR[130] = isoBandNextOBR[40] = 1;
244
- isoBandNextXBL[130] = isoBandNextXBL[40] = 0;
245
- isoBandNextYBL[130] = isoBandNextYBL[40] = 1;
246
- isoBandNextOBL[130] = isoBandNextOBL[40] = 0;
247
- isoBandNextXTL[130] = isoBandNextXTL[40] = 0;
248
- isoBandNextYTL[130] = isoBandNextYTL[40] = -1;
249
- isoBandNextOTL[130] = isoBandNextOTL[40] = 0;
250
- isoBandNextXTR[130] = isoBandNextXTR[40] = 0;
251
- isoBandNextYTR[130] = isoBandNextYTR[40] = -1;
252
- isoBandNextOTR[130] = isoBandNextOTR[40] = 1;
253
- /* single hexagon cases */
254
- isoBandNextXRB[37] = isoBandNextXRB[133] = 0;
255
- isoBandNextYRB[37] = isoBandNextYRB[133] = 1;
256
- isoBandNextORB[37] = isoBandNextORB[133] = 1;
257
- isoBandNextXLB[37] = isoBandNextXLB[133] = 0;
258
- isoBandNextYLB[37] = isoBandNextYLB[133] = 1;
259
- isoBandNextOLB[37] = isoBandNextOLB[133] = 0;
260
- isoBandNextXTL[37] = isoBandNextXTL[133] = -1;
261
- isoBandNextYTL[37] = isoBandNextYTL[133] = 0;
262
- isoBandNextOTL[37] = isoBandNextOTL[133] = 0;
263
- isoBandNextXTR[37] = isoBandNextXTR[133] = 1;
264
- isoBandNextYTR[37] = isoBandNextYTR[133] = 0;
265
- isoBandNextOTR[37] = isoBandNextOTR[133] = 0;
266
- isoBandNextXBR[148] = isoBandNextXBR[22] = -1;
267
- isoBandNextYBR[148] = isoBandNextYBR[22] = 0;
268
- isoBandNextOBR[148] = isoBandNextOBR[22] = 0;
269
- isoBandNextXLB[148] = isoBandNextXLB[22] = 0;
270
- isoBandNextYLB[148] = isoBandNextYLB[22] = -1;
271
- isoBandNextOLB[148] = isoBandNextOLB[22] = 1;
272
- isoBandNextXLT[148] = isoBandNextXLT[22] = 0;
273
- isoBandNextYLT[148] = isoBandNextYLT[22] = 1;
274
- isoBandNextOLT[148] = isoBandNextOLT[22] = 1;
275
- isoBandNextXTR[148] = isoBandNextXTR[22] = -1;
276
- isoBandNextYTR[148] = isoBandNextYTR[22] = 0;
277
- isoBandNextOTR[148] = isoBandNextOTR[22] = 1;
278
- isoBandNextXRT[82] = isoBandNextXRT[88] = 0;
279
- isoBandNextYRT[82] = isoBandNextYRT[88] = -1;
280
- isoBandNextORT[82] = isoBandNextORT[88] = 1;
281
- isoBandNextXBR[82] = isoBandNextXBR[88] = 1;
282
- isoBandNextYBR[82] = isoBandNextYBR[88] = 0;
283
- isoBandNextOBR[82] = isoBandNextOBR[88] = 1;
284
- isoBandNextXBL[82] = isoBandNextXBL[88] = -1;
285
- isoBandNextYBL[82] = isoBandNextYBL[88] = 0;
286
- isoBandNextOBL[82] = isoBandNextOBL[88] = 1;
287
- isoBandNextXLT[82] = isoBandNextXLT[88] = 0;
288
- isoBandNextYLT[82] = isoBandNextYLT[88] = -1;
289
- isoBandNextOLT[82] = isoBandNextOLT[88] = 0;
290
- isoBandNextXRT[73] = isoBandNextXRT[97] = 0;
291
- isoBandNextYRT[73] = isoBandNextYRT[97] = 1;
292
- isoBandNextORT[73] = isoBandNextORT[97] = 0;
293
- isoBandNextXRB[73] = isoBandNextXRB[97] = 0;
294
- isoBandNextYRB[73] = isoBandNextYRB[97] = -1;
295
- isoBandNextORB[73] = isoBandNextORB[97] = 0;
296
- isoBandNextXBL[73] = isoBandNextXBL[97] = 1;
297
- isoBandNextYBL[73] = isoBandNextYBL[97] = 0;
298
- isoBandNextOBL[73] = isoBandNextOBL[97] = 0;
299
- isoBandNextXTL[73] = isoBandNextXTL[97] = 1;
300
- isoBandNextYTL[73] = isoBandNextYTL[97] = 0;
301
- isoBandNextOTL[73] = isoBandNextOTL[97] = 1;
302
- isoBandNextXRT[145] = isoBandNextXRT[25] = 0;
303
- isoBandNextYRT[145] = isoBandNextYRT[25] = -1;
304
- isoBandNextORT[145] = isoBandNextORT[25] = 0;
305
- isoBandNextXBL[145] = isoBandNextXBL[25] = 1;
306
- isoBandNextYBL[145] = isoBandNextYBL[25] = 0;
307
- isoBandNextOBL[145] = isoBandNextOBL[25] = 1;
308
- isoBandNextXLB[145] = isoBandNextXLB[25] = 0;
309
- isoBandNextYLB[145] = isoBandNextYLB[25] = 1;
310
- isoBandNextOLB[145] = isoBandNextOLB[25] = 1;
311
- isoBandNextXTR[145] = isoBandNextXTR[25] = -1;
312
- isoBandNextYTR[145] = isoBandNextYTR[25] = 0;
313
- isoBandNextOTR[145] = isoBandNextOTR[25] = 0;
314
- isoBandNextXRB[70] = isoBandNextXRB[100] = 0;
315
- isoBandNextYRB[70] = isoBandNextYRB[100] = 1;
316
- isoBandNextORB[70] = isoBandNextORB[100] = 0;
317
- isoBandNextXBR[70] = isoBandNextXBR[100] = -1;
318
- isoBandNextYBR[70] = isoBandNextYBR[100] = 0;
319
- isoBandNextOBR[70] = isoBandNextOBR[100] = 1;
320
- isoBandNextXLT[70] = isoBandNextXLT[100] = 0;
321
- isoBandNextYLT[70] = isoBandNextYLT[100] = -1;
322
- isoBandNextOLT[70] = isoBandNextOLT[100] = 1;
323
- isoBandNextXTL[70] = isoBandNextXTL[100] = 1;
324
- isoBandNextYTL[70] = isoBandNextYTL[100] = 0;
325
- isoBandNextOTL[70] = isoBandNextOTL[100] = 0;
326
- /* single pentagon cases */
327
- isoBandNextXRB[101] = isoBandNextXRB[69] = 0;
328
- isoBandNextYRB[101] = isoBandNextYRB[69] = 1;
329
- isoBandNextORB[101] = isoBandNextORB[69] = 0;
330
- isoBandNextXTL[101] = isoBandNextXTL[69] = 1;
331
- isoBandNextYTL[101] = isoBandNextYTL[69] = 0;
332
- isoBandNextOTL[101] = isoBandNextOTL[69] = 0;
333
- isoBandNextXLB[149] = isoBandNextXLB[21] = 0;
334
- isoBandNextYLB[149] = isoBandNextYLB[21] = 1;
335
- isoBandNextOLB[149] = isoBandNextOLB[21] = 1;
336
- isoBandNextXTR[149] = isoBandNextXTR[21] = -1;
337
- isoBandNextYTR[149] = isoBandNextYTR[21] = 0;
338
- isoBandNextOTR[149] = isoBandNextOTR[21] = 0;
339
- isoBandNextXBR[86] = isoBandNextXBR[84] = -1;
340
- isoBandNextYBR[86] = isoBandNextYBR[84] = 0;
341
- isoBandNextOBR[86] = isoBandNextOBR[84] = 1;
342
- isoBandNextXLT[86] = isoBandNextXLT[84] = 0;
343
- isoBandNextYLT[86] = isoBandNextYLT[84] = -1;
344
- isoBandNextOLT[86] = isoBandNextOLT[84] = 1;
345
- isoBandNextXRT[89] = isoBandNextXRT[81] = 0;
346
- isoBandNextYRT[89] = isoBandNextYRT[81] = -1;
347
- isoBandNextORT[89] = isoBandNextORT[81] = 0;
348
- isoBandNextXBL[89] = isoBandNextXBL[81] = 1;
349
- isoBandNextYBL[89] = isoBandNextYBL[81] = 0;
350
- isoBandNextOBL[89] = isoBandNextOBL[81] = 1;
351
- isoBandNextXRT[96] = isoBandNextXRT[74] = 0;
352
- isoBandNextYRT[96] = isoBandNextYRT[74] = 1;
353
- isoBandNextORT[96] = isoBandNextORT[74] = 0;
354
- isoBandNextXRB[96] = isoBandNextXRB[74] = -1;
355
- isoBandNextYRB[96] = isoBandNextYRB[74] = 0;
356
- isoBandNextORB[96] = isoBandNextORB[74] = 1;
357
- isoBandNextXLT[96] = isoBandNextXLT[74] = 1;
358
- isoBandNextYLT[96] = isoBandNextYLT[74] = 0;
359
- isoBandNextOLT[96] = isoBandNextOLT[74] = 0;
360
- isoBandNextXTL[96] = isoBandNextXTL[74] = 1;
361
- isoBandNextYTL[96] = isoBandNextYTL[74] = 0;
362
- isoBandNextOTL[96] = isoBandNextOTL[74] = 1;
363
- isoBandNextXRT[24] = isoBandNextXRT[146] = 0;
364
- isoBandNextYRT[24] = isoBandNextYRT[146] = -1;
365
- isoBandNextORT[24] = isoBandNextORT[146] = 1;
366
- isoBandNextXBR[24] = isoBandNextXBR[146] = 1;
367
- isoBandNextYBR[24] = isoBandNextYBR[146] = 0;
368
- isoBandNextOBR[24] = isoBandNextOBR[146] = 1;
369
- isoBandNextXBL[24] = isoBandNextXBL[146] = 0;
370
- isoBandNextYBL[24] = isoBandNextYBL[146] = 1;
371
- isoBandNextOBL[24] = isoBandNextOBL[146] = 1;
372
- isoBandNextXTR[24] = isoBandNextXTR[146] = 0;
373
- isoBandNextYTR[24] = isoBandNextYTR[146] = -1;
374
- isoBandNextOTR[24] = isoBandNextOTR[146] = 0;
375
- isoBandNextXRB[6] = isoBandNextXRB[164] = -1;
376
- isoBandNextYRB[6] = isoBandNextYRB[164] = 0;
377
- isoBandNextORB[6] = isoBandNextORB[164] = 1;
378
- isoBandNextXBR[6] = isoBandNextXBR[164] = -1;
379
- isoBandNextYBR[6] = isoBandNextYBR[164] = 0;
380
- isoBandNextOBR[6] = isoBandNextOBR[164] = 0;
381
- isoBandNextXLB[6] = isoBandNextXLB[164] = 0;
382
- isoBandNextYLB[6] = isoBandNextYLB[164] = -1;
383
- isoBandNextOLB[6] = isoBandNextOLB[164] = 1;
384
- isoBandNextXLT[6] = isoBandNextXLT[164] = 1;
385
- isoBandNextYLT[6] = isoBandNextYLT[164] = 0;
386
- isoBandNextOLT[6] = isoBandNextOLT[164] = 0;
387
- isoBandNextXBL[129] = isoBandNextXBL[41] = 0;
388
- isoBandNextYBL[129] = isoBandNextYBL[41] = 1;
389
- isoBandNextOBL[129] = isoBandNextOBL[41] = 1;
390
- isoBandNextXLB[129] = isoBandNextXLB[41] = 0;
391
- isoBandNextYLB[129] = isoBandNextYLB[41] = 1;
392
- isoBandNextOLB[129] = isoBandNextOLB[41] = 0;
393
- isoBandNextXTL[129] = isoBandNextXTL[41] = -1;
394
- isoBandNextYTL[129] = isoBandNextYTL[41] = 0;
395
- isoBandNextOTL[129] = isoBandNextOTL[41] = 0;
396
- isoBandNextXTR[129] = isoBandNextXTR[41] = 0;
397
- isoBandNextYTR[129] = isoBandNextYTR[41] = -1;
398
- isoBandNextOTR[129] = isoBandNextOTR[41] = 0;
399
- isoBandNextXBR[66] = isoBandNextXBR[104] = 0;
400
- isoBandNextYBR[66] = isoBandNextYBR[104] = 1;
401
- isoBandNextOBR[66] = isoBandNextOBR[104] = 0;
402
- isoBandNextXBL[66] = isoBandNextXBL[104] = -1;
403
- isoBandNextYBL[66] = isoBandNextYBL[104] = 0;
404
- isoBandNextOBL[66] = isoBandNextOBL[104] = 1;
405
- isoBandNextXLT[66] = isoBandNextXLT[104] = 0;
406
- isoBandNextYLT[66] = isoBandNextYLT[104] = -1;
407
- isoBandNextOLT[66] = isoBandNextOLT[104] = 0;
408
- isoBandNextXTL[66] = isoBandNextXTL[104] = 0;
409
- isoBandNextYTL[66] = isoBandNextYTL[104] = -1;
410
- isoBandNextOTL[66] = isoBandNextOTL[104] = 1;
411
- isoBandNextXRT[144] = isoBandNextXRT[26] = -1;
412
- isoBandNextYRT[144] = isoBandNextYRT[26] = 0;
413
- isoBandNextORT[144] = isoBandNextORT[26] = 0;
414
- isoBandNextXLB[144] = isoBandNextXLB[26] = 1;
415
- isoBandNextYLB[144] = isoBandNextYLB[26] = 0;
416
- isoBandNextOLB[144] = isoBandNextOLB[26] = 1;
417
- isoBandNextXLT[144] = isoBandNextXLT[26] = 0;
418
- isoBandNextYLT[144] = isoBandNextYLT[26] = 1;
419
- isoBandNextOLT[144] = isoBandNextOLT[26] = 1;
420
- isoBandNextXTR[144] = isoBandNextXTR[26] = -1;
421
- isoBandNextYTR[144] = isoBandNextYTR[26] = 0;
422
- isoBandNextOTR[144] = isoBandNextOTR[26] = 1;
423
- isoBandNextXRB[36] = isoBandNextXRB[134] = 0;
424
- isoBandNextYRB[36] = isoBandNextYRB[134] = 1;
425
- isoBandNextORB[36] = isoBandNextORB[134] = 1;
426
- isoBandNextXBR[36] = isoBandNextXBR[134] = 0;
427
- isoBandNextYBR[36] = isoBandNextYBR[134] = 1;
428
- isoBandNextOBR[36] = isoBandNextOBR[134] = 0;
429
- isoBandNextXTL[36] = isoBandNextXTL[134] = 0;
430
- isoBandNextYTL[36] = isoBandNextYTL[134] = -1;
431
- isoBandNextOTL[36] = isoBandNextOTL[134] = 1;
432
- isoBandNextXTR[36] = isoBandNextXTR[134] = 1;
433
- isoBandNextYTR[36] = isoBandNextYTR[134] = 0;
434
- isoBandNextOTR[36] = isoBandNextOTR[134] = 0;
435
- isoBandNextXRT[9] = isoBandNextXRT[161] = -1;
436
- isoBandNextYRT[9] = isoBandNextYRT[161] = 0;
437
- isoBandNextORT[9] = isoBandNextORT[161] = 0;
438
- isoBandNextXRB[9] = isoBandNextXRB[161] = 0;
439
- isoBandNextYRB[9] = isoBandNextYRB[161] = -1;
440
- isoBandNextORB[9] = isoBandNextORB[161] = 0;
441
- isoBandNextXBL[9] = isoBandNextXBL[161] = 1;
442
- isoBandNextYBL[9] = isoBandNextYBL[161] = 0;
443
- isoBandNextOBL[9] = isoBandNextOBL[161] = 0;
444
- isoBandNextXLB[9] = isoBandNextXLB[161] = 1;
445
- isoBandNextYLB[9] = isoBandNextYLB[161] = 0;
446
- isoBandNextOLB[9] = isoBandNextOLB[161] = 1;
447
- /* 8-sided cases */
448
- isoBandNextXRT[136] = 0;
449
- isoBandNextYRT[136] = 1;
450
- isoBandNextORT[136] = 1;
451
- isoBandNextXRB[136] = 0;
452
- isoBandNextYRB[136] = 1;
453
- isoBandNextORB[136] = 0;
454
- isoBandNextXBR[136] = -1;
455
- isoBandNextYBR[136] = 0;
456
- isoBandNextOBR[136] = 1;
457
- isoBandNextXBL[136] = -1;
458
- isoBandNextYBL[136] = 0;
459
- isoBandNextOBL[136] = 0;
460
- isoBandNextXLB[136] = 0;
461
- isoBandNextYLB[136] = -1;
462
- isoBandNextOLB[136] = 0;
463
- isoBandNextXLT[136] = 0;
464
- isoBandNextYLT[136] = -1;
465
- isoBandNextOLT[136] = 1;
466
- isoBandNextXTL[136] = 1;
467
- isoBandNextYTL[136] = 0;
468
- isoBandNextOTL[136] = 0;
469
- isoBandNextXTR[136] = 1;
470
- isoBandNextYTR[136] = 0;
471
- isoBandNextOTR[136] = 1;
472
- isoBandNextXRT[34] = 0;
473
- isoBandNextYRT[34] = -1;
474
- isoBandNextORT[34] = 0;
475
- isoBandNextXRB[34] = 0;
476
- isoBandNextYRB[34] = -1;
477
- isoBandNextORB[34] = 1;
478
- isoBandNextXBR[34] = 1;
479
- isoBandNextYBR[34] = 0;
480
- isoBandNextOBR[34] = 0;
481
- isoBandNextXBL[34] = 1;
482
- isoBandNextYBL[34] = 0;
483
- isoBandNextOBL[34] = 1;
484
- isoBandNextXLB[34] = 0;
485
- isoBandNextYLB[34] = 1;
486
- isoBandNextOLB[34] = 1;
487
- isoBandNextXLT[34] = 0;
488
- isoBandNextYLT[34] = 1;
489
- isoBandNextOLT[34] = 0;
490
- isoBandNextXTL[34] = -1;
491
- isoBandNextYTL[34] = 0;
492
- isoBandNextOTL[34] = 1;
493
- isoBandNextXTR[34] = -1;
494
- isoBandNextYTR[34] = 0;
495
- isoBandNextOTR[34] = 0;
496
- isoBandNextXRT[35] = 0;
497
- isoBandNextYRT[35] = 1;
498
- isoBandNextORT[35] = 1;
499
- isoBandNextXRB[35] = 0;
500
- isoBandNextYRB[35] = -1;
501
- isoBandNextORB[35] = 1;
502
- isoBandNextXBR[35] = 1;
503
- isoBandNextYBR[35] = 0;
504
- isoBandNextOBR[35] = 0;
505
- isoBandNextXBL[35] = -1;
506
- isoBandNextYBL[35] = 0;
507
- isoBandNextOBL[35] = 0;
508
- isoBandNextXLB[35] = 0;
509
- isoBandNextYLB[35] = -1;
510
- isoBandNextOLB[35] = 0;
511
- isoBandNextXLT[35] = 0;
512
- isoBandNextYLT[35] = 1;
513
- isoBandNextOLT[35] = 0;
514
- isoBandNextXTL[35] = -1;
515
- isoBandNextYTL[35] = 0;
516
- isoBandNextOTL[35] = 1;
517
- isoBandNextXTR[35] = 1;
518
- isoBandNextYTR[35] = 0;
519
- isoBandNextOTR[35] = 1;
520
- /* 6-sided cases */
521
- isoBandNextXRT[153] = 0;
522
- isoBandNextYRT[153] = 1;
523
- isoBandNextORT[153] = 1;
524
- isoBandNextXBL[153] = -1;
525
- isoBandNextYBL[153] = 0;
526
- isoBandNextOBL[153] = 0;
527
- isoBandNextXLB[153] = 0;
528
- isoBandNextYLB[153] = -1;
529
- isoBandNextOLB[153] = 0;
530
- isoBandNextXTR[153] = 1;
531
- isoBandNextYTR[153] = 0;
532
- isoBandNextOTR[153] = 1;
533
- isoBandNextXRB[102] = 0;
534
- isoBandNextYRB[102] = -1;
535
- isoBandNextORB[102] = 1;
536
- isoBandNextXBR[102] = 1;
537
- isoBandNextYBR[102] = 0;
538
- isoBandNextOBR[102] = 0;
539
- isoBandNextXLT[102] = 0;
540
- isoBandNextYLT[102] = 1;
541
- isoBandNextOLT[102] = 0;
542
- isoBandNextXTL[102] = -1;
543
- isoBandNextYTL[102] = 0;
544
- isoBandNextOTL[102] = 1;
545
- isoBandNextXRT[155] = 0;
546
- isoBandNextYRT[155] = -1;
547
- isoBandNextORT[155] = 0;
548
- isoBandNextXBL[155] = 1;
549
- isoBandNextYBL[155] = 0;
550
- isoBandNextOBL[155] = 1;
551
- isoBandNextXLB[155] = 0;
552
- isoBandNextYLB[155] = 1;
553
- isoBandNextOLB[155] = 1;
554
- isoBandNextXTR[155] = -1;
555
- isoBandNextYTR[155] = 0;
556
- isoBandNextOTR[155] = 0;
557
- isoBandNextXRB[103] = 0;
558
- isoBandNextYRB[103] = 1;
559
- isoBandNextORB[103] = 0;
560
- isoBandNextXBR[103] = -1;
561
- isoBandNextYBR[103] = 0;
562
- isoBandNextOBR[103] = 1;
563
- isoBandNextXLT[103] = 0;
564
- isoBandNextYLT[103] = -1;
565
- isoBandNextOLT[103] = 1;
566
- isoBandNextXTL[103] = 1;
567
- isoBandNextYTL[103] = 0;
568
- isoBandNextOTL[103] = 0;
569
- /* 7-sided cases */
570
- isoBandNextXRT[152] = 0;
571
- isoBandNextYRT[152] = 1;
572
- isoBandNextORT[152] = 1;
573
- isoBandNextXBR[152] = -1;
574
- isoBandNextYBR[152] = 0;
575
- isoBandNextOBR[152] = 1;
576
- isoBandNextXBL[152] = -1;
577
- isoBandNextYBL[152] = 0;
578
- isoBandNextOBL[152] = 0;
579
- isoBandNextXLB[152] = 0;
580
- isoBandNextYLB[152] = -1;
581
- isoBandNextOLB[152] = 0;
582
- isoBandNextXLT[152] = 0;
583
- isoBandNextYLT[152] = -1;
584
- isoBandNextOLT[152] = 1;
585
- isoBandNextXTR[152] = 1;
586
- isoBandNextYTR[152] = 0;
587
- isoBandNextOTR[152] = 1;
588
- isoBandNextXRT[156] = 0;
589
- isoBandNextYRT[156] = -1;
590
- isoBandNextORT[156] = 1;
591
- isoBandNextXBR[156] = 1;
592
- isoBandNextYBR[156] = 0;
593
- isoBandNextOBR[156] = 1;
594
- isoBandNextXBL[156] = -1;
595
- isoBandNextYBL[156] = 0;
596
- isoBandNextOBL[156] = 0;
597
- isoBandNextXLB[156] = 0;
598
- isoBandNextYLB[156] = -1;
599
- isoBandNextOLB[156] = 0;
600
- isoBandNextXLT[156] = 0;
601
- isoBandNextYLT[156] = 1;
602
- isoBandNextOLT[156] = 1;
603
- isoBandNextXTR[156] = -1;
604
- isoBandNextYTR[156] = 0;
605
- isoBandNextOTR[156] = 1;
606
- isoBandNextXRT[137] = 0;
607
- isoBandNextYRT[137] = 1;
608
- isoBandNextORT[137] = 1;
609
- isoBandNextXRB[137] = 0;
610
- isoBandNextYRB[137] = 1;
611
- isoBandNextORB[137] = 0;
612
- isoBandNextXBL[137] = -1;
613
- isoBandNextYBL[137] = 0;
614
- isoBandNextOBL[137] = 0;
615
- isoBandNextXLB[137] = 0;
616
- isoBandNextYLB[137] = -1;
617
- isoBandNextOLB[137] = 0;
618
- isoBandNextXTL[137] = 1;
619
- isoBandNextYTL[137] = 0;
620
- isoBandNextOTL[137] = 0;
621
- isoBandNextXTR[137] = 1;
622
- isoBandNextYTR[137] = 0;
623
- isoBandNextOTR[137] = 1;
624
- isoBandNextXRT[139] = 0;
625
- isoBandNextYRT[139] = 1;
626
- isoBandNextORT[139] = 1;
627
- isoBandNextXRB[139] = 0;
628
- isoBandNextYRB[139] = -1;
629
- isoBandNextORB[139] = 0;
630
- isoBandNextXBL[139] = 1;
631
- isoBandNextYBL[139] = 0;
632
- isoBandNextOBL[139] = 0;
633
- isoBandNextXLB[139] = 0;
634
- isoBandNextYLB[139] = 1;
635
- isoBandNextOLB[139] = 0;
636
- isoBandNextXTL[139] = -1;
637
- isoBandNextYTL[139] = 0;
638
- isoBandNextOTL[139] = 0;
639
- isoBandNextXTR[139] = 1;
640
- isoBandNextYTR[139] = 0;
641
- isoBandNextOTR[139] = 1;
642
- isoBandNextXRT[98] = 0;
643
- isoBandNextYRT[98] = -1;
644
- isoBandNextORT[98] = 0;
645
- isoBandNextXRB[98] = 0;
646
- isoBandNextYRB[98] = -1;
647
- isoBandNextORB[98] = 1;
648
- isoBandNextXBR[98] = 1;
649
- isoBandNextYBR[98] = 0;
650
- isoBandNextOBR[98] = 0;
651
- isoBandNextXBL[98] = 1;
652
- isoBandNextYBL[98] = 0;
653
- isoBandNextOBL[98] = 1;
654
- isoBandNextXLT[98] = 0;
655
- isoBandNextYLT[98] = 1;
656
- isoBandNextOLT[98] = 0;
657
- isoBandNextXTL[98] = -1;
658
- isoBandNextYTL[98] = 0;
659
- isoBandNextOTL[98] = 1;
660
- isoBandNextXRT[99] = 0;
661
- isoBandNextYRT[99] = 1;
662
- isoBandNextORT[99] = 0;
663
- isoBandNextXRB[99] = 0;
664
- isoBandNextYRB[99] = -1;
665
- isoBandNextORB[99] = 1;
666
- isoBandNextXBR[99] = 1;
667
- isoBandNextYBR[99] = 0;
668
- isoBandNextOBR[99] = 0;
669
- isoBandNextXBL[99] = -1;
670
- isoBandNextYBL[99] = 0;
671
- isoBandNextOBL[99] = 1;
672
- isoBandNextXLT[99] = 0;
673
- isoBandNextYLT[99] = -1;
674
- isoBandNextOLT[99] = 0;
675
- isoBandNextXTL[99] = 1;
676
- isoBandNextYTL[99] = 0;
677
- isoBandNextOTL[99] = 1;
678
- isoBandNextXRB[38] = 0;
679
- isoBandNextYRB[38] = -1;
680
- isoBandNextORB[38] = 1;
681
- isoBandNextXBR[38] = 1;
682
- isoBandNextYBR[38] = 0;
683
- isoBandNextOBR[38] = 0;
684
- isoBandNextXLB[38] = 0;
685
- isoBandNextYLB[38] = 1;
686
- isoBandNextOLB[38] = 1;
687
- isoBandNextXLT[38] = 0;
688
- isoBandNextYLT[38] = 1;
689
- isoBandNextOLT[38] = 0;
690
- isoBandNextXTL[38] = -1;
691
- isoBandNextYTL[38] = 0;
692
- isoBandNextOTL[38] = 1;
693
- isoBandNextXTR[38] = -1;
694
- isoBandNextYTR[38] = 0;
695
- isoBandNextOTR[38] = 0;
696
- isoBandNextXRB[39] = 0;
697
- isoBandNextYRB[39] = 1;
698
- isoBandNextORB[39] = 1;
699
- isoBandNextXBR[39] = -1;
700
- isoBandNextYBR[39] = 0;
701
- isoBandNextOBR[39] = 0;
702
- isoBandNextXLB[39] = 0;
703
- isoBandNextYLB[39] = -1;
704
- isoBandNextOLB[39] = 1;
705
- isoBandNextXLT[39] = 0;
706
- isoBandNextYLT[39] = 1;
707
- isoBandNextOLT[39] = 0;
708
- isoBandNextXTL[39] = -1;
709
- isoBandNextYTL[39] = 0;
710
- isoBandNextOTL[39] = 1;
711
- isoBandNextXTR[39] = 1;
712
- isoBandNextYTR[39] = 0;
713
- isoBandNextOTR[39] = 0;
714
- /*
715
- Define helper functions for the polygon_table
716
- */
717
- /* triangle cases */
718
- var p00 = function (cell) {
719
- return [
720
- [cell.bottomleft, 0],
721
- [0, 0],
722
- [0, cell.leftbottom],
723
- ];
724
- };
725
- var p01 = function (cell) {
726
- return [
727
- [1, cell.rightbottom],
728
- [1, 0],
729
- [cell.bottomright, 0],
730
- ];
731
- };
732
- var p02 = function (cell) {
733
- return [
734
- [cell.topright, 1],
735
- [1, 1],
736
- [1, cell.righttop],
737
- ];
738
- };
739
- var p03 = function (cell) {
740
- return [
741
- [0, cell.lefttop],
742
- [0, 1],
743
- [cell.topleft, 1],
744
- ];
745
- };
746
- /* trapezoid cases */
747
- var p04 = function (cell) {
748
- return [
749
- [cell.bottomright, 0],
750
- [cell.bottomleft, 0],
751
- [0, cell.leftbottom],
752
- [0, cell.lefttop],
753
- ];
754
- };
755
- var p05 = function (cell) {
756
- return [
757
- [cell.bottomright, 0],
758
- [cell.bottomleft, 0],
759
- [1, cell.righttop],
760
- [1, cell.rightbottom],
761
- ];
762
- };
763
- var p06 = function (cell) {
764
- return [
765
- [1, cell.righttop],
766
- [1, cell.rightbottom],
767
- [cell.topleft, 1],
768
- [cell.topright, 1],
769
- ];
770
- };
771
- var p07 = function (cell) {
772
- return [
773
- [0, cell.leftbottom],
774
- [0, cell.lefttop],
775
- [cell.topleft, 1],
776
- [cell.topright, 1],
777
- ];
778
- };
779
- /* rectangle cases */
780
- var p08 = function (cell) {
781
- return [
782
- [0, 0],
783
- [0, cell.leftbottom],
784
- [1, cell.rightbottom],
785
- [1, 0],
786
- ];
787
- };
788
- var p09 = function (cell) {
789
- return [
790
- [1, 0],
791
- [cell.bottomright, 0],
792
- [cell.topright, 1],
793
- [1, 1],
794
- ];
795
- };
796
- var p10 = function (cell) {
797
- return [
798
- [1, 1],
799
- [1, cell.righttop],
800
- [0, cell.lefttop],
801
- [0, 1],
802
- ];
803
- };
804
- var p11 = function (cell) {
805
- return [
806
- [cell.bottomleft, 0],
807
- [0, 0],
808
- [0, 1],
809
- [cell.topleft, 1],
810
- ];
811
- };
812
- var p12 = function (cell) {
813
- return [
814
- [1, cell.righttop],
815
- [1, cell.rightbottom],
816
- [0, cell.leftbottom],
817
- [0, cell.lefttop],
818
- ];
819
- };
820
- var p13 = function (cell) {
821
- return [
822
- [cell.topleft, 1],
823
- [cell.topright, 1],
824
- [cell.bottomright, 0],
825
- [cell.bottomleft, 0],
826
- ];
827
- };
828
- /* square case */
829
- var p14 = function () {
830
- return [
831
- [0, 0],
832
- [0, 1],
833
- [1, 1],
834
- [1, 0],
835
- ];
836
- };
837
- /* pentagon cases */
838
- var p15 = function (cell) {
839
- return [
840
- [1, cell.rightbottom],
841
- [1, 0],
842
- [0, 0],
843
- [0, 1],
844
- [cell.topleft, 1],
845
- ];
846
- };
847
- /* 1211 || 1011 */
848
- var p16 = function (cell) {
849
- return [
850
- [cell.topright, 1],
851
- [1, 1],
852
- [1, 0],
853
- [0, 0],
854
- [0, cell.leftbottom],
855
- ];
856
- };
857
- /* 2111 || 0111 */
858
- var p17 = function (cell) {
859
- return [
860
- [1, 0],
861
- [cell.bottomright, 0],
862
- [0, cell.lefttop],
863
- [0, 1],
864
- [1, 1],
865
- ];
866
- };
867
- /* 1112 || 1110 */
868
- var p18 = function (cell) {
869
- return [
870
- [1, 1],
871
- [1, cell.righttop],
872
- [cell.bottomleft, 0],
873
- [0, 0],
874
- [0, 1],
875
- ];
876
- };
877
- /* 1121 || 1101 */
878
- var p19 = function (cell) {
879
- return [
880
- [1, cell.righttop],
881
- [1, cell.rightbottom],
882
- [0, cell.lefttop],
883
- [0, 1],
884
- [cell.topleft, 1],
885
- ];
886
- };
887
- /* 1200 || 1022 */
888
- var p20 = function (cell) {
889
- return [
890
- [1, 1],
891
- [1, cell.righttop],
892
- [cell.bottomright, 0],
893
- [cell.bottomleft, 0],
894
- [cell.topright, 1],
895
- ];
896
- };
897
- /* 0120 || 2102 */
898
- var p21 = function (cell) {
899
- return [
900
- [1, cell.rightbottom],
901
- [1, 0],
902
- [cell.bottomright, 0],
903
- [0, cell.leftbottom],
904
- [0, cell.lefttop],
905
- ];
906
- };
907
- /* 0012 || 2210 */
908
- var p22 = function (cell) {
909
- return [
910
- [cell.topright, 1],
911
- [cell.bottomleft, 0],
912
- [0, 0],
913
- [0, cell.leftbottom],
914
- [cell.topleft, 1],
915
- ];
916
- };
917
- /* 2001 || 0221 */
918
- var p23 = function (cell) {
919
- return [
920
- [cell.bottomright, 0],
921
- [cell.bottomleft, 0],
922
- [0, cell.lefttop],
923
- [0, 1],
924
- [cell.topleft, 1],
925
- ];
926
- };
927
- /* 1002 || 1220 */
928
- var p24 = function (cell) {
929
- return [
930
- [1, 1],
931
- [1, cell.righttop],
932
- [0, cell.leftbottom],
933
- [0, cell.lefttop],
934
- [cell.topright, 1],
935
- ];
936
- };
937
- /* 2100 || 0122 */
938
- var p25 = function (cell) {
939
- return [
940
- [1, cell.rightbottom],
941
- [1, 0],
942
- [cell.bottomright, 0],
943
- [cell.topleft, 1],
944
- [cell.topright, 1],
945
- ];
946
- };
947
- /* 0210 || 2012 */
948
- var p26 = function (cell) {
949
- return [
950
- [1, cell.righttop],
951
- [1, cell.rightbottom],
952
- [cell.bottomleft, 0],
953
- [0, 0],
954
- [0, cell.leftbottom],
955
- ];
956
- };
957
- /* 0021 || 2201 */
958
- /*hexagon cases */
959
- var p27 = function (cell) {
960
- return [
961
- [1, cell.rightbottom],
962
- [1, 0],
963
- [0, 0],
964
- [0, cell.leftbottom],
965
- [cell.topleft, 1],
966
- [cell.topright, 1],
967
- ];
968
- };
969
- /* 0211 || 2011 */
970
- var p28 = function (cell) {
971
- return [
972
- [1, 1],
973
- [1, 0],
974
- [cell.bottomright, 0],
975
- [0, cell.leftbottom],
976
- [0, cell.lefttop],
977
- [cell.topright, 1],
978
- ];
979
- };
980
- /* 2110 || 0112 */
981
- var p29 = function (cell) {
982
- return [
983
- [1, 1],
984
- [1, cell.righttop],
985
- [cell.bottomright, 0],
986
- [cell.bottomleft, 0],
987
- [0, cell.lefttop],
988
- [0, 1],
989
- ];
990
- };
991
- /* 1102 || 1120 */
992
- var p30 = function (cell) {
993
- return [
994
- [1, cell.righttop],
995
- [1, cell.rightbottom],
996
- [cell.bottomleft, 0],
997
- [0, 0],
998
- [0, 1],
999
- [cell.topleft, 1],
1000
- ];
1001
- };
1002
- /* 1021 || 1201 */
1003
- var p31 = function (cell) {
1004
- return [
1005
- [1, 1],
1006
- [1, cell.righttop],
1007
- [cell.bottomleft, 0],
1008
- [0, 0],
1009
- [0, cell.leftbottom],
1010
- [cell.topright, 1],
1011
- ];
1012
- };
1013
- /* 2101 || 0121 */
1014
- var p32 = function (cell) {
1015
- return [
1016
- [1, cell.rightbottom],
1017
- [1, 0],
1018
- [cell.bottomright, 0],
1019
- [0, cell.lefttop],
1020
- [0, 1],
1021
- [cell.topleft, 1],
1022
- ];
1023
- };
1024
- /* 1012 || 1210 */
1025
- /* 8-sided cases */
1026
- var p33 = function (cell) {
1027
- return [
1028
- [1, cell.righttop],
1029
- [1, cell.rightbottom],
1030
- [cell.bottomright, 0],
1031
- [cell.bottomleft, 0],
1032
- [0, cell.leftbottom],
1033
- [0, cell.lefttop],
1034
- [cell.topleft, 1],
1035
- [cell.topright, 1],
1036
- ];
1037
- };
1038
- /* flipped == 1 state for 0202 and 2020 */
1039
- /* 6-sided cases */
1040
- var p34 = function (cell) {
1041
- return [
1042
- [1, 1],
1043
- [1, cell.righttop],
1044
- [cell.bottomleft, 0],
1045
- [0, 0],
1046
- [0, cell.leftbottom],
1047
- [cell.topright, 1],
1048
- ];
1049
- };
1050
- /* 0101 with flipped == 1 || 2121 with flipped == 1 */
1051
- var p35 = function (cell) {
1052
- return [
1053
- [1, cell.rightbottom],
1054
- [1, 0],
1055
- [cell.bottomright, 0],
1056
- [0, cell.lefttop],
1057
- [0, 1],
1058
- [cell.topleft, 1],
1059
- ];
1060
- };
1061
- /* 1010 with flipped == 1 || 1212 with flipped == 1 */
1062
- /* 7-sided cases */
1063
- var p36 = function (cell) {
1064
- return [
1065
- [1, 1],
1066
- [1, cell.righttop],
1067
- [cell.bottomright, 0],
1068
- [cell.bottomleft, 0],
1069
- [0, cell.leftbottom],
1070
- [0, cell.lefttop],
1071
- [cell.topright, 1],
1072
- ];
1073
- };
1074
- /* 2120 with flipped == 1 || 0102 with flipped == 1 */
1075
- var p37 = function (cell) {
1076
- return [
1077
- [1, cell.righttop],
1078
- [1, cell.rightbottom],
1079
- [cell.bottomleft, 0],
1080
- [0, 0],
1081
- [0, cell.leftbottom],
1082
- [cell.topleft, 1],
1083
- [cell.topright, 1],
1084
- ];
1085
- };
1086
- /* 2021 with flipped == 1 || 0201 with flipped == 1 */
1087
- var p38 = function (cell) {
1088
- return [
1089
- [1, cell.righttop],
1090
- [1, cell.rightbottom],
1091
- [cell.bottomright, 0],
1092
- [cell.bottomleft, 0],
1093
- [0, cell.lefttop],
1094
- [0, 1],
1095
- [cell.topleft, 1],
1096
- ];
1097
- };
1098
- /* 1202 with flipped == 1 || 1020 with flipped == 1 */
1099
- var p39 = function (cell) {
1100
- return [
1101
- [1, cell.rightbottom],
1102
- [1, 0],
1103
- [cell.bottomright, 0],
1104
- [0, cell.leftbottom],
1105
- [0, cell.lefttop],
1106
- [cell.topleft, 1],
1107
- [cell.topright, 1],
1108
- ];
1109
- };
1110
- /* 0212 with flipped == 1 || 2010 with flipped == 1 */
1111
- /*
1112
- The lookup tables for edge number given the polygon
1113
- is entered at a specific location
1114
- */
1115
- var isoBandEdgeRT = [];
1116
- var isoBandEdgeRB = [];
1117
- var isoBandEdgeBR = [];
1118
- var isoBandEdgeBL = [];
1119
- var isoBandEdgeLB = [];
1120
- var isoBandEdgeLT = [];
1121
- var isoBandEdgeTL = [];
1122
- var isoBandEdgeTR = [];
1123
- /* triangle cases */
1124
- isoBandEdgeBL[1] = isoBandEdgeLB[1] = 18;
1125
- isoBandEdgeBL[169] = isoBandEdgeLB[169] = 18;
1126
- isoBandEdgeBR[4] = isoBandEdgeRB[4] = 12;
1127
- isoBandEdgeBR[166] = isoBandEdgeRB[166] = 12;
1128
- isoBandEdgeRT[16] = isoBandEdgeTR[16] = 4;
1129
- isoBandEdgeRT[154] = isoBandEdgeTR[154] = 4;
1130
- isoBandEdgeLT[64] = isoBandEdgeTL[64] = 22;
1131
- isoBandEdgeLT[106] = isoBandEdgeTL[106] = 22;
1132
- /* trapezoid cases */
1133
- isoBandEdgeBR[2] = isoBandEdgeLT[2] = 17;
1134
- isoBandEdgeBL[2] = isoBandEdgeLB[2] = 18;
1135
- isoBandEdgeBR[168] = isoBandEdgeLT[168] = 17;
1136
- isoBandEdgeBL[168] = isoBandEdgeLB[168] = 18;
1137
- isoBandEdgeRT[8] = isoBandEdgeBL[8] = 9;
1138
- isoBandEdgeRB[8] = isoBandEdgeBR[8] = 12;
1139
- isoBandEdgeRT[162] = isoBandEdgeBL[162] = 9;
1140
- isoBandEdgeRB[162] = isoBandEdgeBR[162] = 12;
1141
- isoBandEdgeRT[32] = isoBandEdgeTR[32] = 4;
1142
- isoBandEdgeRB[32] = isoBandEdgeTL[32] = 1;
1143
- isoBandEdgeRT[138] = isoBandEdgeTR[138] = 4;
1144
- isoBandEdgeRB[138] = isoBandEdgeTL[138] = 1;
1145
- isoBandEdgeLB[128] = isoBandEdgeTR[128] = 21;
1146
- isoBandEdgeLT[128] = isoBandEdgeTL[128] = 22;
1147
- isoBandEdgeLB[42] = isoBandEdgeTR[42] = 21;
1148
- isoBandEdgeLT[42] = isoBandEdgeTL[42] = 22;
1149
- /* rectangle cases */
1150
- isoBandEdgeRB[5] = isoBandEdgeLB[5] = 14;
1151
- isoBandEdgeRB[165] = isoBandEdgeLB[165] = 14;
1152
- isoBandEdgeBR[20] = isoBandEdgeTR[20] = 6;
1153
- isoBandEdgeBR[150] = isoBandEdgeTR[150] = 6;
1154
- isoBandEdgeRT[80] = isoBandEdgeLT[80] = 11;
1155
- isoBandEdgeRT[90] = isoBandEdgeLT[90] = 11;
1156
- isoBandEdgeBL[65] = isoBandEdgeTL[65] = 3;
1157
- isoBandEdgeBL[105] = isoBandEdgeTL[105] = 3;
1158
- isoBandEdgeRT[160] = isoBandEdgeLT[160] = 11;
1159
- isoBandEdgeRB[160] = isoBandEdgeLB[160] = 14;
1160
- isoBandEdgeRT[10] = isoBandEdgeLT[10] = 11;
1161
- isoBandEdgeRB[10] = isoBandEdgeLB[10] = 14;
1162
- isoBandEdgeBR[130] = isoBandEdgeTR[130] = 6;
1163
- isoBandEdgeBL[130] = isoBandEdgeTL[130] = 3;
1164
- isoBandEdgeBR[40] = isoBandEdgeTR[40] = 6;
1165
- isoBandEdgeBL[40] = isoBandEdgeTL[40] = 3;
1166
- /* pentagon cases */
1167
- isoBandEdgeRB[101] = isoBandEdgeTL[101] = 1;
1168
- isoBandEdgeRB[69] = isoBandEdgeTL[69] = 1;
1169
- isoBandEdgeLB[149] = isoBandEdgeTR[149] = 21;
1170
- isoBandEdgeLB[21] = isoBandEdgeTR[21] = 21;
1171
- isoBandEdgeBR[86] = isoBandEdgeLT[86] = 17;
1172
- isoBandEdgeBR[84] = isoBandEdgeLT[84] = 17;
1173
- isoBandEdgeRT[89] = isoBandEdgeBL[89] = 9;
1174
- isoBandEdgeRT[81] = isoBandEdgeBL[81] = 9;
1175
- isoBandEdgeRT[96] = isoBandEdgeTL[96] = 0;
1176
- isoBandEdgeRB[96] = isoBandEdgeLT[96] = 15;
1177
- isoBandEdgeRT[74] = isoBandEdgeTL[74] = 0;
1178
- isoBandEdgeRB[74] = isoBandEdgeLT[74] = 15;
1179
- isoBandEdgeRT[24] = isoBandEdgeBR[24] = 8;
1180
- isoBandEdgeBL[24] = isoBandEdgeTR[24] = 7;
1181
- isoBandEdgeRT[146] = isoBandEdgeBR[146] = 8;
1182
- isoBandEdgeBL[146] = isoBandEdgeTR[146] = 7;
1183
- isoBandEdgeRB[6] = isoBandEdgeLT[6] = 15;
1184
- isoBandEdgeBR[6] = isoBandEdgeLB[6] = 16;
1185
- isoBandEdgeRB[164] = isoBandEdgeLT[164] = 15;
1186
- isoBandEdgeBR[164] = isoBandEdgeLB[164] = 16;
1187
- isoBandEdgeBL[129] = isoBandEdgeTR[129] = 7;
1188
- isoBandEdgeLB[129] = isoBandEdgeTL[129] = 20;
1189
- isoBandEdgeBL[41] = isoBandEdgeTR[41] = 7;
1190
- isoBandEdgeLB[41] = isoBandEdgeTL[41] = 20;
1191
- isoBandEdgeBR[66] = isoBandEdgeTL[66] = 2;
1192
- isoBandEdgeBL[66] = isoBandEdgeLT[66] = 19;
1193
- isoBandEdgeBR[104] = isoBandEdgeTL[104] = 2;
1194
- isoBandEdgeBL[104] = isoBandEdgeLT[104] = 19;
1195
- isoBandEdgeRT[144] = isoBandEdgeLB[144] = 10;
1196
- isoBandEdgeLT[144] = isoBandEdgeTR[144] = 23;
1197
- isoBandEdgeRT[26] = isoBandEdgeLB[26] = 10;
1198
- isoBandEdgeLT[26] = isoBandEdgeTR[26] = 23;
1199
- isoBandEdgeRB[36] = isoBandEdgeTR[36] = 5;
1200
- isoBandEdgeBR[36] = isoBandEdgeTL[36] = 2;
1201
- isoBandEdgeRB[134] = isoBandEdgeTR[134] = 5;
1202
- isoBandEdgeBR[134] = isoBandEdgeTL[134] = 2;
1203
- isoBandEdgeRT[9] = isoBandEdgeLB[9] = 10;
1204
- isoBandEdgeRB[9] = isoBandEdgeBL[9] = 13;
1205
- isoBandEdgeRT[161] = isoBandEdgeLB[161] = 10;
1206
- isoBandEdgeRB[161] = isoBandEdgeBL[161] = 13;
1207
- /* hexagon cases */
1208
- isoBandEdgeRB[37] = isoBandEdgeTR[37] = 5;
1209
- isoBandEdgeLB[37] = isoBandEdgeTL[37] = 20;
1210
- isoBandEdgeRB[133] = isoBandEdgeTR[133] = 5;
1211
- isoBandEdgeLB[133] = isoBandEdgeTL[133] = 20;
1212
- isoBandEdgeBR[148] = isoBandEdgeLB[148] = 16;
1213
- isoBandEdgeLT[148] = isoBandEdgeTR[148] = 23;
1214
- isoBandEdgeBR[22] = isoBandEdgeLB[22] = 16;
1215
- isoBandEdgeLT[22] = isoBandEdgeTR[22] = 23;
1216
- isoBandEdgeRT[82] = isoBandEdgeBR[82] = 8;
1217
- isoBandEdgeBL[82] = isoBandEdgeLT[82] = 19;
1218
- isoBandEdgeRT[88] = isoBandEdgeBR[88] = 8;
1219
- isoBandEdgeBL[88] = isoBandEdgeLT[88] = 19;
1220
- isoBandEdgeRT[73] = isoBandEdgeTL[73] = 0;
1221
- isoBandEdgeRB[73] = isoBandEdgeBL[73] = 13;
1222
- isoBandEdgeRT[97] = isoBandEdgeTL[97] = 0;
1223
- isoBandEdgeRB[97] = isoBandEdgeBL[97] = 13;
1224
- isoBandEdgeRT[145] = isoBandEdgeBL[145] = 9;
1225
- isoBandEdgeLB[145] = isoBandEdgeTR[145] = 21;
1226
- isoBandEdgeRT[25] = isoBandEdgeBL[25] = 9;
1227
- isoBandEdgeLB[25] = isoBandEdgeTR[25] = 21;
1228
- isoBandEdgeRB[70] = isoBandEdgeTL[70] = 1;
1229
- isoBandEdgeBR[70] = isoBandEdgeLT[70] = 17;
1230
- isoBandEdgeRB[100] = isoBandEdgeTL[100] = 1;
1231
- isoBandEdgeBR[100] = isoBandEdgeLT[100] = 17;
1232
- /* 8-sided cases */
1233
- isoBandEdgeRT[34] = isoBandEdgeBL[34] = 9;
1234
- isoBandEdgeRB[34] = isoBandEdgeBR[34] = 12;
1235
- isoBandEdgeLB[34] = isoBandEdgeTR[34] = 21;
1236
- isoBandEdgeLT[34] = isoBandEdgeTL[34] = 22;
1237
- isoBandEdgeRT[136] = isoBandEdgeTR[136] = 4;
1238
- isoBandEdgeRB[136] = isoBandEdgeTL[136] = 1;
1239
- isoBandEdgeBR[136] = isoBandEdgeLT[136] = 17;
1240
- isoBandEdgeBL[136] = isoBandEdgeLB[136] = 18;
1241
- isoBandEdgeRT[35] = isoBandEdgeTR[35] = 4;
1242
- isoBandEdgeRB[35] = isoBandEdgeBR[35] = 12;
1243
- isoBandEdgeBL[35] = isoBandEdgeLB[35] = 18;
1244
- isoBandEdgeLT[35] = isoBandEdgeTL[35] = 22;
1245
- /* 6-sided cases */
1246
- isoBandEdgeRT[153] = isoBandEdgeTR[153] = 4;
1247
- isoBandEdgeBL[153] = isoBandEdgeLB[153] = 18;
1248
- isoBandEdgeRB[102] = isoBandEdgeBR[102] = 12;
1249
- isoBandEdgeLT[102] = isoBandEdgeTL[102] = 22;
1250
- isoBandEdgeRT[155] = isoBandEdgeBL[155] = 9;
1251
- isoBandEdgeLB[155] = isoBandEdgeTR[155] = 23;
1252
- isoBandEdgeRB[103] = isoBandEdgeTL[103] = 1;
1253
- isoBandEdgeBR[103] = isoBandEdgeLT[103] = 17;
1254
- /* 7-sided cases */
1255
- isoBandEdgeRT[152] = isoBandEdgeTR[152] = 4;
1256
- isoBandEdgeBR[152] = isoBandEdgeLT[152] = 17;
1257
- isoBandEdgeBL[152] = isoBandEdgeLB[152] = 18;
1258
- isoBandEdgeRT[156] = isoBandEdgeBR[156] = 8;
1259
- isoBandEdgeBL[156] = isoBandEdgeLB[156] = 18;
1260
- isoBandEdgeLT[156] = isoBandEdgeTR[156] = 23;
1261
- isoBandEdgeRT[137] = isoBandEdgeTR[137] = 4;
1262
- isoBandEdgeRB[137] = isoBandEdgeTL[137] = 1;
1263
- isoBandEdgeBL[137] = isoBandEdgeLB[137] = 18;
1264
- isoBandEdgeRT[139] = isoBandEdgeTR[139] = 4;
1265
- isoBandEdgeRB[139] = isoBandEdgeBL[139] = 13;
1266
- isoBandEdgeLB[139] = isoBandEdgeTL[139] = 20;
1267
- isoBandEdgeRT[98] = isoBandEdgeBL[98] = 9;
1268
- isoBandEdgeRB[98] = isoBandEdgeBR[98] = 12;
1269
- isoBandEdgeLT[98] = isoBandEdgeTL[98] = 22;
1270
- isoBandEdgeRT[99] = isoBandEdgeTL[99] = 0;
1271
- isoBandEdgeRB[99] = isoBandEdgeBR[99] = 12;
1272
- isoBandEdgeBL[99] = isoBandEdgeLT[99] = 19;
1273
- isoBandEdgeRB[38] = isoBandEdgeBR[38] = 12;
1274
- isoBandEdgeLB[38] = isoBandEdgeTR[38] = 21;
1275
- isoBandEdgeLT[38] = isoBandEdgeTL[38] = 22;
1276
- isoBandEdgeRB[39] = isoBandEdgeTR[39] = 5;
1277
- isoBandEdgeBR[39] = isoBandEdgeLB[39] = 16;
1278
- isoBandEdgeLT[39] = isoBandEdgeTL[39] = 22;
1279
- /*
1280
- The lookup tables for all different polygons that
1281
- may appear within a grid cell
1282
- */
1283
- var polygon_table = [];
1284
- /* triangle cases */
1285
- polygon_table[1] = polygon_table[169] = p00; /* 2221 || 0001 */
1286
- polygon_table[4] = polygon_table[166] = p01; /* 2212 || 0010 */
1287
- polygon_table[16] = polygon_table[154] = p02; /* 2122 || 0100 */
1288
- polygon_table[64] = polygon_table[106] = p03; /* 1222 || 1000 */
1289
- /* trapezoid cases */
1290
- polygon_table[168] = polygon_table[2] = p04; /* 2220 || 0002 */
1291
- polygon_table[162] = polygon_table[8] = p05; /* 2202 || 0020 */
1292
- polygon_table[138] = polygon_table[32] = p06; /* 2022 || 0200 */
1293
- polygon_table[42] = polygon_table[128] = p07; /* 0222 || 2000 */
1294
- /* rectangle cases */
1295
- polygon_table[5] = polygon_table[165] = p08; /* 0011 || 2211 */
1296
- polygon_table[20] = polygon_table[150] = p09; /* 0110 || 2112 */
1297
- polygon_table[80] = polygon_table[90] = p10; /* 1100 || 1122 */
1298
- polygon_table[65] = polygon_table[105] = p11; /* 1001 || 1221 */
1299
- polygon_table[160] = polygon_table[10] = p12; /* 2200 || 0022 */
1300
- polygon_table[130] = polygon_table[40] = p13; /* 2002 || 0220 */
1301
- /* square case */
1302
- polygon_table[85] = p14; /* 1111 */
1303
- /* pentagon cases */
1304
- polygon_table[101] = polygon_table[69] = p15; /* 1211 || 1011 */
1305
- polygon_table[149] = polygon_table[21] = p16; /* 2111 || 0111 */
1306
- polygon_table[86] = polygon_table[84] = p17; /* 1112 || 1110 */
1307
- polygon_table[89] = polygon_table[81] = p18; /* 1121 || 1101 */
1308
- polygon_table[96] = polygon_table[74] = p19; /* 1200 || 1022 */
1309
- polygon_table[24] = polygon_table[146] = p20; /* 0120 || 2102 */
1310
- polygon_table[6] = polygon_table[164] = p21; /* 0012 || 2210 */
1311
- polygon_table[129] = polygon_table[41] = p22; /* 2001 || 0221 */
1312
- polygon_table[66] = polygon_table[104] = p23; /* 1002 || 1220 */
1313
- polygon_table[144] = polygon_table[26] = p24; /* 2100 || 0122 */
1314
- polygon_table[36] = polygon_table[134] = p25; /* 0210 || 2012 */
1315
- polygon_table[9] = polygon_table[161] = p26; /* 0021 || 2201 */
1316
- /* hexagon cases */
1317
- polygon_table[37] = polygon_table[133] = p27; /* 0211 || 2011 */
1318
- polygon_table[148] = polygon_table[22] = p28; /* 2110 || 0112 */
1319
- polygon_table[82] = polygon_table[88] = p29; /* 1102 || 1120 */
1320
- polygon_table[73] = polygon_table[97] = p30; /* 1021 || 1201 */
1321
- polygon_table[145] = polygon_table[25] = p31; /* 2101 || 0121 */
1322
- polygon_table[70] = polygon_table[100] = p32; /* 1012 || 1210 */
1323
- /* 8-sided cases */
1324
- polygon_table[34] = function (c) {
1325
- return [p07(c), p05(c)];
1326
- }; /* 0202 || 2020 with flipped == 0 */
1327
- polygon_table[35] = p33; /* flipped == 1 state for 0202 and 2020 */
1328
- polygon_table[136] = function (c) {
1329
- return [p06(c), p04(c)];
1330
- }; /* 2020 || 0202 with flipped == 0 */
1331
- /* 6-sided cases */
1332
- polygon_table[153] = function (c) {
1333
- return [p02(c), p00(c)];
1334
- }; /* 0101 with flipped == 0 || 2121 with flipped == 2 */
1335
- polygon_table[102] = function (c) {
1336
- return [p01(c), p03(c)];
1337
- }; /* 1010 with flipped == 0 || 1212 with flipped == 2 */
1338
- polygon_table[155] = p34; /* 0101 with flipped == 1 || 2121 with flipped == 1 */
1339
- polygon_table[103] = p35; /* 1010 with flipped == 1 || 1212 with flipped == 1 */
1340
- /* 7-sided cases */
1341
- polygon_table[152] = function (c) {
1342
- return [p02(c), p04(c)];
1343
- }; /* 2120 with flipped == 2 || 0102 with flipped == 0 */
1344
- polygon_table[156] = p36; /* 2120 with flipped == 1 || 0102 with flipped == 1 */
1345
- polygon_table[137] = function (c) {
1346
- return [p06(c), p00(c)];
1347
- }; /* 2021 with flipped == 2 || 0201 with flipped == 0 */
1348
- polygon_table[139] = p37; /* 2021 with flipped == 1 || 0201 with flipped == 1 */
1349
- polygon_table[98] = function (c) {
1350
- return [p05(c), p03(c)];
1351
- }; /* 1202 with flipped == 2 || 1020 with flipped == 0 */
1352
- polygon_table[99] = p38; /* 1202 with flipped == 1 || 1020 with flipped == 1 */
1353
- polygon_table[38] = function (c) {
1354
- return [p01(c), p07(c)];
1355
- }; /* 0212 with flipped == 2 || 2010 with flipped == 0 */
1356
- polygon_table[39] = p39; /* 0212 with flipped == 1 || 2010 with flipped == 1 */
1357
- /*
1358
- ####################################
1359
- Some small helper functions
1360
- ####################################
1361
- */
1362
- /* assume that x1 == 1 && x0 == 0 */
1363
- function interpolateX(y, y0, y1) {
1364
- return (y - y0) / (y1 - y0);
1365
- }
1366
- function isArray(myArray) {
1367
- return myArray.constructor.toString().indexOf("Array") > -1;
1368
- }
1369
- /*
1370
- ####################################
1371
- Below is the actual Marching Squares implementation
1372
- ####################################
1373
- */
1374
- function computeBandGrid(data, minV, bandwidth) {
1375
- var rows = data.length - 1;
1376
- var cols = data[0].length - 1;
1377
- var BandGrid = { rows: rows, cols: cols, cells: [] };
1378
- var maxV = minV + Math.abs(bandwidth);
1379
- for (var j = 0; j < rows; ++j) {
1380
- BandGrid.cells[j] = [];
1381
- for (var i = 0; i < cols; ++i) {
1382
- /* compose the 4-trit corner representation */
1383
- var cval = 0;
1384
- var tl = data[j + 1][i];
1385
- var tr = data[j + 1][i + 1];
1386
- var br = data[j][i + 1];
1387
- var bl = data[j][i];
1388
- if (isNaN(tl) || isNaN(tr) || isNaN(br) || isNaN(bl)) {
1389
- continue;
1390
- }
1391
- cval |= tl < minV ? 0 : tl > maxV ? 128 : 64;
1392
- cval |= tr < minV ? 0 : tr > maxV ? 32 : 16;
1393
- cval |= br < minV ? 0 : br > maxV ? 8 : 4;
1394
- cval |= bl < minV ? 0 : bl > maxV ? 2 : 1;
1395
- var cval_real = +cval;
1396
- /* resolve ambiguity via averaging */
1397
- var flipped = 0;
1398
- if (cval === 17 /* 0101 */ ||
1399
- cval === 18 /* 0102 */ ||
1400
- cval === 33 /* 0201 */ ||
1401
- cval === 34 /* 0202 */ ||
1402
- cval === 38 /* 0212 */ ||
1403
- cval === 68 /* 1010 */ ||
1404
- cval === 72 /* 1020 */ ||
1405
- cval === 98 /* 1202 */ ||
1406
- cval === 102 /* 1212 */ ||
1407
- cval === 132 /* 2010 */ ||
1408
- cval === 136 /* 2020 */ ||
1409
- cval === 137 /* 2021 */ ||
1410
- cval === 152 /* 2120 */ ||
1411
- cval === 153 /* 2121 */) {
1412
- var average = (tl + tr + br + bl) / 4;
1413
- /* set flipped state */
1414
- flipped = average > maxV ? 2 : average < minV ? 0 : 1;
1415
- /* adjust cval for flipped cases */
1416
- /* 8-sided cases */
1417
- if (cval === 34) {
1418
- if (flipped === 1) {
1419
- cval = 35;
1420
- }
1421
- else if (flipped === 0) {
1422
- cval = 136;
1423
- }
1424
- }
1425
- else if (cval === 136) {
1426
- if (flipped === 1) {
1427
- cval = 35;
1428
- flipped = 4;
1429
- }
1430
- else if (flipped === 0) {
1431
- cval = 34;
1432
- }
1433
- }
1434
- else if (cval === 17) {
1435
- /* 6-sided polygon cases */
1436
- if (flipped === 1) {
1437
- cval = 155;
1438
- flipped = 4;
1439
- }
1440
- else if (flipped === 0) {
1441
- cval = 153;
1442
- }
1443
- }
1444
- else if (cval === 68) {
1445
- if (flipped === 1) {
1446
- cval = 103;
1447
- flipped = 4;
1448
- }
1449
- else if (flipped === 0) {
1450
- cval = 102;
1451
- }
1452
- }
1453
- else if (cval === 153) {
1454
- if (flipped === 1)
1455
- cval = 155;
1456
- }
1457
- else if (cval === 102) {
1458
- if (flipped === 1)
1459
- cval = 103;
1460
- }
1461
- else if (cval === 152) {
1462
- /* 7-sided polygon cases */
1463
- if (flipped < 2) {
1464
- cval = 156;
1465
- flipped = 1;
1466
- }
1467
- }
1468
- else if (cval === 137) {
1469
- if (flipped < 2) {
1470
- cval = 139;
1471
- flipped = 1;
1472
- }
1473
- }
1474
- else if (cval === 98) {
1475
- if (flipped < 2) {
1476
- cval = 99;
1477
- flipped = 1;
1478
- }
1479
- }
1480
- else if (cval === 38) {
1481
- if (flipped < 2) {
1482
- cval = 39;
1483
- flipped = 1;
1484
- }
1485
- }
1486
- else if (cval === 18) {
1487
- if (flipped > 0) {
1488
- cval = 156;
1489
- flipped = 4;
1490
- }
1491
- else {
1492
- cval = 152;
1493
- }
1494
- }
1495
- else if (cval === 33) {
1496
- if (flipped > 0) {
1497
- cval = 139;
1498
- flipped = 4;
1499
- }
1500
- else {
1501
- cval = 137;
1502
- }
1503
- }
1504
- else if (cval === 72) {
1505
- if (flipped > 0) {
1506
- cval = 99;
1507
- flipped = 4;
1508
- }
1509
- else {
1510
- cval = 98;
1511
- }
1512
- }
1513
- else if (cval === 132) {
1514
- if (flipped > 0) {
1515
- cval = 39;
1516
- flipped = 4;
1517
- }
1518
- else {
1519
- cval = 38;
1520
- }
1521
- }
1522
- }
1523
- /* add cell to BandGrid if it contains at least one polygon-side */
1524
- if (cval != 0 && cval != 170) {
1525
- var topleft, topright, bottomleft, bottomright, righttop, rightbottom, lefttop, leftbottom;
1526
- topleft = topright = bottomleft = bottomright = righttop = rightbottom = lefttop = leftbottom = 0.5;
1527
- var edges = [];
1528
- /* do interpolation here */
1529
- /* 1st Triangles */
1530
- if (cval === 1) {
1531
- /* 0001 */
1532
- bottomleft = 1 - interpolateX(minV, br, bl);
1533
- leftbottom = 1 - interpolateX(minV, tl, bl);
1534
- edges.push(isoBandEdgeBL[cval]);
1535
- }
1536
- else if (cval === 169) {
1537
- /* 2221 */
1538
- bottomleft = interpolateX(maxV, bl, br);
1539
- leftbottom = interpolateX(maxV, bl, tl);
1540
- edges.push(isoBandEdgeBL[cval]);
1541
- }
1542
- else if (cval === 4) {
1543
- /* 0010 */
1544
- rightbottom = 1 - interpolateX(minV, tr, br);
1545
- bottomright = interpolateX(minV, bl, br);
1546
- edges.push(isoBandEdgeRB[cval]);
1547
- }
1548
- else if (cval === 166) {
1549
- /* 2212 */
1550
- rightbottom = interpolateX(maxV, br, tr);
1551
- bottomright = 1 - interpolateX(maxV, br, bl);
1552
- edges.push(isoBandEdgeRB[cval]);
1553
- }
1554
- else if (cval === 16) {
1555
- /* 0100 */
1556
- righttop = interpolateX(minV, br, tr);
1557
- topright = interpolateX(minV, tl, tr);
1558
- edges.push(isoBandEdgeRT[cval]);
1559
- }
1560
- else if (cval === 154) {
1561
- /* 2122 */
1562
- righttop = 1 - interpolateX(maxV, tr, br);
1563
- topright = 1 - interpolateX(maxV, tr, tl);
1564
- edges.push(isoBandEdgeRT[cval]);
1565
- }
1566
- else if (cval === 64) {
1567
- /* 1000 */
1568
- lefttop = interpolateX(minV, bl, tl);
1569
- topleft = 1 - interpolateX(minV, tr, tl);
1570
- edges.push(isoBandEdgeLT[cval]);
1571
- }
1572
- else if (cval === 106) {
1573
- /* 1222 */
1574
- lefttop = 1 - interpolateX(maxV, tl, bl);
1575
- topleft = interpolateX(maxV, tl, tr);
1576
- edges.push(isoBandEdgeLT[cval]);
1577
- }
1578
- else if (cval === 168) {
1579
- /* 2nd Trapezoids */
1580
- /* 2220 */
1581
- bottomright = interpolateX(maxV, bl, br);
1582
- bottomleft = interpolateX(minV, bl, br);
1583
- leftbottom = interpolateX(minV, bl, tl);
1584
- lefttop = interpolateX(maxV, bl, tl);
1585
- edges.push(isoBandEdgeBR[cval]);
1586
- edges.push(isoBandEdgeBL[cval]);
1587
- }
1588
- else if (cval === 2) {
1589
- /* 0002 */
1590
- bottomright = 1 - interpolateX(minV, br, bl);
1591
- bottomleft = 1 - interpolateX(maxV, br, bl);
1592
- leftbottom = 1 - interpolateX(maxV, tl, bl);
1593
- lefttop = 1 - interpolateX(minV, tl, bl);
1594
- edges.push(isoBandEdgeBR[cval]);
1595
- edges.push(isoBandEdgeBL[cval]);
1596
- }
1597
- else if (cval === 162) {
1598
- /* 2202 */
1599
- righttop = interpolateX(maxV, br, tr);
1600
- rightbottom = interpolateX(minV, br, tr);
1601
- bottomright = 1 - interpolateX(minV, br, bl);
1602
- bottomleft = 1 - interpolateX(maxV, br, bl);
1603
- edges.push(isoBandEdgeBR[cval]);
1604
- edges.push(isoBandEdgeBL[cval]);
1605
- }
1606
- else if (cval === 8) {
1607
- /* 0020 */
1608
- righttop = 1 - interpolateX(minV, tr, br);
1609
- rightbottom = 1 - interpolateX(maxV, tr, br);
1610
- bottomright = interpolateX(maxV, bl, br);
1611
- bottomleft = interpolateX(minV, bl, br);
1612
- edges.push(isoBandEdgeRT[cval]);
1613
- edges.push(isoBandEdgeRB[cval]);
1614
- }
1615
- else if (cval === 138) {
1616
- /* 2022 */
1617
- righttop = 1 - interpolateX(minV, tr, br);
1618
- rightbottom = 1 - interpolateX(maxV, tr, br);
1619
- topleft = 1 - interpolateX(maxV, tr, tl);
1620
- topright = 1 - interpolateX(minV, tr, tl);
1621
- edges.push(isoBandEdgeRT[cval]);
1622
- edges.push(isoBandEdgeRB[cval]);
1623
- }
1624
- else if (cval === 32) {
1625
- /* 0200 */
1626
- righttop = interpolateX(maxV, br, tr);
1627
- rightbottom = interpolateX(minV, br, tr);
1628
- topleft = interpolateX(minV, tl, tr);
1629
- topright = interpolateX(maxV, tl, tr);
1630
- edges.push(isoBandEdgeRT[cval]);
1631
- edges.push(isoBandEdgeRB[cval]);
1632
- }
1633
- else if (cval === 42) {
1634
- /* 0222 */
1635
- leftbottom = 1 - interpolateX(maxV, tl, bl);
1636
- lefttop = 1 - interpolateX(minV, tl, bl);
1637
- topleft = interpolateX(minV, tl, tr);
1638
- topright = interpolateX(maxV, tl, tr);
1639
- edges.push(isoBandEdgeLB[cval]);
1640
- edges.push(isoBandEdgeLT[cval]);
1641
- }
1642
- else if (cval === 128) {
1643
- /* 2000 */
1644
- leftbottom = interpolateX(minV, bl, tl);
1645
- lefttop = interpolateX(maxV, bl, tl);
1646
- topleft = 1 - interpolateX(maxV, tr, tl);
1647
- topright = 1 - interpolateX(minV, tr, tl);
1648
- edges.push(isoBandEdgeLB[cval]);
1649
- edges.push(isoBandEdgeLT[cval]);
1650
- }
1651
- /* 3rd rectangle cases */
1652
- if (cval === 5) {
1653
- /* 0011 */
1654
- rightbottom = 1 - interpolateX(minV, tr, br);
1655
- leftbottom = 1 - interpolateX(minV, tl, bl);
1656
- edges.push(isoBandEdgeRB[cval]);
1657
- }
1658
- else if (cval === 165) {
1659
- /* 2211 */
1660
- rightbottom = interpolateX(maxV, br, tr);
1661
- leftbottom = interpolateX(maxV, bl, tl);
1662
- edges.push(isoBandEdgeRB[cval]);
1663
- }
1664
- else if (cval === 20) {
1665
- /* 0110 */
1666
- bottomright = interpolateX(minV, bl, br);
1667
- topright = interpolateX(minV, tl, tr);
1668
- edges.push(isoBandEdgeBR[cval]);
1669
- }
1670
- else if (cval === 150) {
1671
- /* 2112 */
1672
- bottomright = 1 - interpolateX(maxV, br, bl);
1673
- topright = 1 - interpolateX(maxV, tr, tl);
1674
- edges.push(isoBandEdgeBR[cval]);
1675
- }
1676
- else if (cval === 80) {
1677
- /* 1100 */
1678
- righttop = interpolateX(minV, br, tr);
1679
- lefttop = interpolateX(minV, bl, tl);
1680
- edges.push(isoBandEdgeRT[cval]);
1681
- }
1682
- else if (cval === 90) {
1683
- /* 1122 */
1684
- righttop = 1 - interpolateX(maxV, tr, br);
1685
- lefttop = 1 - interpolateX(maxV, tl, bl);
1686
- edges.push(isoBandEdgeRT[cval]);
1687
- }
1688
- else if (cval === 65) {
1689
- /* 1001 */
1690
- bottomleft = 1 - interpolateX(minV, br, bl);
1691
- topleft = 1 - interpolateX(minV, tr, tl);
1692
- edges.push(isoBandEdgeBL[cval]);
1693
- }
1694
- else if (cval === 105) {
1695
- /* 1221 */
1696
- bottomleft = interpolateX(maxV, bl, br);
1697
- topleft = interpolateX(maxV, tl, tr);
1698
- edges.push(isoBandEdgeBL[cval]);
1699
- }
1700
- else if (cval === 160) {
1701
- /* 2200 */
1702
- righttop = interpolateX(maxV, br, tr);
1703
- rightbottom = interpolateX(minV, br, tr);
1704
- leftbottom = interpolateX(minV, bl, tl);
1705
- lefttop = interpolateX(maxV, bl, tl);
1706
- edges.push(isoBandEdgeRT[cval]);
1707
- edges.push(isoBandEdgeRB[cval]);
1708
- }
1709
- else if (cval === 10) {
1710
- /* 0022 */
1711
- righttop = 1 - interpolateX(minV, tr, br);
1712
- rightbottom = 1 - interpolateX(maxV, tr, br);
1713
- leftbottom = 1 - interpolateX(maxV, tl, bl);
1714
- lefttop = 1 - interpolateX(minV, tl, bl);
1715
- edges.push(isoBandEdgeRT[cval]);
1716
- edges.push(isoBandEdgeRB[cval]);
1717
- }
1718
- else if (cval === 130) {
1719
- /* 2002 */
1720
- bottomright = 1 - interpolateX(minV, br, bl);
1721
- bottomleft = 1 - interpolateX(maxV, br, bl);
1722
- topleft = 1 - interpolateX(maxV, tr, tl);
1723
- topright = 1 - interpolateX(minV, tr, tl);
1724
- edges.push(isoBandEdgeBR[cval]);
1725
- edges.push(isoBandEdgeBL[cval]);
1726
- }
1727
- else if (cval === 40) {
1728
- /* 0220 */
1729
- bottomright = interpolateX(maxV, bl, br);
1730
- bottomleft = interpolateX(minV, bl, br);
1731
- topleft = interpolateX(minV, tl, tr);
1732
- topright = interpolateX(maxV, tl, tr);
1733
- edges.push(isoBandEdgeBR[cval]);
1734
- edges.push(isoBandEdgeBL[cval]);
1735
- }
1736
- else if (cval === 101) {
1737
- /* 4th single pentagon cases */
1738
- /* 1211 */
1739
- rightbottom = interpolateX(maxV, br, tr);
1740
- topleft = interpolateX(maxV, tl, tr);
1741
- edges.push(isoBandEdgeRB[cval]);
1742
- }
1743
- else if (cval === 69) {
1744
- /* 1011 */
1745
- rightbottom = 1 - interpolateX(minV, tr, br);
1746
- topleft = 1 - interpolateX(minV, tr, tl);
1747
- edges.push(isoBandEdgeRB[cval]);
1748
- }
1749
- else if (cval === 149) {
1750
- /* 2111 */
1751
- leftbottom = interpolateX(maxV, bl, tl);
1752
- topright = 1 - interpolateX(maxV, tr, tl);
1753
- edges.push(isoBandEdgeLB[cval]);
1754
- }
1755
- else if (cval === 21) {
1756
- /* 0111 */
1757
- leftbottom = 1 - interpolateX(minV, tl, bl);
1758
- topright = interpolateX(minV, tl, tr);
1759
- edges.push(isoBandEdgeLB[cval]);
1760
- }
1761
- else if (cval === 86) {
1762
- /* 1112 */
1763
- bottomright = 1 - interpolateX(maxV, br, bl);
1764
- lefttop = 1 - interpolateX(maxV, tl, bl);
1765
- edges.push(isoBandEdgeBR[cval]);
1766
- }
1767
- else if (cval === 84) {
1768
- /* 1110 */
1769
- bottomright = interpolateX(minV, bl, br);
1770
- lefttop = interpolateX(minV, bl, tl);
1771
- edges.push(isoBandEdgeBR[cval]);
1772
- }
1773
- else if (cval === 89) {
1774
- /* 1121 */
1775
- righttop = 1 - interpolateX(maxV, tr, br);
1776
- bottomleft = interpolateX(maxV, bl, br);
1777
- edges.push(isoBandEdgeBL[cval]);
1778
- }
1779
- else if (cval === 81) {
1780
- /* 1101 */
1781
- righttop = interpolateX(minV, br, tr);
1782
- bottomleft = 1 - interpolateX(minV, br, bl);
1783
- edges.push(isoBandEdgeBL[cval]);
1784
- }
1785
- else if (cval === 96) {
1786
- /* 1200 */
1787
- righttop = interpolateX(maxV, br, tr);
1788
- rightbottom = interpolateX(minV, br, tr);
1789
- lefttop = interpolateX(minV, bl, tl);
1790
- topleft = interpolateX(maxV, tl, tr);
1791
- edges.push(isoBandEdgeRT[cval]);
1792
- edges.push(isoBandEdgeRB[cval]);
1793
- }
1794
- else if (cval === 74) {
1795
- /* 1022 */
1796
- righttop = 1 - interpolateX(minV, tr, br);
1797
- rightbottom = 1 - interpolateX(maxV, tr, br);
1798
- lefttop = 1 - interpolateX(maxV, tl, bl);
1799
- topleft = 1 - interpolateX(minV, tr, tl);
1800
- edges.push(isoBandEdgeRT[cval]);
1801
- edges.push(isoBandEdgeRB[cval]);
1802
- }
1803
- else if (cval === 24) {
1804
- /* 0120 */
1805
- righttop = 1 - interpolateX(maxV, tr, br);
1806
- bottomright = interpolateX(maxV, bl, br);
1807
- bottomleft = interpolateX(minV, bl, br);
1808
- topright = interpolateX(minV, tl, tr);
1809
- edges.push(isoBandEdgeRT[cval]);
1810
- edges.push(isoBandEdgeBL[cval]);
1811
- }
1812
- else if (cval === 146) {
1813
- /* 2102 */
1814
- righttop = interpolateX(minV, br, tr);
1815
- bottomright = 1 - interpolateX(minV, br, bl);
1816
- bottomleft = 1 - interpolateX(maxV, br, bl);
1817
- topright = 1 - interpolateX(maxV, tr, tl);
1818
- edges.push(isoBandEdgeRT[cval]);
1819
- edges.push(isoBandEdgeBL[cval]);
1820
- }
1821
- else if (cval === 6) {
1822
- /* 0012 */
1823
- rightbottom = 1 - interpolateX(minV, tr, br);
1824
- bottomright = 1 - interpolateX(maxV, br, bl);
1825
- leftbottom = 1 - interpolateX(maxV, tl, bl);
1826
- lefttop = 1 - interpolateX(minV, tl, bl);
1827
- edges.push(isoBandEdgeRB[cval]);
1828
- edges.push(isoBandEdgeBR[cval]);
1829
- }
1830
- else if (cval === 164) {
1831
- /* 2210 */
1832
- rightbottom = interpolateX(maxV, br, tr);
1833
- bottomright = interpolateX(minV, bl, br);
1834
- leftbottom = interpolateX(minV, bl, tl);
1835
- lefttop = interpolateX(maxV, bl, tl);
1836
- edges.push(isoBandEdgeRB[cval]);
1837
- edges.push(isoBandEdgeBR[cval]);
1838
- }
1839
- else if (cval === 129) {
1840
- /* 2001 */
1841
- bottomleft = 1 - interpolateX(minV, br, bl);
1842
- leftbottom = interpolateX(maxV, bl, tl);
1843
- topleft = 1 - interpolateX(maxV, tr, tl);
1844
- topright = 1 - interpolateX(minV, tr, tl);
1845
- edges.push(isoBandEdgeBL[cval]);
1846
- edges.push(isoBandEdgeLB[cval]);
1847
- }
1848
- else if (cval === 41) {
1849
- /* 0221 */
1850
- bottomleft = interpolateX(maxV, bl, br);
1851
- leftbottom = 1 - interpolateX(minV, tl, bl);
1852
- topleft = interpolateX(minV, tl, tr);
1853
- topright = interpolateX(maxV, tl, tr);
1854
- edges.push(isoBandEdgeBL[cval]);
1855
- edges.push(isoBandEdgeLB[cval]);
1856
- }
1857
- else if (cval === 66) {
1858
- /* 1002 */
1859
- bottomright = 1 - interpolateX(minV, br, bl);
1860
- bottomleft = 1 - interpolateX(maxV, br, bl);
1861
- lefttop = 1 - interpolateX(maxV, tl, bl);
1862
- topleft = 1 - interpolateX(minV, tr, tl);
1863
- edges.push(isoBandEdgeBR[cval]);
1864
- edges.push(isoBandEdgeBL[cval]);
1865
- }
1866
- else if (cval === 104) {
1867
- /* 1220 */
1868
- bottomright = interpolateX(maxV, bl, br);
1869
- bottomleft = interpolateX(minV, bl, br);
1870
- lefttop = interpolateX(minV, bl, tl);
1871
- topleft = interpolateX(maxV, tl, tr);
1872
- edges.push(isoBandEdgeBL[cval]);
1873
- edges.push(isoBandEdgeTL[cval]);
1874
- }
1875
- else if (cval === 144) {
1876
- /* 2100 */
1877
- righttop = interpolateX(minV, br, tr);
1878
- leftbottom = interpolateX(minV, bl, tl);
1879
- lefttop = interpolateX(maxV, bl, tl);
1880
- topright = 1 - interpolateX(maxV, tr, tl);
1881
- edges.push(isoBandEdgeRT[cval]);
1882
- edges.push(isoBandEdgeLT[cval]);
1883
- }
1884
- else if (cval === 26) {
1885
- /* 0122 */
1886
- righttop = 1 - interpolateX(maxV, tr, br);
1887
- leftbottom = 1 - interpolateX(maxV, tl, bl);
1888
- lefttop = 1 - interpolateX(minV, tl, bl);
1889
- topright = interpolateX(minV, tl, tr);
1890
- edges.push(isoBandEdgeRT[cval]);
1891
- edges.push(isoBandEdgeLT[cval]);
1892
- }
1893
- else if (cval === 36) {
1894
- /* 0210 */
1895
- rightbottom = interpolateX(maxV, br, tr);
1896
- bottomright = interpolateX(minV, bl, br);
1897
- topleft = interpolateX(minV, tl, tr);
1898
- topright = interpolateX(maxV, tl, tr);
1899
- edges.push(isoBandEdgeRB[cval]);
1900
- edges.push(isoBandEdgeBR[cval]);
1901
- }
1902
- else if (cval === 134) {
1903
- /* 2012 */
1904
- rightbottom = 1 - interpolateX(minV, tr, br);
1905
- bottomright = 1 - interpolateX(maxV, br, bl);
1906
- topleft = 1 - interpolateX(maxV, tr, tl);
1907
- topright = 1 - interpolateX(minV, tr, tl);
1908
- edges.push(isoBandEdgeRB[cval]);
1909
- edges.push(isoBandEdgeBR[cval]);
1910
- }
1911
- else if (cval === 9) {
1912
- /* 0021 */
1913
- righttop = 1 - interpolateX(minV, tr, br);
1914
- rightbottom = 1 - interpolateX(maxV, tr, br);
1915
- bottomleft = interpolateX(maxV, bl, br);
1916
- leftbottom = 1 - interpolateX(minV, tl, bl);
1917
- edges.push(isoBandEdgeRT[cval]);
1918
- edges.push(isoBandEdgeRB[cval]);
1919
- }
1920
- else if (cval === 161) {
1921
- /* 2201 */
1922
- righttop = interpolateX(maxV, br, tr);
1923
- rightbottom = interpolateX(minV, br, tr);
1924
- bottomleft = 1 - interpolateX(minV, br, bl);
1925
- leftbottom = interpolateX(maxV, bl, tl);
1926
- edges.push(isoBandEdgeRT[cval]);
1927
- edges.push(isoBandEdgeRB[cval]);
1928
- }
1929
- else if (cval === 37) {
1930
- /* 5th single hexagon cases */
1931
- /* 0211 */
1932
- rightbottom = interpolateX(maxV, br, tr);
1933
- leftbottom = 1 - interpolateX(minV, tl, bl);
1934
- topleft = interpolateX(minV, tl, tr);
1935
- topright = interpolateX(maxV, tl, tr);
1936
- edges.push(isoBandEdgeRB[cval]);
1937
- edges.push(isoBandEdgeLB[cval]);
1938
- }
1939
- else if (cval === 133) {
1940
- /* 2011 */
1941
- rightbottom = 1 - interpolateX(minV, tr, br);
1942
- leftbottom = interpolateX(maxV, bl, tl);
1943
- topleft = 1 - interpolateX(maxV, tr, tl);
1944
- topright = 1 - interpolateX(minV, tr, tl);
1945
- edges.push(isoBandEdgeRB[cval]);
1946
- edges.push(isoBandEdgeLB[cval]);
1947
- }
1948
- else if (cval === 148) {
1949
- /* 2110 */
1950
- bottomright = interpolateX(minV, bl, br);
1951
- leftbottom = interpolateX(minV, bl, tl);
1952
- lefttop = interpolateX(maxV, bl, tl);
1953
- topright = 1 - interpolateX(maxV, tr, tl);
1954
- edges.push(isoBandEdgeBR[cval]);
1955
- edges.push(isoBandEdgeLT[cval]);
1956
- }
1957
- else if (cval === 22) {
1958
- /* 0112 */
1959
- bottomright = 1 - interpolateX(maxV, br, bl);
1960
- leftbottom = 1 - interpolateX(maxV, tl, bl);
1961
- lefttop = 1 - interpolateX(minV, tl, bl);
1962
- topright = interpolateX(minV, tl, tr);
1963
- edges.push(isoBandEdgeBR[cval]);
1964
- edges.push(isoBandEdgeLT[cval]);
1965
- }
1966
- else if (cval === 82) {
1967
- /* 1102 */
1968
- righttop = interpolateX(minV, br, tr);
1969
- bottomright = 1 - interpolateX(minV, br, bl);
1970
- bottomleft = 1 - interpolateX(maxV, br, bl);
1971
- lefttop = 1 - interpolateX(maxV, tl, bl);
1972
- edges.push(isoBandEdgeRT[cval]);
1973
- edges.push(isoBandEdgeBL[cval]);
1974
- }
1975
- else if (cval === 88) {
1976
- /* 1120 */
1977
- righttop = 1 - interpolateX(maxV, tr, br);
1978
- bottomright = interpolateX(maxV, bl, br);
1979
- bottomleft = interpolateX(minV, bl, br);
1980
- lefttop = interpolateX(minV, bl, tl);
1981
- edges.push(isoBandEdgeRT[cval]);
1982
- edges.push(isoBandEdgeBL[cval]);
1983
- }
1984
- else if (cval === 73) {
1985
- /* 1021 */
1986
- righttop = 1 - interpolateX(minV, tr, br);
1987
- rightbottom = 1 - interpolateX(maxV, tr, br);
1988
- bottomleft = interpolateX(maxV, bl, br);
1989
- topleft = 1 - interpolateX(minV, tr, tl);
1990
- edges.push(isoBandEdgeRT[cval]);
1991
- edges.push(isoBandEdgeRB[cval]);
1992
- }
1993
- else if (cval === 97) {
1994
- /* 1201 */
1995
- righttop = interpolateX(maxV, br, tr);
1996
- rightbottom = interpolateX(minV, br, tr);
1997
- bottomleft = 1 - interpolateX(minV, br, bl);
1998
- topleft = interpolateX(maxV, tl, tr);
1999
- edges.push(isoBandEdgeRT[cval]);
2000
- edges.push(isoBandEdgeRB[cval]);
2001
- }
2002
- else if (cval === 145) {
2003
- /* 2101 */
2004
- righttop = interpolateX(minV, br, tr);
2005
- bottomleft = 1 - interpolateX(minV, br, bl);
2006
- leftbottom = interpolateX(maxV, bl, tl);
2007
- topright = 1 - interpolateX(maxV, tr, tl);
2008
- edges.push(isoBandEdgeRT[cval]);
2009
- edges.push(isoBandEdgeLB[cval]);
2010
- }
2011
- else if (cval === 25) {
2012
- /* 0121 */
2013
- righttop = 1 - interpolateX(maxV, tr, br);
2014
- bottomleft = interpolateX(maxV, bl, br);
2015
- leftbottom = 1 - interpolateX(minV, tl, bl);
2016
- topright = interpolateX(minV, tl, tr);
2017
- edges.push(isoBandEdgeRT[cval]);
2018
- edges.push(isoBandEdgeLB[cval]);
2019
- }
2020
- else if (cval === 70) {
2021
- /* 1012 */
2022
- rightbottom = 1 - interpolateX(minV, tr, br);
2023
- bottomright = 1 - interpolateX(maxV, br, bl);
2024
- lefttop = 1 - interpolateX(maxV, tl, bl);
2025
- topleft = 1 - interpolateX(minV, tr, tl);
2026
- edges.push(isoBandEdgeRB[cval]);
2027
- edges.push(isoBandEdgeBR[cval]);
2028
- }
2029
- else if (cval === 100) {
2030
- /* 1210 */
2031
- rightbottom = interpolateX(maxV, br, tr);
2032
- bottomright = interpolateX(minV, bl, br);
2033
- lefttop = interpolateX(minV, bl, tl);
2034
- topleft = interpolateX(maxV, tl, tr);
2035
- edges.push(isoBandEdgeRB[cval]);
2036
- edges.push(isoBandEdgeBR[cval]);
2037
- }
2038
- else if (cval === 34) {
2039
- /* 8-sided cases */
2040
- /* 0202 || 2020 with flipped == 0 */
2041
- if (flipped === 0) {
2042
- righttop = 1 - interpolateX(minV, tr, br);
2043
- rightbottom = 1 - interpolateX(maxV, tr, br);
2044
- bottomright = interpolateX(maxV, bl, br);
2045
- bottomleft = interpolateX(minV, bl, br);
2046
- leftbottom = interpolateX(minV, bl, tl);
2047
- lefttop = interpolateX(maxV, bl, tl);
2048
- topleft = 1 - interpolateX(maxV, tr, tl);
2049
- topright = 1 - interpolateX(minV, tr, tl);
2050
- }
2051
- else {
2052
- righttop = interpolateX(maxV, br, tr);
2053
- rightbottom = interpolateX(minV, br, tr);
2054
- bottomright = 1 - interpolateX(minV, br, bl);
2055
- bottomleft = 1 - interpolateX(maxV, br, bl);
2056
- leftbottom = 1 - interpolateX(maxV, tl, bl);
2057
- lefttop = 1 - interpolateX(minV, tl, bl);
2058
- topleft = interpolateX(minV, tl, tr);
2059
- topright = interpolateX(maxV, tl, tr);
2060
- }
2061
- edges.push(isoBandEdgeRT[cval]);
2062
- edges.push(isoBandEdgeRB[cval]);
2063
- edges.push(isoBandEdgeLB[cval]);
2064
- edges.push(isoBandEdgeLT[cval]);
2065
- }
2066
- else if (cval === 35) {
2067
- /* flipped == 1 state for 0202, and 2020 with flipped == 4*/
2068
- if (flipped === 4) {
2069
- righttop = 1 - interpolateX(minV, tr, br);
2070
- rightbottom = 1 - interpolateX(maxV, tr, br);
2071
- bottomright = interpolateX(maxV, bl, br);
2072
- bottomleft = interpolateX(minV, bl, br);
2073
- leftbottom = interpolateX(minV, bl, tl);
2074
- lefttop = interpolateX(maxV, bl, tl);
2075
- topleft = 1 - interpolateX(maxV, tr, tl);
2076
- topright = 1 - interpolateX(minV, tr, tl);
2077
- }
2078
- else {
2079
- righttop = interpolateX(maxV, br, tr);
2080
- rightbottom = interpolateX(minV, br, tr);
2081
- bottomright = 1 - interpolateX(minV, br, bl);
2082
- bottomleft = 1 - interpolateX(maxV, br, bl);
2083
- leftbottom = 1 - interpolateX(maxV, tl, bl);
2084
- lefttop = 1 - interpolateX(minV, tl, bl);
2085
- topleft = interpolateX(minV, tl, tr);
2086
- topright = interpolateX(maxV, tl, tr);
2087
- }
2088
- edges.push(isoBandEdgeRT[cval]);
2089
- edges.push(isoBandEdgeRB[cval]);
2090
- edges.push(isoBandEdgeBL[cval]);
2091
- edges.push(isoBandEdgeLT[cval]);
2092
- }
2093
- else if (cval === 136) {
2094
- /* 2020 || 0202 with flipped == 0 */
2095
- if (flipped === 0) {
2096
- righttop = interpolateX(maxV, br, tr);
2097
- rightbottom = interpolateX(minV, br, tr);
2098
- bottomright = 1 - interpolateX(minV, br, bl);
2099
- bottomleft = 1 - interpolateX(maxV, br, bl);
2100
- leftbottom = 1 - interpolateX(maxV, tl, bl);
2101
- lefttop = 1 - interpolateX(minV, tl, bl);
2102
- topleft = interpolateX(minV, tl, tr);
2103
- topright = interpolateX(maxV, tl, tr);
2104
- }
2105
- else {
2106
- righttop = 1 - interpolateX(minV, tr, br);
2107
- rightbottom = 1 - interpolateX(maxV, tr, br);
2108
- bottomright = interpolateX(maxV, bl, br);
2109
- bottomleft = interpolateX(minV, bl, br);
2110
- leftbottom = interpolateX(minV, bl, tl);
2111
- lefttop = interpolateX(maxV, bl, tl);
2112
- topleft = 1 - interpolateX(maxV, tr, tl);
2113
- topright = 1 - interpolateX(minV, tr, tl);
2114
- }
2115
- edges.push(isoBandEdgeRT[cval]);
2116
- edges.push(isoBandEdgeRB[cval]);
2117
- edges.push(isoBandEdgeLB[cval]);
2118
- edges.push(isoBandEdgeLT[cval]);
2119
- }
2120
- else if (cval === 153) {
2121
- /* 6-sided polygon cases */
2122
- /* 0101 with flipped == 0 || 2121 with flipped == 2 */
2123
- if (flipped === 0) {
2124
- righttop = interpolateX(minV, br, tr);
2125
- bottomleft = 1 - interpolateX(minV, br, bl);
2126
- leftbottom = 1 - interpolateX(minV, tl, bl);
2127
- topright = interpolateX(minV, tl, tr);
2128
- }
2129
- else {
2130
- righttop = 1 - interpolateX(maxV, tr, br);
2131
- bottomleft = interpolateX(maxV, bl, br);
2132
- leftbottom = interpolateX(maxV, bl, tl);
2133
- topright = 1 - interpolateX(maxV, tr, tl);
2134
- }
2135
- edges.push(isoBandEdgeRT[cval]);
2136
- edges.push(isoBandEdgeBL[cval]);
2137
- }
2138
- else if (cval === 102) {
2139
- /* 1010 with flipped == 0 || 1212 with flipped == 2 */
2140
- if (flipped === 0) {
2141
- rightbottom = 1 - interpolateX(minV, tr, br);
2142
- bottomright = interpolateX(minV, bl, br);
2143
- lefttop = interpolateX(minV, bl, tl);
2144
- topleft = 1 - interpolateX(minV, tr, tl);
2145
- }
2146
- else {
2147
- rightbottom = interpolateX(maxV, br, tr);
2148
- bottomright = 1 - interpolateX(maxV, br, bl);
2149
- lefttop = 1 - interpolateX(maxV, tl, bl);
2150
- topleft = interpolateX(maxV, tl, tr);
2151
- }
2152
- edges.push(isoBandEdgeRB[cval]);
2153
- edges.push(isoBandEdgeLT[cval]);
2154
- }
2155
- else if (cval === 155) {
2156
- /* 0101 with flipped == 4 || 2121 with flipped == 1 */
2157
- if (flipped === 4) {
2158
- righttop = interpolateX(minV, br, tr);
2159
- bottomleft = 1 - interpolateX(minV, br, bl);
2160
- leftbottom = 1 - interpolateX(minV, tl, bl);
2161
- topright = interpolateX(minV, tl, tr);
2162
- }
2163
- else {
2164
- righttop = 1 - interpolateX(maxV, tr, br);
2165
- bottomleft = interpolateX(maxV, bl, br);
2166
- leftbottom = interpolateX(maxV, bl, tl);
2167
- topright = 1 - interpolateX(maxV, tr, tl);
2168
- }
2169
- edges.push(isoBandEdgeRT[cval]);
2170
- edges.push(isoBandEdgeLB[cval]);
2171
- }
2172
- else if (cval === 103) {
2173
- /* 1010 with flipped == 4 || 1212 with flipped == 1 */
2174
- if (flipped === 4) {
2175
- rightbottom = 1 - interpolateX(minV, tr, br);
2176
- bottomright = interpolateX(minV, bl, br);
2177
- lefttop = interpolateX(minV, bl, tl);
2178
- topleft = 1 - interpolateX(minV, tr, tl);
2179
- }
2180
- else {
2181
- rightbottom = interpolateX(maxV, br, tr);
2182
- bottomright = 1 - interpolateX(maxV, br, bl);
2183
- lefttop = 1 - interpolateX(maxV, tl, bl);
2184
- topleft = interpolateX(maxV, tl, tr);
2185
- }
2186
- edges.push(isoBandEdgeRB[cval]);
2187
- edges.push(isoBandEdgeBR[cval]);
2188
- }
2189
- else if (cval === 152) {
2190
- /* 7-sided polygon cases */
2191
- /* 2120 with flipped == 2 || 0102 with flipped == 0 */
2192
- if (flipped === 0) {
2193
- righttop = interpolateX(minV, br, tr);
2194
- bottomright = 1 - interpolateX(minV, br, bl);
2195
- bottomleft = 1 - interpolateX(maxV, br, bl);
2196
- leftbottom = 1 - interpolateX(maxV, tl, bl);
2197
- lefttop = 1 - interpolateX(minV, tl, bl);
2198
- topright = interpolateX(minV, tl, tr);
2199
- }
2200
- else {
2201
- righttop = 1 - interpolateX(maxV, tr, br);
2202
- bottomright = interpolateX(maxV, bl, br);
2203
- bottomleft = interpolateX(minV, bl, br);
2204
- leftbottom = interpolateX(minV, bl, tl);
2205
- lefttop = interpolateX(maxV, bl, tl);
2206
- topright = 1 - interpolateX(maxV, tr, tl);
2207
- }
2208
- edges.push(isoBandEdgeRT[cval]);
2209
- edges.push(isoBandEdgeBR[cval]);
2210
- edges.push(isoBandEdgeBL[cval]);
2211
- }
2212
- else if (cval === 156) {
2213
- /* 2120 with flipped == 1 || 0102 with flipped == 4 */
2214
- if (flipped === 4) {
2215
- righttop = interpolateX(minV, br, tr);
2216
- bottomright = 1 - interpolateX(minV, br, bl);
2217
- bottomleft = 1 - interpolateX(maxV, br, bl);
2218
- leftbottom = 1 - interpolateX(maxV, tl, bl);
2219
- lefttop = 1 - interpolateX(minV, tl, bl);
2220
- topright = interpolateX(minV, tl, tr);
2221
- }
2222
- else {
2223
- righttop = 1 - interpolateX(maxV, tr, br);
2224
- bottomright = interpolateX(maxV, bl, br);
2225
- bottomleft = interpolateX(minV, bl, br);
2226
- leftbottom = interpolateX(minV, bl, tl);
2227
- lefttop = interpolateX(maxV, bl, tl);
2228
- topright = 1 - interpolateX(maxV, tr, tl);
2229
- }
2230
- edges.push(isoBandEdgeRT[cval]);
2231
- edges.push(isoBandEdgeBL[cval]);
2232
- edges.push(isoBandEdgeLT[cval]);
2233
- }
2234
- else if (cval === 137) {
2235
- /* 2021 with flipped == 2 || 0201 with flipped == 0 */
2236
- if (flipped === 0) {
2237
- righttop = interpolateX(maxV, br, tr);
2238
- rightbottom = interpolateX(minV, br, tr);
2239
- bottomleft = 1 - interpolateX(minV, br, bl);
2240
- leftbottom = 1 - interpolateX(minV, tl, bl);
2241
- topleft = interpolateX(minV, tl, tr);
2242
- topright = interpolateX(maxV, tl, tr);
2243
- }
2244
- else {
2245
- righttop = 1 - interpolateX(minV, tr, br);
2246
- rightbottom = 1 - interpolateX(maxV, tr, br);
2247
- bottomleft = interpolateX(maxV, bl, br);
2248
- leftbottom = interpolateX(maxV, bl, tl);
2249
- topleft = 1 - interpolateX(maxV, tr, tl);
2250
- topright = 1 - interpolateX(minV, tr, tl);
2251
- }
2252
- edges.push(isoBandEdgeRT[cval]);
2253
- edges.push(isoBandEdgeRB[cval]);
2254
- edges.push(isoBandEdgeBL[cval]);
2255
- }
2256
- else if (cval === 139) {
2257
- /* 2021 with flipped == 1 || 0201 with flipped == 4 */
2258
- if (flipped === 4) {
2259
- righttop = interpolateX(maxV, br, tr);
2260
- rightbottom = interpolateX(minV, br, tr);
2261
- bottomleft = 1 - interpolateX(minV, br, bl);
2262
- leftbottom = 1 - interpolateX(minV, tl, bl);
2263
- topleft = interpolateX(minV, tl, tr);
2264
- topright = interpolateX(maxV, tl, tr);
2265
- }
2266
- else {
2267
- righttop = 1 - interpolateX(minV, tr, br);
2268
- rightbottom = 1 - interpolateX(maxV, tr, br);
2269
- bottomleft = interpolateX(maxV, bl, br);
2270
- leftbottom = interpolateX(maxV, bl, tl);
2271
- topleft = 1 - interpolateX(maxV, tr, tl);
2272
- topright = 1 - interpolateX(minV, tr, tl);
2273
- }
2274
- edges.push(isoBandEdgeRT[cval]);
2275
- edges.push(isoBandEdgeRB[cval]);
2276
- edges.push(isoBandEdgeLB[cval]);
2277
- }
2278
- else if (cval === 98) {
2279
- /* 1202 with flipped == 2 || 1020 with flipped == 0 */
2280
- if (flipped === 0) {
2281
- righttop = 1 - interpolateX(minV, tr, br);
2282
- rightbottom = 1 - interpolateX(maxV, tr, br);
2283
- bottomright = interpolateX(maxV, bl, br);
2284
- bottomleft = interpolateX(minV, bl, br);
2285
- lefttop = interpolateX(minV, bl, tl);
2286
- topleft = 1 - interpolateX(minV, tr, tl);
2287
- }
2288
- else {
2289
- righttop = interpolateX(maxV, br, tr);
2290
- rightbottom = interpolateX(minV, br, tr);
2291
- bottomright = 1 - interpolateX(minV, br, bl);
2292
- bottomleft = 1 - interpolateX(maxV, br, bl);
2293
- lefttop = 1 - interpolateX(maxV, tl, bl);
2294
- topleft = interpolateX(maxV, tl, tr);
2295
- }
2296
- edges.push(isoBandEdgeRT[cval]);
2297
- edges.push(isoBandEdgeRB[cval]);
2298
- edges.push(isoBandEdgeLT[cval]);
2299
- }
2300
- else if (cval === 99) {
2301
- /* 1202 with flipped == 1 || 1020 with flipped == 4 */
2302
- if (flipped === 4) {
2303
- righttop = 1 - interpolateX(minV, tr, br);
2304
- rightbottom = 1 - interpolateX(maxV, tr, br);
2305
- bottomright = interpolateX(maxV, bl, br);
2306
- bottomleft = interpolateX(minV, bl, br);
2307
- lefttop = interpolateX(minV, bl, tl);
2308
- topleft = 1 - interpolateX(minV, tr, tl);
2309
- }
2310
- else {
2311
- righttop = interpolateX(maxV, br, tr);
2312
- rightbottom = interpolateX(minV, br, tr);
2313
- bottomright = 1 - interpolateX(minV, br, bl);
2314
- bottomleft = 1 - interpolateX(maxV, br, bl);
2315
- lefttop = 1 - interpolateX(maxV, tl, bl);
2316
- topleft = interpolateX(maxV, tl, tr);
2317
- }
2318
- edges.push(isoBandEdgeRT[cval]);
2319
- edges.push(isoBandEdgeRB[cval]);
2320
- edges.push(isoBandEdgeBL[cval]);
2321
- }
2322
- else if (cval === 38) {
2323
- /* 0212 with flipped == 2 || 2010 with flipped == 0 */
2324
- if (flipped === 0) {
2325
- rightbottom = 1 - interpolateX(minV, tr, br);
2326
- bottomright = interpolateX(minV, bl, br);
2327
- leftbottom = interpolateX(minV, bl, tl);
2328
- lefttop = interpolateX(maxV, bl, tl);
2329
- topleft = 1 - interpolateX(maxV, tr, tl);
2330
- topright = 1 - interpolateX(minV, tr, tl);
2331
- }
2332
- else {
2333
- rightbottom = interpolateX(maxV, br, tr);
2334
- bottomright = 1 - interpolateX(maxV, br, bl);
2335
- leftbottom = 1 - interpolateX(maxV, tl, bl);
2336
- lefttop = 1 - interpolateX(minV, tl, bl);
2337
- topleft = interpolateX(minV, tl, tr);
2338
- topright = interpolateX(maxV, tl, tr);
2339
- }
2340
- edges.push(isoBandEdgeRB[cval]);
2341
- edges.push(isoBandEdgeLB[cval]);
2342
- edges.push(isoBandEdgeLT[cval]);
2343
- }
2344
- else if (cval === 39) {
2345
- /* 0212 with flipped == 1 || 2010 with flipped == 4 */
2346
- if (flipped === 4) {
2347
- rightbottom = 1 - interpolateX(minV, tr, br);
2348
- bottomright = interpolateX(minV, bl, br);
2349
- leftbottom = interpolateX(minV, bl, tl);
2350
- lefttop = interpolateX(maxV, bl, tl);
2351
- topleft = 1 - interpolateX(maxV, tr, tl);
2352
- topright = 1 - interpolateX(minV, tr, tl);
2353
- }
2354
- else {
2355
- rightbottom = interpolateX(maxV, br, tr);
2356
- bottomright = 1 - interpolateX(maxV, br, bl);
2357
- leftbottom = 1 - interpolateX(maxV, tl, bl);
2358
- lefttop = 1 - interpolateX(minV, tl, bl);
2359
- topleft = interpolateX(minV, tl, tr);
2360
- topright = interpolateX(maxV, tl, tr);
2361
- }
2362
- edges.push(isoBandEdgeRB[cval]);
2363
- edges.push(isoBandEdgeBR[cval]);
2364
- edges.push(isoBandEdgeLT[cval]);
2365
- }
2366
- else if (cval === 85) {
2367
- righttop = 1;
2368
- rightbottom = 0;
2369
- bottomright = 1;
2370
- bottomleft = 0;
2371
- leftbottom = 0;
2372
- lefttop = 1;
2373
- topleft = 0;
2374
- topright = 1;
2375
- }
2376
- if (topleft < 0 ||
2377
- topleft > 1 ||
2378
- topright < 0 ||
2379
- topright > 1 ||
2380
- righttop < 0 ||
2381
- righttop > 1 ||
2382
- bottomright < 0 ||
2383
- bottomright > 1 ||
2384
- leftbottom < 0 ||
2385
- leftbottom > 1 ||
2386
- lefttop < 0 ||
2387
- lefttop > 1) {
2388
- console.log("MarchingSquaresJS-isoBands: " +
2389
- cval +
2390
- " " +
2391
- cval_real +
2392
- " " +
2393
- tl +
2394
- "," +
2395
- tr +
2396
- "," +
2397
- br +
2398
- "," +
2399
- bl +
2400
- " " +
2401
- flipped +
2402
- " " +
2403
- topleft +
2404
- " " +
2405
- topright +
2406
- " " +
2407
- righttop +
2408
- " " +
2409
- rightbottom +
2410
- " " +
2411
- bottomright +
2412
- " " +
2413
- bottomleft +
2414
- " " +
2415
- leftbottom +
2416
- " " +
2417
- lefttop);
2418
- }
2419
- BandGrid.cells[j][i] = {
2420
- cval: cval,
2421
- cval_real: cval_real,
2422
- flipped: flipped,
2423
- topleft: topleft,
2424
- topright: topright,
2425
- righttop: righttop,
2426
- rightbottom: rightbottom,
2427
- bottomright: bottomright,
2428
- bottomleft: bottomleft,
2429
- leftbottom: leftbottom,
2430
- lefttop: lefttop,
2431
- edges: edges,
2432
- };
2433
- }
2434
- }
2435
- }
2436
- return BandGrid;
2437
- }
2438
- function BandGrid2AreaPaths(grid) {
2439
- var areas = [];
2440
- var rows = grid.rows;
2441
- var cols = grid.cols;
2442
- var currentPolygon = [];
2443
- for (var j = 0; j < rows; j++) {
2444
- for (var i = 0; i < cols; i++) {
2445
- if (typeof grid.cells[j][i] !== "undefined" &&
2446
- grid.cells[j][i].edges.length > 0) {
2447
- /* trace back polygon path starting from this cell */
2448
- var cell = grid.cells[j][i];
2449
- /* get start coordinates */
2450
- var prev = getStartXY(cell), next = null, p = i, q = j;
2451
- if (prev !== null) {
2452
- currentPolygon.push([prev.p[0] + p, prev.p[1] + q]);
2453
- //console.log(cell);
2454
- //console.log("coords: " + (prev.p[0] + p) + " " + (prev.p[1] + q));
2455
- }
2456
- do {
2457
- //console.log(p + "," + q);
2458
- //console.log(grid.cells[q][p]);
2459
- //console.log(grid.cells[q][p].edges);
2460
- //console.log("from : " + prev.x + " " + prev.y + " " + prev.o);
2461
- next = getExitXY(grid.cells[q][p], prev.x, prev.y, prev.o);
2462
- if (next !== null) {
2463
- //console.log("coords: " + (next.p[0] + p) + " " + (next.p[1] + q));
2464
- currentPolygon.push([next.p[0] + p, next.p[1] + q]);
2465
- p += next.x;
2466
- q += next.y;
2467
- prev = next;
2468
- }
2469
- else {
2470
- //console.log("getExitXY() returned null!");
2471
- break;
2472
- }
2473
- //console.log("to : " + next.x + " " + next.y + " " + next.o);
2474
- /* special case, where we've reached the grid boundaries */
2475
- if (q < 0 ||
2476
- q >= rows ||
2477
- p < 0 ||
2478
- p >= cols ||
2479
- typeof grid.cells[q][p] === "undefined") {
2480
- /* to create a closed path, we need to trace our way
2481
- arround the missing data, until we find an entry
2482
- point again
2483
- */
2484
- /* set back coordinates of current cell */
2485
- p -= next.x;
2486
- q -= next.y;
2487
- //console.log("reached boundary at " + p + " " + q);
2488
- var missing = traceOutOfGridPath(grid, p, q, next.x, next.y, next.o);
2489
- if (missing !== null) {
2490
- missing.path.forEach(function (pp) {
2491
- //console.log("coords: " + (pp[0]) + " " + (pp[1]));
2492
- currentPolygon.push(pp);
2493
- });
2494
- p = missing.i;
2495
- q = missing.j;
2496
- prev = missing;
2497
- }
2498
- else {
2499
- break;
2500
- }
2501
- //console.log(grid.cells[q][p]);
2502
- }
2503
- } while (typeof grid.cells[q][p] !== "undefined" &&
2504
- grid.cells[q][p].edges.length > 0);
2505
- areas.push(currentPolygon);
2506
- //console.log("next polygon");
2507
- //console.log(currentPolygon);
2508
- currentPolygon = [];
2509
- if (grid.cells[j][i].edges.length > 0)
2510
- i--;
2511
- }
2512
- }
2513
- }
2514
- return areas;
2515
- }
2516
- function traceOutOfGridPath(grid, i, j, d_x, d_y, d_o) {
2517
- var cell = grid.cells[j][i];
2518
- var cval = cell.cval_real;
2519
- var p = i + d_x, q = j + d_y;
2520
- var path = [];
2521
- var closed = false;
2522
- while (!closed) {
2523
- //console.log("processing cell " + p + "," + q + " " + d_x + " " + d_y + " " + d_o);
2524
- if (typeof grid.cells[q] === "undefined" ||
2525
- typeof grid.cells[q][p] === "undefined") {
2526
- //console.log("which is undefined");
2527
- /* we can't move on, so we have to change direction to proceed further */
2528
- /* go back to previous cell */
2529
- q -= d_y;
2530
- p -= d_x;
2531
- cell = grid.cells[q][p];
2532
- cval = cell.cval_real;
2533
- /* check where we've left defined cells of the grid... */
2534
- if (d_y === -1) {
2535
- /* we came from top */
2536
- if (d_o === 0) {
2537
- /* exit left */
2538
- if (cval & Node3) {
2539
- /* lower left node is within range, so we move left */
2540
- path.push([p, q]);
2541
- d_x = -1;
2542
- d_y = 0;
2543
- d_o = 0;
2544
- }
2545
- else if (cval & Node2) {
2546
- /* lower right node is within range, so we move right */
2547
- path.push([p + 1, q]);
2548
- d_x = 1;
2549
- d_y = 0;
2550
- d_o = 0;
2551
- }
2552
- else {
2553
- /* close the path */
2554
- path.push([p + cell.bottomright, q]);
2555
- d_x = 0;
2556
- d_y = 1;
2557
- d_o = 1;
2558
- closed = true;
2559
- break;
2560
- }
2561
- }
2562
- else if (cval & Node3) {
2563
- path.push([p, q]);
2564
- d_x = -1;
2565
- d_y = 0;
2566
- d_o = 0;
2567
- }
2568
- else if (cval & Node2) {
2569
- path.push([p + cell.bottomright, q]);
2570
- d_x = 0;
2571
- d_y = 1;
2572
- d_o = 1;
2573
- closed = true;
2574
- break;
2575
- }
2576
- else {
2577
- path.push([p + cell.bottomleft, q]);
2578
- d_x = 0;
2579
- d_y = 1;
2580
- d_o = 0;
2581
- closed = true;
2582
- break;
2583
- }
2584
- }
2585
- else if (d_y === 1) {
2586
- /* we came from bottom */
2587
- //console.log("we came from bottom and hit a non-existing cell " + (p + d_x) + "," + (q + d_y) + "!");
2588
- if (d_o === 0) {
2589
- /* exit left */
2590
- if (cval & Node1) {
2591
- /* top right node is within range, so we move right */
2592
- path.push([p + 1, q + 1]);
2593
- d_x = 1;
2594
- d_y = 0;
2595
- d_o = 1;
2596
- }
2597
- else if (!(cval & Node0)) {
2598
- /* found entry within same cell */
2599
- path.push([p + cell.topright, q + 1]);
2600
- d_x = 0;
2601
- d_y = -1;
2602
- d_o = 1;
2603
- closed = true;
2604
- //console.log("found entry from bottom at " + p + "," + q);
2605
- break;
2606
- }
2607
- else {
2608
- path.push([p + cell.topleft, q + 1]);
2609
- d_x = 0;
2610
- d_y = -1;
2611
- d_o = 0;
2612
- closed = true;
2613
- break;
2614
- }
2615
- }
2616
- else if (cval & Node1) {
2617
- path.push([p + 1, q + 1]);
2618
- d_x = 1;
2619
- d_y = 0;
2620
- d_o = 1;
2621
- }
2622
- else {
2623
- /* move right */
2624
- path.push([p + 1, q + 1]);
2625
- d_x = 1;
2626
- d_y = 0;
2627
- d_o = 1;
2628
- //console.log("wtf");
2629
- //break;
2630
- }
2631
- }
2632
- else if (d_x === -1) {
2633
- /* we came from right */
2634
- //console.log("we came from right and hit a non-existing cell at " + (p + d_x) + "," + (q + d_y) + "!");
2635
- if (d_o === 0) {
2636
- //console.log("continue at bottom");
2637
- if (cval & Node0) {
2638
- path.push([p, q + 1]);
2639
- d_x = 0;
2640
- d_y = 1;
2641
- d_o = 0;
2642
- //console.log("moving upwards to " + (p + d_x) + "," + (q + d_y) + "!");
2643
- }
2644
- else if (!(cval & Node3)) {
2645
- /* there has to be an entry into the regular grid again! */
2646
- //console.log("exiting top");
2647
- path.push([p, q + cell.lefttop]);
2648
- d_x = 1;
2649
- d_y = 0;
2650
- d_o = 1;
2651
- closed = true;
2652
- break;
2653
- }
2654
- else {
2655
- //console.log("exiting bottom");
2656
- path.push([p, q + cell.leftbottom]);
2657
- d_x = 1;
2658
- d_y = 0;
2659
- d_o = 0;
2660
- closed = true;
2661
- break;
2662
- }
2663
- }
2664
- else {
2665
- //console.log("continue at top");
2666
- if (cval & Node0) {
2667
- path.push([p, q + 1]);
2668
- d_x = 0;
2669
- d_y = 1;
2670
- d_o = 0;
2671
- //console.log("moving upwards to " + (p + d_x) + "," + (q + d_y) + "!");
2672
- }
2673
- else {
2674
- /* */
2675
- console.log("MarchingSquaresJS-isoBands: wtf");
2676
- break;
2677
- }
2678
- }
2679
- }
2680
- else if (d_x === 1) {
2681
- /* we came from left */
2682
- //console.log("we came from left and hit a non-existing cell " + (p + d_x) + "," + (q + d_y) + "!");
2683
- if (d_o === 0) {
2684
- /* exit bottom */
2685
- if (cval & Node2) {
2686
- path.push([p + 1, q]);
2687
- d_x = 0;
2688
- d_y = -1;
2689
- d_o = 1;
2690
- }
2691
- else {
2692
- path.push([p + 1, q + cell.rightbottom]);
2693
- d_x = -1;
2694
- d_y = 0;
2695
- d_o = 0;
2696
- closed = true;
2697
- break;
2698
- }
2699
- }
2700
- else {
2701
- /* exit top */
2702
- if (cval & Node2) {
2703
- path.push([p + 1, q]);
2704
- d_x = 0;
2705
- d_y = -1;
2706
- d_o = 1;
2707
- }
2708
- else if (!(cval & Node1)) {
2709
- path.push([p + 1, q + cell.rightbottom]);
2710
- d_x = -1;
2711
- d_y = 0;
2712
- d_o = 0;
2713
- closed = true;
2714
- break;
2715
- }
2716
- else {
2717
- path.push([p + 1, q + cell.righttop]);
2718
- d_x = -1;
2719
- d_y = 0;
2720
- d_o = 1;
2721
- break;
2722
- }
2723
- }
2724
- }
2725
- else {
2726
- /* we came from the same cell */
2727
- console.log("MarchingSquaresJS-isoBands: we came from nowhere!");
2728
- break;
2729
- }
2730
- }
2731
- else {
2732
- /* try to find an entry into the regular grid again! */
2733
- cell = grid.cells[q][p];
2734
- cval = cell.cval_real;
2735
- //console.log("which is defined");
2736
- if (d_x === -1) {
2737
- if (d_o === 0) {
2738
- /* try to go downwards */
2739
- if (typeof grid.cells[q - 1] !== "undefined" &&
2740
- typeof grid.cells[q - 1][p] !== "undefined") {
2741
- d_x = 0;
2742
- d_y = -1;
2743
- d_o = 1;
2744
- }
2745
- else if (cval & Node3) {
2746
- /* proceed searching in x-direction */
2747
- //console.log("proceeding in x-direction!");
2748
- path.push([p, q]);
2749
- }
2750
- else {
2751
- /* we must have found an entry into the regular grid */
2752
- path.push([p + cell.bottomright, q]);
2753
- d_x = 0;
2754
- d_y = 1;
2755
- d_o = 1;
2756
- closed = true;
2757
- //console.log("found entry from bottom at " + p + "," + q);
2758
- break;
2759
- }
2760
- }
2761
- else if (cval & Node0) {
2762
- /* proceed searchin in x-direction */
2763
- console.log("MarchingSquaresJS-isoBands: proceeding in x-direction!");
2764
- }
2765
- else {
2766
- /* we must have found an entry into the regular grid */
2767
- console.log("MarchingSquaresJS-isoBands: found entry from top at " + p + "," + q);
2768
- break;
2769
- }
2770
- }
2771
- else if (d_x === 1) {
2772
- if (d_o === 0) {
2773
- console.log("MarchingSquaresJS-isoBands: wtf");
2774
- break;
2775
- }
2776
- else {
2777
- /* try to go upwards */
2778
- if (typeof grid.cells[q + 1] !== "undefined" &&
2779
- typeof grid.cells[q + 1][p] !== "undefined") {
2780
- d_x = 0;
2781
- d_y = 1;
2782
- d_o = 0;
2783
- }
2784
- else if (cval & Node1) {
2785
- path.push([p + 1, q + 1]);
2786
- d_x = 1;
2787
- d_y = 0;
2788
- d_o = 1;
2789
- }
2790
- else {
2791
- /* found an entry point into regular grid! */
2792
- path.push([p + cell.topleft, q + 1]);
2793
- d_x = 0;
2794
- d_y = -1;
2795
- d_o = 0;
2796
- closed = true;
2797
- //console.log("found entry from bottom at " + p + "," + q);
2798
- break;
2799
- }
2800
- }
2801
- }
2802
- else if (d_y === -1) {
2803
- if (d_o === 1) {
2804
- /* try to go right */
2805
- if (typeof grid.cells[q][p + 1] !== "undefined") {
2806
- d_x = 1;
2807
- d_y = 0;
2808
- d_o = 1;
2809
- }
2810
- else if (cval & Node2) {
2811
- path.push([p + 1, q]);
2812
- d_x = 0;
2813
- d_y = -1;
2814
- d_o = 1;
2815
- }
2816
- else {
2817
- /* found entry into regular grid! */
2818
- path.push([p + 1, q + cell.righttop]);
2819
- d_x = -1;
2820
- d_y = 0;
2821
- d_o = 1;
2822
- closed = true;
2823
- //console.log("found entry from top at " + p + "," + q);
2824
- break;
2825
- }
2826
- }
2827
- else {
2828
- console.log("MarchingSquaresJS-isoBands: wtf");
2829
- break;
2830
- }
2831
- }
2832
- else if (d_y === 1) {
2833
- if (d_o === 0) {
2834
- //console.log("we came from bottom left and proceed to the left");
2835
- /* try to go left */
2836
- if (typeof grid.cells[q][p - 1] !== "undefined") {
2837
- d_x = -1;
2838
- d_y = 0;
2839
- d_o = 0;
2840
- }
2841
- else if (cval & Node0) {
2842
- path.push([p, q + 1]);
2843
- d_x = 0;
2844
- d_y = 1;
2845
- d_o = 0;
2846
- }
2847
- else {
2848
- /* found an entry point into regular grid! */
2849
- path.push([p, q + cell.leftbottom]);
2850
- d_x = 1;
2851
- d_y = 0;
2852
- d_o = 0;
2853
- closed = true;
2854
- //console.log("found entry from bottom at " + p + "," + q);
2855
- break;
2856
- }
2857
- }
2858
- else {
2859
- //console.log("we came from bottom right and proceed to the right");
2860
- console.log("MarchingSquaresJS-isoBands: wtf");
2861
- break;
2862
- }
2863
- }
2864
- else {
2865
- console.log("MarchingSquaresJS-isoBands: where did we came from???");
2866
- break;
2867
- }
2868
- }
2869
- p += d_x;
2870
- q += d_y;
2871
- //console.log("going on to " + p + "," + q + " via " + d_x + " " + d_y + " " + d_o);
2872
- if (p === i && q === j) {
2873
- /* bail out, once we've closed a circle path */
2874
- break;
2875
- }
2876
- }
2877
- //console.log("exit with " + p + "," + q + " " + d_x + " " + d_y + " " + d_o);
2878
- return { path: path, i: p, j: q, x: d_x, y: d_y, o: d_o };
2879
- }
2880
- function deleteEdge(cell, edgeIdx) {
2881
- delete cell.edges[edgeIdx];
2882
- for (var k = edgeIdx + 1; k < cell.edges.length; k++) {
2883
- cell.edges[k - 1] = cell.edges[k];
2884
- }
2885
- cell.edges.pop();
2886
- }
2887
- function getStartXY(cell) {
2888
- if (cell.edges.length > 0) {
2889
- var e = cell.edges[cell.edges.length - 1];
2890
- //console.log("starting with edge " + e);
2891
- var cval = cell.cval_real;
2892
- switch (e) {
2893
- case 0:
2894
- if (cval & Node1) {
2895
- /* node 1 within range */
2896
- return { p: [1, cell.righttop], x: -1, y: 0, o: 1 };
2897
- }
2898
- else {
2899
- /* node 1 below or above threshold */
2900
- return { p: [cell.topleft, 1], x: 0, y: -1, o: 0 };
2901
- }
2902
- case 1:
2903
- if (cval & Node2) {
2904
- return { p: [cell.topleft, 1], x: 0, y: -1, o: 0 };
2905
- }
2906
- else {
2907
- return { p: [1, cell.rightbottom], x: -1, y: 0, o: 0 };
2908
- }
2909
- case 2:
2910
- if (cval & Node2) {
2911
- return { p: [cell.bottomright, 0], x: 0, y: 1, o: 1 };
2912
- }
2913
- else {
2914
- return { p: [cell.topleft, 1], x: 0, y: -1, o: 0 };
2915
- }
2916
- case 3:
2917
- if (cval & Node3) {
2918
- return { p: [cell.topleft, 1], x: 0, y: -1, o: 0 };
2919
- }
2920
- else {
2921
- return { p: [cell.bottomleft, 0], x: 0, y: 1, o: 0 };
2922
- }
2923
- case 4:
2924
- if (cval & Node1) {
2925
- return { p: [1, cell.righttop], x: -1, y: 0, o: 1 };
2926
- }
2927
- else {
2928
- return { p: [cell.topright, 1], x: 0, y: -1, o: 1 };
2929
- }
2930
- case 5:
2931
- if (cval & Node2) {
2932
- return { p: [cell.topright, 1], x: 0, y: -1, o: 1 };
2933
- }
2934
- else {
2935
- return { p: [1, cell.rightbottom], x: -1, y: 0, o: 0 };
2936
- }
2937
- case 6:
2938
- if (cval & Node2) {
2939
- return { p: [cell.bottomright, 0], x: 0, y: 1, o: 1 };
2940
- }
2941
- else {
2942
- return { p: [cell.topright, 1], x: 0, y: -1, o: 1 };
2943
- }
2944
- case 7:
2945
- if (cval & Node3) {
2946
- return { p: [cell.topright, 1], x: 0, y: -1, o: 1 };
2947
- }
2948
- else {
2949
- return { p: [cell.bottomleft, 0], x: 0, y: 1, o: 0 };
2950
- }
2951
- case 8:
2952
- if (cval & Node2) {
2953
- return { p: [cell.bottomright, 0], x: 0, y: 1, o: 1 };
2954
- }
2955
- else {
2956
- return { p: [1, cell.righttop], x: -1, y: 0, o: 1 };
2957
- }
2958
- case 9:
2959
- if (cval & Node3) {
2960
- return { p: [1, cell.righttop], x: -1, y: 0, o: 1 };
2961
- }
2962
- else {
2963
- return { p: [cell.bottomleft, 0], x: 0, y: 1, o: 0 };
2964
- }
2965
- case 10:
2966
- if (cval & Node3) {
2967
- return { p: [0, cell.leftbottom], x: 1, y: 0, o: 0 };
2968
- }
2969
- else {
2970
- return { p: [1, cell.righttop], x: -1, y: 0, o: 1 };
2971
- }
2972
- case 11:
2973
- if (cval & Node0) {
2974
- return { p: [1, cell.righttop], x: -1, y: 0, o: 1 };
2975
- }
2976
- else {
2977
- return { p: [0, cell.lefttop], x: 1, y: 0, o: 1 };
2978
- }
2979
- case 12:
2980
- if (cval & Node2) {
2981
- return { p: [cell.bottomright, 0], x: 0, y: 1, o: 1 };
2982
- }
2983
- else {
2984
- return { p: [1, cell.rightbottom], x: -1, y: 0, o: 0 };
2985
- }
2986
- case 13:
2987
- if (cval & Node3) {
2988
- return { p: [1, cell.rightbottom], x: -1, y: 0, o: 0 };
2989
- }
2990
- else {
2991
- return { p: [cell.bottomleft, 0], x: 0, y: 1, o: 0 };
2992
- }
2993
- case 14:
2994
- if (cval & Node3) {
2995
- return { p: [0, cell.leftbottom], x: 1, y: 0, o: 0 };
2996
- }
2997
- else {
2998
- return { p: [1, cell.rightbottom], x: -1, y: 0, o: 0 };
2999
- }
3000
- case 15:
3001
- if (cval & Node0) {
3002
- return { p: [1, cell.rightbottom], x: -1, y: 0, o: 0 };
3003
- }
3004
- else {
3005
- return { p: [0, cell.lefttop], x: 1, y: 0, o: 1 };
3006
- }
3007
- case 16:
3008
- if (cval & Node2) {
3009
- return { p: [cell.bottomright, 0], x: 0, y: 1, o: 1 };
3010
- }
3011
- else {
3012
- return { p: [0, cell.leftbottom], x: 1, y: 0, o: 0 };
3013
- }
3014
- case 17:
3015
- if (cval & Node0) {
3016
- return { p: [cell.bottomright, 0], x: 0, y: 1, o: 1 };
3017
- }
3018
- else {
3019
- return { p: [0, cell.lefttop], x: 1, y: 0, o: 1 };
3020
- }
3021
- case 18:
3022
- if (cval & Node3) {
3023
- return { p: [0, cell.leftbottom], x: 1, y: 0, o: 0 };
3024
- }
3025
- else {
3026
- return { p: [cell.bottomleft, 0], x: 0, y: 1, o: 0 };
3027
- }
3028
- case 19:
3029
- if (cval & Node0) {
3030
- return { p: [cell.bottomleft, 0], x: 0, y: 1, o: 0 };
3031
- }
3032
- else {
3033
- return { p: [0, cell.lefttop], x: 1, y: 0, o: 1 };
3034
- }
3035
- case 20:
3036
- if (cval & Node0) {
3037
- return { p: [cell.topleft, 1], x: 0, y: -1, o: 0 };
3038
- }
3039
- else {
3040
- return { p: [0, cell.leftbottom], x: 1, y: 0, o: 0 };
3041
- }
3042
- case 21:
3043
- if (cval & Node1) {
3044
- return { p: [0, cell.leftbottom], x: 1, y: 0, o: 0 };
3045
- }
3046
- else {
3047
- return { p: [cell.topright, 1], x: 0, y: -1, o: 1 };
3048
- }
3049
- case 22:
3050
- if (cval & Node0) {
3051
- return { p: [cell.topleft, 1], x: 0, y: -1, o: 0 };
3052
- }
3053
- else {
3054
- return { p: [0, cell.lefttop], x: 1, y: 0, o: 1 };
3055
- }
3056
- case 23:
3057
- if (cval & Node1) {
3058
- return { p: [0, cell.lefttop], x: 1, y: 0, o: 1 };
3059
- }
3060
- else {
3061
- return { p: [cell.topright, 1], x: 0, y: -1, o: 1 };
3062
- }
3063
- default:
3064
- console.log("MarchingSquaresJS-isoBands: edge index out of range!");
3065
- console.log(cell);
3066
- break;
3067
- }
3068
- }
3069
- return null;
3070
- }
3071
- function getExitXY(cell, x, y, o) {
3072
- var e, id_x, d_x, d_y, cval = cell.cval;
3073
- var d_o;
3074
- switch (x) {
3075
- case -1:
3076
- switch (o) {
3077
- case 0:
3078
- e = isoBandEdgeRB[cval];
3079
- d_x = isoBandNextXRB[cval];
3080
- d_y = isoBandNextYRB[cval];
3081
- d_o = isoBandNextORB[cval];
3082
- break;
3083
- default:
3084
- e = isoBandEdgeRT[cval];
3085
- d_x = isoBandNextXRT[cval];
3086
- d_y = isoBandNextYRT[cval];
3087
- d_o = isoBandNextORT[cval];
3088
- break;
3089
- }
3090
- break;
3091
- case 1:
3092
- switch (o) {
3093
- case 0:
3094
- e = isoBandEdgeLB[cval];
3095
- d_x = isoBandNextXLB[cval];
3096
- d_y = isoBandNextYLB[cval];
3097
- d_o = isoBandNextOLB[cval];
3098
- break;
3099
- default:
3100
- e = isoBandEdgeLT[cval];
3101
- d_x = isoBandNextXLT[cval];
3102
- d_y = isoBandNextYLT[cval];
3103
- d_o = isoBandNextOLT[cval];
3104
- break;
3105
- }
3106
- break;
3107
- default:
3108
- switch (y) {
3109
- case -1:
3110
- switch (o) {
3111
- case 0:
3112
- e = isoBandEdgeTL[cval];
3113
- d_x = isoBandNextXTL[cval];
3114
- d_y = isoBandNextYTL[cval];
3115
- d_o = isoBandNextOTL[cval];
3116
- break;
3117
- default:
3118
- e = isoBandEdgeTR[cval];
3119
- d_x = isoBandNextXTR[cval];
3120
- d_y = isoBandNextYTR[cval];
3121
- d_o = isoBandNextOTR[cval];
3122
- break;
3123
- }
3124
- break;
3125
- case 1:
3126
- switch (o) {
3127
- case 0:
3128
- e = isoBandEdgeBL[cval];
3129
- d_x = isoBandNextXBL[cval];
3130
- d_y = isoBandNextYBL[cval];
3131
- d_o = isoBandNextOBL[cval];
3132
- break;
3133
- default:
3134
- e = isoBandEdgeBR[cval];
3135
- d_x = isoBandNextXBR[cval];
3136
- d_y = isoBandNextYBR[cval];
3137
- d_o = isoBandNextOBR[cval];
3138
- break;
3139
- }
3140
- break;
3141
- default:
3142
- break;
3143
- }
3144
- break;
3145
- }
3146
- id_x = cell.edges.indexOf(e);
3147
- if (typeof cell.edges[id_x] !== "undefined") {
3148
- deleteEdge(cell, id_x);
3149
- }
3150
- else {
3151
- //console.log("wrong edges...");
3152
- //console.log(x + " " + y + " " + o);
3153
- //console.log(cell);
3154
- return null;
3155
- }
3156
- cval = cell.cval_real;
3157
- switch (e) {
3158
- case 0:
3159
- if (cval & Node1) {
3160
- /* node 1 within range */
3161
- x = cell.topleft;
3162
- y = 1;
3163
- }
3164
- else {
3165
- /* node 1 below or above threshold */
3166
- x = 1;
3167
- y = cell.righttop;
3168
- }
3169
- break;
3170
- case 1:
3171
- if (cval & Node2) {
3172
- x = 1;
3173
- y = cell.rightbottom;
3174
- }
3175
- else {
3176
- x = cell.topleft;
3177
- y = 1;
3178
- }
3179
- break;
3180
- case 2:
3181
- if (cval & Node2) {
3182
- x = cell.topleft;
3183
- y = 1;
3184
- }
3185
- else {
3186
- x = cell.bottomright;
3187
- y = 0;
3188
- }
3189
- break;
3190
- case 3:
3191
- if (cval & Node3) {
3192
- x = cell.bottomleft;
3193
- y = 0;
3194
- }
3195
- else {
3196
- x = cell.topleft;
3197
- y = 1;
3198
- }
3199
- break;
3200
- case 4:
3201
- if (cval & Node1) {
3202
- x = cell.topright;
3203
- y = 1;
3204
- }
3205
- else {
3206
- x = 1;
3207
- y = cell.righttop;
3208
- }
3209
- break;
3210
- case 5:
3211
- if (cval & Node2) {
3212
- x = 1;
3213
- y = cell.rightbottom;
3214
- }
3215
- else {
3216
- x = cell.topright;
3217
- y = 1;
3218
- }
3219
- break;
3220
- case 6:
3221
- if (cval & Node2) {
3222
- x = cell.topright;
3223
- y = 1;
3224
- }
3225
- else {
3226
- x = cell.bottomright;
3227
- y = 0;
3228
- }
3229
- break;
3230
- case 7:
3231
- if (cval & Node3) {
3232
- x = cell.bottomleft;
3233
- y = 0;
3234
- }
3235
- else {
3236
- x = cell.topright;
3237
- y = 1;
3238
- }
3239
- break;
3240
- case 8:
3241
- if (cval & Node2) {
3242
- x = 1;
3243
- y = cell.righttop;
3244
- }
3245
- else {
3246
- x = cell.bottomright;
3247
- y = 0;
3248
- }
3249
- break;
3250
- case 9:
3251
- if (cval & Node3) {
3252
- x = cell.bottomleft;
3253
- y = 0;
3254
- }
3255
- else {
3256
- x = 1;
3257
- y = cell.righttop;
3258
- }
3259
- break;
3260
- case 10:
3261
- if (cval & Node3) {
3262
- x = 1;
3263
- y = cell.righttop;
3264
- }
3265
- else {
3266
- x = 0;
3267
- y = cell.leftbottom;
3268
- }
3269
- break;
3270
- case 11:
3271
- if (cval & Node0) {
3272
- x = 0;
3273
- y = cell.lefttop;
3274
- }
3275
- else {
3276
- x = 1;
3277
- y = cell.righttop;
3278
- }
3279
- break;
3280
- case 12:
3281
- if (cval & Node2) {
3282
- x = 1;
3283
- y = cell.rightbottom;
3284
- }
3285
- else {
3286
- x = cell.bottomright;
3287
- y = 0;
3288
- }
3289
- break;
3290
- case 13:
3291
- if (cval & Node3) {
3292
- x = cell.bottomleft;
3293
- y = 0;
3294
- }
3295
- else {
3296
- x = 1;
3297
- y = cell.rightbottom;
3298
- }
3299
- break;
3300
- case 14:
3301
- if (cval & Node3) {
3302
- x = 1;
3303
- y = cell.rightbottom;
3304
- }
3305
- else {
3306
- x = 0;
3307
- y = cell.leftbottom;
3308
- }
3309
- break;
3310
- case 15:
3311
- if (cval & Node0) {
3312
- x = 0;
3313
- y = cell.lefttop;
3314
- }
3315
- else {
3316
- x = 1;
3317
- y = cell.rightbottom;
3318
- }
3319
- break;
3320
- case 16:
3321
- if (cval & Node2) {
3322
- x = 0;
3323
- y = cell.leftbottom;
3324
- }
3325
- else {
3326
- x = cell.bottomright;
3327
- y = 0;
3328
- }
3329
- break;
3330
- case 17:
3331
- if (cval & Node0) {
3332
- x = 0;
3333
- y = cell.lefttop;
3334
- }
3335
- else {
3336
- x = cell.bottomright;
3337
- y = 0;
3338
- }
3339
- break;
3340
- case 18:
3341
- if (cval & Node3) {
3342
- x = cell.bottomleft;
3343
- y = 0;
3344
- }
3345
- else {
3346
- x = 0;
3347
- y = cell.leftbottom;
3348
- }
3349
- break;
3350
- case 19:
3351
- if (cval & Node0) {
3352
- x = 0;
3353
- y = cell.lefttop;
3354
- }
3355
- else {
3356
- x = cell.bottomleft;
3357
- y = 0;
3358
- }
3359
- break;
3360
- case 20:
3361
- if (cval & Node0) {
3362
- x = 0;
3363
- y = cell.leftbottom;
3364
- }
3365
- else {
3366
- x = cell.topleft;
3367
- y = 1;
3368
- }
3369
- break;
3370
- case 21:
3371
- if (cval & Node1) {
3372
- x = cell.topright;
3373
- y = 1;
3374
- }
3375
- else {
3376
- x = 0;
3377
- y = cell.leftbottom;
3378
- }
3379
- break;
3380
- case 22:
3381
- if (cval & Node0) {
3382
- x = 0;
3383
- y = cell.lefttop;
3384
- }
3385
- else {
3386
- x = cell.topleft;
3387
- y = 1;
3388
- }
3389
- break;
3390
- case 23:
3391
- if (cval & Node1) {
3392
- x = cell.topright;
3393
- y = 1;
3394
- }
3395
- else {
3396
- x = 0;
3397
- y = cell.lefttop;
3398
- }
3399
- break;
3400
- default:
3401
- console.log("MarchingSquaresJS-isoBands: edge index out of range!");
3402
- console.log(cell);
3403
- return null;
3404
- }
3405
- if (typeof x === "undefined" ||
3406
- typeof y === "undefined" ||
3407
- typeof d_x === "undefined" ||
3408
- typeof d_y === "undefined" ||
3409
- typeof d_o === "undefined") {
3410
- console.log("MarchingSquaresJS-isoBands: undefined value!");
3411
- console.log(cell);
3412
- console.log(x + " " + y + " " + d_x + " " + d_y + " " + d_o);
3413
- }
3414
- return { p: [x, y], x: d_x, y: d_y, o: d_o };
3415
- }
3416
- function BandGrid2Areas(grid) {
3417
- var areas = [];
3418
- var area_idx = 0;
3419
- grid.cells.forEach(function (g, j) {
3420
- g.forEach(function (gg, i) {
3421
- if (typeof gg !== "undefined") {
3422
- var a = polygon_table[gg.cval](gg);
3423
- if (typeof a === "object" && isArray(a)) {
3424
- if (typeof a[0] === "object" && isArray(a[0])) {
3425
- if (typeof a[0][0] === "object" && isArray(a[0][0])) {
3426
- a.forEach(function (aa) {
3427
- aa.forEach(function (aaa) {
3428
- aaa[0] += i;
3429
- aaa[1] += j;
3430
- });
3431
- areas[area_idx++] = aa;
3432
- });
3433
- }
3434
- else {
3435
- a.forEach(function (aa) {
3436
- aa[0] += i;
3437
- aa[1] += j;
3438
- });
3439
- areas[area_idx++] = a;
3440
- }
3441
- }
3442
- else {
3443
- console.log("MarchingSquaresJS-isoBands: bandcell polygon with malformed coordinates");
3444
- }
3445
- }
3446
- else {
3447
- console.log("MarchingSquaresJS-isoBands: bandcell polygon with null coordinates");
3448
- }
3449
- }
3450
- });
3451
- });
3452
- return areas;
3453
- }