flo-mat 4.0.2 → 4.1.0
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.
- package/__tests__/find-2-prong/get-medial/dd-get-medial-point-coeffs-same-curve.spec.ts +106 -0
- package/__tests__/find-2-prong/get-medial/dd-get-medial-point-coeffs.spec.ts +73 -0
- package/__tests__/find-2-prong/get-medial/get-closest-points.spec.ts +5 -2
- package/__tests__/helpers/close-to.ts +5 -5
- package/__tests__/specific-cases/load-svg/load-svg.ts +30 -0
- package/__tests__/specific-cases/specific-cases.spec.ts +170 -0
- package/__tests__/specific-cases/test-svgs/achispado.svg +5052 -0
- package/browser/index.js +5129 -8785
- package/browser/index.min.js +1 -1
- package/{jest.config.cjs → jest.config.ts} +8 -3
- package/node/closest-boundary-point/get-close-boundary-points-certified.js +3 -2
- package/node/closest-boundary-point/get-close-boundary-points-certified.js.map +1 -1
- package/node/corner/get-corner.js +1 -1
- package/node/corner/get-corner.js.map +1 -1
- package/node/cp-node/fs/get-all-on-loop-by-loop.d.ts +11 -0
- package/node/cp-node/fs/get-all-on-loop-by-loop.js +42 -0
- package/node/cp-node/fs/get-all-on-loop-by-loop.js.map +1 -0
- package/node/cp-node/fs/get-boundary-beziers-to-next.d.ts +1 -0
- package/node/cp-node/fs/get-boundary-beziers-to-next.js +1 -59
- package/node/cp-node/fs/get-boundary-beziers-to-next.js.map +1 -1
- package/node/cp-node/fs/get-edge-direction.d.ts +3 -1
- package/node/cp-node/fs/get-edge-direction.js +5 -3
- package/node/cp-node/fs/get-edge-direction.js.map +1 -1
- package/node/cp-node/fs/get-mat-curve-between.js +6 -6
- package/node/cp-node/fs/get-mat-curve-between.js.map +1 -1
- package/node/cp-node/fs/is-fully-terminating.js +12 -0
- package/node/cp-node/fs/is-fully-terminating.js.map +1 -1
- package/node/cp-node/fs/is-on-same-loop.d.ts +3 -0
- package/node/cp-node/fs/is-on-same-loop.js +6 -0
- package/node/cp-node/fs/is-on-same-loop.js.map +1 -0
- package/node/debug/debug.d.ts +8 -22
- package/node/debug/debug.js +12 -50
- package/node/debug/debug.js.map +1 -1
- package/node/find-2-prong/add-1-prong.js +1 -4
- package/node/find-2-prong/add-1-prong.js.map +1 -1
- package/node/find-2-prong/find-2-prong.js +24 -10
- package/node/find-2-prong/find-2-prong.js.map +1 -1
- package/node/find-2-prong/get-medial/get-antipodal-points.d.ts +1 -1
- package/node/find-2-prong/get-medial/get-antipodal-points.js +2 -2
- package/node/find-2-prong/get-medial/get-antipodal-points.js.map +1 -1
- package/node/find-2-prong/get-medial/get-closest-points.d.ts +7 -1
- package/node/find-2-prong/get-medial/get-closest-points.js +60 -14
- package/node/find-2-prong/get-medial/get-closest-points.js.map +1 -1
- package/node/find-2-prong/reduce-radius.d.ts +3 -1
- package/node/find-2-prong/reduce-radius.js +8 -6
- package/node/find-2-prong/reduce-radius.js.map +1 -1
- package/node/find-3-prong/calc-better-x.js +1 -3
- package/node/find-3-prong/calc-better-x.js.map +1 -1
- package/node/find-3-prong/calc-initial-3-prong-center.js +1 -2
- package/node/find-3-prong/calc-initial-3-prong-center.js.map +1 -1
- package/node/find-3-prong/find-3-prong-for-delta3s.js +1 -4
- package/node/find-3-prong/find-3-prong-for-delta3s.js.map +1 -1
- package/node/find-3-prong/find-3-prong.js.map +1 -1
- package/node/find-3-prong/find-and-add-3-prong.js +0 -14
- package/node/find-3-prong/find-and-add-3-prong.js.map +1 -1
- package/node/find-mat/find-mat.js +2 -2
- package/node/find-mat/find-mat.js.map +1 -1
- package/node/find-mat/find-mats.js.map +1 -1
- package/node/find-mat/get-dull-corners-on-loop.js +3 -2
- package/node/find-mat/get-dull-corners-on-loop.js.map +1 -1
- package/node/find-mat/get-for-1-prongs-on-loop.js +6 -3
- package/node/find-mat/get-for-1-prongs-on-loop.js.map +1 -1
- package/node/find-mat/get-for-2-prongs-on-loop.js +5 -1
- package/node/find-mat/get-for-2-prongs-on-loop.js.map +1 -1
- package/node/find-mat/get-meta.d.ts +4 -6
- package/node/find-mat/get-meta.js +12 -26
- package/node/find-mat/get-meta.js.map +1 -1
- package/node/find-mat/get-sharp-corners.js +4 -2
- package/node/find-mat/get-sharp-corners.js.map +1 -1
- package/node/get-medial-points/double-double/dd-get-medial-point-coeffs-bez0.d.ts +21 -0
- package/node/get-medial-points/double-double/dd-get-medial-point-coeffs-bez0.js +46 -0
- package/node/get-medial-points/double-double/dd-get-medial-point-coeffs-bez0.js.map +1 -0
- package/node/get-medial-points/double-double/dd-get-medial-point-coeffs-bez1.d.ts +28 -0
- package/node/get-medial-points/double-double/dd-get-medial-point-coeffs-bez1.js +97 -0
- package/node/get-medial-points/double-double/dd-get-medial-point-coeffs-bez1.js.map +1 -0
- package/node/get-medial-points/double-double/dd-get-medial-point-coeffs-bez2-same-curve.d.ts +28 -0
- package/node/get-medial-points/double-double/dd-get-medial-point-coeffs-bez2-same-curve.js +109 -0
- package/node/get-medial-points/double-double/dd-get-medial-point-coeffs-bez2-same-curve.js.map +1 -0
- package/node/get-medial-points/double-double/dd-get-medial-point-coeffs-bez2.d.ts +29 -0
- package/node/get-medial-points/double-double/dd-get-medial-point-coeffs-bez2.js +123 -0
- package/node/get-medial-points/double-double/dd-get-medial-point-coeffs-bez2.js.map +1 -0
- package/node/get-medial-points/double-double/dd-get-medial-point-coeffs-bez3-same-curve.d.ts +30 -0
- package/node/get-medial-points/double-double/dd-get-medial-point-coeffs-bez3-same-curve.js +177 -0
- package/node/get-medial-points/double-double/dd-get-medial-point-coeffs-bez3-same-curve.js.map +1 -0
- package/node/get-medial-points/double-double/dd-get-medial-point-coeffs-bez3.d.ts +29 -0
- package/node/get-medial-points/double-double/dd-get-medial-point-coeffs-bez3.js +156 -0
- package/node/get-medial-points/double-double/dd-get-medial-point-coeffs-bez3.js.map +1 -0
- package/node/get-medial-points/double-double/dd-get-medial-point-coeffs.d.ts +28 -0
- package/node/get-medial-points/double-double/dd-get-medial-point-coeffs.js +40 -0
- package/node/get-medial-points/double-double/dd-get-medial-point-coeffs.js.map +1 -0
- package/node/index.d.ts +6 -10
- package/node/index.js +5 -6
- package/node/index.js.map +1 -1
- package/node/point-on-shape/point-on-shape.d.ts +2 -0
- package/node/point-on-shape/to-p.d.ts +1 -1
- package/node/point-on-shape/to-p.js +1 -1
- package/node/point-on-shape/to-p.js.map +1 -1
- package/node/reconstruct-from-mat/get-cp-nodess-for-sat.d.ts +4 -0
- package/node/reconstruct-from-mat/get-cp-nodess-for-sat.js +15 -0
- package/node/reconstruct-from-mat/get-cp-nodess-for-sat.js.map +1 -0
- package/node/reconstruct-from-mat/reconstruct-from-mat.d.ts +10 -0
- package/node/reconstruct-from-mat/reconstruct-from-mat.js +160 -0
- package/node/reconstruct-from-mat/reconstruct-from-mat.js.map +1 -0
- package/node/reconstruct-from-mat/remove-sat-induced-trivial-3prongs.d.ts +12 -0
- package/node/reconstruct-from-mat/remove-sat-induced-trivial-3prongs.js +46 -0
- package/node/reconstruct-from-mat/remove-sat-induced-trivial-3prongs.js.map +1 -0
- package/node/sat/add-debug-info.js +1 -2
- package/node/sat/add-debug-info.js.map +1 -1
- package/node/svg/get-loop-bounds.js +6 -2
- package/node/svg/get-loop-bounds.js.map +1 -1
- package/node/utils/map-deep.d.ts +15 -0
- package/node/utils/map-deep.js +34 -0
- package/node/utils/map-deep.js.map +1 -0
- package/package.json +14 -8
- package/src/closest-boundary-point/get-close-boundary-points-certified.ts +3 -2
- package/src/corner/get-corner.ts +1 -1
- package/src/cp-node/fs/get-all-on-loop-by-loop.ts +56 -0
- package/src/cp-node/fs/get-all-on-loop.ts +1 -1
- package/src/cp-node/fs/get-boundary-beziers-to-next.ts +1 -72
- package/src/cp-node/fs/get-edge-direction.ts +8 -4
- package/src/cp-node/fs/get-mat-curve-between.ts +6 -6
- package/src/cp-node/fs/is-fully-terminating.ts +16 -0
- package/src/cp-node/fs/is-on-same-loop.ts +15 -0
- package/src/debug/debug.ts +27 -87
- package/src/find-2-prong/add-1-prong.ts +1 -5
- package/src/find-2-prong/find-2-prong.ts +37 -14
- package/src/find-2-prong/get-medial/get-antipodal-points.ts +3 -2
- package/src/find-2-prong/get-medial/get-closest-points-d.ts +213 -0
- package/src/find-2-prong/get-medial/get-closest-points.ts +74 -13
- package/src/find-2-prong/reduce-radius.ts +8 -5
- package/src/find-3-prong/calc-better-x.ts +1 -3
- package/src/find-3-prong/calc-initial-3-prong-center.ts +1 -2
- package/src/find-3-prong/find-3-prong-for-delta3s.ts +1 -4
- package/src/find-3-prong/find-3-prong.ts +0 -1
- package/src/find-3-prong/find-and-add-3-prong.ts +1 -15
- package/src/find-mat/find-mat.ts +3 -2
- package/src/find-mat/find-mats.ts +0 -1
- package/src/find-mat/get-dull-corners-on-loop.ts +4 -3
- package/src/find-mat/get-for-1-prongs-on-loop.ts +8 -3
- package/src/find-mat/get-for-2-prongs-on-loop.ts +6 -1
- package/src/find-mat/get-meta.ts +14 -38
- package/src/find-mat/get-sharp-corners.ts +5 -1
- package/src/get-medial-curve/__pycache__/get-cubic-self-medial-curve.cpython-313.pyc +0 -0
- package/src/get-medial-curve/get-cubic-self-medial-curve.py +419 -0
- package/src/get-medial-points/double-double/dd-get-medial-point-coeffs-bez0-with-running-err.ts +76 -0
- package/src/get-medial-points/double-double/dd-get-medial-point-coeffs-bez0.ts +61 -0
- package/src/get-medial-points/double-double/dd-get-medial-point-coeffs-bez1.ts +116 -0
- package/src/get-medial-points/double-double/dd-get-medial-point-coeffs-bez2-same-curve.ts +129 -0
- package/src/get-medial-points/double-double/dd-get-medial-point-coeffs-bez2.ts +142 -0
- package/src/get-medial-points/double-double/dd-get-medial-point-coeffs-bez3-same-curve.ts +199 -0
- package/src/get-medial-points/double-double/dd-get-medial-point-coeffs-bez3.ts +177 -0
- package/src/get-medial-points/double-double/dd-get-medial-point-coeffs.ts +48 -0
- package/src/get-medial-points/double-double/error-bound-calc.txt +72 -0
- package/src/index.ts +7 -11
- package/src/point-on-shape/point-on-shape.ts +3 -0
- package/src/point-on-shape/to-p.ts +2 -2
- package/src/reconstruct-from-mat/get-cp-nodess-for-sat.ts +24 -0
- package/src/reconstruct-from-mat/reconstruct-from-mat.ts +226 -0
- package/src/reconstruct-from-mat/remove-sat-induced-trivial-3prongs.ts +62 -0
- package/src/sat/add-debug-info.ts +1 -2
- package/src/svg/get-loop-bounds.ts +11 -3
- package/src/utils/clip.ts +13 -0
- package/src/utils/map-deep.ts +75 -0
- package/src/utils/map-map.ts +33 -0
- package/wallaby.mjs +4 -4
- package/node/debug/debug-elem-types.d.ts +0 -26
- package/node/debug/debug-elem-types.js +0 -22
- package/node/debug/debug-elem-types.js.map +0 -1
- package/node/debug/functions/draw/draw-beziers-as-single-path.d.ts +0 -2
- package/node/debug/functions/draw/draw-beziers-as-single-path.js +0 -30
- package/node/debug/functions/draw/draw-beziers-as-single-path.js.map +0 -1
- package/node/debug/functions/draw/xmlns.d.ts +0 -2
- package/node/debug/functions/draw/xmlns.js +0 -3
- package/node/debug/functions/draw/xmlns.js.map +0 -1
- package/node/debug/functions/draw-elem/bounding-hull.d.ts +0 -3
- package/node/debug/functions/draw-elem/bounding-hull.js +0 -8
- package/node/debug/functions/draw-elem/bounding-hull.js.map +0 -1
- package/node/debug/functions/draw-elem/draw-branch.d.ts +0 -4
- package/node/debug/functions/draw-elem/draw-branch.js +0 -26
- package/node/debug/functions/draw-elem/draw-branch.js.map +0 -1
- package/node/debug/functions/draw-elem/draw-circle-percent.d.ts +0 -3
- package/node/debug/functions/draw-elem/draw-circle-percent.js +0 -13
- package/node/debug/functions/draw-elem/draw-circle-percent.js.map +0 -1
- package/node/debug/functions/draw-elem/draw-cp-node.d.ts +0 -4
- package/node/debug/functions/draw-elem/draw-cp-node.js +0 -26
- package/node/debug/functions/draw-elem/draw-cp-node.js.map +0 -1
- package/node/debug/functions/draw-elem/draw-cull.d.ts +0 -3
- package/node/debug/functions/draw-elem/draw-cull.js +0 -9
- package/node/debug/functions/draw-elem/draw-cull.js.map +0 -1
- package/node/debug/functions/draw-elem/draw-dull-corner.d.ts +0 -4
- package/node/debug/functions/draw-elem/draw-dull-corner.js +0 -10
- package/node/debug/functions/draw-elem/draw-dull-corner.js.map +0 -1
- package/node/debug/functions/draw-elem/draw-elem.d.ts +0 -10
- package/node/debug/functions/draw-elem/draw-elem.js +0 -39
- package/node/debug/functions/draw-elem/draw-elem.js.map +0 -1
- package/node/debug/functions/draw-elem/draw-leaves.d.ts +0 -4
- package/node/debug/functions/draw-elem/draw-leaves.js +0 -34
- package/node/debug/functions/draw-elem/draw-leaves.js.map +0 -1
- package/node/debug/functions/draw-elem/draw-loop.d.ts +0 -4
- package/node/debug/functions/draw-elem/draw-loop.js +0 -11
- package/node/debug/functions/draw-elem/draw-loop.js.map +0 -1
- package/node/debug/functions/draw-elem/draw-loops.d.ts +0 -4
- package/node/debug/functions/draw-elem/draw-loops.js +0 -6
- package/node/debug/functions/draw-elem/draw-loops.js.map +0 -1
- package/node/debug/functions/draw-elem/draw-loose-bounding-box.d.ts +0 -3
- package/node/debug/functions/draw-elem/draw-loose-bounding-box.js +0 -10
- package/node/debug/functions/draw-elem/draw-loose-bounding-box.js.map +0 -1
- package/node/debug/functions/draw-elem/draw-mat.d.ts +0 -4
- package/node/debug/functions/draw-elem/draw-mat.js +0 -34
- package/node/debug/functions/draw-elem/draw-mat.js.map +0 -1
- package/node/debug/functions/draw-elem/draw-max-vertex.d.ts +0 -4
- package/node/debug/functions/draw-elem/draw-max-vertex.js +0 -9
- package/node/debug/functions/draw-elem/draw-max-vertex.js.map +0 -1
- package/node/debug/functions/draw-elem/draw-min-y.d.ts +0 -4
- package/node/debug/functions/draw-elem/draw-min-y.js +0 -10
- package/node/debug/functions/draw-elem/draw-min-y.js.map +0 -1
- package/node/debug/functions/draw-elem/draw-one-prong-at-dull-corner.d.ts +0 -4
- package/node/debug/functions/draw-elem/draw-one-prong-at-dull-corner.js +0 -22
- package/node/debug/functions/draw-elem/draw-one-prong-at-dull-corner.js.map +0 -1
- package/node/debug/functions/draw-elem/draw-one-prong.d.ts +0 -4
- package/node/debug/functions/draw-elem/draw-one-prong.js +0 -13
- package/node/debug/functions/draw-elem/draw-one-prong.js.map +0 -1
- package/node/debug/functions/draw-elem/draw-sharp-corner.d.ts +0 -4
- package/node/debug/functions/draw-elem/draw-sharp-corner.js +0 -10
- package/node/debug/functions/draw-elem/draw-sharp-corner.js.map +0 -1
- package/node/debug/functions/draw-elem/draw-three-prong.d.ts +0 -4
- package/node/debug/functions/draw-elem/draw-three-prong.js +0 -26
- package/node/debug/functions/draw-elem/draw-three-prong.js.map +0 -1
- package/node/debug/functions/draw-elem/draw-tight-bounding-box.d.ts +0 -3
- package/node/debug/functions/draw-elem/draw-tight-bounding-box.js +0 -8
- package/node/debug/functions/draw-elem/draw-tight-bounding-box.js.map +0 -1
- package/node/debug/functions/draw-elem/draw-two-prong.d.ts +0 -4
- package/node/debug/functions/draw-elem/draw-two-prong.js +0 -49
- package/node/debug/functions/draw-elem/draw-two-prong.js.map +0 -1
- package/node/debug/functions/draw-elem/draw-vertex.d.ts +0 -4
- package/node/debug/functions/draw-elem/draw-vertex.js +0 -13
- package/node/debug/functions/draw-elem/draw-vertex.js.map +0 -1
- package/node/debug/functions/general.d.ts +0 -48
- package/node/debug/functions/general.js +0 -53
- package/node/debug/functions/general.js.map +0 -1
- package/node/find-3-prong/timed-cc.d.ts +0 -3
- package/node/find-3-prong/timed-cc.js +0 -5
- package/node/find-3-prong/timed-cc.js.map +0 -1
- package/node/point-on-shape/pos-to-human-string.d.ts +0 -8
- package/node/point-on-shape/pos-to-human-string.js +0 -12
- package/node/point-on-shape/pos-to-human-string.js.map +0 -1
- package/node/utils/time-function-call.d.ts +0 -14
- package/node/utils/time-function-call.js +0 -32
- package/node/utils/time-function-call.js.map +0 -1
- package/src/debug/debug-elem-types.ts +0 -43
- package/src/debug/elem-type-two-prong.ts +0 -8
- package/src/debug/functions/cmp-cp-on-delta.ts +0 -54
- package/src/debug/functions/draw-elem/bounding-hull.ts +0 -18
- package/src/debug/functions/draw-elem/culls.ts +0 -39
- package/src/debug/functions/draw-elem/draw-branch.ts +0 -37
- package/src/debug/functions/draw-elem/draw-circle-percent.ts +0 -23
- package/src/debug/functions/draw-elem/draw-cp-node.ts +0 -46
- package/src/debug/functions/draw-elem/draw-cull.ts +0 -21
- package/src/debug/functions/draw-elem/draw-dull-corner.ts +0 -21
- package/src/debug/functions/draw-elem/draw-elem.ts +0 -64
- package/src/debug/functions/draw-elem/draw-leaves.ts +0 -51
- package/src/debug/functions/draw-elem/draw-loop.ts +0 -16
- package/src/debug/functions/draw-elem/draw-loops.ts +0 -10
- package/src/debug/functions/draw-elem/draw-loose-bounding-box.ts +0 -21
- package/src/debug/functions/draw-elem/draw-mat.ts +0 -43
- package/src/debug/functions/draw-elem/draw-max-vertex.ts +0 -15
- package/src/debug/functions/draw-elem/draw-min-y.ts +0 -18
- package/src/debug/functions/draw-elem/draw-one-prong-at-dull-corner.ts +0 -40
- package/src/debug/functions/draw-elem/draw-one-prong.ts +0 -25
- package/src/debug/functions/draw-elem/draw-sharp-corner.ts +0 -21
- package/src/debug/functions/draw-elem/draw-three-prong.ts +0 -44
- package/src/debug/functions/draw-elem/draw-tight-bounding-box.ts +0 -18
- package/src/debug/functions/draw-elem/draw-two-prong.ts +0 -68
- package/src/debug/functions/draw-elem/draw-vertex.ts +0 -27
- package/src/debug/functions/draw-elem/dull-corner.ts +0 -21
- package/src/debug/functions/draw-elem/leaves.ts +0 -20
- package/src/debug/functions/draw-elem/loop.ts +0 -16
- package/src/debug/functions/draw-elem/loops.ts +0 -10
- package/src/debug/functions/draw-elem/loose-bounding-box.ts +0 -21
- package/src/debug/functions/draw-elem/mat.ts +0 -47
- package/src/debug/functions/draw-elem/max-vertex.ts +0 -15
- package/src/debug/functions/draw-elem/min-y.ts +0 -18
- package/src/debug/functions/draw-elem/one-prong-at-dull-corner.ts +0 -26
- package/src/debug/functions/draw-elem/one-prong.ts +0 -23
- package/src/debug/functions/draw-elem/sharp-corner.ts +0 -20
- package/src/debug/functions/draw-elem/three-prong.ts +0 -30
- package/src/debug/functions/draw-elem/tight-bounding-box.ts +0 -18
- package/src/debug/functions/draw-elem/two-prong.ts +0 -50
- package/src/debug/functions/draw-elem/vertex.ts +0 -51
- package/src/debug/functions/general.ts +0 -79
- package/src/debug/functions/three-prong.ts +0 -249
- package/src/debug/functions/two-prong.ts +0 -203
- package/src/find-2-prong/add-debug-info.ts +0 -45
- package/src/find-3-prong/timed-cc.ts +0 -9
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { isOnSameLoop } from "../cp-node/fs/is-on-same-loop.js";
|
|
2
|
+
import { getAllOnLoop_ByLoop } from "../cp-node/fs/get-all-on-loop-by-loop.js";
|
|
3
|
+
import { isFullyTerminating } from "../cp-node/fs/is-fully-terminating.js";
|
|
4
|
+
function getCpNodessForSat(sat) {
|
|
5
|
+
let { cpNode } = sat;
|
|
6
|
+
while (!isFullyTerminating(cpNode)) {
|
|
7
|
+
cpNode = cpNode.next;
|
|
8
|
+
}
|
|
9
|
+
if (!isOnSameLoop(cpNode, cpNode.next)) {
|
|
10
|
+
cpNode = cpNode.holeCloserTwin;
|
|
11
|
+
}
|
|
12
|
+
return getAllOnLoop_ByLoop(cpNode);
|
|
13
|
+
}
|
|
14
|
+
export { getCpNodessForSat };
|
|
15
|
+
//# sourceMappingURL=get-cp-nodess-for-sat.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-cp-nodess-for-sat.js","sourceRoot":"","sources":["../../src/reconstruct-from-mat/get-cp-nodess-for-sat.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAChE,OAAO,EAAE,mBAAmB,EAAE,MAAM,0CAA0C,CAAC;AAC/E,OAAO,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAC;AAG3E,SAAS,iBAAiB,CAClB,GAAQ;IAEZ,IAAI,EAAE,MAAM,EAAE,GAAG,GAAG,CAAC;IAErB,OAAO,CAAC,kBAAkB,CAAC,MAAM,CAAC,EAAE,CAAC;QACjC,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC;IACzB,CAAC;IACD,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC;QACrC,MAAM,GAAG,MAAM,CAAC,cAAe,CAAC;IACpC,CAAC;IAED,OAAO,mBAAmB,CAAC,MAAM,CAAC,CAAC;AACvC,CAAC;AAGD,OAAO,EAAE,iBAAiB,EAAE,CAAA"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Mat } from '../mat/mat.js';
|
|
2
|
+
/**
|
|
3
|
+
* * used for debugging only
|
|
4
|
+
*
|
|
5
|
+
* @param mats
|
|
6
|
+
*
|
|
7
|
+
* @internal
|
|
8
|
+
*/
|
|
9
|
+
declare function reconstructFromMats(mats: Mat[], minNumAccurateBits?: number | undefined): number[][][][][];
|
|
10
|
+
export { reconstructFromMats };
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import { distanceBetween, fromTo as fromToVec, dot, rotate90Degrees, cross, interpolate, translate, lineLineIntersection } from 'flo-vector2d';
|
|
2
|
+
import { tangent as getTangent } from 'flo-bezier3';
|
|
3
|
+
import { mapDeep } from '../utils/map-deep.js';
|
|
4
|
+
import { removeSatInducedTrivial3Prongs } from './remove-sat-induced-trivial-3prongs.js';
|
|
5
|
+
import { getCpNodessForSat } from './get-cp-nodess-for-sat.js';
|
|
6
|
+
import { getRealProngCount } from '../cp-node/fs/get-real-prong-count.js';
|
|
7
|
+
const { max, abs, round, log2 } = Math;
|
|
8
|
+
// let ii = 0;
|
|
9
|
+
/**
|
|
10
|
+
* * used for debugging only
|
|
11
|
+
*
|
|
12
|
+
* @param mats
|
|
13
|
+
*
|
|
14
|
+
* @internal
|
|
15
|
+
*/
|
|
16
|
+
function reconstructFromMats(mats, minNumAccurateBits = undefined) {
|
|
17
|
+
const maxPO2 = max(...mats.map(mat => mat.meta.maxCoordPowerOf2));
|
|
18
|
+
const recoverBoundary_ = recoverBoundary(maxPO2, minNumAccurateBits);
|
|
19
|
+
// Really only required if getSats was called on the `Mat`s
|
|
20
|
+
const cpNodessPerSat = mats
|
|
21
|
+
.map(removeSatInducedTrivial3Prongs)
|
|
22
|
+
.map(getCpNodessForSat);
|
|
23
|
+
const r = mapDeep(3, cpNodessPerSat, recoverBoundary_, true);
|
|
24
|
+
// ii;//?
|
|
25
|
+
return r;
|
|
26
|
+
}
|
|
27
|
+
const FROM = 0;
|
|
28
|
+
const TO = 1;
|
|
29
|
+
/**
|
|
30
|
+
*
|
|
31
|
+
* @param cpNode
|
|
32
|
+
*
|
|
33
|
+
* @internal
|
|
34
|
+
*/
|
|
35
|
+
function recoverBoundary(maxPO2, minNumAccurateBits) {
|
|
36
|
+
return function (cpNode) {
|
|
37
|
+
const cpNode_ = cpNode.next;
|
|
38
|
+
const pos = cpNode.pointOnShape;
|
|
39
|
+
const pos_ = cpNode_.pointOnShape;
|
|
40
|
+
const { curve, circle, p } = pos;
|
|
41
|
+
const { curve: curve_, p: p_ } = pos_;
|
|
42
|
+
if (p[0] === p_[0] && p[1] === p_[1]) {
|
|
43
|
+
return undefined;
|
|
44
|
+
}
|
|
45
|
+
if (curve.loop !== curve_.loop) {
|
|
46
|
+
// It is a hole-closer going over to the other loop
|
|
47
|
+
// return undefined;
|
|
48
|
+
return undefined;
|
|
49
|
+
}
|
|
50
|
+
const d = distanceBetween(circle.center, p);
|
|
51
|
+
if (getRealProngCount(cpNode)) {
|
|
52
|
+
}
|
|
53
|
+
// DON'T remove these - they tell us the accuracy of the algorithm
|
|
54
|
+
// if (!closeTo(2**34)(circle.radius, d) && getRealProngCount(cpNode) === 3) {
|
|
55
|
+
// ii++;
|
|
56
|
+
// circle.center;//?
|
|
57
|
+
// circle.radius;//?
|
|
58
|
+
// d; //?
|
|
59
|
+
// p;//?
|
|
60
|
+
// pos.isSource;//?
|
|
61
|
+
// getRealProngCount(cpNode);//?
|
|
62
|
+
// }
|
|
63
|
+
// if (!closeTo(2**28)(circle.radius, d) && getRealProngCount(cpNode) !== 3) {
|
|
64
|
+
// ii++;
|
|
65
|
+
// circle.center;//?
|
|
66
|
+
// circle.radius;//?
|
|
67
|
+
// d; //?
|
|
68
|
+
// p;//?
|
|
69
|
+
// pos.isSource;//?
|
|
70
|
+
// getRealProngCount(cpNode);//?
|
|
71
|
+
// }
|
|
72
|
+
if (minNumAccurateBits !== undefined) {
|
|
73
|
+
const TOL = 2 ** (maxPO2 - minNumAccurateBits);
|
|
74
|
+
if (abs(circle.radius - d) > TOL) {
|
|
75
|
+
throw new Error(`Medial circle radius must be about the same (2**${round(log2(TOL))}) ` +
|
|
76
|
+
`as distance from medial circle center to point on shape, ` +
|
|
77
|
+
`found: medial radius ${circle.radius}, distance: ${d}`);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return getBoundaryPiece(cpNode);
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
/** @internal */
|
|
84
|
+
const TOLERANCE_ADD_2PRONG = 0.01;
|
|
85
|
+
/** @internal */
|
|
86
|
+
const TOLERANCE_USE_LINE = 0.0001; // else cubic
|
|
87
|
+
function getBoundaryPiece(cpNode) {
|
|
88
|
+
const cpNode_ = cpNode.next;
|
|
89
|
+
const pos = cpNode.pointOnShape;
|
|
90
|
+
const pos_ = cpNode_.pointOnShape;
|
|
91
|
+
const { p } = pos;
|
|
92
|
+
const { p: p_ } = pos_;
|
|
93
|
+
const fromCc = p;
|
|
94
|
+
const fromL = getEdgeDirection(cpNode, FROM);
|
|
95
|
+
const toCc = p_;
|
|
96
|
+
const toL = getEdgeDirection(cpNode_, TO);
|
|
97
|
+
const mid = lineLineIntersection(fromL, toL);
|
|
98
|
+
const c = fromToVec(fromCc, toCc);
|
|
99
|
+
let twisted;
|
|
100
|
+
if (!mid) {
|
|
101
|
+
twisted = true;
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
const a = fromToVec(fromCc, mid);
|
|
105
|
+
const b = fromToVec(toCc, mid);
|
|
106
|
+
twisted = dot(a, c) < 0 || dot(b, c) > 0;
|
|
107
|
+
}
|
|
108
|
+
if (!twisted) {
|
|
109
|
+
return [fromCc, mid, toCc];
|
|
110
|
+
}
|
|
111
|
+
const r = rotate90Degrees(c);
|
|
112
|
+
const w1 = fromToVec(fromL[0], fromL[1]); // This is a unit vector
|
|
113
|
+
const w2 = fromToVec(toL[0], toL[1]); // This is a unit vector
|
|
114
|
+
const d1 = abs(cross(c, w1)) / (3 * 3);
|
|
115
|
+
const d2 = abs(cross(c, w2)) / (3 * 3);
|
|
116
|
+
if (d1 > TOLERANCE_ADD_2PRONG || d2 > TOLERANCE_ADD_2PRONG) {
|
|
117
|
+
// FUTURE - not within tolerance - must add additional 2-prong
|
|
118
|
+
return [fromCc, toCc];
|
|
119
|
+
}
|
|
120
|
+
if (d1 > TOLERANCE_USE_LINE || d2 > TOLERANCE_USE_LINE) {
|
|
121
|
+
// approximate with cubic bezier
|
|
122
|
+
const m1 = interpolate(fromCc, toCc, 1 / 3);
|
|
123
|
+
const m2 = interpolate(fromCc, toCc, 2 / 3);
|
|
124
|
+
const v1 = translate(r, m1);
|
|
125
|
+
const v2 = translate(r, m2);
|
|
126
|
+
const l1 = [m1, v1];
|
|
127
|
+
const l2 = [m2, v2];
|
|
128
|
+
const mid1 = lineLineIntersection(fromL, l1);
|
|
129
|
+
const mid2 = lineLineIntersection(toL, l2);
|
|
130
|
+
return [fromCc, mid1, mid2, toCc];
|
|
131
|
+
}
|
|
132
|
+
// Within tolerance - approximate with a straight line.
|
|
133
|
+
return [fromCc, toCc];
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Returns a line segment of unit length starting at the given point and
|
|
137
|
+
* being tangent to the shape boundary.
|
|
138
|
+
*
|
|
139
|
+
* @internal
|
|
140
|
+
*/
|
|
141
|
+
function getEdgeDirection(cpNode, fromOrTo) {
|
|
142
|
+
let { pointOnShape } = cpNode;
|
|
143
|
+
let { curve, t, p } = pointOnShape;
|
|
144
|
+
let { ps } = curve;
|
|
145
|
+
if (fromOrTo === FROM && t === 1) {
|
|
146
|
+
t = 0;
|
|
147
|
+
curve = curve.next;
|
|
148
|
+
ps = curve.ps;
|
|
149
|
+
}
|
|
150
|
+
if (fromOrTo === TO && t === 0) {
|
|
151
|
+
t = 1;
|
|
152
|
+
curve = curve.prev;
|
|
153
|
+
ps = curve.ps;
|
|
154
|
+
}
|
|
155
|
+
const tangent = getTangent(ps, t);
|
|
156
|
+
const v = translate(p, tangent);
|
|
157
|
+
return [p, v];
|
|
158
|
+
}
|
|
159
|
+
export { reconstructFromMats };
|
|
160
|
+
//# sourceMappingURL=reconstruct-from-mat.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reconstruct-from-mat.js","sourceRoot":"","sources":["../../src/reconstruct-from-mat/reconstruct-from-mat.ts"],"names":[],"mappings":"AAGA,OAAO,EACW,eAAe,EAAE,MAAM,IAAI,SAAS,EAAE,GAAG,EAAE,eAAe,EACxE,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,oBAAoB,EACtD,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAE,8BAA8B,EAAE,MAAM,yCAAyC,CAAC;AACzF,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,EAAE,iBAAiB,EAAE,MAAM,uCAAuC,CAAC;AAG1E,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC;AAGvC,cAAc;AAGd;;;;;;GAMG;AACH,SAAS,mBAAmB,CACpB,IAAW,EACX,qBAAyC,SAAS;IAEtD,MAAM,MAAM,GAAG,GAAG,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CA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AAC,EAAE,GAAG,YAAY,CAAC;IACnC,IAAI,EAAE,EAAE,EAAE,GAAG,KAAK,CAAC;IAEnB,IAAI,QAAQ,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;QAC/B,CAAC,GAAG,CAAC,CAAC;QACN,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC;QACnB,EAAE,GAAG,KAAK,CAAC,EAAE,CAAC;IAClB,CAAC;IACD,IAAI,QAAQ,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,EAAG,CAAC;QAC9B,CAAC,GAAG,CAAC,CAAC;QACN,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC;QACnB,EAAE,GAAG,KAAK,CAAC,EAAE,CAAC;IAClB,CAAC;IAED,MAAM,OAAO,GAAG,UAAU,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;IAElC,MAAM,CAAC,GAAG,SAAS,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;IAEhC,OAAO,CAAC,CAAC,EAAC,CAAC,CAAC,CAAC;AACjB,CAAC;AAGD,OAAO,EAAE,mBAAmB,EAAE,CAAA"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Mat } from '../mat/mat.js';
|
|
2
|
+
/**
|
|
3
|
+
* In-place removes trivial 3-prongs from the SAT graph; just to simplify
|
|
4
|
+
* subsequent processing.
|
|
5
|
+
*
|
|
6
|
+
* These are 3-prongs that are induced by the SAT construction, and do
|
|
7
|
+
* not correspond to actual 3-prongs in the shape.
|
|
8
|
+
*
|
|
9
|
+
* @param sat the SAT
|
|
10
|
+
*/
|
|
11
|
+
declare function removeSatInducedTrivial3Prongs(sat: Mat): Mat;
|
|
12
|
+
export { removeSatInducedTrivial3Prongs };
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { isFullyTerminating } from '../cp-node/fs/is-fully-terminating.js';
|
|
2
|
+
/**
|
|
3
|
+
* In-place removes trivial 3-prongs from the SAT graph; just to simplify
|
|
4
|
+
* subsequent processing.
|
|
5
|
+
*
|
|
6
|
+
* These are 3-prongs that are induced by the SAT construction, and do
|
|
7
|
+
* not correspond to actual 3-prongs in the shape.
|
|
8
|
+
*
|
|
9
|
+
* @param sat the SAT
|
|
10
|
+
*/
|
|
11
|
+
function removeSatInducedTrivial3Prongs(sat) {
|
|
12
|
+
let { cpNode } = sat;
|
|
13
|
+
let cpStart = cpNode;
|
|
14
|
+
do {
|
|
15
|
+
if (isFullyTerminating(cpNode) ||
|
|
16
|
+
// cpNode.isHoleClosing || // hole-closers are fully terminating
|
|
17
|
+
cpNode.next !== cpNode.nextOnCircle) {
|
|
18
|
+
cpNode = cpNode.next;
|
|
19
|
+
continue;
|
|
20
|
+
}
|
|
21
|
+
//-----------------------------
|
|
22
|
+
// Delete the trivial 3-prong
|
|
23
|
+
//-----------------------------
|
|
24
|
+
// console.log('Removing SAT-induced trivial 3-prong');
|
|
25
|
+
const next = cpNode.next;
|
|
26
|
+
const nextNext = next.next;
|
|
27
|
+
const nextNextOC = cpNode.next.nextOnCircle;
|
|
28
|
+
//-------------------------------------------------------------
|
|
29
|
+
// In-place update of links to remove the trivial 3-prong node
|
|
30
|
+
//-------------------------------------------------------------
|
|
31
|
+
cpNode.next = nextNext;
|
|
32
|
+
cpNode.nextOnCircle = nextNextOC;
|
|
33
|
+
nextNext.prev = cpNode;
|
|
34
|
+
nextNextOC.prevOnCircle = cpNode;
|
|
35
|
+
//-------------------------------------------------------------
|
|
36
|
+
if (cpStart === next) {
|
|
37
|
+
cpStart = cpNode; // ...otherwise the loop will never terminate
|
|
38
|
+
}
|
|
39
|
+
cpNode = cpNode.next;
|
|
40
|
+
} while (cpNode !== cpStart);
|
|
41
|
+
// ...otherwise the caller will have a reference to a node that has been removed from the graph
|
|
42
|
+
sat.cpNode = cpNode;
|
|
43
|
+
return sat;
|
|
44
|
+
}
|
|
45
|
+
export { removeSatInducedTrivial3Prongs };
|
|
46
|
+
//# sourceMappingURL=remove-sat-induced-trivial-3prongs.js.map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M,CAAC;IAEtC,OAAO,GAAG,CAAC;AACf,CAAC;AAGD,OAAO,EAAE,8BAA8B,EAAE,CAAA"}
|
|
@@ -7,8 +7,7 @@ function addDebugInfo(timingStart) {
|
|
|
7
7
|
if (typeof _debug_ === 'undefined') {
|
|
8
8
|
return;
|
|
9
9
|
}
|
|
10
|
-
|
|
11
|
-
timing.sats = performance.now() - timingStart;
|
|
10
|
+
_debug_.timing.sats = performance.now() - timingStart;
|
|
12
11
|
}
|
|
13
12
|
export { addDebugInfo };
|
|
14
13
|
//# sourceMappingURL=add-debug-info.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"add-debug-info.js","sourceRoot":"","sources":["../../src/sat/add-debug-info.ts"],"names":[],"mappings":"AAIA;;;;GAIG;AACH,SAAS,YAAY,CACb,WAAmB;IAEvB,IAAI,OAAO,OAAO,KAAK,WAAW,EAAE,CAAC;QAAC,OAAO;IAAC,CAAC;IAE/C,
|
|
1
|
+
{"version":3,"file":"add-debug-info.js","sourceRoot":"","sources":["../../src/sat/add-debug-info.ts"],"names":[],"mappings":"AAIA;;;;GAIG;AACH,SAAS,YAAY,CACb,WAAmB;IAEvB,IAAI,OAAO,OAAO,KAAK,WAAW,EAAE,CAAC;QAAC,OAAO;IAAC,CAAC;IAE/C,OAAO,CAAC,MAAM,CAAC,IAAI,GAAG,WAAW,CAAC,GAAG,EAAE,GAAG,WAAW,CAAC;AAC1D,CAAC;AAGD,OAAO,EAAE,YAAY,EAAE,CAAA"}
|
|
@@ -2,11 +2,15 @@ import { memoize } from 'flo-memoize';
|
|
|
2
2
|
import { getBounds } from 'flo-bezier3';
|
|
3
3
|
import { toP } from '../point-on-shape/to-p.js';
|
|
4
4
|
function toPrePoint(extreme) {
|
|
5
|
+
const { curve, t } = extreme;
|
|
6
|
+
const { ps } = curve;
|
|
7
|
+
const pDd = toP(ps, t);
|
|
8
|
+
const p = pDd.map(c => c[0] + c[1]);
|
|
5
9
|
return {
|
|
6
|
-
curve
|
|
10
|
+
curve,
|
|
7
11
|
t: extreme.t,
|
|
8
12
|
isSource: true,
|
|
9
|
-
p
|
|
13
|
+
p, pDd
|
|
10
14
|
};
|
|
11
15
|
}
|
|
12
16
|
function updateExtreme(extreme, curve, t, val, isMax) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-loop-bounds.js","sourceRoot":"","sources":["../../src/svg/get-loop-bounds.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,GAAG,EAAE,MAAM,2BAA2B,CAAC;AAUhD,SAAS,UAAU,
|
|
1
|
+
{"version":3,"file":"get-loop-bounds.js","sourceRoot":"","sources":["../../src/svg/get-loop-bounds.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,GAAG,EAAE,MAAM,2BAA2B,CAAC;AAUhD,SAAS,UAAU,CACX,OAAgB;IAEpB,MAAM,EAAE,KAAK,EAAE,CAAC,EAAE,GAAG,OAAO,CAAC;IAC7B,MAAM,EAAE,EAAE,EAAE,GAAG,KAAK,CAAC;IAErB,MAAM,GAAG,GAAG,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;IACvB,MAAM,CAAC,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAEpC,OAAO;QACH,KAAK;QACL,CAAC,EAAE,OAAO,CAAC,CAAC;QACZ,QAAQ,EAAE,IAAI;QACd,CAAC,EAAE,GAAG;KACT,CAAC;AACN,CAAC;AAGD,SAAS,aAAa,CACd,OAAgB,EAChB,KAAY,EACZ,CAAS,EACT,GAAW,EACX,KAAc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AAC,IAAI,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,KAAK,CAAC,CAAC;YACjF,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,CAAC;QACpF,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,OAAO;QACH,IAAI,EAAE,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACzB,IAAI,EAAE,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACzB,IAAI,EAAE,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACzB,IAAI,EAAE,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;KAC5B,CAAC;AACN,CAAC,CAAC,CAAC;AAGH,OAAO,EAAE,cAAc,EAAE,CAAA"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
type Depth = 1 | 2 | 3 | 4 | 5 | 6;
|
|
2
|
+
type NestedArray<T, D extends Depth> = D extends 1 ? T[] : D extends 2 ? T[][] : D extends 3 ? T[][][] : D extends 4 ? T[][][][] : D extends 5 ? T[][][][][] : T[][][][][][];
|
|
3
|
+
type PrevDepth<D extends Depth> = D extends 6 ? 5 : D extends 5 ? 4 : D extends 4 ? 3 : D extends 3 ? 2 : D extends 2 ? 1 : never;
|
|
4
|
+
type LeafAtDepth<A, D extends Depth> = D extends 1 ? A extends (infer T)[] ? T : never : A extends (infer T)[] ? LeafAtDepth<T, PrevDepth<D>> : never;
|
|
5
|
+
type LeafValue<T, FilterUndefined extends boolean> = FilterUndefined extends true ? Exclude<T, undefined> : T;
|
|
6
|
+
/**
|
|
7
|
+
* Returns the result of mapping the array to the given depth and, optionally,
|
|
8
|
+
* filtering out `undefined` leaf values.
|
|
9
|
+
*
|
|
10
|
+
* @param tss
|
|
11
|
+
* @param f
|
|
12
|
+
* @param filterUndefined
|
|
13
|
+
*/
|
|
14
|
+
declare function mapDeep<D extends Depth, A extends NestedArray<unknown, D>, U, F extends boolean = false>(depth: D, tss: A, f: (t: LeafAtDepth<A, D>) => U, filterUndefined?: F): NestedArray<LeafValue<U, F>, D>;
|
|
15
|
+
export { mapDeep };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns the result of mapping the array to the given depth and, optionally,
|
|
3
|
+
* filtering out `undefined` leaf values.
|
|
4
|
+
*
|
|
5
|
+
* @param tss
|
|
6
|
+
* @param f
|
|
7
|
+
* @param filterUndefined
|
|
8
|
+
*/
|
|
9
|
+
function mapDeep(depth, tss, f, filterUndefined) {
|
|
10
|
+
if (!Number.isInteger(depth) || depth < 1) {
|
|
11
|
+
throw new Error('depth must be an integer >= 1');
|
|
12
|
+
}
|
|
13
|
+
function mapRec(d, arr) {
|
|
14
|
+
const a = arr;
|
|
15
|
+
if (d === 1) {
|
|
16
|
+
const ts_ = [];
|
|
17
|
+
for (let i = 0; i < a.length; i++) {
|
|
18
|
+
const v = f(a[i]);
|
|
19
|
+
if (!filterUndefined || v !== undefined) {
|
|
20
|
+
ts_.push(v);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return ts_;
|
|
24
|
+
}
|
|
25
|
+
const tss_ = [];
|
|
26
|
+
for (let i = 0; i < a.length; i++) {
|
|
27
|
+
tss_.push(mapRec(d - 1, a[i]));
|
|
28
|
+
}
|
|
29
|
+
return tss_;
|
|
30
|
+
}
|
|
31
|
+
return mapRec(depth, tss);
|
|
32
|
+
}
|
|
33
|
+
export { mapDeep };
|
|
34
|
+
//# sourceMappingURL=map-deep.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
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GED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "flo-mat",
|
|
3
3
|
"sideEffects": false,
|
|
4
4
|
"description": "Medial / Scale Axis Transform (MAT/SAT) Library.",
|
|
5
|
-
"version": "4.0
|
|
5
|
+
"version": "4.1.0",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Floris Steenkamp"
|
|
8
8
|
},
|
|
@@ -33,14 +33,15 @@
|
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"big-float-ts": "^4.0.4",
|
|
35
35
|
"double-double": "^3.0.4",
|
|
36
|
-
"flo-bezier3": "^8.0.
|
|
37
|
-
"flo-boolean": "^5.0.
|
|
36
|
+
"flo-bezier3": "^8.0.13",
|
|
37
|
+
"flo-boolean": "^5.0.8",
|
|
38
38
|
"flo-draw": "^2.0.5",
|
|
39
39
|
"flo-gauss-quadrature": "^2.1.4",
|
|
40
40
|
"flo-ll-rb-tree": "^1.0.1",
|
|
41
41
|
"flo-memoize": "^2.0.1",
|
|
42
|
-
"flo-poly": "^8.1.
|
|
43
|
-
"flo-vector2d": "^4.0.6"
|
|
42
|
+
"flo-poly": "^8.1.4",
|
|
43
|
+
"flo-vector2d": "^4.0.6",
|
|
44
|
+
"squares-rng": "^2.0.4"
|
|
44
45
|
},
|
|
45
46
|
"devDependencies": {
|
|
46
47
|
"@jest/globals": "^30.4.1",
|
|
@@ -48,15 +49,16 @@
|
|
|
48
49
|
"@swc/jest": "^0.2.39",
|
|
49
50
|
"@types/jest": "^30.0.0",
|
|
50
51
|
"@types/node": "^26.1.1",
|
|
51
|
-
"jest": "^30.4.2",
|
|
52
|
-
"jest-ts-webcompat-resolver": "^1.0.1",
|
|
53
52
|
"c8": "^12.0.0",
|
|
53
|
+
"cheerio": "^1.2.0",
|
|
54
54
|
"circular-dependency-plugin": "^5.2.2",
|
|
55
|
+
"jest": "^30.4.2",
|
|
56
|
+
"jest-ts-webcompat-resolver": "^1.0.1",
|
|
55
57
|
"rimraf": "^6.1.3",
|
|
56
58
|
"ts-loader": "^9.6.2",
|
|
57
59
|
"ts-node": "^10.9.2",
|
|
58
60
|
"typescript": "^6.0.3",
|
|
59
|
-
"webpack": "^5.
|
|
61
|
+
"webpack": "^5.109.0",
|
|
60
62
|
"webpack-cli": "^7.2.1"
|
|
61
63
|
},
|
|
62
64
|
"scripts": {
|
|
@@ -65,5 +67,9 @@
|
|
|
65
67
|
"build-browser": "rimraf browser && webpack --mode production",
|
|
66
68
|
"test": "jest",
|
|
67
69
|
"test-package": "npm pack"
|
|
70
|
+
},
|
|
71
|
+
"allowScripts": {
|
|
72
|
+
"@swc/core@1.15.46": true,
|
|
73
|
+
"unrs-resolver@1.11.1": true
|
|
68
74
|
}
|
|
69
75
|
}
|
|
@@ -56,10 +56,11 @@ function getCloseBoundaryPointsCertified(
|
|
|
56
56
|
return closestPointInfos.map(info => {
|
|
57
57
|
const { curve, t } = info;
|
|
58
58
|
const { ps } = curve;
|
|
59
|
-
const
|
|
59
|
+
const pDd = toP(ps, t);
|
|
60
|
+
const p = pDd.map(c => c[0] + c[1])
|
|
60
61
|
|
|
61
62
|
return {
|
|
62
|
-
|
|
63
|
+
curve, t, isSource: false, p, pDd
|
|
63
64
|
};
|
|
64
65
|
});
|
|
65
66
|
}
|
package/src/corner/get-corner.ts
CHANGED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { CpNode } from '../cp-node.js';
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Returns all `CpNode`s on the MAT that this `CpNode` is part of
|
|
6
|
+
* starting from the current one and going anti-clockwise around the shape
|
|
7
|
+
* going loop by loop.
|
|
8
|
+
*
|
|
9
|
+
* * sometimes more useful than `getAllOnLoop` since this function returns an
|
|
10
|
+
* array of `CpNode`s for each loop seperately.
|
|
11
|
+
*/
|
|
12
|
+
function getAllOnLoop_ByLoop(
|
|
13
|
+
cpNode: CpNode): CpNode[][] {
|
|
14
|
+
|
|
15
|
+
const cpNodess: CpNode[][] = [];
|
|
16
|
+
|
|
17
|
+
const cpStarts: CpNode[] = [cpNode];
|
|
18
|
+
const cpStartSet = new Set(cpStarts);
|
|
19
|
+
if (cpNode.isHoleClosing) {
|
|
20
|
+
cpStartSet.add(cpNode.prevOnCircle.holeCloserTwin!);
|
|
21
|
+
}
|
|
22
|
+
cpStartSet.add(cpNode);
|
|
23
|
+
|
|
24
|
+
while (cpStarts.length > 0) {
|
|
25
|
+
const cpNodes: CpNode[] = [];
|
|
26
|
+
|
|
27
|
+
const cpStart = cpStarts.pop()!;
|
|
28
|
+
const _loop = cpStart.pointOnShape.curve.loop;
|
|
29
|
+
let cpNode = cpStart;
|
|
30
|
+
|
|
31
|
+
do {
|
|
32
|
+
const loop = cpNode.pointOnShape.curve.loop;
|
|
33
|
+
if (_loop === loop) {
|
|
34
|
+
cpNodes.push(cpNode);
|
|
35
|
+
cpNode = cpNode.next;
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const twin = cpNode.holeCloserTwin!;
|
|
40
|
+
if (!cpStartSet.has(twin)) {
|
|
41
|
+
cpStartSet.add(twin);
|
|
42
|
+
cpStartSet.add(twin.prevOnCircle.holeCloserTwin!);
|
|
43
|
+
cpStarts.push(twin);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
cpNode = cpNode.prev.holeCloserTwin!;
|
|
47
|
+
} while (cpNode !== cpStart);
|
|
48
|
+
|
|
49
|
+
cpNodess.push(cpNodes);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return cpNodess;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
export { getAllOnLoop_ByLoop }
|
|
@@ -6,6 +6,7 @@ import { getBoundaryBezierPartsToNext } from './get-boundary-bezier-parts-to-nex
|
|
|
6
6
|
/**
|
|
7
7
|
* Returns the ordered bezier curves from this `CpNode` to the next `CpNode`
|
|
8
8
|
* on the boundary.
|
|
9
|
+
*
|
|
9
10
|
* @param cpNode
|
|
10
11
|
*/
|
|
11
12
|
function getBoundaryBeziersToNext(
|
|
@@ -17,76 +18,4 @@ function getBoundaryBeziersToNext(
|
|
|
17
18
|
}
|
|
18
19
|
|
|
19
20
|
|
|
20
|
-
// /**
|
|
21
|
-
// * Returns the boundary beziers between this `CpNode` and the next
|
|
22
|
-
// * one.
|
|
23
|
-
// *
|
|
24
|
-
// * * returns `[]` if the next `CpNode` is on a different loop,
|
|
25
|
-
// * as this is a hole-closer and there are no boundary beziers between them.
|
|
26
|
-
// *
|
|
27
|
-
// * @param cpNode
|
|
28
|
-
// */
|
|
29
|
-
// function getBoundaryBeziersToNext(
|
|
30
|
-
// cpNode: CpNode): number[][][] {
|
|
31
|
-
|
|
32
|
-
// const cpThis = cpNode;
|
|
33
|
-
// const cpNext = cpNode.next;
|
|
34
|
-
|
|
35
|
-
// const posThis = cpThis.cp.pointOnShape;
|
|
36
|
-
// const posNext = cpNext.cp.pointOnShape;
|
|
37
|
-
|
|
38
|
-
// const curveThis = posThis.curve;
|
|
39
|
-
// const curveNext = posNext.curve;
|
|
40
|
-
|
|
41
|
-
// if (curveThis.loop !== curveNext.loop) {
|
|
42
|
-
// // It is a hole-closer going over to the other loop - a kind of terminal
|
|
43
|
-
// // CpNode.
|
|
44
|
-
// // return undefined!;
|
|
45
|
-
// return [];
|
|
46
|
-
// }
|
|
47
|
-
|
|
48
|
-
// const beziers: number[][][] = [];
|
|
49
|
-
|
|
50
|
-
// if (curveNext === curveThis) {
|
|
51
|
-
// beziers.push(
|
|
52
|
-
// fromTo(posThis.curve.ps, posThis.t, posNext.t)
|
|
53
|
-
// );
|
|
54
|
-
// } else {
|
|
55
|
-
// beziers.push(
|
|
56
|
-
// fromTo(posThis.curve.ps, posThis.t, 1)
|
|
57
|
-
// );
|
|
58
|
-
|
|
59
|
-
// addSkippedBeziers(
|
|
60
|
-
// beziers,
|
|
61
|
-
// posThis.curve,
|
|
62
|
-
// posNext.curve,
|
|
63
|
-
// posNext.t
|
|
64
|
-
// );
|
|
65
|
-
// }
|
|
66
|
-
|
|
67
|
-
// return beziers;
|
|
68
|
-
// }
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
// /**
|
|
72
|
-
// * Adds pieces of skipped beziers.
|
|
73
|
-
// * @internal
|
|
74
|
-
// */
|
|
75
|
-
// function addSkippedBeziers(
|
|
76
|
-
// beziers: number[][][],
|
|
77
|
-
// curveStart: Curve,
|
|
78
|
-
// curveEnd: Curve,
|
|
79
|
-
// t1: number) {
|
|
80
|
-
|
|
81
|
-
// let curveThis = curveStart;
|
|
82
|
-
// do {
|
|
83
|
-
// curveThis = curveThis.next;
|
|
84
|
-
// const tEnd = curveThis === curveEnd ? t1 : 1;
|
|
85
|
-
// beziers.push(
|
|
86
|
-
// fromTo(curveThis.ps, 0, tEnd)
|
|
87
|
-
// );
|
|
88
|
-
// } while (curveThis !== curveEnd);
|
|
89
|
-
// }
|
|
90
|
-
|
|
91
|
-
|
|
92
21
|
export { getBoundaryBeziersToNext }
|
|
@@ -1,17 +1,21 @@
|
|
|
1
1
|
import type { Curve } from 'flo-boolean';
|
|
2
2
|
import type { CpNode } from '../cp-node.js';
|
|
3
|
-
import { toUnitVector, fromTo, rotate, translate, rotate90Degrees, reverse, dot } from 'flo-vector2d';
|
|
3
|
+
import { toUnitVector, fromTo, rotate, translate, rotate90Degrees, reverse as reverseVec, dot } from 'flo-vector2d';
|
|
4
4
|
import { tangent } from 'flo-bezier3';
|
|
5
5
|
import { isPosSharpCorner } from '../../point-on-shape/is-pos-sharp-corner.js';
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
|
-
* @internal
|
|
10
9
|
* Returns a line segment of unit length starting in the given Vertex center and
|
|
11
10
|
* pointing in the direction of the medial axis (viewed as a rooted tree).
|
|
11
|
+
*
|
|
12
12
|
* @param cpNode
|
|
13
|
+
*
|
|
14
|
+
* @internal
|
|
13
15
|
*/
|
|
14
|
-
function getEdgeDirection(
|
|
16
|
+
function getEdgeDirection(
|
|
17
|
+
cpNode: CpNode) {
|
|
18
|
+
|
|
15
19
|
const circleCenter = cpNode.pointOnShape.circle.center;
|
|
16
20
|
|
|
17
21
|
const cp1 = cpNode;
|
|
@@ -44,7 +48,7 @@ function getEdgeDirection(cpNode: CpNode) {
|
|
|
44
48
|
}
|
|
45
49
|
|
|
46
50
|
const tan1 = toUnitVector(tangent(curve1!.ps, 0));
|
|
47
|
-
const tan2 =
|
|
51
|
+
const tan2 = reverseVec( toUnitVector(tangent(curve2!.ps, 1)) );
|
|
48
52
|
|
|
49
53
|
const x = dot(tan1, tan2);
|
|
50
54
|
// Recall the identities sin(acos(x)) = sqrt(1-x^2), etc. Also
|