flo-mat 3.0.6 → 3.0.7

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 (185) hide show
  1. package/__tests__/cp-node/fs/add-distance-from.spec.ts +7 -0
  2. package/__tests__/cp-node/fs/check-jsog-eql-calc.spec.ts +30 -0
  3. package/__tests__/cp-node/fs/clone.spec.ts +7 -0
  4. package/__tests__/cp-node/fs/cp-nodes-to-boundary-beziers.spec.ts +7 -0
  5. package/__tests__/cp-node/fs/create-cp-node.spec.ts +7 -0
  6. package/__tests__/cp-node/fs/enhance-cp-node.spec.ts +7 -0
  7. package/__tests__/cp-node/fs/find-first.spec.ts +7 -0
  8. package/__tests__/cp-node/fs/get-all-between.spec.ts +7 -0
  9. package/__tests__/cp-node/fs/get-all-on-circle.spec.ts +92 -0
  10. package/__tests__/cp-node/fs/get-all-on-loop.spec.ts +7 -0
  11. package/__tests__/cp-node/fs/get-all-vertices.spec.ts +7 -0
  12. package/__tests__/cp-node/fs/get-angle-between-mat-curves.spec.ts +7 -0
  13. package/__tests__/cp-node/fs/get-avg-speed.spec.ts +7 -0
  14. package/__tests__/cp-node/fs/get-boundary-bezier-parts-to-next.spec.ts +7 -0
  15. package/__tests__/cp-node/fs/get-boundary-beziers-between.spec.ts +7 -0
  16. package/__tests__/cp-node/fs/get-boundary-beziers-to-next.spec.ts +7 -0
  17. package/__tests__/cp-node/fs/get-boundary-distance-to-next.spec.ts +7 -0
  18. package/__tests__/cp-node/fs/get-branch-beziers.spec.ts +7 -0
  19. package/__tests__/cp-node/fs/get-branch.spec.ts +7 -0
  20. package/__tests__/cp-node/fs/get-children.spec.ts +7 -0
  21. package/__tests__/cp-node/fs/get-cp-node-ordering.spec.ts +7 -0
  22. package/__tests__/cp-node/fs/get-distance-between.spec.ts +7 -0
  23. package/__tests__/cp-node/fs/get-distance-to-next.spec.ts +7 -0
  24. package/__tests__/cp-node/fs/get-edge-direction.spec.ts +7 -0
  25. package/__tests__/cp-node/fs/get-first-exit.spec.ts +7 -0
  26. package/__tests__/cp-node/fs/get-hole-closers.spec.ts +7 -0
  27. package/__tests__/cp-node/fs/get-implied-boundary-bezier-between.spec.ts +7 -0
  28. package/__tests__/cp-node/fs/get-mat-curve-between.spec.ts +7 -0
  29. package/__tests__/cp-node/fs/get-mat-curve-to-next.spec.ts +7 -0
  30. package/__tests__/cp-node/fs/get-mat-curves-between.spec.ts +7 -0
  31. package/__tests__/cp-node/fs/get-non-terminating-on-circle.spec.ts +7 -0
  32. package/__tests__/cp-node/fs/get-prong-count.spec.ts +7 -0
  33. package/__tests__/cp-node/fs/get-real-prong-count.spec.ts +7 -0
  34. package/__tests__/cp-node/fs/get-salience.spec.ts +7 -0
  35. package/__tests__/cp-node/fs/get-smoothed-speed.spec.ts +7 -0
  36. package/__tests__/cp-node/fs/get-smoothed.spec.ts +7 -0
  37. package/__tests__/cp-node/fs/get-speed.spec.ts +7 -0
  38. package/__tests__/cp-node/fs/get-terminating-on-circle.spec.ts +7 -0
  39. package/__tests__/cp-node/fs/get-vertex-forward-children.spec.ts +7 -0
  40. package/__tests__/cp-node/fs/insert-cp-node.spec.ts +7 -0
  41. package/__tests__/cp-node/fs/is-fully-terminating.spec.ts +7 -0
  42. package/__tests__/cp-node/fs/is-on-same-circle.spec.ts +7 -0
  43. package/__tests__/cp-node/fs/is-one-prong.spec.ts +7 -0
  44. package/__tests__/cp-node/fs/is-order-correct.spec.ts +7 -0
  45. package/__tests__/cp-node/fs/is-sharp.spec.ts +7 -0
  46. package/__tests__/cp-node/fs/is-single-3-prong.spec.ts +7 -0
  47. package/__tests__/cp-node/fs/is-special.spec.ts +7 -0
  48. package/__tests__/cp-node/fs/is-terminating.spec.ts +7 -0
  49. package/__tests__/cp-node/fs/is-trivial.spec.ts +7 -0
  50. package/__tests__/cp-node/fs/is-two-prong.spec.ts +7 -0
  51. package/__tests__/cp-node/fs/is-vertex-special.spec.ts +7 -0
  52. package/__tests__/cp-node/fs/is-vertex.spec.ts +7 -0
  53. package/__tests__/cp-node/fs/iterate-all-on-loop.spec.ts +7 -0
  54. package/__tests__/cp-node/fs/mat-dummys.ts +6716 -0
  55. package/__tests__/cp-node/fs/remove-cp-node.spec.ts +7 -0
  56. package/__tests__/cp-node/fs/traverse-all-forward.spec.ts +7 -0
  57. package/__tests__/cp-node/fs/traverse-cp.spec.ts +7 -0
  58. package/__tests__/cp-node/fs/traverse-edges.spec.ts +7 -0
  59. package/__tests__/cp-node/fs/traverse-vertices.spec.ts +7 -0
  60. package/__tests__/lib-load.spec.ts +9 -10
  61. package/browser/index.js +239 -158
  62. package/browser/index.min.js +1 -1
  63. package/jest.config.cjs +32 -0
  64. package/node/corner/get-interface-ccw.js +0 -1
  65. package/node/corner/get-interface-ccw.js.map +1 -1
  66. package/node/cp-node/cp-node-fs.d.ts +32 -32
  67. package/node/cp-node/cp-node-fs.js +32 -32
  68. package/node/cp-node/cp-node.d.ts +13 -21
  69. package/node/cp-node/fs/clone.d.ts +3 -3
  70. package/node/cp-node/fs/clone.js +3 -3
  71. package/node/cp-node/fs/enhance-cp-node.d.ts +1 -5
  72. package/node/cp-node/fs/enhance-cp-node.js.map +1 -1
  73. package/node/cp-node/fs/get-all-between.d.ts +3 -3
  74. package/node/cp-node/fs/get-all-between.js +3 -3
  75. package/node/cp-node/fs/get-all-between.js.map +1 -1
  76. package/node/cp-node/fs/get-all-on-circle.d.ts +7 -1
  77. package/node/cp-node/fs/get-all-on-circle.js +11 -7
  78. package/node/cp-node/fs/get-all-on-circle.js.map +1 -1
  79. package/node/cp-node/fs/get-all-on-loop.d.ts +1 -1
  80. package/node/cp-node/fs/get-all-on-loop.js.map +1 -1
  81. package/node/cp-node/fs/get-boundary-bezier-parts-to-next.d.ts +12 -3
  82. package/node/cp-node/fs/get-boundary-bezier-parts-to-next.js +22 -7
  83. package/node/cp-node/fs/get-boundary-bezier-parts-to-next.js.map +1 -1
  84. package/node/cp-node/fs/get-boundary-beziers-between.d.ts +1 -1
  85. package/node/cp-node/fs/get-boundary-beziers-between.js.map +1 -1
  86. package/node/cp-node/fs/get-boundary-beziers-to-next.js.map +1 -1
  87. package/node/cp-node/fs/insert-cp-node.d.ts +3 -1
  88. package/node/cp-node/fs/insert-cp-node.js +12 -2
  89. package/node/cp-node/fs/insert-cp-node.js.map +1 -1
  90. package/node/cp-node/fs/is-fully-terminating.d.ts +7 -0
  91. package/node/cp-node/fs/is-fully-terminating.js +7 -0
  92. package/node/cp-node/fs/is-fully-terminating.js.map +1 -1
  93. package/node/cp-node/fs/is-terminating.d.ts +1 -1
  94. package/node/cp-node/fs/remove-cp-node.d.ts +3 -4
  95. package/node/cp-node/fs/remove-cp-node.js +3 -1
  96. package/node/cp-node/fs/remove-cp-node.js.map +1 -1
  97. package/node/curve/curve.d.ts +18 -11
  98. package/node/find-2-prong/add-1-prong.js +1 -1
  99. package/node/find-2-prong/add-1-prong.js.map +1 -1
  100. package/node/find-2-prong/add-2-prong.js +9 -7
  101. package/node/find-2-prong/add-2-prong.js.map +1 -1
  102. package/node/find-2-prong/calc-seperation-tolerance.d.ts +8 -1
  103. package/node/find-2-prong/calc-seperation-tolerance.js +73 -59
  104. package/node/find-2-prong/calc-seperation-tolerance.js.map +1 -1
  105. package/node/find-2-prong/find-2-prong.js +2 -2
  106. package/node/find-2-prong/find-2-prong.js.map +1 -1
  107. package/node/find-2-prong/get-initial-bezier-pieces.d.ts +2 -3
  108. package/node/find-2-prong/get-initial-bezier-pieces.js +4 -1
  109. package/node/find-2-prong/get-initial-bezier-pieces.js.map +1 -1
  110. package/node/find-3-prong.ts/find-and-add-3-prong.js +1 -1
  111. package/node/find-3-prong.ts/find-and-add-3-prong.js.map +1 -1
  112. package/node/find-3-prong.ts/find-and-add-3-prongs-on-loop.d.ts +2 -2
  113. package/node/find-3-prong.ts/find-and-add-3-prongs-on-loop.js +8 -3
  114. package/node/find-3-prong.ts/find-and-add-3-prongs-on-loop.js.map +1 -1
  115. package/node/find-mat/create-initial-cp-tree.d.ts +7 -3
  116. package/node/find-mat/create-initial-cp-tree.js +7 -5
  117. package/node/find-mat/create-initial-cp-tree.js.map +1 -1
  118. package/node/find-mat/find-mat.d.ts +2 -1
  119. package/node/find-mat/find-mat.js +10 -4
  120. package/node/find-mat/find-mat.js.map +1 -1
  121. package/node/find-mat/get-meta.d.ts +5 -2
  122. package/node/find-mat/get-meta.js +15 -14
  123. package/node/find-mat/get-meta.js.map +1 -1
  124. package/node/index.d.ts +0 -1
  125. package/node/index.js +1 -1
  126. package/node/index.js.map +1 -1
  127. package/node/mat/add-to-cp-tree.d.ts +5 -6
  128. package/node/mat/add-to-cp-tree.js +5 -2
  129. package/node/mat/add-to-cp-tree.js.map +1 -1
  130. package/node/mat/get-branches.d.ts +7 -0
  131. package/node/mat/get-branches.js +7 -0
  132. package/node/mat/get-branches.js.map +1 -1
  133. package/node/mat/mat-meta.d.ts +8 -1
  134. package/node/mat/mat.d.ts +3 -3
  135. package/node/mat/simplify-mat.js +1 -1
  136. package/node/mat/simplify-mat.js.map +1 -1
  137. package/node/point-on-shape/point-on-shape.d.ts +1 -1
  138. package/node/vertex/remove-vertex.d.ts +3 -4
  139. package/node/vertex/remove-vertex.js +3 -2
  140. package/node/vertex/remove-vertex.js.map +1 -1
  141. package/package.json +9 -6
  142. package/src/corner/get-interface-ccw.ts +0 -1
  143. package/src/cp-node/cp-node-fs.ts +43 -43
  144. package/src/cp-node/cp-node.ts +27 -39
  145. package/src/cp-node/fs/clone.ts +3 -3
  146. package/src/cp-node/fs/enhance-cp-node.ts +0 -1
  147. package/src/cp-node/fs/get-all-between.ts +31 -28
  148. package/src/cp-node/fs/get-all-on-circle.ts +13 -8
  149. package/src/cp-node/fs/get-all-on-loop.ts +12 -10
  150. package/src/cp-node/fs/get-boundary-bezier-parts-to-next.ts +39 -22
  151. package/src/cp-node/fs/get-boundary-beziers-between.ts +6 -2
  152. package/src/cp-node/fs/get-boundary-beziers-to-next.ts +6 -4
  153. package/src/cp-node/fs/insert-cp-node.ts +13 -2
  154. package/src/cp-node/fs/is-fully-terminating.ts +7 -0
  155. package/src/cp-node/fs/is-terminating.ts +1 -1
  156. package/src/cp-node/fs/remove-cp-node.ts +8 -4
  157. package/src/curve/curve.ts +19 -13
  158. package/src/debug/functions/check-ordering.ts +7 -3
  159. package/src/find-2-prong/add-1-prong.ts +1 -1
  160. package/src/find-2-prong/add-2-prong.ts +79 -74
  161. package/src/find-2-prong/calc-seperation-tolerance.ts +88 -78
  162. package/src/find-2-prong/find-2-prong.ts +2 -2
  163. package/src/find-2-prong/get-initial-bezier-pieces.ts +5 -1
  164. package/src/find-3-prong.ts/add-3-prong.ts +73 -70
  165. package/src/find-3-prong.ts/find-and-add-3-prong.ts +1 -1
  166. package/src/find-3-prong.ts/find-and-add-3-prongs-on-loop.ts +9 -8
  167. package/src/find-mat/create-initial-cp-tree.ts +10 -6
  168. package/src/find-mat/find-mat.ts +12 -5
  169. package/src/find-mat/get-meta.ts +30 -20
  170. package/src/get-curve/get-curve-between.ts +2 -2
  171. package/src/index.ts +1 -1
  172. package/src/mat/add-to-cp-tree.ts +18 -9
  173. package/src/mat/get-branches.ts +35 -28
  174. package/src/mat/mat-meta.ts +6 -1
  175. package/src/mat/mat.ts +3 -3
  176. package/src/mat/simplify-mat.ts +1 -1
  177. package/src/point-on-shape/compare-poss.ts +3 -3
  178. package/src/point-on-shape/get-osculating-circle.ts +1 -1
  179. package/src/point-on-shape/point-on-shape.ts +1 -1
  180. package/src/point-on-shape/pos-to-human-string.ts +1 -1
  181. package/src/sat/to-scale-axis.ts +1 -1
  182. package/src/vertex/remove-vertex.ts +7 -5
  183. package/.mocharc.cjs +0 -17
  184. package/src/debug/functions/draw-elem/branch.ts +0 -26
  185. package/src/find-mat/create-initial-cp-graph.ts +0 -59
