flo-mat 3.0.9 → 3.0.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (261) 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 +280 -236
  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/cull-bezier-pieces.d.ts +5 -4
  11. package/node/closest-boundary-point/cull-bezier-pieces.js +9 -8
  12. package/node/closest-boundary-point/cull-bezier-pieces.js.map +1 -1
  13. package/node/closest-boundary-point/cull-by-loose-bounding-box.d.ts +2 -2
  14. package/node/closest-boundary-point/cull-by-loose-bounding-box.js +8 -8
  15. package/node/closest-boundary-point/cull-by-loose-bounding-box.js.map +1 -1
  16. package/node/closest-boundary-point/cull-by-tight-boundary-box.d.ts +2 -2
  17. package/node/closest-boundary-point/cull-by-tight-boundary-box.js +8 -8
  18. package/node/closest-boundary-point/cull-by-tight-boundary-box.js.map +1 -1
  19. package/node/closest-boundary-point/dd-deflate-with-running-error.js.map +1 -1
  20. package/node/closest-boundary-point/get-best-distance-squared.d.ts +1 -1
  21. package/node/closest-boundary-point/get-best-distance-squared.js +6 -6
  22. package/node/closest-boundary-point/get-best-distance-squared.js.map +1 -1
  23. package/node/closest-boundary-point/get-close-boundary-points-certified.d.ts +2 -2
  24. package/node/closest-boundary-point/get-close-boundary-points-certified.js +7 -7
  25. package/node/closest-boundary-point/get-close-boundary-points-certified.js.map +1 -1
  26. package/node/contact-point/contact-point.js.map +1 -1
  27. package/node/corner/get-corner.js.map +1 -1
  28. package/node/corner/get-interface-ccw.js.map +1 -1
  29. package/node/cp-node/cp-node-fs.d.ts +2 -1
  30. package/node/cp-node/cp-node-fs.js +1 -2
  31. package/node/cp-node/cp-node-fs.js.map +1 -1
  32. package/node/cp-node/fs/cp-node-comparator.d.ts +3 -0
  33. package/node/cp-node/fs/cp-node-comparator.js +6 -0
  34. package/node/cp-node/fs/cp-node-comparator.js.map +1 -0
  35. package/node/cp-node/fs/find-first.js.map +1 -1
  36. package/node/cp-node/fs/get-all-on-loop.js.map +1 -1
  37. package/node/cp-node/fs/get-boundary-bezier-parts-to-next.d.ts +1 -1
  38. package/node/cp-node/fs/get-boundary-bezier-parts-to-next.js +11 -16
  39. package/node/cp-node/fs/get-boundary-bezier-parts-to-next.js.map +1 -1
  40. package/node/cp-node/fs/get-boundary-beziers-between.js +4 -6
  41. package/node/cp-node/fs/get-boundary-beziers-between.js.map +1 -1
  42. package/node/cp-node/fs/get-boundary-beziers-to-next.d.ts +10 -1
  43. package/node/cp-node/fs/get-boundary-beziers-to-next.js +70 -35
  44. package/node/cp-node/fs/get-boundary-beziers-to-next.js.map +1 -1
  45. package/node/cp-node/fs/get-branch-beziers.js.map +1 -1
  46. package/node/cp-node/fs/get-branch.js.map +1 -1
  47. package/node/cp-node/fs/get-children.js.map +1 -1
  48. package/node/cp-node/fs/get-first-exit.js.map +1 -1
  49. package/node/cp-node/fs/get-mat-curve-to-next.js.map +1 -1
  50. package/node/cp-node/fs/get-mat-curves-between.js.map +1 -1
  51. package/node/cp-node/fs/get-prong-count.js.map +1 -1
  52. package/node/cp-node/fs/get-real-prong-count.js.map +1 -1
  53. package/node/cp-node/fs/get-salience.js +2 -2
  54. package/node/cp-node/fs/get-salience.js.map +1 -1
  55. package/node/cp-node/fs/get-speed.js +0 -1
  56. package/node/cp-node/fs/get-speed.js.map +1 -1
  57. package/node/cp-node/fs/get-vertex-forward-children.js.map +1 -1
  58. package/node/cp-node/fs/is-fully-terminating.d.ts +1 -1
  59. package/node/cp-node/fs/is-fully-terminating.js.map +1 -1
  60. package/node/cp-node/fs/is-one-prong.js.map +1 -1
  61. package/node/cp-node/fs/is-sharp.js.map +1 -1
  62. package/node/cp-node/fs/is-terminating.js.map +1 -1
  63. package/node/cp-node/fs/traverse-cp.js.map +1 -1
  64. package/node/cp-node/fs/traverse-edges.js.map +1 -1
  65. package/node/cp-node/fs/traverse-vertices.js.map +1 -1
  66. package/node/debug/functions/draw-elem/bounding-hull.js.map +1 -1
  67. package/node/debug/functions/draw-elem/draw-cp-node.js +1 -1
  68. package/node/debug/functions/draw-elem/draw-cp-node.js.map +1 -1
  69. package/node/debug/functions/draw-elem/draw-cull.js.map +1 -1
  70. package/node/debug/functions/draw-elem/draw-dull-corner.js.map +1 -1
  71. package/node/debug/functions/draw-elem/draw-elem.js.map +1 -1
  72. package/node/debug/functions/draw-elem/draw-leaves.js.map +1 -1
  73. package/node/debug/functions/draw-elem/draw-loose-bounding-box.js.map +1 -1
  74. package/node/debug/functions/draw-elem/draw-max-vertex.js.map +1 -1
  75. package/node/debug/functions/draw-elem/draw-min-y.js.map +1 -1
  76. package/node/debug/functions/draw-elem/draw-one-prong-at-dull-corner.js.map +1 -1
  77. package/node/debug/functions/draw-elem/draw-one-prong.js.map +1 -1
  78. package/node/debug/functions/draw-elem/draw-sharp-corner.js.map +1 -1
  79. package/node/debug/functions/draw-elem/draw-speed.js.map +1 -1
  80. package/node/debug/functions/draw-elem/draw-three-prong.js.map +1 -1
  81. package/node/debug/functions/draw-elem/draw-tight-bounding-box.js.map +1 -1
  82. package/node/debug/functions/draw-elem/draw-two-prong.js.map +1 -1
  83. package/node/debug/functions/draw-elem/draw-vertex.js.map +1 -1
  84. package/node/debug/functions/general.js.map +1 -1
  85. package/node/find-2-prong/add-1-prong.js.map +1 -1
  86. package/node/find-2-prong/cull-bezier-pieces.d.ts +4 -4
  87. package/node/find-2-prong/cull-bezier-pieces.js +9 -9
  88. package/node/find-2-prong/cull-bezier-pieces.js.map +1 -1
  89. package/node/find-2-prong/find-2-prong.js +8 -8
  90. package/node/find-2-prong/find-2-prong.js.map +1 -1
  91. package/node/find-2-prong/find-equidistant-point-on-line-dd.js.map +1 -1
  92. package/node/find-2-prong/get-initial-bezier-pieces.d.ts +2 -2
  93. package/node/find-2-prong/get-initial-bezier-pieces.js +2 -2
  94. package/node/find-2-prong/get-initial-bezier-pieces.js.map +1 -1
  95. package/node/find-2-prong/reduce-radius.d.ts +1 -1
  96. package/node/find-2-prong/reduce-radius.js +5 -5
  97. package/node/find-2-prong/reduce-radius.js.map +1 -1
  98. package/node/find-3-prong.ts/calc-better-x.d.ts +2 -2
  99. package/node/find-3-prong.ts/calc-better-x.js +3 -3
  100. package/node/find-3-prong.ts/calc-better-x.js.map +1 -1
  101. package/node/find-3-prong.ts/calc-initial-3-prong-center.d.ts +2 -2
  102. package/node/find-3-prong.ts/calc-initial-3-prong-center.js +3 -3
  103. package/node/find-3-prong.ts/calc-initial-3-prong-center.js.map +1 -1
  104. package/node/find-3-prong.ts/find-3-prong-for-delta3s.d.ts +2 -2
  105. package/node/find-3-prong.ts/find-3-prong-for-delta3s.js +16 -16
  106. package/node/find-3-prong.ts/find-3-prong-for-delta3s.js.map +1 -1
  107. package/node/find-3-prong.ts/find-3-prong.js +2 -2
  108. package/node/find-3-prong.ts/find-3-prong.js.map +1 -1
  109. package/node/find-3-prong.ts/find-and-add-3-prong.js.map +1 -1
  110. package/node/find-3-prong.ts/find-and-add-3-prongs.js.map +1 -1
  111. package/node/find-3-prong.ts/get-closest-points.d.ts +2 -2
  112. package/node/find-3-prong.ts/get-closest-points.js +4 -4
  113. package/node/find-3-prong.ts/get-closest-points.js.map +1 -1
  114. package/node/find-mat/find-mats.js.map +1 -1
  115. package/node/geometry/get-closest-square-distance-to-rect.js.map +1 -1
  116. package/node/geometry/get-closest-squared-distance-to-rotated-rect.js.map +1 -1
  117. package/node/index.d.ts +35 -1
  118. package/node/index.js +36 -1
  119. package/node/index.js.map +1 -1
  120. package/node/mat/create-new-cp-tree.js.map +1 -1
  121. package/node/mat/get-boundary-piece-beziers.js +7 -7
  122. package/node/mat/get-boundary-piece-beziers.js.map +1 -1
  123. package/node/mat/get-largest-vertex.js.map +1 -1
  124. package/node/mat/trim-mat.js.map +1 -1
  125. package/node/memoize-primitive.js.map +1 -1
  126. package/node/sat/add-debug-info.js.map +1 -1
  127. package/node/sat/cull.d.ts +7 -5
  128. package/node/sat/cull.js +7 -4
  129. package/node/sat/cull.js.map +1 -1
  130. package/node/sat/get-leaves.js.map +1 -1
  131. package/node/sat/to-scale-axis.d.ts +3 -2
  132. package/node/sat/to-scale-axis.js +3 -2
  133. package/node/sat/to-scale-axis.js.map +1 -1
  134. package/node/svg/get-loop-bounds.js.map +1 -1
  135. package/node/svg/get-min-y-pos.js.map +1 -1
  136. package/node/sweep-line/sweep-line.js.map +1 -1
  137. package/package.json +6 -6
  138. package/src/add-n-prong.ts/join-spokes.ts +11 -11
  139. package/src/closest-boundary-point/cull-bezier-pieces.ts +12 -11
  140. package/src/closest-boundary-point/cull-by-loose-bounding-box.ts +8 -8
  141. package/src/closest-boundary-point/cull-by-tight-boundary-box.ts +8 -8
  142. package/src/closest-boundary-point/dd-deflate-with-running-error.ts +22 -22
  143. package/src/closest-boundary-point/get-best-distance-squared.ts +6 -6
  144. package/src/closest-boundary-point/get-close-boundary-points-certified.ts +41 -41
  145. package/src/contact-point/contact-point.ts +13 -13
  146. package/src/corner/get-corner.ts +39 -39
  147. package/src/corner/get-interface-ccw.ts +3 -3
  148. package/src/cp-node/cp-node-fs.ts +132 -135
  149. package/src/cp-node/cp-node.ts +30 -30
  150. package/src/cp-node/fs/clone.ts +4 -4
  151. package/src/cp-node/fs/cp-node-comparator.ts +13 -0
  152. package/src/cp-node/fs/find-first.ts +6 -6
  153. package/src/cp-node/fs/get-all-on-loop.ts +1 -1
  154. package/src/cp-node/fs/get-boundary-bezier-parts-to-next.ts +12 -18
  155. package/src/cp-node/fs/get-boundary-beziers-between.ts +6 -7
  156. package/src/cp-node/fs/get-boundary-beziers-to-next.ts +79 -53
  157. package/src/cp-node/fs/get-branch-beziers.ts +1 -1
  158. package/src/cp-node/fs/get-branch.ts +1 -1
  159. package/src/cp-node/fs/get-children.ts +8 -8
  160. package/src/cp-node/fs/get-first-exit.ts +11 -11
  161. package/src/cp-node/fs/get-mat-curve-to-next.ts +1 -1
  162. package/src/cp-node/fs/get-mat-curves-between.ts +1 -1
  163. package/src/cp-node/fs/get-prong-count.ts +8 -8
  164. package/src/cp-node/fs/get-real-prong-count.ts +3 -3
  165. package/src/cp-node/fs/get-salience.ts +2 -2
  166. package/src/cp-node/fs/get-speed.ts +1 -6
  167. package/src/cp-node/fs/get-vertex-forward-children.ts +10 -10
  168. package/src/cp-node/fs/is-fully-terminating.ts +3 -3
  169. package/src/cp-node/fs/is-one-prong.ts +8 -8
  170. package/src/cp-node/fs/is-sharp.ts +1 -1
  171. package/src/cp-node/fs/is-terminating.ts +1 -1
  172. package/src/cp-node/fs/iterate-all-on-loop.ts +6 -6
  173. package/src/cp-node/fs/traverse-all-forward.ts +11 -11
  174. package/src/cp-node/fs/traverse-cp.ts +19 -17
  175. package/src/cp-node/fs/traverse-edges.ts +10 -10
  176. package/src/cp-node/fs/traverse-vertices.ts +17 -17
  177. package/src/curve/curve.ts +26 -26
  178. package/src/debug/functions/cmp-cp-on-delta.ts +1 -1
  179. package/src/debug/functions/draw-elem/bounding-hull.ts +2 -2
  180. package/src/debug/functions/draw-elem/culls.ts +2 -2
  181. package/src/debug/functions/draw-elem/draw-cp-node.ts +30 -30
  182. package/src/debug/functions/draw-elem/draw-cull.ts +2 -2
  183. package/src/debug/functions/draw-elem/draw-dull-corner.ts +7 -7
  184. package/src/debug/functions/draw-elem/draw-elem.ts +28 -28
  185. package/src/debug/functions/draw-elem/draw-leaves.ts +12 -12
  186. package/src/debug/functions/draw-elem/draw-loose-bounding-box.ts +7 -7
  187. package/src/debug/functions/draw-elem/draw-max-vertex.ts +2 -2
  188. package/src/debug/functions/draw-elem/draw-min-y.ts +2 -2
  189. package/src/debug/functions/draw-elem/draw-one-prong-at-dull-corner.ts +1 -1
  190. package/src/debug/functions/draw-elem/draw-one-prong.ts +1 -1
  191. package/src/debug/functions/draw-elem/draw-sharp-corner.ts +6 -6
  192. package/src/debug/functions/draw-elem/draw-speed.ts +2 -2
  193. package/src/debug/functions/draw-elem/draw-three-prong.ts +28 -28
  194. package/src/debug/functions/draw-elem/draw-tight-bounding-box.ts +4 -4
  195. package/src/debug/functions/draw-elem/draw-two-prong.ts +51 -51
  196. package/src/debug/functions/draw-elem/draw-vertex.ts +12 -12
  197. package/src/debug/functions/draw-elem/dull-corner.ts +7 -7
  198. package/src/debug/functions/draw-elem/leaves.ts +2 -2
  199. package/src/debug/functions/draw-elem/loose-bounding-box.ts +7 -7
  200. package/src/debug/functions/draw-elem/max-vertex.ts +2 -2
  201. package/src/debug/functions/draw-elem/min-y.ts +2 -2
  202. package/src/debug/functions/draw-elem/one-prong-at-dull-corner.ts +1 -1
  203. package/src/debug/functions/draw-elem/one-prong.ts +1 -1
  204. package/src/debug/functions/draw-elem/sharp-corner.ts +6 -6
  205. package/src/debug/functions/draw-elem/three-prong.ts +19 -19
  206. package/src/debug/functions/draw-elem/tight-bounding-box.ts +4 -4
  207. package/src/debug/functions/draw-elem/two-prong.ts +44 -44
  208. package/src/debug/functions/draw-elem/vertex.ts +28 -28
  209. package/src/debug/functions/general.ts +18 -18
  210. package/src/debug/functions/three-prong.ts +184 -184
  211. package/src/debug/functions/two-prong.ts +201 -201
  212. package/src/debug/two-prong-for-debugging.ts +26 -26
  213. package/src/find-2-prong/add-1-prong.ts +25 -25
  214. package/src/find-2-prong/add-debug-info.ts +38 -38
  215. package/src/find-2-prong/cull-bezier-pieces.ts +10 -10
  216. package/src/find-2-prong/find-2-prong.ts +158 -158
  217. package/src/find-2-prong/find-equidistant-point-on-line-dd.ts +50 -50
  218. package/src/find-2-prong/find-equidistant-point-on-line.ts +27 -27
  219. package/src/find-2-prong/get-initial-bezier-pieces.ts +2 -2
  220. package/src/find-2-prong/reduce-radius.ts +5 -5
  221. package/src/find-3-prong.ts/calc-better-x.ts +3 -3
  222. package/src/find-3-prong.ts/calc-initial-3-prong-center.ts +3 -3
  223. package/src/find-3-prong.ts/find-3-prong-for-delta3s.ts +17 -17
  224. package/src/find-3-prong.ts/find-3-prong.ts +23 -23
  225. package/src/find-3-prong.ts/find-and-add-3-prong.ts +37 -37
  226. package/src/find-3-prong.ts/find-and-add-3-prongs.ts +30 -30
  227. package/src/find-3-prong.ts/get-closest-points.ts +4 -4
  228. package/src/find-mat/add-2-prongs-by-error.ts +8 -8
  229. package/src/find-mat/find-mats.ts +49 -49
  230. package/src/find-mat/fix-ordering.ts +2 -2
  231. package/src/find-mat/get-total-by.ts +12 -12
  232. package/src/geometry/get-closest-square-distance-to-rect.ts +37 -37
  233. package/src/geometry/get-closest-squared-distance-to-rotated-rect.ts +14 -14
  234. package/src/get-curve/get-curve-between.ts +1 -1
  235. package/src/index.ts +41 -4
  236. package/src/mat/cmp-cp-on-delta.ts +1 -1
  237. package/src/mat/create-new-cp-tree.ts +12 -12
  238. package/src/mat/get-boundary-piece-beziers.ts +7 -7
  239. package/src/mat/get-edges-as-array.ts +9 -9
  240. package/src/mat/get-largest-3-prong.ts +8 -8
  241. package/src/mat/get-largest-three-prong.ts +5 -5
  242. package/src/mat/get-largest-vertex.ts +6 -6
  243. package/src/mat/get-two-prong-type.ts +9 -9
  244. package/src/mat/trim-mat.ts +1 -1
  245. package/src/memoize-primitive.ts +14 -14
  246. package/src/sat/add-debug-info.ts +4 -4
  247. package/src/sat/cull-by-salience.ts +1 -1
  248. package/src/sat/cull.ts +10 -7
  249. package/src/sat/get-leaves.ts +0 -1
  250. package/src/sat/to-scale-axis.ts +18 -17
  251. package/src/svg/get-extreme.ts +8 -8
  252. package/src/svg/get-loop-bounds.ts +84 -84
  253. package/src/svg/get-min-y-pos.ts +1 -1
  254. package/src/sweep-line/sweep-line.ts +23 -23
  255. package/src/utils/bezier-piece-to-bezier.ts +7 -7
  256. package/__tests__/cp-node/fs/check-jsog-eql-calc.spec.ts +0 -30
  257. package/node/cp-node/fs/cp-nodes-to-boundary-beziers.d.ts +0 -3
  258. package/node/cp-node/fs/cp-nodes-to-boundary-beziers.js +0 -6
  259. package/node/cp-node/fs/cp-nodes-to-boundary-beziers.js.map +0 -1
  260. package/src/closest-boundary-point/get-closest-boundary-point-certified.ts +0 -70
  261. package/src/cp-node/fs/cp-nodes-to-boundary-beziers.ts +0 -10
