flo-mat 4.1.1 → 4.1.2

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 (37) hide show
  1. package/browser/index.js +137 -2
  2. package/browser/index.min.js +1 -1
  3. package/node/cp-node/stringification/cp-node-stringifyable.d.ts +29 -0
  4. package/node/cp-node/stringification/cp-node-stringifyable.js +7 -0
  5. package/node/cp-node/stringification/cp-node-stringifyable.js.map +1 -0
  6. package/node/cp-node/stringification/from-stringifyable.d.ts +4 -0
  7. package/node/cp-node/stringification/from-stringifyable.js +43 -0
  8. package/node/cp-node/stringification/from-stringifyable.js.map +1 -0
  9. package/node/cp-node/stringification/loop-from-stringifyable.d.ts +4 -0
  10. package/node/cp-node/stringification/loop-from-stringifyable.js +7 -0
  11. package/node/cp-node/stringification/loop-from-stringifyable.js.map +1 -0
  12. package/node/cp-node/stringification/loop-stringifyable.d.ts +5 -0
  13. package/node/cp-node/stringification/loop-stringifyable.js +2 -0
  14. package/node/cp-node/stringification/loop-stringifyable.js.map +1 -0
  15. package/node/cp-node/stringification/loop-to-stringifyable.d.ts +4 -0
  16. package/node/cp-node/stringification/loop-to-stringifyable.js +6 -0
  17. package/node/cp-node/stringification/loop-to-stringifyable.js.map +1 -0
  18. package/node/cp-node/stringification/to-stringifyable.d.ts +9 -0
  19. package/node/cp-node/stringification/to-stringifyable.js +46 -0
  20. package/node/cp-node/stringification/to-stringifyable.js.map +1 -0
  21. package/node/index.d.ts +5 -0
  22. package/node/index.js +5 -0
  23. package/node/index.js.map +1 -1
  24. package/node/mat/get-branches.js.map +1 -1
  25. package/node/mat/get-largest-3-prong.d.ts +3 -0
  26. package/node/mat/get-largest-3-prong.js +16 -0
  27. package/node/mat/get-largest-3-prong.js.map +1 -0
  28. package/node/mat/get-largest-vertex.d.ts +0 -1
  29. package/node/mat/get-largest-vertex.js +0 -1
  30. package/node/mat/get-largest-vertex.js.map +1 -1
  31. package/package.json +1 -1
  32. package/src/cp-node/stringification/from-stringifyable.ts +2 -2
  33. package/src/cp-node/stringification/to-stringifyable.ts +2 -2
  34. package/src/index.ts +6 -1
  35. package/src/mat/get-branches.ts +1 -3
  36. package/src/mat/get-largest-3-prong.ts +3 -2
  37. package/src/mat/get-largest-vertex.ts +3 -2
