"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class; var _class2; var _class3;var __defProp = Object.defineProperty; var __name = (target, value) => __defProp(target, "name", { value, configurable: true }); // src/interpolation.ts function linear(a, b, v) { if (a < b) return (v - a) / (b - a); return (a - v) / (a - b); } __name(linear, "linear"); function linear_ab(a, b, v0, v1) { if (v0 > v1) { [v0, v1] = [v1, v0]; } if (a < b) { if (a < v0) return (v0 - a) / (b - a); else return (v1 - a) / (b - a); } else if (a > v1) { return (a - v1) / (a - b); } return (a - v0) / (a - b); } __name(linear_ab, "linear_ab"); function linear_a(a, b, minV, maxV) { if (a < b) return (minV - a) / (b - a); return (a - maxV) / (a - b); } __name(linear_a, "linear_a"); function linear_b(a, b, minV, maxV) { if (a < b) return (maxV - a) / (b - a); return (a - minV) / (a - b); } __name(linear_b, "linear_b"); // src/options.ts var InternalOptions = (_class = class {constructor() { _class.prototype.__init.call(this);_class.prototype.__init2.call(this);_class.prototype.__init3.call(this);_class.prototype.__init4.call(this);_class.prototype.__init5.call(this);_class.prototype.__init6.call(this); } static { __name(this, "InternalOptions"); } /* Settings common to all implemented algorithms */ __init() {this.verbose = false} __init2() {this.polygons = false} __init3() {this.polygons_full = false} __init4() {this.linearRing = true} __init5() {this.noQuadTree = false} __init6() {this.noFrame = false} }, _class); var IsoLineOptions = (_class2 = class extends InternalOptions {constructor(...args) { super(...args); _class2.prototype.__init7.call(this); } static { __name(this, "IsoLineOptions"); } /* add interpolation functions (not yet user customizable) */ __init7() {this.interpolate = linear} }, _class2); var IsoBandOptions = (_class3 = class extends InternalOptions {constructor(...args2) { super(...args2); _class3.prototype.__init8.call(this);_class3.prototype.__init9.call(this);_class3.prototype.__init10.call(this); } static { __name(this, "IsoBandOptions"); } /* add interpolation functions (not yet user customizable) */ __init8() {this.interpolate = linear_ab} __init9() {this.interpolate_a = linear_a} __init10() {this.interpolate_b = linear_b} }, _class3); function isoBandOptions(userSettings) { const bandOptions = new IsoBandOptions(); for (const key of Object.keys(bandOptions)) { const val = userSettings[key]; if (typeof val !== "undefined" && val !== null) { bandOptions[key] = val; } } bandOptions.polygons_full = !bandOptions.polygons; bandOptions.interpolate = linear_ab; bandOptions.interpolate_a = linear_a; bandOptions.interpolate_b = linear_b; return bandOptions; } __name(isoBandOptions, "isoBandOptions"); function isoLineOptions(userSettings) { const lineOptions = new IsoLineOptions(); for (const key of Object.keys(lineOptions)) { const val = userSettings[key]; if (typeof val !== "undefined" && val !== null) { lineOptions[key] = val; } } lineOptions.polygons_full = !lineOptions.polygons; lineOptions.interpolate = linear; return lineOptions; } __name(isoLineOptions, "isoLineOptions"); // src/polygons.ts function cell2Polygons(cell, x, y, settings) { const polygons = []; cell.polygons.forEach(function(p) { p.forEach(function(pp) { pp[0] += x; pp[1] += y; }); if (settings.linearRing) p.push(p[0]); polygons.push(p); }); return polygons; } __name(cell2Polygons, "cell2Polygons"); function entry_coordinate(x, y, mode, path) { if (mode === 0) { x += 1; y += path[0][1]; } else if (mode === 1) { x += path[0][0]; } else if (mode === 2) { y += path[0][1]; } else if (mode === 3) { x += path[0][0]; y += 1; } return [x, y]; } __name(entry_coordinate, "entry_coordinate"); function skip_coordinate(x, y, mode) { if (mode === 0) { x++; } else if (mode === 1) { } else if (mode === 2) { y++; } else if (mode === 3) { x++; y++; } return [x, y]; } __name(skip_coordinate, "skip_coordinate"); function requireFrame(data, lowerBound, upperBound) { let frameRequired = true; const cols = data[0].length; const rows = data.length; for (let j = 0; j < rows; j++) { if (data[j][0] < lowerBound || data[j][0] > upperBound || data[j][cols - 1] < lowerBound || data[j][cols - 1] > upperBound) { frameRequired = false; break; } } if (frameRequired && (data[rows - 1][0] < lowerBound || data[rows - 1][0] > upperBound || data[rows - 1][cols - 1] < lowerBound || data[rows - 1][cols - 1] > upperBound)) { frameRequired = false; } if (frameRequired) for (let i = 0; i < cols - 1; i++) { if (data[0][i] < lowerBound || data[0][i] > upperBound || data[rows - 1][i] < lowerBound || data[rows - 1][i] > upperBound) { frameRequired = false; break; } } return frameRequired; } __name(requireFrame, "requireFrame"); function requireLineFrame(data, threshold) { let frameRequired = true; const cols = data[0].length; const rows = data.length; for (let j = 0; j < rows; j++) { if (data[j][0] >= threshold || data[j][cols - 1] >= threshold) { frameRequired = false; break; } } if (frameRequired && (data[rows - 1][0] >= threshold || data[rows - 1][cols - 1] >= threshold)) { frameRequired = false; } if (frameRequired) for (let i = 0; i < cols - 1; i++) { if (data[0][i] >= threshold || data[rows - 1][i] > threshold) { frameRequired = false; break; } } return frameRequired; } __name(requireLineFrame, "requireLineFrame"); function traceBandPaths(data, cellGrid, settings) { const polygons = []; const rows = data.length - 1; const cols = data[0].length - 1; const valid_entries = [ ["rt", "rb"], ["br", "bl"], ["lb", "lt"], ["tl", "tr"] ]; const add_x = [0, -1, 0, 1]; const add_y = [-1, 0, 1, 0]; const available_starts = [ "bl", "lb", "lt", "tl", "tr", "rt", "rb", "br" ]; const entry_dir = { bl: 1, br: 1, lb: 2, lt: 2, tl: 3, tr: 3, rt: 0, rb: 0 }; if (requireFrame(data, settings.minV, settings.maxV)) { if (settings.linearRing) polygons.push([ [0, 0], [0, rows], [cols, rows], [cols, 0], [0, 0] ]); else polygons.push([ [0, 0], [0, rows], [cols, rows], [cols, 0] ]); } cellGrid.forEach(function(a, i) { a.forEach(function(cell, j) { for (let e = 0; e < 8; e++) { const nextedge = available_starts[e]; if (typeof _optionalChain([cell, 'optionalAccess', _ => _.edges, 'access', _2 => _2[nextedge]]) !== "object") continue; let ee = cell.edges[nextedge], enter = nextedge, x = i, y = j, finalized = false; const path = [], origin = [i + ee.path[0][0], j + ee.path[0][1]]; path.push(origin); while (!finalized) { let cc = cellGrid[x][y]; if (typeof _optionalChain([cc, 'optionalAccess', _3 => _3.edges, 'access', _4 => _4[enter]]) !== "object") break; ee = cc.edges[enter]; delete cc.edges[enter]; const point = ee.path[1]; point[0] += x; point[1] += y; path.push(point); enter = ee.move.enter; x = x + ee.move.x; y = y + ee.move.y; if (typeof cellGrid[x] === "undefined" || typeof cellGrid[x][y] === "undefined") { let dir = 0, count = 0; if (x === cols) { x--; dir = 0; } else if (x < 0) { x++; dir = 2; } else if (y === rows) { y--; dir = 3; } else if (y < 0) { y++; dir = 1; } else { throw new Error("Left the grid somewhere in the interior!"); } if (x === i && y === j && dir === entry_dir[nextedge]) { finalized = true; enter = nextedge; break; } while (true) { let found_entry = false; if (count > 4) throw new Error( "Direction change counter overflow! This should never happen!" ); if (!(typeof cellGrid[x] === "undefined" || typeof cellGrid[x][y] === "undefined")) { cc = cellGrid[x][y]; for (let s = 0; s < valid_entries[dir].length; s++) { const ve = valid_entries[dir][s]; if (typeof _optionalChain([cc, 'optionalAccess', _5 => _5.edges, 'access', _6 => _6[ve]]) === "object") { ee = cc.edges[ve]; path.push(entry_coordinate(x, y, dir, ee.path)); enter = ve; found_entry = true; break; } } } if (found_entry) { break; } else { path.push(skip_coordinate(x, y, dir)); x += add_x[dir]; y += add_y[dir]; if (typeof cellGrid[x] === "undefined" || typeof cellGrid[x][y] === "undefined") { if (dir === 0 && y < 0 || dir === 1 && x < 0 || dir === 2 && y === rows || dir === 3 && x === cols) { x -= add_x[dir]; y -= add_y[dir]; dir = (dir + 1) % 4; count++; } } if (x === i && y === j && dir === entry_dir[nextedge]) { finalized = true; enter = nextedge; break; } } } } } if (settings.linearRing && (path[path.length - 1][0] !== origin[0] || path[path.length - 1][1] !== origin[1])) path.push(origin); polygons.push(path); } }); }); return polygons; } __name(traceBandPaths, "traceBandPaths"); function traceLinePaths(data, cellGrid, settings) { const polygons = []; const rows = data.length - 1; const cols = data[0].length - 1; const valid_entries = [ "right", "bottom", "left", "top" ]; const add_x = [0, -1, 0, 1]; const add_y = [-1, 0, 1, 0]; const entry_dir = { bottom: 1, left: 2, top: 3, right: 0 }; if (!settings.noFrame) { if (requireLineFrame(data, settings.threshold)) { if (settings.linearRing) { polygons.push([ [0, 0], [0, rows], [cols, rows], [cols, 0], [0, 0] ]); } else { polygons.push([ [0, 0], [0, rows], [cols, rows], [cols, 0] ]); } } } cellGrid.forEach(function(a, i) { a.forEach(function(cell, j) { for (let e = 0; e < 4; e++) { const nextedge = valid_entries[e]; if (typeof _optionalChain([cell, 'optionalAccess', _7 => _7.edges, 'access', _8 => _8[nextedge]]) !== "object") continue; let ee = cell.edges[nextedge], enter = nextedge, x = i, y = j, finalized = false; const path = [], origin = [i + ee.path[0][0], j + ee.path[0][1]]; path.push(origin); while (!finalized) { let cc = cellGrid[x][y]; if (typeof _optionalChain([cc, 'optionalAccess', _9 => _9.edges, 'access', _10 => _10[enter]]) !== "object") break; ee = cc.edges[enter]; delete cc.edges[enter]; const point = ee.path[1]; point[0] += x; point[1] += y; path.push(point); enter = ee.move.enter; x = x + ee.move.x; y = y + ee.move.y; if (typeof cellGrid[x] === "undefined" || typeof cellGrid[x][y] === "undefined") { if (!settings.linearRing) break; let dir = 0, count = 0; if (x === cols) { x--; dir = 0; } else if (x < 0) { x++; dir = 2; } else if (y === rows) { y--; dir = 3; } else if (y < 0) { y++; dir = 1; } if (x === i && y === j && dir === entry_dir[nextedge]) { finalized = true; enter = nextedge; break; } while (true) { let found_entry = false; if (count > 4) throw new Error( "Direction change counter overflow! This should never happen!" ); if (!(typeof cellGrid[x] === "undefined" || typeof cellGrid[x][y] === "undefined")) { cc = cellGrid[x][y]; const ve = valid_entries[dir]; if (typeof _optionalChain([cc, 'optionalAccess', _11 => _11.edges, 'access', _12 => _12[ve]]) === "object") { ee = cc.edges[ve]; path.push(entry_coordinate(x, y, dir, ee.path)); enter = ve; found_entry = true; break; } } if (found_entry) { break; } else { path.push(skip_coordinate(x, y, dir)); x += add_x[dir]; y += add_y[dir]; if (typeof cellGrid[x] === "undefined" || typeof cellGrid[x][y] === "undefined") { if (dir === 0 && y < 0 || dir === 1 && x < 0 || dir === 2 && y === rows || dir === 3 && x === cols) { x -= add_x[dir]; y -= add_y[dir]; dir = (dir + 1) % 4; count++; } } if (x === i && y === j && dir === entry_dir[nextedge]) { finalized = true; enter = nextedge; break; } } } } } if (settings.linearRing && (path[path.length - 1][0] !== origin[0] || path[path.length - 1][1] !== origin[1])) path.push(origin); polygons.push(path); } }); }); return polygons; } __name(traceLinePaths, "traceLinePaths"); // src/quadtree.ts var TreeNode = class _TreeNode { static { __name(this, "TreeNode"); } constructor(data, x, y, dx, dy) { let dx_tmp = dx, dy_tmp = dy, msb_x = 0, msb_y = 0; this.x = x; this.y = y; this.childA = null; this.childB = null; this.childC = null; this.childD = null; if (dx === 1 && dy === 1) { this.lowerBound = Math.min( data[y][x], data[y][x + 1], data[y + 1][x + 1], data[y + 1][x] ); this.upperBound = Math.max( data[y][x], data[y][x + 1], data[y + 1][x + 1], data[y + 1][x] ); } else { if (dx > 1) { while (dx_tmp !== 0) { dx_tmp = dx_tmp >> 1; msb_x++; } if (dx === 1 << msb_x - 1) msb_x--; dx_tmp = 1 << msb_x - 1; } if (dy > 1) { while (dy_tmp !== 0) { dy_tmp = dy_tmp >> 1; msb_y++; } if (dy === 1 << msb_y - 1) msb_y--; dy_tmp = 1 << msb_y - 1; } this.childA = new _TreeNode(data, x, y, dx_tmp, dy_tmp); this.lowerBound = this.childA.lowerBound; this.upperBound = this.childA.upperBound; if (dx - dx_tmp > 0) { this.childB = new _TreeNode(data, x + dx_tmp, y, dx - dx_tmp, dy_tmp); this.lowerBound = Math.min(this.lowerBound, this.childB.lowerBound); this.upperBound = Math.max(this.upperBound, this.childB.upperBound); if (dy - dy_tmp > 0) { this.childC = new _TreeNode( data, x + dx_tmp, y + dy_tmp, dx - dx_tmp, dy - dy_tmp ); this.lowerBound = Math.min(this.lowerBound, this.childC.lowerBound); this.upperBound = Math.max(this.upperBound, this.childC.upperBound); } } if (dy - dy_tmp > 0) { this.childD = new _TreeNode(data, x, y + dy_tmp, dx_tmp, dy - dy_tmp); this.lowerBound = Math.min(this.lowerBound, this.childD.lowerBound); this.upperBound = Math.max(this.upperBound, this.childD.upperBound); } } } /** * Retrieve a list of cells within a particular range of values by * recursivly traversing the quad tree to it's leaves. * * @param subsumed If 'true' include all cells that are completely * subsumed within the specified range. Otherwise, * return only cells where at least one corner is * outside the specified range. * * @return An array of objects 'o' where each object has exactly two * properties: 'o.x' and 'o.y' denoting the left-bottom corner * of the corresponding cell. */ cellsInBand(lowerBound, upperBound, subsumed) { let cells = []; subsumed = typeof subsumed === "undefined" ? true : subsumed; if (this.lowerBound > upperBound || this.upperBound < lowerBound) return cells; if (!(this.childA || this.childB || this.childC || this.childD)) { if (subsumed || this.lowerBound <= lowerBound || this.upperBound >= upperBound) { cells.push({ x: this.x, y: this.y }); } } else { if (this.childA) cells = cells.concat( this.childA.cellsInBand(lowerBound, upperBound, subsumed) ); if (this.childB) cells = cells.concat( this.childB.cellsInBand(lowerBound, upperBound, subsumed) ); if (this.childD) cells = cells.concat( this.childD.cellsInBand(lowerBound, upperBound, subsumed) ); if (this.childC) cells = cells.concat( this.childC.cellsInBand(lowerBound, upperBound, subsumed) ); } return cells; } cellsBelowThreshold(threshold, subsumed) { let cells = []; subsumed = typeof subsumed === "undefined" ? true : subsumed; if (this.lowerBound > threshold) return cells; if (!(this.childA || this.childB || this.childC || this.childD)) { if (subsumed || this.upperBound >= threshold) { cells.push({ x: this.x, y: this.y }); } } else { if (this.childA) cells = cells.concat( this.childA.cellsBelowThreshold(threshold, subsumed) ); if (this.childB) cells = cells.concat( this.childB.cellsBelowThreshold(threshold, subsumed) ); if (this.childD) cells = cells.concat( this.childD.cellsBelowThreshold(threshold, subsumed) ); if (this.childC) cells = cells.concat( this.childC.cellsBelowThreshold(threshold, subsumed) ); } return cells; } }; var QuadTree = class { static { __name(this, "QuadTree"); } constructor(data) { if (!data) throw new Error("data is required"); if (!Array.isArray(data) || !Array.isArray(data[0])) throw new Error("data must be scalar field, i.e. array of arrays"); if (data.length < 2) throw new Error("data must contain at least two rows"); const cols = data[0].length; if (cols < 2) throw new Error("data must contain at least two columns"); for (let i = 1; i < data.length; i++) { if (!Array.isArray(data[i])) throw new Error("Row " + i + " is not an array"); if (data[i].length != cols) throw new Error( "unequal row lengths detected, please provide a regular grid" ); } this.data = data; this.root = new TreeNode(data, 0, 0, data[0].length - 1, data.length - 1); } }; // src/isolines.ts function isoLines(input, thresholds, options) { let settings, i, j, useQuadTree = false, tree = null, root = null, data, cellGrid = [], linePolygons, ret = []; options = _nullishCoalesce(options, () => ( {})); if (!!options && typeof options !== "object") throw new Error("options must be an object"); settings = isoLineOptions(options); if (!input) throw new Error("data is required"); if (input instanceof QuadTree) { tree = input; root = input.root; data = input.data; if (!settings.noQuadTree) useQuadTree = true; } else if (Array.isArray(input) && Array.isArray(input[0])) { data = input; } else { throw new Error( "input is neither array of arrays nor object retrieved from 'QuadTree()'" ); } if (thresholds === void 0 || thresholds === null) throw new Error("thresholds is required"); if (!Array.isArray(thresholds)) throw new Error("thresholds must be an array"); if (!settings.noQuadTree) useQuadTree = true; for (i = 0; i < thresholds.length; i++) if (isNaN(+thresholds[i])) throw new Error("thresholds[" + i + "] is not a number"); if (useQuadTree && !root) { tree = new QuadTree(data); root = tree.root; data = tree.data; } if (settings.verbose) { if (settings.polygons) console.log( "isoLines: returning single lines (polygons) for each grid cell" ); else console.log( "isoLines: returning line paths (polygons) for entire data grid" ); } thresholds.forEach(function(t, i2) { linePolygons = []; settings.threshold = t; if (settings.verbose) console.log( "MarchingSquaresJS-isoLines: computing iso lines for threshold " + t ); if (settings.polygons) { if (useQuadTree) { root.cellsBelowThreshold(settings.threshold, true).forEach(function(c) { const cell = prepareCell(data, c.x, c.y, settings); if (cell) { linePolygons = linePolygons.concat( cell2Polygons(cell, c.x, c.y, settings) ); } }); } else { for (j = 0; j < data.length - 1; ++j) { for (i2 = 0; i2 < data[0].length - 1; ++i2) { const cell = prepareCell(data, i2, j, settings); if (cell) { linePolygons = linePolygons.concat( cell2Polygons(cell, i2, j, settings) ); } } } } } else { cellGrid = []; for (i2 = 0; i2 < data[0].length - 1; ++i2) cellGrid[i2] = []; if (useQuadTree) { root.cellsBelowThreshold(settings.threshold, false).forEach(function(c) { cellGrid[c.x][c.y] = prepareCell(data, c.x, c.y, settings); }); } else { for (i2 = 0; i2 < data[0].length - 1; ++i2) { for (j = 0; j < data.length - 1; ++j) { cellGrid[i2][j] = prepareCell(data, i2, j, settings); } } } linePolygons = traceLinePaths(data, cellGrid, settings); } ret.push(linePolygons); if (typeof settings.successCallback === "function") { settings.successCallback(ret, t); } }); return ret; } __name(isoLines, "isoLines"); function prepareCell(grid, x, y, settings) { let cval = 0; const x3 = grid[y + 1][x], x2 = grid[y + 1][x + 1], x1 = grid[y][x + 1], x0 = grid[y][x], threshold = settings.threshold; if (isNaN(x0) || isNaN(x1) || isNaN(x2) || isNaN(x3)) { return; } cval |= x3 >= threshold ? 8 : 0; cval |= x2 >= threshold ? 4 : 0; cval |= x1 >= threshold ? 2 : 0; cval |= x0 >= threshold ? 1 : 0; cval = +cval; const cell = { cval, polygons: [], edges: {}, x0, x1, x2, x3 }; let left, right, top, bottom, average; switch (cval) { case 0: if (settings.polygons) cell.polygons.push([ [0, 0], [0, 1], [1, 1], [1, 0] ]); break; case 15: break; case 14: left = settings.interpolate(x0, x3, threshold); bottom = settings.interpolate(x0, x1, threshold); if (settings.polygons_full) { cell.edges.left = { path: [ [0, left], [bottom, 0] ], move: { x: 0, y: -1, enter: "top" } }; } if (settings.polygons) cell.polygons.push([ [0, 0], [0, left], [bottom, 0] ]); break; case 13: bottom = settings.interpolate(x0, x1, threshold); right = settings.interpolate(x1, x2, threshold); if (settings.polygons_full) { cell.edges.bottom = { path: [ [bottom, 0], [1, right] ], move: { x: 1, y: 0, enter: "left" } }; } if (settings.polygons) cell.polygons.push([ [bottom, 0], [1, right], [1, 0] ]); break; case 11: right = settings.interpolate(x1, x2, threshold); top = settings.interpolate(x3, x2, threshold); if (settings.polygons_full) { cell.edges.right = { path: [ [1, right], [top, 1] ], move: { x: 0, y: 1, enter: "bottom" } }; } if (settings.polygons) cell.polygons.push([ [1, right], [top, 1], [1, 1] ]); break; case 7: left = settings.interpolate(x0, x3, threshold); top = settings.interpolate(x3, x2, threshold); if (settings.polygons_full) { cell.edges.top = { path: [ [top, 1], [0, left] ], move: { x: -1, y: 0, enter: "right" } }; } if (settings.polygons) cell.polygons.push([ [top, 1], [0, left], [0, 1] ]); break; case 1: left = settings.interpolate(x0, x3, threshold); bottom = settings.interpolate(x0, x1, threshold); if (settings.polygons_full) { cell.edges.bottom = { path: [ [bottom, 0], [0, left] ], move: { x: -1, y: 0, enter: "right" } }; } if (settings.polygons) cell.polygons.push([ [bottom, 0], [0, left], [0, 1], [1, 1], [1, 0] ]); break; case 2: bottom = settings.interpolate(x0, x1, threshold); right = settings.interpolate(x1, x2, threshold); if (settings.polygons_full) { cell.edges.right = { path: [ [1, right], [bottom, 0] ], move: { x: 0, y: -1, enter: "top" } }; } if (settings.polygons) cell.polygons.push([ [0, 0], [0, 1], [1, 1], [1, right], [bottom, 0] ]); break; case 4: right = settings.interpolate(x1, x2, threshold); top = settings.interpolate(x3, x2, threshold); if (settings.polygons_full) { cell.edges.top = { path: [ [top, 1], [1, right] ], move: { x: 1, y: 0, enter: "left" } }; } if (settings.polygons) cell.polygons.push([ [0, 0], [0, 1], [top, 1], [1, right], [1, 0] ]); break; case 8: left = settings.interpolate(x0, x3, threshold); top = settings.interpolate(x3, x2, threshold); if (settings.polygons_full) { cell.edges.left = { path: [ [0, left], [top, 1] ], move: { x: 0, y: 1, enter: "bottom" } }; } if (settings.polygons) cell.polygons.push([ [0, 0], [0, left], [top, 1], [1, 1], [1, 0] ]); break; case 12: left = settings.interpolate(x0, x3, threshold); right = settings.interpolate(x1, x2, threshold); if (settings.polygons_full) { cell.edges.left = { path: [ [0, left], [1, right] ], move: { x: 1, y: 0, enter: "left" } }; } if (settings.polygons) cell.polygons.push([ [0, 0], [0, left], [1, right], [1, 0] ]); break; case 9: bottom = settings.interpolate(x0, x1, threshold); top = settings.interpolate(x3, x2, threshold); if (settings.polygons_full) { cell.edges.bottom = { path: [ [bottom, 0], [top, 1] ], move: { x: 0, y: 1, enter: "bottom" } }; } if (settings.polygons) cell.polygons.push([ [bottom, 0], [top, 1], [1, 1], [1, 0] ]); break; case 3: left = settings.interpolate(x0, x3, threshold); right = settings.interpolate(x1, x2, threshold); if (settings.polygons_full) { cell.edges.right = { path: [ [1, right], [0, left] ], move: { x: -1, y: 0, enter: "right" } }; } if (settings.polygons) cell.polygons.push([ [0, left], [0, 1], [1, 1], [1, right] ]); break; case 6: bottom = settings.interpolate(x0, x1, threshold); top = settings.interpolate(x3, x2, threshold); if (settings.polygons_full) { cell.edges.top = { path: [ [top, 1], [bottom, 0] ], move: { x: 0, y: -1, enter: "top" } }; } if (settings.polygons) cell.polygons.push([ [0, 0], [0, 1], [top, 1], [bottom, 0] ]); break; case 10: left = settings.interpolate(x0, x3, threshold); right = settings.interpolate(x1, x2, threshold); bottom = settings.interpolate(x0, x1, threshold); top = settings.interpolate(x3, x2, threshold); average = (x0 + x1 + x2 + x3) / 4; if (settings.polygons_full) { if (average < threshold) { cell.edges.left = { path: [ [0, left], [top, 1] ], move: { x: 0, y: 1, enter: "bottom" } }; cell.edges.right = { path: [ [1, right], [bottom, 0] ], move: { x: 0, y: -1, enter: "top" } }; } else { cell.edges.right = { path: [ [1, right], [top, 1] ], move: { x: 0, y: 1, enter: "bottom" } }; cell.edges.left = { path: [ [0, left], [bottom, 0] ], move: { x: 0, y: -1, enter: "top" } }; } } if (settings.polygons) { if (average < threshold) { cell.polygons.push([ [0, 0], [0, left], [top, 1], [1, 1], [1, right], [bottom, 0] ]); } else { cell.polygons.push([ [0, 0], [0, left], [bottom, 0] ]); cell.polygons.push([ [top, 1], [1, 1], [1, right] ]); } } break; case 5: left = settings.interpolate(x0, x3, threshold); right = settings.interpolate(x1, x2, threshold); bottom = settings.interpolate(x0, x1, threshold); top = settings.interpolate(x3, x2, threshold); average = (x0 + x1 + x2 + x3) / 4; if (settings.polygons_full) { if (average < threshold) { cell.edges.bottom = { path: [ [bottom, 0], [0, left] ], move: { x: -1, y: 0, enter: "right" } }; cell.edges.top = { path: [ [top, 1], [1, right] ], move: { x: 1, y: 0, enter: "left" } }; } else { cell.edges.top = { path: [ [top, 1], [0, left] ], move: { x: -1, y: 0, enter: "right" } }; cell.edges.bottom = { path: [ [bottom, 0], [1, right] ], move: { x: 1, y: 0, enter: "left" } }; } } if (settings.polygons) { if (average < threshold) { cell.polygons.push([ [0, left], [0, 1], [top, 1], [1, right], [1, 0], [bottom, 0] ]); } else { cell.polygons.push([ [0, left], [0, 1], [top, 1] ]); cell.polygons.push([ [bottom, 0], [1, right], [1, 0] ]); } } break; } return cell; } __name(prepareCell, "prepareCell"); // src/isobands.ts var shapeCoordinates = { square: /* @__PURE__ */ __name(function(cell, x0, x1, x2, x3, opt) { if (opt.polygons) cell.polygons.push([ [0, 0], [0, 1], [1, 1], [1, 0] ]); }, "square"), triangle_bl: /* @__PURE__ */ __name(function(cell, x0, x1, x2, x3, opt) { const bottomleft = opt.interpolate(x0, x1, opt.minV, opt.maxV); const leftbottom = opt.interpolate(x0, x3, opt.minV, opt.maxV); if (opt.polygons_full) { cell.edges.lb = { path: [ [0, leftbottom], [bottomleft, 0] ], move: { x: 0, y: -1, enter: "tl" } }; } if (opt.polygons) cell.polygons.push([ [0, leftbottom], [bottomleft, 0], [0, 0] ]); }, "triangle_bl"), triangle_br: /* @__PURE__ */ __name(function(cell, x0, x1, x2, x3, opt) { const bottomright = opt.interpolate(x0, x1, opt.minV, opt.maxV); const rightbottom = opt.interpolate(x1, x2, opt.minV, opt.maxV); if (opt.polygons_full) { cell.edges.br = { path: [ [bottomright, 0], [1, rightbottom] ], move: { x: 1, y: 0, enter: "lb" } }; } if (opt.polygons) cell.polygons.push([ [bottomright, 0], [1, rightbottom], [1, 0] ]); }, "triangle_br"), triangle_tr: /* @__PURE__ */ __name(function(cell, x0, x1, x2, x3, opt) { const righttop = opt.interpolate(x1, x2, opt.minV, opt.maxV); const topright = opt.interpolate(x3, x2, opt.minV, opt.maxV); if (opt.polygons_full) { cell.edges.rt = { path: [ [1, righttop], [topright, 1] ], move: { x: 0, y: 1, enter: "br" } }; } if (opt.polygons) cell.polygons.push([ [1, righttop], [topright, 1], [1, 1] ]); }, "triangle_tr"), triangle_tl: /* @__PURE__ */ __name(function(cell, x0, x1, x2, x3, opt) { const topleft = opt.interpolate(x3, x2, opt.minV, opt.maxV); const lefttop = opt.interpolate(x0, x3, opt.minV, opt.maxV); if (opt.polygons_full) { cell.edges.tl = { path: [ [topleft, 1], [0, lefttop] ], move: { x: -1, y: 0, enter: "rt" } }; } if (opt.polygons) cell.polygons.push([ [0, lefttop], [0, 1], [topleft, 1] ]); }, "triangle_tl"), tetragon_t: /* @__PURE__ */ __name(function(cell, x0, x1, x2, x3, opt) { const righttop = opt.interpolate(x1, x2, opt.minV, opt.maxV); const lefttop = opt.interpolate(x0, x3, opt.minV, opt.maxV); if (opt.polygons_full) { cell.edges.rt = { path: [ [1, righttop], [0, lefttop] ], move: { x: -1, y: 0, enter: "rt" } }; } if (opt.polygons) cell.polygons.push([ [0, lefttop], [0, 1], [1, 1], [1, righttop] ]); }, "tetragon_t"), tetragon_r: /* @__PURE__ */ __name(function(cell, x0, x1, x2, x3, opt) { const bottomright = opt.interpolate(x0, x1, opt.minV, opt.maxV); const topright = opt.interpolate(x3, x2, opt.minV, opt.maxV); if (opt.polygons_full) { cell.edges.br = { path: [ [bottomright, 0], [topright, 1] ], move: { x: 0, y: 1, enter: "br" } }; } if (opt.polygons) cell.polygons.push([ [bottomright, 0], [topright, 1], [1, 1], [1, 0] ]); }, "tetragon_r"), tetragon_b: /* @__PURE__ */ __name(function(cell, x0, x1, x2, x3, opt) { const leftbottom = opt.interpolate(x0, x3, opt.minV, opt.maxV); const rightbottom = opt.interpolate(x1, x2, opt.minV, opt.maxV); if (opt.polygons_full) { cell.edges.lb = { path: [ [0, leftbottom], [1, rightbottom] ], move: { x: 1, y: 0, enter: "lb" } }; } if (opt.polygons) cell.polygons.push([ [0, 0], [0, leftbottom], [1, rightbottom], [1, 0] ]); }, "tetragon_b"), tetragon_l: /* @__PURE__ */ __name(function(cell, x0, x1, x2, x3, opt) { const topleft = opt.interpolate(x3, x2, opt.minV, opt.maxV); const bottomleft = opt.interpolate(x0, x1, opt.minV, opt.maxV); if (opt.polygons_full) { cell.edges.tl = { path: [ [topleft, 1], [bottomleft, 0] ], move: { x: 0, y: -1, enter: "tl" } }; } if (opt.polygons) cell.polygons.push([ [0, 0], [0, 1], [topleft, 1], [bottomleft, 0] ]); }, "tetragon_l"), tetragon_bl: /* @__PURE__ */ __name(function(cell, x0, x1, x2, x3, opt) { const bottomleft = opt.interpolate_a(x0, x1, opt.minV, opt.maxV); const bottomright = opt.interpolate_b(x0, x1, opt.minV, opt.maxV); const leftbottom = opt.interpolate_a(x0, x3, opt.minV, opt.maxV); const lefttop = opt.interpolate_b(x0, x3, opt.minV, opt.maxV); if (opt.polygons_full) { cell.edges.bl = { path: [ [bottomleft, 0], [0, leftbottom] ], move: { x: -1, y: 0, enter: "rb" } }; cell.edges.lt = { path: [ [0, lefttop], [bottomright, 0] ], move: { x: 0, y: -1, enter: "tr" } }; } if (opt.polygons) cell.polygons.push([ [bottomleft, 0], [0, leftbottom], [0, lefttop], [bottomright, 0] ]); }, "tetragon_bl"), tetragon_br: /* @__PURE__ */ __name(function(cell, x0, x1, x2, x3, opt) { const bottomleft = opt.interpolate_a(x0, x1, opt.minV, opt.maxV); const bottomright = opt.interpolate_b(x0, x1, opt.minV, opt.maxV); const rightbottom = opt.interpolate_a(x1, x2, opt.minV, opt.maxV); const righttop = opt.interpolate_b(x1, x2, opt.minV, opt.maxV); if (opt.polygons_full) { cell.edges.bl = { path: [ [bottomleft, 0], [1, righttop] ], move: { x: 1, y: 0, enter: "lt" } }; cell.edges.rb = { path: [ [1, rightbottom], [bottomright, 0] ], move: { x: 0, y: -1, enter: "tr" } }; } if (opt.polygons) cell.polygons.push([ [bottomleft, 0], [1, righttop], [1, rightbottom], [bottomright, 0] ]); }, "tetragon_br"), tetragon_tr: /* @__PURE__ */ __name(function(cell, x0, x1, x2, x3, opt) { const topleft = opt.interpolate_a(x3, x2, opt.minV, opt.maxV); const topright = opt.interpolate_b(x3, x2, opt.minV, opt.maxV); const righttop = opt.interpolate_b(x1, x2, opt.minV, opt.maxV); const rightbottom = opt.interpolate_a(x1, x2, opt.minV, opt.maxV); if (opt.polygons_full) { cell.edges.rb = { path: [ [1, rightbottom], [topleft, 1] ], move: { x: 0, y: 1, enter: "bl" } }; cell.edges.tr = { path: [ [topright, 1], [1, righttop] ], move: { x: 1, y: 0, enter: "lt" } }; } if (opt.polygons) cell.polygons.push([ [1, rightbottom], [topleft, 1], [topright, 1], [1, righttop] ]); }, "tetragon_tr"), tetragon_tl: /* @__PURE__ */ __name(function(cell, x0, x1, x2, x3, opt) { const topleft = opt.interpolate_a(x3, x2, opt.minV, opt.maxV); const topright = opt.interpolate_b(x3, x2, opt.minV, opt.maxV); const lefttop = opt.interpolate_b(x0, x3, opt.minV, opt.maxV); const leftbottom = opt.interpolate_a(x0, x3, opt.minV, opt.maxV); if (opt.polygons_full) { cell.edges.tr = { path: [ [topright, 1], [0, leftbottom] ], move: { x: -1, y: 0, enter: "rb" } }; cell.edges.lt = { path: [ [0, lefttop], [topleft, 1] ], move: { x: 0, y: 1, enter: "bl" } }; } if (opt.polygons) cell.polygons.push([ [topright, 1], [0, leftbottom], [0, lefttop], [topleft, 1] ]); }, "tetragon_tl"), tetragon_lr: /* @__PURE__ */ __name(function(cell, x0, x1, x2, x3, opt) { const leftbottom = opt.interpolate_a(x0, x3, opt.minV, opt.maxV); const lefttop = opt.interpolate_b(x0, x3, opt.minV, opt.maxV); const righttop = opt.interpolate_b(x1, x2, opt.minV, opt.maxV); const rightbottom = opt.interpolate_a(x1, x2, opt.minV, opt.maxV); if (opt.polygons_full) { cell.edges.lt = { path: [ [0, lefttop], [1, righttop] ], move: { x: 1, y: 0, enter: "lt" } }; cell.edges.rb = { path: [ [1, rightbottom], [0, leftbottom] ], move: { x: -1, y: 0, enter: "rb" } }; } if (opt.polygons) cell.polygons.push([ [0, leftbottom], [0, lefttop], [1, righttop], [1, rightbottom] ]); }, "tetragon_lr"), tetragon_tb: /* @__PURE__ */ __name(function(cell, x0, x1, x2, x3, opt) { const topleft = opt.interpolate_a(x3, x2, opt.minV, opt.maxV); const topright = opt.interpolate_b(x3, x2, opt.minV, opt.maxV); const bottomright = opt.interpolate_b(x0, x1, opt.minV, opt.maxV); const bottomleft = opt.interpolate_a(x0, x1, opt.minV, opt.maxV); if (opt.polygons_full) { cell.edges.tr = { path: [ [topright, 1], [bottomright, 0] ], move: { x: 0, y: -1, enter: "tr" } }; cell.edges.bl = { path: [ [bottomleft, 0], [topleft, 1] ], move: { x: 0, y: 1, enter: "bl" } }; } if (opt.polygons) cell.polygons.push([ [bottomleft, 0], [topleft, 1], [topright, 1], [bottomright, 0] ]); }, "tetragon_tb"), pentagon_tr: /* @__PURE__ */ __name(function(cell, x0, x1, x2, x3, opt) { const topleft = opt.interpolate(x3, x2, opt.minV, opt.maxV); const rightbottom = opt.interpolate(x1, x2, opt.minV, opt.maxV); if (opt.polygons_full) { cell.edges.tl = { path: [ [topleft, 1], [1, rightbottom] ], move: { x: 1, y: 0, enter: "lb" } }; } if (opt.polygons) cell.polygons.push([ [0, 0], [0, 1], [topleft, 1], [1, rightbottom], [1, 0] ]); }, "pentagon_tr"), pentagon_tl: /* @__PURE__ */ __name(function(cell, x0, x1, x2, x3, opt) { const leftbottom = opt.interpolate(x0, x3, opt.minV, opt.maxV); const topright = opt.interpolate(x3, x2, opt.minV, opt.maxV); if (opt.polygons_full) { cell.edges.lb = { path: [ [0, leftbottom], [topright, 1] ], move: { x: 0, y: 1, enter: "br" } }; } if (opt.polygons) cell.polygons.push([ [0, 0], [0, leftbottom], [topright, 1], [1, 1], [1, 0] ]); }, "pentagon_tl"), pentagon_br: /* @__PURE__ */ __name(function(cell, x0, x1, x2, x3, opt) { const bottomleft = opt.interpolate(x0, x1, opt.minV, opt.maxV); const righttop = opt.interpolate(x1, x2, opt.minV, opt.maxV); if (opt.polygons_full) { cell.edges.rt = { path: [ [1, righttop], [bottomleft, 0] ], move: { x: 0, y: -1, enter: "tl" } }; } if (opt.polygons) cell.polygons.push([ [0, 0], [0, 1], [1, 1], [1, righttop], [bottomleft, 0] ]); }, "pentagon_br"), pentagon_bl: /* @__PURE__ */ __name(function(cell, x0, x1, x2, x3, opt) { const lefttop = opt.interpolate(x0, x3, opt.minV, opt.maxV); const bottomright = opt.interpolate(x0, x1, opt.minV, opt.maxV); if (opt.polygons_full) { cell.edges.br = { path: [ [bottomright, 0], [0, lefttop] ], move: { x: -1, y: 0, enter: "rt" } }; } if (opt.polygons) cell.polygons.push([ [0, lefttop], [0, 1], [1, 1], [1, 0], [bottomright, 0] ]); }, "pentagon_bl"), pentagon_tr_rl: /* @__PURE__ */ __name(function(cell, x0, x1, x2, x3, opt) { const lefttop = opt.interpolate(x0, x3, opt.minV, opt.maxV); const topleft = opt.interpolate(x3, x2, opt.minV, opt.maxV); const righttop = opt.interpolate_b(x1, x2, opt.minV, opt.maxV); const rightbottom = opt.interpolate_a(x1, x2, opt.minV, opt.maxV); if (opt.polygons_full) { cell.edges.tl = { path: [ [topleft, 1], [1, righttop] ], move: { x: 1, y: 0, enter: "lt" } }; cell.edges.rb = { path: [ [1, rightbottom], [0, lefttop] ], move: { x: -1, y: 0, enter: "rt" } }; } if (opt.polygons) cell.polygons.push([ [0, lefttop], [0, 1], [topleft, 1], [1, righttop], [1, rightbottom] ]); }, "pentagon_tr_rl"), pentagon_rb_bt: /* @__PURE__ */ __name(function(cell, x0, x1, x2, x3, opt) { const righttop = opt.interpolate(x1, x2, opt.minV, opt.maxV); const bottomright = opt.interpolate_b(x0, x1, opt.minV, opt.maxV); const bottomleft = opt.interpolate_a(x0, x1, opt.minV, opt.maxV); const topright = opt.interpolate(x3, x2, opt.minV, opt.maxV); if (opt.polygons_full) { cell.edges.rt = { path: [ [1, righttop], [bottomright, 0] ], move: { x: 0, y: -1, enter: "tr" } }; cell.edges.bl = { path: [ [bottomleft, 0], [topright, 1] ], move: { x: 0, y: 1, enter: "br" } }; } if (opt.polygons) cell.polygons.push([ [topright, 1], [1, 1], [1, righttop], [bottomright, 0], [bottomleft, 0] ]); }, "pentagon_rb_bt"), pentagon_bl_lr: /* @__PURE__ */ __name(function(cell, x0, x1, x2, x3, opt) { const bottomright = opt.interpolate(x0, x1, opt.minV, opt.maxV); const leftbottom = opt.interpolate_a(x0, x3, opt.minV, opt.maxV); const lefttop = opt.interpolate_b(x0, x3, opt.minV, opt.maxV); const rightbottom = opt.interpolate(x1, x2, opt.minV, opt.maxV); if (opt.polygons_full) { cell.edges.br = { path: [ [bottomright, 0], [0, leftbottom] ], move: { x: -1, y: 0, enter: "rb" } }; cell.edges.lt = { path: [ [0, lefttop], [1, rightbottom] ], move: { x: 1, y: 0, enter: "lb" } }; } if (opt.polygons) cell.polygons.push([ [bottomright, 0], [0, leftbottom], [0, lefttop], [1, rightbottom], [1, 0] ]); }, "pentagon_bl_lr"), pentagon_lt_tb: /* @__PURE__ */ __name(function(cell, x0, x1, x2, x3, opt) { const leftbottom = opt.interpolate(x0, x3, opt.minV, opt.maxV); const topleft = opt.interpolate_a(x3, x2, opt.minV, opt.maxV); const topright = opt.interpolate_b(x3, x2, opt.minV, opt.maxV); const bottomleft = opt.interpolate(x0, x1, opt.minV, opt.maxV); if (opt.polygons_full) { cell.edges.lb = { path: [ [0, leftbottom], [topleft, 1] ], move: { x: 0, y: 1, enter: "bl" } }; cell.edges.tr = { path: [ [topright, 1], [bottomleft, 0] ], move: { x: 0, y: -1, enter: "tl" } }; } if (opt.polygons) cell.polygons.push([ [0, 0], [0, leftbottom], [topleft, 1], [topright, 1], [bottomleft, 0] ]); }, "pentagon_lt_tb"), pentagon_bl_tb: /* @__PURE__ */ __name(function(cell, x0, x1, x2, x3, opt) { const lefttop = opt.interpolate(x0, x3, opt.minV, opt.maxV); const topleft = opt.interpolate(x3, x2, opt.minV, opt.maxV); const bottomright = opt.interpolate_b(x0, x1, opt.minV, opt.maxV); const bottomleft = opt.interpolate_a(x0, x1, opt.minV, opt.maxV); if (opt.polygons_full) { cell.edges.bl = { path: [ [bottomleft, 0], [0, lefttop] ], move: { x: -1, y: 0, enter: "rt" } }; cell.edges.tl = { path: [ [topleft, 1], [bottomright, 0] ], move: { x: 0, y: -1, enter: "tr" } }; } if (opt.polygons) cell.polygons.push([ [0, lefttop], [0, 1], [topleft, 1], [bottomright, 0], [bottomleft, 0] ]); }, "pentagon_bl_tb"), pentagon_lt_rl: /* @__PURE__ */ __name(function(cell, x0, x1, x2, x3, opt) { const leftbottom = opt.interpolate_a(x0, x3, opt.minV, opt.maxV); const lefttop = opt.interpolate_b(x0, x3, opt.minV, opt.maxV); const topright = opt.interpolate(x3, x2, opt.minV, opt.maxV); const righttop = opt.interpolate(x1, x3, opt.minV, opt.maxV); if (opt.polygons_full) { cell.edges.lt = { path: [ [0, lefttop], [topright, 1] ], move: { x: 0, y: 1, enter: "br" } }; cell.edges.rt = { path: [ [1, righttop], [0, leftbottom] ], move: { x: -1, y: 0, enter: "rb" } }; } if (opt.polygons) cell.polygons.push([ [0, leftbottom], [0, lefttop], [topright, 1], [1, 1], [1, righttop] ]); }, "pentagon_lt_rl"), pentagon_tr_bt: /* @__PURE__ */ __name(function(cell, x0, x1, x2, x3, opt) { const topleft = opt.interpolate_a(x3, x2, opt.minV, opt.maxV); const topright = opt.interpolate_b(x3, x2, opt.minV, opt.maxV); const rightbottom = opt.interpolate(x1, x2, opt.minV, opt.maxV); const bottomright = opt.interpolate(x0, x1, opt.minV, opt.maxV); if (opt.polygons_full) { cell.edges.br = { path: [ [bottomright, 0], [topleft, 1] ], move: { x: 0, y: 1, enter: "bl" } }; cell.edges.tr = { path: [ [topright, 1], [1, rightbottom] ], move: { x: 1, y: 0, enter: "lb" } }; } if (opt.polygons) cell.polygons.push([ [topleft, 1], [topright, 1], [1, rightbottom], [1, 0], [bottomright, 0] ]); }, "pentagon_tr_bt"), pentagon_rb_lr: /* @__PURE__ */ __name(function(cell, x0, x1, x2, x3, opt) { const leftbottom = opt.interpolate(x0, x3, opt.minV, opt.maxV); const righttop = opt.interpolate_b(x1, x2, opt.minV, opt.maxV); const rightbottom = opt.interpolate_a(x1, x2, opt.minV, opt.maxV); const bottomleft = opt.interpolate(x0, x1, opt.minV, opt.maxV); if (opt.polygons_full) { cell.edges.lb = { path: [ [0, leftbottom], [1, righttop] ], move: { x: 1, y: 0, enter: "lt" } }; cell.edges.rb = { path: [ [1, rightbottom], [bottomleft, 0] ], move: { x: 0, y: -1, enter: "tl" } }; } if (opt.polygons) cell.polygons.push([ [0, 0], [0, leftbottom], [1, righttop], [1, rightbottom], [bottomleft, 0] ]); }, "pentagon_rb_lr"), hexagon_lt_tr: /* @__PURE__ */ __name(function(cell, x0, x1, x2, x3, opt) { const leftbottom = opt.interpolate(x0, x3, opt.minV, opt.maxV); const topleft = opt.interpolate_a(x3, x2, opt.minV, opt.maxV); const topright = opt.interpolate_b(x3, x2, opt.minV, opt.maxV); const rightbottom = opt.interpolate(x1, x2, opt.minV, opt.maxV); if (opt.polygons_full) { cell.edges.lb = { path: [ [0, leftbottom], [topleft, 1] ], move: { x: 0, y: 1, enter: "bl" } }; cell.edges.tr = { path: [ [topright, 1], [1, rightbottom] ], move: { x: 1, y: 0, enter: "lb" } }; } if (opt.polygons) cell.polygons.push([ [0, 0], [0, leftbottom], [topleft, 1], [topright, 1], [1, rightbottom], [1, 0] ]); }, "hexagon_lt_tr"), hexagon_bl_lt: /* @__PURE__ */ __name(function(cell, x0, x1, x2, x3, opt) { const bottomright = opt.interpolate(x0, x1, opt.minV, opt.maxV); const leftbottom = opt.interpolate_a(x0, x3, opt.minV, opt.maxV); const lefttop = opt.interpolate_b(x0, x3, opt.minV, opt.maxV); const topright = opt.interpolate(x3, x2, opt.minV, opt.maxV); if (opt.polygons_full) { cell.edges.br = { path: [ [bottomright, 0], [0, leftbottom] ], move: { x: -1, y: 0, enter: "rb" } }; cell.edges.lt = { path: [ [0, lefttop], [topright, 1] ], move: { x: 0, y: 1, enter: "br" } }; } if (opt.polygons) cell.polygons.push([ [bottomright, 0], [0, leftbottom], [0, lefttop], [topright, 1], [1, 1], [1, 0] ]); }, "hexagon_bl_lt"), hexagon_bl_rb: /* @__PURE__ */ __name(function(cell, x0, x1, x2, x3, opt) { const bottomleft = opt.interpolate_a(x0, x1, opt.minV, opt.maxV); const bottomright = opt.interpolate_b(x0, x1, opt.minV, opt.maxV); const lefttop = opt.interpolate(x0, x3, opt.minV, opt.maxV); const righttop = opt.interpolate(x1, x2, opt.minV, opt.maxV); if (opt.polygons_full) { cell.edges.bl = { path: [ [bottomleft, 0], [0, lefttop] ], move: { x: -1, y: 0, enter: "rt" } }; cell.edges.rt = { path: [ [1, righttop], [bottomright, 0] ], move: { x: 0, y: -1, enter: "tr" } }; } if (opt.polygons) cell.polygons.push([ [bottomleft, 0], [0, lefttop], [0, 1], [1, 1], [1, righttop], [bottomright, 0] ]); }, "hexagon_bl_rb"), hexagon_tr_rb: /* @__PURE__ */ __name(function(cell, x0, x1, x2, x3, opt) { const bottomleft = opt.interpolate(x0, x1, opt.minV, opt.maxV); const topleft = opt.interpolate(x3, x2, opt.minV, opt.maxV); const righttop = opt.interpolate_b(x1, x2, opt.minV, opt.maxV); const rightbottom = opt.interpolate_a(x1, x2, opt.minV, opt.maxV); if (opt.polygons_full) { cell.edges.tl = { path: [ [topleft, 1], [1, righttop] ], move: { x: 1, y: 0, enter: "lt" } }; cell.edges.rb = { path: [ [1, rightbottom], [bottomleft, 0] ], move: { x: 0, y: -1, enter: "tl" } }; } if (opt.polygons) cell.polygons.push([ [0, 0], [0, 1], [topleft, 1], [1, righttop], [1, rightbottom], [bottomleft, 0] ]); }, "hexagon_tr_rb"), hexagon_lt_rb: /* @__PURE__ */ __name(function(cell, x0, x1, x2, x3, opt) { const leftbottom = opt.interpolate(x0, x3, opt.minV, opt.maxV); const topright = opt.interpolate(x3, x2, opt.minV, opt.maxV); const righttop = opt.interpolate(x1, x2, opt.minV, opt.maxV); const bottomleft = opt.interpolate(x0, x1, opt.minV, opt.maxV); if (opt.polygons_full) { cell.edges.lb = { path: [ [0, leftbottom], [topright, 1] ], move: { x: 0, y: 1, enter: "br" } }; cell.edges.rt = { path: [ [1, righttop], [bottomleft, 0] ], move: { x: 0, y: -1, enter: "tl" } }; } if (opt.polygons) cell.polygons.push([ [0, 0], [0, leftbottom], [topright, 1], [1, 1], [1, righttop], [bottomleft, 0] ]); }, "hexagon_lt_rb"), hexagon_bl_tr: /* @__PURE__ */ __name(function(cell, x0, x1, x2, x3, opt) { const bottomright = opt.interpolate(x0, x1, opt.minV, opt.maxV); const lefttop = opt.interpolate(x0, x3, opt.minV, opt.maxV); const topleft = opt.interpolate(x3, x2, opt.minV, opt.maxV); const rightbottom = opt.interpolate(x1, x2, opt.minV, opt.maxV); if (opt.polygons_full) { cell.edges.br = { path: [ [bottomright, 0], [0, lefttop] ], move: { x: -1, y: 0, enter: "rt" } }; cell.edges.tl = { path: [ [topleft, 1], [1, rightbottom] ], move: { x: 1, y: 0, enter: "lb" } }; } if (opt.polygons) cell.polygons.push([ [bottomright, 0], [0, lefttop], [0, 1], [topleft, 1], [1, rightbottom], [1, 0] ]); }, "hexagon_bl_tr"), heptagon_tr: /* @__PURE__ */ __name(function(cell, x0, x1, x2, x3, opt) { const bottomleft = opt.interpolate_a(x0, x1, opt.minV, opt.maxV); const bottomright = opt.interpolate_b(x0, x1, opt.minV, opt.maxV); const leftbottom = opt.interpolate_a(x0, x3, opt.minV, opt.maxV); const lefttop = opt.interpolate_b(x0, x3, opt.minV, opt.maxV); const topright = opt.interpolate(x3, x2, opt.minV, opt.maxV); const righttop = opt.interpolate(x1, x2, opt.minV, opt.maxV); if (opt.polygons_full) { cell.edges.bl = { path: [ [bottomleft, 0], [0, leftbottom] ], move: { x: -1, y: 0, enter: "rb" } }; cell.edges.lt = { path: [ [0, lefttop], [topright, 1] ], move: { x: 0, y: 1, enter: "br" } }; cell.edges.rt = { path: [ [1, righttop], [bottomright, 0] ], move: { x: 0, y: -1, enter: "tr" } }; } if (opt.polygons) cell.polygons.push([ [bottomleft, 0], [0, leftbottom], [0, lefttop], [topright, 1], [1, 1], [1, righttop], [bottomright, 0] ]); }, "heptagon_tr"), heptagon_bl: /* @__PURE__ */ __name(function(cell, x0, x1, x2, x3, opt) { const bottomleft = opt.interpolate(x0, x1, opt.minV, opt.maxV); const leftbottom = opt.interpolate(x0, x3, opt.minV, opt.maxV); const topleft = opt.interpolate_a(x3, x2, opt.minV, opt.maxV); const topright = opt.interpolate_b(x3, x2, opt.minV, opt.maxV); const righttop = opt.interpolate_b(x1, x2, opt.minV, opt.maxV); const rightbottom = opt.interpolate_a(x1, x2, opt.minV, opt.maxV); if (opt.polygons_full) { cell.edges.lb = { path: [ [0, leftbottom], [topleft, 1] ], move: { x: 0, y: 1, enter: "bl" } }; cell.edges.tr = { path: [ [topright, 1], [1, righttop] ], move: { x: 1, y: 0, enter: "lt" } }; cell.edges.rb = { path: [ [1, rightbottom], [bottomleft, 0] ], move: { x: 0, y: -1, enter: "tl" } }; } if (opt.polygons) cell.polygons.push([ [0, 0], [0, leftbottom], [topleft, 1], [topright, 1], [1, righttop], [1, rightbottom], [bottomleft, 0] ]); }, "heptagon_bl"), heptagon_tl: /* @__PURE__ */ __name(function(cell, x0, x1, x2, x3, opt) { const bottomleft = opt.interpolate_a(x0, x1, opt.minV, opt.maxV); const bottomright = opt.interpolate_b(x0, x1, opt.minV, opt.maxV); const lefttop = opt.interpolate(x0, x3, opt.minV, opt.maxV); const topleft = opt.interpolate(x3, x2, opt.minV, opt.maxV); const righttop = opt.interpolate_b(x1, x2, opt.minV, opt.maxV); const rightbottom = opt.interpolate_a(x1, x2, opt.minV, opt.maxV); if (opt.polygons_full) { cell.edges.bl = { path: [ [bottomleft, 0], [0, lefttop] ], move: { x: -1, y: 0, enter: "rt" } }; cell.edges.tl = { path: [ [topleft, 1], [1, righttop] ], move: { x: 1, y: 0, enter: "lt" } }; cell.edges.rb = { path: [ [1, rightbottom], [bottomright, 0] ], move: { x: 0, y: -1, enter: "tr" } }; } if (opt.polygons) cell.polygons.push([ [bottomleft, 0], [0, lefttop], [0, 1], [topleft, 1], [1, righttop], [1, rightbottom], [bottomright, 0] ]); }, "heptagon_tl"), heptagon_br: /* @__PURE__ */ __name(function(cell, x0, x1, x2, x3, opt) { const bottomright = opt.interpolate(x0, x1, opt.minV, opt.maxV); const leftbottom = opt.interpolate_a(x0, x3, opt.minV, opt.maxV); const lefttop = opt.interpolate_b(x0, x3, opt.minV, opt.maxV); const topleft = opt.interpolate_a(x3, x2, opt.minV, opt.maxV); const topright = opt.interpolate_b(x3, x2, opt.minV, opt.maxV); const rightbottom = opt.interpolate(x1, x2, opt.minV, opt.maxV); if (opt.polygons_full) { cell.edges.br = { path: [ [bottomright, 0], [0, leftbottom] ], move: { x: -1, y: 0, enter: "rb" } }; cell.edges.lt = { path: [ [0, lefttop], [topleft, 1] ], move: { x: 0, y: 1, enter: "bl" } }; cell.edges.tr = { path: [ [topright, 1], [1, rightbottom] ], move: { x: 1, y: 0, enter: "lb" } }; } if (opt.polygons) cell.polygons.push([ [bottomright, 0], [0, leftbottom], [0, lefttop], [topleft, 1], [topright, 1], [1, rightbottom], [1, 0] ]); }, "heptagon_br"), octagon: /* @__PURE__ */ __name(function(cell, x0, x1, x2, x3, opt) { const bottomleft = opt.interpolate_a(x0, x1, opt.minV, opt.maxV); const bottomright = opt.interpolate_b(x0, x1, opt.minV, opt.maxV); const leftbottom = opt.interpolate_a(x0, x3, opt.minV, opt.maxV); const lefttop = opt.interpolate_b(x0, x3, opt.minV, opt.maxV); const topleft = opt.interpolate_a(x3, x2, opt.minV, opt.maxV); const topright = opt.interpolate_b(x3, x2, opt.minV, opt.maxV); const righttop = opt.interpolate_b(x1, x2, opt.minV, opt.maxV); const rightbottom = opt.interpolate_a(x1, x2, opt.minV, opt.maxV); if (opt.polygons_full) { cell.edges.bl = { path: [ [bottomleft, 0], [0, leftbottom] ], move: { x: -1, y: 0, enter: "rb" } }; cell.edges.lt = { path: [ [0, lefttop], [topleft, 1] ], move: { x: 0, y: 1, enter: "bl" } }; cell.edges.tr = { path: [ [topright, 1], [1, righttop] ], move: { x: 1, y: 0, enter: "lt" } }; cell.edges.rb = { path: [ [1, rightbottom], [bottomright, 0] ], move: { x: 0, y: -1, enter: "tr" } }; } if (opt.polygons) cell.polygons.push([ [bottomleft, 0], [0, leftbottom], [0, lefttop], [topleft, 1], [topright, 1], [1, righttop], [1, rightbottom], [bottomright, 0] ]); }, "octagon") }; function isoBands(input, thresholds, bandwidths, options) { let i, j, settings, useQuadTree = false, tree = null, root = null, data = null, cellGrid = [], bandPolygons, ret = []; options = _nullishCoalesce(options, () => ( {})); if (!!options && typeof options !== "object") throw new Error("options must be an object"); settings = isoBandOptions(options); if (!input) throw new Error("data is required"); if (input instanceof QuadTree) { tree = input; root = input.root; data = input.data; if (!settings.noQuadTree) useQuadTree = true; } else if (Array.isArray(input) && Array.isArray(input[0])) { data = input; } else { throw new Error( "input is neither array of arrays nor object retrieved from 'QuadTree()'" ); } if (thresholds === void 0 || thresholds === null) throw new Error("thresholds is required"); if (!Array.isArray(thresholds)) throw new Error("thresholds must be an array"); if (bandwidths === void 0 || bandwidths === null) throw new Error("bandwidths is required"); if (!Array.isArray(bandwidths)) throw new Error("bandwidths must be an array"); if (!settings.noQuadTree) useQuadTree = true; for (i = 0; i < thresholds.length; i++) if (isNaN(+thresholds[i])) throw new Error("thresholds[" + i + "] is not a number"); if (thresholds.length !== bandwidths.length) throw new Error("threshold and bandwidth arrays have unequal lengths"); for (i = 0; i < bandwidths.length; i++) if (isNaN(+bandwidths[i])) throw new Error("bandwidths[" + i + "] is not a number"); if (useQuadTree && !root) { tree = new QuadTree(data); root = tree.root; data = tree.data; } if (settings.verbose) { if (settings.polygons) console.log("isoBands: returning single polygons for each grid cell"); else console.log("isoBands: returning polygon paths for entire data grid"); } thresholds.forEach(function(lowerBound, b) { bandPolygons = []; settings.minV = lowerBound; settings.maxV = lowerBound + bandwidths[b]; if (settings.verbose) console.log( "isoBands: computing isobands for [" + lowerBound + ":" + (lowerBound + bandwidths[b]) + "]" ); if (settings.polygons) { if (useQuadTree) { root.cellsInBand(settings.minV, settings.maxV, true).forEach(function(c) { const cell = prepareCell2(data, c.x, c.y, settings); if (cell) { bandPolygons = bandPolygons.concat( cell2Polygons(cell, c.x, c.y, settings) ); } }); } else { for (j = 0; j < data.length - 1; ++j) { for (i = 0; i < data[0].length - 1; ++i) { const cell = prepareCell2(data, i, j, settings); if (cell) { bandPolygons = bandPolygons.concat( cell2Polygons(cell, i, j, settings) ); } } } } } else { cellGrid = []; for (i = 0; i < data[0].length - 1; ++i) cellGrid[i] = []; if (useQuadTree) { root.cellsInBand(settings.minV, settings.maxV, false).forEach(function(c) { cellGrid[c.x][c.y] = prepareCell2(data, c.x, c.y, settings); }); } else { for (i = 0; i < data[0].length - 1; ++i) { for (j = 0; j < data.length - 1; ++j) { cellGrid[i][j] = prepareCell2(data, i, j, settings); } } } bandPolygons = traceBandPaths(data, cellGrid, settings); } ret.push(bandPolygons); if (typeof settings.successCallback === "function") settings.successCallback(ret, lowerBound, bandwidths[b]); }); return ret; } __name(isoBands, "isoBands"); function computeCenterAverage(bl, br, tr, tl, minV, maxV) { const average = (tl + tr + br + bl) / 4; if (average > maxV) return 2; if (average < minV) return 0; return 1; } __name(computeCenterAverage, "computeCenterAverage"); function prepareCell2(grid, x, y, opt) { let cval = 0; const x3 = grid[y + 1][x], x2 = grid[y + 1][x + 1], x1 = grid[y][x + 1], x0 = grid[y][x], minV = opt.minV, maxV = opt.maxV; if (isNaN(x0) || isNaN(x1) || isNaN(x2) || isNaN(x3)) { return; } cval |= x3 < minV ? 0 : x3 > maxV ? 128 : 64; cval |= x2 < minV ? 0 : x2 > maxV ? 32 : 16; cval |= x1 < minV ? 0 : x1 > maxV ? 8 : 4; cval |= x0 < minV ? 0 : x0 > maxV ? 2 : 1; cval = +cval; let center_avg = 0; let cell = { cval, polygons: [], edges: {}, x0, x1, x2, x3, x, y }; switch (cval) { case 85: shapeCoordinates.square(cell, x0, x1, x2, x3, opt); /* fall through */ case 0: /* 0000 */ /* fall through */ case 170: break; /* single triangle cases */ case 169: shapeCoordinates.triangle_bl(cell, x0, x1, x2, x3, opt); break; case 166: shapeCoordinates.triangle_br(cell, x0, x1, x2, x3, opt); break; case 154: shapeCoordinates.triangle_tr(cell, x0, x1, x2, x3, opt); break; case 106: shapeCoordinates.triangle_tl(cell, x0, x1, x2, x3, opt); break; case 1: shapeCoordinates.triangle_bl(cell, x0, x1, x2, x3, opt); break; case 4: shapeCoordinates.triangle_br(cell, x0, x1, x2, x3, opt); break; case 16: shapeCoordinates.triangle_tr(cell, x0, x1, x2, x3, opt); break; case 64: shapeCoordinates.triangle_tl(cell, x0, x1, x2, x3, opt); break; /* single trapezoid cases */ case 168: shapeCoordinates.tetragon_bl(cell, x0, x1, x2, x3, opt); break; case 162: shapeCoordinates.tetragon_br(cell, x0, x1, x2, x3, opt); break; case 138: shapeCoordinates.tetragon_tr(cell, x0, x1, x2, x3, opt); break; case 42: shapeCoordinates.tetragon_tl(cell, x0, x1, x2, x3, opt); break; case 2: shapeCoordinates.tetragon_bl(cell, x0, x1, x2, x3, opt); break; case 8: shapeCoordinates.tetragon_br(cell, x0, x1, x2, x3, opt); break; case 32: shapeCoordinates.tetragon_tr(cell, x0, x1, x2, x3, opt); break; case 128: shapeCoordinates.tetragon_tl(cell, x0, x1, x2, x3, opt); break; /* single rectangle cases */ case 5: shapeCoordinates.tetragon_b(cell, x0, x1, x2, x3, opt); break; case 20: shapeCoordinates.tetragon_r(cell, x0, x1, x2, x3, opt); break; case 80: shapeCoordinates.tetragon_t(cell, x0, x1, x2, x3, opt); break; case 65: shapeCoordinates.tetragon_l(cell, x0, x1, x2, x3, opt); break; case 165: shapeCoordinates.tetragon_b(cell, x0, x1, x2, x3, opt); break; case 150: shapeCoordinates.tetragon_r(cell, x0, x1, x2, x3, opt); break; case 90: shapeCoordinates.tetragon_t(cell, x0, x1, x2, x3, opt); break; case 105: shapeCoordinates.tetragon_l(cell, x0, x1, x2, x3, opt); break; case 160: shapeCoordinates.tetragon_lr(cell, x0, x1, x2, x3, opt); break; case 130: shapeCoordinates.tetragon_tb(cell, x0, x1, x2, x3, opt); break; case 10: shapeCoordinates.tetragon_lr(cell, x0, x1, x2, x3, opt); break; case 40: shapeCoordinates.tetragon_tb(cell, x0, x1, x2, x3, opt); break; /* single pentagon cases */ case 101: shapeCoordinates.pentagon_tr(cell, x0, x1, x2, x3, opt); break; case 149: shapeCoordinates.pentagon_tl(cell, x0, x1, x2, x3, opt); break; case 86: shapeCoordinates.pentagon_bl(cell, x0, x1, x2, x3, opt); break; case 89: shapeCoordinates.pentagon_br(cell, x0, x1, x2, x3, opt); break; case 69: shapeCoordinates.pentagon_tr(cell, x0, x1, x2, x3, opt); break; case 21: shapeCoordinates.pentagon_tl(cell, x0, x1, x2, x3, opt); break; case 84: shapeCoordinates.pentagon_bl(cell, x0, x1, x2, x3, opt); break; case 81: shapeCoordinates.pentagon_br(cell, x0, x1, x2, x3, opt); break; case 96: shapeCoordinates.pentagon_tr_rl(cell, x0, x1, x2, x3, opt); break; case 24: shapeCoordinates.pentagon_rb_bt(cell, x0, x1, x2, x3, opt); break; case 6: shapeCoordinates.pentagon_bl_lr(cell, x0, x1, x2, x3, opt); break; case 129: shapeCoordinates.pentagon_lt_tb(cell, x0, x1, x2, x3, opt); break; case 74: shapeCoordinates.pentagon_tr_rl(cell, x0, x1, x2, x3, opt); break; case 146: shapeCoordinates.pentagon_rb_bt(cell, x0, x1, x2, x3, opt); break; case 164: shapeCoordinates.pentagon_bl_lr(cell, x0, x1, x2, x3, opt); break; case 41: shapeCoordinates.pentagon_lt_tb(cell, x0, x1, x2, x3, opt); break; case 66: shapeCoordinates.pentagon_bl_tb(cell, x0, x1, x2, x3, opt); break; case 144: shapeCoordinates.pentagon_lt_rl(cell, x0, x1, x2, x3, opt); break; case 36: shapeCoordinates.pentagon_tr_bt(cell, x0, x1, x2, x3, opt); break; case 9: shapeCoordinates.pentagon_rb_lr(cell, x0, x1, x2, x3, opt); break; case 104: shapeCoordinates.pentagon_bl_tb(cell, x0, x1, x2, x3, opt); break; case 26: shapeCoordinates.pentagon_lt_rl(cell, x0, x1, x2, x3, opt); break; case 134: shapeCoordinates.pentagon_tr_bt(cell, x0, x1, x2, x3, opt); break; case 161: shapeCoordinates.pentagon_rb_lr(cell, x0, x1, x2, x3, opt); break; /* single hexagon cases */ case 37: shapeCoordinates.hexagon_lt_tr(cell, x0, x1, x2, x3, opt); break; case 148: shapeCoordinates.hexagon_bl_lt(cell, x0, x1, x2, x3, opt); break; case 82: shapeCoordinates.hexagon_bl_rb(cell, x0, x1, x2, x3, opt); break; case 73: shapeCoordinates.hexagon_tr_rb(cell, x0, x1, x2, x3, opt); break; case 133: shapeCoordinates.hexagon_lt_tr(cell, x0, x1, x2, x3, opt); break; case 22: shapeCoordinates.hexagon_bl_lt(cell, x0, x1, x2, x3, opt); break; case 88: shapeCoordinates.hexagon_bl_rb(cell, x0, x1, x2, x3, opt); break; case 97: shapeCoordinates.hexagon_tr_rb(cell, x0, x1, x2, x3, opt); break; case 145: shapeCoordinates.hexagon_lt_rb(cell, x0, x1, x2, x3, opt); break; case 25: shapeCoordinates.hexagon_lt_rb(cell, x0, x1, x2, x3, opt); break; case 70: shapeCoordinates.hexagon_bl_tr(cell, x0, x1, x2, x3, opt); break; case 100: shapeCoordinates.hexagon_bl_tr(cell, x0, x1, x2, x3, opt); break; /* 6-sided saddles */ case 17: center_avg = computeCenterAverage(x0, x1, x2, x3, minV, maxV); if (center_avg === 0) { shapeCoordinates.triangle_bl(cell, x0, x1, x2, x3, opt); shapeCoordinates.triangle_tr(cell, x0, x1, x2, x3, opt); } else { shapeCoordinates.hexagon_lt_rb(cell, x0, x1, x2, x3, opt); } break; case 68: center_avg = computeCenterAverage(x0, x1, x2, x3, minV, maxV); if (center_avg === 0) { shapeCoordinates.triangle_tl(cell, x0, x1, x2, x3, opt); shapeCoordinates.triangle_br(cell, x0, x1, x2, x3, opt); } else { shapeCoordinates.hexagon_bl_tr(cell, x0, x1, x2, x3, opt); } break; case 153: center_avg = computeCenterAverage(x0, x1, x2, x3, minV, maxV); if (center_avg === 2) { shapeCoordinates.triangle_bl(cell, x0, x1, x2, x3, opt); shapeCoordinates.triangle_tr(cell, x0, x1, x2, x3, opt); } else { shapeCoordinates.hexagon_lt_rb(cell, x0, x1, x2, x3, opt); } break; case 102: center_avg = computeCenterAverage(x0, x1, x2, x3, minV, maxV); if (center_avg === 2) { shapeCoordinates.triangle_tl(cell, x0, x1, x2, x3, opt); shapeCoordinates.triangle_br(cell, x0, x1, x2, x3, opt); } else { shapeCoordinates.hexagon_bl_tr(cell, x0, x1, x2, x3, opt); } break; /* 7-sided saddles */ case 152: center_avg = computeCenterAverage(x0, x1, x2, x3, minV, maxV); if (center_avg === 2) { shapeCoordinates.triangle_tr(cell, x0, x1, x2, x3, opt); shapeCoordinates.tetragon_bl(cell, x0, x1, x2, x3, opt); } else { shapeCoordinates.heptagon_tr(cell, x0, x1, x2, x3, opt); } break; case 137: center_avg = computeCenterAverage(x0, x1, x2, x3, minV, maxV); if (center_avg === 2) { shapeCoordinates.triangle_bl(cell, x0, x1, x2, x3, opt); shapeCoordinates.tetragon_tr(cell, x0, x1, x2, x3, opt); } else { shapeCoordinates.heptagon_bl(cell, x0, x1, x2, x3, opt); } break; case 98: center_avg = computeCenterAverage(x0, x1, x2, x3, minV, maxV); if (center_avg === 2) { shapeCoordinates.triangle_tl(cell, x0, x1, x2, x3, opt); shapeCoordinates.tetragon_br(cell, x0, x1, x2, x3, opt); } else { shapeCoordinates.heptagon_tl(cell, x0, x1, x2, x3, opt); } break; case 38: center_avg = computeCenterAverage(x0, x1, x2, x3, minV, maxV); if (center_avg === 2) { shapeCoordinates.triangle_br(cell, x0, x1, x2, x3, opt); shapeCoordinates.tetragon_tl(cell, x0, x1, x2, x3, opt); } else { shapeCoordinates.heptagon_br(cell, x0, x1, x2, x3, opt); } break; case 18: center_avg = computeCenterAverage(x0, x1, x2, x3, minV, maxV); if (center_avg === 0) { shapeCoordinates.triangle_tr(cell, x0, x1, x2, x3, opt); shapeCoordinates.tetragon_bl(cell, x0, x1, x2, x3, opt); } else { shapeCoordinates.heptagon_tr(cell, x0, x1, x2, x3, opt); } break; case 33: center_avg = computeCenterAverage(x0, x1, x2, x3, minV, maxV); if (center_avg === 0) { shapeCoordinates.triangle_bl(cell, x0, x1, x2, x3, opt); shapeCoordinates.tetragon_tr(cell, x0, x1, x2, x3, opt); } else { shapeCoordinates.heptagon_bl(cell, x0, x1, x2, x3, opt); } break; case 72: center_avg = computeCenterAverage(x0, x1, x2, x3, minV, maxV); if (center_avg === 0) { shapeCoordinates.triangle_tl(cell, x0, x1, x2, x3, opt); shapeCoordinates.tetragon_br(cell, x0, x1, x2, x3, opt); } else { shapeCoordinates.heptagon_tl(cell, x0, x1, x2, x3, opt); } break; case 132: center_avg = computeCenterAverage(x0, x1, x2, x3, minV, maxV); if (center_avg === 0) { shapeCoordinates.triangle_br(cell, x0, x1, x2, x3, opt); shapeCoordinates.tetragon_tl(cell, x0, x1, x2, x3, opt); } else { shapeCoordinates.heptagon_br(cell, x0, x1, x2, x3, opt); } break; /* 8-sided saddles */ case 136: center_avg = computeCenterAverage(x0, x1, x2, x3, minV, maxV); if (center_avg === 0) { shapeCoordinates.tetragon_tl(cell, x0, x1, x2, x3, opt); shapeCoordinates.tetragon_br(cell, x0, x1, x2, x3, opt); } else if (center_avg === 1) { shapeCoordinates.octagon(cell, x0, x1, x2, x3, opt); } else { shapeCoordinates.tetragon_bl(cell, x0, x1, x2, x3, opt); shapeCoordinates.tetragon_tr(cell, x0, x1, x2, x3, opt); } break; case 34: center_avg = computeCenterAverage(x0, x1, x2, x3, minV, maxV); if (center_avg === 0) { shapeCoordinates.tetragon_bl(cell, x0, x1, x2, x3, opt); shapeCoordinates.tetragon_tr(cell, x0, x1, x2, x3, opt); } else if (center_avg === 1) { shapeCoordinates.octagon(cell, x0, x1, x2, x3, opt); } else { shapeCoordinates.tetragon_tl(cell, x0, x1, x2, x3, opt); shapeCoordinates.tetragon_br(cell, x0, x1, x2, x3, opt); } break; } return cell; } __name(prepareCell2, "prepareCell"); exports.QuadTree = QuadTree; exports.TreeNode = TreeNode; exports.isoBands = isoBands; exports.isoContours = isoLines; exports.isoLines = isoLines; exports.quadTree = QuadTree; //# sourceMappingURL=index.cjs.map