package/src/index.ts CHANGED
@@ -1,8 +1,8 @@
1
1
 
2
- export { loopFromBeziers, beziersToSvgPathStr, getPathsFromStr } from 'flo-boolean';
2
+ export { loopFromBeziers, beziersToSvgPathStr, getPathsFromStr } from 'flo-boolean';
3
3
 
4
4
  export type { MatMeta } from './mat/mat-meta.js';
5
- export type { Loop } from 'flo-boolean';
5
+ export type { Loop } from 'flo-boolean';
6
6
  export type { Mat } from './mat/mat.js';
7
7
  export type { Curve } from './curve/curve.js';
8
8
  export type { CpNode } from './cp-node/cp-node.js';
@@ -39,7 +39,6 @@ export { sweepLine } from './sweep-line/sweep-line.js';
39
39
  export { getClosestSquareDistanceToRect } from './geometry/get-closest-square-distance-to-rect.js';
40
40
  export { connectHoleClosers } from './mat/connect-hole-closers.js';
41
41
  export { findAndAdd2Prong } from './find-2-prong/find-and-add-2-prong.js';
42
- export { getBoundaryBeziersToNext } from './cp-node/fs/get-boundary-beziers-to-next.js';
43
42
  export { getImpliedBoundaryBezierBetween } from './cp-node/fs/get-implied-boundary-bezier-between.js';
