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.
Files changed (183) hide show
  1. package/__tests__/jsog/check-jsog-eql-calc.spec.ts +81 -0
  2. package/__tests__/jsog/decode-jsog.ts +85 -0
  3. package/__tests__/jsog/get-mats1.ts +41 -0
  4. package/__tests__/{cp-node/fs → jsog}/mat-dummys.ts +51 -564
  5. package/__tests__/jsog/to-jsog-breath-first.ts +107 -0
  6. package/__tests__/jsog/to-jsog-depth-first.ts +55 -0
  7. package/browser/index.js +126 -84
  8. package/browser/index.min.js +1 -1
  9. package/node/add-n-prong.ts/join-spokes.js.map +1 -1
  10. package/node/closest-boundary-point/dd-deflate-with-running-error.js.map +1 -1
  11. package/node/closest-boundary-point/get-close-boundary-points-certified.js.map +1 -1
  12. package/node/contact-point/contact-point.js.map +1 -1
  13. package/node/corner/get-corner.js.map +1 -1
  14. package/node/corner/get-interface-ccw.js.map +1 -1
  15. package/node/cp-node/cp-node-fs.d.ts +2 -1
  16. package/node/cp-node/cp-node-fs.js +1 -2
  17. package/node/cp-node/cp-node-fs.js.map +1 -1
  18. package/node/cp-node/fs/cp-node-comparator.d.ts +3 -0
  19. package/node/cp-node/fs/cp-node-comparator.js +6 -0
  20. package/node/cp-node/fs/cp-node-comparator.js.map +1 -0
  21. package/node/cp-node/fs/find-first.js.map +1 -1
  22. package/node/cp-node/fs/get-all-on-loop.js.map +1 -1
  23. package/node/cp-node/fs/get-branch-beziers.js.map +1 -1
  24. package/node/cp-node/fs/get-branch.js.map +1 -1
  25. package/node/cp-node/fs/get-children.js.map +1 -1
  26. package/node/cp-node/fs/get-first-exit.js.map +1 -1
  27. package/node/cp-node/fs/get-mat-curve-to-next.js.map +1 -1
  28. package/node/cp-node/fs/get-mat-curves-between.js.map +1 -1
  29. package/node/cp-node/fs/get-prong-count.js.map +1 -1
  30. package/node/cp-node/fs/get-real-prong-count.js.map +1 -1
  31. package/node/cp-node/fs/get-vertex-forward-children.js.map +1 -1
  32. package/node/cp-node/fs/is-fully-terminating.d.ts +1 -1
  33. package/node/cp-node/fs/is-fully-terminating.js.map +1 -1
  34. package/node/cp-node/fs/is-one-prong.js.map +1 -1
  35. package/node/cp-node/fs/is-sharp.js.map +1 -1
  36. package/node/cp-node/fs/is-terminating.js.map +1 -1
  37. package/node/cp-node/fs/traverse-cp.js.map +1 -1
  38. package/node/cp-node/fs/traverse-edges.js.map +1 -1
  39. package/node/cp-node/fs/traverse-vertices.js.map +1 -1
  40. package/node/debug/functions/draw-elem/bounding-hull.js.map +1 -1
  41. package/node/debug/functions/draw-elem/draw-cp-node.js +1 -1
  42. package/node/debug/functions/draw-elem/draw-cp-node.js.map +1 -1
  43. package/node/debug/functions/draw-elem/draw-cull.js.map +1 -1
  44. package/node/debug/functions/draw-elem/draw-dull-corner.js.map +1 -1
  45. package/node/debug/functions/draw-elem/draw-elem.js.map +1 -1
  46. package/node/debug/functions/draw-elem/draw-leaves.js.map +1 -1
  47. package/node/debug/functions/draw-elem/draw-loose-bounding-box.js.map +1 -1
  48. package/node/debug/functions/draw-elem/draw-max-vertex.js.map +1 -1
  49. package/node/debug/functions/draw-elem/draw-min-y.js.map +1 -1
  50. package/node/debug/functions/draw-elem/draw-one-prong-at-dull-corner.js.map +1 -1
  51. package/node/debug/functions/draw-elem/draw-one-prong.js.map +1 -1
  52. package/node/debug/functions/draw-elem/draw-sharp-corner.js.map +1 -1
  53. package/node/debug/functions/draw-elem/draw-speed.js.map +1 -1
  54. package/node/debug/functions/draw-elem/draw-three-prong.js.map +1 -1
  55. package/node/debug/functions/draw-elem/draw-tight-bounding-box.js.map +1 -1
  56. package/node/debug/functions/draw-elem/draw-two-prong.js.map +1 -1
  57. package/node/debug/functions/draw-elem/draw-vertex.js.map +1 -1
  58. package/node/debug/functions/general.js.map +1 -1
  59. package/node/find-2-prong/add-1-prong.js.map +1 -1
  60. package/node/find-2-prong/find-2-prong.d.ts +1 -0
  61. package/node/find-2-prong/find-2-prong.js +2 -1
  62. package/node/find-2-prong/find-2-prong.js.map +1 -1
  63. package/node/find-2-prong/find-equidistant-point-on-line-dd.js.map +1 -1
  64. package/node/find-3-prong.ts/find-3-prong.js.map +1 -1
  65. package/node/find-3-prong.ts/find-and-add-3-prong.js.map +1 -1
  66. package/node/find-3-prong.ts/find-and-add-3-prongs.js.map +1 -1
  67. package/node/find-mat/find-mats.js.map +1 -1
  68. package/node/find-mat/mat-options.js +1 -1
  69. package/node/find-mat/mat-options.js.map +1 -1
  70. package/node/geometry/get-closest-square-distance-to-rect.js.map +1 -1
  71. package/node/geometry/get-closest-squared-distance-to-rotated-rect.js.map +1 -1
  72. package/node/index.d.ts +35 -1
  73. package/node/index.js +36 -1
  74. package/node/index.js.map +1 -1
  75. package/node/mat/create-new-cp-tree.js.map +1 -1
  76. package/node/mat/get-largest-vertex.js.map +1 -1
  77. package/node/mat/trim-mat.js.map +1 -1
  78. package/node/memoize-primitive.js.map +1 -1
  79. package/node/sat/add-debug-info.js.map +1 -1
  80. package/node/sat/get-leaves.js.map +1 -1
  81. package/node/svg/get-loop-bounds.js.map +1 -1
  82. package/node/svg/get-min-y-pos.js.map +1 -1
  83. package/node/sweep-line/sweep-line.js.map +1 -1
  84. package/package.json +4 -4
  85. package/src/add-n-prong.ts/join-spokes.ts +11 -11
  86. package/src/closest-boundary-point/dd-deflate-with-running-error.ts +22 -22
  87. package/src/closest-boundary-point/get-close-boundary-points-certified.ts +38 -38
  88. package/src/contact-point/contact-point.ts +13 -13
  89. package/src/corner/get-corner.ts +39 -39
  90. package/src/corner/get-interface-ccw.ts +3 -3
  91. package/src/cp-node/cp-node-fs.ts +132 -135
  92. package/src/cp-node/cp-node.ts +30 -30
  93. package/src/cp-node/fs/clone.ts +4 -4
  94. package/src/cp-node/fs/cp-node-comparator.ts +13 -0
  95. package/src/cp-node/fs/find-first.ts +6 -6
  96. package/src/cp-node/fs/get-all-on-loop.ts +1 -1
  97. package/src/cp-node/fs/get-branch-beziers.ts +1 -1
  98. package/src/cp-node/fs/get-branch.ts +1 -1
  99. package/src/cp-node/fs/get-children.ts +8 -8
  100. package/src/cp-node/fs/get-first-exit.ts +11 -11
  101. package/src/cp-node/fs/get-mat-curve-to-next.ts +1 -1
  102. package/src/cp-node/fs/get-mat-curves-between.ts +1 -1
  103. package/src/cp-node/fs/get-prong-count.ts +8 -8
  104. package/src/cp-node/fs/get-real-prong-count.ts +3 -3
  105. package/src/cp-node/fs/get-vertex-forward-children.ts +10 -10
  106. package/src/cp-node/fs/is-fully-terminating.ts +3 -3
  107. package/src/cp-node/fs/is-one-prong.ts +8 -8
  108. package/src/cp-node/fs/is-sharp.ts +1 -1
  109. package/src/cp-node/fs/is-terminating.ts +1 -1
  110. package/src/cp-node/fs/iterate-all-on-loop.ts +6 -6
  111. package/src/cp-node/fs/traverse-all-forward.ts +11 -11
  112. package/src/cp-node/fs/traverse-cp.ts +19 -17
  113. package/src/cp-node/fs/traverse-edges.ts +10 -10
  114. package/src/cp-node/fs/traverse-vertices.ts +17 -17
  115. package/src/curve/curve.ts +26 -26
  116. package/src/debug/functions/cmp-cp-on-delta.ts +1 -1
  117. package/src/debug/functions/draw-elem/bounding-hull.ts +2 -2
  118. package/src/debug/functions/draw-elem/culls.ts +2 -2
  119. package/src/debug/functions/draw-elem/draw-cp-node.ts +30 -30
  120. package/src/debug/functions/draw-elem/draw-cull.ts +2 -2
  121. package/src/debug/functions/draw-elem/draw-dull-corner.ts +7 -7
  122. package/src/debug/functions/draw-elem/draw-elem.ts +28 -28
  123. package/src/debug/functions/draw-elem/draw-leaves.ts +12 -12
  124. package/src/debug/functions/draw-elem/draw-loose-bounding-box.ts +7 -7
  125. package/src/debug/functions/draw-elem/draw-max-vertex.ts +2 -2
  126. package/src/debug/functions/draw-elem/draw-min-y.ts +2 -2
  127. package/src/debug/functions/draw-elem/draw-one-prong-at-dull-corner.ts +1 -1
  128. package/src/debug/functions/draw-elem/draw-one-prong.ts +1 -1
  129. package/src/debug/functions/draw-elem/draw-sharp-corner.ts +6 -6
  130. package/src/debug/functions/draw-elem/draw-speed.ts +2 -2
  131. package/src/debug/functions/draw-elem/draw-three-prong.ts +28 -28
  132. package/src/debug/functions/draw-elem/draw-tight-bounding-box.ts +4 -4
  133. package/src/debug/functions/draw-elem/draw-two-prong.ts +51 -51
  134. package/src/debug/functions/draw-elem/draw-vertex.ts +12 -12
  135. package/src/debug/functions/draw-elem/dull-corner.ts +7 -7
  136. package/src/debug/functions/draw-elem/leaves.ts +2 -2
  137. package/src/debug/functions/draw-elem/loose-bounding-box.ts +7 -7
  138. package/src/debug/functions/draw-elem/max-vertex.ts +2 -2
  139. package/src/debug/functions/draw-elem/min-y.ts +2 -2
  140. package/src/debug/functions/draw-elem/one-prong-at-dull-corner.ts +1 -1
  141. package/src/debug/functions/draw-elem/one-prong.ts +1 -1
  142. package/src/debug/functions/draw-elem/sharp-corner.ts +6 -6
  143. package/src/debug/functions/draw-elem/three-prong.ts +19 -19
  144. package/src/debug/functions/draw-elem/tight-bounding-box.ts +4 -4
  145. package/src/debug/functions/draw-elem/two-prong.ts +34 -34
  146. package/src/debug/functions/draw-elem/vertex.ts +28 -28
  147. package/src/debug/functions/general.ts +18 -18
  148. package/src/debug/functions/three-prong.ts +184 -184
  149. package/src/debug/functions/two-prong.ts +112 -112
  150. package/src/find-2-prong/add-1-prong.ts +25 -25
  151. package/src/find-2-prong/find-2-prong.ts +158 -157
  152. package/src/find-2-prong/find-equidistant-point-on-line-dd.ts +50 -50
  153. package/src/find-2-prong/find-equidistant-point-on-line.ts +27 -27
  154. package/src/find-3-prong.ts/find-3-prong-for-delta3s.ts +1 -1
  155. package/src/find-3-prong.ts/find-3-prong.ts +23 -23
  156. package/src/find-3-prong.ts/find-and-add-3-prong.ts +37 -37
  157. package/src/find-3-prong.ts/find-and-add-3-prongs.ts +30 -30
  158. package/src/find-mat/add-2-prongs-by-error.ts +1 -1
  159. package/src/find-mat/find-mats.ts +49 -49
  160. package/src/find-mat/fix-ordering.ts +2 -2
  161. package/src/find-mat/get-total-by.ts +12 -12
  162. package/src/find-mat/mat-options.ts +1 -1
  163. package/src/geometry/get-closest-square-distance-to-rect.ts +37 -37
  164. package/src/geometry/get-closest-squared-distance-to-rotated-rect.ts +14 -14
  165. package/src/get-curve/get-curve-between.ts +1 -1
  166. package/src/index.ts +40 -3
  167. package/src/mat/cmp-cp-on-delta.ts +1 -1
  168. package/src/mat/create-new-cp-tree.ts +12 -12
  169. package/src/mat/get-edges-as-array.ts +9 -9
  170. package/src/mat/get-largest-3-prong.ts +8 -8
  171. package/src/mat/get-largest-three-prong.ts +5 -5
  172. package/src/mat/get-largest-vertex.ts +6 -6
  173. package/src/mat/get-two-prong-type.ts +3 -3
  174. package/src/mat/trim-mat.ts +1 -1
  175. package/src/memoize-primitive.ts +14 -14
  176. package/src/sat/add-debug-info.ts +4 -4
  177. package/src/sat/cull-by-salience.ts +1 -1
  178. package/src/sat/get-leaves.ts +0 -1
  179. package/src/svg/get-extreme.ts +8 -8
  180. package/src/svg/get-loop-bounds.ts +84 -84
  181. package/src/svg/get-min-y-pos.ts +1 -1
  182. package/src/sweep-line/sweep-line.ts +23 -23
  183. 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
