flo-mat 4.1.3 → 4.1.5
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__/cp-node/circle-identity.spec.ts +56 -0
- package/__tests__/find-2-prong/get-medial/dd-get-medial-point-coeffs-same-curve.spec.ts +8 -6
- package/__tests__/find-2-prong/get-medial/dd-get-medial-point-coeffs.spec.ts +4 -2
- package/__tests__/specific-cases/specific-cases.spec.ts +1 -14
- package/__tests__/specific-cases/test-svgs/achispado.svg +37 -24
- package/browser/index.js +2969 -2315
- package/browser/index.min.js +1 -1
- package/node/add-n-prong.ts/join-spokes.js +3 -2
- package/node/add-n-prong.ts/join-spokes.js.map +1 -1
- package/node/cp-node/fs/enhance-cp-node.d.ts +9 -9
- package/node/cp-node/fs/get-angle-between-mat-curves.d.ts +1 -1
- package/node/cp-node/fs/get-angle-between-mat-curves.js +2 -1
- package/node/cp-node/fs/get-angle-between-mat-curves.js.map +1 -1
- package/node/cp-node/fs/get-edge-direction.js +3 -2
- package/node/cp-node/fs/get-edge-direction.js.map +1 -1
- package/node/cp-node/fs/get-implied-boundary-bezier-between.d.ts +1 -1
- package/node/cp-node/fs/get-implied-boundary-bezier-between.js +3 -2
- 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 +1 -0
- package/node/cp-node/fs/get-mat-curve-between.js +1 -0
- package/node/cp-node/fs/get-mat-curve-between.js.map +1 -1
- package/node/cp-node/fs/insert-cp-node.d.ts +12 -1
- package/node/cp-node/fs/insert-cp-node.js +21 -6
- package/node/cp-node/fs/insert-cp-node.js.map +1 -1
- package/node/cp-node/fs/is-fully-terminating.d.ts +1 -1
- package/node/cp-node/fs/is-fully-terminating.js +3 -5
- package/node/cp-node/fs/is-fully-terminating.js.map +1 -1
- package/node/cp-node/fs/is-on-same-circle.d.ts +3 -0
- package/node/cp-node/fs/is-on-same-circle.js +4 -4
- package/node/cp-node/fs/is-on-same-circle.js.map +1 -1
- package/node/cp-node/fs/is-order-correct.d.ts +9 -1
- package/node/cp-node/fs/is-order-correct.js +51 -10
- package/node/cp-node/fs/is-order-correct.js.map +1 -1
- package/node/cp-node/fs/remove-cp-node.js +1 -1
- package/node/cp-node/fs/remove-cp-node.js.map +1 -1
- package/node/cp-node/stringification/from-stringifyable.js +16 -0
- package/node/cp-node/stringification/from-stringifyable.js.map +1 -1
- package/node/debug/functions/check-ordering.d.ts +4 -0
- package/node/debug/functions/check-ordering.js +43 -0
- package/node/debug/functions/check-ordering.js.map +1 -0
- package/node/find-2-prong/add-2-prong.js +8 -2
- package/node/find-2-prong/add-2-prong.js.map +1 -1
- package/node/find-2-prong/calc-seperation-tolerance.js +2 -2
- package/node/find-2-prong/calc-seperation-tolerance.js.map +1 -1
- package/node/find-2-prong/find-and-add-2-prongs.js +1 -1
- package/node/find-2-prong/find-and-add-2-prongs.js.map +1 -1
- package/node/find-2-prong/get-initial-bezier-pieces.js +2 -2
- package/node/find-2-prong/get-initial-bezier-pieces.js.map +1 -1
- package/node/find-3-prong/find-3-prong-for-delta3s.d.ts +1 -1
- package/node/find-3-prong/find-3-prong-for-delta3s.js +1 -1
- package/node/find-3-prong/find-3-prong-for-delta3s.js.map +1 -1
- package/node/find-3-prong/find-3-prong.d.ts +1 -1
- package/node/find-3-prong/find-3-prong.js.map +1 -1
- package/node/find-3-prong/find-and-add-3-prong.js +1 -1
- package/node/find-3-prong/find-and-add-3-prong.js.map +1 -1
- package/node/find-3-prong/find-and-add-3-prongs-on-loop.d.ts +1 -1
- package/node/find-3-prong/find-and-add-3-prongs-on-loop.js +6 -2
- package/node/find-3-prong/find-and-add-3-prongs-on-loop.js.map +1 -1
- package/node/find-3-prong/three-prong-info.d.ts +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 +2 -2
- package/node/find-mat/find-mat.js.map +1 -1
- package/node/find-mat/get-for-1-prongs-on-loop.js +3 -1
- package/node/find-mat/get-for-1-prongs-on-loop.js.map +1 -1
- package/node/geometry/get-closest-squared-distance-to-rotated-rect.js +2 -1
- package/node/geometry/get-closest-squared-distance-to-rotated-rect.js.map +1 -1
- package/node/mat/add-to-cp-tree.d.ts +4 -1
- package/node/mat/add-to-cp-tree.js +11 -4
- package/node/mat/add-to-cp-tree.js.map +1 -1
- package/node/mat/get-boundary-piece-beziers.d.ts +2 -2
- package/node/mat/get-boundary-piece-beziers.js +1 -1
- package/node/mat/get-boundary-piece-beziers.js.map +1 -1
- package/node/mat/get-closeby-cp-if-exist.js +4 -3
- package/node/mat/get-closeby-cp-if-exist.js.map +1 -1
- package/node/mat/{get-cp-node-to-left-or-same.d.ts → get-cp-node-neighbors.d.ts} +2 -2
- package/node/mat/get-cp-node-neighbors.js +31 -0
- package/node/mat/get-cp-node-neighbors.js.map +1 -0
- package/node/point-on-shape/point-on-shape.d.ts +5 -0
- package/node/reconstruct-from-mat/reconstruct-from-mat.js.map +1 -1
- package/package.json +15 -15
- package/src/add-n-prong.ts/join-spokes.ts +4 -2
- package/src/cp-node/fs/get-angle-between-mat-curves.ts +4 -2
- package/src/cp-node/fs/get-edge-direction.ts +4 -2
- package/src/cp-node/fs/get-implied-boundary-bezier-between.ts +6 -6
- package/src/cp-node/fs/get-mat-curve-between.ts +1 -0
- package/src/cp-node/fs/insert-cp-node.ts +22 -7
- package/src/cp-node/fs/is-fully-terminating.ts +3 -7
- package/src/cp-node/fs/is-on-same-circle.ts +6 -7
- package/src/cp-node/fs/is-order-correct copy.ts +60 -0
- package/src/cp-node/fs/is-order-correct.ts +61 -13
- package/src/cp-node/fs/remove-cp-node.ts +1 -1
- package/src/cp-node/stringification/from-stringifyable.ts +17 -0
- package/src/debug/functions/check-ordering.ts +44 -61
- package/src/find-2-prong/add-2-prong.ts +9 -2
- package/src/find-2-prong/calc-seperation-tolerance.ts +2 -2
- package/src/find-2-prong/find-and-add-2-prongs.ts +1 -1
- package/src/find-2-prong/get-initial-bezier-pieces.ts +2 -2
- package/src/find-3-prong/find-3-prong-for-delta3s.ts +15 -7
- package/src/find-3-prong/find-3-prong.ts +1 -1
- package/src/find-3-prong/find-and-add-3-prong.ts +1 -4
- package/src/find-3-prong/find-and-add-3-prongs-on-loop.ts +6 -3
- package/src/find-3-prong/three-prong-info.ts +1 -1
- package/src/find-mat/create-initial-cp-tree.ts +2 -2
- package/src/find-mat/find-mat.ts +3 -2
- package/src/find-mat/get-for-1-prongs-on-loop.ts +3 -1
- package/src/geometry/get-closest-squared-distance-to-rotated-rect.ts +4 -4
- package/src/mat/add-to-cp-tree copy.ts +71 -0
- package/src/mat/add-to-cp-tree.ts +12 -4
- package/src/mat/get-boundary-piece-beziers.ts +2 -2
- package/src/mat/get-closeby-cp-if-exist.ts +5 -3
- package/src/mat/{get-cp-node-to-left-or-same.ts → get-cp-node-neighbors.ts} +12 -10
- package/src/point-on-shape/point-on-shape.ts +5 -0
- package/src/utils/deg-to-rad.ts +4 -2
- package/src/utils/rad-to-deg.ts +4 -1
- package/webpack.config.cjs +7 -2
- package/node/mat/get-cp-node-to-left-or-same.js +0 -30
- package/node/mat/get-cp-node-to-left-or-same.js.map +0 -1
|
@@ -25,7 +25,6 @@ function findAndAdd3Prong(
|
|
|
25
25
|
δs.push([visitedCp, visitedCp.next]);
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
|
|
29
28
|
const threeProngInfo = find3Prong(δs, meta.maxCoordPowerOf2);
|
|
30
29
|
|
|
31
30
|
const { circle, poss, δ3s } = threeProngInfo;
|
|
@@ -49,9 +48,7 @@ function findAndAdd3Prong(
|
|
|
49
48
|
}
|
|
50
49
|
|
|
51
50
|
const cpNodes = closeBysFor3Prong.length === 0
|
|
52
|
-
? addToCpTree(
|
|
53
|
-
true, false, circle, orders, meta, poss, δ3s.map(v => v[0])
|
|
54
|
-
).cpNodes
|
|
51
|
+
? addToCpTree(true, false, circle, orders, meta, poss, δ3s).cpNodes
|
|
55
52
|
: [];
|
|
56
53
|
|
|
57
54
|
return { closeBysFor3Prong, cpNodes: cpNodes as CpNode[] };
|
|
@@ -12,7 +12,7 @@ import { getAllOnCircle } from '../cp-node/fs/get-all-on-circle.js';
|
|
|
12
12
|
*
|
|
13
13
|
* @param meta
|
|
14
14
|
* @param cpStart The CpNode to start traversing from.
|
|
15
|
-
|
|
15
|
+
*/
|
|
16
16
|
function findAndAdd3ProngsOnLoop(
|
|
17
17
|
meta: MatMeta,
|
|
18
18
|
cpStart: CpNode | undefined): CpNode | undefined {
|
|
@@ -25,8 +25,11 @@ function findAndAdd3ProngsOnLoop(
|
|
|
25
25
|
reLoop = false;
|
|
26
26
|
const cpNodeSet = new Set(getAllOnLoop(cpStart));
|
|
27
27
|
for (const cpNode of cpNodeSet) {
|
|
28
|
-
const
|
|
29
|
-
|
|
28
|
+
const threeProngs = findAndAdd3Prongs(meta, cpNode);
|
|
29
|
+
if (threeProngs === undefined) {
|
|
30
|
+
return getFirstItemOfSet(cpNodeGoodSet)!;
|
|
31
|
+
}
|
|
32
|
+
const { closeBysFor3Prong, addedCpNodes } = threeProngs;
|
|
30
33
|
|
|
31
34
|
if (addedCpNodes.length > 0) { reLoop = true; }
|
|
32
35
|
|
|
@@ -6,7 +6,7 @@ import type { PrePointOnShape } from '../point-on-shape/point-on-shape.js';
|
|
|
6
6
|
interface ThreeProngInfo {
|
|
7
7
|
readonly circle: Circle;
|
|
8
8
|
readonly poss: PrePointOnShape[];
|
|
9
|
-
readonly δ3s: CpNode[][];
|
|
9
|
+
readonly δ3s: [[CpNode, CpNode], [CpNode, CpNode], [CpNode, CpNode]];
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
|
|
@@ -41,8 +41,8 @@ function createInitialCpTree(
|
|
|
41
41
|
const pos1: PointOnShape = { ...ppos, curve, t: 1, circle, order: -1, order2: 0 };
|
|
42
42
|
const pos2: PointOnShape = { ...ppos, curve: curve.next, t: 0, circle, order: +1, order2: 0 };
|
|
43
43
|
|
|
44
|
-
cpNode1 = insertCpNode(true, false, false, cpTree, pos1, cpNode2, lastInsertId)!;
|
|
45
|
-
cpNode2 = insertCpNode(true, false, false, cpTree, pos2, cpNode1, lastInsertId)!;
|
|
44
|
+
cpNode1 = insertCpNode(true, false, false, cpTree, pos1, cpNode2, undefined, /* unused */ lastInsertId)!;
|
|
45
|
+
cpNode2 = insertCpNode(true, false, false, cpTree, pos2, cpNode1, undefined, /* unused */ lastInsertId)!;
|
|
46
46
|
|
|
47
47
|
cpNode1.prevOnCircle = cpNode2;
|
|
48
48
|
cpNode2.prevOnCircle = cpNode1;
|
package/src/find-mat/find-mat.ts
CHANGED
|
@@ -16,6 +16,7 @@ import { getFor2ProngsOnLoop } from './get-for-2-prongs-on-loop.js';
|
|
|
16
16
|
import { getFor1ProngsOnLoop } from './get-for-1-prongs-on-loop.js';
|
|
17
17
|
import { findAndAddHoleClosing2Prongs } from '../find-2-prong/find-and-add-hole-closing-2-prongs.js';
|
|
18
18
|
import { getShapeBounds } from '../svg/get-shape-bounds.js';
|
|
19
|
+
import { checkOrdering } from '../debug/functions/check-ordering.js';
|
|
19
20
|
|
|
20
21
|
|
|
21
22
|
/**
|
|
@@ -85,10 +86,10 @@ function findMat(
|
|
|
85
86
|
if (cpNode === undefined) { return undefined!; }
|
|
86
87
|
|
|
87
88
|
if (typeof _debug_ !== 'undefined') {
|
|
88
|
-
if (_debug_.directives.stopAfterThreeProngs) { return { cpNode
|
|
89
|
+
if (_debug_.directives.stopAfterThreeProngs) { return { cpNode, meta }; }
|
|
89
90
|
}
|
|
90
91
|
|
|
91
|
-
// if (cpNode !== undefined) { checkOrdering(
|
|
92
|
+
// if (cpNode !== undefined) { checkOrdering(meta, cpNode); }
|
|
92
93
|
|
|
93
94
|
const mat = { cpNode, meta };
|
|
94
95
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
}
|
|
1
|
+
import { squaredDistanceBetweenPointAndLineSegment, squaredDistanceBetween } from 'flo-vector2d';
|
|
2
|
+
|
|
3
|
+
const { min } = Math;
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
/**
|
|
@@ -23,7 +23,7 @@ function getClosestSquaredDistanceToRotatedRect(ps: number[][], p: number[]) {
|
|
|
23
23
|
return 0; // Inside rotated rect
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
return
|
|
26
|
+
return min(...ds);
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import type { Circle } from '../geometry/circle.js';
|
|
2
|
+
import type { PointOnShape, PrePointOnShape } from '../point-on-shape/point-on-shape.js';
|
|
3
|
+
import type { CpNode } from '../cp-node/cp-node.js';
|
|
4
|
+
import type { MatMeta } from '../mat/mat-meta.js';
|
|
5
|
+
import { getCpNodeNeighbors } from './get-cp-node-neighbors.js';
|
|
6
|
+
import { insertCpNode } from '../cp-node/fs/insert-cp-node.js';
|
|
7
|
+
import { joinSpokes } from '../add-n-prong.ts/join-spokes.js';
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Insert the given `poss` into the `cpTree` (within `meta`) and returns the
|
|
12
|
+
* newly inserted `CpNode`s.
|
|
13
|
+
*
|
|
14
|
+
* @param circle
|
|
15
|
+
* @param orders
|
|
16
|
+
* @param cpTrees
|
|
17
|
+
* @param poss
|
|
18
|
+
* @param neighbors
|
|
19
|
+
*
|
|
20
|
+
* @internal
|
|
21
|
+
*/
|
|
22
|
+
function addToCpTree(
|
|
23
|
+
insertIfOrderIsWrong: boolean,
|
|
24
|
+
isHoleClosing: boolean,
|
|
25
|
+
circle: Circle,
|
|
26
|
+
orders: number[],
|
|
27
|
+
meta: MatMeta,
|
|
28
|
+
poss: PrePointOnShape[],
|
|
29
|
+
neighbors?: [CpNode,CpNode][]): { anyFailed: boolean, cpNodes: (CpNode | undefined) [] } {
|
|
30
|
+
|
|
31
|
+
const { cpTrees } = meta;
|
|
32
|
+
|
|
33
|
+
let anyFailed = false;
|
|
34
|
+
const cpNodes = poss.map((ppos,i) => {
|
|
35
|
+
const order = orders[i];
|
|
36
|
+
const cpTree = cpTrees.get(ppos.curve.loop)!;
|
|
37
|
+
const pos: PointOnShape = { ...ppos, circle, order, order2: 0 };
|
|
38
|
+
|
|
39
|
+
const r = neighbors === undefined
|
|
40
|
+
? getCpNodeNeighbors(cpTree, ppos, order, 0)
|
|
41
|
+
: neighbors[i];
|
|
42
|
+
|
|
43
|
+
const pred = r?.[0];
|
|
44
|
+
// const succ = r?.[1];
|
|
45
|
+
const succ = pred?.next;
|
|
46
|
+
|
|
47
|
+
const cpNode = insertCpNode(
|
|
48
|
+
insertIfOrderIsWrong,
|
|
49
|
+
isHoleClosing,
|
|
50
|
+
false,
|
|
51
|
+
cpTree,
|
|
52
|
+
pos,
|
|
53
|
+
pred,
|
|
54
|
+
succ,
|
|
55
|
+
meta.lastInsertId
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
if (cpNode === undefined) { anyFailed = true; }
|
|
59
|
+
|
|
60
|
+
return cpNode;
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
if (!anyFailed) {
|
|
64
|
+
joinSpokes(circle, cpNodes as CpNode[]);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return { anyFailed, cpNodes };
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
export { addToCpTree }
|
|
@@ -2,12 +2,15 @@ import type { Circle } from '../geometry/circle.js';
|
|
|
2
2
|
import type { PointOnShape, PrePointOnShape } from '../point-on-shape/point-on-shape.js';
|
|
3
3
|
import type { CpNode } from '../cp-node/cp-node.js';
|
|
4
4
|
import type { MatMeta } from '../mat/mat-meta.js';
|
|
5
|
-
import {
|
|
5
|
+
import { getCpNodeNeighbors } from './get-cp-node-neighbors.js';
|
|
6
6
|
import { insertCpNode } from '../cp-node/fs/insert-cp-node.js';
|
|
7
7
|
import { joinSpokes } from '../add-n-prong.ts/join-spokes.js';
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
|
+
* Insert the given `poss` into the `cpTree` (within `meta`) and returns the
|
|
12
|
+
* newly inserted `CpNode`s.
|
|
13
|
+
*
|
|
11
14
|
* @param circle
|
|
12
15
|
* @param orders
|
|
13
16
|
* @param cpTrees
|
|
@@ -23,7 +26,7 @@ function addToCpTree(
|
|
|
23
26
|
orders: number[],
|
|
24
27
|
meta: MatMeta,
|
|
25
28
|
poss: PrePointOnShape[],
|
|
26
|
-
neighbors?: CpNode[]): { anyFailed: boolean, cpNodes: (CpNode | undefined) [] } {
|
|
29
|
+
neighbors?: [CpNode,CpNode][]): { anyFailed: boolean, cpNodes: (CpNode | undefined) [] } {
|
|
27
30
|
|
|
28
31
|
const { cpTrees } = meta;
|
|
29
32
|
|
|
@@ -33,10 +36,13 @@ function addToCpTree(
|
|
|
33
36
|
const cpTree = cpTrees.get(ppos.curve.loop)!;
|
|
34
37
|
const pos: PointOnShape = { ...ppos, circle, order, order2: 0 };
|
|
35
38
|
|
|
36
|
-
const
|
|
37
|
-
?
|
|
39
|
+
const r = neighbors === undefined
|
|
40
|
+
? getCpNodeNeighbors(cpTree, ppos, order, 0)
|
|
38
41
|
: neighbors[i];
|
|
39
42
|
|
|
43
|
+
const pred = r?.[0];
|
|
44
|
+
const succ = r?.[1];
|
|
45
|
+
|
|
40
46
|
const cpNode = insertCpNode(
|
|
41
47
|
insertIfOrderIsWrong,
|
|
42
48
|
isHoleClosing,
|
|
@@ -44,6 +50,8 @@ function addToCpTree(
|
|
|
44
50
|
cpTree,
|
|
45
51
|
pos,
|
|
46
52
|
pred,
|
|
53
|
+
// pred?.next,
|
|
54
|
+
succ,
|
|
47
55
|
meta.lastInsertId
|
|
48
56
|
);
|
|
49
57
|
|
|
@@ -5,7 +5,7 @@ import { comparePoss } from '../point-on-shape/compare-poss.js';
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
|
-
* Returns the ordered bezier pieces between
|
|
8
|
+
* Returns the ordered bezier pieces between the two given `CpNode`s.
|
|
9
9
|
*
|
|
10
10
|
* @param cpNodes - An ordered pair that represents the start and end points of
|
|
11
11
|
* the boundary piece
|
|
@@ -13,7 +13,7 @@ import { comparePoss } from '../point-on-shape/compare-poss.js';
|
|
|
13
13
|
* @internal
|
|
14
14
|
*/
|
|
15
15
|
function getBoundaryPieceBeziers(
|
|
16
|
-
cpNodes: CpNode
|
|
16
|
+
cpNodes: [CpNode,CpNode]): CurvePiece[] {
|
|
17
17
|
|
|
18
18
|
let cpThis = cpNodes[0];
|
|
19
19
|
const cpEnd = cpNodes[1];
|
|
@@ -3,12 +3,14 @@ import type { PrePointOnShape } from '../point-on-shape/point-on-shape.js';
|
|
|
3
3
|
import type { Circle } from '../geometry/circle.js';
|
|
4
4
|
import type { MatMeta } from './mat-meta.js';
|
|
5
5
|
import { distanceBetween, toUnitVector, fromTo, dot } from 'flo-vector2d';
|
|
6
|
-
import {
|
|
6
|
+
import { getCpNodeNeighbors } from './get-cp-node-neighbors.js';
|
|
7
|
+
|
|
8
|
+
const { cos, PI: π } = Math;
|
|
7
9
|
|
|
8
10
|
|
|
9
11
|
/** @internal */
|
|
10
12
|
const DEGREES = 1;
|
|
11
|
-
const ANGLE_THRESHOLD =
|
|
13
|
+
const ANGLE_THRESHOLD = cos(DEGREES * (π/180));
|
|
12
14
|
|
|
13
15
|
|
|
14
16
|
/**
|
|
@@ -36,7 +38,7 @@ function getCloseByCpIfExist(
|
|
|
36
38
|
const DISTANCE_THRESHOLD_2 = 2**(maxCoordPowerOf2 - 46);
|
|
37
39
|
|
|
38
40
|
const cpTree = cpTrees.get(pos.curve.loop)!;
|
|
39
|
-
const cur =
|
|
41
|
+
const cur = getCpNodeNeighbors(cpTree, pos, order, order2)?.[0];
|
|
40
42
|
if (!cur) { return undefined; }
|
|
41
43
|
const cpNodes = [cur, cur.next];
|
|
42
44
|
|
|
@@ -16,29 +16,31 @@ import { RbTree } from 'flo-ll-rb-tree';
|
|
|
16
16
|
* @param order
|
|
17
17
|
* @param order2
|
|
18
18
|
*/
|
|
19
|
-
function
|
|
19
|
+
function getCpNodeNeighbors(
|
|
20
20
|
cpTree: RbTree<CpNode>,
|
|
21
21
|
pos: PrePointOnShape,
|
|
22
22
|
order: number,
|
|
23
|
-
order2: number): CpNode | undefined {
|
|
23
|
+
order2: number): [CpNode,CpNode] | undefined {
|
|
24
24
|
|
|
25
25
|
const pointOnShape = { ...pos, order, order2 };
|
|
26
26
|
const cps = cpTree.findBounds({ pointOnShape } as CpNode);
|
|
27
|
+
const [cp0,cp1] = cps;
|
|
27
28
|
|
|
28
|
-
if (
|
|
29
|
+
if (cp0 === undefined && cp1 === undefined) {
|
|
29
30
|
// The tree is still empty
|
|
30
31
|
return undefined;
|
|
31
32
|
}
|
|
32
33
|
|
|
33
|
-
if (
|
|
34
|
-
// Smaller than all
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
34
|
+
if (cp0 === undefined || cp1 === undefined) {
|
|
35
|
+
// Smaller than all OR larger than all
|
|
36
|
+
const minNode = cpTree.getMinNode()?.datum!;
|
|
37
|
+
const maxNode = cpTree.getMaxNode()?.datum!;
|
|
38
|
+
|
|
39
|
+
return [maxNode,minNode];
|
|
38
40
|
}
|
|
39
41
|
|
|
40
|
-
return
|
|
42
|
+
return [cp0.datum, cp1.datum];
|
|
41
43
|
}
|
|
42
44
|
|
|
43
45
|
|
|
44
|
-
export {
|
|
46
|
+
export { getCpNodeNeighbors }
|
|
@@ -44,6 +44,11 @@ interface PointOnShape extends PrePointOnShape {
|
|
|
44
44
|
* The (cached) maximal disk circle touching this point.
|
|
45
45
|
* Calculated from `curve` and `t` (if 2-prong source point, else
|
|
46
46
|
* from `curve` and `t` of the antipodal 2-prong point).
|
|
47
|
+
*
|
|
48
|
+
* * the same `Circle` object is shared by all `CpNode`s on the same
|
|
49
|
+
* on-circle ring (`nextOnCircle`), and only by them - so object
|
|
50
|
+
* identity identifies the MAT vertex (hole-closer twins form their own
|
|
51
|
+
* ring, with their own equal circle)
|
|
47
52
|
*/
|
|
48
53
|
readonly circle: Circle;
|
|
49
54
|
/** Internally used to order two points lying at the same planar point. */
|
package/src/utils/deg-to-rad.ts
CHANGED
package/src/utils/rad-to-deg.ts
CHANGED
package/webpack.config.cjs
CHANGED
|
@@ -38,8 +38,13 @@ const config_Basic = (env, argv) => {
|
|
|
38
38
|
rules: [{
|
|
39
39
|
test: /\.tsx?$/,
|
|
40
40
|
use: [{
|
|
41
|
-
loader: '
|
|
42
|
-
options: {
|
|
41
|
+
loader: 'swc-loader',
|
|
42
|
+
options: {
|
|
43
|
+
jsc: {
|
|
44
|
+
parser: { syntax: 'typescript' },
|
|
45
|
+
target: 'esnext'
|
|
46
|
+
}
|
|
47
|
+
}
|
|
43
48
|
}],
|
|
44
49
|
exclude: /node_modules/,
|
|
45
50
|
sideEffects: false
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @internal
|
|
3
|
-
*
|
|
4
|
-
* Returns the predecessor `CpNode` in the `CpTree` or the same one if they fall
|
|
5
|
-
* on top of each other.
|
|
6
|
-
*
|
|
7
|
-
* * returns `undefined` if the tree is still empty
|
|
8
|
-
*
|
|
9
|
-
* @param cpTree
|
|
10
|
-
* @param pos
|
|
11
|
-
* @param order
|
|
12
|
-
* @param order2
|
|
13
|
-
*/
|
|
14
|
-
function getCpNodeToLeftOrSame(cpTree, pos, order, order2) {
|
|
15
|
-
const pointOnShape = { ...pos, order, order2 };
|
|
16
|
-
const cps = cpTree.findBounds({ pointOnShape });
|
|
17
|
-
if (cps[0] === undefined && cps[1] === undefined) {
|
|
18
|
-
// The tree is still empty
|
|
19
|
-
return undefined;
|
|
20
|
-
}
|
|
21
|
-
if (cps[0] === undefined || cps[1] === undefined) {
|
|
22
|
-
// Smaller than all -> cptree.min() === cps[1].data OR
|
|
23
|
-
// Larger than all -> cptree.max() === cps[0].data
|
|
24
|
-
// return cpTree.max(cpTree.root);
|
|
25
|
-
return cpTree.getMaxNode()?.datum;
|
|
26
|
-
}
|
|
27
|
-
return cps[0].datum;
|
|
28
|
-
}
|
|
29
|
-
export { getCpNodeToLeftOrSame };
|
|
30
|
-
//# sourceMappingURL=get-cp-node-to-left-or-same.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"get-cp-node-to-left-or-same.js","sourceRoot":"","sources":["../../src/mat/get-cp-node-to-left-or-same.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;;;GAYG;AACH,SAAS,qBAAqB,CACtB,MAAsB,EACtB,GAAoB,EACpB,KAAa,EACb,MAAc;IAElB,MAAM,YAAY,GAAG,EAAE,GAAG,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;IAC/C,MAAM,GAAG,GAAG,MAAM,CAAC,UAAU,CAAC,EAAE,YAAY,EAAY,CAAC,CAAC;IAE1D,IAAI,GAAG,CAAC,CAAC,CAAC,KAAK,SAAS,IAAI,GAAG,CAAC,CAAC,CAAC,KAAK,SAAS,EAAE,CAAC;QAC/C,0BAA0B;QAC1B,OAAO,SAAS,CAAC;IACrB,CAAC;IAED,IAAI,GAAG,CAAC,CAAC,CAAC,KAAK,SAAS,IAAI,GAAG,CAAC,CAAC,CAAC,KAAK,SAAS,EAAE,CAAC;QAC/C,sDAAsD;QACtD,mDAAmD;QACnD,kCAAkC;QAClC,OAAO,MAAM,CAAC,UAAU,EAAE,EAAE,KAAK,CAAC;IACtC,CAAC;IAED,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;AACxB,CAAC;AAGD,OAAO,EAAE,qBAAqB,EAAE,CAAA"}
|