44
43
  export { getSatCulls } from './sat/get-sat-culls.js';
45
44
  export { getGraph } from './floyd-warshall/get-graph.js';
@@ -50,4 +49,42 @@ export { getFor2ProngsOnLoop } from './find-mat/get-for-2-prongs-on-loop.js';
50
49
  export { getPotentialClosestPointsOnCurveCertified } from './closest-boundary-point/get-potential-closest-points-on-curve-certified.js';
51
50
  export { getCloseBoundaryPointsCertified } from './closest-boundary-point/get-close-boundary-points-certified.js';
52
51
  export { getPartialMeta, getPointToCpNode } from './find-mat/get-meta.js';
53
- export { findAndAddHoleClosing2Prongs } from './find-2-prong/find-and-add-hole-closing-2-prongs.js';
52
+ export { findAndAddHoleClosing2Prongs } from './find-2-prong/find-and-add-hole-closing-2-prongs.js';
53
+
54
+
55
+ // CpNodeFs functions
56
+ export { getChildren } from './cp-node/fs/get-children.js';
57
+ export { getVertexForwardChildren } from './cp-node/fs/get-vertex-forward-children.js';
58
+ export { getAllOnLoop } from './cp-node/fs/get-all-on-loop.js';
59
+ export { getAllOnCircle } from './cp-node/fs/get-all-on-circle.js';
60
+ export { isOnSameCircle } from './cp-node/fs/is-on-same-circle.js';
61
+ export { isTerminating } from './cp-node/fs/is-terminating.js';
62
+ export { isFullyTerminating } from './cp-node/fs/is-fully-terminating.js';
63
+ export { getFirstExit } from './cp-node/fs/get-first-exit.js';
64
+ export { isSharp } from './cp-node/fs/is-sharp.js';
65
+ export { isOneProng } from './cp-node/fs/is-one-prong.js';
66
+ export { getProngCount } from './cp-node/fs/get-prong-count.js';
67
+ export { getRealProngCount } from './cp-node/fs/get-real-prong-count.js';
68
+ export { cpNodeComparator } from './cp-node/fs/cp-node-comparator.js';
69
+ export { enhanceCpNode } from './cp-node/fs/enhance-cp-node.js';
70
+ export { traverseCp } from './cp-node/fs/traverse-cp.js';
71
+ export { traverseEdges } from './cp-node/fs/traverse-edges.js';
72
+ export { traverseVertices } from './cp-node/fs/traverse-vertices.js';
73
+ export { clone } from './cp-node/fs/clone.js';
74
+ export { getBoundaryBezierPartsToNext } from './cp-node/fs/get-boundary-bezier-parts-to-next.js';
75
+ export { getBoundaryBeziersToNext } from './cp-node/fs/get-boundary-beziers-to-next.js';
76
+ export { removeVertex } from './vertex/remove-vertex.js';
77
+ export { getMatCurveToNext } from './cp-node/fs/get-mat-curve-to-next.js';
78
+ export { isTwoProng } from './cp-node/fs/is-two-prong.js';
79
+ export { getBranch } from './cp-node/fs/get-branch.js';
80
+ export { getBranchBeziers } from './cp-node/fs/get-branch-beziers.js';
81
+ export { getSalience } from './cp-node/fs/get-salience.js';
82
+ export { getMatCurveBetween } from './cp-node/fs/get-mat-curve-between.js';
83
+ export { getEdgeDirection } from './cp-node/fs/get-edge-direction.js';
84
+ export { getBoundaryBeziersBetween } from './cp-node/fs/get-boundary-beziers-between.js';
85
+ export { getMatCurvesBetween } from './cp-node/fs/get-mat-curves-between.js';
86
+ export { getHoleClosers } from './cp-node/fs/get-hole-closers.js';
87
+ export { getSpeed } from './cp-node/fs/get-speed.js';
88
+ export { getSmoothedSpeed$ } from './cp-node/fs/get-smoothed-speed.js';
89
+ export { getInitialDegAngleBetweenMatCurves } from './cp-node/fs/get-angle-between-mat-curves.js';
90
+ export { getAllVertices } from './cp-node/fs/get-all-vertices.js';
@@ -45,7 +45,7 @@ function cmpCpOnδ(
45
45
  }