- * Returns the children of this `CpNode` when seen as a MAT edge. Only
45
- * children in a 'forward' direction are returned. These include all edges
46
- * except the 'backward' edge given by `prevOnCircle`, even terminating
47
- * edges.
48
- */
49
- getChildren,
50
- /**
51
- * Similar to `getChildren` but returns the child nodes of the tree when
52
- * `CpNode` is seen as a MAT vertex point (as opposed to edge). In this
53
- * way the dual graph of the tree can easily be traversed - see e.g.
54
- * `traverseVertices`. Generally, however, traversing the edges is
55
- * preferred as it returns the entire Medial Axis (by utilizing
56
- * `getMatCurveToNext` on each returned edge).
57
- */
58
- getVertexForwardChildren,
59
- /**
60
- * Returns all `CpNode`s on the MAT that this `CpNode` is part of
61
- * starting from the current one and going anti-clockwise around the shape.
62
- */
63
- getAllOnLoop,
64
- /**
65
- * Return this (except if exclThis is truthy) and the the other CpNodes
66
- * around the maximal disk vertex circle in an anti-clockwise order.
67
- * @param exclThis If true the returned array does not include this
68
- * `CpNode`.
69
- */
70
- getAllOnCircle,
71
- /**
72
- * Returns true if the 2 given `CpNode`s are on the same maximal disk
73
- * circle.
74
- * @param cpNode1 A `CpNode`.
75
- * @param cpNode2 Another `CpNode`
76
- */
77
- isOnSameCircle,
78
- /**
79
- * Returns true if this `CpNode` is terminating, i.e. implies a leaf MAT
80
- * vertex.
81
- *
82
- * This is always the case for sharp corners and maximal disks with
83
- * a single contact point. Note, however, that even in these cases there are
84
- * two contact points stored (sitting 'on top' of each other) for the
85
- * maximal disk. It can be seen as a limiting case of a two-prong where the
86
- * distance between two of the contact points tend to zero. One point
87
- * (represented by a `CpNode` of course) will be terminating with the
88
- * other point being its `next`, whereas the other point will *not* be
89
- * terminating and 'points' back into the shape.
90
- */
91
- isTerminating,
92
- /**
93
- * Like isTerminating() but only returns true if all cpNodes on the circle
94
- * (except this.prevOnCircle) is terminating.
95
- */
96
- isFullyTerminating,
97
- /**
98
- * Returns the first `CpNode` (from this one by successively applying
99
- * .nextOnCircle) that exits the circle.
100
- */
101
- getFirstExit,
102
- /**
103
- * Returns true if this `CpNode` represents a sharp corner, i.e. the
104
- * limiting case of a two-prong having zero radius.
105
- *
106
- * Note that two `CpNode`s are stored for each sharp corner, one being
107
- * terminating and one not. See `isTerminating` for more details.
108
- */
109
- isSharp,
110
- /**
111
- * Returns true if this `CpNode`'s maximal disk has only one contact point
112
- * on the shape boundary (up to planar coordinates). These includes sharp
113
- * corners.
114
- *
115
- * Note, however, that two `CpNode`s are stored for each such point to
116
- * preserve symmetry - see `isTerminating` for more details.
117
- */
118
- isOneProng,
119
- /**
120
- * Returns the number of contact points on the maximal disk circle implied
121
- * by this `CpNode`.
122
- *
123
- * Note, however, that even one-prongs and sharp corners will return 2 (see
124
- * `isTerminating` for more details); if this is not desired use
125
- * `getRealProngCount` instead which will return 1 in these cases.
126
- */
127
- getProngCount,
128
- /**
129
- * Returns the number of contact points (up to planar coordinates) on the
130
- * maximal disk circle implied by this `CpNode`.
131
- *
132
- * See also `getProngCount`.
133
- */
134
- getRealProngCount,
135
- /**
136
- * Primarily for internal use.
137
- *
138
- * Compares the order of two `CpNode`s. The order is cyclic and depends
139
- * on a `CpNode`'s relative position along the shape boundary.
140
- */
141
- cpNodeComparator,
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
- * Returns the bezier curve from the maximal disk of the given `CpNode` to the
201
- * next `CpNode`'s maximal disk and thus directly represents a piece of the
202
- * medial axis.
203
- * @param cpNode
204
- */
205
- getMatCurveToNext,
206
- isTwoProng,
207
- getBranch,
208
- getBranchBeziers,
209
- getSalience,
210
- /**
211
- * Returns the bezier curve from the maximal disk of one `CpNode` to another
212
- * `CpNode`'s maximal disk.
213
- * @param cpNodeFrom
214
- * @param cpNodeTo
215
- */
216
- getMatCurveBetween,
217
- /**
218
- * @internal
219
- * Returns a line segment of unit length starting in the given Vertex center and
220
- * pointing in the direction of the medial axis (viewed as a rooted tree).
221
- * @param cpNode
222
- */
223
- getEdgeDirection,
224
- getBoundaryBeziersBetween,
225
- getMatCurvesBetween,
226
- getHoleClosers,
227
- getSpeed,
228
- getSmoothedSpeed$,
229
- getInitialDegAngleBetweenMatCurves,
230
- getAllVertices
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
 
