flo-mat 3.0.10 → 3.0.12
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 +126 -84
- package/browser/index.min.js +1 -1
- package/node/add-n-prong.ts/join-spokes.js.map +1 -1
- package/node/closest-boundary-point/dd-deflate-with-running-error.js.map +1 -1
- 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-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-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/find-2-prong.d.ts +1 -0
- package/node/find-2-prong/find-2-prong.js +2 -1
- 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-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-mat/find-mats.js.map +1 -1
- package/node/find-mat/mat-options.js +1 -1
- package/node/find-mat/mat-options.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-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/get-leaves.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 +4 -4
- package/src/add-n-prong.ts/join-spokes.ts +11 -11
- package/src/closest-boundary-point/dd-deflate-with-running-error.ts +22 -22
- package/src/closest-boundary-point/get-close-boundary-points-certified.ts +38 -38
- 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-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-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 +34 -34
- 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 +112 -112
- package/src/find-2-prong/add-1-prong.ts +25 -25
- package/src/find-2-prong/find-2-prong.ts +158 -157
- 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-3-prong.ts/find-3-prong-for-delta3s.ts +1 -1
- 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-mat/add-2-prongs-by-error.ts +1 -1
- 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/find-mat/mat-options.ts +1 -1
- 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 +40 -3
- package/src/mat/cmp-cp-on-delta.ts +1 -1
- package/src/mat/create-new-cp-tree.ts +12 -12
- 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 +3 -3
- 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/get-leaves.ts +0 -1
- 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/__tests__/cp-node/fs/check-jsog-eql-calc.spec.ts +0 -30
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { compareCps } from "../contact-point/contact-point.js";
|
|
2
1
|
import { CpNode } from "./cp-node.js";
|
|
3
2
|
import { getHoleClosers } from "./fs/get-hole-closers.js";
|
|
4
3
|
import { getSpeed } from "./fs/get-speed.js";
|
|
@@ -34,111 +33,109 @@ import { getBoundaryBeziersBetween } from './fs/get-boundary-beziers-between.js'
|
|
|
34
33
|
import { getMatCurvesBetween } from './fs/get-mat-curves-between.js';
|
|
35
34
|
import { getInitialDegAngleBetweenMatCurves } from "./fs/get-angle-between-mat-curves.js";
|
|
36
35
|
import { getAllVertices } from "./fs/get-all-vertices.js";
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
const cpNodeComparator = (a: CpNode, b: CpNode) => compareCps(a.cp, b.cp);
|
|
36
|
+
import { cpNodeComparator } from './fs/cp-node-comparator.js';
|
|
40
37
|
|
|
41
38
|
|
|
42
39
|
const CpNodeFs = {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
40
|
+
/**
|
|
41
|
+
* Returns the children of this `CpNode` when seen as a MAT edge. Only
|
|
42
|
+
* children in a 'forward' direction are returned. These include all edges
|
|
43
|
+
* except the 'backward' edge given by `prevOnCircle`, even terminating
|
|
44
|
+
* edges.
|
|
45
|
+
*/
|
|
46
|
+
getChildren,
|
|
47
|
+
/**
|
|
48
|
+
* Similar to `getChildren` but returns the child nodes of the tree when
|
|
49
|
+
* `CpNode` is seen as a MAT vertex point (as opposed to edge). In this
|
|
50
|
+
* way the dual graph of the tree can easily be traversed - see e.g.
|
|
51
|
+
* `traverseVertices`. Generally, however, traversing the edges is
|
|
52
|
+
* preferred as it returns the entire Medial Axis (by utilizing
|
|
53
|
+
* `getMatCurveToNext` on each returned edge).
|
|
54
|
+
*/
|
|
55
|
+
getVertexForwardChildren,
|
|
56
|
+
/**
|
|
57
|
+
* Returns all `CpNode`s on the MAT that this `CpNode` is part of
|
|
58
|
+
* starting from the current one and going anti-clockwise around the shape.
|
|
59
|
+
*/
|
|
60
|
+
getAllOnLoop,
|
|
61
|
+
/**
|
|
62
|
+
* Return this (except if exclThis is truthy) and the the other CpNodes
|
|
63
|
+
* around the maximal disk vertex circle in an anti-clockwise order.
|
|
64
|
+
* @param exclThis If true the returned array does not include this
|
|
65
|
+
* `CpNode`.
|
|
66
|
+
*/
|
|
67
|
+
getAllOnCircle,
|
|
68
|
+
/**
|
|
69
|
+
* Returns true if the 2 given `CpNode`s are on the same maximal disk
|
|
70
|
+
* circle.
|
|
71
|
+
* @param cpNode1 A `CpNode`.
|
|
72
|
+
* @param cpNode2 Another `CpNode`
|
|
73
|
+
*/
|
|
74
|
+
isOnSameCircle,
|
|
75
|
+
/**
|
|
76
|
+
* Returns true if this `CpNode` is terminating, i.e. implies a leaf MAT
|
|
77
|
+
* vertex.
|
|
78
|
+
*
|
|
79
|
+
* This is always the case for sharp corners and maximal disks with
|
|
80
|
+
* a single contact point. Note, however, that even in these cases there are
|
|
81
|
+
* two contact points stored (sitting 'on top' of each other) for the
|
|
82
|
+
* maximal disk. It can be seen as a limiting case of a two-prong where the
|
|
83
|
+
* distance between two of the contact points tend to zero. One point
|
|
84
|
+
* (represented by a `CpNode` of course) will be terminating with the
|
|
85
|
+
* other point being its `next`, whereas the other point will *not* be
|
|
86
|
+
* terminating and 'points' back into the shape.
|
|
87
|
+
*/
|
|
88
|
+
isTerminating,
|
|
89
|
+
/**
|
|
90
|
+
* Like isTerminating() but only returns true if all cpNodes on the circle
|
|
91
|
+
* (except this.prevOnCircle) is terminating.
|
|
92
|
+
*/
|
|
93
|
+
isFullyTerminating,
|
|
94
|
+
/**
|
|
95
|
+
* Returns the first `CpNode` (from this one by successively applying
|
|
96
|
+
* .nextOnCircle) that exits the circle.
|
|
97
|
+
*/
|
|
98
|
+
getFirstExit,
|
|
99
|
+
/**
|
|
100
|
+
* Returns true if this `CpNode` represents a sharp corner, i.e. the
|
|
101
|
+
* limiting case of a two-prong having zero radius.
|
|
102
|
+
*
|
|
103
|
+
* Note that two `CpNode`s are stored for each sharp corner, one being
|
|
104
|
+
* terminating and one not. See `isTerminating` for more details.
|
|
105
|
+
*/
|
|
106
|
+
isSharp,
|
|
107
|
+
/**
|
|
108
|
+
* Returns true if this `CpNode`'s maximal disk has only one contact point
|
|
109
|
+
* on the shape boundary (up to planar coordinates). These includes sharp
|
|
110
|
+
* corners.
|
|
111
|
+
*
|
|
112
|
+
* Note, however, that two `CpNode`s are stored for each such point to
|
|
113
|
+
* preserve symmetry - see `isTerminating` for more details.
|
|
114
|
+
*/
|
|
115
|
+
isOneProng,
|
|
116
|
+
/**
|
|
117
|
+
* Returns the number of contact points on the maximal disk circle implied
|
|
118
|
+
* by this `CpNode`.
|
|
119
|
+
*
|
|
120
|
+
* Note, however, that even one-prongs and sharp corners will return 2 (see
|
|
121
|
+
* `isTerminating` for more details); if this is not desired use
|
|
122
|
+
* `getRealProngCount` instead which will return 1 in these cases.
|
|
123
|
+
*/
|
|
124
|
+
getProngCount,
|
|
125
|
+
/**
|
|
126
|
+
* Returns the number of contact points (up to planar coordinates) on the
|
|
127
|
+
* maximal disk circle implied by this `CpNode`.
|
|
128
|
+
*
|
|
129
|
+
* See also `getProngCount`.
|
|
130
|
+
*/
|
|
131
|
+
getRealProngCount,
|
|
132
|
+
/**
|
|
133
|
+
* Primarily for internal use.
|
|
134
|
+
*
|
|
135
|
+
* Compares the order of two `CpNode`s. The order is cyclic and depends
|
|
136
|
+
* on a `CpNode`'s relative position along the shape boundary.
|
|
137
|
+
*/
|
|
138
|
+
cpNodeComparator,
|
|
142
139
|
/**
|
|
143
140
|
* For debugging
|
|
144
141
|
* @param cpNode
|
|
@@ -196,38 +193,38 @@ const CpNodeFs = {
|
|
|
196
193
|
* @param cpNode The `CpNode` to remove.
|
|
197
194
|
*/
|
|
198
195
|
removeVertex,
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
196
|
+
/**
|
|
197
|
+
* Returns the bezier curve from the maximal disk of the given `CpNode` to the
|
|
198
|
+
* next `CpNode`'s maximal disk and thus directly represents a piece of the
|
|
199
|
+
* medial axis.
|
|
200
|
+
* @param cpNode
|
|
201
|
+
*/
|
|
202
|
+
getMatCurveToNext,
|
|
203
|
+
isTwoProng,
|
|
204
|
+
getBranch,
|
|
205
|
+
getBranchBeziers,
|
|
206
|
+
getSalience,
|
|
207
|
+
/**
|
|
208
|
+
* Returns the bezier curve from the maximal disk of one `CpNode` to another
|
|
209
|
+
* `CpNode`'s maximal disk.
|
|
210
|
+
* @param cpNodeFrom
|
|
211
|
+
* @param cpNodeTo
|
|
212
|
+
*/
|
|
213
|
+
getMatCurveBetween,
|
|
214
|
+
/**
|
|
215
|
+
* @internal
|
|
216
|
+
* Returns a line segment of unit length starting in the given Vertex center and
|
|
217
|
+
* pointing in the direction of the medial axis (viewed as a rooted tree).
|
|
218
|
+
* @param cpNode
|
|
219
|
+
*/
|
|
220
|
+
getEdgeDirection,
|
|
221
|
+
getBoundaryBeziersBetween,
|
|
222
|
+
getMatCurvesBetween,
|
|
223
|
+
getHoleClosers,
|
|
224
|
+
getSpeed,
|
|
225
|
+
getSmoothedSpeed$,
|
|
226
|
+
getInitialDegAngleBetweenMatCurves,
|
|
227
|
+
getAllVertices
|
|
231
228
|
}
|
|
232
229
|
|
|
233
230
|
|
package/src/cp-node/cp-node.ts
CHANGED
|
@@ -50,37 +50,37 @@ import { ContactPoint } from '../contact-point/contact-point.js';
|
|
|
50
50
|
* in opposite directions.
|
|
51
51
|
*/
|
|
52
52
|
interface CpNode {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
53
|
+
/** The shape boundary contact point, i.e. a `CpNode` without its edges. */
|
|
54
|
+
cp: ContactPoint;
|
|
55
|
+
/** If true, this `CpNode` belongs to a hole-closing maximal disk. */
|
|
56
|
+
isHoleClosing: boolean;
|
|
57
|
+
/** true if this cpNode is at a shape boundary intersection point, false otherwise */
|
|
58
|
+
isIntersection: boolean;
|
|
59
|
+
/** The previous (going clockwise around the boundary) contact point (`CpNode`).*/
|
|
60
|
+
prev: CpNode;
|
|
61
|
+
/** The next (going anti-clockwise around the boundary) contact point (`CpNode`). */
|
|
62
|
+
next: CpNode;
|
|
63
|
+
/**
|
|
64
|
+
* The previous `CpNode` (going clockwise around the inscribed circle
|
|
65
|
+
* defined by the maximal disk).
|
|
66
|
+
*/
|
|
67
|
+
prevOnCircle: CpNode;
|
|
68
|
+
/**
|
|
69
|
+
* The next `CpNode` (going anti-clockwise around
|
|
70
|
+
* the inscribed circle defined by the maximal disk).
|
|
71
|
+
*/
|
|
72
|
+
nextOnCircle: CpNode;
|
|
73
|
+
/**
|
|
74
|
+
* For hole closers only - the next `CpNode` ignoring the hole closer
|
|
75
|
+
*/
|
|
76
|
+
holeCloserNext?: CpNode | undefined;
|
|
77
|
+
/**
|
|
78
|
+
* For hole closers only - the prev `CpNode` ignoring the hole closer
|
|
79
|
+
*/
|
|
80
|
+
holeCloserPrev?: CpNode | undefined;
|
|
81
81
|
|
|
82
|
-
|
|
83
|
-
|
|
82
|
+
/** Only used in export */
|
|
83
|
+
id: number;
|
|
84
84
|
}
|
|
85
85
|
|
|
86
86
|
|
package/src/cp-node/fs/clone.ts
CHANGED
|
@@ -4,9 +4,9 @@ import { CpNode } from "../cp-node.js";
|
|
|
4
4
|
/** @internal */
|
|
5
5
|
type Edge =
|
|
6
6
|
| 'prev'
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
| 'next'
|
|
8
|
+
| 'prevOnCircle'
|
|
9
|
+
| 'nextOnCircle';
|
|
10
10
|
|
|
11
11
|
/** @internal */
|
|
12
12
|
const EDGES: Edge[] = ['prev', 'next', 'prevOnCircle', 'nextOnCircle'];
|
|
@@ -38,7 +38,7 @@ function clone(cpNode: CpNode): CpNode {
|
|
|
38
38
|
for (const edge of EDGES) {
|
|
39
39
|
const node = cpNode[edge];
|
|
40
40
|
let newNode = nodeMap.get(node);
|
|
41
|
-
if (!newNode) {
|
|
41
|
+
if (!newNode) {
|
|
42
42
|
newNode = cloneWithoutLinks(node);
|
|
43
43
|
|
|
44
44
|
nodeMap.set(node, newNode);
|
|
@@ -10,15 +10,15 @@ function findFirst(
|
|
|
10
10
|
|
|
11
11
|
if (f(cpStart)) { return cpStart; }
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
let cpNode_ = cpNode.next;
|
|
14
|
+
while (cpNode_ !== cpStart) {
|
|
15
|
+
if (f(cpNode_)) {
|
|
16
16
|
return cpNode_;
|
|
17
17
|
}
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
cpNode_ = cpNode_.next;
|
|
19
|
+
}
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
return undefined;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
|
|
@@ -9,7 +9,7 @@ import { getMatCurveToNext } from './get-mat-curve-to-next.js';
|
|
|
9
9
|
* @param cpNode `CpNode` representing the start vertex.
|
|
10
10
|
*/
|
|
11
11
|
function getBranchBeziers(
|
|
12
|
-
|
|
12
|
+
cpNode: CpNode): number[][][] {
|
|
13
13
|
|
|
14
14
|
return getBranch(cpNode).map(b => getMatCurveToNext(b));
|
|
15
15
|
}
|
|
@@ -2,16 +2,16 @@ import { CpNode } from "../cp-node.js";
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
function getChildren(cpNode: CpNode) {
|
|
5
|
-
|
|
5
|
+
const children: CpNode[] = [];
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
const cp = cpNode.next;
|
|
8
|
+
let cpNode_ = cp;
|
|
9
|
+
do {
|
|
10
|
+
children.push(cpNode_);
|
|
11
|
+
cpNode_ = cpNode_.nextOnCircle;
|
|
12
|
+
} while (cpNode_.nextOnCircle !== cp);
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
return children;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
|
|
@@ -2,20 +2,20 @@ import { CpNode } from "../cp-node.js";
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
function getFirstExit(cpNode: CpNode) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
// const startNode = this as CpNode;
|
|
6
|
+
const startNode = cpNode;
|
|
7
|
+
let cpNode_ = startNode;
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
while (cpNode_.next === cpNode_.prevOnCircle) {
|
|
10
|
+
cpNode_ = cpNode_.next;
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
if (cpNode_ === startNode) {
|
|
13
|
+
// The very special case the MAT is a single point.
|
|
14
|
+
return undefined;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
return cpNode_;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
|
|
@@ -9,7 +9,7 @@ function getMatCurvesBetween(
|
|
|
9
9
|
let cpNode = cpNodeS;
|
|
10
10
|
const pss: number[][][] = [];
|
|
11
11
|
while (cpNode !== cpNodeE) {
|
|
12
|
-
|
|
12
|
+
const ps = getMatCurveBetween(cpNode, cpNode.next);
|
|
13
13
|
pss.push(ps);
|
|
14
14
|
|
|
15
15
|
cpNode = cpNode.next;
|
|
@@ -2,16 +2,16 @@ import { CpNode } from "../cp-node.js";
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
function getProngCount(cpNode: CpNode) {
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
const startCpNode = cpNode;
|
|
6
|
+
let cpNode_ = startCpNode;
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
let i = 0;
|
|
9
|
+
do {
|
|
10
|
+
i++;
|
|
11
|
+
cpNode_ = cpNode_.nextOnCircle;
|
|
12
|
+
} while (cpNode_ !== startCpNode)
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
return i;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
|
|
@@ -4,10 +4,10 @@ import { isTerminating } from "./is-terminating.js";
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
function getRealProngCount(cpNode: CpNode) {
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
const nonTerminatingCpNodes = getAllOnCircle(cpNode)
|
|
8
|
+
.filter(cpNode => !isTerminating(cpNode));
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
return nonTerminatingCpNodes.length;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
|
|
@@ -3,19 +3,19 @@ import { isTerminating } from "./is-terminating.js";
|
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
function getVertexForwardChildren(cpNode: CpNode) {
|
|
6
|
-
|
|
6
|
+
const children: CpNode[] = [];
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
const cpStart = cpNode;
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
10
|
+
let cpNode_ = cpStart;
|
|
11
|
+
while (cpNode_ !== cpStart.prevOnCircle) {
|
|
12
|
+
if (!isTerminating(cpNode_)) {
|
|
13
|
+
children.push(cpNode_.next);
|
|
14
|
+
}
|
|
15
|
+
cpNode_ = cpNode_.nextOnCircle;
|
|
16
|
+
}
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
return children;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CpNode } from "../cp-node.js";
|
|
1
|
+
import type { CpNode } from "../cp-node.js";
|
|
2
2
|
import { getAllOnCircle } from "./get-all-on-circle.js";
|
|
3
3
|
import { isTerminating } from "./is-terminating.js";
|
|
4
4
|
|
|
@@ -11,9 +11,9 @@ import { isTerminating } from "./is-terminating.js";
|
|
|
11
11
|
* @param cpNode
|
|
12
12
|
*/
|
|
13
13
|
function isFullyTerminating(cpNode: CpNode) {
|
|
14
|
-
|
|
14
|
+
const otherOnCircle = getAllOnCircle(cpNode.prevOnCircle, true);
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
return otherOnCircle.every(isTerminating);
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
|
|
@@ -3,18 +3,18 @@ import { CpNode } from "../cp-node.js";
|
|
|
3
3
|
|
|
4
4
|
// TODO2 - remove - or replace with `getRealProngCount === 1`
|
|
5
5
|
function isOneProng(cpNode: CpNode) {
|
|
6
|
-
|
|
6
|
+
const cp1 = cpNode;
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
if (cp1.cp.circle.radius === 0) {
|
|
9
|
+
return true;
|
|
10
|
+
}
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
const cp2 = cp1.nextOnCircle;
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
const p1 = cp1.cp.pointOnShape.p;
|
|
15
|
+
const p2 = cp2.cp.pointOnShape.p;
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
return (p1[0] === p2[0] && p1[1] === p2[1]);
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
|