flo-mat 4.1.1 → 4.1.3
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/__tests__/get-mats1.ts +23 -22
- package/browser/index.js +138 -2
- package/browser/index.min.js +1 -1
- package/node/cp-node/stringification/cp-node-stringifyable.d.ts +29 -0
- package/node/cp-node/stringification/cp-node-stringifyable.js +7 -0
- package/node/cp-node/stringification/cp-node-stringifyable.js.map +1 -0
- package/node/cp-node/stringification/from-stringifyable.d.ts +4 -0
- package/node/cp-node/stringification/from-stringifyable.js +44 -0
- package/node/cp-node/stringification/from-stringifyable.js.map +1 -0
- package/node/cp-node/stringification/loop-from-stringifyable.d.ts +4 -0
- package/node/cp-node/stringification/loop-from-stringifyable.js +7 -0
- package/node/cp-node/stringification/loop-from-stringifyable.js.map +1 -0
- package/node/cp-node/stringification/loop-stringifyable.d.ts +5 -0
- package/node/cp-node/stringification/loop-stringifyable.js +2 -0
- package/node/cp-node/stringification/loop-stringifyable.js.map +1 -0
- package/node/cp-node/stringification/loop-to-stringifyable.d.ts +4 -0
- package/node/cp-node/stringification/loop-to-stringifyable.js +6 -0
- package/node/cp-node/stringification/loop-to-stringifyable.js.map +1 -0
- package/node/cp-node/stringification/to-stringifyable.d.ts +9 -0
- package/node/cp-node/stringification/to-stringifyable.js +46 -0
- package/node/cp-node/stringification/to-stringifyable.js.map +1 -0
- package/node/index.d.ts +5 -0
- package/node/index.js +5 -0
- package/node/index.js.map +1 -1
- package/node/mat/get-branches.js.map +1 -1
- package/node/mat/get-largest-3-prong.d.ts +3 -0
- package/node/mat/get-largest-3-prong.js +16 -0
- package/node/mat/get-largest-3-prong.js.map +1 -0
- package/node/mat/get-largest-vertex.d.ts +0 -1
- package/node/mat/get-largest-vertex.js +0 -1
- package/node/mat/get-largest-vertex.js.map +1 -1
- package/package.json +4 -4
- package/src/cp-node/stringification/from-stringifyable.ts +4 -3
- package/src/cp-node/stringification/to-stringifyable.ts +3 -3
- package/src/index.ts +6 -1
- package/src/mat/get-branches.ts +1 -3
- package/src/mat/get-largest-3-prong.ts +3 -2
- package/src/mat/get-largest-vertex.ts +3 -2
package/__tests__/get-mats1.ts
CHANGED
|
@@ -23,6 +23,7 @@ function getMats1() {
|
|
|
23
23
|
curveIdx: 0,
|
|
24
24
|
loopIdx: 0,
|
|
25
25
|
p: [24, 8],
|
|
26
|
+
pDd: [[0,24],[0,8]],
|
|
26
27
|
t: 1,
|
|
27
28
|
isSource: true,
|
|
28
29
|
order: -1,
|
|
@@ -33,28 +34,28 @@ function getMats1() {
|
|
|
33
34
|
prevOnCircle: 1,
|
|
34
35
|
nextOnCircle: 1
|
|
35
36
|
},
|
|
36
|
-
{ id: 1, isHoleClosing: false, isIntersection: false, pointOnShape: { circle: { center: [24, 8], radius: 0 }, curveIdx: 0, loopIdx: 0, p: [24, 8], t: 1, isSource: true , order: 1, order2: 0 }, prev: 0, next: 10, prevOnCircle: 0, nextOnCircle: 0 },
|
|
37
|
-
{ id: 10, isHoleClosing: false, isIntersection: false, pointOnShape: { circle: { center: [46, -5.21425847941623], radius: 13.21425847941623 }, curveIdx: 1, loopIdx: 0, p: [46, 8], t: 1, isSource: true , order: -1, order2: 0 }, prev: 1, next: 144, prevOnCircle: 11, nextOnCircle: 11 },
|
|
38
|
-
{ id: 144, isHoleClosing: false, isIntersection: false, pointOnShape: { circle: { center: [81.5, -12.641417453935567], radius: 41.064803841095305 }, curveIdx: 1, loopIdx: 0, p: [46, 8], t: 1, isSource: false , order: -0.5026547194480646, order2: 0 }, prev: 10, next: 147, prevOnCircle: 143, nextOnCircle: 142 },
|
|
39
|
-
{ id: 147, isHoleClosing: false, isIntersection: false, pointOnShape: { circle: { center: [81.5, 18.5], radius: 35.5 }, curveIdx: 2, loopIdx: 0, p: [46, 18.499999999999996], t: 0.2282608695652173, isSource: false , order: 0, order2: 0 }, prev: 144, next: 2, prevOnCircle: 146, nextOnCircle: 145 },
|
|
40
|
-
{ id: 2, isHoleClosing: false, isIntersection: false, pointOnShape: { circle: { center: [46, 54], radius: 0 }, curveIdx: 2, loopIdx: 0, p: [46, 54], t: 1, isSource: true , order: -1, order2: 0 }, prev: 147, next: 3, prevOnCircle: 3, nextOnCircle: 3 },
|
|
41
|
-
{ id: 3, isHoleClosing: false, isIntersection: false, pointOnShape: { circle: { center: [46, 54], radius: 0 }, curveIdx: 2, loopIdx: 0, p: [46, 54], t: 1, isSource: true , order: 1, order2: 0 }, prev: 2, next: 145, prevOnCircle: 2, nextOnCircle: 2 },
|
|
42
|
-
{ id: 145, isHoleClosing: false, isIntersection: false, pointOnShape: { circle: { center: [81.5, 18.5], radius: 35.5 }, curveIdx: 3, loopIdx: 0, p: [81.5, 54], t: 0.5, isSource: false , order: 0, order2: 0 }, prev: 3, next: 4, prevOnCircle: 147, nextOnCircle: 146 },
|
|
43
|
-
{ id: 4, isHoleClosing: false, isIntersection: false, pointOnShape: { circle: { center: [117, 54], radius: 0 }, curveIdx: 3, loopIdx: 0, p: [117, 54], t: 1, isSource: true , order: -1, order2: 0 }, prev: 145, next: 5, prevOnCircle: 5, nextOnCircle: 5 },
|
|
44
|
-
{ id: 5, isHoleClosing: false, isIntersection: false, pointOnShape: { circle: { center: [117, 54], radius: 0 }, curveIdx: 3, loopIdx: 0, p: [117, 54], t: 1, isSource: true , order: 1, order2: 0 }, prev: 4, next: 146, prevOnCircle: 4, nextOnCircle: 4 },
|
|
45
|
-
{ id: 146, isHoleClosing: false, isIntersection: false, pointOnShape: { circle: { center: [81.5, 18.5], radius: 35.5 }, curveIdx: 4, loopIdx: 0, p: [117, 18.499999999999996], t: 0.7717391304347827, isSource: false , order: 0, order2: 0 }, prev: 5, next: 142, prevOnCircle: 145, nextOnCircle: 147 },
|
|
46
|
-
{ id: 142, isHoleClosing: false, isIntersection: false, pointOnShape: { circle: { center: [81.5, -12.641417453935567], radius: 41.064803841095305 }, curveIdx: 4, loopIdx: 0, p: [117, 8], t: 1, isSource: false , order: -0.8644872659655476, order2: 0 }, prev: 146, next: 148, prevOnCircle: 144, nextOnCircle: 143 },
|
|
47
|
-
{ id: 148, isHoleClosing: false, isIntersection: false, pointOnShape: { circle: { center: [81.68410160768288, -12.970446490933696], radius: 41.07276841516263 }, curveIdx: 4, loopIdx: 0, p: [117, 8], t: 1, isSource: false , order: -0.8598373023056252, order2: 0 }, prev: 142, next: 119, prevOnCircle: 150, nextOnCircle: 149 },
|
|
48
|
-
{ id: 119, isHoleClosing: false, isIntersection: false, pointOnShape: { circle: { center: [115.9110440340909, -5.952334953607174], radius: 13.994766012811272 }, curveIdx: 4, loopIdx: 0, p: [117, 8], t: 1, isSource: false , order: -0.07781165936695383, order2: 0 }, prev: 148, next: 6, prevOnCircle: 118, nextOnCircle: 118 },
|
|
49
|
-
{ id: 6, isHoleClosing: false, isIntersection: false, pointOnShape: { circle: { center: [139, 8], radius: 0 }, curveIdx: 5, loopIdx: 0, p: [139, 8], t: 1, isSource: true , order: -1, order2: 0 }, prev: 119, next: 7, prevOnCircle: 7, nextOnCircle: 7 },
|
|
50
|
-
{ id: 7, isHoleClosing: false, isIntersection: false, pointOnShape: { circle: { center: [139, 8], radius: 0 }, curveIdx: 5, loopIdx: 0, p: [139, 8], t: 1, isSource: true , order: 1, order2: 0 }, prev: 6, next: 118, prevOnCircle: 6, nextOnCircle: 6 },
|
|
51
|
-
{ id: 118, isHoleClosing: false, isIntersection: false, pointOnShape: { circle: { center: [115.9110440340909, -5.952334953607174], radius: 13.994766012811272 }, curveIdx: 6, loopIdx: 0, p: [128.3125, -12.4375], t: 0.1875, isSource: true , order: 0, order2: 0 }, prev: 7, next: 149, prevOnCircle: 119, nextOnCircle: 119 },
|
|
52
|
-
{ id: 149, isHoleClosing: false, isIntersection: false, pointOnShape: { circle: { center: [81.68410160768288, -12.970446490933696], radius: 41.07276841516263 }, curveIdx: 6, loopIdx: 0, p: [118.08071791640388, -32.003539423017145], t: 0.36700494883501966, isSource: false , order: 0, order2: 0 }, prev: 118, next: 8, prevOnCircle: 148, nextOnCircle: 150 },
|
|
53
|
-
{ id: 8, isHoleClosing: false, isIntersection: false, pointOnShape: { circle: { center: [82, -101], radius: 0 }, curveIdx: 6, loopIdx: 0, p: [82, -101], t: 1, isSource: true , order: -1, order2: 0 }, prev: 149, next: 9, prevOnCircle: 9, nextOnCircle: 9 },
|
|
54
|
-
{ id: 9, isHoleClosing: false, isIntersection: false, pointOnShape: { circle: { center: [82, -101], radius: 0 }, curveIdx: 6, loopIdx: 0, p: [82, -101], t: 1, isSource: true , order: 1, order2: 0 }, prev: 8, next: 150, prevOnCircle: 8, nextOnCircle: 8 },
|
|
55
|
-
{ id: 150, isHoleClosing: false, isIntersection: false, pointOnShape: { circle: { center: [81.68410160768288, -12.970446490933696], radius: 41.07276841516263 }, curveIdx: 0, loopIdx: 0, p: [45.425023320690585, -32.264267964746104], t: 0.6306030461949899, isSource: false , order: 0, order2: 0 }, prev: 9, next: 143, prevOnCircle: 149, nextOnCircle: 148 },
|
|
56
|
-
{ id: 143, isHoleClosing: false, isIntersection: false, pointOnShape: { circle: { center: [81.5, -12.641417453935567], radius: 41.064803841095305 }, curveIdx: 0, loopIdx: 0, p: [45.24795284642707, -31.931497590699145], t: 0.6336559854064299, isSource: false , order: 0, order2: 0 }, prev: 150, next: 11, prevOnCircle: 142, nextOnCircle: 144 },
|
|
57
|
-
{ id: 11, isHoleClosing: false, isIntersection: false, pointOnShape: { circle: { center: [46, -5.21425847941623], radius: 13.21425847941623 }, curveIdx: 0, loopIdx: 0, p: [34.33444028251029, -11.421620530924521], t: 0.8218199951291328, isSource: false , order: 0, order2: 0 }, prev: 143, next: 0, prevOnCircle: 10, nextOnCircle: 10 }
|
|
37
|
+
{ id: 1, isHoleClosing: false, isIntersection: false, pointOnShape: { circle: { center: [24, 8], radius: 0 }, curveIdx: 0, loopIdx: 0, p: [24, 8], t: 1, isSource: true , order: 1, order2: 0, pDd: [[0,24],[0,8]] }, prev: 0, next: 10, prevOnCircle: 0, nextOnCircle: 0 },
|
|
38
|
+
{ id: 10, isHoleClosing: false, isIntersection: false, pointOnShape: { circle: { center: [46, -5.21425847941623], radius: 13.21425847941623 }, curveIdx: 1, loopIdx: 0, p: [46, 8], t: 1, isSource: true , order: -1, order2: 0, pDd: [[0,46],[0,8]] }, prev: 1, next: 144, prevOnCircle: 11, nextOnCircle: 11 },
|
|
39
|
+
{ id: 144, isHoleClosing: false, isIntersection: false, pointOnShape: { circle: { center: [81.5, -12.641417453935567], radius: 41.064803841095305 }, curveIdx: 1, loopIdx: 0, p: [46, 8], t: 1, isSource: false , order: -0.5026547194480646, order2: 0, pDd: [[0,46],[0,8]] }, prev: 10, next: 147, prevOnCircle: 143, nextOnCircle: 142 },
|
|
40
|
+
{ id: 147, isHoleClosing: false, isIntersection: false, pointOnShape: { circle: { center: [81.5, 18.5], radius: 35.5 }, curveIdx: 2, loopIdx: 0, p: [46, 18.499999999999996], t: 0.2282608695652173, isSource: false , order: 0, order2: 0, pDd: [[0,46],[0,18.499999999999996]] }, prev: 144, next: 2, prevOnCircle: 146, nextOnCircle: 145 },
|
|
41
|
+
{ id: 2, isHoleClosing: false, isIntersection: false, pointOnShape: { circle: { center: [46, 54], radius: 0 }, curveIdx: 2, loopIdx: 0, p: [46, 54], t: 1, isSource: true , order: -1, order2: 0, pDd: [[0,46],[0,54]] }, prev: 147, next: 3, prevOnCircle: 3, nextOnCircle: 3 },
|
|
42
|
+
{ id: 3, isHoleClosing: false, isIntersection: false, pointOnShape: { circle: { center: [46, 54], radius: 0 }, curveIdx: 2, loopIdx: 0, p: [46, 54], t: 1, isSource: true , order: 1, order2: 0, pDd: [[0,46],[0,54]] }, prev: 2, next: 145, prevOnCircle: 2, nextOnCircle: 2 },
|
|
43
|
+
{ id: 145, isHoleClosing: false, isIntersection: false, pointOnShape: { circle: { center: [81.5, 18.5], radius: 35.5 }, curveIdx: 3, loopIdx: 0, p: [81.5, 54], t: 0.5, isSource: false , order: 0, order2: 0, pDd: [[0,81.5],[0,54]] }, prev: 3, next: 4, prevOnCircle: 147, nextOnCircle: 146 },
|
|
44
|
+
{ id: 4, isHoleClosing: false, isIntersection: false, pointOnShape: { circle: { center: [117, 54], radius: 0 }, curveIdx: 3, loopIdx: 0, p: [117, 54], t: 1, isSource: true , order: -1, order2: 0, pDd: [[0,117],[0,54]] }, prev: 145, next: 5, prevOnCircle: 5, nextOnCircle: 5 },
|
|
45
|
+
{ id: 5, isHoleClosing: false, isIntersection: false, pointOnShape: { circle: { center: [117, 54], radius: 0 }, curveIdx: 3, loopIdx: 0, p: [117, 54], t: 1, isSource: true , order: 1, order2: 0, pDd: [[0,117],[0,54]] }, prev: 4, next: 146, prevOnCircle: 4, nextOnCircle: 4 },
|
|
46
|
+
{ id: 146, isHoleClosing: false, isIntersection: false, pointOnShape: { circle: { center: [81.5, 18.5], radius: 35.5 }, curveIdx: 4, loopIdx: 0, p: [117, 18.499999999999996], t: 0.7717391304347827, isSource: false , order: 0, order2: 0, pDd: [[0,117],[0,18.499999999999996]] }, prev: 5, next: 142, prevOnCircle: 145, nextOnCircle: 147 },
|
|
47
|
+
{ id: 142, isHoleClosing: false, isIntersection: false, pointOnShape: { circle: { center: [81.5, -12.641417453935567], radius: 41.064803841095305 }, curveIdx: 4, loopIdx: 0, p: [117, 8], t: 1, isSource: false , order: -0.8644872659655476, order2: 0, pDd: [[0,117],[0,8]] }, prev: 146, next: 148, prevOnCircle: 144, nextOnCircle: 143 },
|
|
48
|
+
{ id: 148, isHoleClosing: false, isIntersection: false, pointOnShape: { circle: { center: [81.68410160768288, -12.970446490933696], radius: 41.07276841516263 }, curveIdx: 4, loopIdx: 0, p: [117, 8], t: 1, isSource: false , order: -0.8598373023056252, order2: 0, pDd: [[0,117],[0,8]] }, prev: 142, next: 119, prevOnCircle: 150, nextOnCircle: 149 },
|
|
49
|
+
{ id: 119, isHoleClosing: false, isIntersection: false, pointOnShape: { circle: { center: [115.9110440340909, -5.952334953607174], radius: 13.994766012811272 }, curveIdx: 4, loopIdx: 0, p: [117, 8], t: 1, isSource: false , order: -0.07781165936695383, order2: 0, pDd: [[0,117],[0,8]] }, prev: 148, next: 6, prevOnCircle: 118, nextOnCircle: 118 },
|
|
50
|
+
{ id: 6, isHoleClosing: false, isIntersection: false, pointOnShape: { circle: { center: [139, 8], radius: 0 }, curveIdx: 5, loopIdx: 0, p: [139, 8], t: 1, isSource: true , order: -1, order2: 0, pDd: [[0,139],[0,8]] }, prev: 119, next: 7, prevOnCircle: 7, nextOnCircle: 7 },
|
|
51
|
+
{ id: 7, isHoleClosing: false, isIntersection: false, pointOnShape: { circle: { center: [139, 8], radius: 0 }, curveIdx: 5, loopIdx: 0, p: [139, 8], t: 1, isSource: true , order: 1, order2: 0, pDd: [[0,139],[0,8]] }, prev: 6, next: 118, prevOnCircle: 6, nextOnCircle: 6 },
|
|
52
|
+
{ id: 118, isHoleClosing: false, isIntersection: false, pointOnShape: { circle: { center: [115.9110440340909, -5.952334953607174], radius: 13.994766012811272 }, curveIdx: 6, loopIdx: 0, p: [128.3125, -12.4375], t: 0.1875, isSource: true , order: 0, order2: 0, pDd: [[0,128.3125],[0,-12.4375]] }, prev: 7, next: 149, prevOnCircle: 119, nextOnCircle: 119 },
|
|
53
|
+
{ id: 149, isHoleClosing: false, isIntersection: false, pointOnShape: { circle: { center: [81.68410160768288, -12.970446490933696], radius: 41.07276841516263 }, curveIdx: 6, loopIdx: 0, p: [118.08071791640388, -32.003539423017145], t: 0.36700494883501966, isSource: false , order: 0, order2: 0, pDd: [[0,118.08071791640388],[0,-32.003539423017145]] }, prev: 118, next: 8, prevOnCircle: 148, nextOnCircle: 150 },
|
|
54
|
+
{ id: 8, isHoleClosing: false, isIntersection: false, pointOnShape: { circle: { center: [82, -101], radius: 0 }, curveIdx: 6, loopIdx: 0, p: [82, -101], t: 1, isSource: true , order: -1, order2: 0, pDd: [[0,82],[0,-101]] }, prev: 149, next: 9, prevOnCircle: 9, nextOnCircle: 9 },
|
|
55
|
+
{ id: 9, isHoleClosing: false, isIntersection: false, pointOnShape: { circle: { center: [82, -101], radius: 0 }, curveIdx: 6, loopIdx: 0, p: [82, -101], t: 1, isSource: true , order: 1, order2: 0, pDd: [[0,82],[0,-101]] }, prev: 8, next: 150, prevOnCircle: 8, nextOnCircle: 8 },
|
|
56
|
+
{ id: 150, isHoleClosing: false, isIntersection: false, pointOnShape: { circle: { center: [81.68410160768288, -12.970446490933696], radius: 41.07276841516263 }, curveIdx: 0, loopIdx: 0, p: [45.425023320690585, -32.264267964746104], t: 0.6306030461949899, isSource: false , order: 0, order2: 0, pDd: [[0,45.425023320690585],[0,-32.264267964746104]] }, prev: 9, next: 143, prevOnCircle: 149, nextOnCircle: 148 },
|
|
57
|
+
{ id: 143, isHoleClosing: false, isIntersection: false, pointOnShape: { circle: { center: [81.5, -12.641417453935567], radius: 41.064803841095305 }, curveIdx: 0, loopIdx: 0, p: [45.24795284642707, -31.931497590699145], t: 0.6336559854064299, isSource: false , order: 0, order2: 0, pDd: [[0,45.24795284642707],[0,-31.931497590699145]] }, prev: 150, next: 11, prevOnCircle: 142, nextOnCircle: 144 },
|
|
58
|
+
{ id: 11, isHoleClosing: false, isIntersection: false, pointOnShape: { circle: { center: [46, -5.21425847941623], radius: 13.21425847941623 }, curveIdx: 0, loopIdx: 0, p: [34.33444028251029, -11.421620530924521], t: 0.8218199951291328, isSource: false , order: 0, order2: 0, pDd: [[0,34.33444028251029],[0,-11.421620530924521]] }, prev: 143, next: 0, prevOnCircle: 10, nextOnCircle: 10 }
|
|
58
59
|
],
|
|
59
60
|
loops: [
|
|
60
61
|
{ idx: 0, beziers: [[[82, -101], [24, 8]], [[24, 8], [46, 8]], [[46, 8], [46, 54]], [[46, 54], [117, 54]], [[117, 54], [117, 8]], [[117, 8], [139, 8]], [[139, 8], [82, -101]]] }
|
package/browser/index.js
CHANGED
|
@@ -25570,7 +25570,6 @@ function getTotalHausdorffDistance(i, j, branch, hausdorffSpacing) {
|
|
|
25570
25570
|
|
|
25571
25571
|
;// ./src/mat/get-largest-vertex.ts
|
|
25572
25572
|
|
|
25573
|
-
/** @internal */
|
|
25574
25573
|
function getLargestVertex(cpNode) {
|
|
25575
25574
|
const cpNodes = getAllOnLoop(cpNode);
|
|
25576
25575
|
return cpNodes.reduce(function (maxCpNode, cpNode) {
|
|
@@ -30251,6 +30250,23 @@ function trimMat(mat) {
|
|
|
30251
30250
|
}
|
|
30252
30251
|
|
|
30253
30252
|
|
|
30253
|
+
;// ./src/mat/get-largest-3-prong.ts
|
|
30254
|
+
|
|
30255
|
+
|
|
30256
|
+
function getLargest3Prong(cpNode) {
|
|
30257
|
+
const cpNodes = getAllOnLoop(cpNode)
|
|
30258
|
+
.filter(cpNode => getRealProngCount(cpNode) >= 3);
|
|
30259
|
+
if (cpNodes.length === 0) {
|
|
30260
|
+
return undefined;
|
|
30261
|
+
}
|
|
30262
|
+
return cpNodes.reduce(function (maxCpNode, cpNode) {
|
|
30263
|
+
return maxCpNode.pointOnShape.circle.radius >= cpNode.pointOnShape.circle.radius
|
|
30264
|
+
? maxCpNode
|
|
30265
|
+
: cpNode;
|
|
30266
|
+
}, cpNodes[0]);
|
|
30267
|
+
}
|
|
30268
|
+
|
|
30269
|
+
|
|
30254
30270
|
;// ./src/debug/debug.ts
|
|
30255
30271
|
function enableDebugForMat(debugOn) {
|
|
30256
30272
|
if (!debugOn) {
|
|
@@ -30826,6 +30842,121 @@ function reconstruct_from_mat_getEdgeDirection(cpNode, fromOrTo) {
|
|
|
30826
30842
|
}
|
|
30827
30843
|
|
|
30828
30844
|
|
|
30845
|
+
;// ./src/cp-node/stringification/loop-to-stringifyable.ts
|
|
30846
|
+
function loopToStringifyable(loop) {
|
|
30847
|
+
const { idx, beziers } = loop;
|
|
30848
|
+
return { idx: idx, beziers };
|
|
30849
|
+
}
|
|
30850
|
+
|
|
30851
|
+
|
|
30852
|
+
;// ./src/cp-node/stringification/to-stringifyable.ts
|
|
30853
|
+
|
|
30854
|
+
/**
|
|
30855
|
+
* Returns a deep clone of this `CpNode`. Can be used to copy the MAT
|
|
30856
|
+
* since cloning a single `CpNode` necessarily implies cloning all
|
|
30857
|
+
* `CpNode`s on the same MAT tree.
|
|
30858
|
+
*/
|
|
30859
|
+
function toStringifyable(cpNode) {
|
|
30860
|
+
const cpNodes_ = [];
|
|
30861
|
+
const loopSet = new Set();
|
|
30862
|
+
//--------------------------------------------------------------------------
|
|
30863
|
+
// Clone `CpNode`s with edges replaced with ids AND
|
|
30864
|
+
// set the `nodeMap` to map original `CpNode`s to their ids.
|
|
30865
|
+
//--------------------------------------------------------------------------
|
|
30866
|
+
const cpStart = cpNode;
|
|
30867
|
+
do {
|
|
30868
|
+
const { id, isHoleClosing, isIntersection, pointOnShape, prev, next, nextOnCircle, prevOnCircle, holeCloserTwin, } = cpNode;
|
|
30869
|
+
const { curve, p, pDd, t, isSource, circle, order, order2 } = pointOnShape;
|
|
30870
|
+
const { idx: curveIdx, loop, ps, prev: prevCurve, next: nextCurve } = curve;
|
|
30871
|
+
if (!loopSet.has(loop)) {
|
|
30872
|
+
loopSet.add(loop);
|
|
30873
|
+
}
|
|
30874
|
+
const posSimplified = {
|
|
30875
|
+
curveIdx, loopIdx: loop.idx, p, pDd, t, isSource,
|
|
30876
|
+
circle, order, order2
|
|
30877
|
+
};
|
|
30878
|
+
cpNodes_.push({
|
|
30879
|
+
id, isHoleClosing, isIntersection,
|
|
30880
|
+
pointOnShape: posSimplified,
|
|
30881
|
+
prev: prev.id,
|
|
30882
|
+
next: next.id,
|
|
30883
|
+
prevOnCircle: prevOnCircle.id,
|
|
30884
|
+
nextOnCircle: nextOnCircle.id,
|
|
30885
|
+
holeCloserTwin: holeCloserTwin?.id
|
|
30886
|
+
});
|
|
30887
|
+
cpNode = cpNode.next;
|
|
30888
|
+
} while (cpNode !== cpStart);
|
|
30889
|
+
//--------------------------------------------------------------------------
|
|
30890
|
+
const loops = Array.from(loopSet).sort((a, b) => a.idx - b.idx);
|
|
30891
|
+
const loops_ = loops.map(loopToStringifyable);
|
|
30892
|
+
return {
|
|
30893
|
+
cpNodes: cpNodes_,
|
|
30894
|
+
loops: loops_
|
|
30895
|
+
};
|
|
30896
|
+
}
|
|
30897
|
+
|
|
30898
|
+
|
|
30899
|
+
;// ./src/cp-node/stringification/cp-node-stringifyable.ts
|
|
30900
|
+
const cp_node_stringifyable_EDGES = [
|
|
30901
|
+
'prev', 'next',
|
|
30902
|
+
'prevOnCircle', 'nextOnCircle',
|
|
30903
|
+
'holeCloserTwin'
|
|
30904
|
+
];
|
|
30905
|
+
|
|
30906
|
+
|
|
30907
|
+
;// ./src/cp-node/stringification/loop-from-stringifyable.ts
|
|
30908
|
+
|
|
30909
|
+
function loopFromStringifyable(loopStringifyable) {
|
|
30910
|
+
const { idx, beziers } = loopStringifyable;
|
|
30911
|
+
return loopFromBeziers(beziers, idx);
|
|
30912
|
+
}
|
|
30913
|
+
|
|
30914
|
+
|
|
30915
|
+
;// ./src/cp-node/stringification/from-stringifyable.ts
|
|
30916
|
+
|
|
30917
|
+
|
|
30918
|
+
function fromStringifyable(cpNodesStringifyable) {
|
|
30919
|
+
const { cpNodes: _cpNodes, loops: _loops } = cpNodesStringifyable;
|
|
30920
|
+
const loops = _loops.map(loopFromStringifyable);
|
|
30921
|
+
const loopsByIdx = new Map(loops.map(loop => [loop.idx, loop]));
|
|
30922
|
+
//--------------------------------------------------------------------------
|
|
30923
|
+
// First pass: build all CpNode objects with proper `cp`.
|
|
30924
|
+
// Edges still hold number ids at this point.
|
|
30925
|
+
//--------------------------------------------------------------------------
|
|
30926
|
+
const cpNodes = _cpNodes.map(cpNode_ => {
|
|
30927
|
+
const { id, pointOnShape, isHoleClosing, isIntersection } = cpNode_;
|
|
30928
|
+
const { circle, order, order2 } = pointOnShape;
|
|
30929
|
+
const { curveIdx, loopIdx, p, pDd, t, isSource } = pointOnShape;
|
|
30930
|
+
const curve = loopsByIdx.get(loopIdx).curves[curveIdx];
|
|
30931
|
+
const pointOnShape_ = {
|
|
30932
|
+
circle,
|
|
30933
|
+
curve, p, pDd, t, isSource,
|
|
30934
|
+
order, order2
|
|
30935
|
+
};
|
|
30936
|
+
return {
|
|
30937
|
+
...cpNode_,
|
|
30938
|
+
id, isHoleClosing, isIntersection,
|
|
30939
|
+
pointOnShape: pointOnShape_
|
|
30940
|
+
};
|
|
30941
|
+
});
|
|
30942
|
+
//--------------------------------------------------------------------------
|
|
30943
|
+
// Second pass: replace number id edges with real CpNode references.
|
|
30944
|
+
//--------------------------------------------------------------------------
|
|
30945
|
+
const nodeMap = new Map(cpNodes.map(n => [n.id, n]));
|
|
30946
|
+
for (const cpNode of cpNodes) {
|
|
30947
|
+
for (const edge of cp_node_stringifyable_EDGES) {
|
|
30948
|
+
const id = cpNode[edge];
|
|
30949
|
+
if (id === undefined) {
|
|
30950
|
+
continue;
|
|
30951
|
+
}
|
|
30952
|
+
// @ts-ignore
|
|
30953
|
+
cpNode[edge] = nodeMap.get(id);
|
|
30954
|
+
}
|
|
30955
|
+
}
|
|
30956
|
+
return cpNodes[0];
|
|
30957
|
+
}
|
|
30958
|
+
|
|
30959
|
+
|
|
30829
30960
|
;// ./src/geometry/circle.ts
|
|
30830
30961
|
/* unused harmony import specifier */ var circle_squaredDistanceBetween;
|
|
30831
30962
|
|
|
@@ -30877,6 +31008,10 @@ function engulfsCircle(c1, c2) {
|
|
|
30877
31008
|
|
|
30878
31009
|
|
|
30879
31010
|
|
|
31011
|
+
|
|
31012
|
+
|
|
31013
|
+
|
|
31014
|
+
|
|
30880
31015
|
|
|
30881
31016
|
|
|
30882
31017
|
|
|
@@ -30921,4 +31056,5 @@ function engulfsCircle(c1, c2) {
|
|
|
30921
31056
|
|
|
30922
31057
|
|
|
30923
31058
|
|
|
30924
|
-
|
|
31059
|
+
|
|
31060
|
+
export { CpNodeFs, beziersToSvgPathStr, clone, cpNodeComparator, createInitialCpTree, enableDebugForMat, enhanceCpNode, find2Prong, findAndAddHoleClosing2Prongs, findMats, floydWarshall, fromStringifyable, getAllOnCircle, getAllOnLoop, getAllOnLoop_ByLoop, getAllVertices, getBoundaryBezierPartsToNext, getBoundaryBeziersBetween, getBoundaryBeziersToNext, getBoundaryPieceBeziers, getBranch, getBranchBeziers, getBranches, getChildren, getCloseBoundaryPointsCertified, getClosestSquareDistanceToRect, getEdgeDirection, getFirstExit, getFor2ProngsOnLoop, getGraph, getHoleClosers, getImpliedBoundaryBezierBetween, getInitialDegAngleBetweenMatCurves, getLargest3Prong, getLargestVertex, getMatCurveBetween, getMatCurveToNext, getMatCurvesBetween, getNonTerminatingOnCircle, getOsculatingCircle, getPartialMeta, getPathsFromStr, getPotentialClosestPointsOnCurveCertified, getProngCount, getRealProngCount, getSalience, getSatCulls, get_shape_bounds_getShapeBounds as getShapeBounds, getSharpCornersOnLoop, getVertexForwardChildren, isFullyTerminating, isOnSameCircle, isOnSameLoop, isOneProng, isSharp, isTerminating, isTrivial, isTwoProng, isVertexSpecial, loopFromBeziers, reconstructFromMats, removeVertex, scaleCircle, simplifyMat, sweep_line_sweepLine as sweepLine, toScaleAxis, toStringifyable, traverseCp, traverseEdges, traverseVertices, trimMat };
|