flo-mat 2.0.2 → 2.0.3
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/browser/index.js +8230 -8229
- package/browser/index.min.js +1 -1
- package/node/circle.d.ts +20 -20
- package/node/circle.js +31 -31
- package/node/compare-curvatures-at-interface.d.ts +19 -19
- package/node/compare-curvatures-at-interface.js +124 -124
- package/node/contact-point.d.ts +26 -26
- package/node/contact-point.js +25 -25
- package/node/cp-node/clone.d.ts +8 -8
- package/node/cp-node/clone.js +31 -31
- package/node/cp-node/remove.d.ts +9 -9
- package/node/cp-node/remove.js +19 -19
- package/node/cp-node.d.ts +202 -202
- package/node/cp-node.js +320 -320
- package/node/curve.d.ts +46 -46
- package/node/curve.js +88 -88
- package/node/debug/cp-node-for-debugging.d.ts +11 -11
- package/node/debug/cp-node-for-debugging.js +1 -1
- package/node/debug/debug-elem-types.d.ts +32 -32
- package/node/debug/debug-elem-types.js +1 -1
- package/node/debug/debug.d.ts +50 -50
- package/node/debug/debug.js +75 -75
- package/node/debug/functions/draw-elem/bounding-hull.d.ts +3 -3
- package/node/debug/functions/draw-elem/bounding-hull.js +7 -7
- package/node/debug/functions/draw-elem/branch.d.ts +4 -4
- package/node/debug/functions/draw-elem/branch.js +22 -22
- package/node/debug/functions/draw-elem/culls.d.ts +4 -4
- package/node/debug/functions/draw-elem/culls.js +21 -21
- package/node/debug/functions/draw-elem/draw-circle-percent.d.ts +3 -3
- package/node/debug/functions/draw-elem/draw-circle-percent.js +12 -12
- package/node/debug/functions/draw-elem/draw-elem.d.ts +8 -8
- package/node/debug/functions/draw-elem/draw-elem.js +45 -45
- package/node/debug/functions/draw-elem/dull-corner.d.ts +4 -4
- package/node/debug/functions/draw-elem/dull-corner.js +10 -10
- package/node/debug/functions/draw-elem/leaves.d.ts +4 -4
- package/node/debug/functions/draw-elem/leaves.js +12 -12
- package/node/debug/functions/draw-elem/loop.d.ts +4 -4
- package/node/debug/functions/draw-elem/loop.js +11 -11
- package/node/debug/functions/draw-elem/loops.d.ts +4 -4
- package/node/debug/functions/draw-elem/loops.js +6 -6
- package/node/debug/functions/draw-elem/loose-bounding-box.d.ts +3 -3
- package/node/debug/functions/draw-elem/loose-bounding-box.js +9 -9
- package/node/debug/functions/draw-elem/mat.d.ts +4 -4
- package/node/debug/functions/draw-elem/mat.js +30 -30
- package/node/debug/functions/draw-elem/max-vertex.d.ts +4 -4
- package/node/debug/functions/draw-elem/max-vertex.js +8 -8
- package/node/debug/functions/draw-elem/min-y.d.ts +4 -4
- package/node/debug/functions/draw-elem/min-y.js +13 -13
- package/node/debug/functions/draw-elem/one-prong-at-dull-corner.d.ts +4 -4
- package/node/debug/functions/draw-elem/one-prong-at-dull-corner.js +12 -12
- package/node/debug/functions/draw-elem/one-prong.d.ts +4 -4
- package/node/debug/functions/draw-elem/one-prong.js +16 -16
- package/node/debug/functions/draw-elem/sharp-corner.d.ts +4 -4
- package/node/debug/functions/draw-elem/sharp-corner.js +9 -9
- package/node/debug/functions/draw-elem/three-prong.d.ts +4 -4
- package/node/debug/functions/draw-elem/three-prong.js +16 -16
- package/node/debug/functions/draw-elem/tight-bounding-box.d.ts +3 -3
- package/node/debug/functions/draw-elem/tight-bounding-box.js +7 -7
- package/node/debug/functions/draw-elem/two-prong.d.ts +4 -4
- package/node/debug/functions/draw-elem/two-prong.js +36 -36
- package/node/debug/functions/draw-elem/vertex.d.ts +4 -4
- package/node/debug/functions/draw-elem/vertex.js +27 -27
- package/node/debug/functions/general.d.ts +48 -48
- package/node/debug/functions/general.js +52 -52
- package/node/debug/functions/three-prong.d.ts +11 -11
- package/node/debug/functions/three-prong.js +184 -184
- package/node/debug/functions/two-prong.d.ts +13 -13
- package/node/debug/functions/two-prong.js +117 -117
- package/node/debug/three-prong-for-debugging.d.ts +31 -31
- package/node/debug/three-prong-for-debugging.js +20 -20
- package/node/debug/two-prong-for-debugging.d.ts +26 -26
- package/node/debug/two-prong-for-debugging.js +1 -1
- package/node/find-mats.d.ts +26 -26
- package/node/find-mats.js +122 -122
- package/node/get-boundary-bezier-parts-to-next.d.ts +9 -9
- package/node/get-boundary-bezier-parts-to-next.js +42 -42
- package/node/get-boundary-beziers-to-next.d.ts +8 -8
- package/node/get-boundary-beziers-to-next.js +44 -44
- package/node/get-bounding-box-.d.ts +2 -2
- package/node/get-bounding-box-.js +4 -4
- package/node/get-branches.d.ts +12 -12
- package/node/get-branches.js +68 -68
- package/node/get-curve/get-curve-between.d.ts +9 -9
- package/node/get-curve/get-curve-between.js +56 -56
- package/node/get-curve/get-edge-direction.d.ts +9 -9
- package/node/get-curve/get-edge-direction.js +53 -53
- package/node/get-curve-to-next.d.ts +9 -9
- package/node/get-curve-to-next.js +11 -11
- package/node/get-interface-ccw.d.ts +24 -24
- package/node/get-interface-ccw.js +97 -97
- package/node/index.d.ts +36 -36
- package/node/index.js +32 -32
- package/node/loop/get-max-coordinate.d.ts +10 -10
- package/node/loop/get-max-coordinate.js +43 -43
- package/node/loop.d.ts +16 -16
- package/node/loop.js +34 -34
- package/node/mat/add-to-cp-graph.d.ts +16 -16
- package/node/mat/add-to-cp-graph.js +30 -30
- package/node/mat/bezier-piece.d.ts +12 -12
- package/node/mat/bezier-piece.js +1 -1
- package/node/mat/closest-boundary-point/closest-points-on-curve.d.ts +14 -14
- package/node/mat/closest-boundary-point/closest-points-on-curve.js +72 -72
- package/node/mat/closest-boundary-point/cull-bezier-pieces.d.ts +9 -9
- package/node/mat/closest-boundary-point/cull-bezier-pieces.js +19 -19
- package/node/mat/closest-boundary-point/cull-by-loose-bounding-box.d.ts +11 -11
- package/node/mat/closest-boundary-point/cull-by-loose-bounding-box.js +24 -24
- package/node/mat/closest-boundary-point/cull-by-tight-boundary-box.d.ts +11 -11
- package/node/mat/closest-boundary-point/cull-by-tight-boundary-box.js +26 -26
- package/node/mat/closest-boundary-point/get-best-distance-squared.d.ts +8 -8
- package/node/mat/closest-boundary-point/get-best-distance-squared.js +24 -24
- package/node/mat/closest-boundary-point/get-close-boundary-points.d.ts +17 -17
- package/node/mat/closest-boundary-point/get-close-boundary-points.js +80 -80
- package/node/mat/closest-boundary-point/get-closest-boundary-point.d.ts +18 -18
- package/node/mat/closest-boundary-point/get-closest-boundary-point.js +40 -40
- package/node/mat/corner.d.ts +37 -37
- package/node/mat/corner.js +1 -1
- package/node/mat/create-new-cp-tree.d.ts +9 -9
- package/node/mat/create-new-cp-tree.js +23 -23
- package/node/mat/elem-type-two-prong.d.ts +3 -3
- package/node/mat/elem-type-two-prong.js +1 -1
- package/node/mat/find-mat/add-1-prong.d.ts +12 -12
- package/node/mat/find-mat/add-1-prong.js +42 -42
- package/node/mat/find-mat/add-2-prong.d.ts +21 -21
- package/node/mat/find-mat/add-2-prong.js +192 -192
- package/node/mat/find-mat/add-3-prong.d.ts +19 -19
- package/node/mat/find-mat/add-3-prong.js +54 -54
- package/node/mat/find-mat/add-debug-info.d.ts +9 -9
- package/node/mat/find-mat/add-debug-info.js +67 -67
- package/node/mat/find-mat/create-get-interesting-points-on-loop.d.ts +11 -11
- package/node/mat/find-mat/create-get-interesting-points-on-loop.js +51 -51
- package/node/mat/find-mat/create-initial-cp-graph.d.ts +12 -12
- package/node/mat/find-mat/create-initial-cp-graph.js +40 -40
- package/node/mat/find-mat/find-2-prong/add-debug-info.d.ts +8 -8
- package/node/mat/find-mat/find-2-prong/add-debug-info.js +21 -21
- package/node/mat/find-mat/find-2-prong/cull-bezier-pieces.d.ts +11 -11
- package/node/mat/find-mat/find-2-prong/cull-bezier-pieces.js +29 -29
- package/node/mat/find-mat/find-2-prong/find-2-prong.d.ts +37 -37
- package/node/mat/find-mat/find-2-prong/find-2-prong.js +232 -232
- package/node/mat/find-mat/find-2-prong/find-equidistant-point-on-line.d.ts +9 -9
- package/node/mat/find-mat/find-2-prong/find-equidistant-point-on-line.js +39 -39
- package/node/mat/find-mat/find-2-prong/get-initial-bezier-pieces.d.ts +11 -11
- package/node/mat/find-mat/find-2-prong/get-initial-bezier-pieces.js +37 -37
- package/node/mat/find-mat/find-2-prong/x-for-debugging.d.ts +9 -9
- package/node/mat/find-mat/find-2-prong/x-for-debugging.js +1 -1
- package/node/mat/find-mat/find-3-prong/calc-better-x.d.ts +19 -19
- package/node/mat/find-mat/find-3-prong/calc-better-x.js +36 -36
- package/node/mat/find-mat/find-3-prong/calc-initial-3-prong-center.d.ts +13 -13
- package/node/mat/find-mat/find-3-prong/calc-initial-3-prong-center.js +25 -25
- package/node/mat/find-mat/find-3-prong/find-3-prong-for-delta3s.d.ts +22 -22
- package/node/mat/find-mat/find-3-prong/find-3-prong-for-delta3s.js +159 -159
- package/node/mat/find-mat/find-3-prong/find-3-prong.d.ts +16 -16
- package/node/mat/find-mat/find-3-prong/find-3-prong.js +76 -76
- package/node/mat/find-mat/find-3-prong/get-closest-points.d.ts +9 -9
- package/node/mat/find-mat/find-3-prong/get-closest-points.js +16 -16
- package/node/mat/find-mat/find-and-add-2-prongs-on-all-paths.d.ts +15 -15
- package/node/mat/find-mat/find-and-add-2-prongs-on-all-paths.js +20 -20
- package/node/mat/find-mat/find-and-add-2-prongs.d.ts +16 -16
- package/node/mat/find-mat/find-and-add-2-prongs.js +73 -73
- package/node/mat/find-mat/find-and-add-3-prongs.d.ts +13 -13
- package/node/mat/find-mat/find-and-add-3-prongs.js +146 -146
- package/node/mat/find-mat/find-and-add-hole-closing-2-prongs.d.ts +14 -14
- package/node/mat/find-mat/find-and-add-hole-closing-2-prongs.js +33 -33
- package/node/mat/find-mat/get-potential-2-prongs.d.ts +4 -4
- package/node/mat/find-mat/get-potential-2-prongs.js +16 -16
- package/node/mat/find-mat/get-sharp-corners.d.ts +4 -4
- package/node/mat/find-mat/get-sharp-corners.js +17 -17
- package/node/mat/geometry/get-closest-square-distance-to-rect.d.ts +5 -5
- package/node/mat/geometry/get-closest-square-distance-to-rect.js +49 -49
- package/node/mat/geometry/get-closest-squared-distance-to-rotated-rect.d.ts +5 -5
- package/node/mat/geometry/get-closest-squared-distance-to-rotated-rect.js +15 -15
- package/node/mat/get-boundary-piece-beziers.d.ts +11 -11
- package/node/mat/get-boundary-piece-beziers.js +58 -58
- package/node/mat/get-contact-circles-at-interface.d.ts +8 -8
- package/node/mat/get-contact-circles-at-interface.js +20 -20
- package/node/mat/get-largest-vertex.d.ts +4 -4
- package/node/mat/get-largest-vertex.js +9 -9
- package/node/mat/get-leaves.d.ts +4 -4
- package/node/mat/get-leaves.js +12 -12
- package/node/mat/get-neighboring-cps.d.ts +14 -14
- package/node/mat/get-neighboring-cps.js +30 -30
- package/node/mat/get-two-prong-type.d.ts +5 -5
- package/node/mat/get-two-prong-type.js +8 -8
- package/node/mat/is-another-cp-closeby.d.ts +20 -20
- package/node/mat/is-another-cp-closeby.js +55 -55
- package/node/mat/simplify-mat-map-only.d.ts +23 -23
- package/node/mat/simplify-mat-map-only.js +80 -80
- package/node/mat/to-scale-axis/add-debug-info.d.ts +7 -7
- package/node/mat/to-scale-axis/add-debug-info.js +13 -13
- package/node/mat/to-scale-axis/cull-non-cycles.d.ts +9 -9
- package/node/mat/to-scale-axis/cull-non-cycles.js +51 -51
- package/node/mat/to-scale-axis/cull.d.ts +12 -12
- package/node/mat/to-scale-axis/cull.js +132 -132
- package/node/mat/trim-mat.d.ts +8 -8
- package/node/mat/trim-mat.js +16 -16
- package/node/mat.d.ts +22 -22
- package/node/mat.js +1 -1
- package/node/point-on-shape.d.ts +73 -73
- package/node/point-on-shape.js +167 -167
- package/node/simplify-mat.d.ts +16 -16
- package/node/simplify-mat.js +71 -71
- package/node/svg/get-loop-bounds.d.ts +12 -12
- package/node/svg/get-loop-bounds.js +80 -80
- package/node/svg/get-min-y-pos.d.ts +8 -8
- package/node/svg/get-min-y-pos.js +9 -9
- package/node/svg/get-shape-bounds.d.ts +9 -9
- package/node/svg/get-shape-bounds.js +35 -35
- package/node/sweep-line/sweep-line.d.ts +18 -18
- package/node/sweep-line/sweep-line.js +72 -72
- package/node/to-scale-axis.d.ts +16 -16
- package/node/to-scale-axis.js +74 -74
- package/node/traverse-edges.d.ts +10 -10
- package/node/traverse-edges.js +21 -21
- package/node/traverse-vertices.d.ts +12 -12
- package/node/traverse-vertices.js +27 -27
- package/package.json +11 -11
- package/tsconfig.json +0 -1
|
@@ -1,81 +1,81 @@
|
|
|
1
|
-
import { getBounds } from 'flo-bezier3';
|
|
2
|
-
import { memoize } from 'flo-memoize';
|
|
3
|
-
import { PointOnShape } from '../point-on-shape.js';
|
|
4
|
-
/** @hidden */
|
|
5
|
-
const INF = Number.POSITIVE_INFINITY;
|
|
6
|
-
/**
|
|
7
|
-
* @hidden
|
|
8
|
-
*/
|
|
9
|
-
const getLoopBounds = memoize(function (loop) {
|
|
10
|
-
const extremes = [
|
|
11
|
-
[
|
|
12
|
-
{ bezier: undefined, t: undefined, val: INF },
|
|
13
|
-
{ bezier: undefined, t: undefined, val: INF }
|
|
14
|
-
],
|
|
15
|
-
[
|
|
16
|
-
{ bezier: undefined, t: undefined, val: -INF },
|
|
17
|
-
{ bezier: undefined, t: undefined, val: -INF }
|
|
18
|
-
]
|
|
19
|
-
];
|
|
20
|
-
loop.curves.forEach(function (curve) {
|
|
21
|
-
const ps = curve.ps;
|
|
22
|
-
// const bounds = getBounds_(ps);
|
|
23
|
-
const bounds = getBounds(ps);
|
|
24
|
-
{
|
|
25
|
-
{
|
|
26
|
-
const v = bounds.box[0][0];
|
|
27
|
-
const x = extremes[0][0].val;
|
|
28
|
-
if (v < x || (v === x && bounds.ts[0][0] > extremes[0][0].t)) {
|
|
29
|
-
extremes[0][0] = {
|
|
30
|
-
bezier: curve,
|
|
31
|
-
t: bounds.ts[0][0],
|
|
32
|
-
val: v
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
{
|
|
37
|
-
const v = bounds.box[0][1];
|
|
38
|
-
const x = extremes[0][1].val;
|
|
39
|
-
if (v < x || (v === x && bounds.ts[0][1] > extremes[0][1].t)) {
|
|
40
|
-
extremes[0][1] = {
|
|
41
|
-
bezier: curve,
|
|
42
|
-
t: bounds.ts[0][1],
|
|
43
|
-
val: v
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
{
|
|
49
|
-
{
|
|
50
|
-
const v = bounds.box[1][0];
|
|
51
|
-
const x = extremes[1][0].val;
|
|
52
|
-
if (v > x || (v === x && bounds.ts[1][0] > extremes[1][0].t)) {
|
|
53
|
-
extremes[1][0] = {
|
|
54
|
-
bezier: curve,
|
|
55
|
-
t: bounds.ts[1][0],
|
|
56
|
-
val: v
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
{
|
|
61
|
-
const v = bounds.box[1][1];
|
|
62
|
-
const x = extremes[1][1].val;
|
|
63
|
-
if (v > x || (v === x && bounds.ts[1][1] > extremes[1][1].t)) {
|
|
64
|
-
extremes[1][1] = {
|
|
65
|
-
bezier: curve,
|
|
66
|
-
t: bounds.ts[1][1],
|
|
67
|
-
val: v
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
});
|
|
73
|
-
return {
|
|
74
|
-
minX: new PointOnShape(extremes[0][0].bezier, extremes[0][0].t),
|
|
75
|
-
minY: new PointOnShape(extremes[0][1].bezier, extremes[0][1].t),
|
|
76
|
-
maxX: new PointOnShape(extremes[1][0].bezier, extremes[1][0].t),
|
|
77
|
-
maxY: new PointOnShape(extremes[1][1].bezier, extremes[1][1].t)
|
|
78
|
-
};
|
|
79
|
-
});
|
|
80
|
-
export { getLoopBounds };
|
|
1
|
+
import { getBounds } from 'flo-bezier3';
|
|
2
|
+
import { memoize } from 'flo-memoize';
|
|
3
|
+
import { PointOnShape } from '../point-on-shape.js';
|
|
4
|
+
/** @hidden */
|
|
5
|
+
const INF = Number.POSITIVE_INFINITY;
|
|
6
|
+
/**
|
|
7
|
+
* @hidden
|
|
8
|
+
*/
|
|
9
|
+
const getLoopBounds = memoize(function (loop) {
|
|
10
|
+
const extremes = [
|
|
11
|
+
[
|
|
12
|
+
{ bezier: undefined, t: undefined, val: INF },
|
|
13
|
+
{ bezier: undefined, t: undefined, val: INF }
|
|
14
|
+
],
|
|
15
|
+
[
|
|
16
|
+
{ bezier: undefined, t: undefined, val: -INF },
|
|
17
|
+
{ bezier: undefined, t: undefined, val: -INF }
|
|
18
|
+
]
|
|
19
|
+
];
|
|
20
|
+
loop.curves.forEach(function (curve) {
|
|
21
|
+
const ps = curve.ps;
|
|
22
|
+
// const bounds = getBounds_(ps);
|
|
23
|
+
const bounds = getBounds(ps);
|
|
24
|
+
{
|
|
25
|
+
{
|
|
26
|
+
const v = bounds.box[0][0];
|
|
27
|
+
const x = extremes[0][0].val;
|
|
28
|
+
if (v < x || (v === x && bounds.ts[0][0] > extremes[0][0].t)) {
|
|
29
|
+
extremes[0][0] = {
|
|
30
|
+
bezier: curve,
|
|
31
|
+
t: bounds.ts[0][0],
|
|
32
|
+
val: v
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
{
|
|
37
|
+
const v = bounds.box[0][1];
|
|
38
|
+
const x = extremes[0][1].val;
|
|
39
|
+
if (v < x || (v === x && bounds.ts[0][1] > extremes[0][1].t)) {
|
|
40
|
+
extremes[0][1] = {
|
|
41
|
+
bezier: curve,
|
|
42
|
+
t: bounds.ts[0][1],
|
|
43
|
+
val: v
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
{
|
|
49
|
+
{
|
|
50
|
+
const v = bounds.box[1][0];
|
|
51
|
+
const x = extremes[1][0].val;
|
|
52
|
+
if (v > x || (v === x && bounds.ts[1][0] > extremes[1][0].t)) {
|
|
53
|
+
extremes[1][0] = {
|
|
54
|
+
bezier: curve,
|
|
55
|
+
t: bounds.ts[1][0],
|
|
56
|
+
val: v
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
{
|
|
61
|
+
const v = bounds.box[1][1];
|
|
62
|
+
const x = extremes[1][1].val;
|
|
63
|
+
if (v > x || (v === x && bounds.ts[1][1] > extremes[1][1].t)) {
|
|
64
|
+
extremes[1][1] = {
|
|
65
|
+
bezier: curve,
|
|
66
|
+
t: bounds.ts[1][1],
|
|
67
|
+
val: v
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
return {
|
|
74
|
+
minX: new PointOnShape(extremes[0][0].bezier, extremes[0][0].t),
|
|
75
|
+
minY: new PointOnShape(extremes[0][1].bezier, extremes[0][1].t),
|
|
76
|
+
maxX: new PointOnShape(extremes[1][0].bezier, extremes[1][0].t),
|
|
77
|
+
maxY: new PointOnShape(extremes[1][1].bezier, extremes[1][1].t)
|
|
78
|
+
};
|
|
79
|
+
});
|
|
80
|
+
export { getLoopBounds };
|
|
81
81
|
//# sourceMappingURL=get-loop-bounds.js.map
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
/** @hidden */
|
|
2
|
-
import { Loop } from '../loop.js';
|
|
3
|
-
/**
|
|
4
|
-
* @hidden
|
|
5
|
-
* Get topmost PointOnShape of the given loop.
|
|
6
|
-
*/
|
|
7
|
-
declare function getMinYPos(loop: Loop): import("../point-on-shape.js").IPointOnShape;
|
|
8
|
-
export { getMinYPos };
|
|
1
|
+
/** @hidden */
|
|
2
|
+
import { Loop } from '../loop.js';
|
|
3
|
+
/**
|
|
4
|
+
* @hidden
|
|
5
|
+
* Get topmost PointOnShape of the given loop.
|
|
6
|
+
*/
|
|
7
|
+
declare function getMinYPos(loop: Loop): import("../point-on-shape.js").IPointOnShape;
|
|
8
|
+
export { getMinYPos };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { getLoopBounds } from './get-loop-bounds.js';
|
|
2
|
-
/**
|
|
3
|
-
* @hidden
|
|
4
|
-
* Get topmost PointOnShape of the given loop.
|
|
5
|
-
*/
|
|
6
|
-
function getMinYPos(loop) {
|
|
7
|
-
return getLoopBounds(loop).minY;
|
|
8
|
-
}
|
|
9
|
-
export { getMinYPos };
|
|
1
|
+
import { getLoopBounds } from './get-loop-bounds.js';
|
|
2
|
+
/**
|
|
3
|
+
* @hidden
|
|
4
|
+
* Get topmost PointOnShape of the given loop.
|
|
5
|
+
*/
|
|
6
|
+
function getMinYPos(loop) {
|
|
7
|
+
return getLoopBounds(loop).minY;
|
|
8
|
+
}
|
|
9
|
+
export { getMinYPos };
|
|
10
10
|
//# sourceMappingURL=get-min-y-pos.js.map
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { Loop } from '../loop.js';
|
|
2
|
-
/** @internal */
|
|
3
|
-
declare const getShapeBounds: (a: Loop[]) => {
|
|
4
|
-
minX: import("../point-on-shape.js").IPointOnShape;
|
|
5
|
-
minY: import("../point-on-shape.js").IPointOnShape;
|
|
6
|
-
maxX: import("../point-on-shape.js").IPointOnShape;
|
|
7
|
-
maxY: import("../point-on-shape.js").IPointOnShape;
|
|
8
|
-
};
|
|
9
|
-
export { getShapeBounds };
|
|
1
|
+
import { Loop } from '../loop.js';
|
|
2
|
+
/** @internal */
|
|
3
|
+
declare const getShapeBounds: (a: Loop[]) => {
|
|
4
|
+
minX: import("../point-on-shape.js").IPointOnShape;
|
|
5
|
+
minY: import("../point-on-shape.js").IPointOnShape;
|
|
6
|
+
maxX: import("../point-on-shape.js").IPointOnShape;
|
|
7
|
+
maxY: import("../point-on-shape.js").IPointOnShape;
|
|
8
|
+
};
|
|
9
|
+
export { getShapeBounds };
|
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
import { memoize } from 'flo-memoize';
|
|
2
|
-
import { getLoopBounds } from './get-loop-bounds.js';
|
|
3
|
-
// TODO - move to another library
|
|
4
|
-
/** @internal */
|
|
5
|
-
const getShapeBounds = memoize(function (loops) {
|
|
6
|
-
let minX_ = Number.POSITIVE_INFINITY;
|
|
7
|
-
let maxX_ = Number.NEGATIVE_INFINITY;
|
|
8
|
-
let minY_ = Number.POSITIVE_INFINITY;
|
|
9
|
-
let maxY_ = Number.NEGATIVE_INFINITY;
|
|
10
|
-
let minX;
|
|
11
|
-
let maxX;
|
|
12
|
-
let minY;
|
|
13
|
-
let maxY;
|
|
14
|
-
for (const loop of loops) {
|
|
15
|
-
const bounds = getLoopBounds(loop);
|
|
16
|
-
if (bounds.minX.p[0] < minX_) {
|
|
17
|
-
minX = bounds.minX;
|
|
18
|
-
minX_ = bounds.minX.p[0];
|
|
19
|
-
}
|
|
20
|
-
if (bounds.maxX.p[0] > maxX_) {
|
|
21
|
-
maxX = bounds.maxX;
|
|
22
|
-
maxX_ = bounds.maxX.p[0];
|
|
23
|
-
}
|
|
24
|
-
if (bounds.minY.p[1] < minY_) {
|
|
25
|
-
minY = bounds.minY;
|
|
26
|
-
minY_ = bounds.minY.p[1];
|
|
27
|
-
}
|
|
28
|
-
if (bounds.maxY.p[1] > maxY_) {
|
|
29
|
-
maxY = bounds.maxY;
|
|
30
|
-
maxY_ = bounds.maxY.p[1];
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
return { minX, minY, maxX, maxY };
|
|
34
|
-
});
|
|
35
|
-
export { getShapeBounds };
|
|
1
|
+
import { memoize } from 'flo-memoize';
|
|
2
|
+
import { getLoopBounds } from './get-loop-bounds.js';
|
|
3
|
+
// TODO - move to another library
|
|
4
|
+
/** @internal */
|
|
5
|
+
const getShapeBounds = memoize(function (loops) {
|
|
6
|
+
let minX_ = Number.POSITIVE_INFINITY;
|
|
7
|
+
let maxX_ = Number.NEGATIVE_INFINITY;
|
|
8
|
+
let minY_ = Number.POSITIVE_INFINITY;
|
|
9
|
+
let maxY_ = Number.NEGATIVE_INFINITY;
|
|
10
|
+
let minX;
|
|
11
|
+
let maxX;
|
|
12
|
+
let minY;
|
|
13
|
+
let maxY;
|
|
14
|
+
for (const loop of loops) {
|
|
15
|
+
const bounds = getLoopBounds(loop);
|
|
16
|
+
if (bounds.minX.p[0] < minX_) {
|
|
17
|
+
minX = bounds.minX;
|
|
18
|
+
minX_ = bounds.minX.p[0];
|
|
19
|
+
}
|
|
20
|
+
if (bounds.maxX.p[0] > maxX_) {
|
|
21
|
+
maxX = bounds.maxX;
|
|
22
|
+
maxX_ = bounds.maxX.p[0];
|
|
23
|
+
}
|
|
24
|
+
if (bounds.minY.p[1] < minY_) {
|
|
25
|
+
minY = bounds.minY;
|
|
26
|
+
minY_ = bounds.minY.p[1];
|
|
27
|
+
}
|
|
28
|
+
if (bounds.maxY.p[1] > maxY_) {
|
|
29
|
+
maxY = bounds.maxY;
|
|
30
|
+
maxY_ = bounds.maxY.p[1];
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return { minX, minY, maxX, maxY };
|
|
34
|
+
});
|
|
35
|
+
export { getShapeBounds };
|
|
36
36
|
//# sourceMappingURL=get-shape-bounds.js.map
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @hidden
|
|
3
|
-
* Generalized sweepline algorithm.
|
|
4
|
-
*
|
|
5
|
-
* Typically used to turn O(n^2) algorithms into roughly O(n logn) algorithms.
|
|
6
|
-
*
|
|
7
|
-
* @param items An array of items that are to be compared. Items should
|
|
8
|
-
* typically be geometric objects in 2d space with well-defined left and right
|
|
9
|
-
* endpoints.
|
|
10
|
-
* @param getLeftmostPoint A function that returns the leftmost point of the
|
|
11
|
-
* geometric object of interest.
|
|
12
|
-
* @param getRightmostPoint A function that returns the rightmost point of the
|
|
13
|
-
* geometric object of interest.
|
|
14
|
-
* @param predicate A predicate that takes two geometric objects and returns
|
|
15
|
-
* true if they are of interest or false otherwise.
|
|
16
|
-
*/
|
|
17
|
-
declare function sweepLine<T>(items: T[], getLeftmost: (item: T) => number, getRightmost: (item: T) => number, predicate: (item1: T, item2: T) => boolean): [T, T][];
|
|
18
|
-
export { sweepLine };
|
|
1
|
+
/**
|
|
2
|
+
* @hidden
|
|
3
|
+
* Generalized sweepline algorithm.
|
|
4
|
+
*
|
|
5
|
+
* Typically used to turn O(n^2) algorithms into roughly O(n logn) algorithms.
|
|
6
|
+
*
|
|
7
|
+
* @param items An array of items that are to be compared. Items should
|
|
8
|
+
* typically be geometric objects in 2d space with well-defined left and right
|
|
9
|
+
* endpoints.
|
|
10
|
+
* @param getLeftmostPoint A function that returns the leftmost point of the
|
|
11
|
+
* geometric object of interest.
|
|
12
|
+
* @param getRightmostPoint A function that returns the rightmost point of the
|
|
13
|
+
* geometric object of interest.
|
|
14
|
+
* @param predicate A predicate that takes two geometric objects and returns
|
|
15
|
+
* true if they are of interest or false otherwise.
|
|
16
|
+
*/
|
|
17
|
+
declare function sweepLine<T>(items: T[], getLeftmost: (item: T) => number, getRightmost: (item: T) => number, predicate: (item1: T, item2: T) => boolean): [T, T][];
|
|
18
|
+
export { sweepLine };
|
|
@@ -1,73 +1,73 @@
|
|
|
1
|
-
/** @hidden */
|
|
2
|
-
const EVENT_LEFT = 0;
|
|
3
|
-
/** @hidden */
|
|
4
|
-
const EVENT_RIGHT = 1;
|
|
5
|
-
/**
|
|
6
|
-
* @hidden
|
|
7
|
-
* Generalized sweepline algorithm.
|
|
8
|
-
*
|
|
9
|
-
* Typically used to turn O(n^2) algorithms into roughly O(n logn) algorithms.
|
|
10
|
-
*
|
|
11
|
-
* @param items An array of items that are to be compared. Items should
|
|
12
|
-
* typically be geometric objects in 2d space with well-defined left and right
|
|
13
|
-
* endpoints.
|
|
14
|
-
* @param getLeftmostPoint A function that returns the leftmost point of the
|
|
15
|
-
* geometric object of interest.
|
|
16
|
-
* @param getRightmostPoint A function that returns the rightmost point of the
|
|
17
|
-
* geometric object of interest.
|
|
18
|
-
* @param predicate A predicate that takes two geometric objects and returns
|
|
19
|
-
* true if they are of interest or false otherwise.
|
|
20
|
-
*/
|
|
21
|
-
function sweepLine(items, getLeftmost, getRightmost, predicate) {
|
|
22
|
-
// Initialize event queue to contain all endpoints.
|
|
23
|
-
const events = [];
|
|
24
|
-
for (const item of items) {
|
|
25
|
-
events.push({
|
|
26
|
-
type: EVENT_LEFT,
|
|
27
|
-
item,
|
|
28
|
-
x: getLeftmost(item)
|
|
29
|
-
});
|
|
30
|
-
events.push({
|
|
31
|
-
type: EVENT_RIGHT,
|
|
32
|
-
item,
|
|
33
|
-
x: getRightmost(item)
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
events.sort(compare);
|
|
37
|
-
const activeItems = new Set();
|
|
38
|
-
/** A list of pairs of items that passed the predicate */
|
|
39
|
-
const pairedItems = [];
|
|
40
|
-
for (const event of events) {
|
|
41
|
-
const { item } = event;
|
|
42
|
-
if (event.type === EVENT_LEFT) {
|
|
43
|
-
for (const activeItem of activeItems.values()) {
|
|
44
|
-
if (predicate(item, activeItem)) {
|
|
45
|
-
pairedItems.push([item, activeItem]);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
activeItems.add(item);
|
|
49
|
-
}
|
|
50
|
-
else if (event.type === EVENT_RIGHT) {
|
|
51
|
-
activeItems.delete(event.item);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
return pairedItems;
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* @hidden
|
|
58
|
-
* Compare two Events by their x-axis and then by their type. Since it is
|
|
59
|
-
* open boxes that are compared we must let the right endpoint type come
|
|
60
|
-
* before the left.
|
|
61
|
-
* @param a An event
|
|
62
|
-
* @param b Another event
|
|
63
|
-
*/
|
|
64
|
-
function compare(a, b) {
|
|
65
|
-
const res = a.x - b.x;
|
|
66
|
-
if (res !== 0) {
|
|
67
|
-
return res;
|
|
68
|
-
}
|
|
69
|
-
// Alwys put left events before right ones.
|
|
70
|
-
return a.type === EVENT_LEFT ? -1 : +1;
|
|
71
|
-
}
|
|
72
|
-
export { sweepLine };
|
|
1
|
+
/** @hidden */
|
|
2
|
+
const EVENT_LEFT = 0;
|
|
3
|
+
/** @hidden */
|
|
4
|
+
const EVENT_RIGHT = 1;
|
|
5
|
+
/**
|
|
6
|
+
* @hidden
|
|
7
|
+
* Generalized sweepline algorithm.
|
|
8
|
+
*
|
|
9
|
+
* Typically used to turn O(n^2) algorithms into roughly O(n logn) algorithms.
|
|
10
|
+
*
|
|
11
|
+
* @param items An array of items that are to be compared. Items should
|
|
12
|
+
* typically be geometric objects in 2d space with well-defined left and right
|
|
13
|
+
* endpoints.
|
|
14
|
+
* @param getLeftmostPoint A function that returns the leftmost point of the
|
|
15
|
+
* geometric object of interest.
|
|
16
|
+
* @param getRightmostPoint A function that returns the rightmost point of the
|
|
17
|
+
* geometric object of interest.
|
|
18
|
+
* @param predicate A predicate that takes two geometric objects and returns
|
|
19
|
+
* true if they are of interest or false otherwise.
|
|
20
|
+
*/
|
|
21
|
+
function sweepLine(items, getLeftmost, getRightmost, predicate) {
|
|
22
|
+
// Initialize event queue to contain all endpoints.
|
|
23
|
+
const events = [];
|
|
24
|
+
for (const item of items) {
|
|
25
|
+
events.push({
|
|
26
|
+
type: EVENT_LEFT,
|
|
27
|
+
item,
|
|
28
|
+
x: getLeftmost(item)
|
|
29
|
+
});
|
|
30
|
+
events.push({
|
|
31
|
+
type: EVENT_RIGHT,
|
|
32
|
+
item,
|
|
33
|
+
x: getRightmost(item)
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
events.sort(compare);
|
|
37
|
+
const activeItems = new Set();
|
|
38
|
+
/** A list of pairs of items that passed the predicate */
|
|
39
|
+
const pairedItems = [];
|
|
40
|
+
for (const event of events) {
|
|
41
|
+
const { item } = event;
|
|
42
|
+
if (event.type === EVENT_LEFT) {
|
|
43
|
+
for (const activeItem of activeItems.values()) {
|
|
44
|
+
if (predicate(item, activeItem)) {
|
|
45
|
+
pairedItems.push([item, activeItem]);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
activeItems.add(item);
|
|
49
|
+
}
|
|
50
|
+
else if (event.type === EVENT_RIGHT) {
|
|
51
|
+
activeItems.delete(event.item);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return pairedItems;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* @hidden
|
|
58
|
+
* Compare two Events by their x-axis and then by their type. Since it is
|
|
59
|
+
* open boxes that are compared we must let the right endpoint type come
|
|
60
|
+
* before the left.
|
|
61
|
+
* @param a An event
|
|
62
|
+
* @param b Another event
|
|
63
|
+
*/
|
|
64
|
+
function compare(a, b) {
|
|
65
|
+
const res = a.x - b.x;
|
|
66
|
+
if (res !== 0) {
|
|
67
|
+
return res;
|
|
68
|
+
}
|
|
69
|
+
// Alwys put left events before right ones.
|
|
70
|
+
return a.type === EVENT_LEFT ? -1 : +1;
|
|
71
|
+
}
|
|
72
|
+
export { sweepLine };
|
|
73
73
|
//# sourceMappingURL=sweep-line.js.map
|
package/node/to-scale-axis.d.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { Mat } from './mat.js';
|
|
2
|
-
/** @hidden */
|
|
3
|
-
/**
|
|
4
|
-
* Apply and returns an enhanced version of the Scale Axis Transform (SAT) to
|
|
5
|
-
* the given MAT. The returned SAT is guaranteed to be a subset of the MAT and
|
|
6
|
-
* preserves topology at any scale.
|
|
7
|
-
*
|
|
8
|
-
* Typically the MAT contains too many branches caused by minute details on the
|
|
9
|
-
* boundary of the shape. The SAT is a simplification of the MAT that preserves
|
|
10
|
-
* less detail the higher the applied scale factor. The severity at which noise
|
|
11
|
-
* are removed depends on the local scale of the shape.
|
|
12
|
-
* @param mat The Medial Axis Transform ([[Mat]]) on which to apply the SAT.
|
|
13
|
-
* @param s The scale factor >= 1 (e.g. 1.3)
|
|
14
|
-
*/
|
|
15
|
-
declare function toScaleAxis(mat: Mat, s: number, f?: (s: number) => (r: number) => number): Mat;
|
|
16
|
-
export { toScaleAxis };
|
|
1
|
+
import { Mat } from './mat.js';
|
|
2
|
+
/** @hidden */
|
|
3
|
+
/**
|
|
4
|
+
* Apply and returns an enhanced version of the Scale Axis Transform (SAT) to
|
|
5
|
+
* the given MAT. The returned SAT is guaranteed to be a subset of the MAT and
|
|
6
|
+
* preserves topology at any scale.
|
|
7
|
+
*
|
|
8
|
+
* Typically the MAT contains too many branches caused by minute details on the
|
|
9
|
+
* boundary of the shape. The SAT is a simplification of the MAT that preserves
|
|
10
|
+
* less detail the higher the applied scale factor. The severity at which noise
|
|
11
|
+
* are removed depends on the local scale of the shape.
|
|
12
|
+
* @param mat The Medial Axis Transform ([[Mat]]) on which to apply the SAT.
|
|
13
|
+
* @param s The scale factor >= 1 (e.g. 1.3)
|
|
14
|
+
*/
|
|
15
|
+
declare function toScaleAxis(mat: Mat, s: number, f?: (s: number) => (r: number) => number): Mat;
|
|
16
|
+
export { toScaleAxis };
|
package/node/to-scale-axis.js
CHANGED
|
@@ -1,75 +1,75 @@
|
|
|
1
|
-
import { length } from 'flo-bezier3';
|
|
2
|
-
import { traverseEdges } from './traverse-edges.js';
|
|
3
|
-
import { traverseVertices } from './traverse-vertices.js';
|
|
4
|
-
import { getLargestVertex } from './mat/get-largest-vertex.js';
|
|
5
|
-
import { getLeaves } from './mat/get-leaves.js';
|
|
6
|
-
import { cull } from './mat/to-scale-axis/cull.js';
|
|
7
|
-
import { addDebugInfo } from './mat/to-scale-axis/add-debug-info.js';
|
|
8
|
-
import { clone } from './cp-node/clone.js';
|
|
9
|
-
import { getCurveToNext } from './get-curve-to-next.js';
|
|
10
|
-
function linearScale(s) {
|
|
11
|
-
return function (r) {
|
|
12
|
-
return s * r;
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
/** @hidden */
|
|
16
|
-
//let len = length([0,1]);
|
|
17
|
-
/**
|
|
18
|
-
* Apply and returns an enhanced version of the Scale Axis Transform (SAT) to
|
|
19
|
-
* the given MAT. The returned SAT is guaranteed to be a subset of the MAT and
|
|
20
|
-
* preserves topology at any scale.
|
|
21
|
-
*
|
|
22
|
-
* Typically the MAT contains too many branches caused by minute details on the
|
|
23
|
-
* boundary of the shape. The SAT is a simplification of the MAT that preserves
|
|
24
|
-
* less detail the higher the applied scale factor. The severity at which noise
|
|
25
|
-
* are removed depends on the local scale of the shape.
|
|
26
|
-
* @param mat The Medial Axis Transform ([[Mat]]) on which to apply the SAT.
|
|
27
|
-
* @param s The scale factor >= 1 (e.g. 1.3)
|
|
28
|
-
*/
|
|
29
|
-
function toScaleAxis(mat, s, f = linearScale) {
|
|
30
|
-
let timingStart = 0;
|
|
31
|
-
if (typeof _debug_ !== 'undefined') {
|
|
32
|
-
timingStart = performance.now();
|
|
33
|
-
const leaves = getLeaves(mat.cpNode);
|
|
34
|
-
_debug_.generated.elems.leaves.push(leaves);
|
|
35
|
-
}
|
|
36
|
-
/** The largest vertex (as measured by its inscribed disk) */
|
|
37
|
-
const cpNodes = [];
|
|
38
|
-
traverseVertices(clone(mat.cpNode), cpNode => { cpNodes.push(cpNode); });
|
|
39
|
-
const cpNode = getLargestVertex(cpNodes);
|
|
40
|
-
const f_ = f(s);
|
|
41
|
-
if (typeof _debug_ !== 'undefined') {
|
|
42
|
-
_debug_.generated.elems.maxVertex.push(cpNode);
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* All vertices that are set to be culled initially. This may change later
|
|
46
|
-
* in order to preserve topology.
|
|
47
|
-
*/
|
|
48
|
-
const culls = new Set();
|
|
49
|
-
const rMap = new Map();
|
|
50
|
-
traverseEdges(cpNode, function (cpNode) {
|
|
51
|
-
/** The occulating radius stored with this vertex. */
|
|
52
|
-
const R = rMap.get(cpNode) || f_(cpNode.cp.circle.radius);
|
|
53
|
-
const cpNode_ = cpNode.next;
|
|
54
|
-
const l = length([0, 1], getCurveToNext(cpNode));
|
|
55
|
-
const r = cpNode_.cp.circle.radius;
|
|
56
|
-
const r_ = f_(r);
|
|
57
|
-
if (R - l > r_) {
|
|
58
|
-
for (const cpNode of cpNode_.getCpNodesOnCircle()) {
|
|
59
|
-
rMap.set(cpNode, R - l); // Update osculating radii
|
|
60
|
-
}
|
|
61
|
-
culls.add(cpNode_.cp.circle);
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
cull(culls, cpNode);
|
|
65
|
-
if (typeof _debug_ !== 'undefined') {
|
|
66
|
-
_debug_.generated.elems.culls.push(Array.from(culls));
|
|
67
|
-
}
|
|
68
|
-
// TODO - put line below back - goes into infinite loop
|
|
69
|
-
//const sat: Mat = { cpNode, cpTrees: createNewCpTree(cpNode) };
|
|
70
|
-
const sat = { cpNode, cpTrees: undefined };
|
|
71
|
-
addDebugInfo(sat, timingStart);
|
|
72
|
-
return sat;
|
|
73
|
-
}
|
|
74
|
-
export { toScaleAxis };
|
|
1
|
+
import { length } from 'flo-bezier3';
|
|
2
|
+
import { traverseEdges } from './traverse-edges.js';
|
|
3
|
+
import { traverseVertices } from './traverse-vertices.js';
|
|
4
|
+
import { getLargestVertex } from './mat/get-largest-vertex.js';
|
|
5
|
+
import { getLeaves } from './mat/get-leaves.js';
|
|
6
|
+
import { cull } from './mat/to-scale-axis/cull.js';
|
|
7
|
+
import { addDebugInfo } from './mat/to-scale-axis/add-debug-info.js';
|
|
8
|
+
import { clone } from './cp-node/clone.js';
|
|
9
|
+
import { getCurveToNext } from './get-curve-to-next.js';
|
|
10
|
+
function linearScale(s) {
|
|
11
|
+
return function (r) {
|
|
12
|
+
return s * r;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
/** @hidden */
|
|
16
|
+
//let len = length([0,1]);
|
|
17
|
+
/**
|
|
18
|
+
* Apply and returns an enhanced version of the Scale Axis Transform (SAT) to
|
|
19
|
+
* the given MAT. The returned SAT is guaranteed to be a subset of the MAT and
|
|
20
|
+
* preserves topology at any scale.
|
|
21
|
+
*
|
|
22
|
+
* Typically the MAT contains too many branches caused by minute details on the
|
|
23
|
+
* boundary of the shape. The SAT is a simplification of the MAT that preserves
|
|
24
|
+
* less detail the higher the applied scale factor. The severity at which noise
|
|
25
|
+
* are removed depends on the local scale of the shape.
|
|
26
|
+
* @param mat The Medial Axis Transform ([[Mat]]) on which to apply the SAT.
|
|
27
|
+
* @param s The scale factor >= 1 (e.g. 1.3)
|
|
28
|
+
*/
|
|
29
|
+
function toScaleAxis(mat, s, f = linearScale) {
|
|
30
|
+
let timingStart = 0;
|
|
31
|
+
if (typeof _debug_ !== 'undefined') {
|
|
32
|
+
timingStart = performance.now();
|
|
33
|
+
const leaves = getLeaves(mat.cpNode);
|
|
34
|
+
_debug_.generated.elems.leaves.push(leaves);
|
|
35
|
+
}
|
|
36
|
+
/** The largest vertex (as measured by its inscribed disk) */
|
|
37
|
+
const cpNodes = [];
|
|
38
|
+
traverseVertices(clone(mat.cpNode), cpNode => { cpNodes.push(cpNode); });
|
|
39
|
+
const cpNode = getLargestVertex(cpNodes);
|
|
40
|
+
const f_ = f(s);
|
|
41
|
+
if (typeof _debug_ !== 'undefined') {
|
|
42
|
+
_debug_.generated.elems.maxVertex.push(cpNode);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* All vertices that are set to be culled initially. This may change later
|
|
46
|
+
* in order to preserve topology.
|
|
47
|
+
*/
|
|
48
|
+
const culls = new Set();
|
|
49
|
+
const rMap = new Map();
|
|
50
|
+
traverseEdges(cpNode, function (cpNode) {
|
|
51
|
+
/** The occulating radius stored with this vertex. */
|
|
52
|
+
const R = rMap.get(cpNode) || f_(cpNode.cp.circle.radius);
|
|
53
|
+
const cpNode_ = cpNode.next;
|
|
54
|
+
const l = length([0, 1], getCurveToNext(cpNode));
|
|
55
|
+
const r = cpNode_.cp.circle.radius;
|
|
56
|
+
const r_ = f_(r);
|
|
57
|
+
if (R - l > r_) {
|
|
58
|
+
for (const cpNode of cpNode_.getCpNodesOnCircle()) {
|
|
59
|
+
rMap.set(cpNode, R - l); // Update osculating radii
|
|
60
|
+
}
|
|
61
|
+
culls.add(cpNode_.cp.circle);
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
cull(culls, cpNode);
|
|
65
|
+
if (typeof _debug_ !== 'undefined') {
|
|
66
|
+
_debug_.generated.elems.culls.push(Array.from(culls));
|
|
67
|
+
}
|
|
68
|
+
// TODO - put line below back - goes into infinite loop
|
|
69
|
+
//const sat: Mat = { cpNode, cpTrees: createNewCpTree(cpNode) };
|
|
70
|
+
const sat = { cpNode, cpTrees: undefined };
|
|
71
|
+
addDebugInfo(sat, timingStart);
|
|
72
|
+
return sat;
|
|
73
|
+
}
|
|
74
|
+
export { toScaleAxis };
|
|
75
75
|
//# sourceMappingURL=to-scale-axis.js.map
|