46
46
 
47
47
  if (cmpPrev === 0 || cmpNext === 0) {
48
- console.log('2-PRONG orders are equal.');
48
+ console.log('2-PRONG orders are equal.');
49
49
  return 0;
50
50
  }
51
51
 
@@ -11,21 +11,21 @@ const { cpNodeComparator, getAllOnLoop } = CpNodeFs;
11
11
  * @param cpNode
12
12
  */
13
13
  function createNewCpTree(cpNode: CpNode) {
14
- const newCpTrees: Map<Loop,LlRbTree<CpNode>> = new Map();
14
+ const newCpTrees: Map<Loop,LlRbTree<CpNode>> = new Map();
15
15
 
16
- getAllOnLoop(cpNode).forEach(createNewCpTree_);
16
+ getAllOnLoop(cpNode).forEach(createNewCpTree_);
17
17
 
18
- function createNewCpTree_(cpNode: CpNode) {
19
- const loop = cpNode.cp.pointOnShape.curve.loop;
20
- let cpTree = newCpTrees.get(loop);
21
- if (!cpTree) {
22
- cpTree = new LlRbTree(cpNodeComparator, false);
23
- newCpTrees.set(loop, cpTree);
24
- }
25
- cpTree.insert(cpNode);
26
- }
18
+ function createNewCpTree_(cpNode: CpNode) {
19
+ const loop = cpNode.cp.pointOnShape.curve.loop;
20
+ let cpTree = newCpTrees.get(loop);
21
+ if (!cpTree) {
22
+ cpTree = new LlRbTree(cpNodeComparator, false);
23
+ newCpTrees.set(loop, cpTree);
24
+ }
25
+ cpTree.insert(cpNode);
26
+ }
27
27
 
28
- return newCpTrees;
28
+ return newCpTrees;
29
29
  }
