flo-mat 3.0.12 → 3.0.13

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 (122) hide show
  1. package/browser/index.js +174 -40
  2. package/browser/index.min.js +1 -1
  3. package/node/cp-node/cp-node-fs.d.ts +4 -4
  4. package/node/cp-node/cp-node-fs.js +4 -4
  5. package/node/cp-node/cp-node.d.ts +8 -10
  6. package/node/cp-node/fs/cp-node-comparator.d.ts +6 -0
  7. package/node/cp-node/fs/cp-node-comparator.js +6 -0
  8. package/node/cp-node/fs/cp-node-comparator.js.map +1 -1
  9. package/node/cp-node/fs/enhance-cp-node.d.ts +5 -2
  10. package/node/cp-node/fs/enhance-cp-node.js +4 -0
  11. package/node/cp-node/fs/enhance-cp-node.js.map +1 -1
  12. package/node/cp-node/fs/get-all-on-circle.d.ts +4 -4
  13. package/node/cp-node/fs/get-all-on-circle.js +4 -4
  14. package/node/cp-node/fs/get-all-on-loop.d.ts +4 -0
  15. package/node/cp-node/fs/get-all-on-loop.js +4 -0
  16. package/node/cp-node/fs/get-all-on-loop.js.map +1 -1
  17. package/node/cp-node/fs/get-boundary-bezier-parts-to-next.d.ts +5 -4
  18. package/node/cp-node/fs/get-boundary-bezier-parts-to-next.js +5 -4
  19. package/node/cp-node/fs/get-boundary-bezier-parts-to-next.js.map +1 -1
  20. package/node/cp-node/fs/get-boundary-beziers-to-next.d.ts +4 -8
  21. package/node/cp-node/fs/get-boundary-beziers-to-next.js +4 -8
  22. package/node/cp-node/fs/get-boundary-beziers-to-next.js.map +1 -1
  23. package/node/cp-node/fs/get-children.d.ts +6 -0
  24. package/node/cp-node/fs/get-children.js +6 -0
  25. package/node/cp-node/fs/get-children.js.map +1 -1
  26. package/node/cp-node/fs/get-edge-direction.d.ts +6 -0
  27. package/node/cp-node/fs/get-edge-direction.js +6 -0
  28. package/node/cp-node/fs/get-edge-direction.js.map +1 -1
  29. package/node/cp-node/fs/get-first-exit.d.ts +4 -0
  30. package/node/cp-node/fs/get-first-exit.js +4 -0
  31. package/node/cp-node/fs/get-first-exit.js.map +1 -1
  32. package/node/cp-node/fs/get-mat-curve-between.d.ts +6 -0
  33. package/node/cp-node/fs/get-mat-curve-between.js +6 -0
  34. package/node/cp-node/fs/get-mat-curve-between.js.map +1 -1
  35. package/node/cp-node/fs/get-mat-curve-to-next.d.ts +6 -0
  36. package/node/cp-node/fs/get-mat-curve-to-next.js +6 -0
  37. package/node/cp-node/fs/get-mat-curve-to-next.js.map +1 -1
  38. package/node/cp-node/fs/get-prong-count.d.ts +8 -0
  39. package/node/cp-node/fs/get-prong-count.js +8 -0
  40. package/node/cp-node/fs/get-prong-count.js.map +1 -1
  41. package/node/cp-node/fs/get-real-prong-count.d.ts +6 -0
  42. package/node/cp-node/fs/get-real-prong-count.js +6 -0
  43. package/node/cp-node/fs/get-real-prong-count.js.map +1 -1
  44. package/node/cp-node/fs/get-vertex-forward-children.d.ts +8 -0
  45. package/node/cp-node/fs/get-vertex-forward-children.js +8 -0
  46. package/node/cp-node/fs/get-vertex-forward-children.js.map +1 -1
  47. package/node/cp-node/fs/is-fully-terminating.d.ts +2 -5
  48. package/node/cp-node/fs/is-fully-terminating.js +2 -5
  49. package/node/cp-node/fs/is-fully-terminating.js.map +1 -1
  50. package/node/cp-node/fs/is-on-same-circle.d.ts +6 -0
  51. package/node/cp-node/fs/is-on-same-circle.js +6 -0
  52. package/node/cp-node/fs/is-on-same-circle.js.map +1 -1
  53. package/node/cp-node/fs/is-one-prong.d.ts +8 -0
  54. package/node/cp-node/fs/is-one-prong.js +8 -0
  55. package/node/cp-node/fs/is-one-prong.js.map +1 -1
  56. package/node/cp-node/fs/is-order-correct.d.ts +1 -1
  57. package/node/cp-node/fs/is-order-correct.js +1 -4
  58. package/node/cp-node/fs/is-order-correct.js.map +1 -1
  59. package/node/cp-node/fs/is-sharp.d.ts +7 -0
  60. package/node/cp-node/fs/is-sharp.js +7 -0
  61. package/node/cp-node/fs/is-sharp.js.map +1 -1
  62. package/node/cp-node/fs/is-special.d.ts +1 -1
  63. package/node/cp-node/fs/is-special.js +1 -3
  64. package/node/cp-node/fs/is-special.js.map +1 -1
  65. package/node/cp-node/fs/is-terminating.d.ts +22 -0
  66. package/node/cp-node/fs/is-terminating.js +22 -0
  67. package/node/cp-node/fs/is-terminating.js.map +1 -1
  68. package/node/cp-node/fs/traverse-cp.d.ts +9 -0
  69. package/node/cp-node/fs/traverse-cp.js +9 -0
  70. package/node/cp-node/fs/traverse-cp.js.map +1 -1
  71. package/node/cp-node/fs/traverse-edges.d.ts +7 -0
  72. package/node/cp-node/fs/traverse-edges.js +7 -0
  73. package/node/cp-node/fs/traverse-edges.js.map +1 -1
  74. package/node/cp-node/fs/traverse-vertices.d.ts +9 -0
  75. package/node/cp-node/fs/traverse-vertices.js +9 -0
  76. package/node/cp-node/fs/traverse-vertices.js.map +1 -1
  77. package/node/find-2-prong/add-2-prong.js +5 -3
  78. package/node/find-2-prong/add-2-prong.js.map +1 -1
  79. package/node/floyd-warshall/get-graph.d.ts +1 -1
  80. package/node/floyd-warshall/get-graph.js +2 -2
  81. package/node/floyd-warshall/get-graph.js.map +1 -1
  82. package/node/floyd-warshall/get-hole-closer-pairs.d.ts +6 -1
  83. package/node/floyd-warshall/get-hole-closer-pairs.js +8 -0
  84. package/node/floyd-warshall/get-hole-closer-pairs.js.map +1 -1
  85. package/node/mat/add-to-cp-tree.js +1 -3
  86. package/node/mat/add-to-cp-tree.js.map +1 -1
  87. package/node/vertex/remove-vertex.d.ts +5 -0
  88. package/node/vertex/remove-vertex.js +5 -0
  89. package/node/vertex/remove-vertex.js.map +1 -1
  90. package/package.json +1 -1
  91. package/src/cp-node/cp-node-fs.ts +4 -4
  92. package/src/cp-node/cp-node.ts +8 -10
  93. package/src/cp-node/fs/cp-node-comparator.ts +6 -0
  94. package/src/cp-node/fs/enhance-cp-node.ts +4 -0
  95. package/src/cp-node/fs/get-all-on-circle.ts +4 -4
  96. package/src/cp-node/fs/get-all-on-loop.ts +4 -0
  97. package/src/cp-node/fs/get-boundary-bezier-parts-to-next.ts +6 -5
  98. package/src/cp-node/fs/get-boundary-beziers-to-next.ts +4 -8
  99. package/src/cp-node/fs/get-children.ts +6 -0
  100. package/src/cp-node/fs/get-edge-direction.ts +6 -0
  101. package/src/cp-node/fs/get-first-exit.ts +4 -0
  102. package/src/cp-node/fs/get-mat-curve-between.ts +6 -0
  103. package/src/cp-node/fs/get-mat-curve-to-next.ts +6 -0
  104. package/src/cp-node/fs/get-prong-count.ts +8 -0
  105. package/src/cp-node/fs/get-real-prong-count.ts +6 -0
  106. package/src/cp-node/fs/get-vertex-forward-children.ts +8 -0
  107. package/src/cp-node/fs/is-fully-terminating.ts +2 -5
  108. package/src/cp-node/fs/is-on-same-circle.ts +6 -0
  109. package/src/cp-node/fs/is-one-prong.ts +8 -0
  110. package/src/cp-node/fs/is-order-correct.ts +1 -4
  111. package/src/cp-node/fs/is-sharp.ts +7 -0
  112. package/src/cp-node/fs/is-special.ts +2 -3
  113. package/src/cp-node/fs/is-terminating.ts +22 -0
  114. package/src/cp-node/fs/traverse-cp.ts +9 -0
  115. package/src/cp-node/fs/traverse-edges.ts +7 -0
  116. package/src/cp-node/fs/traverse-vertices.ts +9 -0
  117. package/src/find-2-prong/add-2-prong.ts +4 -1
  118. package/src/floyd-warshall/get-graph.ts +3 -3
  119. package/src/floyd-warshall/get-hole-closer-pairs.ts +9 -1
  120. package/src/mat/add-to-cp-tree.ts +1 -2
  121. package/src/vertex/remove-vertex.ts +5 -0
  122. package/src/cp-node/fs/create-cp-node.ts +0 -21
