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,7 +1,91 @@
1
1
  import { expect, test } from '@jest/globals';
2
+ import { RbTree } from 'flo-ll-rb-tree';
3
+ import type { CpNode } from '../../../src/cp-node/cp-node.js';
4
+ import type { PointOnShape } from '../../../src/point-on-shape/point-on-shape.js';
2
5
  import { insertCpNode } from '../../../src/cp-node/fs/insert-cp-node.js';
6
+ import { cpNodeComparator } from '../../../src/cp-node/fs/cp-node-comparator.js';
7
+ import { getAllOnLoop } from '../../../src/cp-node/fs/get-all-on-loop.js';
8
+ import { getMats1 } from '../../get-mats1.js';
9
+ import { cpNodesByIdOn } from '../../helpers/cp-node-by-id.js';
3
10
 
4
- test.skip('insertCpNode [STUB]', () => {
5
- // TODO: implement test
6
- expect(true).toBe(true);
11
+
12
+ /** A point on the shape (on the curve of the given node at `t`) with a zero disk. */
13
+ function posOnCurveOf(cpNode: CpNode, t: number, p: number[]): PointOnShape {
14
+ return {
15
+ curve: cpNode.pointOnShape.curve, t, p,
16
+ pDd: [[0,p[0]],[0,p[1]]], isSource: true,
17
+ circle: { center: p, radius: 0 }, order: 0, order2: 0
18
+ };
19
+ }
20
+
21
+
22
+ test('insertCpNode', function() {
23
+ const { cpNode } = getMats1()[0];
24
+ const byId = cpNodesByIdOn(cpNode);
25
+ const all = getAllOnLoop(cpNode);
26
+ const cpTree = new RbTree<CpNode>(cpNodeComparator);
27
+ for (const cp of all) { cpTree.insert(cp); }
28
+ const lastInsertId = { id: 1000 };
29
+
30
+ // insert between [24,8] (id 1, end of curve 0) and [46,8] (id 10, end of
31
+ // curve 1) a point halfway along curve 1
32
+ const pred = byId(1);
33
+ const succ = byId(10);
34
+ const pos = posOnCurveOf(succ, 0.5, [35, 8]);
35
+ const inserted = insertCpNode(false, false, false, cpTree, pos, pred, succ, lastInsertId)!;
36
+
37
+ expect(inserted).toBeDefined();
38
+ expect(inserted.id).toBe(1000);
39
+ expect(lastInsertId.id).toBe(1001);
40
+ expect(inserted.pointOnShape).toBe(pos);
41
+ expect(inserted.isHoleClosing).toBe(false);
42
+ expect(inserted.isIntersection).toBe(false);
43
+ // linked into the loop...
44
+ expect(inserted.prev).toBe(pred);
45
+ expect(inserted.next).toBe(succ);
46
+ expect(pred.next).toBe(inserted);
47
+ expect(succ.prev).toBe(inserted);
48
+ expect(getAllOnLoop(cpNode).length).toBe(all.length + 1);
49
+ // ...and into the tree, in order
50
+ expect(cpTree.find(inserted)?.datum).toBe(inserted);
51
+ expect(cpTree.size).toBe(all.length + 1);
52
+ const inOrder = cpTree.toArr();
53
+ expect(inOrder.length).toBe(all.length + 1);
54
+ expect(inOrder[inOrder.indexOf(pred) + 1]).toBe(inserted);
55
+ expect(inOrder[inOrder.indexOf(inserted) + 1]).toBe(succ);
56
+ // the on-circle edges are left for the caller to set
57
+ expect(inserted.nextOnCircle).toBeUndefined();
58
+ expect(inserted.prevOnCircle).toBeUndefined();
59
+
60
+ {
61
+ // A point on curve 3 does not belong between ids 1 and 10 - refused
62
+ // unless told to insert regardless. (At t=0.25 - not t=0.5 where id
63
+ // 145 already sits, which the tree would treat as a duplicate.)
64
+ const wrongPos = posOnCurveOf(byId(145), 0.25, [63.75, 54]);
65
+ const r = insertCpNode(false, false, false, cpTree, wrongPos, pred, inserted, lastInsertId);
66
+ expect(r).toBeUndefined();
67
+ expect(pred.next).toBe(inserted);
68
+ expect(cpTree.size).toBe(all.length + 1);
69
+ expect(lastInsertId.id).toBe(1001);
70
+
71
+ const forced = insertCpNode(true, true, true, cpTree, wrongPos, pred, inserted, lastInsertId)!;
72
+ expect(forced).toBeDefined();
73
+ expect(forced.id).toBe(1001);
74
+ expect(forced.isHoleClosing).toBe(true);
75
+ expect(forced.isIntersection).toBe(true);
76
+ expect(pred.next).toBe(forced);
77
+ expect(forced.next).toBe(inserted);
78
+ expect(inserted.prev).toBe(forced);
79
+ expect(cpTree.size).toBe(all.length + 2);
80
+ }
81
+
82
+ {
83
+ // without a predecessor the node starts a loop of its own
84
+ const emptyTree = new RbTree<CpNode>(cpNodeComparator);
85
+ const lone = insertCpNode(false, false, false, emptyTree, pos, undefined, undefined, lastInsertId)!;
86
+ expect(lone.next).toBe(lone);
87
+ expect(lone.prev).toBe(lone);
88
+ expect(emptyTree.size).toBe(1);
89
+ expect(emptyTree.toArr()[0]).toBe(lone);
90
+ }
7
91
  });
@@ -10,7 +10,7 @@ test('isSpecial', function() {
10
10
  const allOnLoop = getAllOnLoop(cpNode);
11
11
 
12
12
  for (const n of allOnLoop) {
13
- const expected = getRealProngCount(n) !== 2 && !n.isHoleClosing;
13
+ const expected = getRealProngCount(n) !== 2 || n.isHoleClosing;
14
14
  expect(isSpecial(n)).toBe(expected);
15
15
  }
16
16
  });
@@ -1,7 +1,46 @@
1
1
  import { expect, test } from '@jest/globals';
2
+ import { RbTree } from 'flo-ll-rb-tree';
3
+ import type { CpNode } from '../../../src/cp-node/cp-node.js';
4
+ import type { MatMeta } from '../../../src/mat/mat-meta.js';
2
5
  import { removeCpNode } from '../../../src/cp-node/fs/remove-cp-node.js';
6
+ import { cpNodeComparator } from '../../../src/cp-node/fs/cp-node-comparator.js';
7
+ import { getAllOnLoop } from '../../../src/cp-node/fs/get-all-on-loop.js';
8
+ import { getMats1 } from '../../get-mats1.js';
9
+ import { cpNodesByIdOn } from '../../helpers/cp-node-by-id.js';
3
10
 
4
- test.skip('removeCpNode [STUB]', () => {
5
- // TODO: implement test
6
- expect(true).toBe(true);
11
+
12
+ test('removeCpNode', function() {
13
+ const { cpNode } = getMats1()[0];
14
+ const byId = cpNodesByIdOn(cpNode);
15
+ const all = getAllOnLoop(cpNode);
16
+
17
+ const loop = cpNode.pointOnShape.curve.loop;
18
+ const cpTree = new RbTree<CpNode>(cpNodeComparator);
19
+ for (const cp of all) { cpTree.insert(cp); }
20
+ const meta = { cpTrees: new Map([[loop, cpTree]]) } as unknown as MatMeta;
21
+
22
+ const cp = byId(10);
23
+ const prev = cp.prev; // id 1
24
+ const next = cp.next; // id 144
25
+ expect(cpTree.find(cp)?.datum).toBe(cp);
26
+
27
+ removeCpNode(cp, meta);
28
+
29
+ // (compare `CpNode`s by identity / id only - they are circular structures
30
+ // that must not be deep-compared)
31
+
32
+ // unlinked from the loop...
33
+ expect(prev.next).toBe(next);
34
+ expect(next.prev).toBe(prev);
35
+ const remaining = getAllOnLoop(cpNode);
36
+ expect(remaining.length).toBe(all.length - 1);
37
+ expect(remaining.includes(cp)).toBe(false);
38
+ // ...and from the tree, with everything else still there
39
+ expect(cpTree.find(cp)).toBeUndefined();
40
+ expect(cpTree.size).toBe(all.length - 1);
41
+ const expectedIds = all.filter(c => c !== cp).sort(cpNodeComparator).map(c => c.id);
42
+ expect(cpTree.toArr().map(c => c.id)).toEqual(expectedIds);
43
+ // the removed node itself is left untouched
44
+ expect(cp.prev).toBe(prev);
45
+ expect(cp.next).toBe(next);
7
46
  });
@@ -0,0 +1,46 @@
1
+ import { expect, test } from '@jest/globals';
2
+ import { calcSquaredSeperationTolerance } from '../../src/find-2-prong/calc-seperation-tolerance.js';
3
+
4
+
5
+ /**
6
+ * Reference: the squared chord `(2r·sin(θ/2))²` with `θ` from the law of
7
+ * cosines formulation, computed via `1 - cos θ` to avoid cancellation.
8
+ */
9
+ function refSquaredChord(R: number, r: number, δ: number) {
10
+ const oneMinusCos = (R*δ + δ*δ/2) / ((R - r)*(r + δ));
11
+ const θ = 2*Math.asin(Math.sqrt(oneMinusCos/2));
12
+ return (2*r*Math.sin(θ/2))**2;
13
+ }
14
+
15
+
16
+ test('calcSquaredSeperationTolerance', function() {
17
+ // a spread of osculating radii, MAT radii and (tiny) distance tolerances
18
+ const cases: [number, number, number][] = [
19
+ [100, 50, 2**-34], [100, 99, 2**-34], [1000, 0.5, 2**-30],
20
+ [100, 99.999, 2**-34], [37.3, 12.1, 2**-40], [2**20, 1000, 2**-24],
21
+ ];
22
+ for (const [R, r, δ] of cases) {
23
+ const d2 = calcSquaredSeperationTolerance(R, r, δ);
24
+ expect(Number.isFinite(d2)).toBe(true);
25
+ expect(d2).toBeGreaterThan(0);
26
+ // agrees with the trigonometric reference
27
+ expect(d2 / refSquaredChord(R, r, δ)).toBeCloseTo(1, 12);
28
+ }
29
+
30
+ // the closer the MAT radius gets to the osculating radius (a near
31
+ // 1-prong) the larger the separation required
32
+ const grow = [10, 50, 90, 99, 99.9].map(r => calcSquaredSeperationTolerance(100, r, 2**-34));
33
+ for (let i=1; i<grow.length; i++) { expect(grow[i]).toBeGreaterThan(grow[i-1]); }
34
+
35
+ // ...and a larger error tolerance requires more separation too
36
+ expect(calcSquaredSeperationTolerance(100, 50, 2**-30))
37
+ .toBeGreaterThan(calcSquaredSeperationTolerance(100, 50, 2**-34));
38
+
39
+ // the enlarged MAT circle reaching the osculating circle: reject everything
40
+ expect(calcSquaredSeperationTolerance(100, 100, 2**-34)).toBe(Infinity);
41
+ expect(calcSquaredSeperationTolerance(100, 100 - 2**-40, 2**-34)).toBe(Infinity);
42
+ expect(calcSquaredSeperationTolerance(100, 120, 2**-34)).toBe(Infinity);
43
+
44
+ // sanity: a concrete value (R=100, r=50, δ=2**-34), chord ~ 1.079e-4
45
+ expect(Math.sqrt(calcSquaredSeperationTolerance(100, 50, 2**-34))).toBeCloseTo(1.078959e-4, 9);
46
+ });
@@ -44,7 +44,7 @@ test('getClosestPoints', function() {
44
44
  const def = deflate(H,t);//?
45
45
  // def = [47279295, -157379071.5, 100304568, -23598664.03125, 1904993.75390625]
46
46
 
47
- const r = getClosestPoint(maxPowerOf2, nnorm, nnormDd, yPos, for1Prong, angle, curvePiece);
47
+ const r = getClosestPoint(maxPowerOf2, nnormDd, yPos, for1Prong, angle, curvePiece);
48
48
 
49
49
  r;//?
50
50
 
@@ -0,0 +1,100 @@
1
+ import { expect, test } from '@jest/globals';
2
+ import type { CpNode } from '../../src/cp-node/cp-node.js';
3
+ import { getGraph } from '../../src/floyd-warshall/get-graph.js';
4
+ import { getAllOnLoop } from '../../src/cp-node/fs/get-all-on-loop.js';
5
+ import { getAllOnCircle } from '../../src/cp-node/fs/get-all-on-circle.js';
6
+ import { isVertexSpecial } from '../../src/cp-node/fs/is-vertex-special.js';
7
+ import { getPathsFromStr } from 'flo-boolean';
8
+ import { findMats } from '../../src/find-mat/find-mats.js';
9
+ import { getMats1 } from '../get-mats1.js';
10
+
11
+
12
+ /** One `CpNode` per special vertex (leaves, 3-prongs, hole closers). */
13
+ function getSpecialVertices(cpNode: CpNode): CpNode[] {
14
+ const seen = new Set<CpNode>();
15
+ const vertices: CpNode[] = [];
16
+ for (const cp of getAllOnLoop(cpNode)) {
17
+ if (seen.has(cp)) { continue; }
18
+ for (const c of getAllOnCircle(cp)) { seen.add(c); }
19
+ if (isVertexSpecial(cp)) { vertices.push(cp); }
20
+ }
21
+ return vertices;
22
+ }
23
+
24
+
25
+ function checkGraph(graph: number[][], V: number, symmetricLengths: boolean) {
26
+ expect(graph.length).toBe(V);
27
+ for (let i=0; i<V; i++) {
28
+ expect(graph[i].length).toBe(V);
29
+ expect(graph[i][i]).toBe(0);
30
+ let adjacent = 0;
31
+ for (let j=0; j<V; j++) {
32
+ const d = graph[i][j];
33
+ // symmetric adjacency...
34
+ expect(Number.isFinite(graph[j][i])).toBe(Number.isFinite(d));
35
+ // ...and symmetric lengths (up to the summation order of the edge
36
+ // lengths) - except across hole closers, where the two directions
37
+ // currently accumulate slightly different lengths (pre-existing)
38
+ if (symmetricLengths && Number.isFinite(d)) {
39
+ expect(d).toBeCloseTo(graph[j][i], 9);
40
+ }
41
+ expect(d >= 0).toBe(true);
42
+ if (i !== j && Number.isFinite(d)) { adjacent++; }
43
+ }
44
+ // the MAT is connected: every special vertex has a neighbour
45
+ expect(adjacent).toBeGreaterThan(0);
46
+ }
47
+ }
48
+
49
+
50
+ test('getGraph - single loop fixture', function() {
51
+ const { cpNode } = getMats1()[0];
52
+ const vertices = getSpecialVertices(cpNode);
53
+ // 5 leaves + 3 3-prongs
54
+ expect(vertices.length).toBe(8);
55
+
56
+ const graph = getGraph(vertices);
57
+ checkGraph(graph, vertices.length, true);
58
+
59
+ // the 3-prong {142,143,144} (center [81.5,-12.64]) is adjacent to the
60
+ // 3-prong at [81.5,18.5] by a straight vertical edge of length 31.14...
61
+ const i = vertices.findIndex(v => v.pointOnShape.circle.center[1] === 18.5);
62
+ const j = vertices.findIndex(v => v.pointOnShape.circle.center[1] === -12.641417453935567);
63
+ expect(i).toBeGreaterThanOrEqual(0);
64
+ expect(j).toBeGreaterThanOrEqual(0);
65
+ expect(graph[i][j]).toBeCloseTo(18.5 + 12.641417453935567, 9);
66
+ });
67
+
68
+
69
+ test('getGraph - shape with a hole (hole closers are skipped via their twins)', function() {
70
+ // (not the SAT-processed fixture: the SAT culls all the spurs of a square
71
+ // frame, leaving only a cycle of 2-prongs and thus no special vertices)
72
+ const loops = getPathsFromStr(
73
+ 'M0 0 L100 0 L100 100 L0 100 Z ' +
74
+ 'M30 30 L30 70 L70 70 L70 30 Z'
75
+ );
76
+ const { cpNode } = findMats(loops, { applySat: false, simplify: false })[0];
77
+ const vertices = getSpecialVertices(cpNode).filter(v => !v.isHoleClosing);
78
+ // 4 outer-corner leaves + 4 3-prongs where the spurs meet the ring
79
+ expect(vertices.length).toBe(8);
80
+
81
+ // must terminate (the walk over a hole closer continues on the other loop)
82
+ const graph = getGraph(vertices);
83
+ checkGraph(graph, vertices.length, false);
84
+
85
+ // the 4 leaves are each adjacent to exactly one 3-prong (their spur)...
86
+ const leaves = vertices.filter(v => v.pointOnShape.circle.radius === 0);
87
+ expect(leaves.length).toBe(4);
88
+ for (const leaf of leaves) {
89
+ const i = vertices.indexOf(leaf);
90
+ const finite = graph[i].filter((d, j) => j !== i && Number.isFinite(d));
91
+ expect(finite.length).toBe(1);
92
+ }
93
+ // ...and each 3-prong to its spur leaf and its two ring neighbours
94
+ for (const v of vertices) {
95
+ if (v.pointOnShape.circle.radius === 0) { continue; }
96
+ const i = vertices.indexOf(v);
97
+ const finite = graph[i].filter((d, j) => j !== i && Number.isFinite(d));
98
+ expect(finite.length).toBe(3);
99
+ }
100
+ });
@@ -0,0 +1,28 @@
1
+ import type { Mat } from "../src/mat/mat.js";
2
+ import { getPathsFromStr } from 'flo-boolean';
3
+ import { findMats } from "../src/find-mat/find-mats.js";
4
+
5
+
6
+ // Cache - the tests using this fixture must not mutate it.
7
+ let mats: Mat[] | undefined = undefined;
8
+
9
+ /**
10
+ * A square with a square hole - forces hole-closing 2-prongs (which `getMats1`
11
+ * does not have). Unlike `getMats1` this is calculated and thus susceptible to
12
+ * small perturbations in the algorithm, so only test *structural* properties
13
+ * against it.
14
+ */
15
+ function getMatsWithHole(): Mat[] {
16
+ if (mats) { return mats; }
17
+
18
+ const loops = getPathsFromStr(
19
+ 'M0 0 L100 0 L100 100 L0 100 Z ' +
20
+ 'M30 30 L30 70 L70 70 L70 30 Z'
21
+ );
22
+ mats = findMats(loops, {});
23
+
24
+ return mats;
25
+ }
26
+
27
+
28
+ export { getMatsWithHole }
@@ -0,0 +1,61 @@
1
+ import { expect, test } from '@jest/globals';
2
+ import type { Circle } from '../src/geometry/circle.js';
3
+ import { getMats1, cpNodeStringifyable1 } from './get-mats1.js';
4
+ import { getAllOnCircle } from '../src/cp-node/fs/get-all-on-circle.js';
5
+ import { getAllOnLoop_ByLoop } from '../src/cp-node/fs/get-all-on-loop-by-loop.js';
6
+
7
+
8
+ test('`getMats1` fixture: one `Circle` object per on-circle ring', function() {
9
+ {
10
+ // The stringifyable literal itself (before `fromStringifyable`
11
+ // normalizes anything) must already share one `Circle` object per
12
+ // on-circle ring and no `Circle` object across rings.
13
+ const { cpNodes } = cpNodeStringifyable1;
14
+ const byId = new Map(cpNodes.map(cp => [cp.id, cp]));
15
+
16
+ const seen = new Set<number>();
17
+ const ringOfCircle = new Map<Circle, number[]>();
18
+ for (const cpNode of cpNodes) {
19
+ if (seen.has(cpNode.id)) { continue; }
20
+
21
+ // walk the ring via the `nextOnCircle` ids
22
+ const ring: number[] = [];
23
+ let cp = cpNode;
24
+ do {
25
+ ring.push(cp.id);
26
+ seen.add(cp.id);
27
+ cp = byId.get(cp.nextOnCircle as number)!;
28
+ } while (cp !== cpNode);
29
+
30
+ const { circle } = cpNode.pointOnShape;
31
+ for (const id of ring) {
32
+ expect(byId.get(id)!.pointOnShape.circle).toBe(circle);
33
+ }
34
+ expect(ringOfCircle.has(circle)).toBe(false);
35
+ ringOfCircle.set(circle, ring);
36
+ }
37
+
38
+ expect(ringOfCircle.size).toBe(10);
39
+ }
40
+ {
41
+ // ...and so does the `CpNode` graph built from it
42
+ const { cpNode } = getMats1()[0];
43
+ const cpNodes = getAllOnLoop_ByLoop(cpNode).flat();
44
+
45
+ const seen = new Set<typeof cpNode>();
46
+ const circles = new Set<Circle>();
47
+ for (const cp of cpNodes) {
48
+ if (seen.has(cp)) { continue; }
49
+
50
+ const { circle } = cp.pointOnShape;
51
+ for (const cp_ of getAllOnCircle(cp)) {
52
+ seen.add(cp_);
53
+ expect(cp_.pointOnShape.circle).toBe(circle);
54
+ }
55
+ expect(circles.has(circle)).toBe(false);
56
+ circles.add(circle);
57
+ }
58
+
59
+ expect(circles.size).toBe(10);
60
+ }
61
+ });
@@ -1,83 +1,90 @@
1
1
  import type { Mat } from "../src/mat/mat.js";
2
2
  import type { CpNodeStringifyable } from "../src/cp-node/stringification/cp-node-stringifyable.js";
3
+ import type { Circle } from "../src/geometry/circle.js";
3
4
  import { findMats } from "../src/find-mat/find-mats.js";
4
5
  import { fromStringifyable } from "../src/cp-node/stringification/from-stringifyable.js";
5
6
 
6
7
 
7
8
 
8
- // Cache; we use this one in tests since it is fixed and not susceptible to
9
- // small perturbations in the algorithm.
10
- let mats1: Mat[] | undefined = undefined;
11
- function getMats1() {
12
- const _cpNode: CpNodeStringifyable = {
13
- cpNodes: [
14
- {
15
- id: 0,
16
- isHoleClosing: false,
17
- isIntersection: false,
18
- pointOnShape: {
19
- circle: {
20
- center: [24,8],
21
- radius: 0
22
- },
23
- curveIdx: 0,
24
- loopIdx: 0,
25
- p: [24, 8],
26
- pDd: [[0,24],[0,8]],
27
- t: 1,
28
- isSource: true,
29
- order: -1,
30
- order2: 0
31
- },
32
- prev: 11,
33
- next: 1,
34
- prevOnCircle: 1,
35
- nextOnCircle: 1
9
+ // One `Circle` object per on-circle ring (shared by all the ring's `CpNode`s
10
+ // and by no other ring) - see `PointOnShape.circle`. The fixture has no hole
11
+ // closers, so there are no twin rings with equal-but-distinct circles.
12
+ const circle_0_1: Circle = { center: [24, 8], radius: 0 };
13
+ const circle_10_11: Circle = { center: [46, -5.21425847941623], radius: 13.21425847941623 };
14
+ const circle_142_143_144: Circle = { center: [81.5, -12.641417453935567], radius: 41.064803841095305 };
15
+ const circle_145_146_147: Circle = { center: [81.5, 18.5], radius: 35.5 };
16
+ const circle_2_3: Circle = { center: [46, 54], radius: 0 };
17
+ const circle_4_5: Circle = { center: [117, 54], radius: 0 };
18
+ const circle_6_7: Circle = { center: [139, 8], radius: 0 };
19
+ const circle_8_9: Circle = { center: [82, -101], radius: 0 };
20
+ const circle_148_149_150: Circle = { center: [81.68410160768288, -12.970446490933696], radius: 41.07276841516263 };
21
+ const circle_118_119: Circle = { center: [115.9110440340909, -5.952334953607174], radius: 13.994766012811272 };
22
+
23
+
24
+ /** mat-demo: "achispado" font, "comma" glyph - fixed MAT fixture */
25
+ const cpNodeStringifyable1: CpNodeStringifyable = {
26
+ cpNodes: [
27
+ {
28
+ id: 0,
29
+ isHoleClosing: false,
30
+ isIntersection: false,
31
+ pointOnShape: {
32
+ circle: circle_0_1,
33
+ curveIdx: 0,
34
+ loopIdx: 0,
35
+ p: [24, 8],
36
+ pDd: [[0,24],[0,8]],
37
+ t: 1,
38
+ isSource: true,
39
+ order: -1,
40
+ order2: 0
36
41
  },
37
- { id: 1, isHoleClosing: false, isIntersection: false, pointOnShape: { circle: { center: [24, 8], radius: 0 }, curveIdx: 0, loopIdx: 0, p: [24, 8], t: 1, isSource: true , order: 1, order2: 0, pDd: [[0,24],[0,8]] }, prev: 0, next: 10, prevOnCircle: 0, nextOnCircle: 0 },
38
- { id: 10, isHoleClosing: false, isIntersection: false, pointOnShape: { circle: { center: [46, -5.21425847941623], radius: 13.21425847941623 }, curveIdx: 1, loopIdx: 0, p: [46, 8], t: 1, isSource: true , order: -1, order2: 0, pDd: [[0,46],[0,8]] }, prev: 1, next: 144, prevOnCircle: 11, nextOnCircle: 11 },
39
- { id: 144, isHoleClosing: false, isIntersection: false, pointOnShape: { circle: { center: [81.5, -12.641417453935567], radius: 41.064803841095305 }, curveIdx: 1, loopIdx: 0, p: [46, 8], t: 1, isSource: false , order: -0.5026547194480646, order2: 0, pDd: [[0,46],[0,8]] }, prev: 10, next: 147, prevOnCircle: 143, nextOnCircle: 142 },
40
- { id: 147, isHoleClosing: false, isIntersection: false, pointOnShape: { circle: { center: [81.5, 18.5], radius: 35.5 }, curveIdx: 2, loopIdx: 0, p: [46, 18.499999999999996], t: 0.2282608695652173, isSource: false , order: 0, order2: 0, pDd: [[0,46],[0,18.499999999999996]] }, prev: 144, next: 2, prevOnCircle: 146, nextOnCircle: 145 },
41
- { id: 2, isHoleClosing: false, isIntersection: false, pointOnShape: { circle: { center: [46, 54], radius: 0 }, curveIdx: 2, loopIdx: 0, p: [46, 54], t: 1, isSource: true , order: -1, order2: 0, pDd: [[0,46],[0,54]] }, prev: 147, next: 3, prevOnCircle: 3, nextOnCircle: 3 },
42
- { id: 3, isHoleClosing: false, isIntersection: false, pointOnShape: { circle: { center: [46, 54], radius: 0 }, curveIdx: 2, loopIdx: 0, p: [46, 54], t: 1, isSource: true , order: 1, order2: 0, pDd: [[0,46],[0,54]] }, prev: 2, next: 145, prevOnCircle: 2, nextOnCircle: 2 },
43
- { id: 145, isHoleClosing: false, isIntersection: false, pointOnShape: { circle: { center: [81.5, 18.5], radius: 35.5 }, curveIdx: 3, loopIdx: 0, p: [81.5, 54], t: 0.5, isSource: false , order: 0, order2: 0, pDd: [[0,81.5],[0,54]] }, prev: 3, next: 4, prevOnCircle: 147, nextOnCircle: 146 },
44
- { id: 4, isHoleClosing: false, isIntersection: false, pointOnShape: { circle: { center: [117, 54], radius: 0 }, curveIdx: 3, loopIdx: 0, p: [117, 54], t: 1, isSource: true , order: -1, order2: 0, pDd: [[0,117],[0,54]] }, prev: 145, next: 5, prevOnCircle: 5, nextOnCircle: 5 },
45
- { id: 5, isHoleClosing: false, isIntersection: false, pointOnShape: { circle: { center: [117, 54], radius: 0 }, curveIdx: 3, loopIdx: 0, p: [117, 54], t: 1, isSource: true , order: 1, order2: 0, pDd: [[0,117],[0,54]] }, prev: 4, next: 146, prevOnCircle: 4, nextOnCircle: 4 },
46
- { id: 146, isHoleClosing: false, isIntersection: false, pointOnShape: { circle: { center: [81.5, 18.5], radius: 35.5 }, curveIdx: 4, loopIdx: 0, p: [117, 18.499999999999996], t: 0.7717391304347827, isSource: false , order: 0, order2: 0, pDd: [[0,117],[0,18.499999999999996]] }, prev: 5, next: 142, prevOnCircle: 145, nextOnCircle: 147 },
47
- { id: 142, isHoleClosing: false, isIntersection: false, pointOnShape: { circle: { center: [81.5, -12.641417453935567], radius: 41.064803841095305 }, curveIdx: 4, loopIdx: 0, p: [117, 8], t: 1, isSource: false , order: -0.8644872659655476, order2: 0, pDd: [[0,117],[0,8]] }, prev: 146, next: 148, prevOnCircle: 144, nextOnCircle: 143 },
48
- { id: 148, isHoleClosing: false, isIntersection: false, pointOnShape: { circle: { center: [81.68410160768288, -12.970446490933696], radius: 41.07276841516263 }, curveIdx: 4, loopIdx: 0, p: [117, 8], t: 1, isSource: false , order: -0.8598373023056252, order2: 0, pDd: [[0,117],[0,8]] }, prev: 142, next: 119, prevOnCircle: 150, nextOnCircle: 149 },
49
- { id: 119, isHoleClosing: false, isIntersection: false, pointOnShape: { circle: { center: [115.9110440340909, -5.952334953607174], radius: 13.994766012811272 }, curveIdx: 4, loopIdx: 0, p: [117, 8], t: 1, isSource: false , order: -0.07781165936695383, order2: 0, pDd: [[0,117],[0,8]] }, prev: 148, next: 6, prevOnCircle: 118, nextOnCircle: 118 },
50
- { id: 6, isHoleClosing: false, isIntersection: false, pointOnShape: { circle: { center: [139, 8], radius: 0 }, curveIdx: 5, loopIdx: 0, p: [139, 8], t: 1, isSource: true , order: -1, order2: 0, pDd: [[0,139],[0,8]] }, prev: 119, next: 7, prevOnCircle: 7, nextOnCircle: 7 },
51
- { id: 7, isHoleClosing: false, isIntersection: false, pointOnShape: { circle: { center: [139, 8], radius: 0 }, curveIdx: 5, loopIdx: 0, p: [139, 8], t: 1, isSource: true , order: 1, order2: 0, pDd: [[0,139],[0,8]] }, prev: 6, next: 118, prevOnCircle: 6, nextOnCircle: 6 },
52
- { id: 118, isHoleClosing: false, isIntersection: false, pointOnShape: { circle: { center: [115.9110440340909, -5.952334953607174], radius: 13.994766012811272 }, curveIdx: 6, loopIdx: 0, p: [128.3125, -12.4375], t: 0.1875, isSource: true , order: 0, order2: 0, pDd: [[0,128.3125],[0,-12.4375]] }, prev: 7, next: 149, prevOnCircle: 119, nextOnCircle: 119 },
53
- { id: 149, isHoleClosing: false, isIntersection: false, pointOnShape: { circle: { center: [81.68410160768288, -12.970446490933696], radius: 41.07276841516263 }, curveIdx: 6, loopIdx: 0, p: [118.08071791640388, -32.003539423017145], t: 0.36700494883501966, isSource: false , order: 0, order2: 0, pDd: [[0,118.08071791640388],[0,-32.003539423017145]] }, prev: 118, next: 8, prevOnCircle: 148, nextOnCircle: 150 },
54
- { id: 8, isHoleClosing: false, isIntersection: false, pointOnShape: { circle: { center: [82, -101], radius: 0 }, curveIdx: 6, loopIdx: 0, p: [82, -101], t: 1, isSource: true , order: -1, order2: 0, pDd: [[0,82],[0,-101]] }, prev: 149, next: 9, prevOnCircle: 9, nextOnCircle: 9 },
55
- { id: 9, isHoleClosing: false, isIntersection: false, pointOnShape: { circle: { center: [82, -101], radius: 0 }, curveIdx: 6, loopIdx: 0, p: [82, -101], t: 1, isSource: true , order: 1, order2: 0, pDd: [[0,82],[0,-101]] }, prev: 8, next: 150, prevOnCircle: 8, nextOnCircle: 8 },
56
- { id: 150, isHoleClosing: false, isIntersection: false, pointOnShape: { circle: { center: [81.68410160768288, -12.970446490933696], radius: 41.07276841516263 }, curveIdx: 0, loopIdx: 0, p: [45.425023320690585, -32.264267964746104], t: 0.6306030461949899, isSource: false , order: 0, order2: 0, pDd: [[0,45.425023320690585],[0,-32.264267964746104]] }, prev: 9, next: 143, prevOnCircle: 149, nextOnCircle: 148 },
57
- { id: 143, isHoleClosing: false, isIntersection: false, pointOnShape: { circle: { center: [81.5, -12.641417453935567], radius: 41.064803841095305 }, curveIdx: 0, loopIdx: 0, p: [45.24795284642707, -31.931497590699145], t: 0.6336559854064299, isSource: false , order: 0, order2: 0, pDd: [[0,45.24795284642707],[0,-31.931497590699145]] }, prev: 150, next: 11, prevOnCircle: 142, nextOnCircle: 144 },
58
- { id: 11, isHoleClosing: false, isIntersection: false, pointOnShape: { circle: { center: [46, -5.21425847941623], radius: 13.21425847941623 }, curveIdx: 0, loopIdx: 0, p: [34.33444028251029, -11.421620530924521], t: 0.8218199951291328, isSource: false , order: 0, order2: 0, pDd: [[0,34.33444028251029],[0,-11.421620530924521]] }, prev: 143, next: 0, prevOnCircle: 10, nextOnCircle: 10 }
59
- ],
60
- loops: [
61
- { idx: 0, beziers: [[[82, -101], [24, 8]], [[24, 8], [46, 8]], [[46, 8], [46, 54]], [[46, 54], [117, 54]], [[117, 54], [117, 8]], [[117, 8], [139, 8]], [[139, 8], [82, -101]]] }
62
- ]
63
- };
64
-
65
- const cpNode = fromStringifyable(_cpNode);
66
-
67
- mats1 = [{ cpNode, meta: {
68
- boundingHulls: undefined!,
42
+ prev: 11,
43
+ next: 1,
44
+ prevOnCircle: 1,
45
+ nextOnCircle: 1
46
+ },
47
+ { id: 1, isHoleClosing: false, isIntersection: false, pointOnShape: { circle: circle_0_1, curveIdx: 0, loopIdx: 0, p: [24, 8], t: 1, isSource: true , order: 1, order2: 0, pDd: [[0,24],[0,8]] }, prev: 0, next: 10, prevOnCircle: 0, nextOnCircle: 0 },
48
+ { id: 10, isHoleClosing: false, isIntersection: false, pointOnShape: { circle: circle_10_11, curveIdx: 1, loopIdx: 0, p: [46, 8], t: 1, isSource: true , order: -1, order2: 0, pDd: [[0,46],[0,8]] }, prev: 1, next: 144, prevOnCircle: 11, nextOnCircle: 11 },
49
+ { id: 144, isHoleClosing: false, isIntersection: false, pointOnShape: { circle: circle_142_143_144, curveIdx: 1, loopIdx: 0, p: [46, 8], t: 1, isSource: false , order: -0.5026547194480646, order2: 0, pDd: [[0,46],[0,8]] }, prev: 10, next: 147, prevOnCircle: 143, nextOnCircle: 142 },
50
+ { id: 147, isHoleClosing: false, isIntersection: false, pointOnShape: { circle: circle_145_146_147, curveIdx: 2, loopIdx: 0, p: [46, 18.499999999999996], t: 0.2282608695652173, isSource: false , order: 0, order2: 0, pDd: [[0,46],[0,18.499999999999996]] }, prev: 144, next: 2, prevOnCircle: 146, nextOnCircle: 145 },
51
+ { id: 2, isHoleClosing: false, isIntersection: false, pointOnShape: { circle: circle_2_3, curveIdx: 2, loopIdx: 0, p: [46, 54], t: 1, isSource: true , order: -1, order2: 0, pDd: [[0,46],[0,54]] }, prev: 147, next: 3, prevOnCircle: 3, nextOnCircle: 3 },
52
+ { id: 3, isHoleClosing: false, isIntersection: false, pointOnShape: { circle: circle_2_3, curveIdx: 2, loopIdx: 0, p: [46, 54], t: 1, isSource: true , order: 1, order2: 0, pDd: [[0,46],[0,54]] }, prev: 2, next: 145, prevOnCircle: 2, nextOnCircle: 2 },
53
+ { id: 145, isHoleClosing: false, isIntersection: false, pointOnShape: { circle: circle_145_146_147, curveIdx: 3, loopIdx: 0, p: [81.5, 54], t: 0.5, isSource: false , order: 0, order2: 0, pDd: [[0,81.5],[0,54]] }, prev: 3, next: 4, prevOnCircle: 147, nextOnCircle: 146 },
54
+ { id: 4, isHoleClosing: false, isIntersection: false, pointOnShape: { circle: circle_4_5, curveIdx: 3, loopIdx: 0, p: [117, 54], t: 1, isSource: true , order: -1, order2: 0, pDd: [[0,117],[0,54]] }, prev: 145, next: 5, prevOnCircle: 5, nextOnCircle: 5 },
55
+ { id: 5, isHoleClosing: false, isIntersection: false, pointOnShape: { circle: circle_4_5, curveIdx: 3, loopIdx: 0, p: [117, 54], t: 1, isSource: true , order: 1, order2: 0, pDd: [[0,117],[0,54]] }, prev: 4, next: 146, prevOnCircle: 4, nextOnCircle: 4 },
56
+ { id: 146, isHoleClosing: false, isIntersection: false, pointOnShape: { circle: circle_145_146_147, curveIdx: 4, loopIdx: 0, p: [117, 18.499999999999996], t: 0.7717391304347827, isSource: false , order: 0, order2: 0, pDd: [[0,117],[0,18.499999999999996]] }, prev: 5, next: 142, prevOnCircle: 145, nextOnCircle: 147 },
57
+ { id: 142, isHoleClosing: false, isIntersection: false, pointOnShape: { circle: circle_142_143_144, curveIdx: 4, loopIdx: 0, p: [117, 8], t: 1, isSource: false , order: -0.8644872659655476, order2: 0, pDd: [[0,117],[0,8]] }, prev: 146, next: 148, prevOnCircle: 144, nextOnCircle: 143 },
58
+ { id: 148, isHoleClosing: false, isIntersection: false, pointOnShape: { circle: circle_148_149_150, curveIdx: 4, loopIdx: 0, p: [117, 8], t: 1, isSource: false , order: -0.8598373023056252, order2: 0, pDd: [[0,117],[0,8]] }, prev: 142, next: 119, prevOnCircle: 150, nextOnCircle: 149 },
59
+ { id: 119, isHoleClosing: false, isIntersection: false, pointOnShape: { circle: circle_118_119, curveIdx: 4, loopIdx: 0, p: [117, 8], t: 1, isSource: false , order: -0.07781165936695383, order2: 0, pDd: [[0,117],[0,8]] }, prev: 148, next: 6, prevOnCircle: 118, nextOnCircle: 118 },
60
+ { id: 6, isHoleClosing: false, isIntersection: false, pointOnShape: { circle: circle_6_7, curveIdx: 5, loopIdx: 0, p: [139, 8], t: 1, isSource: true , order: -1, order2: 0, pDd: [[0,139],[0,8]] }, prev: 119, next: 7, prevOnCircle: 7, nextOnCircle: 7 },
61
+ { id: 7, isHoleClosing: false, isIntersection: false, pointOnShape: { circle: circle_6_7, curveIdx: 5, loopIdx: 0, p: [139, 8], t: 1, isSource: true , order: 1, order2: 0, pDd: [[0,139],[0,8]] }, prev: 6, next: 118, prevOnCircle: 6, nextOnCircle: 6 },
62
+ { id: 118, isHoleClosing: false, isIntersection: false, pointOnShape: { circle: circle_118_119, curveIdx: 6, loopIdx: 0, p: [128.3125, -12.4375], t: 0.1875, isSource: true , order: 0, order2: 0, pDd: [[0,128.3125],[0,-12.4375]] }, prev: 7, next: 149, prevOnCircle: 119, nextOnCircle: 119 },
63
+ { id: 149, isHoleClosing: false, isIntersection: false, pointOnShape: { circle: circle_148_149_150, curveIdx: 6, loopIdx: 0, p: [118.08071791640388, -32.003539423017145], t: 0.36700494883501966, isSource: false , order: 0, order2: 0, pDd: [[0,118.08071791640388],[0,-32.003539423017145]] }, prev: 118, next: 8, prevOnCircle: 148, nextOnCircle: 150 },
64
+ { id: 8, isHoleClosing: false, isIntersection: false, pointOnShape: { circle: circle_8_9, curveIdx: 6, loopIdx: 0, p: [82, -101], t: 1, isSource: true , order: -1, order2: 0, pDd: [[0,82],[0,-101]] }, prev: 149, next: 9, prevOnCircle: 9, nextOnCircle: 9 },
65
+ { id: 9, isHoleClosing: false, isIntersection: false, pointOnShape: { circle: circle_8_9, curveIdx: 6, loopIdx: 0, p: [82, -101], t: 1, isSource: true , order: 1, order2: 0, pDd: [[0,82],[0,-101]] }, prev: 8, next: 150, prevOnCircle: 8, nextOnCircle: 8 },
66
+ { id: 150, isHoleClosing: false, isIntersection: false, pointOnShape: { circle: circle_148_149_150, curveIdx: 0, loopIdx: 0, p: [45.425023320690585, -32.264267964746104], t: 0.6306030461949899, isSource: false , order: 0, order2: 0, pDd: [[0,45.425023320690585],[0,-32.264267964746104]] }, prev: 9, next: 143, prevOnCircle: 149, nextOnCircle: 148 },
67
+ { id: 143, isHoleClosing: false, isIntersection: false, pointOnShape: { circle: circle_142_143_144, curveIdx: 0, loopIdx: 0, p: [45.24795284642707, -31.931497590699145], t: 0.6336559854064299, isSource: false , order: 0, order2: 0, pDd: [[0,45.24795284642707],[0,-31.931497590699145]] }, prev: 150, next: 11, prevOnCircle: 142, nextOnCircle: 144 },
68
+ { id: 11, isHoleClosing: false, isIntersection: false, pointOnShape: { circle: circle_10_11, curveIdx: 0, loopIdx: 0, p: [34.33444028251029, -11.421620530924521], t: 0.8218199951291328, isSource: false , order: 0, order2: 0, pDd: [[0,34.33444028251029],[0,-11.421620530924521]] }, prev: 143, next: 0, prevOnCircle: 10, nextOnCircle: 10 }
69
+ ],
70
+ loops: [
71
+ { idx: 0, beziers: [[[82, -101], [24, 8]], [[24, 8], [46, 8]], [[46, 8], [46, 54]], [[46, 54], [117, 54]], [[117, 54], [117, 8]], [[117, 8], [139, 8]], [[139, 8], [82, -101]]] }
72
+ ]
73
+ };
74
+
75
+
76
+ // We use this one in tests since it is fixed and not susceptible to
77
+ // small perturbations in the algorithm.
78
+ function getMats1(): Mat[] {
79
+ const cpNode = fromStringifyable(cpNodeStringifyable1);
80
+
81
+ return [{ cpNode, meta: {
69
82
  cpTrees: undefined!,
70
83
  loops: undefined!,
71
- dullCorners: undefined!,
72
84
  lastInsertId: undefined!,
73
- looseBoundingBoxes: undefined!,
74
85
  maxCoordPowerOf2: undefined!,
75
- sharpCorners: undefined!,
76
- squaredDiagonalLength: undefined!,
77
- tightBoundingBoxes: undefined!
86
+ squaredDiagonalLength: undefined!
78
87
  } }];
79
-
80
- return mats1;
81
88
  }
82
89
 
83
90
 
@@ -119,5 +126,6 @@ function _getMats1() {
119
126
 
120
127
  export {
121
128
  getMats1,
129
+ cpNodeStringifyable1,
122
130
  // _getMats1
123
131
  }
@@ -0,0 +1,27 @@
1
+ import type { CpNode } from "../../src/cp-node/cp-node.js";
2
+ import { getAllOnLoop } from "../../src/cp-node/fs/get-all-on-loop.js";
3
+
4
+
5
+ /**
6
+ * Returns the `CpNode` with the given `id` on the same loop as the given
7
+ * `CpNode` (throws if not found) - for picking out specific nodes of the
8
+ * `getMats1` fixture.
9
+ */
10
+ function cpNodeById(
11
+ cpNode: CpNode,
12
+ id: number): CpNode {
13
+
14
+ const found = getAllOnLoop(cpNode).find(cp => cp.id === id);
15
+ if (!found) { throw new Error(`no CpNode with id ${id}`); }
16
+
17
+ return found;
18
+ }
19
+
20
+
21
+ /** Returns a function mapping ids to `CpNode`s on the given loop. */
22
+ function cpNodesByIdOn(cpNode: CpNode) {
23
+ return (id: number) => cpNodeById(cpNode, id);
24
+ }
25
+
26
+
27
+ export { cpNodeById, cpNodesByIdOn }