flo-mat 4.1.5 → 5.0.1

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 (356) hide show
  1. package/__tests__/closest-boundary-point/get-endpoint-info.spec.ts +140 -0
  2. package/__tests__/closest-boundary-point/root-interval-to-distance-squared-interval.spec.ts +87 -0
  3. package/__tests__/cp-node/fs/get-all-on-loop-by-loop.spec.ts +55 -0
  4. package/__tests__/cp-node/fs/get-angle-between-mat-curves.spec.ts +39 -3
  5. package/__tests__/cp-node/fs/get-boundary-bezier-parts-to-next.spec.ts +87 -3
  6. package/__tests__/cp-node/fs/get-boundary-beziers-between.spec.ts +68 -3
  7. package/__tests__/cp-node/fs/get-boundary-beziers-to-next.spec.ts +41 -3
  8. package/__tests__/cp-node/fs/get-boundary-distance-to-next.spec.ts +20 -3
  9. package/__tests__/cp-node/fs/get-branch-beziers.spec.ts +42 -3
  10. package/__tests__/cp-node/fs/get-branch.spec.ts +60 -3
  11. package/__tests__/cp-node/fs/get-cp-node-ordering.spec.ts +19 -3
  12. package/__tests__/cp-node/fs/get-distance-to-next.spec.ts +37 -4
  13. package/__tests__/cp-node/fs/get-edge-direction.spec.ts +50 -3
  14. package/__tests__/cp-node/fs/get-first-exit.spec.ts +78 -3
  15. package/__tests__/cp-node/fs/get-hole-closers.spec.ts +32 -3
  16. package/__tests__/cp-node/fs/get-implied-boundary-bezier-between.spec.ts +48 -3
  17. package/__tests__/cp-node/fs/get-mat-curve-between.spec.ts +77 -3
  18. package/__tests__/cp-node/fs/get-mat-curve-to-next.spec.ts +17 -4
  19. package/__tests__/cp-node/fs/get-mat-curves-between.spec.ts +38 -3
  20. package/__tests__/cp-node/fs/get-salience.spec.ts +68 -3
  21. package/__tests__/cp-node/fs/get-vertex-forward-children.spec.ts +40 -3
  22. package/__tests__/cp-node/fs/insert-cp-node.spec.ts +87 -3
  23. package/__tests__/cp-node/fs/is-special.spec.ts +1 -1
  24. package/__tests__/cp-node/fs/remove-cp-node.spec.ts +42 -3
  25. package/__tests__/find-2-prong/calc-seperation-tolerance.spec.ts +46 -0
  26. package/__tests__/find-2-prong/get-medial/get-closest-points.spec.ts +1 -1
  27. package/__tests__/floyd-warshall/get-graph.spec.ts +100 -0
  28. package/__tests__/get-mats-with-hole.ts +28 -0
  29. package/__tests__/get-mats1.spec.ts +61 -0
  30. package/__tests__/get-mats1.ts +75 -67
  31. package/__tests__/helpers/cp-node-by-id.ts +27 -0
  32. package/__tests__/helpers/expect-point-close.ts +42 -0
  33. package/__tests__/mat/hausdorff-distance-one-sided-exceeds.spec.ts +129 -0
  34. package/__tests__/mat/simplify-mat.spec.ts +85 -0
  35. package/__tests__/reconstruct-from-mat/reconstruct-from-mat.spec.ts +39 -0
  36. package/__tests__/specific-cases/test-svgs/achispado.svg +14 -0
  37. package/__tests__/utils/get-beziers-from-tangents.spec.ts +142 -0
  38. package/browser/index.js +13944 -10307
  39. package/browser/index.min.js +1 -1
  40. package/node/closest-boundary-point/cull-curve-pieces.d.ts +21 -0
  41. package/node/closest-boundary-point/cull-curve-pieces.js +40 -0
  42. package/node/closest-boundary-point/cull-curve-pieces.js.map +1 -0
  43. package/node/closest-boundary-point/get-close-boundary-points-certified.js +5 -2
  44. package/node/closest-boundary-point/get-close-boundary-points-certified.js.map +1 -1
  45. package/node/closest-boundary-point/get-endpoint-info.d.ts +39 -0
  46. package/node/closest-boundary-point/get-endpoint-info.js +78 -0
  47. package/node/closest-boundary-point/get-endpoint-info.js.map +1 -0
  48. package/node/closest-boundary-point/get-potential-closest-points-on-curve-certified.js +5 -19
  49. package/node/closest-boundary-point/get-potential-closest-points-on-curve-certified.js.map +1 -1
  50. package/node/closest-boundary-point/root-interval-to-distance-squared-interval.d.ts +17 -5
  51. package/node/closest-boundary-point/root-interval-to-distance-squared-interval.js +37 -50
  52. package/node/closest-boundary-point/root-interval-to-distance-squared-interval.js.map +1 -1
  53. package/node/corner/get-corner.d.ts +18 -1
  54. package/node/corner/get-corner.js +8 -1
  55. package/node/corner/get-corner.js.map +1 -1
  56. package/node/corner/get-interface-ccw.js.map +1 -1
  57. package/node/cp-node/cp-node.d.ts +4 -3
  58. package/node/cp-node/fs/get-all-on-loop-by-loop.js +0 -4
  59. package/node/cp-node/fs/get-all-on-loop-by-loop.js.map +1 -1
  60. package/node/cp-node/fs/get-angle-between-mat-curves.js +6 -4
  61. package/node/cp-node/fs/get-angle-between-mat-curves.js.map +1 -1
  62. package/node/cp-node/fs/get-boundary-beziers-between.d.ts +6 -4
  63. package/node/cp-node/fs/get-boundary-beziers-between.js +6 -4
  64. package/node/cp-node/fs/get-boundary-beziers-between.js.map +1 -1
  65. package/node/cp-node/fs/get-branch-beziers.d.ts +2 -1
  66. package/node/cp-node/fs/get-branch-beziers.js +3 -2
  67. package/node/cp-node/fs/get-branch-beziers.js.map +1 -1
  68. package/node/cp-node/fs/get-branch.js +1 -2
  69. package/node/cp-node/fs/get-branch.js.map +1 -1
  70. package/node/cp-node/fs/get-distance-to-next.js +4 -2
  71. package/node/cp-node/fs/get-distance-to-next.js.map +1 -1
  72. package/node/cp-node/fs/get-first-exit.d.ts +7 -3
  73. package/node/cp-node/fs/get-first-exit.js +13 -11
  74. package/node/cp-node/fs/get-first-exit.js.map +1 -1
  75. package/node/cp-node/fs/get-implied-boundary-bezier-between.d.ts +9 -1
  76. package/node/cp-node/fs/get-implied-boundary-bezier-between.js +11 -55
  77. package/node/cp-node/fs/get-implied-boundary-bezier-between.js.map +1 -1
  78. package/node/cp-node/fs/get-mat-curve-between.d.ts +4 -3
  79. package/node/cp-node/fs/get-mat-curve-between.js +5 -49
  80. package/node/cp-node/fs/get-mat-curve-between.js.map +1 -1
  81. package/node/cp-node/fs/get-mat-curve-to-next.d.ts +1 -1
  82. package/node/cp-node/fs/get-mat-curves-between.d.ts +8 -0
  83. package/node/cp-node/fs/get-mat-curves-between.js +9 -2
  84. package/node/cp-node/fs/get-mat-curves-between.js.map +1 -1
  85. package/node/cp-node/fs/get-real-prong-count.d.ts +2 -1
  86. package/node/cp-node/fs/get-real-prong-count.js +11 -5
  87. package/node/cp-node/fs/get-real-prong-count.js.map +1 -1
  88. package/node/cp-node/fs/get-salience.d.ts +10 -0
  89. package/node/cp-node/fs/get-salience.js +17 -1
  90. package/node/cp-node/fs/get-salience.js.map +1 -1
  91. package/node/cp-node/fs/is-fully-terminating.d.ts +4 -2
  92. package/node/cp-node/fs/is-fully-terminating.js +6 -15
  93. package/node/cp-node/fs/is-fully-terminating.js.map +1 -1
  94. package/node/cp-node/fs/is-on-same-loop.d.ts +1 -1
  95. package/node/cp-node/fs/is-special.d.ts +7 -0
  96. package/node/cp-node/fs/is-special.js +9 -2
  97. package/node/cp-node/fs/is-special.js.map +1 -1
  98. package/node/cp-node/fs/is-vertex.d.ts +1 -1
  99. package/node/cp-node/fs/traverse-edges.d.ts +7 -3
  100. package/node/cp-node/fs/traverse-edges.js +7 -3
  101. package/node/cp-node/fs/traverse-edges.js.map +1 -1
  102. package/node/cp-node/stringification/from-stringifyable.d.ts +2 -2
  103. package/node/cp-node/stringification/from-stringifyable.js +1 -1
  104. package/node/cp-node/stringification/from-stringifyable.js.map +1 -1
  105. package/node/cp-node/stringification/to-stringifyable.d.ts +3 -3
  106. package/node/cp-node/stringification/to-stringifyable.js +3 -3
  107. package/node/debug/debug.d.ts +26 -3
  108. package/node/debug/debug.js +16 -5
  109. package/node/debug/debug.js.map +1 -1
  110. package/node/find-2-prong/add-2-prong.js +1 -7
  111. package/node/find-2-prong/add-2-prong.js.map +1 -1
  112. package/node/find-2-prong/calc-seperation-tolerance.d.ts +28 -5
  113. package/node/find-2-prong/calc-seperation-tolerance.js +32 -89
  114. package/node/find-2-prong/calc-seperation-tolerance.js.map +1 -1
  115. package/node/find-2-prong/find-2-prong.js +8 -10
  116. package/node/find-2-prong/find-2-prong.js.map +1 -1
  117. package/node/find-2-prong/find-and-add-2-prongs.js +2 -2
  118. package/node/find-2-prong/find-and-add-2-prongs.js.map +1 -1
  119. package/node/find-2-prong/get-medial/get-antipodal-points.d.ts +1 -2
  120. package/node/find-2-prong/get-medial/get-antipodal-points.js +2 -3
  121. package/node/find-2-prong/get-medial/get-antipodal-points.js.map +1 -1
  122. package/node/find-2-prong/get-medial/get-closest-points.d.ts +1 -8
  123. package/node/find-2-prong/get-medial/get-closest-points.js +4 -40
  124. package/node/find-2-prong/get-medial/get-closest-points.js.map +1 -1
  125. package/node/find-2-prong/reduce-radius.d.ts +1 -1
  126. package/node/find-2-prong/reduce-radius.js +6 -3
  127. package/node/find-2-prong/reduce-radius.js.map +1 -1
  128. package/node/find-3-prong/calc-better-x.js +1 -1
  129. package/node/find-3-prong/calc-better-x.js.map +1 -1
  130. package/node/find-3-prong/find-3-prong-for-delta3s.d.ts +3 -2
  131. package/node/find-3-prong/find-3-prong-for-delta3s.js +35 -41
  132. package/node/find-3-prong/find-3-prong-for-delta3s.js.map +1 -1
  133. package/node/find-3-prong/find-3-prong.js +3 -1
  134. package/node/find-3-prong/find-3-prong.js.map +1 -1
  135. package/node/find-3-prong/find-and-add-3-prongs.js +16 -0
  136. package/node/find-3-prong/find-and-add-3-prongs.js.map +1 -1
  137. package/node/find-mat/create-initial-cp-tree.js +2 -2
  138. package/node/find-mat/create-initial-cp-tree.js.map +1 -1
  139. package/node/find-mat/find-mat.js +3 -4
  140. package/node/find-mat/find-mat.js.map +1 -1
  141. package/node/find-mat/find-mats.d.ts +6 -12
  142. package/node/find-mat/find-mats.js +10 -27
  143. package/node/find-mat/find-mats.js.map +1 -1
  144. package/node/find-mat/get-dull-corners-on-loop.js +2 -2
  145. package/node/find-mat/get-dull-corners-on-loop.js.map +1 -1
  146. package/node/find-mat/get-for-1-prongs-on-loop.js +36 -8
  147. package/node/find-mat/get-for-1-prongs-on-loop.js.map +1 -1
  148. package/node/find-mat/get-meta.d.ts +14 -4
  149. package/node/find-mat/get-meta.js +30 -24
  150. package/node/find-mat/get-meta.js.map +1 -1
  151. package/node/find-mat/get-sharp-corners.js +2 -2
  152. package/node/find-mat/get-sharp-corners.js.map +1 -1
  153. package/node/find-mat/mat-options.d.ts +2 -2
  154. package/node/floyd-warshall/get-graph.d.ts +12 -1
  155. package/node/floyd-warshall/get-graph.js +41 -38
  156. package/node/floyd-warshall/get-graph.js.map +1 -1
  157. package/node/geometry/get-bounding-box-.d.ts +16 -2
  158. package/node/geometry/get-bounding-box-.js +5 -2
  159. package/node/geometry/get-bounding-box-.js.map +1 -1
  160. package/node/geometry/get-closest-square-distance-to-rect.d.ts +3 -0
  161. package/node/geometry/get-closest-square-distance-to-rect.js +7 -5
  162. package/node/geometry/get-closest-square-distance-to-rect.js.map +1 -1
  163. package/node/geometry/get-closest-squared-distance-to-rotated-rect.d.ts +4 -0
  164. package/node/geometry/get-closest-squared-distance-to-rotated-rect.js +11 -5
  165. package/node/geometry/get-closest-squared-distance-to-rotated-rect.js.map +1 -1
  166. package/node/get-medial-points/double-double/dd-get-medial-point-coeffs-bez3.js +1 -2
  167. package/node/get-medial-points/double-double/dd-get-medial-point-coeffs-bez3.js.map +1 -1
  168. package/node/index.d.ts +3 -2
  169. package/node/index.js +2 -1
  170. package/node/index.js.map +1 -1
  171. package/node/mat/clone-mat.d.ts +9 -0
  172. package/node/mat/clone-mat.js +17 -0
  173. package/node/mat/clone-mat.js.map +1 -0
  174. package/node/mat/clone-meta.d.ts +12 -0
  175. package/node/mat/clone-meta.js +24 -0
  176. package/node/mat/clone-meta.js.map +1 -0
  177. package/node/mat/get-boundary-piece-beziers.d.ts +5 -0
  178. package/node/mat/get-boundary-piece-beziers.js +7 -93
  179. package/node/mat/get-boundary-piece-beziers.js.map +1 -1
  180. package/node/mat/get-largest-3-prong.d.ts +6 -0
  181. package/node/mat/get-largest-3-prong.js +8 -5
  182. package/node/mat/get-largest-3-prong.js.map +1 -1
  183. package/node/mat/get-largest-vertex.d.ts +15 -1
  184. package/node/mat/get-largest-vertex.js +20 -7
  185. package/node/mat/get-largest-vertex.js.map +1 -1
  186. package/node/mat/hausdorff-distance-one-sided-exceeds.d.ts +79 -0
  187. package/node/mat/hausdorff-distance-one-sided-exceeds.js +251 -0
  188. package/node/mat/hausdorff-distance-one-sided-exceeds.js.map +1 -0
  189. package/node/mat/mat-meta.d.ts +0 -6
  190. package/node/mat/simplify-mat.d.ts +25 -8
  191. package/node/mat/simplify-mat.js +182 -53
  192. package/node/mat/simplify-mat.js.map +1 -1
  193. package/node/mat/trim-mat.d.ts +4 -2
  194. package/node/mat/trim-mat.js +3 -1
  195. package/node/mat/trim-mat.js.map +1 -1
  196. package/node/point-on-shape/get-boundary-tangent-line.d.ts +19 -0
  197. package/node/point-on-shape/get-boundary-tangent-line.js +33 -0
  198. package/node/point-on-shape/get-boundary-tangent-line.js.map +1 -0
  199. package/node/point-on-shape/get-osculating-circle.d.ts +6 -4
  200. package/node/point-on-shape/get-osculating-circle.js +6 -4
  201. package/node/point-on-shape/get-osculating-circle.js.map +1 -1
  202. package/node/point-on-shape/get-pos-corner.js +2 -2
  203. package/node/point-on-shape/get-pos-corner.js.map +1 -1
  204. package/node/reconstruct-from-mat/reconstruct-from-mat.js +20 -80
  205. package/node/reconstruct-from-mat/reconstruct-from-mat.js.map +1 -1
  206. package/node/reconstruct-from-mat/remove-sat-induced-trivial-3prongs.d.ts +4 -0
  207. package/node/reconstruct-from-mat/remove-sat-induced-trivial-3prongs.js +4 -0
  208. package/node/reconstruct-from-mat/remove-sat-induced-trivial-3prongs.js.map +1 -1
  209. package/node/sat/cull.d.ts +7 -6
  210. package/node/sat/cull.js +13 -16
  211. package/node/sat/cull.js.map +1 -1
  212. package/node/sat/get-sat-culls.d.ts +12 -2
  213. package/node/sat/get-sat-culls.js +21 -16
  214. package/node/sat/get-sat-culls.js.map +1 -1
  215. package/node/svg/get-shape-bounds.d.ts +1 -12
  216. package/node/svg/get-shape-bounds.js +2 -3
  217. package/node/svg/get-shape-bounds.js.map +1 -1
  218. package/node/sweep-line/sweep-line.js.map +1 -1
  219. package/node/utils/get-beziers-from-tangents.d.ts +28 -0
  220. package/node/utils/get-beziers-from-tangents.js +92 -0
  221. package/node/utils/get-beziers-from-tangents.js.map +1 -0
  222. package/node/vertex/remove-vertex.d.ts +5 -3
  223. package/node/vertex/remove-vertex.js +5 -3
  224. package/node/vertex/remove-vertex.js.map +1 -1
  225. package/package.json +8 -8
  226. package/qv-infinite-loop.md +120 -0
  227. package/src/closest-boundary-point/cull-curve-pieces.ts +49 -0
  228. package/src/closest-boundary-point/get-close-boundary-points-certified.ts +5 -2
  229. package/src/closest-boundary-point/get-endpoint-info.ts +96 -0
  230. package/src/closest-boundary-point/get-potential-closest-points-on-curve-certified.ts +5 -23
  231. package/src/closest-boundary-point/root-interval-to-distance-squared-interval.ts +42 -60
  232. package/src/corner/get-corner.ts +10 -1
  233. package/src/corner/get-interface-ccw.ts +2 -2
  234. package/src/cp-node/cp-node.ts +4 -3
  235. package/src/cp-node/fs/get-all-on-loop-by-loop.ts +0 -4
  236. package/src/cp-node/fs/get-angle-between-mat-curves.ts +6 -4
  237. package/src/cp-node/fs/get-boundary-beziers-between.ts +10 -8
  238. package/src/cp-node/fs/get-branch-beziers.ts +3 -2
  239. package/src/cp-node/fs/get-branch.ts +1 -2
  240. package/src/cp-node/fs/get-distance-to-next.ts +4 -2
  241. package/src/cp-node/fs/get-first-exit.ts +15 -14
  242. package/src/cp-node/fs/get-implied-boundary-bezier-between.ts +17 -69
  243. package/src/cp-node/fs/get-mat-curve-between.ts +9 -67
  244. package/src/cp-node/fs/get-mat-curves-between.ts +9 -2
  245. package/src/cp-node/fs/get-real-prong-count.ts +11 -7
  246. package/src/cp-node/fs/get-salience.ts +15 -2
  247. package/src/cp-node/fs/is-fully-terminating.ts +6 -18
  248. package/src/cp-node/fs/is-on-same-loop.ts +2 -2
  249. package/src/cp-node/fs/is-special.ts +11 -6
  250. package/src/cp-node/fs/is-vertex.ts +1 -1
  251. package/src/cp-node/fs/traverse-edges.ts +8 -4
  252. package/src/cp-node/stringification/from-stringifyable.ts +75 -75
  253. package/src/cp-node/stringification/to-stringifyable.ts +3 -3
  254. package/src/debug/debug.ts +44 -8
  255. package/src/find-2-prong/add-2-prong.ts +2 -9
  256. package/src/find-2-prong/calc-seperation-tolerance.ts +34 -115
  257. package/src/find-2-prong/find-2-prong.ts +9 -11
  258. package/src/find-2-prong/find-and-add-2-prongs.ts +2 -2
  259. package/src/find-2-prong/get-medial/get-antipodal-points.ts +1 -3
  260. package/src/find-2-prong/get-medial/get-closest-points.ts +6 -51
  261. package/src/find-2-prong/reduce-radius.ts +6 -4
  262. package/src/find-3-prong/calc-better-x.ts +2 -2
  263. package/src/find-3-prong/find-3-prong-for-delta3s.ts +197 -214
  264. package/src/find-3-prong/find-3-prong.ts +54 -51
  265. package/src/find-3-prong/find-and-add-3-prongs.ts +20 -1
  266. package/src/find-mat/create-initial-cp-tree.ts +2 -2
  267. package/src/find-mat/find-mat.ts +4 -6
  268. package/src/find-mat/find-mats.ts +83 -105
  269. package/src/find-mat/get-dull-corners-on-loop.ts +2 -2
  270. package/src/find-mat/get-for-1-prongs-on-loop.ts +40 -8
  271. package/src/find-mat/get-meta.ts +34 -39
  272. package/src/find-mat/get-sharp-corners.ts +2 -2
  273. package/src/find-mat/mat-options.ts +2 -2
  274. package/src/floyd-warshall/get-graph.ts +46 -47
  275. package/src/geometry/get-bounding-box-.ts +5 -2
  276. package/src/geometry/get-closest-square-distance-to-rect.ts +7 -7
  277. package/src/geometry/get-closest-squared-distance-to-rotated-rect.ts +12 -10
  278. package/src/get-medial-points/double-double/dd-get-medial-point-coeffs-bez3.ts +1 -2
  279. package/src/index.ts +3 -2
  280. package/src/mat/clone-mat.ts +9 -3
  281. package/src/mat/clone-meta.ts +8 -0
  282. package/src/mat/get-boundary-piece-beziers.ts +16 -117
  283. package/src/mat/get-largest-3-prong.ts +9 -6
  284. package/src/mat/get-largest-vertex.ts +25 -9
  285. package/src/mat/hausdorff-distance-one-sided-exceeds.ts +314 -0
  286. package/src/mat/mat-meta.ts +0 -9
  287. package/src/mat/simplify-mat.ts +254 -116
  288. package/src/mat/trim-mat.ts +6 -4
  289. package/src/point-on-shape/get-boundary-tangent-line.ts +36 -0
  290. package/src/point-on-shape/get-osculating-circle.ts +7 -5
  291. package/src/point-on-shape/get-pos-corner.ts +2 -2
  292. package/src/reconstruct-from-mat/reconstruct-from-mat.ts +22 -111
  293. package/src/reconstruct-from-mat/remove-sat-induced-trivial-3prongs.ts +4 -0
  294. package/src/sat/cull.ts +16 -20
  295. package/src/sat/get-sat-culls.ts +28 -23
  296. package/src/svg/get-shape-bounds.ts +2 -3
  297. package/src/sweep-line/sweep-line.ts +1 -1
  298. package/src/utils/get-beziers-from-tangents.ts +110 -0
  299. package/src/utils/map-map.ts +1 -1
  300. package/src/vertex/remove-vertex.ts +5 -3
  301. package/__tests__/cp-node/fs/get-distance-between.spec.ts +0 -7
  302. package/__tests__/cp-node/fs/get-terminating-on-circle.spec.ts +0 -24
  303. package/__tests__/cp-node/fs/is-single-3-prong.spec.ts +0 -17
  304. package/__tests__/cp-node/fs/iterate-all-on-loop.spec.ts +0 -17
  305. package/__tests__/cp-node/fs/traverse-all-forward.spec.ts +0 -14
  306. package/node/closest-boundary-point/cull-bezier-pieces-1.d.ts +0 -9
  307. package/node/closest-boundary-point/cull-bezier-pieces-1.js +0 -17
  308. package/node/closest-boundary-point/cull-bezier-pieces-1.js.map +0 -1
  309. package/node/closest-boundary-point/cull-by-loose-bounding-box.d.ts +0 -13
  310. package/node/closest-boundary-point/cull-by-loose-bounding-box.js +0 -27
  311. package/node/closest-boundary-point/cull-by-loose-bounding-box.js.map +0 -1
  312. package/node/closest-boundary-point/cull-by-tight-boundary-box.d.ts +0 -11
  313. package/node/closest-boundary-point/cull-by-tight-boundary-box.js +0 -27
  314. package/node/closest-boundary-point/cull-by-tight-boundary-box.js.map +0 -1
  315. package/node/cp-node/fs/find-first.d.ts +0 -10
  316. package/node/cp-node/fs/find-first.js +0 -19
  317. package/node/cp-node/fs/find-first.js.map +0 -1
  318. package/node/debug/functions/check-ordering.d.ts +0 -4
  319. package/node/debug/functions/check-ordering.js +0 -43
  320. package/node/debug/functions/check-ordering.js.map +0 -1
  321. package/node/find-2-prong/cull-bezier-pieces.d.ts +0 -13
  322. package/node/find-2-prong/cull-bezier-pieces.js +0 -43
  323. package/node/find-2-prong/cull-bezier-pieces.js.map +0 -1
  324. package/node/floyd-warshall/get-hole-closer-pairs.d.ts +0 -8
  325. package/node/floyd-warshall/get-hole-closer-pairs.js +0 -27
  326. package/node/floyd-warshall/get-hole-closer-pairs.js.map +0 -1
  327. package/node/utils/dual-set.d.ts +0 -27
  328. package/node/utils/dual-set.js +0 -55
  329. package/node/utils/dual-set.js.map +0 -1
  330. package/node/utils/tri-map.d.ts +0 -27
  331. package/node/utils/tri-map.js +0 -49
  332. package/node/utils/tri-map.js.map +0 -1
  333. package/src/closest-boundary-point/cull-bezier-pieces-1.ts +0 -36
  334. package/src/closest-boundary-point/cull-by-loose-bounding-box.ts +0 -42
  335. package/src/closest-boundary-point/cull-by-tight-boundary-box.ts +0 -43
  336. package/src/closest-boundary-point/get-p-from-box.ts +0 -14
  337. package/src/cp-node/fs/add-distance-from.ts +0 -49
  338. package/src/cp-node/fs/get-distance-between.ts +0 -16
  339. package/src/cp-node/fs/get-terminating-on-circle.ts +0 -24
  340. package/src/cp-node/fs/is-single-3-prong.ts +0 -15
  341. package/src/cp-node/fs/iterate-all-on-loop.ts +0 -15
  342. package/src/cp-node/fs/traverse-all-forward.ts +0 -24
  343. package/src/debug/functions/draw/draw-beziers-as-single-path.ts +0 -40
  344. package/src/debug/functions/draw/draw-disk.ts +0 -34
  345. package/src/debug/functions/draw/xmlns.ts +0 -5
  346. package/src/find-2-prong/cull-bezier-pieces.ts +0 -61
  347. package/src/find-2-prong/find-and-add-2-prong.ts +0 -30
  348. package/src/find-2-prong/get-medial/get-closest-points-d.ts +0 -213
  349. package/src/find-2-prong/x-for-debugging.ts +0 -13
  350. package/src/floyd-warshall/get-hole-closer-pairs.ts +0 -35
  351. package/src/mat/get-two-prong-type.ts +0 -13
  352. package/src/point-on-shape/is-pos-dull-corner.ts +0 -18
  353. package/src/point-on-shape/is-pos-quite-dull-corner.ts +0 -18
  354. package/src/point-on-shape/is-pos-quite-sharp-corner.ts +0 -18
  355. package/src/point-on-shape/pos-to-human-string.ts +0 -18
  356. package/src/sweep-line/are-boxes-intersecting.ts +0 -37