30
30
 
31
31
 
@@ -17,7 +17,7 @@ function getBoundaryPieceBeziers(cpNodes: CpNode[]): CurvePiece[] {
17
17
  let cpThis = cpNodes[0];
18
18
  const cpEnd = cpNodes[1];
19
19
 
20
- const bezierPieces: CurvePiece[] = [];
20
+ const curvePieces: CurvePiece[] = [];
21
21
 
22
22
  // As opposed to going around the circle and taking the last exit
23
23
  let goStraight = true;
@@ -41,17 +41,17 @@ function getBoundaryPieceBeziers(cpNodes: CpNode[]): CurvePiece[] {
41
41
  } else if (posNext.curve === posThis.curve &&
42
42
  compareCps(cpThis.next.cp, cpThis.cp) > 0) {
43
43
 
44
- bezierPieces.push(
44
+ curvePieces.push(
45
45
  { curve: posThis.curve, ts: [posThis.t, posNext.t] }
46
46
  );
47
47
  } else {
48
- bezierPieces.push(
48
+ curvePieces.push(
49
49
  { curve: posThis.curve, ts: [posThis.t, 1] }
50
50
  );
51
51
 
52
52
  if (posThis.curve.loop === posNext.curve.loop) {
53
53
  addSkippedBeziers(
54
- bezierPieces,
54
+ curvePieces,
55
55
  posThis.curve,
56
56
  posNext.curve,
57
57
  posNext.t
@@ -63,7 +63,7 @@ function getBoundaryPieceBeziers(cpNodes: CpNode[]): CurvePiece[] {
63
63
  } while (cpThis !== cpEnd);
64
64
 
65
65
 
66
- return bezierPieces;
66
+ return curvePieces;
67
67
  }
68
68
 
69
69
 
@@ -72,7 +72,7 @@ function getBoundaryPieceBeziers(cpNodes: CpNode[]): CurvePiece[] {
72
72
  * Adds pieces of skipped beziers
73
73
  */
74
74
  function addSkippedBeziers(
75
- bezierPieces: CurvePiece[],
75
+ curvePieces: CurvePiece[],
76
76
  curveStart: Curve,
77
77
  curveEnd: Curve,
78
78
  t1: number) {
@@ -81,7 +81,7 @@ function addSkippedBeziers(
81
81
  do {
82
82
  curveThis = curveThis.next;
83
83
  const tEnd = curveThis === curveEnd ? t1 : 1;
84
- bezierPieces.push({ curve: curveThis, ts: [0, tEnd] });
84
+ curvePieces.push({ curve: curveThis, ts: [0, tEnd] });
85
85
  } while (curveThis !== curveEnd);
86
86
  }
87
87
 
@@ -3,15 +3,15 @@
3
3
 
4
4
 
5
5
  // /** @internal */
6
- // function getEdgesAsArray(cpNode: CpNode) {
7
- // const cpNodes: CpNode[] = [];
8
-
9
- // traverseEdges(
10
- // cpNode,
11
- // function(cpNode) { cpNodes.push(cpNode) }
12
- // );
13
-
14
- // return cpNodes;
6
+ // function getEdgesAsArray(cpNode: CpNode) {
7
+ // const cpNodes: CpNode[] = [];
8
+
9
+ // traverseEdges(
10
+ // cpNode,
11
+ // function(cpNode) { cpNodes.push(cpNode) }
12
+ // );
13
+
14
+ // return cpNodes;
15
15
  // }
16
16
 
17
17
 
@@ -5,16 +5,16 @@ import { getRealProngCount } from '../cp-node/fs/get-real-prong-count.js';
5
5
 
6
6
  /** @internal */
7
7
  function getLargest3Prong(cpNode: CpNode) {
8
- const cpNodes = getAllOnLoop(cpNode)
9
- .filter(cpNode => getRealProngCount(cpNode) >= 3);
8
+ const cpNodes = getAllOnLoop(cpNode)
9
+ .filter(cpNode => getRealProngCount(cpNode) >= 3);
10
10
 
11
- if (cpNodes.length === 0) { return undefined; }
11
+ if (cpNodes.length === 0) { return undefined; }
12
12
 
13
- return cpNodes.reduce(function(maxCpNode: CpNode, cpNode: CpNode) {
14
- return maxCpNode.cp.circle.radius >= cpNode.cp.circle.radius
15
- ? maxCpNode
16
- : cpNode
17
- }, cpNodes[0]);
13
+ return cpNodes.reduce(function(maxCpNode: CpNode, cpNode: CpNode) {
14
+ return maxCpNode.cp.circle.radius >= cpNode.cp.circle.radius
15
+ ? maxCpNode
16
+ : cpNode
17
+ }, cpNodes[0]);
18
18
  }
19
19
 
20
20
 
@@ -3,11 +3,11 @@ import { CpNode } from '../cp-node/cp-node.js';
3
3
 
4
4
  /** @internal */
5
5
  function getLargestThreeProng(cpNodes: CpNode[]) {
6
- return cpNodes.reduce(function(maxCpNode: CpNode, cpNode: CpNode) {
7
- return cpNode === undefined || maxCpNode.cp.circle.radius >= cpNode.cp.circle.radius
8
- ? maxCpNode
9
- : cpNode;
10
- }, undefined!);
6
+ return cpNodes.reduce(function(maxCpNode: CpNode, cpNode: CpNode) {
7
+ return cpNode === undefined || maxCpNode.cp.circle.radius >= cpNode.cp.circle.radius
8
+ ? maxCpNode
9
+ : cpNode;
10
+ }, undefined!);
11
11
  }
12
12
 
13
13
 
@@ -4,13 +4,13 @@ import { getAllOnLoop } from '../cp-node/fs/get-all-on-loop.js';
4
4
 
5
5
  /** @internal */
6
6
  function getLargestVertex(cpNode: CpNode) {
7
- const cpNodes = getAllOnLoop(cpNode);
7
+ const cpNodes = getAllOnLoop(cpNode);
8
8
 
9
- return cpNodes.reduce(function(maxCpNode: CpNode, cpNode: CpNode) {
10
- return maxCpNode.cp.circle.radius >= cpNode.cp.circle.radius
11
- ? maxCpNode
12
- : cpNode
13
- }, cpNodes[0]);
9
+ return cpNodes.reduce(function(maxCpNode: CpNode, cpNode: CpNode) {
10
+ return maxCpNode.cp.circle.radius >= cpNode.cp.circle.radius
11
+ ? maxCpNode
12
+ : cpNode
13
+ }, cpNodes[0]);
14
14
  }
15
15
 
16
16
 
@@ -1,13 +1,13 @@
1
- import { TwoProngForDebugging } from '../debug/two-prong-for-debugging.js';
2
- import { ElemType_TwoProng } from './elem-type-two-prong.js';
1
+ // import { TwoProngForDebugging } from '../debug/two-prong-for-debugging.js';
2
+ // import { ElemType_TwoProng } from './elem-type-two-prong.js';
3
3
 
4
4
 
5
- /** @internal */
6
- function getTwoProngType(e: TwoProngForDebugging): ElemType_TwoProng {
7
- if (e.holeClosing) { return 'twoProng_holeClosing' }
8
-
9
- return 'twoProng_regular';
10
- }
5
+ // /** @internal */
6
+ // function getTwoProngType(e: TwoProngForDebugging): ElemType_TwoProng {
7
+ // if (e.holeClosing) { return 'twoProng_holeClosing' }
8
+
9
+ // return 'twoProng_regular';
10
+ // }
11
11
 
12
12
 
13
- export { getTwoProngType }
13
+ // export { getTwoProngType }
@@ -10,7 +10,7 @@ import { clone } from '../cp-node/fs/clone.js';
10
10
  * @param mat The MAT to trim.
11
11
  */
12
12
  function trimMat(mat: Mat): Mat {
13
- const cpNode = cullNonCycles(clone(mat.cpNode));
13
+ const cpNode = cullNonCycles(clone(mat.cpNode));
14
14
 
15
15
  if (!cpNode) { return undefined!; }
16
16
 
@@ -10,21 +10,21 @@
10
10
  * prevent garbage collection, rather use `memoize` instead
11
11
  */
12
12
  function memoizePrimitive<T, U>(f: (a: T) => U): (a: T) => U {
13
- const results = new Map<T,U>();
14
-
15
- return function(a: T): U {
16
- let result = results.get(a);
17
- if (result !== undefined) {
18
- //console.log('cache hit');
19
- return result;
20
- }
13
+ const results = new Map<T,U>();
14
+
15
+ return function(a: T): U {
16
+ let result = results.get(a);
17
+ if (result !== undefined) {
18
+ //console.log('cache hit');
19
+ return result;
20
+ }
21
21
 
22
- //console.log('cache miss');
23
- result = f(a);
24
- results.set(a, result);
25
-
26
- return result;
27
- }
22
+ //console.log('cache miss');
23
+ result = f(a);
24
+ results.set(a, result);
25
+
26
+ return result;
27
+ }
28
28
  }
29
29
 
30
30
 
@@ -8,12 +8,12 @@ import { Debug } from '../debug/debug.js';
8
8
  * @param sat
9
9
  */
10
10
  function addDebugInfo(
11
- timingStart: number) {
11
+ timingStart: number) {
12
12
 
13
- if (typeof _debug_ === 'undefined') { return; }
13
+ if (typeof _debug_ === 'undefined') { return; }
14
14
 
15
- const timing = _debug_.generated.timing;
16
- timing.sats = performance.now() - timingStart;
15
+ const timing = _debug_.generated.timing;
16
+ timing.sats = performance.now() - timingStart;
17
17
  }
18
18
 
19
19
 
@@ -75,7 +75,7 @@ function cullBySalience(
75
75
  cpNode: cpNodeT,
76
76
  meta: {
77
77
  ...mat.meta,
78
- cpTrees: createNewCpTree(cpNodeT)
78
+ cpTrees: createNewCpTree(cpNodeT)
79
79
  }
80
80
  };
81
81
 
package/src/sat/cull.ts CHANGED
@@ -1,16 +1,17 @@
1
- import { Circle } from '../geometry/circle.js';
1
+ import type { CpNode } from '../cp-node/cp-node.js';
2
+ import type { DualSet } from '../utils/dual-set.js';
2
3
  import { getLeaves } from './get-leaves.js';
3
- import { CpNode } from '../cp-node/cp-node.js';
4
4
  import { CpNodeFs } from '../cp-node/cp-node-fs.js';
5
5
  import { isTerminating } from '../cp-node/fs/is-terminating.js';
6
- import { DualSet, DualSetFs } from '../utils/dual-set.js';
6
+ import { DualSetFs } from '../utils/dual-set.js';
7
7
 
8
8
  const { isOnSameCircle } = CpNodeFs;
9
9
 
10
10
 
11
11
  /**
12
+ * Returns the set of non-trivial forward edges starting from the given `CpNode`.
12
13
  *
13
- * @param cpStart
14
+ * @param cpStart the start `CpNode`
14
15
  */
15
16
  function getNonTrivialForwardEdges(cpStart: CpNode) {
16
17
  let cpNode = cpStart;
@@ -32,12 +33,14 @@ function getNonTrivialForwardEdges(cpStart: CpNode) {
32
33
 
33
34
 
34
35
  /**
35
- * @internal
36
36
  * Returns the set of Vertices passing the following test: walk the MAT tree and
37
37
  * keep all Vertices not in the current cull set and any Vertices that have a
38
38
  * non-culled node further down the line toward the tree leaves.
39
- * @param culls The CpNodes (referred to by circles) that should be culled.
40
- * @param maxCpNode The start CpNode which must reprsesent the maximal vertex.
39
+ *
40
+ * @param culls the `CpNode`s (referred to by circles) that should be culled
41
+ * @param maxCpNode the start `CpNode` which must represent the maximal vertex
42
+ *
43
+ * @internal
41
44
  */
42
45
  function cull(
43
46
  culls: DualSet<number, number>,
@@ -1,7 +1,6 @@
1
1
  import { CpNode } from '../cp-node/cp-node.js';
2
2
  import { CpNodeFs } from '../cp-node/cp-node-fs.js';
3
3
  import { isFullyTerminating } from '../cp-node/fs/is-fully-terminating.js';
4
- import { getRealProngCount } from '../cp-node/fs/get-real-prong-count.js';
5
4
 
6
5
  const { getAllOnLoop } = CpNodeFs;
7
6
 
@@ -12,43 +12,44 @@ import { getSatCulls } from './get-sat-culls.js';
12
12
 
13
13
 
14
14
  /**
15
- * Apply and returns an enhanced version of the Scale Axis Transform (SAT) to
16
- * the given MAT. The returned SAT is guaranteed to be a subset of the MAT and
15
+ * Apply and returns an enhanced version of the Scale Axis Transform (SAT) to
16
+ * the given MAT. The returned SAT is guaranteed to be a subset of the MAT and
17
17
  * preserves topology at any scale.
18
18
  *
19
19
  * Typically the MAT contains too many branches caused by minute details on the
20
20
  * boundary of the shape. The SAT is a simplification of the MAT that preserves
21
21
  * less detail the higher the applied scale factor. The severity at which noise
22
22
  * are removed depends on the local scale of the shape.
23
- * @param mat The Medial Axis Transform (`Mat`) on which to apply the SAT.
24
- * @param s The scale factor >= 1 (e.g. 1.3)
23
+ *
24
+ * @param mat the Medial Axis Transform (MAT) on which to apply the SAT
25
+ * @param s the scale factor >= 1 (e.g. 1.3)
25
26
  */
26
27
  function toScaleAxis(
27
- mat: Mat,
28
- s: number): Mat {
28
+ mat: Mat,
29
+ s: number): Mat {
29
30
 
30
- let timingStart = 0;
31
- if (typeof _debug_ !== 'undefined') {
32
- timingStart = performance.now();
33
- }
31
+ let timingStart = 0;
32
+ if (typeof _debug_ !== 'undefined') {
33
+ timingStart = performance.now();
34
+ }
34
35
 
35
- const cpNode = getLargestVertex(clone(mat.cpNode));
36
- const culls = getSatCulls(cpNode, s);
36
+ const cpNode = getLargestVertex(clone(mat.cpNode));
37
+ const culls = getSatCulls(cpNode, s);
37
38
 
38
- cull(culls, cpNode);
39
+ cull(culls, cpNode);
39
40
 
40
- const sat: Mat = {
41
+ const sat: Mat = {
41
42
  cpNode: cpNode,
42
43
  meta: {
43
44
  ...mat.meta,
44
- cpTrees: createNewCpTree(cpNode)
45
+ cpTrees: createNewCpTree(cpNode)
45
46
  }
46
47
  };
47
48
 
48
49
 
49
- addDebugInfo(timingStart);
50
+ addDebugInfo(timingStart);
50
51
 
51
- return sat;
52
+ return sat;
52
53
  }
53
54
 
54
55
 
@@ -9,14 +9,14 @@ import { getShapeBounds } from './get-shape-bounds.js';
9
9
  * @param loops
10
10
  */
11
11
  function getExtreme(loops: Loop[]) {
12
- const bounds = getShapeBounds(loops);
13
-
14
- return Math.max(
15
- Math.abs(bounds.minX.p[0]),
16
- Math.abs(bounds.minY.p[1]),
17
- Math.abs(bounds.maxX.p[0]),
18
- Math.abs(bounds.maxY.p[1])
19
- );
12
+ const bounds = getShapeBounds(loops);
13
+
14
+ return Math.max(
15
+ Math.abs(bounds.minX.p[0]),
16
+ Math.abs(bounds.minY.p[1]),
17
+ Math.abs(bounds.maxX.p[0]),
18
+ Math.abs(bounds.maxY.p[1])
19
+ );
20
20
  }
21
21
 
22
22