dgeoutils 2.4.41 → 2.4.44
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.
- package/package.json +1 -4
- package/dist/cjs/DCircle.d.ts +0 -18
- package/dist/cjs/DCircle.js +0 -102
- package/dist/cjs/DLine.d.ts +0 -39
- package/dist/cjs/DLine.js +0 -343
- package/dist/cjs/DNumbers.d.ts +0 -8
- package/dist/cjs/DNumbers.js +0 -30
- package/dist/cjs/DPlane.d.ts +0 -25
- package/dist/cjs/DPlane.js +0 -132
- package/dist/cjs/DPoint.d.ts +0 -138
- package/dist/cjs/DPoint.js +0 -803
- package/dist/cjs/DPolygon.d.ts +0 -137
- package/dist/cjs/DPolygon.js +0 -1745
- package/dist/cjs/DPolygonLoop.d.ts +0 -60
- package/dist/cjs/DPolygonLoop.js +0 -439
- package/dist/cjs/FastSearch.d.ts +0 -6
- package/dist/cjs/FastSearch.js +0 -53
- package/dist/cjs/InterpolationMatrix.d.ts +0 -24
- package/dist/cjs/InterpolationMatrix.js +0 -173
- package/dist/cjs/TraceMatrix.d.ts +0 -22
- package/dist/cjs/TraceMatrix.js +0 -285
- package/dist/cjs/index.d.ts +0 -11
- package/dist/cjs/index.js +0 -37
- package/dist/cjs/utils.d.ts +0 -49
- package/dist/cjs/utils.js +0 -280
- package/dist/es2015/DCircle.js +0 -87
- package/dist/es2015/DLine.js +0 -290
- package/dist/es2015/DNumbers.js +0 -22
- package/dist/es2015/DPlane.js +0 -105
- package/dist/es2015/DPoint.js +0 -676
- package/dist/es2015/DPolygon.js +0 -1193
- package/dist/es2015/DPolygonLoop.js +0 -430
- package/dist/es2015/FastSearch.js +0 -25
- package/dist/es2015/InterpolationMatrix.js +0 -128
- package/dist/es2015/TraceMatrix.js +0 -229
- package/dist/es2015/index.js +0 -11
- package/dist/es2015/utils.js +0 -207
- package/dist/esm/DCircle.js +0 -99
- package/dist/esm/DLine.js +0 -340
- package/dist/esm/DNumbers.js +0 -27
- package/dist/esm/DPlane.js +0 -129
- package/dist/esm/DPoint.js +0 -800
- package/dist/esm/DPolygon.js +0 -1742
- package/dist/esm/DPolygonLoop.js +0 -436
- package/dist/esm/FastSearch.js +0 -50
- package/dist/esm/InterpolationMatrix.js +0 -170
- package/dist/esm/TraceMatrix.js +0 -282
- package/dist/esm/index.js +0 -11
- package/dist/esm/utils.js +0 -265
- package/dist/umd/dgeoutils.js +0 -4347
- package/dist/umd/dgeoutils.min.js +0 -1
- package/dist/umd/dgeoutils.min.js.map +0 -1
|
@@ -1,173 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
14
|
-
var t = {};
|
|
15
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
16
|
-
t[p] = s[p];
|
|
17
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
18
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
19
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
20
|
-
t[p[i]] = s[p[i]];
|
|
21
|
-
}
|
|
22
|
-
return t;
|
|
23
|
-
};
|
|
24
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
25
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
26
|
-
if (!m) return o;
|
|
27
|
-
var i = m.call(o), r, ar = [], e;
|
|
28
|
-
try {
|
|
29
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
30
|
-
}
|
|
31
|
-
catch (error) { e = { error: error }; }
|
|
32
|
-
finally {
|
|
33
|
-
try {
|
|
34
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
35
|
-
}
|
|
36
|
-
finally { if (e) throw e.error; }
|
|
37
|
-
}
|
|
38
|
-
return ar;
|
|
39
|
-
};
|
|
40
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
|
-
exports.InterpolationMatrix = void 0;
|
|
42
|
-
var DPolygon_1 = require("./DPolygon");
|
|
43
|
-
var DPoint_1 = require("./DPoint");
|
|
44
|
-
var utils_1 = require("./utils");
|
|
45
|
-
var InterpolationMatrix = (function () {
|
|
46
|
-
function InterpolationMatrix(bboxLike, stepSize, keys, p) {
|
|
47
|
-
if (p === void 0) { p = 2; }
|
|
48
|
-
this.stepSize = stepSize;
|
|
49
|
-
this.p = p;
|
|
50
|
-
this.points = [];
|
|
51
|
-
this.cells = {};
|
|
52
|
-
this.allCells = [];
|
|
53
|
-
this.minPoint = bboxLike.minPoint;
|
|
54
|
-
this.maxPoint = bboxLike.maxPoint;
|
|
55
|
-
this.sizePoly = DPolygon_1.DPolygon.createSquareBySize(new DPoint_1.DPoint(this.stepSize));
|
|
56
|
-
this.size = this.maxPoint.clone().move(this.minPoint.clone().minus())
|
|
57
|
-
.divide(this.stepSize)
|
|
58
|
-
.ceil();
|
|
59
|
-
this.keys = Array.isArray(keys) ? keys : [keys];
|
|
60
|
-
this.generateCells();
|
|
61
|
-
}
|
|
62
|
-
InterpolationMatrix.prototype.setKnownPoints = function (points) {
|
|
63
|
-
var _this = this;
|
|
64
|
-
this.points = points instanceof DPolygon_1.DPolygon ? points.points : points;
|
|
65
|
-
this.minPoint.setProperties(this.points.reduce(function (a, v) { return _this.keys
|
|
66
|
-
.reduce(function (aa, k) {
|
|
67
|
-
var _a;
|
|
68
|
-
aa[k] = Math.min((_a = a[k]) !== null && _a !== void 0 ? _a : Infinity, v.properties[k]);
|
|
69
|
-
return aa;
|
|
70
|
-
}, a); }, {}));
|
|
71
|
-
this.maxPoint.setProperties(this.points.reduce(function (a, v) { return _this.keys
|
|
72
|
-
.reduce(function (aa, k) {
|
|
73
|
-
var _a;
|
|
74
|
-
aa[k] = Math.max((_a = a[k]) !== null && _a !== void 0 ? _a : -Infinity, v.properties[k]);
|
|
75
|
-
return aa;
|
|
76
|
-
}, a); }, {}));
|
|
77
|
-
return this;
|
|
78
|
-
};
|
|
79
|
-
InterpolationMatrix.prototype.positionToCellCoords = function (d) {
|
|
80
|
-
return d.clone()
|
|
81
|
-
.move(this.minPoint.clone().minus())
|
|
82
|
-
.divide(this.stepSize)
|
|
83
|
-
.floor();
|
|
84
|
-
};
|
|
85
|
-
InterpolationMatrix.prototype.calculate = function () {
|
|
86
|
-
this.setKnownValues();
|
|
87
|
-
this.interpolateValues();
|
|
88
|
-
return this;
|
|
89
|
-
};
|
|
90
|
-
InterpolationMatrix.prototype.getCellValue = function (_a, key) {
|
|
91
|
-
var x = _a.x, y = _a.y;
|
|
92
|
-
var cell = this.cells[x][y];
|
|
93
|
-
if (key) {
|
|
94
|
-
if (Array.isArray(key)) {
|
|
95
|
-
return key.reduce(function (a, k) {
|
|
96
|
-
a[k] = cell.properties[k];
|
|
97
|
-
return a;
|
|
98
|
-
}, {});
|
|
99
|
-
}
|
|
100
|
-
return cell.properties[key];
|
|
101
|
-
}
|
|
102
|
-
return __assign({}, cell.properties);
|
|
103
|
-
};
|
|
104
|
-
Object.defineProperty(InterpolationMatrix.prototype, "getCellData", {
|
|
105
|
-
get: function () {
|
|
106
|
-
return this.allCells.reduce(function (a, c) {
|
|
107
|
-
var _a = c.properties, x = _a.x, y = _a.y, props = __rest(_a, ["x", "y"]);
|
|
108
|
-
a[x] = a[x] || {};
|
|
109
|
-
a[x][y] = __assign({}, props);
|
|
110
|
-
return a;
|
|
111
|
-
}, {});
|
|
112
|
-
},
|
|
113
|
-
enumerable: false,
|
|
114
|
-
configurable: true
|
|
115
|
-
});
|
|
116
|
-
Object.defineProperty(InterpolationMatrix.prototype, "allCellsClone", {
|
|
117
|
-
get: function () {
|
|
118
|
-
return this.allCells.map(function (p) { return p.clone(); });
|
|
119
|
-
},
|
|
120
|
-
enumerable: false,
|
|
121
|
-
configurable: true
|
|
122
|
-
});
|
|
123
|
-
InterpolationMatrix.prototype.interpolateValues = function () {
|
|
124
|
-
var _this = this;
|
|
125
|
-
var points = this.points.map(function (p) { return _this.positionToCellCoords(p); });
|
|
126
|
-
this.allCells.forEach(function (cell) {
|
|
127
|
-
var t = new DPoint_1.DPoint(cell.properties.x, cell.properties.y);
|
|
128
|
-
var distances = points.map(function (p) { return Math.pow(t.distance(p), _this.p); });
|
|
129
|
-
_this.keys.forEach(function (k) {
|
|
130
|
-
if ((0, utils_1.isDefAndNotNull)(cell.properties[k])) {
|
|
131
|
-
return;
|
|
132
|
-
}
|
|
133
|
-
var _a = __read(distances.reduce(function (a, d, i) {
|
|
134
|
-
if ((0, utils_1.isDefAndNotNull)(_this.points[i].properties[k])) {
|
|
135
|
-
a[0] += _this.points[i].properties[k] / d;
|
|
136
|
-
a[1] += 1 / d;
|
|
137
|
-
}
|
|
138
|
-
return a;
|
|
139
|
-
}, [0, 0]), 2), valueSum = _a[0], oneSum = _a[1];
|
|
140
|
-
cell.properties[k] = valueSum / oneSum;
|
|
141
|
-
});
|
|
142
|
-
});
|
|
143
|
-
};
|
|
144
|
-
InterpolationMatrix.prototype.setKnownValues = function () {
|
|
145
|
-
var _this = this;
|
|
146
|
-
this.points.forEach(function (p) {
|
|
147
|
-
var _a = _this.positionToCellCoords(p), x = _a.x, y = _a.y;
|
|
148
|
-
_this.keys.forEach(function (k) {
|
|
149
|
-
_this.cells[x][y].properties[k] = p.properties[k];
|
|
150
|
-
});
|
|
151
|
-
});
|
|
152
|
-
};
|
|
153
|
-
InterpolationMatrix.prototype.generateCells = function () {
|
|
154
|
-
for (var i = this.minPoint.x, x = 0; i < this.maxPoint.x; i += this.stepSize, x++) {
|
|
155
|
-
this.cells[x] = this.cells[x] || {};
|
|
156
|
-
for (var j = this.minPoint.y, y = 0; j < this.maxPoint.y; j += this.stepSize, y++) {
|
|
157
|
-
var t = this.sizePoly
|
|
158
|
-
.clone()
|
|
159
|
-
.loop()
|
|
160
|
-
.move(i, j)
|
|
161
|
-
.run()
|
|
162
|
-
.setProperties({
|
|
163
|
-
x: x,
|
|
164
|
-
y: y
|
|
165
|
-
});
|
|
166
|
-
this.cells[x][y] = t;
|
|
167
|
-
this.allCells.push(t);
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
};
|
|
171
|
-
return InterpolationMatrix;
|
|
172
|
-
}());
|
|
173
|
-
exports.InterpolationMatrix = InterpolationMatrix;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { DPoint } from './DPoint';
|
|
2
|
-
import { DPolygon } from './DPolygon';
|
|
3
|
-
export declare enum TraceMatrixValues {
|
|
4
|
-
f = 0,
|
|
5
|
-
t = 1
|
|
6
|
-
}
|
|
7
|
-
export declare type SimpleMatrix = TraceMatrixValues[][];
|
|
8
|
-
export declare class TraceMatrix {
|
|
9
|
-
private readonly m;
|
|
10
|
-
approximation: boolean;
|
|
11
|
-
private readonly size;
|
|
12
|
-
constructor(s: DPoint, f: (p: DPoint) => TraceMatrixValues);
|
|
13
|
-
fullMatrixTrace(): DPolygon[];
|
|
14
|
-
private reverseMatrix;
|
|
15
|
-
private findGroupByIndex;
|
|
16
|
-
private findMarked;
|
|
17
|
-
private totalCountInMatrix;
|
|
18
|
-
private findAllGroupsInMatrix;
|
|
19
|
-
private traceGroup;
|
|
20
|
-
private createHoleMatrix;
|
|
21
|
-
static createMatrix(size: DPoint, f?: (pos: DPoint) => TraceMatrixValues): SimpleMatrix;
|
|
22
|
-
}
|
package/dist/cjs/TraceMatrix.js
DELETED
|
@@ -1,285 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
3
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
4
|
-
if (!m) return o;
|
|
5
|
-
var i = m.call(o), r, ar = [], e;
|
|
6
|
-
try {
|
|
7
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
8
|
-
}
|
|
9
|
-
catch (error) { e = { error: error }; }
|
|
10
|
-
finally {
|
|
11
|
-
try {
|
|
12
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
13
|
-
}
|
|
14
|
-
finally { if (e) throw e.error; }
|
|
15
|
-
}
|
|
16
|
-
return ar;
|
|
17
|
-
};
|
|
18
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
19
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
20
|
-
if (ar || !(i in from)) {
|
|
21
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
22
|
-
ar[i] = from[i];
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
26
|
-
};
|
|
27
|
-
var __values = (this && this.__values) || function(o) {
|
|
28
|
-
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
29
|
-
if (m) return m.call(o);
|
|
30
|
-
if (o && typeof o.length === "number") return {
|
|
31
|
-
next: function () {
|
|
32
|
-
if (o && i >= o.length) o = void 0;
|
|
33
|
-
return { value: o && o[i++], done: !o };
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
37
|
-
};
|
|
38
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.TraceMatrix = exports.TraceMatrixValues = void 0;
|
|
40
|
-
var DPoint_1 = require("./DPoint");
|
|
41
|
-
var DPolygon_1 = require("./DPolygon");
|
|
42
|
-
var FastSearch_1 = require("./FastSearch");
|
|
43
|
-
var utils_1 = require("./utils");
|
|
44
|
-
var TraceMatrixValues;
|
|
45
|
-
(function (TraceMatrixValues) {
|
|
46
|
-
TraceMatrixValues[TraceMatrixValues["f"] = 0] = "f";
|
|
47
|
-
TraceMatrixValues[TraceMatrixValues["t"] = 1] = "t";
|
|
48
|
-
})(TraceMatrixValues = exports.TraceMatrixValues || (exports.TraceMatrixValues = {}));
|
|
49
|
-
var getByPosition = function (m, p, defaultValue) {
|
|
50
|
-
if (defaultValue === void 0) { defaultValue = TraceMatrixValues.f; }
|
|
51
|
-
if (m[p.y] === undefined || m[p.y][p.x] === undefined) {
|
|
52
|
-
return defaultValue;
|
|
53
|
-
}
|
|
54
|
-
return m[p.y][p.x];
|
|
55
|
-
};
|
|
56
|
-
var setByPosition = function (m, p, value) {
|
|
57
|
-
if (m[p.y] === undefined || m[p.y][p.x] === undefined) {
|
|
58
|
-
return value;
|
|
59
|
-
}
|
|
60
|
-
m[p.y][p.x] = value;
|
|
61
|
-
return m[p.y][p.x];
|
|
62
|
-
};
|
|
63
|
-
var TraceMatrix = (function () {
|
|
64
|
-
function TraceMatrix(s, f) {
|
|
65
|
-
var _this = this;
|
|
66
|
-
this.approximation = true;
|
|
67
|
-
this.findGroupByIndex = function (m, s) {
|
|
68
|
-
var res = new DPolygon_1.DPolygon();
|
|
69
|
-
if (s && getByPosition(m, s) === TraceMatrixValues.t) {
|
|
70
|
-
res.push(s);
|
|
71
|
-
var startIndex = 0;
|
|
72
|
-
var marked = TraceMatrix.createMatrix(_this.size, function () { return TraceMatrixValues.f; });
|
|
73
|
-
setByPosition(marked, s, TraceMatrixValues.t);
|
|
74
|
-
while (startIndex < res.length) {
|
|
75
|
-
var r = res.at(startIndex);
|
|
76
|
-
for (var i = -1; i < 2; i++) {
|
|
77
|
-
for (var j = -1; j < 2; j++) {
|
|
78
|
-
var t = new DPoint_1.DPoint(r.x + i, r.y + j);
|
|
79
|
-
if (getByPosition(marked, t, TraceMatrixValues.t) === TraceMatrixValues.f &&
|
|
80
|
-
getByPosition(m, t, TraceMatrixValues.f) === TraceMatrixValues.t) {
|
|
81
|
-
res.push(t);
|
|
82
|
-
setByPosition(marked, t, TraceMatrixValues.t);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
startIndex++;
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
return res;
|
|
90
|
-
};
|
|
91
|
-
this.findAllGroupsInMatrix = function (m) {
|
|
92
|
-
var firstMark = _this.findMarked(m);
|
|
93
|
-
if (!firstMark) {
|
|
94
|
-
return [];
|
|
95
|
-
}
|
|
96
|
-
var group = _this.findGroupByIndex(m, firstMark);
|
|
97
|
-
var groups = [group];
|
|
98
|
-
var groupSum = group.length;
|
|
99
|
-
var allGroups = __spreadArray([], __read(group.points), false);
|
|
100
|
-
var fs = new FastSearch_1.FastSearch();
|
|
101
|
-
fs.add(allGroups);
|
|
102
|
-
while (groupSum < _this.totalCountInMatrix(m)) {
|
|
103
|
-
var mark = _this.findMarked(m);
|
|
104
|
-
while (mark && fs.find(mark)) {
|
|
105
|
-
mark = _this.findMarked(m, mark);
|
|
106
|
-
}
|
|
107
|
-
var nextGroup = _this.findGroupByIndex(m, mark);
|
|
108
|
-
groupSum += nextGroup.length;
|
|
109
|
-
allGroups = __spreadArray(__spreadArray([], __read(allGroups), false), __read(nextGroup.points), false);
|
|
110
|
-
fs.add(nextGroup.points);
|
|
111
|
-
groups.push(nextGroup);
|
|
112
|
-
}
|
|
113
|
-
return groups.filter(function (g) { return g.length > 2; });
|
|
114
|
-
};
|
|
115
|
-
this.traceGroup = function (m, group) {
|
|
116
|
-
var traceDirections = [
|
|
117
|
-
new DPoint_1.DPoint(-1, -1),
|
|
118
|
-
new DPoint_1.DPoint(-1, 0),
|
|
119
|
-
new DPoint_1.DPoint(-1, 1),
|
|
120
|
-
new DPoint_1.DPoint(0, 1),
|
|
121
|
-
new DPoint_1.DPoint(1, 1),
|
|
122
|
-
new DPoint_1.DPoint(1, 0),
|
|
123
|
-
new DPoint_1.DPoint(1, -1),
|
|
124
|
-
new DPoint_1.DPoint(0, -1)
|
|
125
|
-
];
|
|
126
|
-
var left = function (d) { return (d + traceDirections.length + 1) % traceDirections.length; };
|
|
127
|
-
var right = function (d) { return (d + traceDirections.length - 1) % traceDirections.length; };
|
|
128
|
-
if (group.length < 2) {
|
|
129
|
-
var t = group.at(0).clone();
|
|
130
|
-
return new DPolygon_1.DPolygon([t, t, t]);
|
|
131
|
-
}
|
|
132
|
-
var points = new DPolygon_1.DPolygon();
|
|
133
|
-
var direction = 0;
|
|
134
|
-
var prevDirection = Infinity;
|
|
135
|
-
var p = group.at(0);
|
|
136
|
-
while (!p.equal(group.at(0)) || points.length < 2) {
|
|
137
|
-
while (true) {
|
|
138
|
-
var nextValue = getByPosition(m, p.clone().move(traceDirections[direction]));
|
|
139
|
-
var nextNeighbourValue = getByPosition(m, p.clone().move(traceDirections[left(direction)]));
|
|
140
|
-
if (nextValue === TraceMatrixValues.t && nextNeighbourValue === TraceMatrixValues.f) {
|
|
141
|
-
break;
|
|
142
|
-
}
|
|
143
|
-
direction = right(direction);
|
|
144
|
-
}
|
|
145
|
-
if (prevDirection !== direction) {
|
|
146
|
-
points.push(p);
|
|
147
|
-
prevDirection = direction;
|
|
148
|
-
}
|
|
149
|
-
p = p.clone().move(traceDirections[direction]);
|
|
150
|
-
direction = left(left(direction));
|
|
151
|
-
}
|
|
152
|
-
if (_this.approximation) {
|
|
153
|
-
return points.approximation().close();
|
|
154
|
-
}
|
|
155
|
-
return points.clone().close();
|
|
156
|
-
};
|
|
157
|
-
this.createHoleMatrix = function (group) {
|
|
158
|
-
var e_1, _a;
|
|
159
|
-
var fullTraceDirections = [
|
|
160
|
-
new DPoint_1.DPoint(-1, 0),
|
|
161
|
-
new DPoint_1.DPoint(0, 1),
|
|
162
|
-
new DPoint_1.DPoint(1, 0),
|
|
163
|
-
new DPoint_1.DPoint(0, -1)
|
|
164
|
-
];
|
|
165
|
-
group.prepareToFastSearch();
|
|
166
|
-
var tmpMatrix = TraceMatrix
|
|
167
|
-
.createMatrix(_this.size, function (p) { return group.fastHas(p) ? TraceMatrixValues.t : TraceMatrixValues.f; });
|
|
168
|
-
var startCoords = new DPolygon_1.DPolygon();
|
|
169
|
-
for (var i = 0; i < _this.size.w; i++) {
|
|
170
|
-
startCoords.push(new DPoint_1.DPoint(i, -1));
|
|
171
|
-
startCoords.push(new DPoint_1.DPoint(i, _this.size.h));
|
|
172
|
-
}
|
|
173
|
-
for (var i = 0; i < _this.size.h; i++) {
|
|
174
|
-
startCoords.push(new DPoint_1.DPoint(-1, i));
|
|
175
|
-
startCoords.push(new DPoint_1.DPoint(_this.size.w, i));
|
|
176
|
-
}
|
|
177
|
-
while (startCoords.length) {
|
|
178
|
-
var point = startCoords.pop();
|
|
179
|
-
try {
|
|
180
|
-
for (var fullTraceDirections_1 = (e_1 = void 0, __values(fullTraceDirections)), fullTraceDirections_1_1 = fullTraceDirections_1.next(); !fullTraceDirections_1_1.done; fullTraceDirections_1_1 = fullTraceDirections_1.next()) {
|
|
181
|
-
var direction = fullTraceDirections_1_1.value;
|
|
182
|
-
var tmpPoint = point.clone().move(direction);
|
|
183
|
-
var value = getByPosition(tmpMatrix, tmpPoint, TraceMatrixValues.t);
|
|
184
|
-
if (value === TraceMatrixValues.f) {
|
|
185
|
-
setByPosition(tmpMatrix, tmpPoint, TraceMatrixValues.t);
|
|
186
|
-
startCoords.push(tmpPoint);
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
191
|
-
finally {
|
|
192
|
-
try {
|
|
193
|
-
if (fullTraceDirections_1_1 && !fullTraceDirections_1_1.done && (_a = fullTraceDirections_1.return)) _a.call(fullTraceDirections_1);
|
|
194
|
-
}
|
|
195
|
-
finally { if (e_1) throw e_1.error; }
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
var t = _this.reverseMatrix(tmpMatrix);
|
|
199
|
-
return _this.totalCountInMatrix(t) ? t : null;
|
|
200
|
-
};
|
|
201
|
-
this.size = s.clone().scale(4);
|
|
202
|
-
var t = TraceMatrix.createMatrix(this.size, function (p) {
|
|
203
|
-
var _a = p.clone().mod(4), x = _a.x, y = _a.y;
|
|
204
|
-
if ([1, 2].includes(x) && [1, 2].includes(y)) {
|
|
205
|
-
return f(p.clone().div(4));
|
|
206
|
-
}
|
|
207
|
-
return TraceMatrixValues.f;
|
|
208
|
-
});
|
|
209
|
-
this.m = TraceMatrix.createMatrix(this.size);
|
|
210
|
-
for (var i = 1; i < this.size.y - 1; i++) {
|
|
211
|
-
for (var j = 1; j < this.size.x - 1; j++) {
|
|
212
|
-
if (t[i][j] === TraceMatrixValues.t) {
|
|
213
|
-
this.m[i - 1][j - 1] = TraceMatrixValues.t;
|
|
214
|
-
this.m[i - 1][j] = TraceMatrixValues.t;
|
|
215
|
-
this.m[i - 1][j + 1] = TraceMatrixValues.t;
|
|
216
|
-
this.m[i][j - 1] = TraceMatrixValues.t;
|
|
217
|
-
this.m[i][j] = TraceMatrixValues.t;
|
|
218
|
-
this.m[i][j + 1] = TraceMatrixValues.t;
|
|
219
|
-
this.m[i + 1][j - 1] = TraceMatrixValues.t;
|
|
220
|
-
this.m[i + 1][j] = TraceMatrixValues.t;
|
|
221
|
-
this.m[i + 1][j + 1] = TraceMatrixValues.t;
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
TraceMatrix.prototype.fullMatrixTrace = function () {
|
|
227
|
-
var _this = this;
|
|
228
|
-
var groups = this.findAllGroupsInMatrix(this.m);
|
|
229
|
-
var paths = groups.map(function (g) { return _this.traceGroup(_this.m, g); });
|
|
230
|
-
var holeMatrixs = groups.map(this.createHoleMatrix);
|
|
231
|
-
var holesGroups = holeMatrixs.map(function (m) { return m && _this.findAllGroupsInMatrix(m); });
|
|
232
|
-
var holesPaths = holesGroups.map(function (hg, index) { return hg && hg.map(function (g) { return _this
|
|
233
|
-
.traceGroup(holeMatrixs[index], g); }).filter(function (r) { return r.length > DPolygon_1.MIN_POINTS_IN_VALID_POLYGON; }); });
|
|
234
|
-
return groups.map(function (g, index) {
|
|
235
|
-
var res = paths[index];
|
|
236
|
-
if (holesGroups[index] && holesGroups[index].length) {
|
|
237
|
-
res.holes = holesPaths[index];
|
|
238
|
-
}
|
|
239
|
-
return res.loop()
|
|
240
|
-
.divide(4)
|
|
241
|
-
.round()
|
|
242
|
-
.run();
|
|
243
|
-
});
|
|
244
|
-
};
|
|
245
|
-
TraceMatrix.prototype.reverseMatrix = function (m) {
|
|
246
|
-
return TraceMatrix.createMatrix(this.size, function (p) { return getByPosition(m, p) === TraceMatrixValues.f ? TraceMatrixValues.t : TraceMatrixValues.f; });
|
|
247
|
-
};
|
|
248
|
-
TraceMatrix.prototype.findMarked = function (m, init) {
|
|
249
|
-
var s = this.size;
|
|
250
|
-
var ini = false;
|
|
251
|
-
for (var i = 0; i < s.w; i++) {
|
|
252
|
-
for (var j = 0; j < s.h; j++) {
|
|
253
|
-
if (!ini && init) {
|
|
254
|
-
i = init.x;
|
|
255
|
-
j = init.y;
|
|
256
|
-
ini = true;
|
|
257
|
-
continue;
|
|
258
|
-
}
|
|
259
|
-
if (getByPosition(m, new DPoint_1.DPoint(i, j)) === TraceMatrixValues.t) {
|
|
260
|
-
return new DPoint_1.DPoint(i, j);
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
return null;
|
|
265
|
-
};
|
|
266
|
-
TraceMatrix.prototype.totalCountInMatrix = function (m) {
|
|
267
|
-
var res = 0;
|
|
268
|
-
var s = this.size;
|
|
269
|
-
for (var i = 0; i < s.w; i++) {
|
|
270
|
-
for (var j = 0; j < s.h; j++) {
|
|
271
|
-
if (getByPosition(m, new DPoint_1.DPoint(i, j))) {
|
|
272
|
-
res++;
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
return res;
|
|
277
|
-
};
|
|
278
|
-
TraceMatrix.createMatrix = function (size, f) {
|
|
279
|
-
if (f === void 0) { f = function () { return TraceMatrixValues.f; }; }
|
|
280
|
-
return (0, utils_1.createArray)(size.h)
|
|
281
|
-
.map(function (v, i) { return (0, utils_1.createArray)(size.w).map(function (v2, j) { return f(new DPoint_1.DPoint(j, i)); }); });
|
|
282
|
-
};
|
|
283
|
-
return TraceMatrix;
|
|
284
|
-
}());
|
|
285
|
-
exports.TraceMatrix = TraceMatrix;
|
package/dist/cjs/index.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export * from './DCircle';
|
|
2
|
-
export * from './DLine';
|
|
3
|
-
export * from './DNumbers';
|
|
4
|
-
export * from './DPoint';
|
|
5
|
-
export * from './DPolygon';
|
|
6
|
-
export * from './FastSearch';
|
|
7
|
-
export * from './TraceMatrix';
|
|
8
|
-
export * from './InterpolationMatrix';
|
|
9
|
-
export * from './DPolygonLoop';
|
|
10
|
-
export * from './DPlane';
|
|
11
|
-
export { gaussianElimination, createCanvas, createArray, createMatrix, isDefAndNotNull, cartesianProduct, getCombinations, parseDegreesMinutesSeconds, DGeo } from './utils';
|
package/dist/cjs/index.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.DGeo = exports.parseDegreesMinutesSeconds = exports.getCombinations = exports.cartesianProduct = exports.isDefAndNotNull = exports.createMatrix = exports.createArray = exports.createCanvas = exports.gaussianElimination = void 0;
|
|
18
|
-
__exportStar(require("./DCircle"), exports);
|
|
19
|
-
__exportStar(require("./DLine"), exports);
|
|
20
|
-
__exportStar(require("./DNumbers"), exports);
|
|
21
|
-
__exportStar(require("./DPoint"), exports);
|
|
22
|
-
__exportStar(require("./DPolygon"), exports);
|
|
23
|
-
__exportStar(require("./FastSearch"), exports);
|
|
24
|
-
__exportStar(require("./TraceMatrix"), exports);
|
|
25
|
-
__exportStar(require("./InterpolationMatrix"), exports);
|
|
26
|
-
__exportStar(require("./DPolygonLoop"), exports);
|
|
27
|
-
__exportStar(require("./DPlane"), exports);
|
|
28
|
-
var utils_1 = require("./utils");
|
|
29
|
-
Object.defineProperty(exports, "gaussianElimination", { enumerable: true, get: function () { return utils_1.gaussianElimination; } });
|
|
30
|
-
Object.defineProperty(exports, "createCanvas", { enumerable: true, get: function () { return utils_1.createCanvas; } });
|
|
31
|
-
Object.defineProperty(exports, "createArray", { enumerable: true, get: function () { return utils_1.createArray; } });
|
|
32
|
-
Object.defineProperty(exports, "createMatrix", { enumerable: true, get: function () { return utils_1.createMatrix; } });
|
|
33
|
-
Object.defineProperty(exports, "isDefAndNotNull", { enumerable: true, get: function () { return utils_1.isDefAndNotNull; } });
|
|
34
|
-
Object.defineProperty(exports, "cartesianProduct", { enumerable: true, get: function () { return utils_1.cartesianProduct; } });
|
|
35
|
-
Object.defineProperty(exports, "getCombinations", { enumerable: true, get: function () { return utils_1.getCombinations; } });
|
|
36
|
-
Object.defineProperty(exports, "parseDegreesMinutesSeconds", { enumerable: true, get: function () { return utils_1.parseDegreesMinutesSeconds; } });
|
|
37
|
-
Object.defineProperty(exports, "DGeo", { enumerable: true, get: function () { return utils_1.DGeo; } });
|
package/dist/cjs/utils.d.ts
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
/// <reference types="offscreencanvas" />
|
|
2
|
-
import { DPoint } from './DPoint';
|
|
3
|
-
interface DGeoInterface {
|
|
4
|
-
DEBUG: boolean;
|
|
5
|
-
parseFormat: string;
|
|
6
|
-
}
|
|
7
|
-
export declare const DGeo: DGeoInterface;
|
|
8
|
-
export declare const warn: (...args: any[]) => void;
|
|
9
|
-
export declare const isDefAndNotNull: (a: any) => boolean;
|
|
10
|
-
declare type CheckFunc = (p: DPoint) => CheckFunction;
|
|
11
|
-
declare type CheckFunc2 = (p: any) => CheckFunction;
|
|
12
|
-
interface CheckArgument {
|
|
13
|
-
shouldBeDegree: CheckFunc;
|
|
14
|
-
shouldBeMeters: CheckFunc;
|
|
15
|
-
shouldBeInt: CheckFunc;
|
|
16
|
-
shouldBeUInt: CheckFunc;
|
|
17
|
-
shouldBeRadians: CheckFunc;
|
|
18
|
-
shouldExist: CheckFunc2;
|
|
19
|
-
}
|
|
20
|
-
interface CheckFunction {
|
|
21
|
-
checkArgument: (argName: string) => CheckArgument;
|
|
22
|
-
}
|
|
23
|
-
export declare const checkFunction: (funcName: string) => CheckFunction;
|
|
24
|
-
declare type ArrayFillFunction<T> = (index: number) => T;
|
|
25
|
-
export declare const createArray: <T = number>(v: number, fillSymbol?: T | ArrayFillFunction<T> | undefined) => T[];
|
|
26
|
-
declare type MatrixFillFunction<T> = (x: number, y: number) => T;
|
|
27
|
-
export declare const createMatrix: <T>({ h, w }: DPoint, fillSymbol?: T | MatrixFillFunction<T> | undefined) => T[][];
|
|
28
|
-
export declare const gaussianElimination: {
|
|
29
|
-
(matrix: number[][]): number[];
|
|
30
|
-
MIN: number;
|
|
31
|
-
};
|
|
32
|
-
export declare type True = true;
|
|
33
|
-
export declare const createCanvas: {
|
|
34
|
-
(size: number): [HTMLCanvasElement, CanvasRenderingContext2D];
|
|
35
|
-
(size: number, offscreen: True): [OffscreenCanvas, OffscreenCanvasRenderingContext2D];
|
|
36
|
-
(w: number, h: number): [HTMLCanvasElement, CanvasRenderingContext2D];
|
|
37
|
-
(w: number, h: number, offscreen: True): [OffscreenCanvas, OffscreenCanvasRenderingContext2D];
|
|
38
|
-
(size: DPoint): [HTMLCanvasElement, CanvasRenderingContext2D];
|
|
39
|
-
(size: DPoint, offscreen: True): [OffscreenCanvas, OffscreenCanvasRenderingContext2D];
|
|
40
|
-
document?: Document;
|
|
41
|
-
};
|
|
42
|
-
export declare const cartesianProduct: {
|
|
43
|
-
<T>(a: T[], ...b: T[][]): T[][];
|
|
44
|
-
};
|
|
45
|
-
export declare const getCombinations: <T>(arr: T[][]) => T[][];
|
|
46
|
-
export declare const div: (a: number, b: number) => number;
|
|
47
|
-
export declare const toDegreesMinutesSeconds: (v: number) => string;
|
|
48
|
-
export declare const parseDegreesMinutesSeconds: (i: string) => number;
|
|
49
|
-
export {};
|