flo-mat 3.0.9 → 3.0.11
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__/jsog/check-jsog-eql-calc.spec.ts +81 -0
- package/__tests__/jsog/decode-jsog.ts +85 -0
- package/__tests__/jsog/get-mats1.ts +41 -0
- package/__tests__/{cp-node/fs → jsog}/mat-dummys.ts +51 -564
- package/__tests__/jsog/to-jsog-breath-first.ts +107 -0
- package/__tests__/jsog/to-jsog-depth-first.ts +55 -0
- package/browser/index.js +280 -236
- package/browser/index.min.js +1 -1
- package/node/add-n-prong.ts/join-spokes.js.map +1 -1
- package/node/closest-boundary-point/cull-bezier-pieces.d.ts +5 -4
- package/node/closest-boundary-point/cull-bezier-pieces.js +9 -8
- package/node/closest-boundary-point/cull-bezier-pieces.js.map +1 -1
- package/node/closest-boundary-point/cull-by-loose-bounding-box.d.ts +2 -2
- package/node/closest-boundary-point/cull-by-loose-bounding-box.js +8 -8
- package/node/closest-boundary-point/cull-by-loose-bounding-box.js.map +1 -1
- package/node/closest-boundary-point/cull-by-tight-boundary-box.d.ts +2 -2
- package/node/closest-boundary-point/cull-by-tight-boundary-box.js +8 -8
- package/node/closest-boundary-point/cull-by-tight-boundary-box.js.map +1 -1
- package/node/closest-boundary-point/dd-deflate-with-running-error.js.map +1 -1
- package/node/closest-boundary-point/get-best-distance-squared.d.ts +1 -1
- package/node/closest-boundary-point/get-best-distance-squared.js +6 -6
- package/node/closest-boundary-point/get-best-distance-squared.js.map +1 -1
- package/node/closest-boundary-point/get-close-boundary-points-certified.d.ts +2 -2
- package/node/closest-boundary-point/get-close-boundary-points-certified.js +7 -7
- package/node/closest-boundary-point/get-close-boundary-points-certified.js.map +1 -1
- package/node/contact-point/contact-point.js.map +1 -1
- package/node/corner/get-corner.js.map +1 -1
- package/node/corner/get-interface-ccw.js.map +1 -1
- package/node/cp-node/cp-node-fs.d.ts +2 -1
- package/node/cp-node/cp-node-fs.js +1 -2
- package/node/cp-node/cp-node-fs.js.map +1 -1
- package/node/cp-node/fs/cp-node-comparator.d.ts +3 -0
- package/node/cp-node/fs/cp-node-comparator.js +6 -0
- package/node/cp-node/fs/cp-node-comparator.js.map +1 -0
- package/node/cp-node/fs/find-first.js.map +1 -1
- package/node/cp-node/fs/get-all-on-loop.js.map +1 -1
- package/node/cp-node/fs/get-boundary-bezier-parts-to-next.d.ts +1 -1
- package/node/cp-node/fs/get-boundary-bezier-parts-to-next.js +11 -16
- package/node/cp-node/fs/get-boundary-bezier-parts-to-next.js.map +1 -1
- package/node/cp-node/fs/get-boundary-beziers-between.js +4 -6
- package/node/cp-node/fs/get-boundary-beziers-between.js.map +1 -1
- package/node/cp-node/fs/get-boundary-beziers-to-next.d.ts +10 -1
- package/node/cp-node/fs/get-boundary-beziers-to-next.js +70 -35
- package/node/cp-node/fs/get-boundary-beziers-to-next.js.map +1 -1
- package/node/cp-node/fs/get-branch-beziers.js.map +1 -1
- package/node/cp-node/fs/get-branch.js.map +1 -1
- package/node/cp-node/fs/get-children.js.map +1 -1
- package/node/cp-node/fs/get-first-exit.js.map +1 -1
- package/node/cp-node/fs/get-mat-curve-to-next.js.map +1 -1
- package/node/cp-node/fs/get-mat-curves-between.js.map +1 -1
- package/node/cp-node/fs/get-prong-count.js.map +1 -1
- package/node/cp-node/fs/get-real-prong-count.js.map +1 -1
- package/node/cp-node/fs/get-salience.js +2 -2
- package/node/cp-node/fs/get-salience.js.map +1 -1
- package/node/cp-node/fs/get-speed.js +0 -1
- package/node/cp-node/fs/get-speed.js.map +1 -1
- package/node/cp-node/fs/get-vertex-forward-children.js.map +1 -1
- package/node/cp-node/fs/is-fully-terminating.d.ts +1 -1
- package/node/cp-node/fs/is-fully-terminating.js.map +1 -1
- package/node/cp-node/fs/is-one-prong.js.map +1 -1
- package/node/cp-node/fs/is-sharp.js.map +1 -1
- package/node/cp-node/fs/is-terminating.js.map +1 -1
- package/node/cp-node/fs/traverse-cp.js.map +1 -1
- package/node/cp-node/fs/traverse-edges.js.map +1 -1
- package/node/cp-node/fs/traverse-vertices.js.map +1 -1
- package/node/debug/functions/draw-elem/bounding-hull.js.map +1 -1
- package/node/debug/functions/draw-elem/draw-cp-node.js +1 -1
- package/node/debug/functions/draw-elem/draw-cp-node.js.map +1 -1
- package/node/debug/functions/draw-elem/draw-cull.js.map +1 -1
- package/node/debug/functions/draw-elem/draw-dull-corner.js.map +1 -1
- package/node/debug/functions/draw-elem/draw-elem.js.map +1 -1
- package/node/debug/functions/draw-elem/draw-leaves.js.map +1 -1
- package/node/debug/functions/draw-elem/draw-loose-bounding-box.js.map +1 -1
- package/node/debug/functions/draw-elem/draw-max-vertex.js.map +1 -1
- package/node/debug/functions/draw-elem/draw-min-y.js.map +1 -1
- package/node/debug/functions/draw-elem/draw-one-prong-at-dull-corner.js.map +1 -1
- package/node/debug/functions/draw-elem/draw-one-prong.js.map +1 -1
- package/node/debug/functions/draw-elem/draw-sharp-corner.js.map +1 -1
- package/node/debug/functions/draw-elem/draw-speed.js.map +1 -1
- package/node/debug/functions/draw-elem/draw-three-prong.js.map +1 -1
- package/node/debug/functions/draw-elem/draw-tight-bounding-box.js.map +1 -1
- package/node/debug/functions/draw-elem/draw-two-prong.js.map +1 -1
- package/node/debug/functions/draw-elem/draw-vertex.js.map +1 -1
- package/node/debug/functions/general.js.map +1 -1
- package/node/find-2-prong/add-1-prong.js.map +1 -1
- package/node/find-2-prong/cull-bezier-pieces.d.ts +4 -4
- package/node/find-2-prong/cull-bezier-pieces.js +9 -9
- package/node/find-2-prong/cull-bezier-pieces.js.map +1 -1
- package/node/find-2-prong/find-2-prong.js +8 -8
- package/node/find-2-prong/find-2-prong.js.map +1 -1
- package/node/find-2-prong/find-equidistant-point-on-line-dd.js.map +1 -1
- package/node/find-2-prong/get-initial-bezier-pieces.d.ts +2 -2
- package/node/find-2-prong/get-initial-bezier-pieces.js +2 -2
- package/node/find-2-prong/get-initial-bezier-pieces.js.map +1 -1
- package/node/find-2-prong/reduce-radius.d.ts +1 -1
- package/node/find-2-prong/reduce-radius.js +5 -5
- package/node/find-2-prong/reduce-radius.js.map +1 -1
- package/node/find-3-prong.ts/calc-better-x.d.ts +2 -2
- package/node/find-3-prong.ts/calc-better-x.js +3 -3
- package/node/find-3-prong.ts/calc-better-x.js.map +1 -1
- package/node/find-3-prong.ts/calc-initial-3-prong-center.d.ts +2 -2
- package/node/find-3-prong.ts/calc-initial-3-prong-center.js +3 -3
- package/node/find-3-prong.ts/calc-initial-3-prong-center.js.map +1 -1
- package/node/find-3-prong.ts/find-3-prong-for-delta3s.d.ts +2 -2
- package/node/find-3-prong.ts/find-3-prong-for-delta3s.js +16 -16
- package/node/find-3-prong.ts/find-3-prong-for-delta3s.js.map +1 -1
- package/node/find-3-prong.ts/find-3-prong.js +2 -2
- package/node/find-3-prong.ts/find-3-prong.js.map +1 -1
- package/node/find-3-prong.ts/find-and-add-3-prong.js.map +1 -1
- package/node/find-3-prong.ts/find-and-add-3-prongs.js.map +1 -1
- package/node/find-3-prong.ts/get-closest-points.d.ts +2 -2
- package/node/find-3-prong.ts/get-closest-points.js +4 -4
- package/node/find-3-prong.ts/get-closest-points.js.map +1 -1
- package/node/find-mat/find-mats.js.map +1 -1
- package/node/geometry/get-closest-square-distance-to-rect.js.map +1 -1
- package/node/geometry/get-closest-squared-distance-to-rotated-rect.js.map +1 -1
- package/node/index.d.ts +35 -1
- package/node/index.js +36 -1
- package/node/index.js.map +1 -1
- package/node/mat/create-new-cp-tree.js.map +1 -1
- package/node/mat/get-boundary-piece-beziers.js +7 -7
- package/node/mat/get-boundary-piece-beziers.js.map +1 -1
- package/node/mat/get-largest-vertex.js.map +1 -1
- package/node/mat/trim-mat.js.map +1 -1
- package/node/memoize-primitive.js.map +1 -1
- package/node/sat/add-debug-info.js.map +1 -1
- package/node/sat/cull.d.ts +7 -5
- package/node/sat/cull.js +7 -4
- package/node/sat/cull.js.map +1 -1
- package/node/sat/get-leaves.js.map +1 -1
- package/node/sat/to-scale-axis.d.ts +3 -2
- package/node/sat/to-scale-axis.js +3 -2
- package/node/sat/to-scale-axis.js.map +1 -1
- package/node/svg/get-loop-bounds.js.map +1 -1
- package/node/svg/get-min-y-pos.js.map +1 -1
- package/node/sweep-line/sweep-line.js.map +1 -1
- package/package.json +6 -6
- package/src/add-n-prong.ts/join-spokes.ts +11 -11
- package/src/closest-boundary-point/cull-bezier-pieces.ts +12 -11
- package/src/closest-boundary-point/cull-by-loose-bounding-box.ts +8 -8
- package/src/closest-boundary-point/cull-by-tight-boundary-box.ts +8 -8
- package/src/closest-boundary-point/dd-deflate-with-running-error.ts +22 -22
- package/src/closest-boundary-point/get-best-distance-squared.ts +6 -6
- package/src/closest-boundary-point/get-close-boundary-points-certified.ts +41 -41
- package/src/contact-point/contact-point.ts +13 -13
- package/src/corner/get-corner.ts +39 -39
- package/src/corner/get-interface-ccw.ts +3 -3
- package/src/cp-node/cp-node-fs.ts +132 -135
- package/src/cp-node/cp-node.ts +30 -30
- package/src/cp-node/fs/clone.ts +4 -4
- package/src/cp-node/fs/cp-node-comparator.ts +13 -0
- package/src/cp-node/fs/find-first.ts +6 -6
- package/src/cp-node/fs/get-all-on-loop.ts +1 -1
- package/src/cp-node/fs/get-boundary-bezier-parts-to-next.ts +12 -18
- package/src/cp-node/fs/get-boundary-beziers-between.ts +6 -7
- package/src/cp-node/fs/get-boundary-beziers-to-next.ts +79 -53
- package/src/cp-node/fs/get-branch-beziers.ts +1 -1
- package/src/cp-node/fs/get-branch.ts +1 -1
- package/src/cp-node/fs/get-children.ts +8 -8
- package/src/cp-node/fs/get-first-exit.ts +11 -11
- package/src/cp-node/fs/get-mat-curve-to-next.ts +1 -1
- package/src/cp-node/fs/get-mat-curves-between.ts +1 -1
- package/src/cp-node/fs/get-prong-count.ts +8 -8
- package/src/cp-node/fs/get-real-prong-count.ts +3 -3
- package/src/cp-node/fs/get-salience.ts +2 -2
- package/src/cp-node/fs/get-speed.ts +1 -6
- package/src/cp-node/fs/get-vertex-forward-children.ts +10 -10
- package/src/cp-node/fs/is-fully-terminating.ts +3 -3
- package/src/cp-node/fs/is-one-prong.ts +8 -8
- package/src/cp-node/fs/is-sharp.ts +1 -1
- package/src/cp-node/fs/is-terminating.ts +1 -1
- package/src/cp-node/fs/iterate-all-on-loop.ts +6 -6
- package/src/cp-node/fs/traverse-all-forward.ts +11 -11
- package/src/cp-node/fs/traverse-cp.ts +19 -17
- package/src/cp-node/fs/traverse-edges.ts +10 -10
- package/src/cp-node/fs/traverse-vertices.ts +17 -17
- package/src/curve/curve.ts +26 -26
- package/src/debug/functions/cmp-cp-on-delta.ts +1 -1
- package/src/debug/functions/draw-elem/bounding-hull.ts +2 -2
- package/src/debug/functions/draw-elem/culls.ts +2 -2
- package/src/debug/functions/draw-elem/draw-cp-node.ts +30 -30
- package/src/debug/functions/draw-elem/draw-cull.ts +2 -2
- package/src/debug/functions/draw-elem/draw-dull-corner.ts +7 -7
- package/src/debug/functions/draw-elem/draw-elem.ts +28 -28
- package/src/debug/functions/draw-elem/draw-leaves.ts +12 -12
- package/src/debug/functions/draw-elem/draw-loose-bounding-box.ts +7 -7
- package/src/debug/functions/draw-elem/draw-max-vertex.ts +2 -2
- package/src/debug/functions/draw-elem/draw-min-y.ts +2 -2
- package/src/debug/functions/draw-elem/draw-one-prong-at-dull-corner.ts +1 -1
- package/src/debug/functions/draw-elem/draw-one-prong.ts +1 -1
- package/src/debug/functions/draw-elem/draw-sharp-corner.ts +6 -6
- package/src/debug/functions/draw-elem/draw-speed.ts +2 -2
- package/src/debug/functions/draw-elem/draw-three-prong.ts +28 -28
- package/src/debug/functions/draw-elem/draw-tight-bounding-box.ts +4 -4
- package/src/debug/functions/draw-elem/draw-two-prong.ts +51 -51
- package/src/debug/functions/draw-elem/draw-vertex.ts +12 -12
- package/src/debug/functions/draw-elem/dull-corner.ts +7 -7
- package/src/debug/functions/draw-elem/leaves.ts +2 -2
- package/src/debug/functions/draw-elem/loose-bounding-box.ts +7 -7
- package/src/debug/functions/draw-elem/max-vertex.ts +2 -2
- package/src/debug/functions/draw-elem/min-y.ts +2 -2
- package/src/debug/functions/draw-elem/one-prong-at-dull-corner.ts +1 -1
- package/src/debug/functions/draw-elem/one-prong.ts +1 -1
- package/src/debug/functions/draw-elem/sharp-corner.ts +6 -6
- package/src/debug/functions/draw-elem/three-prong.ts +19 -19
- package/src/debug/functions/draw-elem/tight-bounding-box.ts +4 -4
- package/src/debug/functions/draw-elem/two-prong.ts +44 -44
- package/src/debug/functions/draw-elem/vertex.ts +28 -28
- package/src/debug/functions/general.ts +18 -18
- package/src/debug/functions/three-prong.ts +184 -184
- package/src/debug/functions/two-prong.ts +201 -201
- package/src/debug/two-prong-for-debugging.ts +26 -26
- package/src/find-2-prong/add-1-prong.ts +25 -25
- package/src/find-2-prong/add-debug-info.ts +38 -38
- package/src/find-2-prong/cull-bezier-pieces.ts +10 -10
- package/src/find-2-prong/find-2-prong.ts +158 -158
- package/src/find-2-prong/find-equidistant-point-on-line-dd.ts +50 -50
- package/src/find-2-prong/find-equidistant-point-on-line.ts +27 -27
- package/src/find-2-prong/get-initial-bezier-pieces.ts +2 -2
- package/src/find-2-prong/reduce-radius.ts +5 -5
- package/src/find-3-prong.ts/calc-better-x.ts +3 -3
- package/src/find-3-prong.ts/calc-initial-3-prong-center.ts +3 -3
- package/src/find-3-prong.ts/find-3-prong-for-delta3s.ts +17 -17
- package/src/find-3-prong.ts/find-3-prong.ts +23 -23
- package/src/find-3-prong.ts/find-and-add-3-prong.ts +37 -37
- package/src/find-3-prong.ts/find-and-add-3-prongs.ts +30 -30
- package/src/find-3-prong.ts/get-closest-points.ts +4 -4
- package/src/find-mat/add-2-prongs-by-error.ts +8 -8
- package/src/find-mat/find-mats.ts +49 -49
- package/src/find-mat/fix-ordering.ts +2 -2
- package/src/find-mat/get-total-by.ts +12 -12
- package/src/geometry/get-closest-square-distance-to-rect.ts +37 -37
- package/src/geometry/get-closest-squared-distance-to-rotated-rect.ts +14 -14
- package/src/get-curve/get-curve-between.ts +1 -1
- package/src/index.ts +41 -4
- package/src/mat/cmp-cp-on-delta.ts +1 -1
- package/src/mat/create-new-cp-tree.ts +12 -12
- package/src/mat/get-boundary-piece-beziers.ts +7 -7
- package/src/mat/get-edges-as-array.ts +9 -9
- package/src/mat/get-largest-3-prong.ts +8 -8
- package/src/mat/get-largest-three-prong.ts +5 -5
- package/src/mat/get-largest-vertex.ts +6 -6
- package/src/mat/get-two-prong-type.ts +9 -9
- package/src/mat/trim-mat.ts +1 -1
- package/src/memoize-primitive.ts +14 -14
- package/src/sat/add-debug-info.ts +4 -4
- package/src/sat/cull-by-salience.ts +1 -1
- package/src/sat/cull.ts +10 -7
- package/src/sat/get-leaves.ts +0 -1
- package/src/sat/to-scale-axis.ts +18 -17
- package/src/svg/get-extreme.ts +8 -8
- package/src/svg/get-loop-bounds.ts +84 -84
- package/src/svg/get-min-y-pos.ts +1 -1
- package/src/sweep-line/sweep-line.ts +23 -23
- package/src/utils/bezier-piece-to-bezier.ts +7 -7
- package/__tests__/cp-node/fs/check-jsog-eql-calc.spec.ts +0 -30
- package/node/cp-node/fs/cp-nodes-to-boundary-beziers.d.ts +0 -3
- package/node/cp-node/fs/cp-nodes-to-boundary-beziers.js +0 -6
- package/node/cp-node/fs/cp-nodes-to-boundary-beziers.js.map +0 -1
- package/src/closest-boundary-point/get-closest-boundary-point-certified.ts +0 -70
- package/src/cp-node/fs/cp-nodes-to-boundary-beziers.ts +0 -10
|
@@ -14,95 +14,95 @@ const INF = Number.POSITIVE_INFINITY;
|
|
|
14
14
|
* @internal
|
|
15
15
|
*/
|
|
16
16
|
const getLoopBounds = memoize(function(loop: Loop): {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
minX: PointOnShape;
|
|
18
|
+
minY: PointOnShape;
|
|
19
|
+
maxX: PointOnShape;
|
|
20
|
+
maxY: PointOnShape } {
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
22
|
+
const extremes: {
|
|
23
|
+
bezier: Curve,
|
|
24
|
+
t: number,
|
|
25
|
+
val: number
|
|
26
|
+
}[][] = [
|
|
27
|
+
[
|
|
28
|
+
{ bezier: undefined!, t: undefined!, val: INF},
|
|
29
|
+
{ bezier: undefined!, t: undefined!, val: INF}
|
|
30
|
+
],
|
|
31
|
+
[
|
|
32
|
+
{ bezier: undefined!, t: undefined!, val: -INF},
|
|
33
|
+
{ bezier: undefined!, t: undefined!, val: -INF}
|
|
34
|
+
]
|
|
35
|
+
];
|
|
36
|
+
|
|
37
|
+
loop.curves.forEach(function(curve: Curve): void {
|
|
38
|
+
const ps = curve.ps;
|
|
39
|
+
// const bounds = getBounds_(ps);
|
|
40
|
+
const bounds = getBounds(ps);
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
{
|
|
44
|
+
{
|
|
45
|
+
const v = bounds.box[0][0];
|
|
46
|
+
const x = extremes[0][0].val;
|
|
47
|
+
if (v < x || (v === x && bounds.ts[0][0] > extremes[0][0].t)) {
|
|
48
|
+
extremes[0][0] = {
|
|
49
|
+
bezier : curve,
|
|
50
|
+
t : bounds.ts[0][0],
|
|
51
|
+
val : v
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
55
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
56
|
+
{
|
|
57
|
+
const v = bounds.box[0][1];
|
|
58
|
+
const x = extremes[0][1].val;
|
|
59
|
+
if (v < x || (v === x && bounds.ts[0][1] > extremes[0][1].t)) {
|
|
60
|
+
extremes[0][1] = {
|
|
61
|
+
bezier : curve,
|
|
62
|
+
t : bounds.ts[0][1],
|
|
63
|
+
val : v
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
68
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
69
|
+
{
|
|
70
|
+
{
|
|
71
|
+
const v = bounds.box[1][0];
|
|
72
|
+
const x = extremes[1][0].val;
|
|
73
|
+
if (v > x || (v === x && bounds.ts[1][0] > extremes[1][0].t)) {
|
|
74
|
+
extremes[1][0] = {
|
|
75
|
+
bezier : curve,
|
|
76
|
+
t : bounds.ts[1][0],
|
|
77
|
+
val : v
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
81
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
82
|
+
{
|
|
83
|
+
const v = bounds.box[1][1];
|
|
84
|
+
const x = extremes[1][1].val;
|
|
85
|
+
if (v > x || (v === x && bounds.ts[1][1] > extremes[1][1].t)) {
|
|
86
|
+
extremes[1][1] = {
|
|
87
|
+
bezier : curve,
|
|
88
|
+
t : bounds.ts[1][1],
|
|
89
|
+
val : v
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
95
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
96
|
+
return {
|
|
97
|
+
// minX : new PointOnShape(extremes[0][0].bezier, extremes[0][0].t),
|
|
98
|
+
// minY : new PointOnShape(extremes[0][1].bezier, extremes[0][1].t),
|
|
99
|
+
// maxX : new PointOnShape(extremes[1][0].bezier, extremes[1][0].t),
|
|
100
|
+
// maxY : new PointOnShape(extremes[1][1].bezier, extremes[1][1].t)
|
|
101
|
+
minY : createPos(extremes[0][1].bezier, extremes[0][1].t, true),
|
|
102
|
+
minX : createPos(extremes[0][0].bezier, extremes[0][0].t, true),
|
|
103
|
+
maxX : createPos(extremes[1][0].bezier, extremes[1][0].t, true),
|
|
104
|
+
maxY : createPos(extremes[1][1].bezier, extremes[1][1].t, true)
|
|
105
|
+
};
|
|
106
106
|
});
|
|
107
107
|
|
|
108
108
|
|
package/src/svg/get-min-y-pos.ts
CHANGED
|
@@ -33,42 +33,42 @@ function sweepLine<T>(
|
|
|
33
33
|
|
|
34
34
|
// Initialize event queue to contain all endpoints.
|
|
35
35
|
const events: IEvent<T>[] = [];
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
for (const item of items) {
|
|
37
|
+
events.push({
|
|
38
38
|
type: EVENT_LEFT,
|
|
39
39
|
item,
|
|
40
40
|
x: getLeftmost(item)
|
|
41
41
|
});
|
|
42
|
-
|
|
42
|
+
events.push({
|
|
43
43
|
type: EVENT_RIGHT,
|
|
44
44
|
item,
|
|
45
45
|
x: getRightmost(item)
|
|
46
46
|
});
|
|
47
|
-
|
|
47
|
+
}
|
|
48
48
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
49
|
+
events.sort(compare);
|
|
50
|
+
|
|
51
|
+
const activeItems = new Set<T>();
|
|
52
52
|
|
|
53
53
|
/** A list of pairs of items that passed the predicate */
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
54
|
+
const pairedItems: [T,T][] = [];
|
|
55
|
+
for (const event of events) {
|
|
56
|
+
const { item } = event;
|
|
57
|
+
|
|
58
|
+
if (event.type === EVENT_LEFT) {
|
|
59
|
+
for (const activeItem of activeItems.values()) {
|
|
60
|
+
if (predicate(item, activeItem)) {
|
|
61
61
|
pairedItems.push([item, activeItem]);
|
|
62
|
-
|
|
63
|
-
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
64
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
65
|
+
activeItems.add(item);
|
|
66
|
+
} else if (event.type === EVENT_RIGHT) {
|
|
67
|
+
activeItems.delete(event.item);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return pairedItems;
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
/** @internal */
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { BezierPiece, fromTo } from "flo-bezier3";
|
|
1
|
+
// import { BezierPiece, fromTo } from "flo-bezier3";
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
function bezierPieceToBezier(
|
|
5
|
-
|
|
4
|
+
// function bezierPieceToBezier(
|
|
5
|
+
// piece: BezierPiece) {
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
// const { ps, ts } = piece;
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
}
|
|
9
|
+
// return fromTo(ps, ts[0], ts[1]);
|
|
10
|
+
// }
|
|
11
11
|
|
|
12
12
|
|
|
13
|
-
export { bezierPieceToBezier }
|
|
13
|
+
// export { bezierPieceToBezier }
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { expect, test } from '@jest/globals';
|
|
2
|
-
import { mats_obj1, getMats_calc1 } from './mat-dummys.js';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
test('Check MAT objects equal (JSOG)', function() {
|
|
6
|
-
const mats_calc1 = getMats_calc1();
|
|
7
|
-
|
|
8
|
-
// too hard for Jest due to circular references
|
|
9
|
-
// expect(mats_obj1).toEqual(mats_calc1);
|
|
10
|
-
|
|
11
|
-
// Fast path: check root array structure and length
|
|
12
|
-
expect(Array.isArray(mats_obj1)).toBe(true);
|
|
13
|
-
expect(Array.isArray(mats_calc1)).toBe(true);
|
|
14
|
-
expect(mats_obj1.length).toBe(mats_calc1.length);
|
|
15
|
-
|
|
16
|
-
// Verify key properties of the MAT objects instead of deep comparison
|
|
17
|
-
if (mats_obj1.length > 0) {
|
|
18
|
-
const obj = mats_obj1[0];
|
|
19
|
-
const calc = mats_calc1[0];
|
|
20
|
-
|
|
21
|
-
// Check critical structure exists
|
|
22
|
-
expect(obj).toHaveProperty('cpNode');
|
|
23
|
-
expect(calc).toHaveProperty('cpNode');
|
|
24
|
-
|
|
25
|
-
// Verify circular reference integrity
|
|
26
|
-
if (obj.cpNode && obj.cpNode.nextOnCircle) {
|
|
27
|
-
expect(obj.cpNode.nextOnCircle).toBeDefined();
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
});
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { getBoundaryBeziersToNext } from "./get-boundary-beziers-to-next.js";
|
|
2
|
-
function cpNodesToBoundaryBeziers(cpNodes) {
|
|
3
|
-
return cpNodes.flatMap(getBoundaryBeziersToNext);
|
|
4
|
-
}
|
|
5
|
-
export { cpNodesToBoundaryBeziers };
|
|
6
|
-
//# sourceMappingURL=cp-nodes-to-boundary-beziers.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cp-nodes-to-boundary-beziers.js","sourceRoot":"","sources":["../../../src/cp-node/fs/cp-nodes-to-boundary-beziers.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,wBAAwB,EAAE,MAAM,mCAAmC,CAAC;AAG7E,SAAS,wBAAwB,CAAC,OAAiB;IAC/C,OAAO,OAAO,CAAC,OAAO,CAAC,wBAAwB,CAAC,CAAA;AACpD,CAAC;AAGD,OAAO,EAAE,wBAAwB,EAAE,CAAA"}
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
// import { getObjClosestTo } from 'flo-vector2d';
|
|
2
|
-
// import { Curve } from '../curve/curve.js';
|
|
3
|
-
// import { PointOnShape } from '../point-on-shape/point-on-shape.js';
|
|
4
|
-
// import { createPos } from '../point-on-shape/create-pos.js';
|
|
5
|
-
// import { BezierPiece } from '../mat/bezier-piece.js';
|
|
6
|
-
// import { cullBezierPieces1 } from './cull-bezier-pieces.js';
|
|
7
|
-
// import { getPotentialClosestPointsOnCurveCertified } from './get-potential-closest-points-on-curve-certified.js';
|
|
8
|
-
// import { squaredDistanceBetweenDd } from '../find-2-prong/squared-distance-between-dd.js';
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
// /**
|
|
12
|
-
// * @internal
|
|
13
|
-
// * Returns the closest boundary point to the given point, limited to the given
|
|
14
|
-
// * bezier pieces, including the beziers actually checked after culling.
|
|
15
|
-
// * @param bezierPieces
|
|
16
|
-
// * @param x
|
|
17
|
-
// * @param touchedCurve
|
|
18
|
-
// * @param t
|
|
19
|
-
// * @param extreme
|
|
20
|
-
// */
|
|
21
|
-
// function getClosestBoundaryPointCertified(
|
|
22
|
-
// angle: number,
|
|
23
|
-
// bezierPieces: BezierPiece[],
|
|
24
|
-
// x: number[],
|
|
25
|
-
// touchedCurve: Curve,
|
|
26
|
-
// t: number,
|
|
27
|
-
// for1Prong: boolean) {
|
|
28
|
-
|
|
29
|
-
// bezierPieces = cullBezierPieces1(bezierPieces, x);
|
|
30
|
-
|
|
31
|
-
// let bestDistance = Number.POSITIVE_INFINITY;
|
|
32
|
-
// let pos: PointOnShape;
|
|
33
|
-
// for (let i=0; i<bezierPieces.length; i++) {
|
|
34
|
-
// const bezierPiece = bezierPieces[i];
|
|
35
|
-
|
|
36
|
-
// const ps = getPotentialClosestPointsOnCurveCertified(
|
|
37
|
-
// bezierPiece.curve,
|
|
38
|
-
// x,
|
|
39
|
-
// bezierPiece.ts,
|
|
40
|
-
// touchedCurve,
|
|
41
|
-
// t,
|
|
42
|
-
// for1Prong,
|
|
43
|
-
// angle
|
|
44
|
-
// );
|
|
45
|
-
|
|
46
|
-
// const p = getObjClosestTo(x, ps, p => p.p)
|
|
47
|
-
|
|
48
|
-
// if (p === undefined) { continue; }
|
|
49
|
-
|
|
50
|
-
// const d = squaredDistanceBetweenDd(p.p, x);
|
|
51
|
-
|
|
52
|
-
// let curve = bezierPiece.curve;
|
|
53
|
-
// let t_= p.t;
|
|
54
|
-
|
|
55
|
-
// if (d < bestDistance) {
|
|
56
|
-
// if (t_ === 0) {
|
|
57
|
-
// t_ = 1;
|
|
58
|
-
// curve = bezierPiece.curve.prev;
|
|
59
|
-
// }
|
|
60
|
-
|
|
61
|
-
// pos = createPos(curve, t_, false);
|
|
62
|
-
// bestDistance = d;
|
|
63
|
-
// }
|
|
64
|
-
// }
|
|
65
|
-
|
|
66
|
-
// return pos!;
|
|
67
|
-
// }
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
// export { getClosestBoundaryPointCertified };
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { CpNode } from "../cp-node.js";
|
|
2
|
-
import { getBoundaryBeziersToNext } from "./get-boundary-beziers-to-next.js";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
function cpNodesToBoundaryBeziers(cpNodes: CpNode[]) {
|
|
6
|
-
return cpNodes.flatMap(getBoundaryBeziersToNext)
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
export { cpNodesToBoundaryBeziers }
|