flo-mat 4.1.2 → 4.1.4

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.
Files changed (80) hide show
  1. package/__tests__/find-2-prong/get-medial/dd-get-medial-point-coeffs-same-curve.spec.ts +1 -1
  2. package/__tests__/get-mats1.ts +23 -22
  3. package/__tests__/specific-cases/specific-cases.spec.ts +1 -14
  4. package/__tests__/specific-cases/test-svgs/achispado.svg +37 -24
  5. package/browser/index.js +408 -198
  6. package/browser/index.min.js +1 -1
  7. package/node/cp-node/fs/insert-cp-node.d.ts +12 -1
  8. package/node/cp-node/fs/insert-cp-node.js +21 -6
  9. package/node/cp-node/fs/insert-cp-node.js.map +1 -1
  10. package/node/cp-node/fs/is-order-correct.d.ts +9 -1
  11. package/node/cp-node/fs/is-order-correct.js +51 -10
  12. package/node/cp-node/fs/is-order-correct.js.map +1 -1
  13. package/node/cp-node/fs/remove-cp-node.js +1 -1
  14. package/node/cp-node/fs/remove-cp-node.js.map +1 -1
  15. package/node/cp-node/stringification/from-stringifyable.js +2 -1
  16. package/node/cp-node/stringification/from-stringifyable.js.map +1 -1
  17. package/node/cp-node/stringification/to-stringifyable.js +2 -2
  18. package/node/cp-node/stringification/to-stringifyable.js.map +1 -1
  19. package/node/debug/functions/check-ordering.d.ts +4 -0
  20. package/node/debug/functions/check-ordering.js +43 -0
  21. package/node/debug/functions/check-ordering.js.map +1 -0
  22. package/node/find-2-prong/add-2-prong.js +4 -2
  23. package/node/find-2-prong/add-2-prong.js.map +1 -1
  24. package/node/find-2-prong/find-and-add-2-prongs.js +1 -1
  25. package/node/find-2-prong/find-and-add-2-prongs.js.map +1 -1
  26. package/node/find-2-prong/get-initial-bezier-pieces.js +2 -2
  27. package/node/find-2-prong/get-initial-bezier-pieces.js.map +1 -1
  28. package/node/find-3-prong/find-3-prong-for-delta3s.d.ts +1 -1
  29. package/node/find-3-prong/find-3-prong-for-delta3s.js.map +1 -1
  30. package/node/find-3-prong/find-3-prong.d.ts +1 -1
  31. package/node/find-3-prong/find-3-prong.js.map +1 -1
  32. package/node/find-3-prong/find-and-add-3-prong.js +1 -1
  33. package/node/find-3-prong/find-and-add-3-prong.js.map +1 -1
  34. package/node/find-3-prong/find-and-add-3-prongs-on-loop.d.ts +1 -1
  35. package/node/find-3-prong/find-and-add-3-prongs-on-loop.js +6 -2
  36. package/node/find-3-prong/find-and-add-3-prongs-on-loop.js.map +1 -1
  37. package/node/find-3-prong/three-prong-info.d.ts +1 -1
  38. package/node/find-mat/create-initial-cp-tree.js +2 -2
  39. package/node/find-mat/create-initial-cp-tree.js.map +1 -1
  40. package/node/find-mat/find-mat.js +2 -2
  41. package/node/find-mat/find-mat.js.map +1 -1
  42. package/node/find-mat/get-for-1-prongs-on-loop.js +3 -1
  43. package/node/find-mat/get-for-1-prongs-on-loop.js.map +1 -1
  44. package/node/mat/add-to-cp-tree.d.ts +4 -1
  45. package/node/mat/add-to-cp-tree.js +11 -4
  46. package/node/mat/add-to-cp-tree.js.map +1 -1
  47. package/node/mat/get-boundary-piece-beziers.d.ts +2 -2
  48. package/node/mat/get-boundary-piece-beziers.js +1 -1
  49. package/node/mat/get-boundary-piece-beziers.js.map +1 -1
  50. package/node/mat/get-closeby-cp-if-exist.js +2 -2
  51. package/node/mat/get-closeby-cp-if-exist.js.map +1 -1
  52. package/node/mat/{get-cp-node-to-left-or-same.d.ts → get-cp-node-neighbors.d.ts} +2 -2
  53. package/node/mat/get-cp-node-neighbors.js +31 -0
  54. package/node/mat/get-cp-node-neighbors.js.map +1 -0
  55. package/package.json +11 -11
  56. package/src/cp-node/fs/insert-cp-node.ts +22 -7
  57. package/src/cp-node/fs/is-order-correct copy.ts +60 -0
  58. package/src/cp-node/fs/is-order-correct.ts +61 -13
  59. package/src/cp-node/fs/remove-cp-node.ts +1 -1
  60. package/src/cp-node/stringification/from-stringifyable.ts +2 -1
  61. package/src/cp-node/stringification/to-stringifyable.ts +2 -2
  62. package/src/debug/functions/check-ordering.ts +44 -61
  63. package/src/find-2-prong/add-2-prong.ts +3 -1
  64. package/src/find-2-prong/find-and-add-2-prongs.ts +1 -1
  65. package/src/find-2-prong/get-initial-bezier-pieces.ts +2 -2
  66. package/src/find-3-prong/find-3-prong-for-delta3s.ts +14 -6
  67. package/src/find-3-prong/find-3-prong.ts +1 -1
  68. package/src/find-3-prong/find-and-add-3-prong.ts +1 -4
  69. package/src/find-3-prong/find-and-add-3-prongs-on-loop.ts +6 -3
  70. package/src/find-3-prong/three-prong-info.ts +1 -1
  71. package/src/find-mat/create-initial-cp-tree.ts +2 -2
  72. package/src/find-mat/find-mat.ts +3 -2
  73. package/src/find-mat/get-for-1-prongs-on-loop.ts +3 -1
  74. package/src/mat/add-to-cp-tree copy.ts +71 -0
  75. package/src/mat/add-to-cp-tree.ts +12 -4
  76. package/src/mat/get-boundary-piece-beziers.ts +2 -2
  77. package/src/mat/get-closeby-cp-if-exist.ts +2 -2
  78. package/src/mat/{get-cp-node-to-left-or-same.ts → get-cp-node-neighbors.ts} +12 -10
  79. package/node/mat/get-cp-node-to-left-or-same.js +0 -30
  80. package/node/mat/get-cp-node-to-left-or-same.js.map +0 -1