package/browser/index.js CHANGED
@@ -25570,7 +25570,6 @@ function getTotalHausdorffDistance(i, j, branch, hausdorffSpacing) {
25570
25570
 
25571
25571
  ;// ./src/mat/get-largest-vertex.ts
25572
25572
 
25573
- /** @internal */
25574
25573
  function getLargestVertex(cpNode) {
25575
25574
  const cpNodes = getAllOnLoop(cpNode);
25576
25575
  return cpNodes.reduce(function (maxCpNode, cpNode) {
@@ -30251,6 +30250,23 @@ function trimMat(mat) {
30251
30250
  }
30252
30251
 
30253
30252
 
30253
+ ;// ./src/mat/get-largest-3-prong.ts
30254
+
30255
+
30256
+ function getLargest3Prong(cpNode) {
30257
+ const cpNodes = getAllOnLoop(cpNode)
30258
+ .filter(cpNode => getRealProngCount(cpNode) >= 3);
30259
+ if (cpNodes.length === 0) {
30260
+ return undefined;
30261
+ }
30262
+ return cpNodes.reduce(function (maxCpNode, cpNode) {
30263
+ return maxCpNode.pointOnShape.circle.radius >= cpNode.pointOnShape.circle.radius
30264
+ ? maxCpNode
30265
+ : cpNode;
30266
+ }, cpNodes[0]);
30267
+ }
30268
+
30269
+
30254
30270
  ;// ./src/debug/debug.ts
30255
30271
  function enableDebugForMat(debugOn) {
30256
30272
  if (!debugOn) {
@@ -30826,6 +30842,120 @@ function reconstruct_from_mat_getEdgeDirection(cpNode, fromOrTo) {
30826
30842
  }
30827
30843
 
30828
30844
 
30845
+ ;// ./src/cp-node/stringification/loop-to-stringifyable.ts
30846
+ function loopToStringifyable(loop) {
30847
+ const { idx, beziers } = loop;
30848
+ return { idx: idx, beziers };
30849
+ }
30850
+
30851
+
30852
+ ;// ./src/cp-node/stringification/to-stringifyable.ts
30853
+
30854
+ /**
30855
+ * Returns a deep clone of this `CpNode`. Can be used to copy the MAT
30856
+ * since cloning a single `CpNode` necessarily implies cloning all
30857
+ * `CpNode`s on the same MAT tree.
30858
+ */
30859
+ function toStringifyable(cpNode) {
30860
+ const cpNodes_ = [];
30861
+ const loopSet = new Set();
30862
+ //--------------------------------------------------------------------------
30863
+ // Clone `CpNode`s with edges replaced with ids AND
30864
+ // set the `nodeMap` to map original `CpNode`s to their ids.
30865
+ //--------------------------------------------------------------------------
30866
+ const cpStart = cpNode;
30867
+ do {
30868
+ const { id, isHoleClosing, isIntersection, pointOnShape, prev, next, nextOnCircle, prevOnCircle, holeCloserTwin, } = cpNode;
30869
+ const { curve, p, pDd, t, isSource, circle, order, order2 } = pointOnShape;
30870
+ const { idx: curveIdx, loop, ps, prev: prevCurve, next: nextCurve } = curve;
30871
+ if (!loopSet.has(loop)) {
30872
+ loopSet.add(loop);
30873
+ }
30874
+ const posSimplified = {
30875
+ curveIdx, loopIdx: loop.idx, p, t, isSource,
30876
+ circle, order, order2, pDd,
30877
+ };
30878
+ cpNodes_.push({
30879
+ id, isHoleClosing, isIntersection,
30880
+ pointOnShape: posSimplified,
30881
+ prev: prev.id,
30882
+ next: next.id,
30883
+ prevOnCircle: prevOnCircle.id,
30884
+ nextOnCircle: nextOnCircle.id,
30885
+ holeCloserTwin: holeCloserTwin?.id
30886
+ });
30887
+ cpNode = cpNode.next;
30888
+ } while (cpNode !== cpStart);
30889
+ //--------------------------------------------------------------------------
30890
+ const loops = Array.from(loopSet).sort((a, b) => a.idx - b.idx);
30891
+ const loops_ = loops.map(loopToStringifyable);
30892
+ return {
30893
+ cpNodes: cpNodes_,
30894
+ loops: loops_
30895
+ };
30896
+ }
30897
+
30898
+
30899
+ ;// ./src/cp-node/stringification/cp-node-stringifyable.ts
30900
+ const cp_node_stringifyable_EDGES = [
30901
+ 'prev', 'next',
30902
+ 'prevOnCircle', 'nextOnCircle',
30903
+ 'holeCloserTwin'
30904
+ ];
30905
+
30906
+
30907
+ ;// ./src/cp-node/stringification/loop-from-stringifyable.ts
30908
+
30909
+ function loopFromStringifyable(loopStringifyable) {
30910
+ const { idx, beziers } = loopStringifyable;
30911
+ return loopFromBeziers(beziers, idx);
30912
+ }
30913
+
30914
+
30915
+ ;// ./src/cp-node/stringification/from-stringifyable.ts
30916
+
30917
+
30918
+ function fromStringifyable(cpNodesStringifyable) {
30919
+ const { cpNodes: _cpNodes, loops: _loops } = cpNodesStringifyable;
30920
+ const loops = _loops.map(loopFromStringifyable);
30921
+ //--------------------------------------------------------------------------
30922
+ // First pass: build all CpNode objects with proper `cp`.
30923
+ // Edges still hold number ids at this point.
30924
+ //--------------------------------------------------------------------------
30925
+ const cpNodes = _cpNodes.map(cpNode_ => {
30926
+ const { id, pointOnShape, isHoleClosing, isIntersection } = cpNode_;
30927
+ const { circle, order, order2 } = pointOnShape;
30928
+ const { curveIdx, loopIdx, p, pDd, t, isSource } = pointOnShape;
30929
+ const curve = loops[loopIdx].curves[curveIdx];
30930
+ const pointOnShape_ = {
30931
+ circle,
30932
+ curve, p, pDd, t, isSource,
30933
+ order, order2
30934
+ };
30935
+ return {
30936
+ ...cpNode_,
30937
+ id, isHoleClosing, isIntersection,
30938
+ pointOnShape: pointOnShape_
30939
+ };
30940
+ });
30941
+ //--------------------------------------------------------------------------
30942
+ // Second pass: replace number id edges with real CpNode references.
30943
+ //--------------------------------------------------------------------------
30944
+ const nodeMap = new Map(cpNodes.map(n => [n.id, n]));
30945
+ for (const cpNode of cpNodes) {
30946
+ for (const edge of cp_node_stringifyable_EDGES) {
30947
+ const id = cpNode[edge];
30948
+ if (id === undefined) {
30949
+ continue;
30950
+ }
30951
+ // @ts-ignore
30952
+ cpNode[edge] = nodeMap.get(id);
30953
+ }
30954
+ }
30955
+ return cpNodes[0];
30956
+ }
30957
+
30958
+
30829
30959
  ;// ./src/geometry/circle.ts
30830
30960
  /* unused harmony import specifier */ var circle_squaredDistanceBetween;
30831
30961
 
@@ -30877,6 +31007,10 @@ function engulfsCircle(c1, c2) {
30877
31007
 
30878
31008
 
30879
31009
 
31010
+
31011
+
31012
+
31013
+
30880
31014
 
30881
31015
 
30882
31016
 
@@ -30921,4 +31055,5 @@ function engulfsCircle(c1, c2) {
30921
31055
 
30922
31056
 
30923
31057
 
30924
- export { CpNodeFs, beziersToSvgPathStr, clone, cpNodeComparator, createInitialCpTree, enableDebugForMat, enhanceCpNode, find2Prong, findAndAddHoleClosing2Prongs, findMats, floydWarshall, getAllOnCircle, getAllOnLoop, getAllOnLoop_ByLoop, getAllVertices, getBoundaryBezierPartsToNext, getBoundaryBeziersBetween, getBoundaryBeziersToNext, getBoundaryPieceBeziers, getBranch, getBranchBeziers, getBranches, getChildren, getCloseBoundaryPointsCertified, getClosestSquareDistanceToRect, getEdgeDirection, getFirstExit, getFor2ProngsOnLoop, getGraph, getHoleClosers, getImpliedBoundaryBezierBetween, getInitialDegAngleBetweenMatCurves, getMatCurveBetween, getMatCurveToNext, getMatCurvesBetween, getOsculatingCircle, getPartialMeta, getPathsFromStr, getPotentialClosestPointsOnCurveCertified, getProngCount, getRealProngCount, getSalience, getSatCulls, get_shape_bounds_getShapeBounds as getShapeBounds, getSharpCornersOnLoop, getVertexForwardChildren, isFullyTerminating, isOnSameCircle, isOnSameLoop, isOneProng, isSharp, isTerminating, isTrivial, isTwoProng, isVertexSpecial, loopFromBeziers, reconstructFromMats, removeVertex, scaleCircle, simplifyMat, sweep_line_sweepLine as sweepLine, toScaleAxis, traverseCp, traverseEdges, traverseVertices, trimMat };
31058
+
31059
+ export { CpNodeFs, beziersToSvgPathStr, clone, cpNodeComparator, createInitialCpTree, enableDebugForMat, enhanceCpNode, find2Prong, findAndAddHoleClosing2Prongs, findMats, floydWarshall, fromStringifyable, getAllOnCircle, getAllOnLoop, getAllOnLoop_ByLoop, getAllVertices, getBoundaryBezierPartsToNext, getBoundaryBeziersBetween, getBoundaryBeziersToNext, getBoundaryPieceBeziers, getBranch, getBranchBeziers, getBranches, getChildren, getCloseBoundaryPointsCertified, getClosestSquareDistanceToRect, getEdgeDirection, getFirstExit, getFor2ProngsOnLoop, getGraph, getHoleClosers, getImpliedBoundaryBezierBetween, getInitialDegAngleBetweenMatCurves, getLargest3Prong, getLargestVertex, getMatCurveBetween, getMatCurveToNext, getMatCurvesBetween, getNonTerminatingOnCircle, getOsculatingCircle, getPartialMeta, getPathsFromStr, getPotentialClosestPointsOnCurveCertified, getProngCount, getRealProngCount, getSalience, getSatCulls, get_shape_bounds_getShapeBounds as getShapeBounds, getSharpCornersOnLoop, getVertexForwardChildren, isFullyTerminating, isOnSameCircle, isOnSameLoop, isOneProng, isSharp, isTerminating, isTrivial, isTwoProng, isVertexSpecial, loopFromBeziers, reconstructFromMats, removeVertex, scaleCircle, simplifyMat, sweep_line_sweepLine as sweepLine, toScaleAxis, toStringifyable, traverseCp, traverseEdges, traverseVertices, trimMat };