@@ -41,23 +41,23 @@ const cpNodeComparator = (a: CpNode, b: CpNode) => compareCps(a.cp, b.cp);
41
41
 
42
42
  const CpNodeFs = {
43
43
  /**
44
- * Returns the children of this [[CpNode]] when seen as a MAT edge. Only
44
+ * Returns the children of this `CpNode` when seen as a MAT edge. Only
45
45
  * children in a 'forward' direction are returned. These include all edges
46
- * except the 'backward' edge given by [[prevOnCircle]], even terminating
46
+ * except the 'backward' edge given by `prevOnCircle`, even terminating
47
47
  * edges.
48
48
  */
49
49
  getChildren,
50
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
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
53
  * way the dual graph of the tree can easily be traversed - see e.g.
54
- * [[traverseVertices]]. Generally, however, traversing the edges is
54
+ * `traverseVertices`. Generally, however, traversing the edges is
55
55
  * preferred as it returns the entire Medial Axis (by utilizing
56
- * [[getMatCurveToNext]] on each returned edge).
56
+ * `getMatCurveToNext` on each returned edge).
57
57
  */
58
58
  getVertexForwardChildren,
59
59
  /**
60
- * Returns all [[CpNode]]s on the MAT that this [[CpNode]] is part of
60
+ * Returns all `CpNode`s on the MAT that this `CpNode` is part of
61
61
  * starting from the current one and going anti-clockwise around the shape.
62
62
  */
