flo-mat 4.1.5 → 5.0.2
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__/closest-boundary-point/get-endpoint-info.spec.ts +140 -0
- package/__tests__/closest-boundary-point/root-interval-to-distance-squared-interval.spec.ts +87 -0
- package/__tests__/cp-node/fs/get-all-on-loop-by-loop.spec.ts +55 -0
- package/__tests__/cp-node/fs/get-angle-between-mat-curves.spec.ts +39 -3
- package/__tests__/cp-node/fs/get-boundary-bezier-parts-to-next.spec.ts +87 -3
- package/__tests__/cp-node/fs/get-boundary-beziers-between.spec.ts +68 -3
- package/__tests__/cp-node/fs/get-boundary-beziers-to-next.spec.ts +41 -3
- package/__tests__/cp-node/fs/get-boundary-distance-to-next.spec.ts +20 -3
- package/__tests__/cp-node/fs/get-branch-beziers.spec.ts +42 -3
- package/__tests__/cp-node/fs/get-branch.spec.ts +60 -3
- package/__tests__/cp-node/fs/get-cp-node-ordering.spec.ts +19 -3
- package/__tests__/cp-node/fs/get-distance-to-next.spec.ts +37 -4
- package/__tests__/cp-node/fs/get-edge-direction.spec.ts +50 -3
- package/__tests__/cp-node/fs/get-first-exit.spec.ts +78 -3
- package/__tests__/cp-node/fs/get-hole-closers.spec.ts +32 -3
- package/__tests__/cp-node/fs/get-implied-boundary-bezier-between.spec.ts +48 -3
- package/__tests__/cp-node/fs/get-mat-curve-between.spec.ts +77 -3
- package/__tests__/cp-node/fs/get-mat-curve-to-next.spec.ts +17 -4
- package/__tests__/cp-node/fs/get-mat-curves-between.spec.ts +38 -3
- package/__tests__/cp-node/fs/get-salience.spec.ts +68 -3
- package/__tests__/cp-node/fs/get-vertex-forward-children.spec.ts +40 -3
- package/__tests__/cp-node/fs/insert-cp-node.spec.ts +87 -3
- package/__tests__/cp-node/fs/is-special.spec.ts +1 -1
- package/__tests__/cp-node/fs/remove-cp-node.spec.ts +42 -3
- package/__tests__/find-2-prong/calc-seperation-tolerance.spec.ts +46 -0
- package/__tests__/find-2-prong/get-medial/get-closest-points.spec.ts +1 -1
- package/__tests__/floyd-warshall/get-graph.spec.ts +100 -0
- package/__tests__/get-mats-with-hole.ts +28 -0
- package/__tests__/get-mats1.spec.ts +61 -0
- package/__tests__/get-mats1.ts +75 -67
- package/__tests__/helpers/cp-node-by-id.ts +27 -0
- package/__tests__/helpers/expect-point-close.ts +42 -0
- package/__tests__/mat/hausdorff-distance-one-sided-exceeds.spec.ts +129 -0
- package/__tests__/mat/simplify-mat.spec.ts +85 -0
- package/__tests__/reconstruct-from-mat/reconstruct-from-mat.spec.ts +39 -0
- package/__tests__/specific-cases/test-svgs/achispado.svg +14 -0
- package/__tests__/utils/get-beziers-from-tangents.spec.ts +142 -0
- package/browser/index.js +12985 -9965
- package/browser/index.min.js +1 -1
- package/node/closest-boundary-point/cull-curve-pieces.d.ts +21 -0
- package/node/closest-boundary-point/cull-curve-pieces.js +40 -0
- package/node/closest-boundary-point/cull-curve-pieces.js.map +1 -0
- package/node/closest-boundary-point/get-close-boundary-points-certified.js +5 -2
- package/node/closest-boundary-point/get-close-boundary-points-certified.js.map +1 -1
- package/node/closest-boundary-point/get-endpoint-info.d.ts +39 -0
- package/node/closest-boundary-point/get-endpoint-info.js +78 -0
- package/node/closest-boundary-point/get-endpoint-info.js.map +1 -0
- package/node/closest-boundary-point/get-potential-closest-points-on-curve-certified.js +5 -19
- package/node/closest-boundary-point/get-potential-closest-points-on-curve-certified.js.map +1 -1
- package/node/closest-boundary-point/root-interval-to-distance-squared-interval.d.ts +17 -5
- package/node/closest-boundary-point/root-interval-to-distance-squared-interval.js +37 -50
- package/node/closest-boundary-point/root-interval-to-distance-squared-interval.js.map +1 -1
- package/node/corner/get-corner.d.ts +18 -1
- package/node/corner/get-corner.js +8 -1
- package/node/corner/get-corner.js.map +1 -1
- package/node/corner/get-interface-ccw.js.map +1 -1
- package/node/cp-node/cp-node.d.ts +4 -3
- package/node/cp-node/fs/get-all-on-loop-by-loop.js +0 -4
- package/node/cp-node/fs/get-all-on-loop-by-loop.js.map +1 -1
- package/node/cp-node/fs/get-angle-between-mat-curves.js +6 -4
- package/node/cp-node/fs/get-angle-between-mat-curves.js.map +1 -1
- package/node/cp-node/fs/get-boundary-beziers-between.d.ts +6 -4
- package/node/cp-node/fs/get-boundary-beziers-between.js +6 -4
- package/node/cp-node/fs/get-boundary-beziers-between.js.map +1 -1
- package/node/cp-node/fs/get-branch-beziers.d.ts +2 -1
- package/node/cp-node/fs/get-branch-beziers.js +3 -2
- package/node/cp-node/fs/get-branch-beziers.js.map +1 -1
- package/node/cp-node/fs/get-branch.js +1 -2
- package/node/cp-node/fs/get-branch.js.map +1 -1
- package/node/cp-node/fs/get-distance-to-next.js +4 -2
- package/node/cp-node/fs/get-distance-to-next.js.map +1 -1
- package/node/cp-node/fs/get-first-exit.d.ts +7 -3
- package/node/cp-node/fs/get-first-exit.js +13 -11
- package/node/cp-node/fs/get-first-exit.js.map +1 -1
- package/node/cp-node/fs/get-implied-boundary-bezier-between.d.ts +9 -1
- package/node/cp-node/fs/get-implied-boundary-bezier-between.js +11 -55
- package/node/cp-node/fs/get-implied-boundary-bezier-between.js.map +1 -1
- package/node/cp-node/fs/get-mat-curve-between.d.ts +4 -3
- package/node/cp-node/fs/get-mat-curve-between.js +5 -49
- package/node/cp-node/fs/get-mat-curve-between.js.map +1 -1
- package/node/cp-node/fs/get-mat-curve-to-next.d.ts +1 -1
- package/node/cp-node/fs/get-mat-curves-between.d.ts +8 -0
- package/node/cp-node/fs/get-mat-curves-between.js +9 -2
- package/node/cp-node/fs/get-mat-curves-between.js.map +1 -1
- package/node/cp-node/fs/get-real-prong-count.d.ts +2 -1
- package/node/cp-node/fs/get-real-prong-count.js +11 -5
- package/node/cp-node/fs/get-real-prong-count.js.map +1 -1
- package/node/cp-node/fs/get-salience.d.ts +10 -0
- package/node/cp-node/fs/get-salience.js +17 -1
- package/node/cp-node/fs/get-salience.js.map +1 -1
- package/node/cp-node/fs/is-fully-terminating.d.ts +4 -2
- package/node/cp-node/fs/is-fully-terminating.js +6 -15
- package/node/cp-node/fs/is-fully-terminating.js.map +1 -1
- package/node/cp-node/fs/is-on-same-loop.d.ts +1 -1
- package/node/cp-node/fs/is-special.d.ts +7 -0
- package/node/cp-node/fs/is-special.js +9 -2
- package/node/cp-node/fs/is-special.js.map +1 -1
- package/node/cp-node/fs/is-vertex.d.ts +1 -1
- package/node/cp-node/fs/traverse-edges.d.ts +7 -3
- package/node/cp-node/fs/traverse-edges.js +7 -3
- package/node/cp-node/fs/traverse-edges.js.map +1 -1
- package/node/cp-node/stringification/from-stringifyable.d.ts +2 -2
- package/node/cp-node/stringification/from-stringifyable.js +1 -1
- package/node/cp-node/stringification/from-stringifyable.js.map +1 -1
- package/node/cp-node/stringification/to-stringifyable.d.ts +3 -3
- package/node/cp-node/stringification/to-stringifyable.js +3 -3
- package/node/debug/debug.d.ts +26 -3
- package/node/debug/debug.js +16 -5
- package/node/debug/debug.js.map +1 -1
- package/node/find-2-prong/add-2-prong.js +1 -7
- package/node/find-2-prong/add-2-prong.js.map +1 -1
- package/node/find-2-prong/calc-seperation-tolerance.d.ts +28 -5
- package/node/find-2-prong/calc-seperation-tolerance.js +32 -89
- package/node/find-2-prong/calc-seperation-tolerance.js.map +1 -1
- package/node/find-2-prong/find-2-prong.js +8 -10
- package/node/find-2-prong/find-2-prong.js.map +1 -1
- package/node/find-2-prong/find-and-add-2-prongs.js +2 -2
- package/node/find-2-prong/find-and-add-2-prongs.js.map +1 -1
- package/node/find-2-prong/get-medial/get-antipodal-points.d.ts +1 -2
- package/node/find-2-prong/get-medial/get-antipodal-points.js +2 -3
- 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 +1 -8
- package/node/find-2-prong/get-medial/get-closest-points.js +4 -40
- package/node/find-2-prong/get-medial/get-closest-points.js.map +1 -1
- package/node/find-2-prong/reduce-radius.d.ts +1 -1
- package/node/find-2-prong/reduce-radius.js +6 -3
- package/node/find-2-prong/reduce-radius.js.map +1 -1
- package/node/find-3-prong/calc-better-x.js +1 -1
- package/node/find-3-prong/calc-better-x.js.map +1 -1
- package/node/find-3-prong/find-3-prong-for-delta3s.d.ts +3 -2
- package/node/find-3-prong/find-3-prong-for-delta3s.js +35 -41
- package/node/find-3-prong/find-3-prong-for-delta3s.js.map +1 -1
- package/node/find-3-prong/find-3-prong.js +3 -1
- package/node/find-3-prong/find-3-prong.js.map +1 -1
- package/node/find-3-prong/find-and-add-3-prongs.js +16 -0
- package/node/find-3-prong/find-and-add-3-prongs.js.map +1 -1
- package/node/find-mat/create-initial-cp-tree.js +2 -2
- package/node/find-mat/create-initial-cp-tree.js.map +1 -1
- package/node/find-mat/find-mat.js +3 -4
- package/node/find-mat/find-mat.js.map +1 -1
- package/node/find-mat/find-mats.d.ts +6 -12
- package/node/find-mat/find-mats.js +10 -27
- package/node/find-mat/find-mats.js.map +1 -1
- package/node/find-mat/get-dull-corners-on-loop.js +2 -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 +36 -8
- package/node/find-mat/get-for-1-prongs-on-loop.js.map +1 -1
- package/node/find-mat/get-meta.d.ts +14 -4
- package/node/find-mat/get-meta.js +30 -24
- package/node/find-mat/get-meta.js.map +1 -1
- package/node/find-mat/get-sharp-corners.js +2 -2
- package/node/find-mat/get-sharp-corners.js.map +1 -1
- package/node/find-mat/mat-options.d.ts +2 -2
- package/node/floyd-warshall/get-graph.d.ts +12 -1
- package/node/floyd-warshall/get-graph.js +41 -38
- package/node/floyd-warshall/get-graph.js.map +1 -1
- package/node/geometry/get-bounding-box-.d.ts +16 -2
- package/node/geometry/get-bounding-box-.js +5 -2
- package/node/geometry/get-bounding-box-.js.map +1 -1
- package/node/geometry/get-closest-square-distance-to-rect.d.ts +3 -0
- package/node/geometry/get-closest-square-distance-to-rect.js +7 -5
- package/node/geometry/get-closest-square-distance-to-rect.js.map +1 -1
- package/node/geometry/get-closest-squared-distance-to-rotated-rect.d.ts +4 -0
- package/node/geometry/get-closest-squared-distance-to-rotated-rect.js +11 -5
- package/node/geometry/get-closest-squared-distance-to-rotated-rect.js.map +1 -1
- package/node/get-medial-points/double-double/dd-get-medial-point-coeffs-bez3.js +1 -2
- package/node/get-medial-points/double-double/dd-get-medial-point-coeffs-bez3.js.map +1 -1
- package/node/index.d.ts +3 -2
- package/node/index.js +2 -1
- package/node/index.js.map +1 -1
- package/node/mat/clone-mat.d.ts +9 -0
- package/node/mat/clone-mat.js +17 -0
- package/node/mat/clone-mat.js.map +1 -0
- package/node/mat/clone-meta.d.ts +12 -0
- package/node/mat/clone-meta.js +24 -0
- package/node/mat/clone-meta.js.map +1 -0
- package/node/mat/get-boundary-piece-beziers.d.ts +5 -0
- package/node/mat/get-boundary-piece-beziers.js +7 -93
- package/node/mat/get-boundary-piece-beziers.js.map +1 -1
- package/node/mat/get-largest-3-prong.d.ts +6 -0
- package/node/mat/get-largest-3-prong.js +8 -5
- package/node/mat/get-largest-3-prong.js.map +1 -1
- package/node/mat/get-largest-vertex.d.ts +15 -1
- package/node/mat/get-largest-vertex.js +20 -7
- package/node/mat/get-largest-vertex.js.map +1 -1
- package/node/mat/hausdorff-distance-one-sided-exceeds.d.ts +79 -0
- package/node/mat/hausdorff-distance-one-sided-exceeds.js +251 -0
- package/node/mat/hausdorff-distance-one-sided-exceeds.js.map +1 -0
- package/node/mat/mat-meta.d.ts +0 -6
- package/node/mat/simplify-mat.d.ts +25 -8
- package/node/mat/simplify-mat.js +182 -53
- package/node/mat/simplify-mat.js.map +1 -1
- package/node/mat/trim-mat.d.ts +4 -2
- package/node/mat/trim-mat.js +3 -1
- package/node/mat/trim-mat.js.map +1 -1
- package/node/point-on-shape/get-boundary-tangent-line.d.ts +19 -0
- package/node/point-on-shape/get-boundary-tangent-line.js +33 -0
- package/node/point-on-shape/get-boundary-tangent-line.js.map +1 -0
- package/node/point-on-shape/get-osculating-circle.d.ts +6 -4
- package/node/point-on-shape/get-osculating-circle.js +6 -4
- package/node/point-on-shape/get-osculating-circle.js.map +1 -1
- package/node/point-on-shape/get-pos-corner.js +2 -2
- package/node/point-on-shape/get-pos-corner.js.map +1 -1
- package/node/reconstruct-from-mat/reconstruct-from-mat.js +20 -80
- package/node/reconstruct-from-mat/reconstruct-from-mat.js.map +1 -1
- package/node/reconstruct-from-mat/remove-sat-induced-trivial-3prongs.d.ts +4 -0
- package/node/reconstruct-from-mat/remove-sat-induced-trivial-3prongs.js +4 -0
- package/node/reconstruct-from-mat/remove-sat-induced-trivial-3prongs.js.map +1 -1
- package/node/sat/cull.d.ts +7 -6
- package/node/sat/cull.js +13 -16
- package/node/sat/cull.js.map +1 -1
- package/node/sat/get-sat-culls.d.ts +12 -2
- package/node/sat/get-sat-culls.js +21 -16
- package/node/sat/get-sat-culls.js.map +1 -1
- package/node/svg/get-shape-bounds.d.ts +1 -12
- package/node/svg/get-shape-bounds.js +2 -3
- package/node/svg/get-shape-bounds.js.map +1 -1
- package/node/sweep-line/sweep-line.js.map +1 -1
- package/node/utils/get-beziers-from-tangents.d.ts +28 -0
- package/node/utils/get-beziers-from-tangents.js +92 -0
- package/node/utils/get-beziers-from-tangents.js.map +1 -0
- package/node/vertex/remove-vertex.d.ts +5 -3
- package/node/vertex/remove-vertex.js +5 -3
- package/node/vertex/remove-vertex.js.map +1 -1
- package/package.json +9 -9
- package/qv-infinite-loop.md +120 -0
- package/src/closest-boundary-point/cull-curve-pieces.ts +49 -0
- package/src/closest-boundary-point/get-close-boundary-points-certified.ts +5 -2
- package/src/closest-boundary-point/get-endpoint-info.ts +96 -0
- package/src/closest-boundary-point/get-potential-closest-points-on-curve-certified.ts +5 -23
- package/src/closest-boundary-point/root-interval-to-distance-squared-interval.ts +42 -60
- package/src/corner/get-corner.ts +10 -1
- package/src/corner/get-interface-ccw.ts +2 -2
- package/src/cp-node/cp-node.ts +4 -3
- package/src/cp-node/fs/get-all-on-loop-by-loop.ts +0 -4
- package/src/cp-node/fs/get-angle-between-mat-curves.ts +6 -4
- package/src/cp-node/fs/get-boundary-beziers-between.ts +10 -8
- package/src/cp-node/fs/get-branch-beziers.ts +3 -2
- package/src/cp-node/fs/get-branch.ts +1 -2
- package/src/cp-node/fs/get-distance-to-next.ts +4 -2
- package/src/cp-node/fs/get-first-exit.ts +15 -14
- package/src/cp-node/fs/get-implied-boundary-bezier-between.ts +17 -69
- package/src/cp-node/fs/get-mat-curve-between.ts +9 -67
- package/src/cp-node/fs/get-mat-curves-between.ts +9 -2
- package/src/cp-node/fs/get-real-prong-count.ts +11 -7
- package/src/cp-node/fs/get-salience.ts +15 -2
- package/src/cp-node/fs/is-fully-terminating.ts +6 -18
- package/src/cp-node/fs/is-on-same-loop.ts +2 -2
- package/src/cp-node/fs/is-special.ts +11 -6
- package/src/cp-node/fs/is-vertex.ts +1 -1
- package/src/cp-node/fs/traverse-edges.ts +8 -4
- package/src/cp-node/stringification/from-stringifyable.ts +75 -75
- package/src/cp-node/stringification/to-stringifyable.ts +3 -3
- package/src/debug/debug.ts +44 -8
- package/src/find-2-prong/add-2-prong.ts +2 -9
- package/src/find-2-prong/calc-seperation-tolerance.ts +34 -115
- package/src/find-2-prong/find-2-prong.ts +9 -11
- package/src/find-2-prong/find-and-add-2-prongs.ts +2 -2
- package/src/find-2-prong/get-medial/get-antipodal-points.ts +1 -3
- package/src/find-2-prong/get-medial/get-closest-points.ts +6 -51
- package/src/find-2-prong/reduce-radius.ts +6 -4
- package/src/find-3-prong/calc-better-x.ts +2 -2
- package/src/find-3-prong/find-3-prong-for-delta3s.ts +197 -214
- package/src/find-3-prong/find-3-prong.ts +54 -51
- package/src/find-3-prong/find-and-add-3-prongs.ts +20 -1
- package/src/find-mat/create-initial-cp-tree.ts +2 -2
- package/src/find-mat/find-mat.ts +4 -6
- package/src/find-mat/find-mats.ts +83 -105
- package/src/find-mat/get-dull-corners-on-loop.ts +2 -2
- package/src/find-mat/get-for-1-prongs-on-loop.ts +40 -8
- package/src/find-mat/get-meta.ts +34 -39
- package/src/find-mat/get-sharp-corners.ts +2 -2
- package/src/find-mat/mat-options.ts +2 -2
- package/src/floyd-warshall/get-graph.ts +46 -47
- package/src/geometry/get-bounding-box-.ts +5 -2
- package/src/geometry/get-closest-square-distance-to-rect.ts +7 -7
- package/src/geometry/get-closest-squared-distance-to-rotated-rect.ts +12 -10
- package/src/get-medial-points/double-double/dd-get-medial-point-coeffs-bez3.ts +1 -2
- package/src/index.ts +3 -2
- package/src/mat/clone-mat.ts +9 -3
- package/src/mat/clone-meta.ts +8 -0
- package/src/mat/get-boundary-piece-beziers.ts +16 -117
- package/src/mat/get-largest-3-prong.ts +9 -6
- package/src/mat/get-largest-vertex.ts +25 -9
- package/src/mat/hausdorff-distance-one-sided-exceeds.ts +314 -0
- package/src/mat/mat-meta.ts +0 -9
- package/src/mat/simplify-mat.ts +254 -116
- package/src/mat/trim-mat.ts +6 -4
- package/src/point-on-shape/get-boundary-tangent-line.ts +36 -0
- package/src/point-on-shape/get-osculating-circle.ts +7 -5
- package/src/point-on-shape/get-pos-corner.ts +2 -2
- package/src/reconstruct-from-mat/reconstruct-from-mat.ts +22 -111
- package/src/reconstruct-from-mat/remove-sat-induced-trivial-3prongs.ts +4 -0
- package/src/sat/cull.ts +16 -20
- package/src/sat/get-sat-culls.ts +28 -23
- package/src/svg/get-shape-bounds.ts +2 -3
- package/src/sweep-line/sweep-line.ts +1 -1
- package/src/utils/get-beziers-from-tangents.ts +110 -0
- package/src/utils/map-map.ts +1 -1
- package/src/vertex/remove-vertex.ts +5 -3
- package/__tests__/cp-node/fs/get-distance-between.spec.ts +0 -7
- package/__tests__/cp-node/fs/get-terminating-on-circle.spec.ts +0 -24
- package/__tests__/cp-node/fs/is-single-3-prong.spec.ts +0 -17
- package/__tests__/cp-node/fs/iterate-all-on-loop.spec.ts +0 -17
- package/__tests__/cp-node/fs/traverse-all-forward.spec.ts +0 -14
- package/node/closest-boundary-point/cull-bezier-pieces-1.d.ts +0 -9
- package/node/closest-boundary-point/cull-bezier-pieces-1.js +0 -17
- package/node/closest-boundary-point/cull-bezier-pieces-1.js.map +0 -1
- package/node/closest-boundary-point/cull-by-loose-bounding-box.d.ts +0 -13
- package/node/closest-boundary-point/cull-by-loose-bounding-box.js +0 -27
- package/node/closest-boundary-point/cull-by-loose-bounding-box.js.map +0 -1
- package/node/closest-boundary-point/cull-by-tight-boundary-box.d.ts +0 -11
- package/node/closest-boundary-point/cull-by-tight-boundary-box.js +0 -27
- package/node/closest-boundary-point/cull-by-tight-boundary-box.js.map +0 -1
- package/node/cp-node/fs/find-first.d.ts +0 -10
- package/node/cp-node/fs/find-first.js +0 -19
- package/node/cp-node/fs/find-first.js.map +0 -1
- package/node/debug/functions/check-ordering.d.ts +0 -4
- package/node/debug/functions/check-ordering.js +0 -43
- package/node/debug/functions/check-ordering.js.map +0 -1
- package/node/find-2-prong/cull-bezier-pieces.d.ts +0 -13
- package/node/find-2-prong/cull-bezier-pieces.js +0 -43
- package/node/find-2-prong/cull-bezier-pieces.js.map +0 -1
- package/node/floyd-warshall/get-hole-closer-pairs.d.ts +0 -8
- package/node/floyd-warshall/get-hole-closer-pairs.js +0 -27
- package/node/floyd-warshall/get-hole-closer-pairs.js.map +0 -1
- package/node/utils/dual-set.d.ts +0 -27
- package/node/utils/dual-set.js +0 -55
- package/node/utils/dual-set.js.map +0 -1
- package/node/utils/tri-map.d.ts +0 -27
- package/node/utils/tri-map.js +0 -49
- package/node/utils/tri-map.js.map +0 -1
- package/src/closest-boundary-point/cull-bezier-pieces-1.ts +0 -36
- package/src/closest-boundary-point/cull-by-loose-bounding-box.ts +0 -42
- package/src/closest-boundary-point/cull-by-tight-boundary-box.ts +0 -43
- package/src/closest-boundary-point/get-p-from-box.ts +0 -14
- package/src/cp-node/fs/add-distance-from.ts +0 -49
- package/src/cp-node/fs/get-distance-between.ts +0 -16
- package/src/cp-node/fs/get-terminating-on-circle.ts +0 -24
- package/src/cp-node/fs/is-single-3-prong.ts +0 -15
- package/src/cp-node/fs/iterate-all-on-loop.ts +0 -15
- package/src/cp-node/fs/traverse-all-forward.ts +0 -24
- package/src/debug/functions/draw/draw-beziers-as-single-path.ts +0 -40
- package/src/debug/functions/draw/draw-disk.ts +0 -34
- package/src/debug/functions/draw/xmlns.ts +0 -5
- package/src/find-2-prong/cull-bezier-pieces.ts +0 -61
- package/src/find-2-prong/find-and-add-2-prong.ts +0 -30
- package/src/find-2-prong/get-medial/get-closest-points-d.ts +0 -213
- package/src/find-2-prong/x-for-debugging.ts +0 -13
- package/src/floyd-warshall/get-hole-closer-pairs.ts +0 -35
- package/src/mat/get-two-prong-type.ts +0 -13
- package/src/point-on-shape/is-pos-dull-corner.ts +0 -18
- package/src/point-on-shape/is-pos-quite-dull-corner.ts +0 -18
- package/src/point-on-shape/is-pos-quite-sharp-corner.ts +0 -18
- package/src/point-on-shape/pos-to-human-string.ts +0 -18
- package/src/sweep-line/are-boxes-intersecting.ts +0 -37
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { distanceBetween
|
|
2
|
-
import { tangent as getTangent } from 'flo-bezier3';
|
|
1
|
+
import { distanceBetween } from 'flo-vector2d';
|
|
3
2
|
import { mapDeep } from '../utils/map-deep.js';
|
|
4
3
|
import { removeSatInducedTrivial3Prongs } from './remove-sat-induced-trivial-3prongs.js';
|
|
5
4
|
import { getCpNodessForSat } from './get-cp-nodess-for-sat.js';
|
|
6
|
-
import {
|
|
5
|
+
import { clone } from '../cp-node/fs/clone.js';
|
|
6
|
+
import { getBoundaryTangentLine } from '../point-on-shape/get-boundary-tangent-line.js';
|
|
7
|
+
import { getBeziersFromTangents } from '../utils/get-beziers-from-tangents.js';
|
|
7
8
|
const { max, abs, round, log2 } = Math;
|
|
8
9
|
// let ii = 0;
|
|
9
10
|
/**
|
|
@@ -14,18 +15,25 @@ const { max, abs, round, log2 } = Math;
|
|
|
14
15
|
* @internal
|
|
15
16
|
*/
|
|
16
17
|
function reconstructFromMats(mats, minNumAccurateBits = undefined) {
|
|
17
|
-
|
|
18
|
+
let maxPO2 = -Infinity;
|
|
19
|
+
for (const mat of mats) {
|
|
20
|
+
maxPO2 = max(maxPO2, mat.meta.maxCoordPowerOf2);
|
|
21
|
+
}
|
|
18
22
|
const recoverBoundary_ = recoverBoundary(maxPO2, minNumAccurateBits);
|
|
23
|
+
// `removeSatInducedTrivial3Prongs` relinks nodes in place so work on
|
|
24
|
+
// clones - the given `Mat`s must not be modified. (Only
|
|
25
|
+
// `meta.maxCoordPowerOf2` is used from the metas so they can be shared.)
|
|
19
26
|
// Really only required if getSats was called on the `Mat`s
|
|
20
27
|
const cpNodessPerSat = mats
|
|
28
|
+
.map(mat => ({ cpNode: clone(mat.cpNode), meta: mat.meta }))
|
|
21
29
|
.map(removeSatInducedTrivial3Prongs)
|
|
22
30
|
.map(getCpNodessForSat);
|
|
23
31
|
const r = mapDeep(3, cpNodessPerSat, recoverBoundary_, true);
|
|
24
32
|
// ii;//?
|
|
25
|
-
|
|
33
|
+
// Flatten the (1 or 2) beziers per boundary piece into a single array of
|
|
34
|
+
// beziers per loop.
|
|
35
|
+
return r.map(loops => loops.map(pieces => pieces.flat()));
|
|
26
36
|
}
|
|
27
|
-
const FROM = 0;
|
|
28
|
-
const TO = 1;
|
|
29
37
|
/**
|
|
30
38
|
*
|
|
31
39
|
* @param cpNode
|
|
@@ -48,8 +56,6 @@ function recoverBoundary(maxPO2, minNumAccurateBits) {
|
|
|
48
56
|
return undefined;
|
|
49
57
|
}
|
|
50
58
|
const d = distanceBetween(circle.center, p);
|
|
51
|
-
if (getRealProngCount(cpNode)) {
|
|
52
|
-
}
|
|
53
59
|
// DON'T remove these - they tell us the accuracy of the algorithm
|
|
54
60
|
// if (!closeTo(2**34)(circle.radius, d) && getRealProngCount(cpNode) === 3) {
|
|
55
61
|
// ii++;
|
|
@@ -80,81 +86,15 @@ function recoverBoundary(maxPO2, minNumAccurateBits) {
|
|
|
80
86
|
return getBoundaryPiece(cpNode);
|
|
81
87
|
};
|
|
82
88
|
}
|
|
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
89
|
/**
|
|
136
|
-
* Returns
|
|
137
|
-
*
|
|
90
|
+
* Returns the bezier curves (1 or 2 lines or quadratics) approximating the
|
|
91
|
+
* shape boundary from the contact point of the given `CpNode` to that of the
|
|
92
|
+
* next `CpNode`.
|
|
138
93
|
*
|
|
139
94
|
* @internal
|
|
140
95
|
*/
|
|
141
|
-
function
|
|
142
|
-
|
|
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];
|
|
96
|
+
function getBoundaryPiece(cpNode) {
|
|
97
|
+
return getBeziersFromTangents(getBoundaryTangentLine(cpNode.pointOnShape, true), getBoundaryTangentLine(cpNode.next.pointOnShape, false));
|
|
158
98
|
}
|
|
159
99
|
export { reconstructFromMats };
|
|
160
100
|
//# sourceMappingURL=reconstruct-from-mat.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reconstruct-from-mat.js","sourceRoot":"","sources":["../../src/reconstruct-from-mat/reconstruct-from-mat.ts"],"names":[],"mappings":"AAGA,OAAO,
|
|
1
|
+
{"version":3,"file":"reconstruct-from-mat.js","sourceRoot":"","sources":["../../src/reconstruct-from-mat/reconstruct-from-mat.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,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,KAAK,EAAE,MAAM,wBAAwB,CAAC;AAC/C,OAAO,EAAE,sBAAsB,EAAE,MAAM,gDAAgD,CAAC;AACxF,OAAO,EAAE,sBAAsB,EAAE,MAAM,uCAAuC,CAAC;AAG/E,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC;AAGvC,cAAc;AAGd;;;;;;GAMG;AACH,SAAS,mBAAmB,CACpB,IAAW,EACX,kBAAkB,GAAuB,SAAS;IAEtD,IAAI,MAAM,GAAG,CAAC,QAAQ,CAAC;IACvB,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;QAAC,MAAM,GAAG,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;IAAC,CAAC;IAC5E,MAAM,gBAAgB,GAAG,eAAe,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC;IAErE,sEAAsE;IACtE,yDAAyD;IACzD,yEAAyE;IACzE,2DAA2D;IAC3D,MAAM,cAAc,GAAG,IAAI;SACtB,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,KA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G5C,kEAAkE;QAClE,8EAA8E;QAC9E,YAAY;QACZ,wBAAwB;QACxB,wBAAwB;QACxB,wBAAwB;QACxB,YAAY;QACZ,uBAAuB;QACvB,oCAAoC;QACpC,IAAI;QACJ,8EAA8E;QAC9E,YAAY;QACZ,wBAAwB;QACxB,wBAAwB;QACxB,wBAAwB;QACxB,YAAY;QACZ,uBAAuB;QACvB,oCAAoC;QACpC,IAAI;QACJ,IAAI,kBAAkB,KAAK,SAAS,EAAE,CAAC;YACnC,MAAM,GAAG,GAAG,CAAC,IAAE,CAAC,MAAM,GAAG,kBAAkB,CAAC,CAAC;YAE7C,IAAI,GAAG,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,GAAG,GAAG,EAAE,CAAC;gBAC/B,MAAM,IAAI,KAAK,CACX,mDAAmD,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI;oBACvE,2DAA2D;oBAC3D,wBAAwB,MAAM,CAAC,MAAM,eAAe,CAAC,EAAE,CAC1D,CAAC;YACN,CAAC;QACL,CAAC;QAED,OAAO,gBAAgB,CAAC,MAAM,CAAC,CAAC;IACpC,CAAC,CAAA;AACL,CAAC;AAGD;;;;;;GAMG;AACH,SAAS,gBAAgB,CACjB,MAAc;IAElB,OAAO,sBAAsB,CACzB,sBAAsB,CAAC,MAAM,CAAC,YAAY,EAAE,IAAI,CAAC,EACjD,sBAAsB,CAAC,MAAM,CAAC,IAAI,CAAC,YAAY,EAAE,KAAK,CAAC,CAC1D,CAAC;AACN,CAAC;AAGD,OAAO,EAAE,mBAAmB,EAAE,CAAA"}
|
|
@@ -3,6 +3,10 @@ import type { Mat } from '../mat/mat.js';
|
|
|
3
3
|
* In-place removes trivial 3-prongs from the SAT graph; just to simplify
|
|
4
4
|
* subsequent processing.
|
|
5
5
|
*
|
|
6
|
+
* * **mutates** the given `Mat` (its `CpNode`s are relinked and `cpNode` is
|
|
7
|
+
* reassigned; `meta.cpTrees` is left stale) - pass a clone if the original
|
|
8
|
+
* must be kept
|
|
9
|
+
*
|
|
6
10
|
* These are 3-prongs that are induced by the SAT construction, and do
|
|
7
11
|
* not correspond to actual 3-prongs in the shape.
|
|
8
12
|
*
|
|
@@ -3,6 +3,10 @@ import { isFullyTerminating } from '../cp-node/fs/is-fully-terminating.js';
|
|
|
3
3
|
* In-place removes trivial 3-prongs from the SAT graph; just to simplify
|
|
4
4
|
* subsequent processing.
|
|
5
5
|
*
|
|
6
|
+
* * **mutates** the given `Mat` (its `CpNode`s are relinked and `cpNode` is
|
|
7
|
+
* reassigned; `meta.cpTrees` is left stale) - pass a clone if the original
|
|
8
|
+
* must be kept
|
|
9
|
+
*
|
|
6
10
|
* These are 3-prongs that are induced by the SAT construction, and do
|
|
7
11
|
* not correspond to actual 3-prongs in the shape.
|
|
8
12
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"remove-sat-induced-trivial-3prongs.js","sourceRoot":"","sources":["../../src/reconstruct-from-mat/remove-sat-induced-trivial-3prongs.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAC;AAG3E
|
|
1
|
+
{"version":3,"file":"remove-sat-induced-trivial-3prongs.js","sourceRoot":"","sources":["../../src/reconstruct-from-mat/remove-sat-induced-trivial-3prongs.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAC;AAG3E;;;;;;;;;;;;GAYG;AACH,SAAS,8BAA8B,CAC/B,GAAQ;IAEZ,IAAI,EAAE,MAAM,EAAE,GAAG,GAAG,CAAC;IAErB,IAAI,OAAO,GAAG,MAAM,CAAC;IACrB,GAAG,CAAC;QACA,IAAI,kBAAkB,CAAC,MAAM,CAAC;YAC1B,iEAAiE;YACjE,MAAM,CAAC,IAAI,KAAK,MAAM,CAAC,YAAY,EAAE,CAAC;YAEtC,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC;YACrB,SAAS;QACb,CAAC;QAED,+BAA+B;QAC/B,6BAA6B;QAC7B,+BAA+B;QAC/B,uDAAuD;QAEvD,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC;QACzB,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC;QAC3B,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC;QAE5C,+DAA+D;QAC/D,8DAA8D;QAC9D,+DAA+D;QAC9D,MAAiC,CAAC,IAAI,GAAG,QAAQ,CAAC;QAClD,MAAiC,CAAC,YAAY,GAAG,UAAU,CAAC;QAC5D,QAAqC,CAAC,IAAI,GAAG,MAAM,CAAC;QACpD,UAAyC,CAAC,YAAY,GAAG,MAAM,CAAC;QACjE,+DAA+D;QAE/D,IAAI,OAAO,KAAK,IAAI,EAAE,CAAC;YACnB,OAAO,GAAG,MAAM,CAAC,CAAE,6CAA6C;QACpE,CAAC;QAED,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC;IACzB,CAAC,QAAQ,MAAM,KAAK,OAAO,EAAC;IAE5B,+FAA+F;IAC9F,GAAoB,CAAC,MAAM,GAAG,MAAM,CAAC;IAEtC,OAAO,GAAG,CAAC;AACf,CAAC;AAGD,OAAO,EAAE,8BAA8B,EAAE,CAAA"}
|
package/node/sat/cull.d.ts
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import type { CpNode } from '../cp-node/cp-node.js';
|
|
2
|
-
import type {
|
|
2
|
+
import type { Circle } from '../geometry/circle.js';
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* non-culled
|
|
4
|
+
* Culls (in place) the vertices of the given MAT tree: walking the tree from
|
|
5
|
+
* the maximal vertex, all vertices in the cull set are removed except those
|
|
6
|
+
* that have a non-culled vertex further down the line toward the tree leaves
|
|
7
|
+
* (which are kept to preserve the topology).
|
|
7
8
|
*
|
|
8
|
-
* @param culls the
|
|
9
|
+
* @param culls the vertices (identified by their `Circle`) that should be culled
|
|
9
10
|
* @param maxCpNode the start `CpNode` which must represent the maximal vertex
|
|
10
11
|
*
|
|
11
12
|
* @internal
|
|
12
13
|
*/
|
|
13
|
-
declare function cull(culls:
|
|
14
|
+
declare function cull(culls: Set<Circle>, maxCpNode: CpNode): void;
|
|
14
15
|
export { cull };
|
package/node/sat/cull.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { getLeaves } from './get-leaves.js';
|
|
2
2
|
import { isTerminating } from '../cp-node/fs/is-terminating.js';
|
|
3
|
-
import { DualSetFs } from '../utils/dual-set.js';
|
|
4
3
|
import { isOnSameCircle } from '../cp-node/fs/is-on-same-circle.js';
|
|
5
4
|
/**
|
|
6
5
|
* Returns the set of non-trivial forward edges starting from the given `CpNode`.
|
|
@@ -23,11 +22,12 @@ function getNonTrivialForwardEdges(cpStart) {
|
|
|
23
22
|
return cps;
|
|
24
23
|
}
|
|
25
24
|
/**
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
* non-culled
|
|
25
|
+
* Culls (in place) the vertices of the given MAT tree: walking the tree from
|
|
26
|
+
* the maximal vertex, all vertices in the cull set are removed except those
|
|
27
|
+
* that have a non-culled vertex further down the line toward the tree leaves
|
|
28
|
+
* (which are kept to preserve the topology).
|
|
29
29
|
*
|
|
30
|
-
* @param culls the
|
|
30
|
+
* @param culls the vertices (identified by their `Circle`) that should be culled
|
|
31
31
|
* @param maxCpNode the start `CpNode` which must represent the maximal vertex
|
|
32
32
|
*
|
|
33
33
|
* @internal
|
|
@@ -36,8 +36,7 @@ function cull(culls, maxCpNode) {
|
|
|
36
36
|
const leaves = getLeaves(maxCpNode);
|
|
37
37
|
while (leaves.length) {
|
|
38
38
|
const leaf = leaves.pop();
|
|
39
|
-
|
|
40
|
-
if (!DualSetFs.has(culls, c[0], c[1]) ||
|
|
39
|
+
if (!culls.has(leaf.pointOnShape.circle) ||
|
|
41
40
|
// Preserve topology.
|
|
42
41
|
leaf.isIntersection) {
|
|
43
42
|
continue;
|
|
@@ -46,8 +45,7 @@ function cull(culls, maxCpNode) {
|
|
|
46
45
|
let cut = false;
|
|
47
46
|
while (!cut) {
|
|
48
47
|
cpNode = cpNode.next;
|
|
49
|
-
|
|
50
|
-
if (!DualSetFs.has(culls, c[0], c[1])) {
|
|
48
|
+
if (!culls.has(cpNode.pointOnShape.circle)) {
|
|
51
49
|
// Cut off the edge once a non-cull has been reached.
|
|
52
50
|
while (isTerminating(cpNode.prevOnCircle)) {
|
|
53
51
|
cpNode = cpNode.prevOnCircle;
|
|
@@ -67,13 +65,12 @@ function cull(culls, maxCpNode) {
|
|
|
67
65
|
}
|
|
68
66
|
}
|
|
69
67
|
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
}
|
|
68
|
+
// Cut the edge: link the node we stopped at directly to the one before
|
|
69
|
+
// it on its circle (`cut` is necessarily `true` here; the on-circle
|
|
70
|
+
// links are already consistent by the ring invariant)
|
|
71
|
+
const cp1 = cpNode.prevOnCircle;
|
|
72
|
+
cp1.next = cpNode;
|
|
73
|
+
cpNode.prev = cp1;
|
|
77
74
|
}
|
|
78
75
|
}
|
|
79
76
|
export { cull };
|
package/node/sat/cull.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cull.js","sourceRoot":"","sources":["../../src/sat/cull.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAChE,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"cull.js","sourceRoot":"","sources":["../../src/sat/cull.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAChE,OAAO,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AAGpE;;;;GAIG;AAC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AG,MAAM,CAAC,YAAY,CAAC;gBACjC,CAAC;gBACD,GAAG,GAAG,IAAI,CAAC;YACf,CAAC;iBAAM,IAAI,cAAc,CAAC,MAAM,EAAE,SAAS,CAAC,EAAE,CAAC;gBAC3C,GAAG,GAAG,IAAI,CAAC,CAAC,0CAA0C;YAC1D,CAAC;iBAAM,CAAC;gBACJ,MAAM,GAAG,GAAG,yBAAyB,CAAC,MAAM,CAAC,CAAC;gBAE9C,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;oBACnB,SAAS;gBACb,CAAC;qBAAM,CAAC;oBACJ,GAAG,GAAG,IAAI,CAAC;gBACf,CAAC;YACL,CAAC;QACL,CAAC;QAED,uEAAuE;QACvE,oEAAoE;QACpE,sDAAsD;QACtD,MAAM,GAAG,GAAG,MAAM,CAAC,YAA+B,CAAC;QACnD,GAAG,CAAC,IAAI,GAAG,MAAM,CAAC;QACjB,MAA0B,CAAC,IAAI,GAAG,GAAG,CAAC;IAC3C,CAAC;AACL,CAAC;AAGD,OAAO,EAAE,IAAI,EAAE,CAAA"}
|
|
@@ -1,4 +1,14 @@
|
|
|
1
|
-
import type { DualSet } from "../utils/dual-set.js";
|
|
2
1
|
import type { CpNode } from "../cp-node/cp-node.js";
|
|
3
|
-
|
|
2
|
+
import type { Circle } from "../geometry/circle.js";
|
|
3
|
+
/**
|
|
4
|
+
* Returns the set of MAT vertices (identified by their `Circle` - all `CpNode`s
|
|
5
|
+
* on a vertex share the same `Circle` object) that are to be culled by the
|
|
6
|
+
* Scale Axis Transform with the given scale factor.
|
|
7
|
+
*
|
|
8
|
+
* @param cpNode the `CpNode` representing the maximal vertex
|
|
9
|
+
* @param s the scale factor
|
|
10
|
+
*
|
|
11
|
+
* @internal
|
|
12
|
+
*/
|
|
13
|
+
declare function getSatCulls(cpNode: CpNode, s: number): Set<Circle>;
|
|
4
14
|
export { getSatCulls };
|
|
@@ -1,29 +1,34 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { getAllOnCircle } from "../cp-node/fs/get-all-on-circle.js";
|
|
3
|
-
import { getMatCurveToNext } from "../cp-node/fs/get-mat-curve-to-next.js";
|
|
1
|
+
import { getMatDistanceToNext } from "../cp-node/fs/get-distance-to-next.js";
|
|
4
2
|
import { traverseEdges } from "../cp-node/fs/traverse-edges.js";
|
|
5
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Returns the set of MAT vertices (identified by their `Circle` - all `CpNode`s
|
|
5
|
+
* on a vertex share the same `Circle` object) that are to be culled by the
|
|
6
|
+
* Scale Axis Transform with the given scale factor.
|
|
7
|
+
*
|
|
8
|
+
* @param cpNode the `CpNode` representing the maximal vertex
|
|
9
|
+
* @param s the scale factor
|
|
10
|
+
*
|
|
11
|
+
* @internal
|
|
12
|
+
*/
|
|
6
13
|
function getSatCulls(cpNode, s) {
|
|
7
14
|
/**
|
|
8
15
|
* All vertices that are set to be culled initially. This may change later
|
|
9
16
|
* in order to preserve topology.
|
|
10
17
|
*/
|
|
11
|
-
const culls = new
|
|
18
|
+
const culls = new Set();
|
|
19
|
+
/** The osculating radius stored with each vertex. */
|
|
12
20
|
const rMap = new Map();
|
|
13
21
|
traverseEdges(cpNode, function (cpNode) {
|
|
14
|
-
|
|
15
|
-
const R = rMap.get(
|
|
22
|
+
const circle = cpNode.pointOnShape.circle;
|
|
23
|
+
const R = rMap.get(circle) ?? s * circle.radius;
|
|
16
24
|
const cpNode_ = cpNode.next;
|
|
17
|
-
const
|
|
18
|
-
const
|
|
19
|
-
const r_ = s *
|
|
25
|
+
const circle_ = cpNode_.pointOnShape.circle;
|
|
26
|
+
const l = getMatDistanceToNext(cpNode);
|
|
27
|
+
const r_ = s * circle_.radius;
|
|
20
28
|
if (R - l > r_) {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
const { center: c } = cpNode_.pointOnShape.circle;
|
|
25
|
-
DualSetFs.add(culls, c[0], c[1]);
|
|
26
|
-
}
|
|
29
|
+
rMap.set(circle_, R - l); // Update osculating radius
|
|
30
|
+
if (!cpNode_.isHoleClosing) {
|
|
31
|
+
culls.add(circle_);
|
|
27
32
|
}
|
|
28
33
|
}
|
|
29
34
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-sat-culls.js","sourceRoot":"","sources":["../../src/sat/get-sat-culls.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"get-sat-culls.js","sourceRoot":"","sources":["../../src/sat/get-sat-culls.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AAC7E,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAGhE;;;;;;;;;GASG;AACH,SAAS,WAAW,CACZ,MAAc,EACd,CAAS;IAEb;;;OAGG;IACH,MAAM,KAAK,GAAG,IAAI,GAAG,EAAU,CAAC;IAEhC,qDAAqD;IACrD,MAAM,IAAI,GAAG,IAAI,GAAG,EAAkB,CAAC;IAEvC,aAAa,CAAC,MAAM,EAAE,UAAS,MAAM;QACjC,MAAM,MAAM,GAAG,MAAM,CAAC,YAAY,CAAC,MAAM,CAAC;QAC1C,MAAM,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,GAAC,MAAM,CAAC,MAAM,CAAC;QAE9C,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC;QAC5B,MAAM,OAAO,GAAG,OAAO,CAAC,YAAY,CAAC,MAAM,CAAC;QAE5C,MAAM,CAAC,GAAG,oBAAoB,CAAC,MAAM,CAAC,CAAC;QAEvC,MAAM,EAAE,GAAG,CAAC,GAAC,OAAO,CAAC,MAAM,CAAC;QAC5B,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,CAAC;YACb,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,2BAA2B;YACrD,IAAI,CAAC,OAAO,CAAC,aAAa,EAAE,CAAC;gBACzB,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;YACvB,CAAC;QACL,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,OAAO,KAAK,CAAC;AACjB,CAAC;AAGD,OAAO,EAAE,WAAW,EAAE,CAAA"}
|
|
@@ -1,21 +1,10 @@
|
|
|
1
1
|
import type { Loop } from 'flo-boolean';
|
|
2
2
|
import type { PrePointOnShape } from '../point-on-shape/point-on-shape.js';
|
|
3
3
|
/** @internal */
|
|
4
|
-
declare
|
|
4
|
+
declare function getShapeBounds(loops: Loop[]): {
|
|
5
5
|
minX: PrePointOnShape;
|
|
6
6
|
minY: PrePointOnShape;
|
|
7
7
|
maxX: PrePointOnShape;
|
|
8
8
|
maxY: PrePointOnShape;
|
|
9
|
-
}) & {
|
|
10
|
-
readonly weakMapS: WeakMap<object, {
|
|
11
|
-
readonly weakMap: WeakMap<object, any>;
|
|
12
|
-
readonly map: Map<object, any>;
|
|
13
|
-
}>;
|
|
14
|
-
readonly mapS: Map<object, {
|
|
15
|
-
readonly weakMap: WeakMap<object, any>;
|
|
16
|
-
readonly map: Map<object, any>;
|
|
17
|
-
}>;
|
|
18
|
-
readonly clearCache: () => void;
|
|
19
|
-
readonly addToCache: (r: unknown, ...args: any) => void;
|
|
20
9
|
};
|
|
21
10
|
export { getShapeBounds };
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { memoize } from 'flo-memoize';
|
|
2
1
|
import { getLoopBounds$ } from './get-loop-bounds.js';
|
|
3
2
|
/** @internal */
|
|
4
|
-
|
|
3
|
+
function getShapeBounds(loops) {
|
|
5
4
|
let minX_ = +Infinity;
|
|
6
5
|
let maxX_ = -Infinity;
|
|
7
6
|
let minY_ = +Infinity;
|
|
@@ -35,6 +34,6 @@ const getShapeBounds = memoize(function (loops) {
|
|
|
35
34
|
maxX: maxX,
|
|
36
35
|
maxY: maxY
|
|
37
36
|
};
|
|
38
|
-
}
|
|
37
|
+
}
|
|
39
38
|
export { getShapeBounds };
|
|
40
39
|
//# sourceMappingURL=get-shape-bounds.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-shape-bounds.js","sourceRoot":"","sources":["../../src/svg/get-shape-bounds.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"get-shape-bounds.js","sourceRoot":"","sources":["../../src/svg/get-shape-bounds.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAGtD,gBAAgB;AAChB,SAAS,cAAc,CAAC,KAAa;IACjC,IAAI,KAAK,GAAG,CAAC,QAAQ,CAAC;IACtB,IAAI,KAAK,GAAG,CAAC,QAAQ,CAAC;IACtB,IAAI,KAAK,GAAG,CAAC,QAAQ,CAAC;IACtB,IAAI,KAAK,GAAG,CAAC,QAAQ,CAAC;IAEtB,IAAI,IAAqB,CAAC;IAC1B,IAAI,IAAqB,CAAC;IAC1B,IAAI,IAAqB,CAAC;IAC1B,IAAI,IAAqB,CAAC;IAE1B,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACvB,MAAM,MAAM,GAAG,cAAc,CAAC,IAAI,CAAC,CAAC;QACpC,IAAI,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,EAAE,CAAC;YAC3B,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC;YACnB,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAC7B,CAAC;QACD,IAAI,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,EAAE,CAAC;YAC3B,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC;YACnB,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAC7B,CAAC;QACD,IAAI,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CA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,MAAM,EAAE,CAAC;QACzB,MAAM,EAAE,IAAI,EAAE,GAAG,KAAK,CAAC;QAEpB,IAAI,KAAK,CAAC,IAAI,KAAK,UAAU,EAAE,CAAC;YAC5B,KAAK,MAAM,UAAU,IAAI,WAAW,CAAC,MAAM,EAAE,EAAE,CAAC;gBAC5C,IAAI,SAAS,CAAC,IAAI,EAAE,UAAU,CAAC,EAAE,CAAC;oBAC7B,WAAW,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC;gBAC1C,CAAC;YACL,CAAC;YAED,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAC1B,CAAC;aAAM,IAAI,KAAK,CAAC,IAAI,KAAK,WAAW,EAAE,CAAC;YACpC,WAAW,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACnC,CAAC;IACR,CAAC;IAED,OAAO,WAAW,CAAC;AACvB,CAAC;AAeD;;;;;;;GAOG;AACH,SAAS,OAAO,CAAI,CAAY,EAAE,CAAY;IAC1C,MAAM,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IAEtB,IAAI,GAAG,KAAK,CAAC,EAAE,CAAC;QAAC,OAAO,GAAG,CAAC;IAAC,CAAC;IAE9B,2CAA2C;IAC3C,OAAO,CAAC,CAAC,IAAI,KAAK,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAC3C,CAAC;AAGD,OAAO,EAAE,SAAS,EAAE,CAAA"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns an array of 1 or 2 bezier curves (each a line or a quadratic) that
|
|
3
|
+
* together form a smooth curve from the start point of `l0` to the start point
|
|
4
|
+
* of `l1` such that the curve is tangent to `l0` at its start and tangent to
|
|
5
|
+
* `l1` at its end.
|
|
6
|
+
*
|
|
7
|
+
* * `l0` and `l1` are given as `[p, p + dir]` where `p` is the curve endpoint
|
|
8
|
+
* and `dir` is the tangent direction (of any magnitude; its orientation does
|
|
9
|
+
* not matter)
|
|
10
|
+
* * if the tangent lines are not 'twisted' (they meet strictly between the
|
|
11
|
+
* endpoints along the chord) a single quadratic is returned
|
|
12
|
+
* * if the tangent lines are 'twisted' (the curve must have an inflection)
|
|
13
|
+
* 2 quadratics joined smoothly at the inflection are returned as an
|
|
14
|
+
* approximation - or, if both tangents deviate from the chord by less than
|
|
15
|
+
* `SIN_TOLERANCE_USE_LINE`, a single line
|
|
16
|
+
* * if the endpoints coincide (or a tangent is degenerate) a (degenerate) line
|
|
17
|
+
* is returned
|
|
18
|
+
*
|
|
19
|
+
* FUTURE: a strongly twisted MAT edge indicates that an additional 2-prong
|
|
20
|
+
* should be added so that the edge is approximated by two less twisted ones.
|
|
21
|
+
*
|
|
22
|
+
* @param l0 the tangent line at the start of the curve
|
|
23
|
+
* @param l1 the tangent line at the end of the curve
|
|
24
|
+
*
|
|
25
|
+
* @internal
|
|
26
|
+
*/
|
|
27
|
+
declare function getBeziersFromTangents(l0: number[][], l1: number[][]): number[][][];
|
|
28
|
+
export { getBeziersFromTangents };
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { fromTo, dot, cross, lineLineIntersection } from 'flo-vector2d';
|
|
2
|
+
const { abs, sqrt } = Math;
|
|
3
|
+
/**
|
|
4
|
+
* The maximum sine of the angle between the chord and either tangent for
|
|
5
|
+
* which a 'twisted' (inflected) curve is approximated by a straight line -
|
|
6
|
+
* the line then deviates from the true curve by only about a millionth of the
|
|
7
|
+
* chord length.
|
|
8
|
+
*
|
|
9
|
+
* * a relative (angle) tolerance and thus independent of the scale of the
|
|
10
|
+
* shape and of the magnitude of the given tangents
|
|
11
|
+
*
|
|
12
|
+
* @internal
|
|
13
|
+
*/
|
|
14
|
+
const SIN_TOLERANCE_USE_LINE = 2 ** -16;
|
|
15
|
+
/**
|
|
16
|
+
* Returns an array of 1 or 2 bezier curves (each a line or a quadratic) that
|
|
17
|
+
* together form a smooth curve from the start point of `l0` to the start point
|
|
18
|
+
* of `l1` such that the curve is tangent to `l0` at its start and tangent to
|
|
19
|
+
* `l1` at its end.
|
|
20
|
+
*
|
|
21
|
+
* * `l0` and `l1` are given as `[p, p + dir]` where `p` is the curve endpoint
|
|
22
|
+
* and `dir` is the tangent direction (of any magnitude; its orientation does
|
|
23
|
+
* not matter)
|
|
24
|
+
* * if the tangent lines are not 'twisted' (they meet strictly between the
|
|
25
|
+
* endpoints along the chord) a single quadratic is returned
|
|
26
|
+
* * if the tangent lines are 'twisted' (the curve must have an inflection)
|
|
27
|
+
* 2 quadratics joined smoothly at the inflection are returned as an
|
|
28
|
+
* approximation - or, if both tangents deviate from the chord by less than
|
|
29
|
+
* `SIN_TOLERANCE_USE_LINE`, a single line
|
|
30
|
+
* * if the endpoints coincide (or a tangent is degenerate) a (degenerate) line
|
|
31
|
+
* is returned
|
|
32
|
+
*
|
|
33
|
+
* FUTURE: a strongly twisted MAT edge indicates that an additional 2-prong
|
|
34
|
+
* should be added so that the edge is approximated by two less twisted ones.
|
|
35
|
+
*
|
|
36
|
+
* @param l0 the tangent line at the start of the curve
|
|
37
|
+
* @param l1 the tangent line at the end of the curve
|
|
38
|
+
*
|
|
39
|
+
* @internal
|
|
40
|
+
*/
|
|
41
|
+
function getBeziersFromTangents(l0, l1) {
|
|
42
|
+
const p0 = l0[0];
|
|
43
|
+
const p1 = l1[0];
|
|
44
|
+
const c = fromTo(p0, p1);
|
|
45
|
+
if (c[0] === 0 && c[1] === 0) {
|
|
46
|
+
return [[p0, p1]]; // coinciding endpoints - a degenerate line
|
|
47
|
+
}
|
|
48
|
+
const w0 = fromTo(l0[0], l0[1]);
|
|
49
|
+
const w1 = fromTo(l1[0], l1[1]);
|
|
50
|
+
const lc = sqrt(dot(c, c));
|
|
51
|
+
const lw0 = sqrt(dot(w0, w0));
|
|
52
|
+
const lw1 = sqrt(dot(w1, w1));
|
|
53
|
+
if (lw0 === 0 || lw1 === 0) {
|
|
54
|
+
return [[p0, p1]]; // a degenerate tangent - fall back to a line
|
|
55
|
+
}
|
|
56
|
+
const mid = lineLineIntersection(l0, l1);
|
|
57
|
+
let twisted;
|
|
58
|
+
if (!mid) {
|
|
59
|
+
twisted = true;
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
const a = fromTo(p0, mid);
|
|
63
|
+
const b = fromTo(p1, mid);
|
|
64
|
+
// (`<= 0` / `>= 0`: an intersection *at* an endpoint, which happens for
|
|
65
|
+
// collinear tangents, would give a degenerate quadratic with a zero
|
|
66
|
+
// end tangent - treat it as twisted so a line results instead)
|
|
67
|
+
twisted = dot(a, c) <= 0 || dot(b, c) >= 0;
|
|
68
|
+
}
|
|
69
|
+
if (!twisted) {
|
|
70
|
+
return [[p0, mid, p1]];
|
|
71
|
+
}
|
|
72
|
+
// the sines of the angles between the chord and the tangents
|
|
73
|
+
const sin0 = abs(cross(c, w0)) / (lc * lw0);
|
|
74
|
+
const sin1 = abs(cross(c, w1)) / (lc * lw1);
|
|
75
|
+
if (sin0 <= SIN_TOLERANCE_USE_LINE && sin1 <= SIN_TOLERANCE_USE_LINE) {
|
|
76
|
+
return [[p0, p1]]; // within tolerance - a straight line
|
|
77
|
+
}
|
|
78
|
+
// Approximate with 2 quadratic beziers joined smoothly at the inflection.
|
|
79
|
+
// The control points lie on the tangent lines a quarter of the chord
|
|
80
|
+
// length away from the endpoints, on the side facing the other endpoint
|
|
81
|
+
// (for small angles this is the midpoint degree reduction of the cubic
|
|
82
|
+
// having control points at 1/3 and 2/3 along the chord; unlike placing
|
|
83
|
+
// them at 1/4 and 3/4 *along* the chord it stays bounded for any angle).
|
|
84
|
+
const q0 = (dot(w0, c) < 0 ? -1 : 1) * lc / (4 * lw0);
|
|
85
|
+
const q1 = (dot(w1, c) < 0 ? 1 : -1) * lc / (4 * lw1);
|
|
86
|
+
const c0 = [p0[0] + q0 * w0[0], p0[1] + q0 * w0[1]];
|
|
87
|
+
const c1 = [p1[0] + q1 * w1[0], p1[1] + q1 * w1[1]];
|
|
88
|
+
const j = [(c0[0] + c1[0]) / 2, (c0[1] + c1[1]) / 2];
|
|
89
|
+
return [[p0, c0, j], [j, c1, p1]];
|
|
90
|
+
}
|
|
91
|
+
export { getBeziersFromTangents };
|
|
92
|
+
//# sourceMappingURL=get-beziers-from-tangents.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-beziers-from-tangents.js","sourceRoot":"","sources":["../../src/utils/get-beziers-from-tangents.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAExE,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC;AAG3B;;;;;;;;;;GAUG;AACH,MAAM,sBAAsB,GAAG,CAAC,IAAE,CAAC,EAAE,CAAC;AAGtC;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,SAAS,sBAAsB,CACvB,EAAc,EACd,EAAc;IAElB,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC;IACjB,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC;IAEjB,MAAM,CAAC,GAAG,MAAM,CAAC,EAAE,EAAC,EAAE,CAAC,CAAC;IACxB,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC;QAC3B,OAAO,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,CAAE,2CAA2C;IACnE,CAAC;IAED,MAAM,EAAE,GAAG,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IAChC,MAAM,EAAE,GAAG,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IAChC,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,CAAC,CAAC;IAEjD,OAAO,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC;AACtC,CAAC;AAGD,OAAO,EAAE,sBAAsB,EAAE,CAAA"}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import type { CpNode } from "../cp-node/cp-node.js";
|
|
2
2
|
import type { MatMeta } from '../mat/mat-meta.js';
|
|
3
3
|
/**
|
|
4
|
-
* Removes
|
|
4
|
+
* Removes the (2-prong) vertex represented by the given `CpNode` from the MAT,
|
|
5
|
+
* i.e. both `CpNode`s on its circle are unlinked from the boundary and removed
|
|
6
|
+
* from `meta.cpTrees`.
|
|
5
7
|
*
|
|
6
|
-
* @param
|
|
7
|
-
* @param
|
|
8
|
+
* @param cpNode a `CpNode` on the vertex to remove
|
|
9
|
+
* @param meta the `MatMeta` whose `cpTrees` hold the `CpNode`s of the MAT
|
|
8
10
|
*/
|
|
9
11
|
declare function removeVertex(cpNode: CpNode, meta: MatMeta): void;
|
|
10
12
|
export { removeVertex };
|
|
@@ -2,10 +2,12 @@ import { getAllOnCircle } from '../cp-node/fs/get-all-on-circle.js';
|
|
|
2
2
|
import { getProngCount } from '../cp-node/fs/get-prong-count.js';
|
|
3
3
|
import { removeCpNode } from '../cp-node/fs/remove-cp-node.js';
|
|
4
4
|
/**
|
|
5
|
-
* Removes
|
|
5
|
+
* Removes the (2-prong) vertex represented by the given `CpNode` from the MAT,
|
|
6
|
+
* i.e. both `CpNode`s on its circle are unlinked from the boundary and removed
|
|
7
|
+
* from `meta.cpTrees`.
|
|
6
8
|
*
|
|
7
|
-
* @param
|
|
8
|
-
* @param
|
|
9
|
+
* @param cpNode a `CpNode` on the vertex to remove
|
|
10
|
+
* @param meta the `MatMeta` whose `cpTrees` hold the `CpNode`s of the MAT
|
|
9
11
|
*/
|
|
10
12
|
function removeVertex(cpNode, meta) {
|
|
11
13
|
const prongCount = getProngCount(cpNode);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"remove-vertex.js","sourceRoot":"","sources":["../../src/vertex/remove-vertex.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AACpE,OAAO,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAG/D
|
|
1
|
+
{"version":3,"file":"remove-vertex.js","sourceRoot":"","sources":["../../src/vertex/remove-vertex.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AACpE,OAAO,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAG/D;;;;;;;GAOG;AACH,SAAS,YAAY,CACb,MAAc,EACd,IAAa;IAEjB,MAAM,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,CAAC;IACzC,IAAI,UAAU,KAAK,CAAC,EAAE,CAAC;QACnB,MAAM,IAAI,KAAK,CAAC,+BAA+B,UAAU,QAAQ,CAAC,CAAA;IACtE,CAAC;IAED,cAAc,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,YAAY,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC;AACzE,CAAC;AAGD,OAAO,EAAE,YAAY,EAAE,CAAA"}
|