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
package/src/sat/cull.ts CHANGED
@@ -1,9 +1,8 @@
1
1
  import type { CpNode } from '../cp-node/cp-node.js';
2
- import type { DualSet } from '../utils/dual-set.js';
2
+ import type { Circle } from '../geometry/circle.js';
3
3
  import type { Mutable } from '../utils/mutable.js';
4
4
  import { getLeaves } from './get-leaves.js';
5
5
  import { isTerminating } from '../cp-node/fs/is-terminating.js';
6
- import { DualSetFs } from '../utils/dual-set.js';
7
6
  import { isOnSameCircle } from '../cp-node/fs/is-on-same-circle.js';
8
7
 
9
8
 
@@ -32,17 +31,18 @@ function getNonTrivialForwardEdges(cpStart: CpNode) {
32
31
 
33
32
 
34
33
  /**
35
- * Returns the set of Vertices passing the following test: walk the MAT tree and
36
- * keep all Vertices not in the current cull set and any Vertices that have a
37
- * non-culled node further down the line toward the tree leaves.
38
- *
39
- * @param culls the `CpNode`s (referred to by circles) that should be culled
34
+ * Culls (in place) the vertices of the given MAT tree: walking the tree from
35
+ * the maximal vertex, all vertices in the cull set are removed except those
36
+ * that have a non-culled vertex further down the line toward the tree leaves
37
+ * (which are kept to preserve the topology).
38
+ *
39
+ * @param culls the vertices (identified by their `Circle`) that should be culled
40
40
  * @param maxCpNode the start `CpNode` which must represent the maximal vertex
41
41
  *
42
42
  * @internal
43
43
  */
44
44
  function cull(
45
- culls: DualSet<number, number>,
45
+ culls: Set<Circle>,
46
46
  maxCpNode: CpNode) {
47
47
 
48
48
  const leaves = getLeaves(maxCpNode);
@@ -50,8 +50,7 @@ function cull(
50
50
  while (leaves.length) {
51
51
  const leaf = leaves.pop()!;
52
52
 
53
- const { center: c } = leaf.pointOnShape.circle;
54
- if (!DualSetFs.has(culls, c[0], c[1]) ||
53
+ if (!culls.has(leaf.pointOnShape.circle) ||
55
54
  // Preserve topology.
56
55
  leaf.isIntersection) {
57
56
 
@@ -63,8 +62,7 @@ function cull(
63
62
  while (!cut) {
64
63
  cpNode = cpNode.next;
65
64
 
66
- const { center: c } = cpNode.pointOnShape.circle;
67
- if (!DualSetFs.has(culls, c[0], c[1])) {
65
+ if (!culls.has(cpNode.pointOnShape.circle)) {
68
66
  // Cut off the edge once a non-cull has been reached.
69
67
  while (isTerminating(cpNode.prevOnCircle)) {
70
68
  cpNode = cpNode.prevOnCircle;
@@ -83,14 +81,12 @@ function cull(
83
81
  }
84
82
  }
85
83
 
86
- if (cut) {
87
- const cp1 = cpNode.prevOnCircle as Mutable<CpNode>;
88
- cp1.next = cpNode;
89
- (cpNode as Mutable<CpNode>).prev = cp1;
90
-
91
- cp1.nextOnCircle = cpNode;
92
- (cpNode as Mutable<CpNode>).prevOnCircle = cp1;
93
- }
84
+ // Cut the edge: link the node we stopped at directly to the one before
85
+ // it on its circle (`cut` is necessarily `true` here; the on-circle
86
+ // links are already consistent by the ring invariant)
87
+ const cp1 = cpNode.prevOnCircle as Mutable<CpNode>;
88
+ cp1.next = cpNode;
89
+ (cpNode as Mutable<CpNode>).prev = cp1;
94
90
  }
95
91
  }
96
92
 
@@ -1,41 +1,46 @@
1
- import type { DualSet } from "../utils/dual-set.js";
2
1
  import type { CpNode } from "../cp-node/cp-node.js";
3
- import { length } from "flo-bezier3";
4
- import { getAllOnCircle } from "../cp-node/fs/get-all-on-circle.js";
5
- import { getMatCurveToNext } from "../cp-node/fs/get-mat-curve-to-next.js";
2
+ import type { Circle } from "../geometry/circle.js";
3
+ import { getMatDistanceToNext } from "../cp-node/fs/get-distance-to-next.js";
6
4
  import { traverseEdges } from "../cp-node/fs/traverse-edges.js";
7
- import { DualSetFs } from "../utils/dual-set.js";
8
5
 
9
6
 
7
+ /**
8
+ * Returns the set of MAT vertices (identified by their `Circle` - all `CpNode`s
9
+ * on a vertex share the same `Circle` object) that are to be culled by the
10
+ * Scale Axis Transform with the given scale factor.
11
+ *
12
+ * @param cpNode the `CpNode` representing the maximal vertex
13
+ * @param s the scale factor
14
+ *
15
+ * @internal
16
+ */
10
17
  function getSatCulls(
11
- cpNode: CpNode,
12
- s: number) {
18
+ cpNode: CpNode,
19
+ s: number): Set<Circle> {
13
20
 
14
- /**
15
- * All vertices that are set to be culled initially. This may change later
16
- * in order to preserve topology.
21
+ /**
22
+ * All vertices that are set to be culled initially. This may change later
23
+ * in order to preserve topology.
17
24
  */
18
- const culls: DualSet<number,number> = new Map();
25
+ const culls = new Set<Circle>();
19
26
 
20
- const rMap: Map<CpNode,number> = new Map();
27
+ /** The osculating radius stored with each vertex. */
28
+ const rMap = new Map<Circle, number>();
21
29
 
22
30
  traverseEdges(cpNode, function(cpNode) {
23
- /** The occulating radius stored with this vertex. */
24
- const R = rMap.get(cpNode) || (s*cpNode.pointOnShape.circle.radius);
31
+ const circle = cpNode.pointOnShape.circle;
32
+ const R = rMap.get(circle) ?? s*circle.radius;
25
33
 
26
34
  const cpNode_ = cpNode.next;
35
+ const circle_ = cpNode_.pointOnShape.circle;
27
36
 
28
- const l = length([0,1], getMatCurveToNext(cpNode));
37
+ const l = getMatDistanceToNext(cpNode);
29
38
 
30
- const r = cpNode_.pointOnShape.circle.radius;
31
- const r_ = s*r;
39
+ const r_ = s*circle_.radius;
32
40
  if (R - l > r_) {
33
- for (const cpNode of getAllOnCircle(cpNode_)) {
34
- rMap.set(cpNode, R - l); // Update osculating radii
35
- if (!cpNode_.isHoleClosing) {
36
- const { center: c } = cpNode_.pointOnShape.circle;
37
- DualSetFs.add(culls, c[0], c[1]);
38
- }
41
+ rMap.set(circle_, R - l); // Update osculating radius
42
+ if (!cpNode_.isHoleClosing) {
43
+ culls.add(circle_);
39
44
  }
40
45
  }
41
46
  });
@@ -1,11 +1,10 @@
1
1
  import type { Loop } from 'flo-boolean';
2
2
  import type { PrePointOnShape } from '../point-on-shape/point-on-shape.js';
3
- import { memoize } from 'flo-memoize';
4
3
  import { getLoopBounds$ } from './get-loop-bounds.js';
5
4
 
6
5
 
7
6
  /** @internal */
8
- const getShapeBounds = memoize(function(loops: Loop[]) {
7
+ function getShapeBounds(loops: Loop[]) {
9
8
  let minX_ = +Infinity;
10
9
  let maxX_ = -Infinity;
11
10
  let minY_ = +Infinity;
@@ -42,7 +41,7 @@ const getShapeBounds = memoize(function(loops: Loop[]) {
42
41
  maxX: maxX!,
43
42
  maxY: maxY!
44
43
  };
45
- });
44
+ }
46
45
 
47
46
 
48
47
  export { getShapeBounds }
@@ -58,7 +58,7 @@ function sweepLine<T>(
58
58
  if (event.type === EVENT_LEFT) {
59
59
  for (const activeItem of activeItems.values()) {
60
60
  if (predicate(item, activeItem)) {
61
- pairedItems.push([item, activeItem]);
61
+ pairedItems.push([item, activeItem]);
62
62
  }
63
63
  }
64
64
 
@@ -0,0 +1,110 @@
1
+ import { fromTo, dot, cross, lineLineIntersection } from 'flo-vector2d';
2
+
3
+ const { abs, sqrt } = Math;
4
+
5
+
6
+ /**
7
+ * The maximum sine of the angle between the chord and either tangent for
8
+ * which a 'twisted' (inflected) curve is approximated by a straight line -
9
+ * the line then deviates from the true curve by only about a millionth of the
10
+ * chord length.
11
+ *
12
+ * * a relative (angle) tolerance and thus independent of the scale of the
13
+ * shape and of the magnitude of the given tangents
14
+ *
15
+ * @internal
16
+ */
17
+ const SIN_TOLERANCE_USE_LINE = 2**-16;
18
+
19
+
20
+ /**
21
+ * Returns an array of 1 or 2 bezier curves (each a line or a quadratic) that
22
+ * together form a smooth curve from the start point of `l0` to the start point
23
+ * of `l1` such that the curve is tangent to `l0` at its start and tangent to
24
+ * `l1` at its end.
25
+ *
26
+ * * `l0` and `l1` are given as `[p, p + dir]` where `p` is the curve endpoint
27
+ * and `dir` is the tangent direction (of any magnitude; its orientation does
28
+ * not matter)
29
+ * * if the tangent lines are not 'twisted' (they meet strictly between the
30
+ * endpoints along the chord) a single quadratic is returned
31
+ * * if the tangent lines are 'twisted' (the curve must have an inflection)
32
+ * 2 quadratics joined smoothly at the inflection are returned as an
33
+ * approximation - or, if both tangents deviate from the chord by less than
34
+ * `SIN_TOLERANCE_USE_LINE`, a single line
35
+ * * if the endpoints coincide (or a tangent is degenerate) a (degenerate) line
36
+ * is returned
37
+ *
38
+ * FUTURE: a strongly twisted MAT edge indicates that an additional 2-prong
39
+ * should be added so that the edge is approximated by two less twisted ones.
40
+ *
41
+ * @param l0 the tangent line at the start of the curve
42
+ * @param l1 the tangent line at the end of the curve
43
+ *
44
+ * @internal
45
+ */
46
+ function getBeziersFromTangents(
47
+ l0: number[][],
48
+ l1: number[][]): number[][][] {
49
+
50
+ const p0 = l0[0];
51
+ const p1 = l1[0];
52
+
53
+ const c = fromTo(p0,p1);
54
+ if (c[0] === 0 && c[1] === 0) {
55
+ return [[p0, p1]]; // coinciding endpoints - a degenerate line
56
+ }
57
+
58
+ const w0 = fromTo(l0[0], l0[1]);
59
+ const w1 = fromTo(l1[0], l1[1]);
60
+ const lc = sqrt(dot(c,c));
61
+ const lw0 = sqrt(dot(w0,w0));
62
+ const lw1 = sqrt(dot(w1,w1));
63
+ if (lw0 === 0 || lw1 === 0) {
64
+ return [[p0, p1]]; // a degenerate tangent - fall back to a line
65
+ }
66
+
67
+ const mid = lineLineIntersection(l0, l1);
68
+
69
+ let twisted: boolean;
70
+ if (!mid) {
71
+ twisted = true;
72
+ } else {
73
+ const a = fromTo(p0, mid);
74
+ const b = fromTo(p1, mid);
75
+
76
+ // (`<= 0` / `>= 0`: an intersection *at* an endpoint, which happens for
77
+ // collinear tangents, would give a degenerate quadratic with a zero
78
+ // end tangent - treat it as twisted so a line results instead)
79
+ twisted = dot(a,c) <= 0 || dot(b,c) >= 0;
80
+ }
81
+
82
+ if (!twisted) {
83
+ return [[p0, mid!, p1]];
84
+ }
85
+
86
+ // the sines of the angles between the chord and the tangents
87
+ const sin0 = abs(cross(c, w0)) / (lc*lw0);
88
+ const sin1 = abs(cross(c, w1)) / (lc*lw1);
89
+
90
+ if (sin0 <= SIN_TOLERANCE_USE_LINE && sin1 <= SIN_TOLERANCE_USE_LINE) {
91
+ return [[p0, p1]]; // within tolerance - a straight line
92
+ }
93
+
94
+ // Approximate with 2 quadratic beziers joined smoothly at the inflection.
95
+ // The control points lie on the tangent lines a quarter of the chord
96
+ // length away from the endpoints, on the side facing the other endpoint
97
+ // (for small angles this is the midpoint degree reduction of the cubic
98
+ // having control points at 1/3 and 2/3 along the chord; unlike placing
99
+ // them at 1/4 and 3/4 *along* the chord it stays bounded for any angle).
100
+ const q0 = (dot(w0,c) < 0 ? -1 : 1) * lc/(4*lw0);
101
+ const q1 = (dot(w1,c) < 0 ? 1 : -1) * lc/(4*lw1);
102
+ const c0 = [p0[0] + q0*w0[0], p0[1] + q0*w0[1]];
103
+ const c1 = [p1[0] + q1*w1[0], p1[1] + q1*w1[1]];
104
+ const j = [(c0[0] + c1[0])/2, (c0[1] + c1[1])/2];
105
+
106
+ return [[p0, c0, j], [j, c1, p1]];
107
+ }
108
+
109
+
110
+ export { getBeziersFromTangents }
@@ -19,7 +19,7 @@ function mapmap<T,U>(
19
19
  for (let j=0; j<ts.length; j++) {
20
20
  const v = f(ts[j]);
21
21
  if (filter(v)) {
22
- ts_.push(f(ts[j]));
22
+ ts_.push(v);
23
23
  }
24
24
  }
25
25
  tss_.push(ts_);
@@ -6,10 +6,12 @@ import { removeCpNode } from '../cp-node/fs/remove-cp-node.js';
6
6
 
7
7
 
8
8
  /**
9
- * Removes a cpNode from the MAT.
9
+ * Removes the (2-prong) vertex represented by the given `CpNode` from the MAT,
10
+ * i.e. both `CpNode`s on its circle are unlinked from the boundary and removed
11
+ * from `meta.cpTrees`.
10
12
  *
11
- * @param cpTree The tree graph holding the `CpNodes` of the MAT.
12
- * @param cpNode The `CpNode` to remove.
13
+ * @param cpNode a `CpNode` on the vertex to remove
14
+ * @param meta the `MatMeta` whose `cpTrees` hold the `CpNode`s of the MAT
13
15
  */
14
16
  function removeVertex(
15
17
  cpNode: CpNode,
@@ -1,7 +0,0 @@
1
- import { expect, test } from '@jest/globals';
2
- import { getDistanceBetween } from '../../../src/cp-node/fs/get-distance-between.js';
3
-
4
- test.skip('getDistanceBetween [STUB]', () => {
5
- // TODO: implement test
6
- expect(true).toBe(true);
7
- });
@@ -1,24 +0,0 @@
1
- import { expect, test } from '@jest/globals';
2
- import { getTerminatingOnCircle } from '../../../src/cp-node/fs/get-terminating-on-circle.js';
3
- import { getNonTerminatingOnCircle } from '../../../src/cp-node/fs/get-non-terminating-on-circle.js';
4
- import { getProngCount } from '../../../src/cp-node/fs/get-prong-count.js';
5
- import { isTerminating } from '../../../src/cp-node/fs/is-terminating.js';
6
- import { getMats1 } from '../../get-mats1.js';
7
-
8
-
9
- test('getTerminatingOnCircle', function() {
10
- const { cpNode } = getMats1()[0];
11
-
12
- const terminating = getTerminatingOnCircle(cpNode);
13
- for (const n of terminating) {
14
- expect(isTerminating(n)).toBe(true);
15
- }
16
-
17
- // terminating + non-terminating = total prong count
18
- const nonTerminating = getNonTerminatingOnCircle(cpNode);
19
- expect(terminating.length + nonTerminating.length).toBe(getProngCount(cpNode));
20
-
21
- // exclThis: cpNode should not be included
22
- const termExcl = getTerminatingOnCircle(cpNode, true);
23
- expect(termExcl.includes(cpNode)).toBe(false);
24
- });
@@ -1,17 +0,0 @@
1
- import { expect, test } from '@jest/globals';
2
- import { isSingle3Prong } from '../../../src/cp-node/fs/is-single-3-prong.js';
3
- import { getAllOnLoop } from '../../../src/cp-node/fs/get-all-on-loop.js';
4
- import { getMats1 } from '../../get-mats1.js';
5
-
6
-
7
- test('isSingle3Prong', function() {
8
- const { cpNode } = getMats1()[0];
9
- const allOnLoop = getAllOnLoop(cpNode);
10
-
11
- for (const n of allOnLoop) {
12
- if (isSingle3Prong(n)) {
13
- expect(n.next === n.nextOnCircle).toBe(true);
14
- expect(n.next.next === n.next.nextOnCircle).toBe(true);
15
- }
16
- }
17
- });
@@ -1,17 +0,0 @@
1
- import { expect, test } from '@jest/globals';
2
- import { iterateAllOnLoop } from '../../../src/cp-node/fs/iterate-all-on-loop.js';
3
- import { getAllOnLoop } from '../../../src/cp-node/fs/get-all-on-loop.js';
4
- import { getMats1 } from '../../get-mats1.js';
5
-
6
-
7
- test('iterateAllOnLoop', function() {
8
- const { cpNode } = getMats1()[0];
9
-
10
- const iterated = [...iterateAllOnLoop(cpNode)];
11
- const expected = getAllOnLoop(cpNode);
12
-
13
- expect(iterated.length).toBe(expected.length);
14
- for (let i = 0; i < iterated.length; i++) {
15
- expect(iterated[i] === expected[i]).toBe(true);
16
- }
17
- });
@@ -1,14 +0,0 @@
1
- import { expect, test } from '@jest/globals';
2
- import { traverseAllForward } from '../../../src/cp-node/fs/traverse-all-forward.js';
3
- import { getMats1 } from '../../get-mats1.js';
4
-
5
-
6
- test('traverseAllForward', function() {
7
- const { cpNode } = getMats1()[0];
8
-
9
- const visited: (typeof cpNode)[] = [];
10
- traverseAllForward(cpNode, cp => visited.push(cp));
11
-
12
- expect(visited.length).toBeGreaterThan(0);
13
- expect(visited[0] === cpNode).toBe(true);
14
- });
@@ -1,9 +0,0 @@
1
- import type { CurvePiece } from '../mat/curve-piece.js';
2
- /**
3
- * @param curvePieces
4
- * @param xO
5
- *
6
- * @internal
7
- */
8
- declare function cullCurvePieces1(curvePieces: CurvePiece[], xO: number[]): CurvePiece[];
9
- export { cullCurvePieces1 };
@@ -1,17 +0,0 @@
1
- import { getBestDistanceSquared } from './get-best-distance-squared.js';
2
- import { cullByLooseBoundingBox } from './cull-by-loose-bounding-box.js';
3
- import { cullByTightBoundingBox } from './cull-by-tight-boundary-box.js';
4
- /**
5
- * @param curvePieces
6
- * @param xO
7
- *
8
- * @internal
9
- */
10
- function cullCurvePieces1(curvePieces, xO) {
11
- const bestSquaredDistance = getBestDistanceSquared(curvePieces, xO);
12
- curvePieces = cullByLooseBoundingBox(curvePieces, xO, bestSquaredDistance);
13
- curvePieces = cullByTightBoundingBox(curvePieces, xO, bestSquaredDistance);
14
- return curvePieces;
15
- }
16
- export { cullCurvePieces1 };
17
- //# sourceMappingURL=cull-bezier-pieces-1.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"cull-bezier-pieces-1.js","sourceRoot":"","sources":["../../src/closest-boundary-point/cull-bezier-pieces-1.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AACxE,OAAO,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AACzE,OAAO,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AAGzE;;;;;GAKG;AACH,SAAS,gBAAgB,CACjB,WAAyB,EACzB,EAAY;IAEhB,MAAM,mBAAmB,GAAG,sBAAsB,CAC9C,WAAW,EAAE,EAAE,CAClB,CAAC;IAEF,WAAW,GAAG,sBAAsB,CAChC,WAAW,EAAE,EAAE,EACf,mBAAmB,CACtB,CAAC;IAEF,WAAW,GAAG,sBAAsB,CAChC,WAAW,EAAE,EAAE,EACf,mBAAmB,CACtB,CAAC;IAGF,OAAO,WAAW,CAAC;AACvB,CAAC;AAGD,OAAO,EAAE,gBAAgB,EAAE,CAAA"}
@@ -1,13 +0,0 @@
1
- import type { CurvePiece } from '../mat/curve-piece.js';
2
- /**
3
- * When checking distances, ignore all those with closest possible distance
4
- * further than 'bestSquaredDistance', i.e. cull them.
5
- *
6
- * @param curvePieces
7
- * @param xO
8
- * @param xy2
9
- *
10
- * @internal
11
- */
12
- declare function cullByLooseBoundingBox(curvePieces: CurvePiece[], xO: number[], xy2: number): CurvePiece[];
13
- export { cullByLooseBoundingBox };
@@ -1,27 +0,0 @@
1
- import { getClosestSquareDistanceToRect } from '../geometry/get-closest-square-distance-to-rect.js';
2
- import { getBoundingBox$ } from '../geometry/get-bounding-box-.js';
3
- /**
4
- * When checking distances, ignore all those with closest possible distance
5
- * further than 'bestSquaredDistance', i.e. cull them.
6
- *
7
- * @param curvePieces
8
- * @param xO
9
- * @param xy2
10
- *
11
- * @internal
12
- */
13
- function cullByLooseBoundingBox(curvePieces, xO, xy2) {
14
- const curvePieces_ = [];
15
- for (let i = 0; i < curvePieces.length; i++) {
16
- const curvePiece = curvePieces[i];
17
- const { ps } = curvePiece.curve;
18
- const boundingBox = getBoundingBox$(ps);
19
- const d = getClosestSquareDistanceToRect(boundingBox, xO);
20
- if (d <= xy2) {
21
- curvePieces_.push(curvePiece);
22
- }
23
- }
24
- return curvePieces_;
25
- }
26
- export { cullByLooseBoundingBox };
27
- //# sourceMappingURL=cull-by-loose-bounding-box.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"cull-by-loose-bounding-box.js","sourceRoot":"","sources":["../../src/closest-boundary-point/cull-by-loose-bounding-box.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,8BAA8B,EAAE,MAAM,oDAAoD,CAAC;AACpG,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AAGnE;;;;;;;;;GASG;AACH,SAAS,sBAAsB,CACvB,WAAyB,EACzB,EAAY,EACZ,GAAW;IAEf,MAAM,YAAY,GAAG,EAAE,CAAC;IAExB,KAAK,IAAI,CAAC,GAAC,CAAC,EAAE,CAAC,GAAC,WAAW,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACtC,MAAM,UAAU,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC;QAClC,MAAM,EAAE,EAAE,EAAE,GAAG,UAAU,CAAC,KAAK,CAAC;QAEhC,MAAM,WAAW,GAAG,eAAe,CAAC,EAAE,CAAC,CAAC;QAExC,MAAM,CAAC,GAAG,8BAA8B,CACpC,WAAW,EACX,EAAE,CACL,CAAC;QACF,IAAI,CAAC,IAAI,GAAG,EAAE,CAAC;YACX,YAAY,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAClC,CAAC;IACL,CAAC;IAED,OAAO,YAAY,CAAC;AACxB,CAAC;AAGD,OAAO,EAAE,sBAAsB,EAAE,CAAA"}
@@ -1,11 +0,0 @@
1
- import { CurvePiece } from "../mat/curve-piece.js";
2
- /**
3
- * @internal
4
- * When checking distances, ignore all those with closest possible distance
5
- * further than 'bestSquaredDistance', i.e. cull them.
6
- * @param curvePieces
7
- * @param p
8
- * @param bestSquaredDistance
9
- */
10
- declare function cullByTightBoundingBox(curvePieces: CurvePiece[], p: number[], bestSquaredDistance: number): CurvePiece[];
11
- export { cullByTightBoundingBox };
@@ -1,27 +0,0 @@
1
- import { getBoundingBoxTight } from "flo-bezier3";
2
- import { memoize } from "flo-memoize";
3
- import { getClosestSquaredDistanceToRotatedRect } from '../geometry/get-closest-squared-distance-to-rotated-rect.js';
4
- const getBoundingBoxTight$ = memoize(getBoundingBoxTight);
5
- /**
6
- * @internal
7
- * When checking distances, ignore all those with closest possible distance
8
- * further than 'bestSquaredDistance', i.e. cull them.
9
- * @param curvePieces
10
- * @param p
11
- * @param bestSquaredDistance
12
- */
13
- function cullByTightBoundingBox(curvePieces, p, bestSquaredDistance) {
14
- const candidateCurvePieces = [];
15
- for (let i = 0; i < curvePieces.length; i++) {
16
- const curvePiece = curvePieces[i];
17
- const ps = curvePiece.curve.ps;
18
- const tightBoundingBox = getBoundingBoxTight$(ps);
19
- const d = getClosestSquaredDistanceToRotatedRect(tightBoundingBox, p);
20
- if (d <= bestSquaredDistance) {
21
- candidateCurvePieces.push(curvePiece);
22
- }
23
- }
24
- return candidateCurvePieces;
25
- }
26
- export { cullByTightBoundingBox };
27
- //# sourceMappingURL=cull-by-tight-boundary-box.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"cull-by-tight-boundary-box.js","sourceRoot":"","sources":["../../src/closest-boundary-point/cull-by-tight-boundary-box.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAEtC,OAAO,EAAE,sCAAsC,EAAE,MAAM,6DAA6D,CAAC;AAGrH,MAAM,oBAAoB,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;AAG1D;;;;;;;GAOG;AACH,SAAS,sBAAsB,CACvB,WAAyB,EACzB,CAAW,EACX,mBAA2B;IAE/B,MAAM,oBAAoB,GAAG,EAAE,CAAC;IAEhC,KAAK,IAAI,CAAC,GAAC,CAAC,EAAE,CAAC,GAAC,WAAW,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACtC,MAAM,UAAU,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC;QAClC,MAAM,EAAE,GAAG,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC;QAE/B,MAAM,gBAAgB,GAAG,oBAAoB,CAAC,EAAE,CAAC,CAAC;QAClD,MAAM,CAAC,GAAG,sCAAsC,CACxC,gBAAgB,EAChB,CAAC,CACR,CAAC;QACF,IAAI,CAAC,IAAI,mBAAmB,EAAE,CAAC;YAC3B,oBAAoB,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAC1C,CAAC;IACL,CAAC;IAED,OAAO,oBAAoB,CAAC;AAChC,CAAC;AAGD,OAAO,EAAE,sBAAsB,EAAE,CAAA"}
@@ -1,10 +0,0 @@
1
- import type { CpNode } from "../cp-node.js";
2
- /**
3
- * Finds the first `CpNode` in the same MAT tree for which `f` returns a
4
- * truthy value. Returns `undefined` if no such `CpNode` exists.
5
- *
6
- * @param f a function that takes a `CpNode` and returns a `CpNode` or `undefined`
7
- * @param cpNode a `CpNode` on the MAT tree to search from
8
- */
9
- declare function findFirst(f: (cpNode: CpNode) => boolean, cpNode: CpNode): CpNode | undefined;
10
- export { findFirst };
@@ -1,19 +0,0 @@
1
- /**
2
- * Finds the first `CpNode` in the same MAT tree for which `f` returns a
3
- * truthy value. Returns `undefined` if no such `CpNode` exists.
4
- *
5
- * @param f a function that takes a `CpNode` and returns a `CpNode` or `undefined`
6
- * @param cpNode a `CpNode` on the MAT tree to search from
7
- */
8
- function findFirst(f, cpNode) {
9
- const cpStart = cpNode;
10
- do {
11
- if (f(cpNode)) {
12
- return cpNode;
13
- }
14
- cpNode = cpNode.next;
15
- } while (cpNode !== cpStart);
16
- return undefined;
17
- }
18
- export { findFirst };
19
- //# sourceMappingURL=find-first.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"find-first.js","sourceRoot":"","sources":["../../../src/cp-node/fs/find-first.ts"],"names":[],"mappings":"AAGA;;;;;;GAMG;AACH,SAAS,SAAS,CACV,CAA8B,EAC9B,MAAc;IAElB,MAAM,OAAO,GAAG,MAAM,CAAC;IAEvB,GAAG,CAAC;QACA,IAAI,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC;YACZ,OAAO,MAAM,CAAC;QAClB,CAAC;QACD,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC;IACzB,CAAC,QAAQ,MAAM,KAAK,OAAO,EAAE;IAE7B,OAAO,SAAS,CAAC;AACrB,CAAC;AAGD,OAAO,EAAE,SAAS,EAAE,CAAA"}
@@ -1,4 +0,0 @@
1
- import type { MatMeta } from "../../mat/mat-meta.js";
2
- import { CpNode } from "../../cp-node/cp-node.js";
3
- declare function checkOrdering(meta: MatMeta, cpStart: CpNode): void;
4
- export { checkOrdering };
@@ -1,43 +0,0 @@
1
- import { getAllOnLoop } from "../../cp-node/fs/get-all-on-loop.js";
2
- import { getProngCount } from "../../cp-node/fs/get-prong-count.js";
3
- import { isOrderCorrect } from "../../cp-node/fs/is-order-correct.js";
4
- function checkOrdering(meta, cpStart) {
5
- const { cpTrees } = meta;
6
- const cpNodes = getAllOnLoop(cpStart);
7
- const wrongsPerLoop = new Map();
8
- for (const cpNode of cpNodes) {
9
- const pos = cpNode.pointOnShape;
10
- const loop = pos.curve.loop;
11
- if (loop !== cpNode.prev.pointOnShape.curve.loop ||
12
- loop !== cpNode.next.pointOnShape.curve.loop) {
13
- continue;
14
- }
15
- const cpTree = cpTrees.get(loop);
16
- const orderCorrect = isOrderCorrect(cpTree, cpNode.prev, cpNode.pointOnShape, cpNode.next, true);
17
- if (!orderCorrect) {
18
- const A = toOrder(cpNode);
19
- const B = toOrder(cpNode.next);
20
- let wrongs = wrongsPerLoop.getOrInsert(loop, []);
21
- wrongs.push([A, B]);
22
- }
23
- }
24
- for (const [loop, wrongs] of wrongsPerLoop) {
25
- for (const wrong of wrongs) {
26
- const A = wrong[0];
27
- const B = wrong[1];
28
- // const c = comparePoss(A.cpNode.pointOnShape, B.cpNode.pointOnShape);
29
- console.log(A);
30
- console.log(B);
31
- console.log('---------');
32
- }
33
- }
34
- }
35
- function toOrder(cpNode) {
36
- const prongCount = getProngCount(cpNode);
37
- const { pointOnShape } = cpNode;
38
- const { p, t, order, order2, curve } = pointOnShape;
39
- const curveIdx = curve.idx;
40
- return { cpNode, prongCount, p, curveIdx, t, order, order2 };
41
- }
42
- export { checkOrdering };
43
- //# sourceMappingURL=check-ordering.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"check-ordering.js","sourceRoot":"","sources":["../../../src/debug/functions/check-ordering.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,qCAAqC,CAAC;AACnE,OAAO,EAAE,aAAa,EAAE,MAAM,qCAAqC,CAAC;AACpE,OAAO,EAAE,cAAc,EAAE,MAAM,sCAAsC,CAAC;AAetE,SAAS,aAAa,CACd,IAAa,EACb,OAAe;IAEnB,MAAM,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;IAEzB,MAAM,OAAO,GAAG,YAAY,CAAC,OAAO,CAAC,CAAC;IAEtC,MAAM,aAAa,GAA8B,IAAI,GAAG,EAAE,CAAC;IAC3D,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;QAC3B,MAAM,GAAG,GAAG,MAAM,CAAC,YAAY,CAAC;QAChC,MAAM,IAAI,GAAG,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC;QAE5B,IAAI,IAAI,KAAK,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,IAAI;YAC5C,IAAI,KAAK,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;YAE/C,SAAS;QACb,CAAC;QAED,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,IAAI,CAAE,CAAC;QAElC,MAAM,YAAY,GAAG,cAAc,CAC/B,MAAM,EAAE,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,YAAY,EAAE,MAAM,CAAC,IAAI,EAAE,IAAI,CAC9D,CAAC;QACF,IAAI,CAAC,YAAY,EAAE,CAAC;YAChB,MAAM,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;YAC1B,MAAM,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;YAE/B,IAAI,MAAM,GAAG,aAAa,CAAC,WAAW,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;YACjD,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAC,CAAC,CAAC,CAAC,CAAC;QACvB,CAAC;IACL,CAAC;IAED,KAAK,MAAM,CAAC,IAAI,EAAC,MAAM,CAAC,IAAI,aAAa,EAAE,CAAC;QACxC,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;YACzB,MAAM,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;YACnB,MAAM,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;YACnB,uEAAuE;YAEvE,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;YACf,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;YACf,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;QAC7B,CAAC;IACL,CAAC;AACL,CAAC;AAGD,SAAS,OAAO,CACR,MAAc;IAElB,MAAM,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,CAAC;IACzC,MAAM,EAAE,YAAY,EAAE,GAAG,MAAM,CAAC;IAChC,MAAM,EAAE,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,YAAY,CAAC;IACpD,MAAM,QAAQ,GAAG,KAAK,CAAC,GAAG,CAAC;IAE3B,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;AACjE,CAAC;AAGD,OAAO,EAAE,aAAa,EAAE,CAAA"}
@@ -1,13 +0,0 @@
1
- import type { CurvePiece } from '../mat/curve-piece.js';
2
- /**
3
- * Cull all `curvePieces` not within the given radius of a given point.
4
- *
5
- * @param extreme
6
- * @param curvePieces
7
- * @param xO
8
- * @param xy2
9
- *
10
- * @internal
11
- */
12
- declare function cullCurvePieces(curvePieces: CurvePiece[], xO: number[], xy2: number): CurvePiece[];
13
- export { cullCurvePieces };