package/browser/index.js CHANGED
@@ -893,6 +893,10 @@ function floydWarshall(graph) {
893
893
  // floydWarshall(graph);//?
894
894
 
895
895
  ;// ./src/cp-node/fs/get-all-on-loop.ts
896
+ /**
897
+ * Returns all `CpNode`s on the MAT that this `CpNode` is part of
898
+ * starting from the current one and going anti-clockwise around the shape.
899
+ */
896
900
  function getAllOnLoop(cpNode) {
897
901
  const cpStart = cpNode;
898
902
  const cpNodes = [cpStart];
@@ -6246,6 +6250,12 @@ const isPosSharpCorner = memoize((pos) => {
6246
6250
 
6247
6251
 
6248
6252
 
6253
+ /**
6254
+ * @internal
6255
+ * Returns a line segment of unit length starting in the given Vertex center and
6256
+ * pointing in the direction of the medial axis (viewed as a rooted tree).
6257
+ * @param cpNode
6258
+ */
6249
6259
  function getEdgeDirection(cpNode) {
6250
6260
  const circleCenter = cpNode.cp.circle.center;
6251
6261
  const cp1 = cpNode;
@@ -6296,6 +6306,12 @@ function getEdgeDirection(cpNode) {
6296
6306
  const TOLERANCE_ADD_2PRONG = 0.01;
6297
6307
  /** @internal */
6298
6308
  const TOLERANCE_USE_LINE = 0.0001; // else cubic
6309
+ /**
6310
+ * Returns the bezier curve from the maximal disk of one `CpNode` to another
6311
+ * `CpNode`'s maximal disk.
6312
+ * @param cpNodeFrom
6313
+ * @param cpNodeTo
6314
+ */
6299
6315
  function getMatCurveBetween(cpNodeFrom, cpNodeTo) {
6300
6316
  const fromCc = cpNodeFrom.cp.circle.center;
6301
6317
  const fromL = getEdgeDirection(cpNodeFrom);
@@ -6344,6 +6360,12 @@ function getMatCurveBetween(cpNodeFrom, cpNodeTo) {
6344
6360
  ;// ./src/cp-node/fs/get-mat-curve-to-next.ts
6345
6361
 
6346
6362
 
6363
+ /**
6364
+ * Returns the bezier curve from the maximal disk of the given `CpNode` to the
6365
+ * next `CpNode`'s maximal disk and thus directly represents a piece of the
6366
+ * medial axis.
6367
+ * @param cpNode
6368
+ */
6347
6369
  function getMatCurveToNext(cpNode) {
6348
6370
  return getMatCurveBetween(cpNode, cpNode.next);
6349
6371
  }
@@ -6352,10 +6374,10 @@ const getMatCurveToNext$ = memoize(getMatCurveToNext);
6352
6374
 
6353
6375
  ;// ./src/cp-node/fs/get-all-on-circle.ts
6354
6376
  /**
6355
- * Returns all the `CpNode`s on the same circle.
6356
- *
6357
- * @param cpNode
6358
- * @param exclThis
6377
+ * Return this (except if exclThis is truthy) and the the other CpNodes
6378
+ * around the maximal disk vertex circle in an anti-clockwise order.
6379
+ * @param exclThis If true the returned array does not include this
6380
+ * `CpNode`.
6359
6381
  */
6360
6382
  function getAllOnCircle(cpNode, exclThis = false) {
6361
6383
  const startCpNode = cpNode;
@@ -6370,6 +6392,28 @@ function getAllOnCircle(cpNode, exclThis = false) {
6370
6392
 
6371
6393
 
6372
6394
  ;// ./src/cp-node/fs/is-terminating.ts
6395
+ /**
6396
+ * Returns `true` if this `CpNode` is terminating, i.e. implies a leaf MAT
6397
+ * vertex.
6398
+ *
6399
+ * The following are some instances where this is the case:
6400
+ *
6401
+ * * Sharp corners.
6402
+ *
6403
+ * * Half of Hole-closers, i.e. `CpNode`s whose next `CpNode` is on a different
6404
+ * loop
6405
+ *
6406
+ * * Maximal disks with a single contact point.
6407
+ * Note, however, that even in these cases there are two contact points stored
6408
+ * (sitting 'on top' of each other) for the maximal disk. It can be seen as a
6409
+ * limiting case of a two-prong where the distance between two of the contact
6410
+ * points tend to zero. One point (represented by a `CpNode` of course) will
6411
+ * be terminating with the other point being its `next`, whereas the other
6412
+ * point will *not* be terminating and 'points' back into the shape.
6413
+ *
6414
+ * * Some 3-prongs may also become terminating if the Scale Axis Transform is
6415
+ * applied to the shape.
6416
+ */
6373
6417
  function isTerminating(cpNode) {
6374
6418
  return cpNode === cpNode.next.prevOnCircle;
6375
6419
  }
@@ -6378,6 +6422,12 @@ function isTerminating(cpNode) {
6378
6422
  ;// ./src/cp-node/fs/get-real-prong-count.ts
6379
6423
 
6380
6424
 
6425
+ /**
6426
+ * Returns the number of contact points (up to planar coordinates) on the
6427
+ * maximal disk circle implied by this `CpNode`.
6428
+ *
6429
+ * See also `getProngCount`.
6430
+ */
6381
6431
  function getRealProngCount(cpNode) {
6382
6432
  const nonTerminatingCpNodes = getAllOnCircle(cpNode)
6383
6433
  .filter(cpNode => !isTerminating(cpNode));
@@ -6467,11 +6517,8 @@ function memoizePrimitive(f) {
6467
6517
 
6468
6518
 
6469
6519
  /**
6470
- * Returns `true` if this `CpNode` is fully terminating, meaning that all
6471
- * `CpNode`s (except `CpNode.prevOnCircle`) on the same circle are terminating,
6472
- * `false` otherwise.
6473
- *
6474
- * @param cpNode
6520
+ * Like isTerminating() but only returns true if all cpNodes on the circle
6521
+ * (except this.prevOnCircle) is terminating.
6475
6522
  */
6476
6523
  function isFullyTerminating(cpNode) {
6477
6524
  const otherOnCircle = getAllOnCircle(cpNode.prevOnCircle, true);
@@ -6573,6 +6620,14 @@ function getCpNodeOrdering(cpNode) {
6573
6620
 
6574
6621
 
6575
6622
  ;// ./src/cp-node/fs/get-prong-count.ts
6623
+ /**
6624
+ * Returns the number of contact points on the maximal disk circle implied
6625
+ * by this `CpNode`.
6626
+ *
6627
+ * Note, however, that even one-prongs and sharp corners will return 2 (see
6628
+ * `isTerminating` for more details); if this is not desired use
6629
+ * `getRealProngCount` instead which will return 1 in these cases.
6630
+ */
6576
6631
  function getProngCount(cpNode) {
6577
6632
  const startCpNode = cpNode;
6578
6633
  let cpNode_ = startCpNode;
@@ -6586,6 +6641,13 @@ function getProngCount(cpNode) {
6586
6641
 
6587
6642
 
6588
6643
  ;// ./src/cp-node/fs/is-sharp.ts
6644
+ /**
6645
+ * Returns true if this `CpNode` represents a sharp corner, i.e. the
6646
+ * limiting case of a two-prong having zero radius.
6647
+ *
6648
+ * Note that two `CpNode`s are stored for each sharp corner, one being
6649
+ * terminating and one not. See `isTerminating` for more details.
6650
+ */
6589
6651
  function isSharp(cpNode) {
6590
6652
  return cpNode.cp.circle.radius === 0;
6591
6653
  }
@@ -6598,6 +6660,10 @@ function isSharp(cpNode) {
6598
6660
 
6599
6661
 
6600
6662
 
6663
+ /**
6664
+ * For debugging
6665
+ * @param cpNode
6666
+ */
6601
6667
  function enhanceCpNode(cpNode) {
6602
6668
  const cp = cpNode.cp;
6603
6669
  const pos = cp.pointOnShape;
@@ -6621,6 +6687,15 @@ function enhanceCpNode(cpNode) {
6621
6687
 
6622
6688
  ;// ./src/cp-node/fs/traverse-cp.ts
6623
6689
 
6690
+ /**
6691
+ * @internal
6692
+ *
6693
+ * Traverses the shape from the given `CpNode` going around the shortest path
6694
+ * so that only a piece of the shape is traversed and returns the visited
6695
+ * `CpNode`s (starting from the given `CpNode`).
6696
+ *
6697
+ * @param cpStart The `CpNode` from where to start the traversal.
6698
+ */
6624
6699
  function traverseCp(cpStart) {
6625
6700
  let cpNode = cpStart;
6626
6701
  if (isTerminating(cpNode)) {
@@ -6641,6 +6716,13 @@ function traverseCp(cpStart) {
6641
6716
  ;// ./src/cp-node/fs/traverse-edges.ts
6642
6717
 
6643
6718
 
6719
+ /**
6720
+ * Traverses all edges (depth first) of the given MAT tree starting at the given
6721
+ * vertex (represented by a `CpNode`).
6722
+ * @param cpNode Any `CpNode` representing the start vertex.
6723
+ * @param traverseEdgesCallback A callback function for each CpNode representing the vertex at the
6724
+ * start of an edge.
6725
+ */
6644
6726
  function traverseEdges(cpNode, traverseEdgesCallback) {
6645
6727
  const cpNodes = getAllOnLoop(cpNode);
6646
6728
  const seen = new Set();
@@ -6655,6 +6737,14 @@ function traverseEdges(cpNode, traverseEdgesCallback) {
6655
6737
 
6656
6738
  ;// ./src/cp-node/fs/get-vertex-forward-children.ts
6657
6739
 
6740
+ /**
6741
+ * Similar to `getChildren` but returns the child nodes of the tree when
6742
+ * `CpNode` is seen as a MAT vertex point (as opposed to edge). In this
6743
+ * way the dual graph of the tree can easily be traversed - see e.g.
6744
+ * `traverseVertices`. Generally, however, traversing the edges is
6745
+ * preferred as it returns the entire Medial Axis (by utilizing
6746
+ * `getMatCurveToNext` on each returned edge).
6747
+ */
6658
6748
  function getVertexForwardChildren(cpNode) {
6659
6749
  const children = [];
6660
6750
  const cpStart = cpNode;
@@ -6673,6 +6763,15 @@ function getVertexForwardChildren(cpNode) {
6673
6763
 
6674
6764
 
6675
6765
 
6766
+ /**
6767
+ * Traverses the MAT tree and calls the given callback function for each vertex
6768
+ * (represented by a `CpNode`) on the MAT.
6769
+ *
6770
+ * It is usually preferable to use `traverseEdges` as it allows for the
6771
+ * traversal of all the smooth curves representing the MAT.
6772
+ * @param cpNode Any `CpNode` representing the start vertex.
6773
+ * @param traverseVerticesCallback A callback function taking a single `CpNode` as parameter.
6774
+ */
6676
6775
  function traverseVertices(cpStart, traverseVerticesCallback) {
6677
6776
  traverseVerticesCallback(cpStart);
6678
6777
  // Since the tree is unrooted we must iterate in all directions from the
@@ -6737,11 +6836,12 @@ function cloneWithoutLinks(cpNode) {
6737
6836
 
6738
6837
  ;// ./src/cp-node/fs/get-boundary-bezier-parts-to-next.ts
6739
6838
  /**
6740
- * Returns the boundary beziers pieces between this `CpNode` and the next
6741
- * one.
6839
+ * Returns the ordered `BezierPiece`s from this `CpNode` to the next `CpNode`
6840
+ * on the boundary.
6742
6841
  *
6743
- * * returns `undefined` if the next `CpNode` is on a different loop,
6744
- * as this is a hole-closer and there are no boundary beziers between them.
6842
+ * * returns `[]` if (and only if) the next `CpNode` is on a different loop;
6843
+ * this differs from "returns `[]` if (and only if) the next `CpNode` is a
6844
+ * hole-closer" as half of hole-closers are on the same loop.
6745
6845
  *
6746
6846
  * @param cpNode
6747
6847
  */
@@ -6788,14 +6888,10 @@ function addSkippedBezierPiecess(bezierPieces, curveStart, curveEnd, t1) {
6788
6888
 
6789
6889
 
6790
6890
  /**
6791
- // * Returns the boundary beziers between this `CpNode` and the next
6792
- // * one.
6793
- // *
6794
- // * * returns `[]` if the next `CpNode` is on a different loop,
6795
- // * as this is a hole-closer and there are no boundary beziers between them.
6796
- // *
6797
- // * @param cpNode
6798
- // */
6891
+ * Returns the ordered bezier curves from this `CpNode` to the next `CpNode`
6892
+ * on the boundary.
6893
+ * @param cpNode
6894
+ */
6799
6895
  function getBoundaryBeziersToNext(cpNode) {
6800
6896
  return getBoundaryBezierPartsToNext(cpNode).map(bp => fromTo(bp.ps, bp.ts[0], bp.ts[1]));
6801
6897
  }
@@ -6877,6 +6973,11 @@ function removeCpNode(cpNode, meta) {
6877
6973
 
6878
6974
 
6879
6975
 
6976
+ /**
6977
+ * Removes a cpNode from the MAT.
6978
+ * @param cpTree The tree graph holding the `CpNodes` of the MAT.
6979
+ * @param cpNode The `CpNode` to remove.
6980
+ */
6880
6981
  function removeVertex(cpNode, meta) {
6881
6982
  // cpTrees: Map<Loop, LlRbTree<CpNode>>): void {
6882
6983
  const prongCount = getProngCount(cpNode);
@@ -6888,6 +6989,12 @@ function removeVertex(cpNode, meta) {
6888
6989
 
6889
6990
 
6890
6991
  ;// ./src/cp-node/fs/get-children.ts
6992
+ /**
6993
+ * Returns the children of this `CpNode` when seen as a MAT edge. Only
6994
+ * children in a 'forward' direction are returned. These include all edges
6995
+ * except the 'backward' edge given by `prevOnCircle`, even terminating
6996
+ * edges.
6997
+ */
6891
6998
  function getChildren(cpNode) {
6892
6999
  const children = [];
6893
7000
  const cp = cpNode.next;
@@ -6901,6 +7008,10 @@ function getChildren(cpNode) {
6901
7008
 
6902
7009
 
6903
7010
  ;// ./src/cp-node/fs/get-first-exit.ts
7011
+ /**
7012
+ * Returns the first `CpNode` (from this one by successively applying
7013
+ * .nextOnCircle) that exits the circle.
7014
+ */
6904
7015
  function getFirstExit(cpNode) {
6905
7016
  // const startNode = this as CpNode;
6906
7017
  const startNode = cpNode;
@@ -6918,6 +7029,12 @@ function getFirstExit(cpNode) {
6918
7029
 
6919
7030
  ;// ./src/cp-node/fs/is-on-same-circle.ts
6920
7031
 
7032
+ /**
7033
+ * Returns true if the 2 given `CpNode`s are on the same maximal disk
7034
+ * circle.
7035
+ * @param cpNode1 A `CpNode`.
7036
+ * @param cpNode2 Another `CpNode`
7037
+ */
6921
7038
  function isOnSameCircle(cpNode1, cpNode2) {
6922
7039
  // const cpNodes = getAllOnCircle(cpNode1, true);
6923
7040
  const cpNodes = getAllOnCircle(cpNode1);
@@ -6926,6 +7043,14 @@ function isOnSameCircle(cpNode1, cpNode2) {
6926
7043
 
6927
7044
 
6928
7045
  ;// ./src/cp-node/fs/is-one-prong.ts
7046
+ /**
7047
+ * Returns true if this `CpNode`'s maximal disk has only one contact point
7048
+ * on the shape boundary (up to planar coordinates). These includes sharp
7049
+ * corners.
7050
+ *
7051
+ * Note, however, that two `CpNode`s are stored for each such point to
7052
+ * preserve symmetry - see `isTerminating` for more details.
7053
+ */
6929
7054
  // TODO2 - remove - or replace with `getRealProngCount === 1`
6930
7055
  function isOneProng(cpNode) {
6931
7056
  const cp1 = cpNode;
@@ -7176,6 +7301,12 @@ function compareCps(a, b) {
7176
7301
 
7177
7302
  ;// ./src/cp-node/fs/cp-node-comparator.ts
7178
7303
 
7304
+ /**
7305
+ * Primarily for internal use.
7306
+ *
7307
+ * Compares the order of two `CpNode`s. The order is cyclic and depends
7308
+ * on a `CpNode`'s relative position along the shape boundary.
7309
+ */
7179
7310
  function cpNodeComparator(a, b) {
7180
7311
  return compareCps(a.cp, b.cp);
7181
7312
  }
@@ -7357,20 +7488,20 @@ const CpNodeFs = {
7357
7488
  */
7358
7489
  clone: clone,
7359
7490
  /**
7360
- * Returns the ordered bezier curves from this CpNode to the next CpNode
7491
+ * Returns the ordered bezier curves from this `CpNode` to the next `CpNode`
7361
7492
  * on the boundary.
7362
7493
  * @param cpNode
7363
7494
  */
7364
7495
  getBoundaryBezierPartsToNext: getBoundaryBezierPartsToNext,
7365
7496
  /**
7366
- * Returns the ordered bezier curves from this CpNode to the next CpNode
7497
+ * Returns the ordered bezier curves from this `CpNode` to the next `CpNode`
7367
7498
  * on the boundary.
7368
7499
  * @param cpNode
7369
7500
  */
7370
7501
  getBoundaryBeziersToNext: getBoundaryBeziersToNext,
7371
7502
  /**
7372
- * Removes a cpNode from the MAT.
7373
- * @param cpTree The tree graph holding the `CpNodes` of the MAT.
7503
+ * Removes a `CpNode` from the MAT.
7504
+ * @param cpTree The tree graph holding the `CpNode`s of the MAT.
7374
7505
  * @param cpNode The `CpNode` to remove.
7375
7506
  */
7376
7507
  removeVertex: removeVertex,
@@ -7413,9 +7544,7 @@ const CpNodeFs = {
7413
7544
 
7414
7545
  function isSpecial(cpNode) {
7415
7546
  return ((getRealProngCount(cpNode) !== 2) &&
7416
- !cpNode.isHoleClosing /* && cpNode.cp.circle.radius !== 0*/
7417
- // !cpNode.isHoleClosing && cpNode.cp.circle.radius !== 0 // TODO2
7418
- );
7547
+ !cpNode.isHoleClosing);
7419
7548
  }
7420
7549
 
7421
7550
 
@@ -26874,10 +27003,7 @@ function getCpNodeToLeftOrSame(cpTree, pos, order, order2) {
26874
27003
 
26875
27004
  ;// ./src/cp-node/fs/is-order-correct.ts
26876
27005
 
26877
- function isOrderCorrect(
26878
- // isHoleClosing: boolean,
26879
- cpTree, cp, next) {
26880
- // if (isHoleClosing) { return true; }
27006
+ function isOrderCorrect(cpTree, cp, next) {
26881
27007
  // TODO2
26882
27008
  const c = compareCps(cp, next.cp);
26883
27009
  if (c < 0) {
@@ -26969,9 +27095,7 @@ function byAngle(circle) {
26969
27095
  *
26970
27096
  * @internal
26971
27097
  */
26972
- function addToCpTree(insertIfOrderIsWrong, isHoleClosing, circle, orders,
26973
- // cpTrees: Map<Loop,LlRbTree<CpNode>>,
26974
- meta, poss, neighbors) {
27098
+ function addToCpTree(insertIfOrderIsWrong, isHoleClosing, circle, orders, meta, poss, neighbors) {
26975
27099
  const { cpTrees } = meta;
26976
27100
  let anyFailed = false;
26977
27101
  const cpNodes = poss.map((pos, i) => {
@@ -28301,16 +28425,18 @@ function add2Prong(meta, circle, poss, isHoleClosing) {
28301
28425
  }
28302
28426
  return cpNodes[0]; // return the source `CpNode`
28303
28427
  }
28304
- function closeHole(meta,
28305
- // cpTrees: Map<Loop, LlRbTree<CpNode>>,
28306
- cpNodes) {
28428
+ function closeHole(meta, cpNodes) {
28307
28429
  const { cpTrees } = meta;
28308
28430
  const [cpNodeA, cpNodeB] = cpNodes;
28309
28431
  // Duplicate ContactPoints
28310
28432
  // const antipodeCpNode = cpNodeB[0];
28311
28433
  const cpAntipode = cpNodeB.cp;
28312
28434
  const cpNodeB2 = insertCpNode(true, true, false, cpTrees.get(cpAntipode.pointOnShape.curve.loop), { ...cpAntipode, order2: +1 }, cpNodeB, meta.lastInsertId);
28435
+ cpNodeB2.holeCloserTwin = cpNodeB;
28436
+ cpNodeB.holeCloserTwin = cpNodeB2;
28313
28437
  const cpNodeB1 = insertCpNode(true, true, false, cpTrees.get(cpNodeA.cp.pointOnShape.curve.loop), { ...cpNodeA.cp, order2: -1 }, cpNodeA.prev, meta.lastInsertId);
28438
+ cpNodeB1.holeCloserTwin = cpNodeA;
28439
+ cpNodeA.holeCloserTwin = cpNodeB1;
28314
28440
  // Connect graph
28315
28441
  cpNodeB1.prevOnCircle = cpNodeB2;
28316
28442
  cpNodeB1.nextOnCircle = cpNodeB2;
@@ -30637,6 +30763,14 @@ const getMatDistanceToNext$ = memoize(getMatDistanceToNext);
30637
30763
 
30638
30764
 
30639
30765
  ;// ./src/floyd-warshall/get-hole-closer-pairs.ts
30766
+ /**
30767
+ *
30768
+ * @param holeClosers
30769
+ * @returns
30770
+ */
30771
+ // TODO - this function is currently O(n^2) but could be made O(n).
30772
+ // TODO - only `pointOnShape.p` is checked but `pointOnShape.t` should also be checked
30773
+ // or better yet, `CpNode.cp.order` and `CpNode.cp.order2`, etc.
30640
30774
  function getHoleCloserPairs(holeClosers) {
30641
30775
  const pairs = new Map();
30642
30776
  for (let hcA of holeClosers) {
@@ -30685,7 +30819,7 @@ function getGraph(specialVertices, holeClosers) {
30685
30819
  }
30686
30820
  if (child.isHoleClosing) {
30687
30821
  // Hole closer found - don't go around loop
30688
- child = holeCloserNext(pairs, child);
30822
+ child = getHoleCloserNext(pairs, child);
30689
30823
  continue;
30690
30824
  }
30691
30825
  if (isVertexSpecial(child)) {
@@ -30706,7 +30840,7 @@ function getGraph(specialVertices, holeClosers) {
30706
30840
  }
30707
30841
  return graph;
30708
30842
  }
30709
- function holeCloserNext(pairs, holeCloser) {
30843
+ function getHoleCloserNext(pairs, holeCloser) {
30710
30844
  return pairs.get(holeCloser).next;
30711
30845
  }
30712
30846