@@ -1,12 +1,13 @@
1
1
  import { getBranch } from './get-branch.js';
2
2
  import { getMatCurveToNext } from './get-mat-curve-to-next.js';
3
3
  /**
4
- * Returns the branch associated with the give cpNode
4
+ * Returns the (flattened) array of bezier curves (lines or quadratics)
5
+ * representing the branch associated with the given cpNode
5
6
  *
6
7
  * @param cpNode `CpNode` representing the start vertex.
7
8
  */
8
9
  function getBranchBeziers(cpNode) {
9
- return getBranch(cpNode).map(b => getMatCurveToNext(b));
10
+ return getBranch(cpNode).flatMap(getMatCurveToNext);
10
11
  }
11
12
  export { getBranchBeziers };
12
13
  //# sourceMappingURL=get-branch-beziers.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"get-branch-beziers.js","sourceRoot":"","sources":["../../../src/cp-node/fs/get-branch-beziers.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAG/D;;;;GAIG;AACH,SAAS,gBAAgB,CACjB,MAAc;IAElB,OAAO,SAAS,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,CAAC;AAC5D,CAAC;AAGD,OAAO,EAAE,gBAAgB,EAAE,CAAA"}
1
+ {"version":3,"file":"get-branch-beziers.js","sourceRoot":"","sources":["../../../src/cp-node/fs/get-branch-beziers.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAG/D;;;;;GAKG;AACH,SAAS,gBAAgB,CACjB,MAAc;IAElB,OAAO,SAAS,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC;AACxD,CAAC;AAGD,OAAO,EAAE,gBAAgB,EAAE,CAAA"}
@@ -1,5 +1,4 @@
1
1
  import { getRealProngCount } from './get-real-prong-count.js';
2
- import { isFullyTerminating } from './is-fully-terminating.js';
3
2
  import { isTerminating } from './is-terminating.js';
4
3
  import { isTrivial } from './is-trivial.js';
5
4
  /**
@@ -26,7 +25,7 @@ function getBranch(cpNode) {
26
25
  do {
27
26
  branch.push(cpNode);
28
27
  cpNode = cpNode.next;
29
- } while (!isFullyTerminating(cpNode) && getRealProngCount(cpNode) === 2);
28
+ } while (getRealProngCount(cpNode) === 2);
30
29
  return branch;
31
30
  }
32
31
  export { getBranch };
@@ -1 +1 @@
1
- {"version":3,"file":"get-branch.js","sourceRoot":"","sources":["../../../src/cp-node/fs/get-branch.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAG5C;;;;;;GAMG;AACH,SAAS,SAAS,CACV,MAAc;IAElB,IAAI,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC;QACpB,OAAO,EAAE,CAAC;IACd,CAAC;IAED,+BAA+B;IAC/B,OAAO,aAAa,CAAC,MAAM,CAAC,EAAE,CAAC;QAC3B,MAAM,GAAG,MAAM,CAAC,YAAY,CAAC;IACjC,CAAC;IAED,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC;IACrB,OAAO,iBAAiB,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;QACrC,MAAM,GAAG,MAAM,CAAC,IA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BAAiB,CAAC,MAAM,CAAC,KAAK,CAAC,EAAC;IAEzC,OAAO,MAAM,CAAC;AAClB,CAAC;AAGD,OAAO,EAAE,SAAS,EAAE,CAAA"}
@@ -2,8 +2,10 @@ import { totalLength } from "flo-bezier3";
2
2
  import { memoize } from "flo-memoize";
3
3
  import { getMatCurveToNext } from "./get-mat-curve-to-next.js";
4
4
  function getMatDistanceToNext(cpNode) {
5
- const ps = getMatCurveToNext(cpNode);
6
- const l = totalLength(ps);
5
+ let l = 0;
6
+ for (const ps of getMatCurveToNext(cpNode)) {
7
+ l += totalLength(ps);
8
+ }
7
9
  return l;
8
10
  }
9
11
  const getMatDistanceToNext$ = memoize(getMatDistanceToNext);
@@ -1 +1 @@
1
- {"version":3,"file":"get-distance-to-next.js","sourceRoot":"","sources":["../../../src/cp-node/fs/get-distance-to-next.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAEtC,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAG/D,SAAS,oBAAoB,CACrB,MAAc;IAElB,MAAM,EAAE,GAAG,iBAAiB,CAAC,MAAM,CAAC,CAAC;IACrC,MAAM,CAAC,GAAG,WAAW,CAAC,EAAE,CAAC,CAAC;IAE1B,OAAO,CAAC,CAAC;AACb,CAAC;AAGD,MAAM,qBAAqB,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAA;AAE3D,OAAO,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,CAAA"}
1
+ {"version":3,"file":"get-distance-to-next.js","sourceRoot":"","sources":["../../../src/cp-node/fs/get-distance-to-next.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAEtC,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAG/D,SAAS,oBAAoB,CACrB,MAAc;IAElB,IAAI,CAAC,GAAG,CAAC,CAAC;IACV,KAAK,MAAM,EAAE,IAAI,iBAAiB,CAAC,MAAM,CAAC,EAAE,CAAC;QACzC,CAAC,IAAI,WAAW,CAAC,EAAE,CAAC,CAAC;IACzB,CAAC;IAED,OAAO,CAAC,CAAC;AACb,CAAC;AAGD,MAAM,qBAAqB,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAA;AAE3D,OAAO,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,CAAA"}
@@ -1,7 +1,11 @@
1
- import { CpNode } from "../cp-node.js";
1
+ import type { CpNode } from "../cp-node.js";
2
2
  /**
3
- * Returns the first `CpNode` (from this one by successively applying
4
- * .nextOnCircle) that exits the circle.
3
+ * Returns the first `CpNode` *after* the given one (by successively applying
4
+ * `.nextOnCircle`) that exits the circle, i.e. the first one that is not
5
+ * terminating - the given `CpNode` itself is never returned.
6
+ *
7
+ * * returns `undefined` if no other `CpNode` on the circle exits (e.g. the
8
+ * other `CpNode` of a 1-prong, or the MAT is a single point)
5
9
  */
6
10
  declare function getFirstExit(cpNode: CpNode): CpNode | undefined;
7
11
  export { getFirstExit };
@@ -1,19 +1,21 @@
1
+ import { isTerminating } from "./is-terminating.js";
1
2
  /**
2
- * Returns the first `CpNode` (from this one by successively applying
3
- * .nextOnCircle) that exits the circle.
3
+ * Returns the first `CpNode` *after* the given one (by successively applying
4
+ * `.nextOnCircle`) that exits the circle, i.e. the first one that is not
5
+ * terminating - the given `CpNode` itself is never returned.
6
+ *
7
+ * * returns `undefined` if no other `CpNode` on the circle exits (e.g. the
8
+ * other `CpNode` of a 1-prong, or the MAT is a single point)
4
9
  */
5
10
  function getFirstExit(cpNode) {
6
- // const startNode = this as CpNode;
7
- const startNode = cpNode;
8
- let cpNode_ = startNode;
9
- while (cpNode_.next === cpNode_.prevOnCircle) {
10
- cpNode_ = cpNode_.next;
11
- if (cpNode_ === startNode) {
12
- // The very special case the MAT is a single point.
13
- return undefined;
11
+ let cpNode_ = cpNode.nextOnCircle;
12
+ while (cpNode_ !== cpNode) {
13
+ if (!isTerminating(cpNode_)) {
14
+ return cpNode_;
14
15
  }
16
+ cpNode_ = cpNode_.nextOnCircle;
15
17
  }
16
- return cpNode_;
18
+ return undefined;
17
19
  }
18
20
  export { getFirstExit };
19
21
  //# sourceMappingURL=get-first-exit.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"get-first-exit.js","sourceRoot":"","sources":["../../../src/cp-node/fs/get-first-exit.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,SAAS,YAAY,CAAC,MAAc;IAChC,oCAAoC;IACpC,MAAM,SAAS,GAAG,MAAM,CAAC;IACzB,IAAI,OAAO,GAAG,SAAS,CAAC;IAExB,OAAO,OAAO,CAAC,IAAI,KAAK,OAAO,CAAC,YAAY,EAAE,CAAC;QAC3C,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;QAEvB,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;YACxB,mDAAmD;YACnD,OAAO,SAAS,CAAC;QACrB,CAAC;IACL,CAAC;IAED,OAAO,OAAO,CAAC;AACnB,CAAC;AAGD,OAAO,EAAE,YAAY,EAAE,CAAA"}
1
+ {"version":3,"file":"get-first-exit.js","sourceRoot":"","sources":["../../../src/cp-node/fs/get-first-exit.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAGpD;;;;;;;GAOG;AACH,SAAS,YAAY,CAAC,MAAc;IAChC,IAAI,OAAO,GAAG,MAAM,CAAC,YAAY,CAAC;IAElC,OAAO,OAAO,KAAK,MAAM,EAAE,CAAC;QACxB,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,EAAE,CAAC;YAC1B,OAAO,OAAO,CAAC;QACnB,CAAC;QACD,OAAO,GAAG,OAAO,CAAC,YAAY,CAAC;IACnC,CAAC;IAED,OAAO,SAAS,CAAC;AACrB,CAAC;AAGD,OAAO,EAAE,YAAY,EAAE,CAAA"}
@@ -1,3 +1,11 @@
1
1
  import type { CpNode } from '../cp-node.js';
2
- declare function getImpliedBoundaryBezierBetween(cpNodeA: CpNode, cpNodeB: CpNode): number[][] | undefined;
2
+ /**
3
+ * Returns the bezier curves (an array of 1 or 2 lines or quadratics joined
4
+ * smoothly) approximating the shape boundary between the contact points of
5
+ * two `CpNode`s.
6
+ *
7
+ * @param cpNodeA
8
+ * @param cpNodeB
9
+ */
10
+ declare function getImpliedBoundaryBezierBetween(cpNodeA: CpNode, cpNodeB: CpNode): number[][][];
3
11
  export { getImpliedBoundaryBezierBetween };
@@ -1,59 +1,15 @@
1
- import { tangent } from 'flo-bezier3';
2
- import { fromTo, dot, cross, translate, lineLineIntersection, toUnitVector } from 'flo-vector2d';
3
- const { abs } = Math;
4
- /** @internal */
5
- const TOLERANCE_ADD_2PRONG = 0.01;
6
- /** @internal */
7
- const TOLERANCE_USE_LINE = 0.0001; // else cubic
1
+ import { getBoundaryTangentLine } from '../../point-on-shape/get-boundary-tangent-line.js';
2
+ import { getBeziersFromTangents } from '../../utils/get-beziers-from-tangents.js';
3
+ /**
4
+ * Returns the bezier curves (an array of 1 or 2 lines or quadratics joined
5
+ * smoothly) approximating the shape boundary between the contact points of
6
+ * two `CpNode`s.
7
+ *
8
+ * @param cpNodeA
9
+ * @param cpNodeB
10
+ */
8
11
  function getImpliedBoundaryBezierBetween(cpNodeA, cpNodeB) {
9
- const posA = cpNodeA.pointOnShape;
10
- const posB = cpNodeB.pointOnShape;
11
- let { curve: curveA, p: pA, t: tA } = posA;
12
- let { curve: curveB, p: pB, t: tB } = posB;
13
- if (pA[0] === pB[0] && pA[1] === pB[1]) {
14
- return [pA];
15
- }
16
- if (tA === 1) {
17
- tA = 0;
18
- curveA = curveA.next;
19
- }
20
- if (tB === 0) {
21
- tB = 1;
22
- curveB = curveB.prev;
23
- }
24
- const { ps: psA } = curveA;
25
- const { ps: psB } = curveB;
26
- const lA = [pA, translate(pA)(toUnitVector(tangent(psA, tA)))];
27
- const lB = [pB, translate(pB)(toUnitVector(tangent(psB, tB)))];
28
- const mid = lineLineIntersection(lA, lB);
29
- const c = fromTo(pA, pB);
30
- let twisted;
31
- if (!mid) {
32
- twisted = true;
33
- }
34
- else {
35
- const a = fromTo(pA, mid);
36
- const b = fromTo(pB, mid);
37
- twisted = dot(a, c) < 0 || dot(b, c) > 0;
38
- }
39
- if (!twisted) {
40
- // drawFs.bezier(g, [pA, mid!, pB], 'thin10 pink nofill', 0)
41
- return [pA, mid, pB];
42
- }
43
- const w1 = fromTo(lA[0], lA[1]); // This is a unit vector
44
- const w2 = fromTo(lB[0], lB[1]); // This is a unit vector
45
- const d1 = abs(cross(c, w1)) / (3 * 3);
46
- const d2 = abs(cross(c, w2)) / (3 * 3);
47
- if (d1 > TOLERANCE_ADD_2PRONG || d2 > TOLERANCE_ADD_2PRONG) {
48
- // not within tolerance
49
- return undefined;
50
- }
51
- if (d1 > TOLERANCE_USE_LINE || d2 > TOLERANCE_USE_LINE) {
52
- // approximate with cubic bezier?
53
- return undefined; // add 2-prong
54
- }
55
- // Within tolerance - approximate with a straight line.
56
- return [pA, pB];
12
+ return getBeziersFromTangents(getBoundaryTangentLine(cpNodeA.pointOnShape, true), getBoundaryTangentLine(cpNodeB.pointOnShape, false));
57
13
  }
58
14
  export { getImpliedBoundaryBezierBetween };
59
15
  //# sourceMappingURL=get-implied-boundary-bezier-between.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"get-implied-boundary-bezier-between.js","sourceRoot":"","sources":["../../../src/cp-node/fs/get-implied-boundary-bezier-between.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,SAAS,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAEjG,MAAM,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AAGrB,gBAAgB;AAChB,M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B,IAAI,EAAE,GAAG,oBAAoB,EAAE,CAAC;QACzD,uBAAuB;QACvB,OAAO,SAAS,CAAC;IACrB,CAAC;IAED,IAAI,EAAE,GAAG,kBAAkB,IAAI,EAAE,GAAG,kBAAkB,EAAE,CAAC;QACrD,iCAAiC;QACjC,OAAO,SAAS,CAAC,CAAE,cAAc;IACrC,CAAC;IAED,uDAAuD;IACvD,OAAO,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;AACpB,CAAC;AAGD,OAAO,EAAE,+BAA+B,EAAE,CAAA"}
1
+ {"version":3,"file":"get-implied-boundary-bezier-between.js","sourceRoot":"","sources":["../../../src/cp-node/fs/get-implied-boundary-bezier-between.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,EAAE,MAAM,mDAAmD,CAAC;AAC3F,OAAO,EAAE,sBAAsB,EAAE,MAAM,0CAA0C,CAAC;AAGlF;;;;;;;GAOG;AACH,SAAS,+BAA+B,CAChC,OAAe,EACf,OAAe;IAEnB,OAAO,sBAAsB,CACzB,sBAAsB,CAAC,OAAO,CAAC,YAAY,EAAE,IAAI,CAAC,EAClD,sBAAsB,CAAC,OAAO,CAAC,YAAY,EAAE,KAAK,CAAC,CACtD,CAAC;AACN,CAAC;AAGD,OAAO,EAAE,+BAA+B,EAAE,CAAA"}
@@ -1,10 +1,11 @@
1
1
  import type { CpNode } from '../cp-node.js';
2
2
  /**
3
- * Returns the bezier curve from the maximal disk of one `CpNode` to another
4
- * `CpNode`'s maximal disk.
3
+ * Returns the bezier curves (an array of 1 or 2 lines or quadratics joined
4
+ * smoothly) from the maximal disk of one `CpNode` to another `CpNode`'s
5
+ * maximal disk.
5
6
  *
6
7
  * @param cpNodeFrom
7
8
  * @param cpNodeTo
8
9
  */
9
- declare function getMatCurveBetween(cpNodeFrom: CpNode, cpNodeTo: CpNode): number[][];
10
+ declare function getMatCurveBetween(cpNodeFrom: CpNode, cpNodeTo: CpNode): number[][][];
10
11
  export { getMatCurveBetween };
@@ -1,59 +1,15 @@
1
- import { fromTo as fromToVec, dot, cross, rotate90Degrees, interpolate, translate, lineLineIntersection } from 'flo-vector2d';
2
1
  import { getEdgeDirection } from './get-edge-direction.js';
3
- const { abs } = Math;
4
- /** @internal */
5
- const TOLERANCE_ADD_2PRONG = 0.01;
6
- /** @internal */
7
- const TOLERANCE_USE_LINE = 0.0001; // else cubic
2
+ import { getBeziersFromTangents } from '../../utils/get-beziers-from-tangents.js';
8
3
  /**
9
- * Returns the bezier curve from the maximal disk of one `CpNode` to another
10
- * `CpNode`'s maximal disk.
4
+ * Returns the bezier curves (an array of 1 or 2 lines or quadratics joined
5
+ * smoothly) from the maximal disk of one `CpNode` to another `CpNode`'s
6
+ * maximal disk.
11
7
  *
12
8
  * @param cpNodeFrom
13
9
  * @param cpNodeTo
14
10
  */
15
11
  function getMatCurveBetween(cpNodeFrom, cpNodeTo) {
16
- const fromCc = cpNodeFrom.pointOnShape.circle.center;
17
- const fromL = getEdgeDirection(cpNodeFrom);
18
- const toCc = cpNodeTo.pointOnShape.circle.center;
19
- const toL = getEdgeDirection(cpNodeTo.prevOnCircle);
20
- const mid = lineLineIntersection(fromL, toL);
21
- const c = fromToVec(fromCc, toCc);
22
- let twisted;
23
- if (!mid) {
24
- twisted = true;
25
- }
26
- else {
27
- const a = fromToVec(fromCc, mid);
28
- const b = fromToVec(toCc, mid);
29
- twisted = dot(a, c) < 0 || dot(b, c) > 0;
30
- }
31
- if (!twisted) {
32
- return [fromCc, mid, toCc];
33
- }
34
- const r = rotate90Degrees(c);
35
- const w1 = fromToVec(fromL[0], fromL[1]); // This is a unit vector
36
- const w2 = fromToVec(toL[0], toL[1]); // This is a unit vector
37
- const d1 = abs(cross(c, w1)) / (3 * 3);
38
- const d2 = abs(cross(c, w2)) / (3 * 3);
39
- if (d1 > TOLERANCE_ADD_2PRONG || d2 > TOLERANCE_ADD_2PRONG) {
40
- // FUTURE - not within tolerance - must add additional 2-prong
41
- return [fromCc, toCc];
42
- }
43
- if (d1 > TOLERANCE_USE_LINE || d2 > TOLERANCE_USE_LINE) {
44
- // approximate with cubic bezier
45
- const m1 = interpolate(fromCc, toCc, 1 / 3);
46
- const m2 = interpolate(fromCc, toCc, 2 / 3);
47
- const v1 = translate(r, m1);
48
- const v2 = translate(r, m2);
49
- const l1 = [m1, v1];
50
- const l2 = [m2, v2];
51
- const mid1 = lineLineIntersection(fromL, l1);
52
- const mid2 = lineLineIntersection(toL, l2);
53
- return [fromCc, mid1, mid2, toCc];
54
- }
55
- // Within tolerance - approximate with a straight line.
56
- return [fromCc, toCc];
12
+ return getBeziersFromTangents(getEdgeDirection(cpNodeFrom), getEdgeDirection(cpNodeTo.prevOnCircle));
57
13
  }
58
14
  export { getMatCurveBetween };
59
15
  //# sourceMappingURL=get-mat-curve-between.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"get-mat-curve-between.js","sourceRoot":"","sources":["../../../src/cp-node/fs/get-mat-curve-between.ts"],"names":[],"mappings":"AACA,OAAO,EACH,MAAM,IAAI,SAAS,EAAE,GAAG,EAAE,KAAK,EAAE,eAAe,EAAE,WAAW,EAAE,SAAS,EACxE,oBAAoB,EACvB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAE3D,MAAM,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AAGrB,gBAAgB;AAChB,MAAM,oBAAoB,GAAG,IAAI,CAAC;AAClC,gBAAgB;AAChB,MAAM,kBAAkB,GAAG,MAAM,CAAC,CAAC,aAAa;AAGhD;;;;;;GAMG;AACH,SAAS,kBAAkB,CACnB,UAAkB,EAClB,QAAgB;IAEpB,MAAM,MAAM,GAAG,UAAU,CAAC,YAAY,CAAC,MAAM,CAAC,MAAM,CAAC;IACrD,MAAM,KAAK,GAAG,gBAAgB,CAAC,UAAU,CAAC,CAAC;IAE3C,MAAM,IAAI,GAAG,QAAQ,CAAC,YAAY,CAAC,MAAM,CAAC,MAAM,CAAC;IACjD,MAAM,G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ACnB,UAAkB,EAClB,QAAgB;IAEpB,OAAO,sBAAsB,CACzB,gBAAgB,CAAC,UAAU,CAAC,EAC5B,gBAAgB,CAAC,QAAQ,CAAC,YAAY,CAAC,CAC1C,CAAC;AACN,CAAC;AAGD,OAAO,EAAE,kBAAkB,EAAE,CAAA"}
@@ -5,7 +5,7 @@ import { CpNode } from '../cp-node.js';
5
5
  * medial axis.
6
6
  * @param cpNode
7
7
  */
8
- declare function getMatCurveToNext(cpNode: CpNode): number[][];
8
+ declare function getMatCurveToNext(cpNode: CpNode): number[][][];
9
9
  declare const getMatCurveToNext$: typeof getMatCurveToNext & {
10
10
  readonly weakMapS: WeakMap<object, {
11
11
  readonly weakMap: WeakMap<object, any>;
@@ -1,3 +1,11 @@
1
1
  import { CpNode } from '../cp-node.js';
2
+ /**
3
+ * Returns the (flattened) array of bezier curves (lines or quadratics)
4
+ * representing the medial axis from one `CpNode` to another by following
5
+ * `next` repeatedly.
6
+ *
7
+ * @param cpNodeS
8
+ * @param cpNodeE
9
+ */
2
10
  declare function getMatCurvesBetween(cpNodeS: CpNode, cpNodeE: CpNode): number[][][];
3
11
  export { getMatCurvesBetween };
@@ -1,10 +1,17 @@
1
1
  import { getMatCurveBetween } from './get-mat-curve-between.js';
2
+ /**
3
+ * Returns the (flattened) array of bezier curves (lines or quadratics)
4
+ * representing the medial axis from one `CpNode` to another by following
5
+ * `next` repeatedly.
6
+ *
7
+ * @param cpNodeS
8
+ * @param cpNodeE
9
+ */
2
10
  function getMatCurvesBetween(cpNodeS, cpNodeE) {
3
11
  let cpNode = cpNodeS;
4
12
  const pss = [];
5
13
  while (cpNode !== cpNodeE) {
6
- const ps = getMatCurveBetween(cpNode, cpNode.next);
7
- pss.push(ps);
14
+ pss.push(...getMatCurveBetween(cpNode, cpNode.next));
8
15
  cpNode = cpNode.next;
9
16
  }
10
17
  return pss;
@@ -1 +1 @@
1
- {"version":3,"file":"get-mat-curves-between.js","sourceRoot":"","sources":["../../../src/cp-node/fs/get-mat-curves-between.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAGhE,SAAS,mBAAmB,CACpB,OAAe,EACf,OAAe;IAEnB,IAAI,MAAM,GAAG,OAAO,CAAC;IACrB,MAAM,GAAG,GAAiB,EAAE,CAAC;IAC7B,OAAO,MAAM,KAAK,OAAO,EAAE,CAAC;QACxB,MAAM,EAAE,GAAG,kBAAkB,CAAC,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC;QACnD,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAEb,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC;IACzB,CAAC;IAED,OAAO,GAAG,CAAC;AACf,CAAC;AAGD,OAAO,EAAE,mBAAmB,EAAE,CAAA"}
1
+ {"version":3,"file":"get-mat-curves-between.js","sourceRoot":"","sources":["../../../src/cp-node/fs/get-mat-curves-between.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAGhE;;;;;;;GAOG;AACH,SAAS,mBAAmB,CACpB,OAAe,EACf,OAAe;IAEnB,IAAI,MAAM,GAAG,OAAO,CAAC;IACrB,MAAM,GAAG,GAAiB,EAAE,CAAC;IAC7B,OAAO,MAAM,KAAK,OAAO,EAAE,CAAC;QACxB,GAAG,CAAC,IAAI,CAAC,GAAG,kBAAkB,CAAC,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;QAErD,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC;IACzB,CAAC;IAED,OAAO,GAAG,CAAC;AACf,CAAC;AAGD,OAAO,EAAE,mBAAmB,EAAE,CAAA"}
@@ -1,7 +1,8 @@
1
1
  import { CpNode } from "../cp-node.js";
2
2
  /**
3
3
  * Returns the number of contact points (up to planar coordinates) on the
4
- * maximal disk circle implied by this `CpNode`.
4
+ * maximal disk circle implied by this `CpNode`, i.e. the number of
5
+ * non-terminating `CpNode`s on its circle.
5
6
  *
6
7
  * See also `getProngCount`.
7
8
  */
@@ -1,15 +1,21 @@
1
- import { getAllOnCircle } from "./get-all-on-circle.js";
2
1
  import { isTerminating } from "./is-terminating.js";
3
2
  /**
4
3
  * Returns the number of contact points (up to planar coordinates) on the
5
- * maximal disk circle implied by this `CpNode`.
4
+ * maximal disk circle implied by this `CpNode`, i.e. the number of
5
+ * non-terminating `CpNode`s on its circle.
6
6
  *
7
7
  * See also `getProngCount`.
8
8
  */
9
9
  function getRealProngCount(cpNode) {
10
- const nonTerminatingCpNodes = getAllOnCircle(cpNode)
11
- .filter(cpNode => !isTerminating(cpNode));
12
- return nonTerminatingCpNodes.length;
10
+ let count = 0;
11
+ let cpNode_ = cpNode;
12
+ do {
13
+ if (!isTerminating(cpNode_)) {
14
+ count++;
15
+ }
16
+ cpNode_ = cpNode_.nextOnCircle;
17
+ } while (cpNode_ !== cpNode);
18
+ return count;
13
19
  }
14
20
  export { getRealProngCount };
15
21
  //# sourceMappingURL=get-real-prong-count.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"get-real-prong-count.js","sourceRoot":"","sources":["../../../src/cp-node/fs/get-real-prong-count.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAGpD;;;;;GAKG;AACH,SAAS,iBAAiB,CAAC,MAAc;IACrC,MAAM,qBAAqB,GAAG,cAAc,CAAC,MAAM,CAAC;SACnD,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC;IAE1C,OAAO,qBAAqB,CAAC,MAAM,CAAC;AACxC,CAAC;AAGD,OAAO,EAAE,iBAAiB,EAAE,CAAA"}
1
+ {"version":3,"file":"get-real-prong-count.js","sourceRoot":"","sources":["../../../src/cp-node/fs/get-real-prong-count.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAGpD;;;;;;GAMG;AACH,SAAS,iBAAiB,CAAC,MAAc;IACrC,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,IAAI,OAAO,GAAG,MAAM,CAAC;IACrB,GAAG,CAAC;QACA,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,EAAE,CAAC;YAAC,KAAK,EAAE,CAAC;QAAC,CAAC;QACzC,OAAO,GAAG,OAAO,CAAC,YAAY,CAAC;IACnC,CAAC,QAAQ,OAAO,KAAK,MAAM,EAAE;IAE7B,OAAO,KAAK,CAAC;AACjB,CAAC;AAGD,OAAO,EAAE,iBAAiB,EAAE,CAAA"}
@@ -1,6 +1,16 @@
1
1
  import type { CpNode } from "../cp-node.js";
2
2
  /**
3
+ * Returns the salience of the given `CpNode`: the ratio of the boundary length
4
+ * from its contact point forward to the next contact point on its circle to
5
+ * the straight distance between those two points.
6
+ *
7
+ * * `Infinity` if that stretch of boundary passes a hole closer
8
+ * * `0` if the two contact points coincide with no boundary in between (the
9
+ * terminating `CpNode` of a 1-prong) - the other `CpNode` of a 1-prong,
10
+ * whose stretch is the entire boundary, gives `Infinity`
11
+ *
3
12
  * See https://research.gold.ac.uk/id/eprint/31944/
13
+ *
4
14
  * @param cpNode
5
15
  */
6
16
  declare function getSalience(cpNode: CpNode): number;
@@ -3,7 +3,17 @@ import { totalLength } from "flo-bezier3";
3
3
  import { getBoundaryBeziersBetween } from "./get-boundary-beziers-between.js";
4
4
  import { sum } from '../../utils/sum.js';
5
5
  /**
6
+ * Returns the salience of the given `CpNode`: the ratio of the boundary length
7
+ * from its contact point forward to the next contact point on its circle to
8
+ * the straight distance between those two points.
9
+ *
10
+ * * `Infinity` if that stretch of boundary passes a hole closer
11
+ * * `0` if the two contact points coincide with no boundary in between (the
12
+ * terminating `CpNode` of a 1-prong) - the other `CpNode` of a 1-prong,
13
+ * whose stretch is the entire boundary, gives `Infinity`
14
+ *
6
15
  * See https://research.gold.ac.uk/id/eprint/31944/
16
+ *
7
17
  * @param cpNode
8
18
  */
9
19
  function getSalience(cpNode) {
@@ -14,7 +24,13 @@ function getSalience(cpNode) {
14
24
  const d = distanceBetween(bp1, bp2);
15
25
  const { pss, hasHoleCloser } = getBoundaryBeziersBetween(cpNode1, cpNode2);
16
26
  const s = sum(pss.map(ps => totalLength(ps)));
17
- return hasHoleCloser ? Infinity : s / d;
27
+ if (hasHoleCloser) {
28
+ return Infinity;
29
+ }
30
+ if (s === 0) {
31
+ return 0;
32
+ } // (avoids `0/0` for the 1-prong case)
33
+ return s / d;
18
34
  }
19
35
  export { getSalience };
20
36
  //# sourceMappingURL=get-salience.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"get-salience.js","sourceRoot":"","sources":["../../../src/cp-node/fs/get-salience.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,yBAAyB,EAAE,MAAM,mCAAmC,CAAC;AAC9E,OAAO,EAAE,GAAG,EAAE,MAAM,oBAAoB,CAAC;AAGzC;;;GAGG;AACH,SAAS,WAAW,CAAC,MAAc;IAC/B,MAAM,OAAO,GAAG,MAAM,CAAC;IACvB,MAAM,OAAO,GAAG,MAAM,CAAC,YAAY,CAAC;IACpC,MAAM,GAAG,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC;IACnC,MAAM,GAAG,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC;IAEnC,MAAM,CAAC,GAAG,eAAe,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IAEpC,MAAM,EAAE,GAAG,EAAE,aAAa,EAAE,GAAG,yBAAyB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAE3E,MAAM,CAAC,GAAG,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;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9 @@
1
1
  import type { CpNode } from "../cp-node.js";
2
2
  /**
3
- * Like `isTerminating` but only returns true if all `CpNode`s on the circle
4
- * (except this.prevOnCircle) is terminating.
3
+ * Like `isTerminating` but only returns `true` if all `CpNode`s on the circle
4
+ * (except possibly the one leading back, i.e. `this.prevOnCircle`) are
5
+ * terminating - i.e. the `CpNode` is terminating and its vertex has at most
6
+ * one real prong.
5
7
  */
6
8
  declare function isFullyTerminating(cpNode: CpNode): boolean;
7
9
  export { isFullyTerminating };
@@ -1,22 +1,13 @@
1
- import { getAllOnCircle } from "./get-all-on-circle.js";
1
+ import { getRealProngCount } from "./get-real-prong-count.js";
2
2
  import { isTerminating } from "./is-terminating.js";
3
- import { isTrivial } from "./is-trivial.js";
4
3
  /**
5
- * Like `isTerminating` but only returns true if all `CpNode`s on the circle
6
- * (except this.prevOnCircle) is terminating.
4
+ * Like `isTerminating` but only returns `true` if all `CpNode`s on the circle
5
+ * (except possibly the one leading back, i.e. `this.prevOnCircle`) are
6
+ * terminating - i.e. the `CpNode` is terminating and its vertex has at most
7
+ * one real prong.
7
8
  */
8
9
  function isFullyTerminating(cpNode) {
9
- if (!isTerminating(cpNode)) {
10
- return false;
11
- }
12
- if (isTrivial(cpNode)) {
13
- return true;
14
- }
15
- while (cpNode.prev === cpNode.prevOnCircle) {
16
- cpNode = cpNode.prev;
17
- }
18
- return getAllOnCircle(cpNode.prevOnCircle, true)
19
- .every(isTerminating);
10
+ return isTerminating(cpNode) && getRealProngCount(cpNode) <= 1;
20
11
  }
21
12
  export { isFullyTerminating };
22
13
  //# sourceMappingURL=is-fully-terminating.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"is-fully-terminating.js","sourceRoot":"","sources":["../../../src/cp-node/fs/is-fully-terminating.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAG5C;;;GAGG;AACH,SAAS,kBAAkB,CAAC,MAAc;IACtC,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,EAAE,CAAC;QACzB,OAAO,KAAK,CAAC;IACjB,CAAC;IAED,IAAI,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC;QACpB,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,OAAO,MAAM,CAAC,IAAI,KAAK,MAAM,CAAC,YAAY,EAAE,CAAC;QACzC,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC;IACzB,CAAC;IAED,OAAO,cAAc,CAAC,MAAM,CAAC,YAAY,EAAE,IAAI,CAAC;SAC3C,KAAK,CAAC,aAAa,CAAC,CAAC;AAC9B,CAAC;AAGD,OAAO,EAAE,kBAAkB,EAAE,CAAA"}
1
+ {"version":3,"file":"is-fully-terminating.js","sourceRoot":"","sources":["../../../src/cp-node/fs/is-fully-terminating.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAGpD;;;;;GAKG;AACH,SAAS,kBAAkB,CAAC,MAAc;IACtC,OAAO,aAAa,CAAC,MAAM,CAAC,IAAI,iBAAiB,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;AACnE,CAAC;AAGD,OAAO,EAAE,kBAAkB,EAAE,CAAA"}
@@ -1,3 +1,3 @@
1
- import type { CpNode } from "flo-mat";
1
+ import { CpNode } from "../cp-node.js";
2
2
  declare function isOnSameLoop(cpNode1: CpNode, cpNode2: CpNode): boolean;
3
3
  export { isOnSameLoop };
@@ -1,3 +1,10 @@
1
1
  import type { CpNode } from "../cp-node.js";
2
+ /**
3
+ * Returns `true` if the given `CpNode` is on a 'special' MAT vertex, i.e. one
4
+ * that is not a plain 2-prong: a leaf, a 3-prong (or higher) or a hole-closer.
5
+ *
6
+ * * these are the vertices that must be kept when simplifying the MAT and
7
+ * the vertices of the MAT seen as a graph
8
+ */
2
9
  declare function isSpecial(cpNode: CpNode): boolean;
3
10
  export { isSpecial };
@@ -1,7 +1,14 @@
1
1
  import { getRealProngCount } from "./get-real-prong-count.js";
2
+ /**
3
+ * Returns `true` if the given `CpNode` is on a 'special' MAT vertex, i.e. one
4
+ * that is not a plain 2-prong: a leaf, a 3-prong (or higher) or a hole-closer.
5
+ *
6
+ * * these are the vertices that must be kept when simplifying the MAT and
7
+ * the vertices of the MAT seen as a graph
8
+ */
2
9
  function isSpecial(cpNode) {
3
- return ((getRealProngCount(cpNode) !== 2) &&
4
- !cpNode.isHoleClosing);
10
+ return (getRealProngCount(cpNode) !== 2 ||
11
+ cpNode.isHoleClosing);
5
12
  }
6
13
  export { isSpecial };
7
14
  //# sourceMappingURL=is-special.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"is-special.js","sourceRoot":"","sources":["../../../src/cp-node/fs/is-special.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAG9D,SAAS,SAAS,CACV,MAAc;IAElB,OAAO,CACH,CAAC,iBAAiB,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACjC,CAAC,MAAM,CAAC,aAAa,CACxB,CAAA;AACL,CAAC;AAGD,OAAO,EAAE,SAAS,EAAE,CAAA"}
1
+ {"version":3,"file":"is-special.js","sourceRoot":"","sources":["../../../src/cp-node/fs/is-special.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAG9D;;;;;;GAMG;AACH,SAAS,SAAS,CAAC,MAAc;IAC7B,OAAO,CACH,iBAAiB,CAAC,MAAM,CAAC,KAAK,CAAC;QAC/B,MAAM,CAAC,aAAa,CACvB,CAAC;AACN,CAAC;AAGD,OAAO,EAAE,SAAS,EAAE,CAAA"}
@@ -1,3 +1,3 @@
1
- import { CpNode } from "../cp-node.js";
1
+ import type { CpNode } from "../cp-node.js";
2
2
  declare function isVertex(f: (cpNode: CpNode) => boolean): (cpNode: CpNode) => boolean;
3
3
  export { isVertex };
@@ -1,8 +1,12 @@
1
1
  import { CpNode } from '../cp-node.js';
2
2
  /**
3
- * Traverses all edges (depth first) of the given MAT tree starting at the given
4
- * vertex (represented by a `CpNode`).
5
- * @param cpNode Any `CpNode` representing the start vertex.
3
+ * Traverses all edges of the given MAT tree exactly once each, calling the
4
+ * callback for one of the two `CpNode`s representing each edge.
5
+ *
6
+ * * the edges are visited in boundary order starting from the given `CpNode`
7
+ * (not depth first)
8
+ *
9
+ * @param cpNode Any `CpNode` on the MAT.
6
10
  * @param traverseEdgesCallback A callback function for each CpNode representing the vertex at the
7
11
  * start of an edge.
8
12
  */
@@ -1,9 +1,13 @@
1
1
  import { isTerminating } from './is-terminating.js';
2
2
  import { getAllOnLoop } from './get-all-on-loop.js';
3
3
  /**
4
- * Traverses all edges (depth first) of the given MAT tree starting at the given
5
- * vertex (represented by a `CpNode`).
6
- * @param cpNode Any `CpNode` representing the start vertex.
4
+ * Traverses all edges of the given MAT tree exactly once each, calling the
5
+ * callback for one of the two `CpNode`s representing each edge.
6
+ *
7
+ * * the edges are visited in boundary order starting from the given `CpNode`
8
+ * (not depth first)
9
+ *
10
+ * @param cpNode Any `CpNode` on the MAT.
7
11
  * @param traverseEdgesCallback A callback function for each CpNode representing the vertex at the
8
12
  * start of an edge.
9
13
  */
@@ -1 +1 @@
1
- {"version":3,"file":"traverse-edges.js","sourceRoot":"","sources":["../../../src/cp-node/fs/traverse-edges.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAGpD;;;;;;GAMG;AACH,SAAS,aAAa,CACd,MAAc,EACd,qBAA+C;IAEnD,MAAM,OAAO,GAAG,YAAY,CAAC,MAAM,CAAC,CAAC;IACrC,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAC;IAE/B,KAAK,MAAM,IAAI,OAAO,EAAE,CAAC;QACrB,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,EAAE,CAAC;YAChE,qBAAqB,CAAC,MAAM,CAAC,CAAC;QAClC,CAAC;QACD,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IACrB,CAAC;AACL,CAAC;AAGD,OAAO,EAAE,aAAa,EAAE,CAAA"}
1
+ {"version":3,"file":"traverse-edges.js","sourceRoot":"","sources":["../../../src/cp-node/fs/traverse-edges.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAGpD;;;;;;;;;;GAUG;AACH,SAAS,aAAa,CACd,MAAc,EACd,qBAA+C;IAEnD,MAAM,OAAO,GAAG,YAAY,CAAC,MAAM,CAAC,CAAC;IACrC,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAC;IAE/B,KAAK,MAAM,IAAI,OAAO,EAAE,CAAC;QACrB,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,EAAE,CAAC;YAChE,qBAAqB,CAAC,MAAM,CAAC,CAAC;QAClC,CAAC;QACD,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IACrB,CAAC;AACL,CAAC;AAGD,OAAO,EAAE,aAAa,EAAE,CAAA"}
@@ -1,4 +1,4 @@
1
- import type { CpNode } from "../cp-node";
2
- import type { CpNodeStringifyable } from "./cp-node-stringifyable";
1
+ import type { CpNode } from "../cp-node.js";
2
+ import type { CpNodeStringifyable } from "./cp-node-stringifyable.js";
3
3
  declare function fromStringifyable(cpNodesStringifyable: CpNodeStringifyable): CpNode;
4
4
  export { fromStringifyable };
@@ -1,4 +1,4 @@
1
- import { EDGES } from "./cp-node-stringifyable";
1
+ import { EDGES } from "./cp-node-stringifyable.js";
2
2
  import { getAllOnCircle } from "../fs/get-all-on-circle.js";
3
3
  import { loopFromStringifyable } from './loop-from-stringifyable.js';
4
4
  function fromStringifyable(cpNodesStringifyable) {