@@ -2,7 +2,7 @@ import type { Loop } from 'flo-boolean';
2
2
  import type { CurvePiece } from '../mat/curve-piece.js';
3
3
  import type { PrePointOnShape } from '../point-on-shape/point-on-shape.js';
4
4
  import type { MatMeta } from '../mat/mat-meta.js';
5
- import { getCpNodeToLeftOrSame } from '../mat/get-cp-node-to-left-or-same.js';
5
+ import { getCpNodeNeighbors } from '../mat/get-cp-node-neighbors.js';
6
6
  import { getBoundaryPieceBeziers } from '../mat/get-boundary-piece-beziers.js';
7
7
  import { calcPosOrder } from '../point-on-shape/calc-pos-order.js';
8
8
  import { isPosCorner } from '../point-on-shape/is-pos-corner.js';
@@ -38,7 +38,7 @@ function getInitialCurvePieces(
38
38
  : calcPosOrder(xO, yPos)
39
39
  : 0;
40
40
 
41
- const cpNode = getCpNodeToLeftOrSame(cpTrees.get(loop)!, yPos, order, 0);
41
+ const cpNode = getCpNodeNeighbors(cpTrees.get(loop)!, yPos, order, 0)?.[0];
42
42
  if (!cpNode ||
43
43
  // The special case if there is only a single sharp corner or
44
44
  // two-way terminating 2-prong currently in the MAT. Don't remove!
@@ -28,7 +28,7 @@ const { min, abs, asin } = Math;
28
28
  * @internal
29
29
  */
30
30
  function find3ProngForDelta3s(
31
- δs: CpNode[][],
31
+ δs: [CpNode, CpNode][],
32
32
  idx: number,
33
33
  k: number,
34
34
  curvePiecess: CurvePiece[][],
@@ -37,25 +37,33 @@ function find3ProngForDelta3s(
37
37
  const TOLERANCE = 2**(maxCoordPowerOf2 - 32);
38
38
  const MAX_ITERATIONS = 10;
39
39
 
40
- const δs_ = [
40
+ const δs_: [[CpNode,CpNode], [CpNode,CpNode], [CpNode,CpNode]] = [
41
41
  δs[0],
42
42
  δs[idx],
43
43
  δs[δs.length-1]
44
44
  ];
45
45
 
46
- const curvePieces_ = [
46
+ const curvePieces_: [CurvePiece[], CurvePiece[], CurvePiece[]] = [
47
47
  curvePiecess[0],
48
48
  curvePiecess[idx],
49
- curvePiecess[δs.length-1]
49
+ curvePiecess[δs.length - 1]
50
50
  ];
51
51
 
52
- const δ3ss = [
52
+ const δ3ss: [
53
+ [[CpNode, CpNode], [CpNode, CpNode], [CpNode, CpNode]],
54
+ [[CpNode, CpNode], [CpNode, CpNode], [CpNode, CpNode]],
55
+ [[CpNode, CpNode], [CpNode, CpNode], [CpNode, CpNode]]
56
+ ] = [
53
57
  [δs_[0], δs_[1], δs_[2]],
54
58
  [δs_[1], δs_[2], δs_[0]],
55
59
  [δs_[2], δs_[0], δs_[1]],
56
60
  ];
57
61
 
58
- const curvePiecess_ = [
62
+ const curvePiecess_: [
63
+ [CurvePiece[], CurvePiece[], CurvePiece[]],
64
+ [CurvePiece[], CurvePiece[], CurvePiece[]],
65
+ [CurvePiece[], CurvePiece[], CurvePiece[]]
66
+ ] = [
59
67
  [curvePieces_[0], curvePieces_[1], curvePieces_[2]],
60
68
  [curvePieces_[1], curvePieces_[2], curvePieces_[0]],
61
69
  [curvePieces_[2], curvePieces_[0], curvePieces_[1]],
@@ -14,7 +14,7 @@ import { getBoundaryPieceBeziers } from '../mat/get-boundary-piece-beziers.js';
14
14
  * @internal
15
15
  */
16
16
  function find3Prong(
17
- δs: CpNode[][],
17
+ δs: [CpNode, CpNode][],
18
18
  maxCoordPowerOf2: number): ThreeProngInfo {
19
19
 
20
20
  // FUTURE if `δs.length > (some threshold (say 4 or 5))` then add two-prongs
@@ -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 { closeBysFor3Prong, addedCpNodes } =
29
- findAndAdd3Prongs(meta, cpNode);
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;
@@ -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: cpNode!, meta }; }
89
+ if (_debug_.directives.stopAfterThreeProngs) { return { cpNode, meta }; }
89
90
  }
90
91
 
91
- // if (cpNode !== undefined) { checkOrdering(cpTrees, cpNode); }
92
+ // if (cpNode !== undefined) { checkOrdering(meta, cpNode); }
92
93
 
93
94
  const mat = { cpNode, meta };
94
95
 
@@ -34,7 +34,9 @@ function getFor1ProngsOnLoop(
34
34
  }));
35
35
  }
36
36
 
37
- return poss;
37
+ return poss
38
+ // keep away from edges
39
+ .filter(pos => pos.t > 2**-20 && pos.t < 2**-20);
38
40
  }
39
41
  }
40
42
 
@@ -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 { getCpNodeToLeftOrSame } from './get-cp-node-to-left-or-same.js';
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 pred = neighbors === undefined
37
- ? getCpNodeToLeftOrSame(cpTree, ppos, order, 0)
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 from the given boundary piece.
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[]): CurvePiece[] {
16
+ cpNodes: [CpNode,CpNode]): CurvePiece[] {
17
17
 
18
18
  let cpThis = cpNodes[0];
19
19
  const cpEnd = cpNodes[1];
@@ -3,7 +3,7 @@ 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 { getCpNodeToLeftOrSame } from './get-cp-node-to-left-or-same.js';
6
+ import { getCpNodeNeighbors } from './get-cp-node-neighbors.js';
7
7
 
8
8
 
9
9
  /** @internal */
@@ -36,7 +36,7 @@ function getCloseByCpIfExist(
36
36
  const DISTANCE_THRESHOLD_2 = 2**(maxCoordPowerOf2 - 46);
37
37
 
38
38
  const cpTree = cpTrees.get(pos.curve.loop)!;
39
- const cur = getCpNodeToLeftOrSame(cpTree, pos, order, order2);
39
+ const cur = getCpNodeNeighbors(cpTree, pos, order, order2)?.[0];
40
40
  if (!cur) { return undefined; }
41
41
  const cpNodes = [cur, cur.next];
42
42
 
@@ -16,29 +16,31 @@ import { RbTree } from 'flo-ll-rb-tree';
16
16
  * @param order
17
17
  * @param order2
18
18
  */
19
- function getCpNodeToLeftOrSame(
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 (cps[0] === undefined && cps[1] === undefined) {
29
+ if (cp0 === undefined && cp1 === undefined) {
29
30
  // The tree is still empty
30
31
  return undefined;
31
32
  }
32
33
 
33
- if (cps[0] === undefined || cps[1] === undefined) {
34
- // Smaller than all -> cptree.min() === cps[1].data OR
35
- // Larger than all -> cptree.max() === cps[0].data
36
- // return cpTree.max(cpTree.root);
37
- return cpTree.getMaxNode()?.datum;
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 cps[0].datum;
42
+ return [cp0.datum, cp1.datum];
41
43
  }
42
44
 
43
45
 
44
- export { getCpNodeToLeftOrSame }
46
+ export { getCpNodeNeighbors }
@@ -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"}