dgeoutils 2.4.24 → 2.4.26
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/dist/cjs/TraceMatrix.d.ts +2 -2
- package/dist/cjs/TraceMatrix.js +29 -4
- package/dist/es2015/TraceMatrix.js +29 -4
- package/dist/esm/TraceMatrix.js +29 -4
- package/dist/umd/dgeoutils.js +30 -5
- package/dist/umd/dgeoutils.min.js +1 -1
- package/dist/umd/dgeoutils.min.js.map +1 -1
- package/package.json +2 -2
|
@@ -6,10 +6,10 @@ export declare enum TraceMatrixValues {
|
|
|
6
6
|
}
|
|
7
7
|
export declare type SimpleMatrix = TraceMatrixValues[][];
|
|
8
8
|
export declare class TraceMatrix {
|
|
9
|
-
private readonly size;
|
|
10
9
|
private readonly m;
|
|
11
10
|
approximation: boolean;
|
|
12
|
-
|
|
11
|
+
private readonly size;
|
|
12
|
+
constructor(s: DPoint, f: (p: DPoint) => TraceMatrixValues);
|
|
13
13
|
fullMatrixTrace(): DPolygon[];
|
|
14
14
|
private reverseMatrix;
|
|
15
15
|
private findGroupByIndex;
|
package/dist/cjs/TraceMatrix.js
CHANGED
|
@@ -61,9 +61,8 @@ var setByPosition = function (m, p, value) {
|
|
|
61
61
|
return m[p.y][p.x];
|
|
62
62
|
};
|
|
63
63
|
var TraceMatrix = (function () {
|
|
64
|
-
function TraceMatrix(
|
|
64
|
+
function TraceMatrix(s, f) {
|
|
65
65
|
var _this = this;
|
|
66
|
-
this.size = size;
|
|
67
66
|
this.approximation = true;
|
|
68
67
|
this.findGroupByIndex = function (m, s) {
|
|
69
68
|
var res = new DPolygon_1.DPolygon();
|
|
@@ -199,7 +198,30 @@ var TraceMatrix = (function () {
|
|
|
199
198
|
var t = _this.reverseMatrix(tmpMatrix);
|
|
200
199
|
return _this.totalCountInMatrix(t) ? t : null;
|
|
201
200
|
};
|
|
202
|
-
this.
|
|
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
|
+
}
|
|
203
225
|
}
|
|
204
226
|
TraceMatrix.prototype.fullMatrixTrace = function () {
|
|
205
227
|
var _this = this;
|
|
@@ -214,7 +236,10 @@ var TraceMatrix = (function () {
|
|
|
214
236
|
if (holesGroups[index] && holesGroups[index].length) {
|
|
215
237
|
res.holes = holesPaths[index];
|
|
216
238
|
}
|
|
217
|
-
return res
|
|
239
|
+
return res.loop()
|
|
240
|
+
.divide(4)
|
|
241
|
+
.round()
|
|
242
|
+
.run();
|
|
218
243
|
});
|
|
219
244
|
};
|
|
220
245
|
TraceMatrix.prototype.reverseMatrix = function (m) {
|
|
@@ -21,8 +21,7 @@ const setByPosition = (m, p, value) => {
|
|
|
21
21
|
return m[p.y][p.x];
|
|
22
22
|
};
|
|
23
23
|
export class TraceMatrix {
|
|
24
|
-
constructor(
|
|
25
|
-
this.size = size;
|
|
24
|
+
constructor(s, f) {
|
|
26
25
|
this.approximation = true;
|
|
27
26
|
this.findGroupByIndex = (m, s) => {
|
|
28
27
|
const res = new DPolygon();
|
|
@@ -147,7 +146,30 @@ export class TraceMatrix {
|
|
|
147
146
|
const t = this.reverseMatrix(tmpMatrix);
|
|
148
147
|
return this.totalCountInMatrix(t) ? t : null;
|
|
149
148
|
};
|
|
150
|
-
this.
|
|
149
|
+
this.size = s.clone().scale(4);
|
|
150
|
+
const t = TraceMatrix.createMatrix(this.size, (p) => {
|
|
151
|
+
const { x, y } = p.clone().mod(4);
|
|
152
|
+
if ([1, 2].includes(x) && [1, 2].includes(y)) {
|
|
153
|
+
return f(p.clone().div(4));
|
|
154
|
+
}
|
|
155
|
+
return TraceMatrixValues.f;
|
|
156
|
+
});
|
|
157
|
+
this.m = TraceMatrix.createMatrix(this.size);
|
|
158
|
+
for (let i = 1; i < this.size.y - 1; i++) {
|
|
159
|
+
for (let j = 1; j < this.size.x - 1; j++) {
|
|
160
|
+
if (t[i][j] === TraceMatrixValues.t) {
|
|
161
|
+
this.m[i - 1][j - 1] = TraceMatrixValues.t;
|
|
162
|
+
this.m[i - 1][j] = TraceMatrixValues.t;
|
|
163
|
+
this.m[i - 1][j + 1] = TraceMatrixValues.t;
|
|
164
|
+
this.m[i][j - 1] = TraceMatrixValues.t;
|
|
165
|
+
this.m[i][j] = TraceMatrixValues.t;
|
|
166
|
+
this.m[i][j + 1] = TraceMatrixValues.t;
|
|
167
|
+
this.m[i + 1][j - 1] = TraceMatrixValues.t;
|
|
168
|
+
this.m[i + 1][j] = TraceMatrixValues.t;
|
|
169
|
+
this.m[i + 1][j + 1] = TraceMatrixValues.t;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
151
173
|
}
|
|
152
174
|
fullMatrixTrace() {
|
|
153
175
|
const groups = this.findAllGroupsInMatrix(this.m);
|
|
@@ -161,7 +183,10 @@ export class TraceMatrix {
|
|
|
161
183
|
if (holesGroups[index] && holesGroups[index].length) {
|
|
162
184
|
res.holes = holesPaths[index];
|
|
163
185
|
}
|
|
164
|
-
return res
|
|
186
|
+
return res.loop()
|
|
187
|
+
.divide(4)
|
|
188
|
+
.round()
|
|
189
|
+
.run();
|
|
165
190
|
});
|
|
166
191
|
}
|
|
167
192
|
reverseMatrix(m) {
|
package/dist/esm/TraceMatrix.js
CHANGED
|
@@ -58,9 +58,8 @@ var setByPosition = function (m, p, value) {
|
|
|
58
58
|
return m[p.y][p.x];
|
|
59
59
|
};
|
|
60
60
|
var TraceMatrix = (function () {
|
|
61
|
-
function TraceMatrix(
|
|
61
|
+
function TraceMatrix(s, f) {
|
|
62
62
|
var _this = this;
|
|
63
|
-
this.size = size;
|
|
64
63
|
this.approximation = true;
|
|
65
64
|
this.findGroupByIndex = function (m, s) {
|
|
66
65
|
var res = new DPolygon();
|
|
@@ -196,7 +195,30 @@ var TraceMatrix = (function () {
|
|
|
196
195
|
var t = _this.reverseMatrix(tmpMatrix);
|
|
197
196
|
return _this.totalCountInMatrix(t) ? t : null;
|
|
198
197
|
};
|
|
199
|
-
this.
|
|
198
|
+
this.size = s.clone().scale(4);
|
|
199
|
+
var t = TraceMatrix.createMatrix(this.size, function (p) {
|
|
200
|
+
var _a = p.clone().mod(4), x = _a.x, y = _a.y;
|
|
201
|
+
if ([1, 2].includes(x) && [1, 2].includes(y)) {
|
|
202
|
+
return f(p.clone().div(4));
|
|
203
|
+
}
|
|
204
|
+
return TraceMatrixValues.f;
|
|
205
|
+
});
|
|
206
|
+
this.m = TraceMatrix.createMatrix(this.size);
|
|
207
|
+
for (var i = 1; i < this.size.y - 1; i++) {
|
|
208
|
+
for (var j = 1; j < this.size.x - 1; j++) {
|
|
209
|
+
if (t[i][j] === TraceMatrixValues.t) {
|
|
210
|
+
this.m[i - 1][j - 1] = TraceMatrixValues.t;
|
|
211
|
+
this.m[i - 1][j] = TraceMatrixValues.t;
|
|
212
|
+
this.m[i - 1][j + 1] = TraceMatrixValues.t;
|
|
213
|
+
this.m[i][j - 1] = TraceMatrixValues.t;
|
|
214
|
+
this.m[i][j] = TraceMatrixValues.t;
|
|
215
|
+
this.m[i][j + 1] = TraceMatrixValues.t;
|
|
216
|
+
this.m[i + 1][j - 1] = TraceMatrixValues.t;
|
|
217
|
+
this.m[i + 1][j] = TraceMatrixValues.t;
|
|
218
|
+
this.m[i + 1][j + 1] = TraceMatrixValues.t;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
}
|
|
200
222
|
}
|
|
201
223
|
TraceMatrix.prototype.fullMatrixTrace = function () {
|
|
202
224
|
var _this = this;
|
|
@@ -211,7 +233,10 @@ var TraceMatrix = (function () {
|
|
|
211
233
|
if (holesGroups[index] && holesGroups[index].length) {
|
|
212
234
|
res.holes = holesPaths[index];
|
|
213
235
|
}
|
|
214
|
-
return res
|
|
236
|
+
return res.loop()
|
|
237
|
+
.divide(4)
|
|
238
|
+
.round()
|
|
239
|
+
.run();
|
|
215
240
|
});
|
|
216
241
|
};
|
|
217
242
|
TraceMatrix.prototype.reverseMatrix = function (m) {
|