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,16 +1,16 @@
|
|
|
1
|
-
import { LlRbTree } from 'flo-ll-rb-tree';
|
|
2
|
-
import { Loop } from '../../loop.js';
|
|
3
|
-
import { CpNode } from '../../cp-node.js';
|
|
4
|
-
import { IPointOnShape } from '../../point-on-shape.js';
|
|
5
|
-
/**
|
|
6
|
-
* @hidden
|
|
7
|
-
* Find and add two-prongs.
|
|
8
|
-
* @param loops
|
|
9
|
-
* @param cpGraphs
|
|
10
|
-
* @param k
|
|
11
|
-
* @param for2Prongs
|
|
12
|
-
* @param extreme The maximum coordinate value used to calculate floating point
|
|
13
|
-
* tolerances.
|
|
14
|
-
*/
|
|
15
|
-
declare function findAndAdd2Prongs(loops: Loop[], cpGraphs: Map<Loop, LlRbTree<CpNode>>, k: number, for2Prongs: IPointOnShape[], extreme: number): CpNode;
|
|
16
|
-
export { findAndAdd2Prongs };
|
|
1
|
+
import { LlRbTree } from 'flo-ll-rb-tree';
|
|
2
|
+
import { Loop } from '../../loop.js';
|
|
3
|
+
import { CpNode } from '../../cp-node.js';
|
|
4
|
+
import { IPointOnShape } from '../../point-on-shape.js';
|
|
5
|
+
/**
|
|
6
|
+
* @hidden
|
|
7
|
+
* Find and add two-prongs.
|
|
8
|
+
* @param loops
|
|
9
|
+
* @param cpGraphs
|
|
10
|
+
* @param k
|
|
11
|
+
* @param for2Prongs
|
|
12
|
+
* @param extreme The maximum coordinate value used to calculate floating point
|
|
13
|
+
* tolerances.
|
|
14
|
+
*/
|
|
15
|
+
declare function findAndAdd2Prongs(loops: Loop[], cpGraphs: Map<Loop, LlRbTree<CpNode>>, k: number, for2Prongs: IPointOnShape[], extreme: number): CpNode;
|
|
16
|
+
export { findAndAdd2Prongs };
|
|
@@ -1,74 +1,74 @@
|
|
|
1
|
-
import { getShapeBounds } from '../../svg/get-shape-bounds.js';
|
|
2
|
-
import { find2Prong } from './find-2-prong/find-2-prong.js';
|
|
3
|
-
import { add2Prong } from './add-2-prong.js';
|
|
4
|
-
/**
|
|
5
|
-
* @hidden
|
|
6
|
-
* Find and add two-prongs.
|
|
7
|
-
* @param loops
|
|
8
|
-
* @param cpGraphs
|
|
9
|
-
* @param k
|
|
10
|
-
* @param for2Prongs
|
|
11
|
-
* @param extreme The maximum coordinate value used to calculate floating point
|
|
12
|
-
* tolerances.
|
|
13
|
-
*/
|
|
14
|
-
function findAndAdd2Prongs(loops, cpGraphs, k, for2Prongs, extreme) {
|
|
15
|
-
const len = for2Prongs.length;
|
|
16
|
-
const index = indexLinear(len);
|
|
17
|
-
//const index = indexInterlaced(len); // Keep for possible future use.
|
|
18
|
-
let cpNode_;
|
|
19
|
-
const bounds = getShapeBounds(loops);
|
|
20
|
-
const squaredDiagonalLength = (bounds.maxX.p[0] - bounds.minX.p[0]) ** 2 +
|
|
21
|
-
(bounds.maxY.p[1] - bounds.minY.p[1]) ** 2;
|
|
22
|
-
for (let i = 0; i < len; i++) {
|
|
23
|
-
const pos = for2Prongs[index[i]];
|
|
24
|
-
const twoProngInfo = find2Prong(loops, extreme, squaredDiagonalLength, cpGraphs, pos, false, k);
|
|
25
|
-
if (twoProngInfo) {
|
|
26
|
-
const { circle, zs } = twoProngInfo;
|
|
27
|
-
const cpNode = add2Prong(cpGraphs, circle, pos, zs, false, extreme);
|
|
28
|
-
cpNode_ = cpNode_ || cpNode;
|
|
29
|
-
}
|
|
30
|
-
if (typeof _debug_ !== 'undefined') {
|
|
31
|
-
if (i + 1 === _debug_.directives.stopAfterTwoProngsNum) {
|
|
32
|
-
return undefined;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
return cpNode_;
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* @hidden
|
|
40
|
-
* Simple linear array indexing.
|
|
41
|
-
* @param n
|
|
42
|
-
*/
|
|
43
|
-
function indexLinear(n) {
|
|
44
|
-
const arr = [];
|
|
45
|
-
for (let i = 0; i < n; i++) {
|
|
46
|
-
arr.push(i);
|
|
47
|
-
}
|
|
48
|
-
return arr;
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* @hidden
|
|
52
|
-
* Creates a kind of interlaced index vector.
|
|
53
|
-
* @param n
|
|
54
|
-
*/
|
|
55
|
-
function indexInterlaced(n) {
|
|
56
|
-
const source = {};
|
|
57
|
-
const arr = [];
|
|
58
|
-
// l is the lowest power of 2 so that 2^l > n
|
|
59
|
-
let l = Math.pow(2, Math.floor(Math.log2(n)));
|
|
60
|
-
while (l >= 1) {
|
|
61
|
-
let k = 0;
|
|
62
|
-
while (k < n) {
|
|
63
|
-
if (!source[k]) {
|
|
64
|
-
arr.push(k);
|
|
65
|
-
source[k] = true;
|
|
66
|
-
}
|
|
67
|
-
k = k + l;
|
|
68
|
-
}
|
|
69
|
-
l = l / 2;
|
|
70
|
-
}
|
|
71
|
-
return arr;
|
|
72
|
-
}
|
|
73
|
-
export { findAndAdd2Prongs };
|
|
1
|
+
import { getShapeBounds } from '../../svg/get-shape-bounds.js';
|
|
2
|
+
import { find2Prong } from './find-2-prong/find-2-prong.js';
|
|
3
|
+
import { add2Prong } from './add-2-prong.js';
|
|
4
|
+
/**
|
|
5
|
+
* @hidden
|
|
6
|
+
* Find and add two-prongs.
|
|
7
|
+
* @param loops
|
|
8
|
+
* @param cpGraphs
|
|
9
|
+
* @param k
|
|
10
|
+
* @param for2Prongs
|
|
11
|
+
* @param extreme The maximum coordinate value used to calculate floating point
|
|
12
|
+
* tolerances.
|
|
13
|
+
*/
|
|
14
|
+
function findAndAdd2Prongs(loops, cpGraphs, k, for2Prongs, extreme) {
|
|
15
|
+
const len = for2Prongs.length;
|
|
16
|
+
const index = indexLinear(len);
|
|
17
|
+
//const index = indexInterlaced(len); // Keep for possible future use.
|
|
18
|
+
let cpNode_;
|
|
19
|
+
const bounds = getShapeBounds(loops);
|
|
20
|
+
const squaredDiagonalLength = (bounds.maxX.p[0] - bounds.minX.p[0]) ** 2 +
|
|
21
|
+
(bounds.maxY.p[1] - bounds.minY.p[1]) ** 2;
|
|
22
|
+
for (let i = 0; i < len; i++) {
|
|
23
|
+
const pos = for2Prongs[index[i]];
|
|
24
|
+
const twoProngInfo = find2Prong(loops, extreme, squaredDiagonalLength, cpGraphs, pos, false, k);
|
|
25
|
+
if (twoProngInfo) {
|
|
26
|
+
const { circle, zs } = twoProngInfo;
|
|
27
|
+
const cpNode = add2Prong(cpGraphs, circle, pos, zs, false, extreme);
|
|
28
|
+
cpNode_ = cpNode_ || cpNode;
|
|
29
|
+
}
|
|
30
|
+
if (typeof _debug_ !== 'undefined') {
|
|
31
|
+
if (i + 1 === _debug_.directives.stopAfterTwoProngsNum) {
|
|
32
|
+
return undefined;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return cpNode_;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* @hidden
|
|
40
|
+
* Simple linear array indexing.
|
|
41
|
+
* @param n
|
|
42
|
+
*/
|
|
43
|
+
function indexLinear(n) {
|
|
44
|
+
const arr = [];
|
|
45
|
+
for (let i = 0; i < n; i++) {
|
|
46
|
+
arr.push(i);
|
|
47
|
+
}
|
|
48
|
+
return arr;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* @hidden
|
|
52
|
+
* Creates a kind of interlaced index vector.
|
|
53
|
+
* @param n
|
|
54
|
+
*/
|
|
55
|
+
function indexInterlaced(n) {
|
|
56
|
+
const source = {};
|
|
57
|
+
const arr = [];
|
|
58
|
+
// l is the lowest power of 2 so that 2^l > n
|
|
59
|
+
let l = Math.pow(2, Math.floor(Math.log2(n)));
|
|
60
|
+
while (l >= 1) {
|
|
61
|
+
let k = 0;
|
|
62
|
+
while (k < n) {
|
|
63
|
+
if (!source[k]) {
|
|
64
|
+
arr.push(k);
|
|
65
|
+
source[k] = true;
|
|
66
|
+
}
|
|
67
|
+
k = k + l;
|
|
68
|
+
}
|
|
69
|
+
l = l / 2;
|
|
70
|
+
}
|
|
71
|
+
return arr;
|
|
72
|
+
}
|
|
73
|
+
export { findAndAdd2Prongs };
|
|
74
74
|
//# sourceMappingURL=find-and-add-2-prongs.js.map
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { LlRbTree } from 'flo-ll-rb-tree';
|
|
2
|
-
import { CpNode } from '../../cp-node.js';
|
|
3
|
-
import { Loop } from '../../loop.js';
|
|
4
|
-
/**
|
|
5
|
-
* @hidden
|
|
6
|
-
* Finds and adds all 3-prongs.
|
|
7
|
-
* @param cpGraphs
|
|
8
|
-
* @param cpStart The CpNode to start traversing from.
|
|
9
|
-
* @param extreme The maximum coordinate value used to calculate floating point
|
|
10
|
-
* tolerances.
|
|
11
|
-
*/
|
|
12
|
-
declare function findAndAddAll3Prongs(cpGraphs: Map<Loop, LlRbTree<CpNode>>, cpStart: CpNode, extreme: number): void;
|
|
13
|
-
export { findAndAddAll3Prongs };
|
|
1
|
+
import { LlRbTree } from 'flo-ll-rb-tree';
|
|
2
|
+
import { CpNode } from '../../cp-node.js';
|
|
3
|
+
import { Loop } from '../../loop.js';
|
|
4
|
+
/**
|
|
5
|
+
* @hidden
|
|
6
|
+
* Finds and adds all 3-prongs.
|
|
7
|
+
* @param cpGraphs
|
|
8
|
+
* @param cpStart The CpNode to start traversing from.
|
|
9
|
+
* @param extreme The maximum coordinate value used to calculate floating point
|
|
10
|
+
* tolerances.
|
|
11
|
+
*/
|
|
12
|
+
declare function findAndAddAll3Prongs(cpGraphs: Map<Loop, LlRbTree<CpNode>>, cpStart: CpNode, extreme: number): void;
|
|
13
|
+
export { findAndAddAll3Prongs };
|
|
@@ -1,147 +1,147 @@
|
|
|
1
|
-
import { calcPosOrder, isPosSharpCorner } from '../../point-on-shape.js';
|
|
2
|
-
import { find3Prong } from './find-3-prong/find-3-prong.js';
|
|
3
|
-
import { add3Prong } from '../find-mat/add-3-prong.js';
|
|
4
|
-
/**
|
|
5
|
-
* @hidden
|
|
6
|
-
* Finds and adds all 3-prongs.
|
|
7
|
-
* @param cpGraphs
|
|
8
|
-
* @param cpStart The CpNode to start traversing from.
|
|
9
|
-
* @param extreme The maximum coordinate value used to calculate floating point
|
|
10
|
-
* tolerances.
|
|
11
|
-
*/
|
|
12
|
-
function findAndAddAll3Prongs(cpGraphs, cpStart, extreme) {
|
|
13
|
-
// Don't change this function to be recursive, the call stack may overflow
|
|
14
|
-
// if there are too many two-prongs.
|
|
15
|
-
const visitedEdges = new Map();
|
|
16
|
-
const edgesToCheck = [{ fromCpNode: undefined, cpStart }];
|
|
17
|
-
while (edgesToCheck.length) {
|
|
18
|
-
const { fromCpNode, cpStart } = edgesToCheck.shift();
|
|
19
|
-
markEdgeAsTaken(visitedEdges, fromCpNode, cpStart);
|
|
20
|
-
for (const cpNode of cpStart.getCpNodesOnCircle()) {
|
|
21
|
-
//if (!PointOnShape.isSharpCorner(cpNode.cp.pointOnShape)) {
|
|
22
|
-
if (!isPosSharpCorner(cpNode.cp.pointOnShape)) {
|
|
23
|
-
if (findAndAdd3Prongs(cpGraphs, cpNode, extreme) === undefined) {
|
|
24
|
-
return; // only for debugging purposes
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
if (hasEdgeBeenTaken(visitedEdges, cpNode, cpNode.next)) {
|
|
28
|
-
continue; // We already visited this edge
|
|
29
|
-
}
|
|
30
|
-
edgesToCheck.push({ fromCpNode: cpStart, cpStart: cpNode.next });
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* @hidden
|
|
36
|
-
* Marks the given edge as already taken.
|
|
37
|
-
*/
|
|
38
|
-
function markEdgeAsTaken(visitedEdges, cp1, cp2) {
|
|
39
|
-
if (cp1 === undefined) {
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
f(cp1, cp2);
|
|
43
|
-
f(cp2, cp1);
|
|
44
|
-
function f(cp1, cp2) {
|
|
45
|
-
let visited = visitedEdges.get(cp1);
|
|
46
|
-
if (!visited) {
|
|
47
|
-
visited = new Set();
|
|
48
|
-
visitedEdges.set(cp1, visited);
|
|
49
|
-
}
|
|
50
|
-
visited.add(cp2);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
/** @hidden */
|
|
54
|
-
function hasEdgeBeenTaken(visitedEdges, cp1, cp2) {
|
|
55
|
-
let cps;
|
|
56
|
-
cps = visitedEdges.get(cp1);
|
|
57
|
-
const takenForward = cps && cps.has(cp2);
|
|
58
|
-
cps = visitedEdges.get(cp2);
|
|
59
|
-
const takenBackwards = cps && cps.has(cp1);
|
|
60
|
-
return takenForward || takenBackwards;
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* @hidden
|
|
64
|
-
* Traverses the shape from the given ContactPoint going around contact circles
|
|
65
|
-
* so that only a piece of the shape is traversed and returns the visited
|
|
66
|
-
* CpNodes (starting from the given CpNode).
|
|
67
|
-
* @param cpStart The ContactPoint from where to start the traversal.
|
|
68
|
-
*/
|
|
69
|
-
function traverseShape(cpStart) {
|
|
70
|
-
let cpNode = cpStart;
|
|
71
|
-
if (cpNode === cpNode.next.prevOnCircle) {
|
|
72
|
-
return [cpNode];
|
|
73
|
-
}
|
|
74
|
-
const visitedCps = [];
|
|
75
|
-
do {
|
|
76
|
-
visitedCps.push(cpNode);
|
|
77
|
-
const next = cpNode.next.prevOnCircle;
|
|
78
|
-
cpNode = cpNode === next
|
|
79
|
-
? cpNode = cpNode.next.next // Terminal vertex
|
|
80
|
-
: cpNode = next; // Take last exit
|
|
81
|
-
} while (cpNode !== cpStart);
|
|
82
|
-
return visitedCps;
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* @hidden
|
|
86
|
-
* Starting from some ContactPoint, traverses the shape going around Vertices
|
|
87
|
-
* and if more than two Vertices have been visited in total then recursively
|
|
88
|
-
* adds 3-prongs until only one or two Vertices have been visited.
|
|
89
|
-
*
|
|
90
|
-
* This process further subdivides the shape.
|
|
91
|
-
* @param cpGraphs
|
|
92
|
-
* @param cpStart The ContactPoint from where to start the process.
|
|
93
|
-
* @param extreme The maximum coordinate value used to calculate floating point
|
|
94
|
-
* tolerances.
|
|
95
|
-
*/
|
|
96
|
-
let ii = 0;
|
|
97
|
-
function findAndAdd3Prongs(cpGraphs, cpStart, extreme) {
|
|
98
|
-
let visitedCps;
|
|
99
|
-
do {
|
|
100
|
-
visitedCps = traverseShape(cpStart);
|
|
101
|
-
if (visitedCps.length > 2) {
|
|
102
|
-
findAndAdd3Prong(cpGraphs, visitedCps, extreme);
|
|
103
|
-
ii++;
|
|
104
|
-
}
|
|
105
|
-
if (typeof _debug_ !== 'undefined') {
|
|
106
|
-
if (ii === _debug_.directives.stopAfterThreeProngsNum) {
|
|
107
|
-
return undefined;
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
} while (visitedCps.length > 2);
|
|
111
|
-
return visitedCps;
|
|
112
|
-
}
|
|
113
|
-
/**
|
|
114
|
-
* @hidden
|
|
115
|
-
* Finds and add a 3-prong MAT circle to the given shape.
|
|
116
|
-
* @param cpGraphs
|
|
117
|
-
* @param visitedCps
|
|
118
|
-
* @param extreme The maximum coordinate value used to calculate floating point
|
|
119
|
-
* tolerances.
|
|
120
|
-
*/
|
|
121
|
-
function findAndAdd3Prong(cpGraphs, visitedCps, extreme) {
|
|
122
|
-
const δs = [];
|
|
123
|
-
for (const visitedCp of visitedCps) {
|
|
124
|
-
δs.push([visitedCp, visitedCp.next]);
|
|
125
|
-
}
|
|
126
|
-
const threeProng = find3Prong(δs, extreme);
|
|
127
|
-
const orders = [];
|
|
128
|
-
for (let i = 0; i < 3; i++) {
|
|
129
|
-
orders.push(
|
|
130
|
-
//PointOnShape.calcOrder(threeProng.circle, threeProng.ps[i])
|
|
131
|
-
calcPosOrder(threeProng.circle, threeProng.ps[i]));
|
|
132
|
-
}
|
|
133
|
-
const circle = add3Prong(cpGraphs, orders, threeProng);
|
|
134
|
-
if (typeof _debug_ !== 'undefined') {
|
|
135
|
-
add3ProngDebugInfo(circle, visitedCps);
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
/** @hidden */
|
|
139
|
-
function add3ProngDebugInfo(circle, visitedCps) {
|
|
140
|
-
const threeProngs = _debug_.generated.elems.threeProng;
|
|
141
|
-
const len = threeProngs.length;
|
|
142
|
-
const data = threeProngs[len - 1];
|
|
143
|
-
data.visitedCps = visitedCps;
|
|
144
|
-
data.circle = circle;
|
|
145
|
-
}
|
|
146
|
-
export { findAndAddAll3Prongs };
|
|
1
|
+
import { calcPosOrder, isPosSharpCorner } from '../../point-on-shape.js';
|
|
2
|
+
import { find3Prong } from './find-3-prong/find-3-prong.js';
|
|
3
|
+
import { add3Prong } from '../find-mat/add-3-prong.js';
|
|
4
|
+
/**
|
|
5
|
+
* @hidden
|
|
6
|
+
* Finds and adds all 3-prongs.
|
|
7
|
+
* @param cpGraphs
|
|
8
|
+
* @param cpStart The CpNode to start traversing from.
|
|
9
|
+
* @param extreme The maximum coordinate value used to calculate floating point
|
|
10
|
+
* tolerances.
|
|
11
|
+
*/
|
|
12
|
+
function findAndAddAll3Prongs(cpGraphs, cpStart, extreme) {
|
|
13
|
+
// Don't change this function to be recursive, the call stack may overflow
|
|
14
|
+
// if there are too many two-prongs.
|
|
15
|
+
const visitedEdges = new Map();
|
|
16
|
+
const edgesToCheck = [{ fromCpNode: undefined, cpStart }];
|
|
17
|
+
while (edgesToCheck.length) {
|
|
18
|
+
const { fromCpNode, cpStart } = edgesToCheck.shift();
|
|
19
|
+
markEdgeAsTaken(visitedEdges, fromCpNode, cpStart);
|
|
20
|
+
for (const cpNode of cpStart.getCpNodesOnCircle()) {
|
|
21
|
+
//if (!PointOnShape.isSharpCorner(cpNode.cp.pointOnShape)) {
|
|
22
|
+
if (!isPosSharpCorner(cpNode.cp.pointOnShape)) {
|
|
23
|
+
if (findAndAdd3Prongs(cpGraphs, cpNode, extreme) === undefined) {
|
|
24
|
+
return; // only for debugging purposes
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
if (hasEdgeBeenTaken(visitedEdges, cpNode, cpNode.next)) {
|
|
28
|
+
continue; // We already visited this edge
|
|
29
|
+
}
|
|
30
|
+
edgesToCheck.push({ fromCpNode: cpStart, cpStart: cpNode.next });
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* @hidden
|
|
36
|
+
* Marks the given edge as already taken.
|
|
37
|
+
*/
|
|
38
|
+
function markEdgeAsTaken(visitedEdges, cp1, cp2) {
|
|
39
|
+
if (cp1 === undefined) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
f(cp1, cp2);
|
|
43
|
+
f(cp2, cp1);
|
|
44
|
+
function f(cp1, cp2) {
|
|
45
|
+
let visited = visitedEdges.get(cp1);
|
|
46
|
+
if (!visited) {
|
|
47
|
+
visited = new Set();
|
|
48
|
+
visitedEdges.set(cp1, visited);
|
|
49
|
+
}
|
|
50
|
+
visited.add(cp2);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
/** @hidden */
|
|
54
|
+
function hasEdgeBeenTaken(visitedEdges, cp1, cp2) {
|
|
55
|
+
let cps;
|
|
56
|
+
cps = visitedEdges.get(cp1);
|
|
57
|
+
const takenForward = cps && cps.has(cp2);
|
|
58
|
+
cps = visitedEdges.get(cp2);
|
|
59
|
+
const takenBackwards = cps && cps.has(cp1);
|
|
60
|
+
return takenForward || takenBackwards;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* @hidden
|
|
64
|
+
* Traverses the shape from the given ContactPoint going around contact circles
|
|
65
|
+
* so that only a piece of the shape is traversed and returns the visited
|
|
66
|
+
* CpNodes (starting from the given CpNode).
|
|
67
|
+
* @param cpStart The ContactPoint from where to start the traversal.
|
|
68
|
+
*/
|
|
69
|
+
function traverseShape(cpStart) {
|
|
70
|
+
let cpNode = cpStart;
|
|
71
|
+
if (cpNode === cpNode.next.prevOnCircle) {
|
|
72
|
+
return [cpNode];
|
|
73
|
+
}
|
|
74
|
+
const visitedCps = [];
|
|
75
|
+
do {
|
|
76
|
+
visitedCps.push(cpNode);
|
|
77
|
+
const next = cpNode.next.prevOnCircle;
|
|
78
|
+
cpNode = cpNode === next
|
|
79
|
+
? cpNode = cpNode.next.next // Terminal vertex
|
|
80
|
+
: cpNode = next; // Take last exit
|
|
81
|
+
} while (cpNode !== cpStart);
|
|
82
|
+
return visitedCps;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* @hidden
|
|
86
|
+
* Starting from some ContactPoint, traverses the shape going around Vertices
|
|
87
|
+
* and if more than two Vertices have been visited in total then recursively
|
|
88
|
+
* adds 3-prongs until only one or two Vertices have been visited.
|
|
89
|
+
*
|
|
90
|
+
* This process further subdivides the shape.
|
|
91
|
+
* @param cpGraphs
|
|
92
|
+
* @param cpStart The ContactPoint from where to start the process.
|
|
93
|
+
* @param extreme The maximum coordinate value used to calculate floating point
|
|
94
|
+
* tolerances.
|
|
95
|
+
*/
|
|
96
|
+
let ii = 0;
|
|
97
|
+
function findAndAdd3Prongs(cpGraphs, cpStart, extreme) {
|
|
98
|
+
let visitedCps;
|
|
99
|
+
do {
|
|
100
|
+
visitedCps = traverseShape(cpStart);
|
|
101
|
+
if (visitedCps.length > 2) {
|
|
102
|
+
findAndAdd3Prong(cpGraphs, visitedCps, extreme);
|
|
103
|
+
ii++;
|
|
104
|
+
}
|
|
105
|
+
if (typeof _debug_ !== 'undefined') {
|
|
106
|
+
if (ii === _debug_.directives.stopAfterThreeProngsNum) {
|
|
107
|
+
return undefined;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
} while (visitedCps.length > 2);
|
|
111
|
+
return visitedCps;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* @hidden
|
|
115
|
+
* Finds and add a 3-prong MAT circle to the given shape.
|
|
116
|
+
* @param cpGraphs
|
|
117
|
+
* @param visitedCps
|
|
118
|
+
* @param extreme The maximum coordinate value used to calculate floating point
|
|
119
|
+
* tolerances.
|
|
120
|
+
*/
|
|
121
|
+
function findAndAdd3Prong(cpGraphs, visitedCps, extreme) {
|
|
122
|
+
const δs = [];
|
|
123
|
+
for (const visitedCp of visitedCps) {
|
|
124
|
+
δs.push([visitedCp, visitedCp.next]);
|
|
125
|
+
}
|
|
126
|
+
const threeProng = find3Prong(δs, extreme);
|
|
127
|
+
const orders = [];
|
|
128
|
+
for (let i = 0; i < 3; i++) {
|
|
129
|
+
orders.push(
|
|
130
|
+
//PointOnShape.calcOrder(threeProng.circle, threeProng.ps[i])
|
|
131
|
+
calcPosOrder(threeProng.circle, threeProng.ps[i]));
|
|
132
|
+
}
|
|
133
|
+
const circle = add3Prong(cpGraphs, orders, threeProng);
|
|
134
|
+
if (typeof _debug_ !== 'undefined') {
|
|
135
|
+
add3ProngDebugInfo(circle, visitedCps);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
/** @hidden */
|
|
139
|
+
function add3ProngDebugInfo(circle, visitedCps) {
|
|
140
|
+
const threeProngs = _debug_.generated.elems.threeProng;
|
|
141
|
+
const len = threeProngs.length;
|
|
142
|
+
const data = threeProngs[len - 1];
|
|
143
|
+
data.visitedCps = visitedCps;
|
|
144
|
+
data.circle = circle;
|
|
145
|
+
}
|
|
146
|
+
export { findAndAddAll3Prongs };
|
|
147
147
|
//# sourceMappingURL=find-and-add-3-prongs.js.map
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { LlRbTree } from 'flo-ll-rb-tree';
|
|
2
|
-
import { Loop } from '../../loop.js';
|
|
3
|
-
import { CpNode } from '../../cp-node.js';
|
|
4
|
-
/**
|
|
5
|
-
* @hidden
|
|
6
|
-
* Find and add two-prongs that remove any holes in the shape.
|
|
7
|
-
* @param loops The loops (that as a precondition must be ordered from
|
|
8
|
-
* highest (i.e. smallest y-value) topmost point loops to lowest)
|
|
9
|
-
* @param cpTrees
|
|
10
|
-
* @param extreme The maximum coordinate value used to calculate floating point
|
|
11
|
-
* tolerances.
|
|
12
|
-
*/
|
|
13
|
-
declare function findAndAddHoleClosing2Prongs(loops: Loop[], cpTrees: Map<Loop, LlRbTree<CpNode>>, extreme: number): void;
|
|
14
|
-
export { findAndAddHoleClosing2Prongs };
|
|
1
|
+
import { LlRbTree } from 'flo-ll-rb-tree';
|
|
2
|
+
import { Loop } from '../../loop.js';
|
|
3
|
+
import { CpNode } from '../../cp-node.js';
|
|
4
|
+
/**
|
|
5
|
+
* @hidden
|
|
6
|
+
* Find and add two-prongs that remove any holes in the shape.
|
|
7
|
+
* @param loops The loops (that as a precondition must be ordered from
|
|
8
|
+
* highest (i.e. smallest y-value) topmost point loops to lowest)
|
|
9
|
+
* @param cpTrees
|
|
10
|
+
* @param extreme The maximum coordinate value used to calculate floating point
|
|
11
|
+
* tolerances.
|
|
12
|
+
*/
|
|
13
|
+
declare function findAndAddHoleClosing2Prongs(loops: Loop[], cpTrees: Map<Loop, LlRbTree<CpNode>>, extreme: number): void;
|
|
14
|
+
export { findAndAddHoleClosing2Prongs };
|
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
import { getShapeBounds } from '../../svg/get-shape-bounds.js';
|
|
2
|
-
import { getMinYPos } from '../../svg/get-min-y-pos.js';
|
|
3
|
-
import { find2Prong } from './find-2-prong/find-2-prong.js';
|
|
4
|
-
import { add2Prong } from './add-2-prong.js';
|
|
5
|
-
/**
|
|
6
|
-
* @hidden
|
|
7
|
-
* Find and add two-prongs that remove any holes in the shape.
|
|
8
|
-
* @param loops The loops (that as a precondition must be ordered from
|
|
9
|
-
* highest (i.e. smallest y-value) topmost point loops to lowest)
|
|
10
|
-
* @param cpTrees
|
|
11
|
-
* @param extreme The maximum coordinate value used to calculate floating point
|
|
12
|
-
* tolerances.
|
|
13
|
-
*/
|
|
14
|
-
function findAndAddHoleClosing2Prongs(loops, cpTrees, extreme) {
|
|
15
|
-
const bounds = getShapeBounds(loops);
|
|
16
|
-
const squaredDiagonalLength = (bounds.maxX.p[0] - bounds.minX.p[0]) ** 2 +
|
|
17
|
-
(bounds.maxY.p[1] - bounds.minY.p[1]) ** 2;
|
|
18
|
-
// Find the topmost points on each loop.
|
|
19
|
-
const minYs = loops.map(getMinYPos);
|
|
20
|
-
// We start at 1 since 0 is the outer (root) loop
|
|
21
|
-
for (let k = 1; k < minYs.length; k++) {
|
|
22
|
-
const posSource = minYs[k];
|
|
23
|
-
const holeClosingTwoProng = find2Prong(loops, extreme, squaredDiagonalLength, cpTrees, posSource, true, k);
|
|
24
|
-
if (!holeClosingTwoProng) {
|
|
25
|
-
throw new Error(`Unable to find hole-closing 2-prong`);
|
|
26
|
-
}
|
|
27
|
-
// TODO important - handle case of n-prong, i.e. more than one antipode
|
|
28
|
-
// - currently we only handle case of single antipode (the general case)
|
|
29
|
-
const { circle, zs: posAntipodes } = holeClosingTwoProng;
|
|
30
|
-
add2Prong(cpTrees, circle, posSource, [posAntipodes[0]], true, extreme);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
export { findAndAddHoleClosing2Prongs };
|
|
1
|
+
import { getShapeBounds } from '../../svg/get-shape-bounds.js';
|
|
2
|
+
import { getMinYPos } from '../../svg/get-min-y-pos.js';
|
|
3
|
+
import { find2Prong } from './find-2-prong/find-2-prong.js';
|
|
4
|
+
import { add2Prong } from './add-2-prong.js';
|
|
5
|
+
/**
|
|
6
|
+
* @hidden
|
|
7
|
+
* Find and add two-prongs that remove any holes in the shape.
|
|
8
|
+
* @param loops The loops (that as a precondition must be ordered from
|
|
9
|
+
* highest (i.e. smallest y-value) topmost point loops to lowest)
|
|
10
|
+
* @param cpTrees
|
|
11
|
+
* @param extreme The maximum coordinate value used to calculate floating point
|
|
12
|
+
* tolerances.
|
|
13
|
+
*/
|
|
14
|
+
function findAndAddHoleClosing2Prongs(loops, cpTrees, extreme) {
|
|
15
|
+
const bounds = getShapeBounds(loops);
|
|
16
|
+
const squaredDiagonalLength = (bounds.maxX.p[0] - bounds.minX.p[0]) ** 2 +
|
|
17
|
+
(bounds.maxY.p[1] - bounds.minY.p[1]) ** 2;
|
|
18
|
+
// Find the topmost points on each loop.
|
|
19
|
+
const minYs = loops.map(getMinYPos);
|
|
20
|
+
// We start at 1 since 0 is the outer (root) loop
|
|
21
|
+
for (let k = 1; k < minYs.length; k++) {
|
|
22
|
+
const posSource = minYs[k];
|
|
23
|
+
const holeClosingTwoProng = find2Prong(loops, extreme, squaredDiagonalLength, cpTrees, posSource, true, k);
|
|
24
|
+
if (!holeClosingTwoProng) {
|
|
25
|
+
throw new Error(`Unable to find hole-closing 2-prong`);
|
|
26
|
+
}
|
|
27
|
+
// TODO important - handle case of n-prong, i.e. more than one antipode
|
|
28
|
+
// - currently we only handle case of single antipode (the general case)
|
|
29
|
+
const { circle, zs: posAntipodes } = holeClosingTwoProng;
|
|
30
|
+
add2Prong(cpTrees, circle, posSource, [posAntipodes[0]], true, extreme);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
export { findAndAddHoleClosing2Prongs };
|
|
34
34
|
//# sourceMappingURL=find-and-add-hole-closing-2-prongs.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IPointOnShape } from '../../point-on-shape.js';
|
|
2
|
-
/** @hidden */
|
|
3
|
-
declare function getPotential2Prongs(possPerLoop: IPointOnShape[][]): IPointOnShape[][];
|
|
4
|
-
export { getPotential2Prongs };
|
|
1
|
+
import { IPointOnShape } from '../../point-on-shape.js';
|
|
2
|
+
/** @hidden */
|
|
3
|
+
declare function getPotential2Prongs(possPerLoop: IPointOnShape[][]): IPointOnShape[][];
|
|
4
|
+
export { getPotential2Prongs };
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { isPosQuiteSharpCorner } from '../../point-on-shape.js';
|
|
2
|
-
/** @hidden */
|
|
3
|
-
function getPotential2Prongs(possPerLoop) {
|
|
4
|
-
const for2ProngsArray = [];
|
|
5
|
-
for (const poss of possPerLoop) {
|
|
6
|
-
const for2Prongs = [];
|
|
7
|
-
for (const pos of poss) {
|
|
8
|
-
if (!isPosQuiteSharpCorner(pos)) {
|
|
9
|
-
for2Prongs.push(pos);
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
for2ProngsArray.push(for2Prongs);
|
|
13
|
-
}
|
|
14
|
-
return for2ProngsArray;
|
|
15
|
-
}
|
|
16
|
-
export { getPotential2Prongs };
|
|
1
|
+
import { isPosQuiteSharpCorner } from '../../point-on-shape.js';
|
|
2
|
+
/** @hidden */
|
|
3
|
+
function getPotential2Prongs(possPerLoop) {
|
|
4
|
+
const for2ProngsArray = [];
|
|
5
|
+
for (const poss of possPerLoop) {
|
|
6
|
+
const for2Prongs = [];
|
|
7
|
+
for (const pos of poss) {
|
|
8
|
+
if (!isPosQuiteSharpCorner(pos)) {
|
|
9
|
+
for2Prongs.push(pos);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
for2ProngsArray.push(for2Prongs);
|
|
13
|
+
}
|
|
14
|
+
return for2ProngsArray;
|
|
15
|
+
}
|
|
16
|
+
export { getPotential2Prongs };
|
|
17
17
|
//# sourceMappingURL=get-potential-2-prongs.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IPointOnShape } from '../../point-on-shape.js';
|
|
2
|
-
/** @hidden */
|
|
3
|
-
declare function getSharpCorners(possPerLoop: IPointOnShape[][]): IPointOnShape[][];
|
|
4
|
-
export { getSharpCorners };
|
|
1
|
+
import { IPointOnShape } from '../../point-on-shape.js';
|
|
2
|
+
/** @hidden */
|
|
3
|
+
declare function getSharpCorners(possPerLoop: IPointOnShape[][]): IPointOnShape[][];
|
|
4
|
+
export { getSharpCorners };
|