@@ -50,37 +50,37 @@ import { ContactPoint } from '../contact-point/contact-point.js';
50
50
  * in opposite directions.
51
51
  */
52
52
  interface CpNode {
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;
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
- /** Only used in export */
83
- id: number;
82
+ /** Only used in export */
83
+ id: number;
84
84
  }
85
85
 
86
86
 
@@ -4,9 +4,9 @@ import { CpNode } from "../cp-node.js";
4
4
  /** @internal */
5
5
  type Edge =
6
6
  | 'prev'
7
- | 'next'
8
- | 'prevOnCircle'
9
- | 'nextOnCircle';
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);
@@ -0,0 +1,13 @@
1
+ import type { CpNode } from "../cp-node.js";
2
+ import { compareCps } from "../../contact-point/contact-point.js";
3
+
4
+
5
+ function cpNodeComparator(
6
+ a: CpNode,
7
+ b: CpNode) {
8
+
9
+ return compareCps(a.cp, b.cp);
10
+ }
11
+
12
+
13
+ export { cpNodeComparator }
@@ -10,15 +10,15 @@ function findFirst(
10
10
 
11
11
  if (f(cpStart)) { return cpStart; }
12
12
 
13
- let cpNode_ = cpNode.next;
14
- while (cpNode_ !== cpStart) {
15
- if (f(cpNode_)) {
13
+ let cpNode_ = cpNode.next;
14
+ while (cpNode_ !== cpStart) {
15
+ if (f(cpNode_)) {
16
16
  return cpNode_;
17
17
  }
18
- cpNode_ = cpNode_.next;
19
- }
18
+ cpNode_ = cpNode_.next;
19
+ }
20
20
 
21
- return undefined;
21
+ return undefined;
22
22
  }
23
23
 
24
24
 
@@ -2,7 +2,7 @@ import type { CpNode } from "../cp-node.js";
2
2
 
3
3
 
4
4
  function getAllOnLoop(
5
- cpNode: CpNode) {
5
+ cpNode: CpNode) {
6
6
 
7
7
  const cpStart = cpNode;
8
8
  const cpNodes: CpNode[] = [cpStart];
@@ -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
- cpNode: CpNode): number[][][] {
12
+ cpNode: CpNode): number[][][] {
13
13
 
14
14
  return getBranch(cpNode).map(b => getMatCurveToNext(b));
15
15
  }
@@ -13,7 +13,7 @@ import { isTrivial } from './is-trivial.js';
13
13
  * @param cpNode `CpNode` representing the start vertex.
14
14
  */
15
15
  function getBranch(
16
- cpNode: CpNode): CpNode[] {
16
+ cpNode: CpNode): CpNode[] {
17
17
 
18
18
  if (isTrivial(cpNode)) {
19
19
  return [];
@@ -2,16 +2,16 @@ import { CpNode } from "../cp-node.js";
2
2
 
3
3
 
4
4
  function getChildren(cpNode: CpNode) {
5
- const children: CpNode[] = [];
5
+ const children: CpNode[] = [];
6
6
 
7
- const cp = cpNode.next;
8
- let cpNode_ = cp;
9
- do {
10
- children.push(cpNode_);
11
- cpNode_ = cpNode_.nextOnCircle;
12
- } while (cpNode_.nextOnCircle !== cp);
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
- return children;
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
- // const startNode = this as CpNode;
6
- const startNode = cpNode;
7
- let cpNode_ = startNode;
5
+ // const startNode = this as CpNode;
6
+ const startNode = cpNode;
7
+ let cpNode_ = startNode;
8
8
 
9
- while (cpNode_.next === cpNode_.prevOnCircle) {
10
- cpNode_ = cpNode_.next;
9
+ while (cpNode_.next === cpNode_.prevOnCircle) {
10
+ cpNode_ = cpNode_.next;
11
11
 
12
- if (cpNode_ === startNode) {
13
- // The very special case the MAT is a single point.
14
- return undefined;
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
- return cpNode_;
18
+ return cpNode_;
19
19
  }
20
20
 
21
21
 
@@ -4,7 +4,7 @@ import { getMatCurveBetween } from './get-mat-curve-between.js';
4
4
 
5
5
 
6
6
  function getMatCurveToNext(cpNode: CpNode) {
7
- return getMatCurveBetween(cpNode, cpNode.next);
7
+ return getMatCurveBetween(cpNode, cpNode.next);
8
8
  }
9
9
 
10
10
 
@@ -9,7 +9,7 @@ function getMatCurvesBetween(
9
9
  let cpNode = cpNodeS;
10
10
  const pss: number[][][] = [];
11
11
  while (cpNode !== cpNodeE) {
12
- const ps = getMatCurveBetween(cpNode, cpNode.next);
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
- const startCpNode = cpNode;
6
- let cpNode_ = startCpNode;
5
+ const startCpNode = cpNode;
6
+ let cpNode_ = startCpNode;
7
7
 
8
- let i = 0;
9
- do {
10
- i++;
11
- cpNode_ = cpNode_.nextOnCircle;
12
- } while (cpNode_ !== startCpNode)
8
+ let i = 0;
9
+ do {
10
+ i++;
11
+ cpNode_ = cpNode_.nextOnCircle;
12
+ } while (cpNode_ !== startCpNode)
13
13
 
14
- return i;
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
- const nonTerminatingCpNodes = getAllOnCircle(cpNode)
8
- .filter(cpNode => !isTerminating(cpNode));
7
+ const nonTerminatingCpNodes = getAllOnCircle(cpNode)
8
+ .filter(cpNode => !isTerminating(cpNode));
9
9
 
10
- return nonTerminatingCpNodes.length;
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
- const children: CpNode[] = [];
6
+ const children: CpNode[] = [];
7
7
 
8
- const cpStart = cpNode;
8
+ const cpStart = cpNode;
9
9
 
10
- let cpNode_ = cpStart;
11
- while (cpNode_ !== cpStart.prevOnCircle) {
12
- if (!isTerminating(cpNode_)) {
13
- children.push(cpNode_.next);
14
- }
15
- cpNode_ = cpNode_.nextOnCircle;
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
- return children;
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
- const otherOnCircle = getAllOnCircle(cpNode.prevOnCircle, true);
14
+ const otherOnCircle = getAllOnCircle(cpNode.prevOnCircle, true);
15
15
 
16
- return otherOnCircle.every(isTerminating);
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
- const cp1 = cpNode;
6
+ const cp1 = cpNode;
7
7
 
8
- if (cp1.cp.circle.radius === 0) {
9
- return true;
10
- }
8
+ if (cp1.cp.circle.radius === 0) {
9
+ return true;
10
+ }
11
11
 
12
- const cp2 = cp1.nextOnCircle;
12
+ const cp2 = cp1.nextOnCircle;
13
13
 
14
- const p1 = cp1.cp.pointOnShape.p;
15
- const p2 = cp2.cp.pointOnShape.p;
14
+ const p1 = cp1.cp.pointOnShape.p;
15
+ const p2 = cp2.cp.pointOnShape.p;
16
16
 
17
- return (p1[0] === p2[0] && p1[1] === p2[1]);
17
+ return (p1[0] === p2[0] && p1[1] === p2[1]);
18
18
  }
19
19
 
20
20
 
@@ -2,7 +2,7 @@ import { CpNode } from "../cp-node.js";
2
2
 
3
3
 
4
4
  function isSharp(cpNode: CpNode) {
5
- return cpNode.cp.circle.radius === 0;
5
+ return cpNode.cp.circle.radius === 0;
6
6
  }
7
7
 
8
8