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