plotboilerplate 1.21.0 → 1.22.0
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/index.esm.js +30 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/index.esm.min.js +1 -1
- package/dist/index.esm.min.js.map +1 -1
- package/dist/plotboilerplate.browser.min.js +1 -1
- package/dist/plotboilerplate.browser.min.js.map +1 -1
- package/dist/plotboilerplate.js +30 -1
- package/dist/plotboilerplate.min.js +1 -1
- package/package.json +3 -2
- package/src/cjs/Polygon.d.ts +13 -1
- package/src/cjs/Polygon.js +30 -1
- package/src/cjs/Polygon.js.map +1 -1
- package/src/cjs/utils/Params.d.ts +15 -0
- package/src/cjs/utils/Params.js +49 -0
- package/src/cjs/utils/Params.js.map +1 -0
- package/src/cjs/utils/algorithms/ContourLineDetection.d.ts +150 -0
- package/src/cjs/utils/algorithms/ContourLineDetection.js +367 -0
- package/src/cjs/utils/algorithms/ContourLineDetection.js.map +1 -0
- package/src/cjs/utils/algorithms/clearDuplicateVertices.d.ts +21 -0
- package/src/cjs/utils/algorithms/clearDuplicateVertices.js +48 -0
- package/src/cjs/utils/algorithms/clearDuplicateVertices.js.map +1 -0
- package/src/cjs/utils/datastructures/DataGrid2d.d.ts +47 -0
- package/src/cjs/utils/datastructures/DataGrid2d.js +20 -0
- package/src/cjs/utils/datastructures/DataGrid2d.js.map +1 -0
- package/src/cjs/utils/datastructures/DataGrid2dListAdapter.d.ts +65 -0
- package/src/cjs/utils/datastructures/DataGrid2dListAdapter.js +84 -0
- package/src/cjs/utils/datastructures/DataGrid2dListAdapter.js.map +1 -0
- package/src/cjs/utils/datastructures/GenericPath.d.ts +14 -3
- package/src/cjs/utils/datastructures/GenericPath.js +20 -3
- package/src/cjs/utils/datastructures/GenericPath.js.map +1 -1
- package/src/esm/Polygon.d.ts +13 -1
- package/src/esm/Polygon.js +30 -1
- package/src/esm/Polygon.js.map +1 -1
- package/src/esm/utils/Params.d.ts +15 -0
- package/src/esm/utils/Params.js +44 -0
- package/src/esm/utils/Params.js.map +1 -0
- package/src/esm/utils/algorithms/ContourLineDetection.d.ts +150 -0
- package/src/esm/utils/algorithms/ContourLineDetection.js +362 -0
- package/src/esm/utils/algorithms/ContourLineDetection.js.map +1 -0
- package/src/esm/utils/algorithms/clearDuplicateVertices.d.ts +21 -0
- package/src/esm/utils/algorithms/clearDuplicateVertices.js +44 -0
- package/src/esm/utils/algorithms/clearDuplicateVertices.js.map +1 -0
- package/src/esm/utils/datastructures/DataGrid2d.d.ts +47 -0
- package/src/esm/utils/datastructures/DataGrid2d.js +19 -0
- package/src/esm/utils/datastructures/DataGrid2d.js.map +1 -0
- package/src/esm/utils/datastructures/DataGrid2dListAdapter.d.ts +65 -0
- package/src/esm/utils/datastructures/DataGrid2dListAdapter.js +79 -0
- package/src/esm/utils/datastructures/DataGrid2dListAdapter.js.map +1 -0
- package/src/esm/utils/datastructures/GenericPath.d.ts +14 -3
- package/src/esm/utils/datastructures/GenericPath.js +20 -3
- package/src/esm/utils/datastructures/GenericPath.js.map +1 -1
- package/src/ts/Polygon.ts +31 -1
- package/src/ts/utils/Params.ts +47 -0
- package/src/ts/utils/algorithms/ContourLineDetection.ts +485 -0
- package/src/ts/utils/algorithms/clearDuplicateVertices.ts +49 -0
- package/src/ts/utils/datastructures/DataGrid2d.ts +54 -0
- package/src/ts/utils/datastructures/DataGrid2dListAdapter.ts +121 -0
- package/src/ts/utils/datastructures/GenericPath.ts +21 -3
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A DataGrid2d implementation on a linear array of triplets/Vector3.
|
|
3
|
+
*
|
|
4
|
+
* @author Ikaros Kappler
|
|
5
|
+
* @date 2023-10-28
|
|
6
|
+
* @modified 2023-11-04 Converted to a Typescript class.
|
|
7
|
+
* @version 1.0.0
|
|
8
|
+
**/
|
|
9
|
+
export class DataGrid2dListAdapter {
|
|
10
|
+
/**
|
|
11
|
+
* Create a new DataGrid2d from the given
|
|
12
|
+
* @throws Error if xSegmentCount*ySegmentCount is larger than the capacity of the array/list.
|
|
13
|
+
* @param list
|
|
14
|
+
* @param xSegmentCount
|
|
15
|
+
* @param ySegmentCount
|
|
16
|
+
*/
|
|
17
|
+
constructor(list, xSegmentCount, ySegmentCount) {
|
|
18
|
+
if (xSegmentCount * ySegmentCount > list.length) {
|
|
19
|
+
throw `Cannot create DataGrid2dListAdapter, the list (length ${list.length}) does not provide enough items for ${xSegmentCount}x${ySegmentCount} required entries.`;
|
|
20
|
+
}
|
|
21
|
+
// this.canvas = document.getElementById(canvasId);
|
|
22
|
+
this.xSegmentCount = xSegmentCount;
|
|
23
|
+
this.ySegmentCount = ySegmentCount;
|
|
24
|
+
this._dataList = list;
|
|
25
|
+
}
|
|
26
|
+
getIndicesFromBufferIndex(bufferIndex) {
|
|
27
|
+
return { xIndex: Math.floor(bufferIndex % this.xSegmentCount), yIndex: Math.floor(bufferIndex / this.xSegmentCount) };
|
|
28
|
+
}
|
|
29
|
+
getCoordsFromBufferIndex(bufferIndex) {
|
|
30
|
+
var index = this.getIndicesFromBufferIndex(bufferIndex);
|
|
31
|
+
// Note that the xSegmentCount and ySegmentCount counts plane squares, each consisting of four vertices
|
|
32
|
+
index.xRel = index.xIndex / (this.xSegmentCount - 1);
|
|
33
|
+
index.yRel = index.yIndex / (this.ySegmentCount - 1);
|
|
34
|
+
return index;
|
|
35
|
+
}
|
|
36
|
+
coordinateIndicesToBufferIndex(xIndex, yIndex) {
|
|
37
|
+
return yIndex * this.xSegmentCount + xIndex;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* @override
|
|
41
|
+
*/
|
|
42
|
+
getMinDataValue() {
|
|
43
|
+
return this.minDataValue;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* @override
|
|
47
|
+
*/
|
|
48
|
+
getMaxDataValue() {
|
|
49
|
+
return this.maxDataValue;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* @override
|
|
53
|
+
*/
|
|
54
|
+
getDataValueAt(xIndex, yIndex, isDebug) {
|
|
55
|
+
// var bufferIndex = yIndex * this.xSegmentCount + xIndex;
|
|
56
|
+
var bufferIndex = this.coordinateIndicesToBufferIndex(xIndex, yIndex);
|
|
57
|
+
if (isDebug) {
|
|
58
|
+
console.log("xIndex", xIndex, "yIndex", yIndex, "bufferIndex", bufferIndex);
|
|
59
|
+
}
|
|
60
|
+
if (bufferIndex > this._dataList.length) {
|
|
61
|
+
console.error("ERR buffer index is out of bounds! xIndex", xIndex, "yIndex", yIndex, "bufferIndex", bufferIndex);
|
|
62
|
+
}
|
|
63
|
+
if (!this._dataList[bufferIndex]) {
|
|
64
|
+
console.error("ERR buffer element is null! xIndex", xIndex, "yIndex", yIndex, "bufferIndex", bufferIndex);
|
|
65
|
+
}
|
|
66
|
+
return this._dataList && bufferIndex < this._dataList.length ? this._dataList[bufferIndex].z : null;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* @override
|
|
70
|
+
*/
|
|
71
|
+
getDataFace4At(xIndex, yIndex, buffer) {
|
|
72
|
+
// buffer: array[2][2]
|
|
73
|
+
buffer[0][0] = this.getDataValueAt(xIndex, yIndex);
|
|
74
|
+
buffer[1][0] = this.getDataValueAt(xIndex + 1, yIndex);
|
|
75
|
+
buffer[1][1] = this.getDataValueAt(xIndex + 1, yIndex + 1);
|
|
76
|
+
buffer[0][1] = this.getDataValueAt(xIndex, yIndex + 1);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=DataGrid2dListAdapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DataGrid2dListAdapter.js","sourceRoot":"","sources":["../../../ts/utils/datastructures/DataGrid2dListAdapter.ts"],"names":[],"mappings":"AAAA;;;;;;;IAOI;AAiBJ,MAAM,OAAO,qBAAqB;IAmBhC;;;;;;OAMG;IACH,YAAY,IAAuB,EAAE,aAAqB,EAAE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AAI,CAAC,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,CAAC,CAAC,CAAC;IACzD,CAAC;CACF"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @author
|
|
3
|
-
* @version
|
|
4
|
-
* @date
|
|
2
|
+
* @author Ikaros Kappler
|
|
3
|
+
* @version 1.1.0
|
|
4
|
+
* @date 2022-10-17
|
|
5
|
+
* @modified 2023-11-27 Added the `GenericPath.getAllStartEndPoints()` function.
|
|
5
6
|
*/
|
|
6
7
|
import { Path, PathSegment } from "../../interfaces/additionals";
|
|
7
8
|
import { Vertex } from "../../Vertex";
|
|
@@ -72,4 +73,14 @@ export declare class GenericPath implements Path {
|
|
|
72
73
|
* @return {Vertex} The end point of the ending point's tangent.
|
|
73
74
|
*/
|
|
74
75
|
getEndTangent(): Vertex;
|
|
76
|
+
/**
|
|
77
|
+
* Get the sequence of all start/end points of this path.
|
|
78
|
+
* Assumption is: each path segment's end point is located on the next segment's start point
|
|
79
|
+
* to shape a full connected path.
|
|
80
|
+
*
|
|
81
|
+
* No arcs are considered here, just plain linear segments.
|
|
82
|
+
*
|
|
83
|
+
* @returns {Array<Vertex>}
|
|
84
|
+
*/
|
|
85
|
+
getAllStartEndPoints(): Array<Vertex>;
|
|
75
86
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @author
|
|
3
|
-
* @version
|
|
4
|
-
* @date
|
|
2
|
+
* @author Ikaros Kappler
|
|
3
|
+
* @version 1.1.0
|
|
4
|
+
* @date 2022-10-17
|
|
5
|
+
* @modified 2023-11-27 Added the `GenericPath.getAllStartEndPoints()` function.
|
|
5
6
|
*/
|
|
6
7
|
export class GenericPath {
|
|
7
8
|
constructor(startSegment) {
|
|
@@ -96,5 +97,21 @@ export class GenericPath {
|
|
|
96
97
|
getEndTangent() {
|
|
97
98
|
return this.segments[this.segments.length - 1].getEndTangent();
|
|
98
99
|
}
|
|
100
|
+
/**
|
|
101
|
+
* Get the sequence of all start/end points of this path.
|
|
102
|
+
* Assumption is: each path segment's end point is located on the next segment's start point
|
|
103
|
+
* to shape a full connected path.
|
|
104
|
+
*
|
|
105
|
+
* No arcs are considered here, just plain linear segments.
|
|
106
|
+
*
|
|
107
|
+
* @returns {Array<Vertex>}
|
|
108
|
+
*/
|
|
109
|
+
getAllStartEndPoints() {
|
|
110
|
+
const verts = [this.segments[0].getStartPoint()];
|
|
111
|
+
this.segments.forEach((segment) => {
|
|
112
|
+
verts.push(segment.getEndPoint());
|
|
113
|
+
});
|
|
114
|
+
return verts;
|
|
115
|
+
}
|
|
99
116
|
}
|
|
100
117
|
//# sourceMappingURL=GenericPath.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GenericPath.js","sourceRoot":"","sources":["../../../ts/utils/datastructures/GenericPath.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"GenericPath.js","sourceRoot":"","sources":["../../../ts/utils/datastructures/GenericPath.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,MAAM,OAAO,WAAW;IAGtB,YAAY,YAAyB;QACnC,IAAI,CAAC,QAAQ,GAAG,CAAC,YAAY,CAAC,CAAC;IACjC,CAAC;IAED;;;;;;OAMG;IACH,eAAe;QACb,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC;IAC9B,CAAC;IAED;;;;;;OAMG;IACH,YAAY,CAAC,KAAa;QACxB,OAAO,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IAC9B,CAAC;IAED;;;;;;OAMG;IACH,KAAK;QACH,MAAM,OAAO,GAAG,IAAI,WAAW,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,OAAO,EAAE,CAAC,CAAC;QAC3F,KAAK,IAAI,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,GAAG,CA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AAE,CAAC,CAAC;QAChE,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,OAAoB,EAAE,EAAE;YAC7C,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC;QACpC,CAAC,CAAC,CAAC;QACH,OAAO,KAAK,CAAC;IACf,CAAC;CACF"}
|
package/src/ts/Polygon.ts
CHANGED
|
@@ -27,7 +27,8 @@
|
|
|
27
27
|
* @modified 2023-09-25 Added the `Polygon.getInterpolationPolygon(number)` function.
|
|
28
28
|
* @modified 2023-09-25 Added the `Polygon.lineIntersections(Line,boolean)` function.
|
|
29
29
|
* @modified 2023-09-29 Added the `Polygon.closestLineIntersection(Line,boolean)` function.
|
|
30
|
-
* @
|
|
30
|
+
* @modified 2023-11-24 Added the `Polygon.containsPolygon(Polygon)' function.
|
|
31
|
+
* @version 1.12.0
|
|
31
32
|
*
|
|
32
33
|
* @file Polygon
|
|
33
34
|
* @public
|
|
@@ -184,6 +185,35 @@ export class Polygon implements SVGSerializable {
|
|
|
184
185
|
return inside;
|
|
185
186
|
}
|
|
186
187
|
|
|
188
|
+
/**
|
|
189
|
+
* Check if the passed polygon is completly contained inside this polygon.
|
|
190
|
+
*
|
|
191
|
+
* This means:
|
|
192
|
+
* - all polygon's vertices must be inside this polygon.
|
|
193
|
+
* - the polygon has no edge intersections with this polygon.
|
|
194
|
+
*
|
|
195
|
+
* @param {Polygon} polygon - The polygon to check if contained.
|
|
196
|
+
* @return {boolean}
|
|
197
|
+
*/
|
|
198
|
+
containsPolygon(polygon: Polygon): boolean {
|
|
199
|
+
for (var i = 0; i < polygon.vertices.length; i++) {
|
|
200
|
+
if (!this.containsVert(polygon.vertices[i])) {
|
|
201
|
+
return false;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
// All vertices are inside; check for intersections
|
|
205
|
+
const lineSegment = new Line(new Vertex(), new Vertex());
|
|
206
|
+
for (var i = 0; i < polygon.vertices.length; i++) {
|
|
207
|
+
lineSegment.a.set(polygon.vertices[i]);
|
|
208
|
+
lineSegment.b.set(polygon.vertices[(i + 1) % polygon.vertices.length]);
|
|
209
|
+
if (this.lineIntersections(lineSegment, true).length > 0) {
|
|
210
|
+
// Current segment has intersection(s) with this polygon.
|
|
211
|
+
return false;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
return true;
|
|
215
|
+
}
|
|
216
|
+
|
|
187
217
|
/**
|
|
188
218
|
* Calculate the area of the given polygon (unsigned).
|
|
189
219
|
*
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wraps a Record<string,string> and adds type conversion methods (developed this in
|
|
3
|
+
* some other project) and added this here (2023-10-28).
|
|
4
|
+
*
|
|
5
|
+
* @author Ikars Kappler
|
|
6
|
+
* @version 1.0.0
|
|
7
|
+
* @date 2023-03-13
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
export class Params {
|
|
11
|
+
baseParams: Record<string, string>;
|
|
12
|
+
|
|
13
|
+
constructor(baseParams: Record<string, string>) {
|
|
14
|
+
this.baseParams = baseParams;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
getString(name: string, fallback: string): string {
|
|
18
|
+
let value = this.baseParams[name];
|
|
19
|
+
if (typeof value === "undefined" || !value || (value = value.trim()).length === 0) {
|
|
20
|
+
return fallback;
|
|
21
|
+
}
|
|
22
|
+
return value;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
getNumber(name: string, fallback: number): number {
|
|
26
|
+
let value = this.baseParams[name];
|
|
27
|
+
if (typeof value === "undefined" || !value || (value = value.trim()).length === 0) {
|
|
28
|
+
return fallback;
|
|
29
|
+
}
|
|
30
|
+
return Number(value);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
getBoolean(name: string, fallback: boolean): boolean {
|
|
34
|
+
let value = this.baseParams[name];
|
|
35
|
+
if (typeof value === "undefined" || !value || (value = value.trim()).length === 0) {
|
|
36
|
+
return fallback;
|
|
37
|
+
}
|
|
38
|
+
value = value.toLocaleLowerCase();
|
|
39
|
+
if (value === "1" || value === "on" || value === "yes" || value === "y" || value === "hi" || value == "high") {
|
|
40
|
+
return true;
|
|
41
|
+
} else if (value === "0" || value === "off" || value === "no" || value === "n" || value === "lo" || value == "low") {
|
|
42
|
+
return false;
|
|
43
|
+
} else {
|
|
44
|
+
return Boolean(value);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|