63
63
  getAllOnLoop,
@@ -65,18 +65,18 @@ const CpNodeFs = {
65
65
  * Return this (except if exclThis is truthy) and the the other CpNodes
66
66
  * around the maximal disk vertex circle in an anti-clockwise order.
67
67
  * @param exclThis If true the returned array does not include this
68
- * [[CpNode]].
68
+ * `CpNode`.
69
69
  */
70
70
  getAllOnCircle,
71
71
  /**
72
- * Returns true if the 2 given [[CpNode]]s are on the same maximal disk
72
+ * Returns true if the 2 given `CpNode`s are on the same maximal disk
73
73
  * circle.
74
- * @param cpNode1 A [[CpNode]].
75
- * @param cpNode2 Another [[CpNode]]
74
+ * @param cpNode1 A `CpNode`.
75
+ * @param cpNode2 Another `CpNode`
76
76
  */
77
77
  isOnSameCircle,
78
78
  /**
79
- * Returns true if this [[CpNode]] is terminating, i.e. implies a leaf MAT
79
+ * Returns true if this `CpNode` is terminating, i.e. implies a leaf MAT
80
80
  * vertex.
81
81
  *
82
82
  * This is always the case for sharp corners and maximal disks with
@@ -84,8 +84,8 @@ const CpNodeFs = {
84
84
  * two contact points stored (sitting 'on top' of each other) for the
85
85
  * maximal disk. It can be seen as a limiting case of a two-prong where the
86
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
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
89
  * terminating and 'points' back into the shape.
90
90
  */
91
91
  isTerminating,
@@ -95,48 +95,48 @@ const CpNodeFs = {
95
95
  */
96
96
  isFullyTerminating,
97
97
  /**
98
- * Returns the first [[CpNode]] (from this one by successively applying
98
+ * Returns the first `CpNode` (from this one by successively applying
99
99
  * .nextOnCircle) that exits the circle.
100
100
  */
101
101
  getFirstExit,
102
102
  /**
103
- * Returns true if this [[CpNode]] represents a sharp corner, i.e. the
103
+ * Returns true if this `CpNode` represents a sharp corner, i.e. the
104
104
  * limiting case of a two-prong having zero radius.
105
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.
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
108
  */
109
109
  isSharp,
110
110
  /**
111
- * Returns true if this [[CpNode]]'s maximal disk has only one contact point
111
+ * Returns true if this `CpNode`'s maximal disk has only one contact point
112
112
  * on the shape boundary (up to planar coordinates). These includes sharp
113
113
  * corners.
114
114
  *
115
- * Note, however, that two [[CpNode]]s are stored for each such point to
116
- * preserve symmetry - see [[isTerminating]] for more details.
115
+ * Note, however, that two `CpNode`s are stored for each such point to
116
+ * preserve symmetry - see `isTerminating` for more details.
117
117
  */
118
118
  isOneProng,
119
119
  /**
120
120
  * Returns the number of contact points on the maximal disk circle implied
121
- * by this [[CpNode]].
121
+ * by this `CpNode`.
122
122
  *
123
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.
124
+ * `isTerminating` for more details); if this is not desired use
125
+ * `getRealProngCount` instead which will return 1 in these cases.
126
126
  */
127
127
  getProngCount,
128
128
  /**
129
129
  * Returns the number of contact points (up to planar coordinates) on the
130
- * maximal disk circle implied by this [[CpNode]].
130
+ * maximal disk circle implied by this `CpNode`.
131
131
  *
132
- * See also [[getProngCount]].
132
+ * See also `getProngCount`.
133
133
  */
134
134
  getRealProngCount,
135
135
  /**
136
136
  * Primarily for internal use.
137
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.
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
140
  */
141
141
  cpNodeComparator,
142
142
  /**
@@ -156,26 +156,26 @@ const CpNodeFs = {
156
156
  traverseCp,
157
157
  /**
158
158
  * Traverses all edges (depth first) of the given MAT tree starting at the given
159
- * vertex (represented by a [[CpNode]]).
160
- * @param cpNode Any [[CpNode]] representing the start vertex.
159
+ * vertex (represented by a `CpNode`).
160
+ * @param cpNode Any `CpNode` representing the start vertex.
161
161
  * @param traverseEdgesCallback A callback function for each CpNode representing the vertex at the
162
162
  * start of an edge.
163
163
  */
164
164
  traverseEdges,
165
165
  /**
166
166
  * Traverses the MAT tree and calls the given callback function for each vertex
167
- * (represented by a [[CpNode]]) on the MAT.
167
+ * (represented by a `CpNode`) on the MAT.
168
168
  *
169
- * It is usually preferable to use [[traverseEdges]] as it allows for the
169
+ * It is usually preferable to use `traverseEdges` as it allows for the
170
170
  * traversal of all the smooth curves representing the MAT.
171
- * @param cpNode Any [[CpNode]] representing the start vertex.
172
- * @param traverseVerticesCallback A callback function taking a single [[CpNode]] as parameter.
171
+ * @param cpNode Any `CpNode` representing the start vertex.
172
+ * @param traverseVerticesCallback A callback function taking a single `CpNode` as parameter.
173
173
  */
174
174
  traverseVertices,
175
175
  /**
176
- * Returns a deep clone of this [[CpNode]]. Can be used to copy the MAT
177
- * since cloning a single [[CpNode]] necessarily implies cloning all
178
- * [[CpNode]]s on the same MAT tree.
176
+ * Returns a deep clone of this `CpNode`. Can be used to copy the MAT
177
+ * since cloning a single `CpNode` necessarily implies cloning all
178
+ * `CpNode`s on the same MAT tree.
179
179
  */
180
180
  clone,
181
181
  /**
@@ -192,13 +192,13 @@ const CpNodeFs = {
192
192
  getBoundaryBeziersToNext,
193
193
  /**
194
194
  * Removes a cpNode from the MAT.
195
- * @param cpTree The tree graph holding the [[CpNodes]] of the MAT.
196
- * @param cpNode The [[CpNode]] to remove.
195
+ * @param cpTree The tree graph holding the `CpNodes` of the MAT.
196
+ * @param cpNode The `CpNode` to remove.
197
197
  */
198
198
  removeVertex,
199
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
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
202
  * medial axis.
203
203
  * @param cpNode
204
204
  */
@@ -208,8 +208,8 @@ const CpNodeFs = {
208
208
  getBranchBeziers,
209
209
  getSalience,
210
210
  /**
211
- * Returns the bezier curve from the maximal disk of one [[CpNode]] to another
212
- * [[CpNode]]'s maximal disk.
211
+ * Returns the bezier curve from the maximal disk of one `CpNode` to another
212
+ * `CpNode`'s maximal disk.
213
213
  * @param cpNodeFrom
214
214
  * @param cpNodeTo
215
215
  */
@@ -7,66 +7,66 @@ import { ContactPoint } from '../contact-point/contact-point.js';
7
7
  * Since the MAT is a full representation of the shape boundary an instance of
8
8
  * this class contains both the information of a boundary point and a medial
9
9
  * axis point (and edge to the next point(s)). It also contains edges to other
10
- * [[CpNode]]s which allows for traversal of the MAT and thus implictly
10
+ * `CpNode`s which allows for traversal of the MAT and thus implictly
11
11
  * represents the entire MAT.
12
12
  *
13
13
  * To get the maximal disk circle (of which the center is on the medial axis)
14
- * use [[cp]].circle.
14
+ * use `cp.circle`.
15
15
  *
16
- * To get the boundary point, use [[cp]].pointOnShape.
16
+ * To get the boundary point, use `cp.pointOnShape`.
17
17
  *
18
- * The edge [[next]] (resp. [[prev]]) allows one to move anti-clockwise (resp.
19
- * clockwise) on the shape boundary to the next [[CpNode]]. This also imposes a
18
+ * The edge `next` (resp. `prev`) allows one to move anti-clockwise (resp.
19
+ * clockwise) on the shape boundary to the next `CpNode`. This also imposes a
20
20
  * direction of traversal of the MAT edges and vertices.
21
21
  *
22
- * The edge [[nextOnCircle]] (resp. [[prevOnCircle]]) allows one to go
22
+ * The edge `nextOnCircle` (resp. `prevOnCircle`) allows one to go
23
23
  * anti-clockwise (resp. clockwise) around the maximal disks implied by
24
24
  * the CpNode to the next maximal disk contact point. This is equivalent to
25
25
  * following other branches on the MAT.
26
26
  *
27
- * Call [[getMatCurveBetween]](cpNodeFrom, cpNodeTo) or getMatCurveToNext(cpNode)
28
- * (replacing the older CpNode.[[matCurveToNextVertex]]) to get a bezier curve
29
- * from the maximal disk of this [[CpNode]] to the next [[CpNode]]'s
27
+ * Call `getMatCurveBetween(cpNodeFrom, cpNodeTo)` or `getMatCurveToNext(cpNode)`
28
+ * (replacing the older CpNode.`matCurveToNextVertex`) to get a bezier curve
29
+ * from the maximal disk of this `CpNode` to the next `CpNode`'s
30
30
  * maximal disk and thus directly representing a piece of the medial axis.
31
31
  *
32
- * The function, [[getChildren]], returns the children of this [[CpNode]] when
32
+ * The function, `getChildren`, returns the children of this `CpNode` when
33
33
  * seen as a MAT edge. Only children in a 'forward' direction are returned. These
34
- * include all edges except the 'backward' edge given by [[prevOnCircle]]. For
35
- * [[CpNode]]s having a maximal disk with 2 contact points (a 2-prong, the usual
36
- * case) the children will be the single edge [[next]]. For a 3-prong this will
37
- * be the edges [[next]] and [[nextOnCircle]], etc. [[getChildren]] allows one to
38
- * easily traverse the MAT tree - see e.g. the implementation of [[traverseEdges]].
34
+ * include all edges except the 'backward' edge given by `prevOnCircle`. For
35
+ * `CpNode`s having a maximal disk with 2 contact points (a 2-prong, the usual
36
+ * case) the children will be the single edge `next`. For a 3-prong this will
37
+ * be the edges `next` and `nextOnCircle`, etc. `getChildren` allows one to
38
+ * easily traverse the MAT tree - see e.g. the implementation of `traverseEdges`.
39
39
  *
40
- * The getter, [[getVertexForwardChildren]], is similar to [[getChildren]] but returns the
41
- * child nodes of the tree when [[CpNode]] is seen as a MAT vertex point (as
40
+ * The getter, `getVertexForwardChildren`, is similar to `getChildren` but returns the
41
+ * child nodes of the tree when `CpNode` is seen as a MAT vertex point (as
42
42
  * opposed to edge). In this way the dual graph of the tree can easily be
43
- * traversed - see e.g. [[traverseVertices]]. Generally, however, traversing the
43
+ * traversed - see e.g. `traverseVertices`. Generally, however, traversing the
44
44
  * edges is preferred as it returns the entire Medial Axis (by utilizing
45
- * [[getMatCurveToNext]] on each returned edge).
45
+ * `getMatCurveToNext` on each returned edge).
46
46
  *
47
47
  * It may be worth mentioning that by traversing from the CpNode by following
48
- * [[next]] repeatedly until one is back at the same CpNode allows one
48
+ * `next` repeatedly until one is back at the same CpNode allows one
49
49
  * to 'go around' the shape boundary and at the same time traverse the MAT twice
50
50
  * in opposite directions.
51
51
  */
52
52
  interface CpNode {
53
- /** The shape boundary contact point, i.e. a [[CpNode]] without its edges. */
53
+ /** The shape boundary contact point, i.e. a `CpNode` without its edges. */
54
54
  cp: ContactPoint;
55
- /** If true, this [[CpNode]] belongs to a hole-closing maximal disk. */
55
+ /** If true, this `CpNode` belongs to a hole-closing maximal disk. */
56
56
  isHoleClosing: boolean;
57
57
  /** true if this cpNode is at a shape boundary intersection point, false otherwise */
58
58
  isIntersection: boolean;
59
- /** The previous (going clockwise around the boundary) contact point ([[CpNode]]).*/
59
+ /** The previous (going clockwise around the boundary) contact point (`CpNode`).*/
60
60
  prev: CpNode;
61
- /** The next (going anti-clockwise around the boundary) contact point ([[CpNode]]). */
61
+ /** The next (going anti-clockwise around the boundary) contact point (`CpNode`). */
62
62
  next: CpNode;
63
63
  /**
64
- * The previous [[CpNode]] (going clockwise around the inscribed circle
64
+ * The previous `CpNode` (going clockwise around the inscribed circle
65
65
  * defined by the maximal disk).
66
66
  */
67
67
  prevOnCircle: CpNode;
68
68
  /**
69
- * The next [[CpNode]] (going anti-clockwise around
69
+ * The next `CpNode` (going anti-clockwise around
70
70
  * the inscribed circle defined by the maximal disk).
71
71
  */
72
72
  nextOnCircle: CpNode;
@@ -80,19 +80,7 @@ interface CpNode {
80
80
  holeCloserPrev?: CpNode | undefined;
81
81
 
82
82
  /** Only used in export */
83
- id?: number;
84
-
85
- /** Only used in export */
86
- children?: number[];
87
-
88
- /** Only used in export */
89
- isRoot?: boolean;
90
-
91
- /** Only used in export */
92
- parentId?: number;
93
-
94
- /** Only used in export */
95
- childId?: number;
83
+ id: number;
96
84
  }
97
85
 
98
86
 
@@ -17,9 +17,9 @@ type CpNodeWithoutEdges =
17
17
 
18
18
 
19
19
  /**
20
- * Returns a deep clone of this [[CpNode]]. Can be used to copy the MAT
21
- * since cloning a single [[CpNode]] necessarily implies cloning all
22
- * [[CpNode]]s on the same MAT tree.
20
+ * Returns a deep clone of this `CpNode`. Can be used to copy the MAT
21
+ * since cloning a single `CpNode` necessarily implies cloning all
22
+ * `CpNode`s on the same MAT tree.
23
23
  */
24
24
  function clone(cpNode: CpNode): CpNode {
25
25
  // Don't change this function to be recursive, the call stack may
@@ -1,6 +1,5 @@
1
1
  import { CpNode } from "../cp-node.js";
2
2
  import { getCpNodeOrdering } from './get-cp-node-ordering.js';
3
- import { CpNodeFs } from '../cp-node-fs.js';
4
3
  import { getProngCount } from './get-prong-count.js';
5
4
  import { getRealProngCount } from "./get-real-prong-count.js";
6
5
  import { isFullyTerminating } from "./is-fully-terminating.js";
@@ -2,42 +2,45 @@ import { CpNode } from "../cp-node.js";
2
2
 
3
3
 
4
4
  /**
5
- * Returns all `CpNode`s between the two given ones (exclisive the last one).
5
+ * Returns all `CpNode`s between the two given ones (excluding the last one).
6
6
  *
7
7
  * * If the second `CpNode` is never encountered all on the loop will be
8
8
  * returned.
9
9
  *
10
- * @param cpNodeS
11
- * @param cpNodeE
10
+ * @param cpNodeS start `CpNode`
11
+ * @param cpNodeE end `CpNode`
12
12
  * @param inclAllIfEqual if `true` and first and last `CpNode`s are equal then
13
13
  * include all `CpNode`s around the loop, otherwise include none.
14
14
  */
15
15
  function getAllBetween(
16
- cpNodeS: CpNode,
17
- cpNodeE: CpNode,
18
- inclAllIfEqual = true) {
19
-
20
- if (!inclAllIfEqual && cpNodeS === cpNodeE) {
21
- return { cpNodes: [], hasHoleCloser: false }
22
- }
23
-
24
- const cpStart = cpNodeS;
25
- const cpNodes: CpNode[] = [cpStart];
26
-
27
- let cpNode_ = cpNodeS.next;
28
- let hasHoleCloser = cpStart.isHoleClosing;
29
-
30
- while (cpNode_ !== cpNodeE &&
31
- cpNode_ !== cpStart) {
32
-
33
- if (cpNode_.isHoleClosing) {
34
- hasHoleCloser = true;
35
- }
36
- cpNodes.push(cpNode_);
37
- cpNode_ = cpNode_.next;
38
- }
39
-
40
- return { cpNodes, hasHoleCloser };
16
+ cpNodeS: CpNode,
17
+ cpNodeE: CpNode,
18
+ inclAllIfEqual = true): {
19
+ cpNodes: CpNode[],
20
+ hasHoleCloser: boolean
21
+ } {
22
+
23
+ if (!inclAllIfEqual && cpNodeS === cpNodeE) {
24
+ return { cpNodes: [], hasHoleCloser: false }
25
+ }
26
+
27
+ const cpStart = cpNodeS;
28
+ const cpNodes: CpNode[] = [cpStart];
29
+
30
+ let cpNode_ = cpNodeS.next;
31
+ let hasHoleCloser = cpStart.isHoleClosing;
32
+
33
+ while (cpNode_ !== cpNodeE &&
34
+ cpNode_ !== cpStart) {
35
+
36
+ if (cpNode_.isHoleClosing) {
37
+ hasHoleCloser = true;
38
+ }
39
+ cpNodes.push(cpNode_);
40
+ cpNode_ = cpNode_.next;
41
+ }
42
+
43
+ return { cpNodes, hasHoleCloser };
41
44
  }
42
45
 
43
46
 
@@ -1,20 +1,25 @@
1
- import { CpNode } from "../cp-node.js";
1
+ import type { CpNode } from "../cp-node.js";
2
2
 
3
3
 
4
+ /**
5
+ * Returns all the `CpNode`s on the same circle.
6
+ *
7
+ * @param cpNode
8
+ * @param exclThis
9
+ */
4
10
  function getAllOnCircle(
5
11
  cpNode: CpNode,
6
12
  exclThis = false) {
7
13
 
8
14
  const startCpNode = cpNode;
9
- let cpNode_ = startCpNode;
10
15
 
11
- const cpNodes: CpNode[] = [];
12
- do {
13
- if (!(exclThis && cpNode_ === startCpNode)) {
14
- cpNodes.push(cpNode_);
15
- }
16
+ const cpNodes: CpNode[] = exclThis ? [] : [cpNode];
17
+
18
+ let cpNode_ = cpNode.nextOnCircle;
19
+ while (cpNode_ !== startCpNode) {
20
+ cpNodes.push(cpNode_);
16
21
  cpNode_ = cpNode_.nextOnCircle;
17
- } while (cpNode_ !== startCpNode)
22
+ }
18
23
 
19
24
  return cpNodes;
20
25
  }
@@ -1,17 +1,19 @@
1
- import { CpNode } from "../cp-node.js";
1
+ import type { CpNode } from "../cp-node.js";
2
2
 
3
3
 
4
- function getAllOnLoop(cpNode: CpNode) {
5
- const cpStart = cpNode;
6
- const cpNodes: CpNode[] = [cpStart];
7
- let cpNode_ = cpNode.next;
4
+ function getAllOnLoop(
5
+ cpNode: CpNode) {
8
6
 
9
- while (cpNode_ !== cpStart) {
10
- cpNodes.push(cpNode_);
11
- cpNode_ = cpNode_.next;
12
- }
7
+ const cpStart = cpNode;
8
+ const cpNodes: CpNode[] = [cpStart];
9
+ let cpNode_ = cpNode.next;
13
10
 
14
- return cpNodes;
11
+ while (cpNode_ !== cpStart) {
12
+ cpNodes.push(cpNode_);
13
+ cpNode_ = cpNode_.next;
14
+ }
15
+
16
+ return cpNodes;
15
17
  }
16
18
 
17
19
 
@@ -1,9 +1,20 @@
1
- import { BezierPiece } from 'flo-bezier3';
2
- import { CpNode } from '../cp-node.js';
3
- import { Curve } from '../../curve/curve.js';
1
+ import type { BezierPiece } from 'flo-bezier3';
2
+ import type { CpNode } from '../cp-node.js';
3
+ import type { Curve } from '../../curve/curve.js';
4
4
 
5
5
 
6
- function getBoundaryBezierPartsToNext(cpNode: CpNode): BezierPiece[] {
6
+ /**
7
+ * Returns the boundary beziers pieces between this `CpNode` and the next
8
+ * one.
9
+ *
10
+ * * returns `undefined` if the next `CpNode` is on a different loop,
11
+ * as this is a hole-closer and there are no boundary beziers between them.
12
+ *
13
+ * @param cpNode
14
+ */
15
+ function getBoundaryBezierPartsToNext(
16
+ cpNode: CpNode): BezierPiece[] | undefined {
17
+
7
18
  const cpThis = cpNode;
8
19
  const cpNext = cpNode.next;
9
20
 
@@ -16,29 +27,35 @@ function getBoundaryBezierPartsToNext(cpNode: CpNode): BezierPiece[] {
16
27
  if (curveThis.loop !== curveNext.loop) {
17
28
  // It is a hole-closer going over to the other loop - a kind of terminal
18
29
  // CpNode.
19
- return undefined!;
30
+ return undefined;
20
31
  }
21
32
 
22
- const bezierParts: BezierPiece[] = [];
33
+ const bezierPieces: BezierPiece[] = [];
23
34
 
24
35
  if (curveNext === curveThis) {
25
- bezierParts.push(
26
- { ps: posThis.curve.ps, ts: [posThis.t, posNext.t] }
36
+ bezierPieces.push(
37
+ {
38
+ ps: posThis.curve.ps,
39
+ ts: [posThis.t, posNext.t]
40
+ }
27
41
  );
28
42
  } else {
29
- bezierParts.push(
30
- { ps: posThis.curve.ps, ts: [posThis.t, 1] }
43
+ bezierPieces.push(
44
+ {
45
+ ps: posThis.curve.ps,
46
+ ts: [posThis.t, 1]
47
+ }
31
48
  );
32
49
 
33
50
  addSkippedBeziers(
34
- bezierParts,
35
- posThis.curve,
36
- posNext.curve,
37
- posNext.t
51
+ bezierPieces,
52
+ posThis.curve,
53
+ posNext.curve,
54
+ posNext.t
38
55
  );
39
- }
40
-
41
- return bezierParts;
56
+ }
57
+
58
+ return bezierPieces;
42
59
  }
43
60
 
44
61
 
@@ -47,10 +64,10 @@ function getBoundaryBezierPartsToNext(cpNode: CpNode): BezierPiece[] {
47
64
  * Adds pieces of skipped beziers.
48
65
  */
49
66
  function addSkippedBeziers(
50
- bezierParts: { ps: number[][]; ts: number[] }[],
51
- curveStart : Curve,
52
- curveEnd : Curve,
53
- t1 : number) {
67
+ bezierPieces: BezierPiece[],
68
+ curveStart: Curve,
69
+ curveEnd: Curve,
70
+ t1: number) {
54
71
 
55
72
  let curveThis = curveStart;
56
73
  do {
@@ -59,7 +76,7 @@ function addSkippedBeziers(
59
76
  ? { ps: curveThis.ps, ts: [0, t1] }
60
77
  : { ps: curveThis.ps, ts: [0, 1] }
61
78
 
62
- bezierParts.push(bezierPart);
79
+ bezierPieces.push(bezierPart);
63
80
  } while (curveThis !== curveEnd);
64
81
  }
65
82
 
@@ -1,4 +1,5 @@
1
- import { CpNode } from "../cp-node.js";
1
+ import type { BezierPiece } from "flo-bezier3";
2
+ import type { CpNode } from "../cp-node.js";
2
3
  import { cpNodesToBoundaryBeziers } from "./cp-nodes-to-boundary-beziers.js";
3
4
  import { getAllBetween } from "./get-all-between.js";
4
5
 
@@ -17,7 +18,10 @@ import { getAllBetween } from "./get-all-between.js";
17
18
  function getBoundaryBeziersBetween(
18
19
  cpNode1: CpNode,
19
20
  cpNode2: CpNode,
20
- inclAllIfEqual = true) {
21
+ inclAllIfEqual = true): {
22
+ pss: number[][][],
23
+ hasHoleCloser: boolean
24
+ } {
21
25
 
22
26
  const allBetween = getAllBetween(cpNode1,cpNode2,inclAllIfEqual);
23
27
 
@@ -3,7 +3,9 @@ import { CpNode } from '../cp-node.js';
3
3
  import { Curve } from '../../curve/curve.js';
4
4
 
5
5
 
6
- function getBoundaryBeziersToNext(cpNode: CpNode): number[][][] {
6
+ function getBoundaryBeziersToNext(
7
+ cpNode: CpNode): number[][][] {
8
+
7
9
  const cpThis = cpNode;
8
10
  const cpNext = cpNode.next;
9
11
 
@@ -19,7 +21,7 @@ function getBoundaryBeziersToNext(cpNode: CpNode): number[][][] {
19
21
  // return undefined!;
20
22
  return [];
21
23
  }
22
-
24
+
23
25
  const beziers = [];
24
26
 
25
27
  if (curveNext === curveThis) {
@@ -37,8 +39,8 @@ function getBoundaryBeziersToNext(cpNode: CpNode): number[][][] {
37
39
  posNext.curve,
38
40
  posNext.t
39
41
  );
40
- }
41
-
42
+ }
43
+
42
44
  return beziers;
43
45
  }
44
46
 
@@ -10,7 +10,8 @@ function insertCpNode(
10
10
  isIntersection: boolean,
11
11
  cpTree: LlRbTree<CpNode>,
12
12
  cp: ContactPoint,
13
- _prev: CpNode | undefined) {
13
+ _prev: CpNode | undefined,
14
+ lastInsertId: { id: number }): CpNode | undefined {
14
15
 
15
16
  if (_prev !== undefined &&
16
17
  !isOrderCorrect(cpTree, cp, _prev.next)) {
@@ -21,7 +22,17 @@ function insertCpNode(
21
22
  }
22
23
  }
23
24
 
24
- const cpNode = { cp, isHoleClosing, isIntersection } as CpNode;
25
+ const cpNode: CpNode = {
26
+ cp,
27
+ isHoleClosing,
28
+ isIntersection,
29
+ id: lastInsertId.id,
30
+ next: undefined!,
31
+ prev: undefined!,
32
+ nextOnCircle: undefined!,
33
+ prevOnCircle: undefined!
34
+ };
35
+ lastInsertId.id++;
25
36
 
26
37
  const prev = _prev === undefined ? cpNode : _prev;
27
38
  const next = _prev === undefined ? cpNode : prev.next;
@@ -3,6 +3,13 @@ import { getAllOnCircle } from "./get-all-on-circle.js";
3
3
  import { isTerminating } from "./is-terminating.js";
4
4
 
5
5
 
6
+ /**
7
+ * Returns `true` if this `CpNode` is fully terminating, meaning that all
8
+ * `CpNode`s (except `CpNode.prevOnCircle`) on the same circle are terminating,
9
+ * `false` otherwise.
10
+ *
11
+ * @param cpNode
12
+ */
6
13
  function isFullyTerminating(cpNode: CpNode) {
7
14
  const otherOnCircle = getAllOnCircle(cpNode.prevOnCircle, true);
8
15