flo-mat 3.0.13 → 3.0.15
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/check-clone-eql-calc.spec.ts +58 -0
- package/__tests__/cp-node/compare-cp-nodes-by-value.ts +35 -0
- package/__tests__/cp-node/compare-loops-by-value.ts +40 -0
- package/__tests__/cp-node/compare-poss-by-value.ts +25 -0
- package/__tests__/cp-node/fs/clone.spec.ts +19 -3
- package/__tests__/cp-node/fs/find-first.spec.ts +13 -3
- package/__tests__/cp-node/fs/get-all-between.spec.ts +20 -3
- package/__tests__/cp-node/fs/get-all-on-circle.spec.ts +2 -2
- package/__tests__/cp-node/fs/get-all-on-loop.spec.ts +16 -3
- package/__tests__/cp-node/fs/get-all-vertices.spec.ts +14 -3
- package/__tests__/cp-node/fs/get-children.spec.ts +18 -3
- package/__tests__/cp-node/fs/get-non-terminating-on-circle.spec.ts +14 -3
- package/__tests__/cp-node/fs/get-prong-count.spec.ts +16 -3
- package/__tests__/cp-node/fs/get-real-prong-count.spec.ts +11 -3
- package/__tests__/cp-node/fs/get-terminating-on-circle.spec.ts +20 -3
- package/__tests__/cp-node/fs/is-fully-terminating.spec.ts +16 -3
- package/__tests__/cp-node/fs/is-on-same-circle.spec.ts +20 -3
- package/__tests__/cp-node/fs/is-one-prong.spec.ts +16 -3
- package/__tests__/cp-node/fs/is-sharp.spec.ts +10 -3
- package/__tests__/cp-node/fs/is-single-3-prong.spec.ts +13 -3
- package/__tests__/cp-node/fs/is-special.spec.ts +12 -3
- package/__tests__/cp-node/fs/is-terminating.spec.ts +15 -3
- package/__tests__/cp-node/fs/is-trivial.spec.ts +13 -3
- package/__tests__/cp-node/fs/is-two-prong.spec.ts +11 -3
- package/__tests__/cp-node/fs/is-vertex-special.spec.ts +13 -3
- package/__tests__/cp-node/fs/is-vertex.spec.ts +14 -3
- package/__tests__/cp-node/fs/iterate-all-on-loop.spec.ts +13 -3
- package/__tests__/cp-node/fs/traverse-all-forward.spec.ts +10 -3
- package/__tests__/cp-node/fs/traverse-cp.spec.ts +9 -3
- package/__tests__/cp-node/fs/traverse-edges.spec.ts +13 -3
- package/__tests__/cp-node/fs/traverse-vertices.spec.ts +12 -3
- package/__tests__/cp-node/random-walk.ts +33 -0
- package/__tests__/cp-node/stringification/from-stringifyable.spec.ts +3 -0
- package/__tests__/cp-node/stringification/loop-from-stringifyable.spec.ts +4 -0
- package/__tests__/cp-node/stringification/loop-to-stringifyable.spec.ts +19 -0
- package/__tests__/cp-node/stringification/to-stringifyable.spec.ts +34 -0
- package/__tests__/get-mats1.ts +125 -0
- package/__tests__/jsog/check-jsog-eql-calc.spec.ts +47 -67
- package/__tests__/jsog/decode-jsog.ts +88 -85
- package/__tests__/jsog/mat-dummy-1.ts +19 -0
- package/__tests__/jsog/mat-dummys.ts +6197 -6195
- package/__tests__/jsog/to-jsog-breath-first.ts +110 -107
- package/__tests__/jsog/to-jsog-depth-first.ts +58 -55
- package/browser/index.js +7002 -6298
- package/browser/index.min.js +1 -1
- package/jest.config.cjs +1 -0
- package/node/closest-boundary-point/foot-and-endpoint-info.d.ts +1 -1
- package/node/closest-boundary-point/get-close-boundary-points-certified.d.ts +3 -3
- package/node/closest-boundary-point/get-close-boundary-points-certified.js +1 -1
- package/node/closest-boundary-point/get-close-boundary-points-certified.js.map +1 -1
- package/node/closest-boundary-point/get-potential-closest-points-on-curve-certified.d.ts +2 -2
- package/node/closest-boundary-point/get-potential-closest-points-on-curve-certified.js +7 -7
- package/node/closest-boundary-point/get-potential-closest-points-on-curve-certified.js.map +1 -1
- package/node/cp-node/cp-node.d.ts +2 -2
- package/node/cp-node/fs/clone.d.ts +1 -1
- package/node/cp-node/fs/clone.js +17 -13
- package/node/cp-node/fs/clone.js.map +1 -1
- package/node/cp-node/fs/enhance-cp-node.d.ts +2 -2
- package/node/cp-node/fs/find-first.d.ts +9 -2
- package/node/cp-node/fs/find-first.js +12 -9
- package/node/cp-node/fs/find-first.js.map +1 -1
- package/node/cp-node/fs/get-all-on-loop.js +5 -6
- package/node/cp-node/fs/get-all-on-loop.js.map +1 -1
- package/node/cp-node/fs/get-edge-direction.d.ts +1 -1
- package/node/cp-node/fs/get-edge-direction.js.map +1 -1
- package/node/cp-node/fs/is-on-same-circle.d.ts +1 -0
- package/node/cp-node/fs/is-on-same-circle.js +1 -0
- package/node/cp-node/fs/is-on-same-circle.js.map +1 -1
- package/node/debug/functions/draw-elem/draw-dull-corner.d.ts +1 -1
- package/node/debug/functions/draw-elem/draw-dull-corner.js +1 -1
- package/node/debug/functions/draw-elem/draw-dull-corner.js.map +1 -1
- package/node/debug/functions/draw-elem/draw-sharp-corner.d.ts +1 -1
- package/node/debug/functions/draw-elem/draw-sharp-corner.js +2 -1
- package/node/debug/functions/draw-elem/draw-sharp-corner.js.map +1 -1
- package/node/find-mat/find-mats.js +7 -2
- package/node/find-mat/find-mats.js.map +1 -1
- package/node/find-mat/get-meta.d.ts +4 -4
- package/node/find-mat/get-meta.js +1 -1
- package/node/find-mat/get-meta.js.map +1 -1
- package/node/geometry/circle.d.ts +4 -3
- package/node/geometry/circle.js +0 -7
- package/node/geometry/circle.js.map +1 -1
- package/node/index.d.ts +2 -2
- package/node/index.js +1 -0
- package/node/index.js.map +1 -1
- package/node/mat/curve-piece.d.ts +3 -3
- package/node/mat/get-boundary-piece-beziers.d.ts +2 -2
- package/node/mat/mat-meta.d.ts +4 -4
- package/node/mat/simplify-mat.d.ts +10 -8
- package/node/mat/simplify-mat.js +12 -10
- package/node/mat/simplify-mat.js.map +1 -1
- package/node/point-on-shape/create-pos.d.ts +2 -2
- package/node/point-on-shape/create-pos.js.map +1 -1
- package/node/point-on-shape/point-on-shape.d.ts +6 -6
- package/node/svg/get-loop-bounds.d.ts +2 -2
- package/node/svg/get-loop-bounds.js +1 -1
- package/node/svg/get-loop-bounds.js.map +1 -1
- package/package.json +10 -10
- package/src/closest-boundary-point/foot-and-endpoint-info.ts +1 -1
- package/src/closest-boundary-point/get-close-boundary-points-certified.ts +5 -5
- package/src/closest-boundary-point/get-potential-closest-points-on-curve-certified.ts +9 -9
- package/src/cp-node/cp-node.ts +8 -3
- package/src/cp-node/fs/add-distance-from.ts +37 -37
- package/src/cp-node/fs/clone.ts +23 -17
- package/src/cp-node/fs/find-first.ts +14 -11
- package/src/cp-node/fs/get-all-on-loop.ts +5 -6
- package/src/cp-node/fs/get-boundary-bezier-parts-to-next.ts +1 -1
- package/src/cp-node/fs/get-edge-direction.ts +3 -5
- package/src/cp-node/fs/is-on-same-circle.ts +1 -0
- package/src/cp-node/stringification/cp-node-stringifyable.ts +68 -0
- package/src/cp-node/stringification/from-stringifyable.ts +57 -0
- package/src/cp-node/stringification/loop-from-stringifyable.ts +15 -0
- package/src/cp-node/stringification/loop-stringifyable.ts +8 -0
- package/src/cp-node/stringification/loop-to-stringifyable.ts +14 -0
- package/src/cp-node/stringification/to-stringifyable.ts +71 -0
- package/src/curve/curve.ts +31 -33
- package/src/debug/functions/draw-elem/draw-dull-corner.ts +2 -2
- package/src/debug/functions/draw-elem/draw-sharp-corner.ts +4 -3
- package/src/find-mat/find-mats.ts +8 -2
- package/src/find-mat/get-meta.ts +7 -6
- package/src/geometry/circle.ts +5 -12
- package/src/index.ts +3 -4
- package/src/mat/curve-piece.ts +3 -3
- package/src/mat/get-boundary-piece-beziers.ts +3 -3
- package/src/mat/mat-meta.ts +4 -4
- package/src/mat/simplify-mat-map-only.ts +110 -110
- package/src/mat/simplify-mat.ts +15 -13
- package/src/point-on-shape/create-pos.ts +3 -3
- package/src/point-on-shape/point-on-shape.ts +6 -6
- package/src/svg/get-loop-bounds.ts +4 -5
- package/__tests__/cp-node/fs/add-distance-from.spec.ts +0 -7
- package/__tests__/cp-node/fs/cp-nodes-to-boundary-beziers.spec.ts +0 -7
- package/__tests__/cp-node/fs/create-cp-node.spec.ts +0 -7
- package/__tests__/cp-node/fs/enhance-cp-node.spec.ts +0 -7
- package/__tests__/jsog/get-mats1.ts +0 -41
- package/node/curve/curve.d.ts +0 -33
- package/node/curve/curve.js +0 -2
- package/node/curve/curve.js.map +0 -1
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
import { Mat } from './mat.js';
|
|
1
|
+
import type { Mat } from './mat.js';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
* the MAT with fewer ones to within a given tolerance.
|
|
5
|
-
*
|
|
6
|
-
* @param
|
|
3
|
+
* Returns a new simplified MAT of the given one by replacing the piecewise
|
|
4
|
+
* quad beziers composing the MAT with fewer ones to within a given tolerance.
|
|
5
|
+
*
|
|
6
|
+
* @param cpNode a representation of the MAT
|
|
7
|
+
* @param anlgeTolerance tolerance given as the degrees difference of the unit
|
|
7
8
|
* direction vectors at the interface between curves. A tolerance of zero means
|
|
8
|
-
* perfect smoothness is required - defaults to 15
|
|
9
|
-
* @param hausdorffTolerance
|
|
9
|
+
* perfect smoothness is required - defaults to 15
|
|
10
|
+
* @param hausdorffTolerance the approximate maximum Hausdorff Distance tolerance -
|
|
10
11
|
* defaults to `2**-3`
|
|
11
|
-
* @param maxIterations
|
|
12
|
+
* @param maxIterations the max iterations of the Hausdorff Distance calculation,
|
|
13
|
+
* defaults to `50`
|
|
12
14
|
*/
|
|
13
15
|
declare function simplifyMat(mat: Mat, hausdorffTolerance?: number, maxIterations?: number): Mat;
|
|
14
16
|
export { simplifyMat };
|
package/node/mat/simplify-mat.js
CHANGED
|
@@ -11,15 +11,17 @@ import { isVertex } from '../cp-node/fs/is-vertex.js';
|
|
|
11
11
|
import { getProngCount } from '../cp-node/fs/get-prong-count.js';
|
|
12
12
|
// TODO2 could be made faster by binary "search" on hausdorff curves
|
|
13
13
|
/**
|
|
14
|
-
*
|
|
15
|
-
* the MAT with fewer ones to within a given tolerance.
|
|
16
|
-
*
|
|
17
|
-
* @param
|
|
14
|
+
* Returns a new simplified MAT of the given one by replacing the piecewise
|
|
15
|
+
* quad beziers composing the MAT with fewer ones to within a given tolerance.
|
|
16
|
+
*
|
|
17
|
+
* @param cpNode a representation of the MAT
|
|
18
|
+
* @param anlgeTolerance tolerance given as the degrees difference of the unit
|
|
18
19
|
* direction vectors at the interface between curves. A tolerance of zero means
|
|
19
|
-
* perfect smoothness is required - defaults to 15
|
|
20
|
-
* @param hausdorffTolerance
|
|
20
|
+
* perfect smoothness is required - defaults to 15
|
|
21
|
+
* @param hausdorffTolerance the approximate maximum Hausdorff Distance tolerance -
|
|
21
22
|
* defaults to `2**-3`
|
|
22
|
-
* @param maxIterations
|
|
23
|
+
* @param maxIterations the max iterations of the Hausdorff Distance calculation,
|
|
24
|
+
* defaults to `50`
|
|
23
25
|
*/
|
|
24
26
|
function simplifyMat(mat, hausdorffTolerance = 2 ** -3, maxIterations = 50) {
|
|
25
27
|
let cpNode = clone(mat.cpNode);
|
|
@@ -49,12 +51,12 @@ function simplifyMat(mat, hausdorffTolerance = 2 ** -3, maxIterations = 50) {
|
|
|
49
51
|
}
|
|
50
52
|
}
|
|
51
53
|
if (i + 1 === j) {
|
|
52
|
-
// no simplification occured
|
|
53
|
-
continue;
|
|
54
|
+
continue; // no simplification occured
|
|
54
55
|
}
|
|
55
56
|
}
|
|
56
57
|
}
|
|
57
|
-
cpNode = findFirst(cpNode_ => isTerminating(cpNode_) ? cpNode_ : undefined, cpNode)
|
|
58
|
+
// cpNode = findFirst(cpNode_ => isTerminating(cpNode_) ? cpNode_ : undefined, cpNode)!;
|
|
59
|
+
cpNode = findFirst(isTerminating, cpNode);
|
|
58
60
|
for (const cpNode of canDeletes) {
|
|
59
61
|
if (!isVertex(cpNode => (getProngCount(cpNode) !== 2) &&
|
|
60
62
|
!cpNode.isHoleClosing)(cpNode)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"simplify-mat.js","sourceRoot":"","sources":["../../src/mat/simplify-mat.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"simplify-mat.js","sourceRoot":"","sources":["../../src/mat/simplify-mat.ts"],"names":[],"mappings":"AAEA,OAAO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AG,kBAAkB,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;IAChE,OAAO,CAAC,GAAC,CAAC,GAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QAChB,GAAG,CAAC,IAAI,CAAC,yBAAyB,CAC9B,iBAAiB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAC5B,SAAS,EACT,gBAAgB,CACnB,CAAC,CAAC;IACP,CAAC;IAED,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC,CAAC;AAC5B,CAAC;AAGD,OAAO,EAAE,WAAW,EAAE,CAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Curve } from "
|
|
2
|
-
import { PointOnShape } from "./point-on-shape.js";
|
|
1
|
+
import type { Curve } from "flo-boolean";
|
|
2
|
+
import type { PointOnShape } from "./point-on-shape.js";
|
|
3
3
|
declare function createPos(curve: Curve, t: number, isSource?: boolean): PointOnShape;
|
|
4
4
|
export { createPos };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-pos.js","sourceRoot":"","sources":["../../src/point-on-shape/create-pos.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"create-pos.js","sourceRoot":"","sources":["../../src/point-on-shape/create-pos.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAGhD,SAAS,SAAS,CACV,KAAY,EACZ,CAAS,EACT,QAAkB;IAEtB,OAAO;QACH,KAAK;QACL,CAAC;QACD,CAAC,EAAE,iBAAiB,CAAC,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC,EAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACpD,QAAQ,EAAE,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,QAAQ;KACtD,CAAA;AACL,CAAC;AAGD,OAAO,EAAE,SAAS,EAAE,CAAA"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { Curve } from '
|
|
1
|
+
import type { Curve } from 'flo-boolean';
|
|
2
2
|
interface PointOnShape {
|
|
3
3
|
/** The `Curve` on the shape boundary this points belong to. */
|
|
4
|
-
curve: Curve;
|
|
4
|
+
readonly curve: Curve;
|
|
5
5
|
/** The bezier parameter value on the curve identifying the point coordinates. */
|
|
6
|
-
t: number;
|
|
7
|
-
p: number[];
|
|
6
|
+
readonly t: number;
|
|
7
|
+
readonly p: number[];
|
|
8
8
|
/** just for debugging */
|
|
9
|
-
isSource?: boolean;
|
|
9
|
+
readonly isSource?: boolean;
|
|
10
10
|
}
|
|
11
|
-
export { PointOnShape };
|
|
11
|
+
export type { PointOnShape };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-loop-bounds.js","sourceRoot":"","sources":["../../src/svg/get-loop-bounds.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"get-loop-bounds.js","sourceRoot":"","sources":["../../src/svg/get-loop-bounds.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAG5D,gBAAgB;AAChB,MAAM,GAAG,GAAG,MAAM,CAAC,iBAAiB,CAAC;AAGrC;;GAEG;AACH,MAAM,aAAa,GAAG,OAAO,CAAC,UAAS,IAAU;IAM7C,MAAM,QAAQ,GAIN;QACJ;YACI,EAAE,MAAM,EAAE,SAAU,EAAE,CAAC,EAAE,SAAU,EAAE,GAAG,EAAE,GAAG,EAAC;YAC9C,EAAE,MAAM,EAAE,SAAU,EAAE,CAAC,EAAE,SAAU,EAAE,GAAG,EAAE,GAAG,EAAC;SACjD;QACD;YACI,EAAE,M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",
|
|
3
3
|
"sideEffects": false,
|
|
4
4
|
"description": "Medial / Scale Axis Transform (MAT/SAT) Library.",
|
|
5
|
-
"version": "3.0.
|
|
5
|
+
"version": "3.0.15",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Floris Steenkamp"
|
|
8
8
|
},
|
|
@@ -31,23 +31,23 @@
|
|
|
31
31
|
"skeleton"
|
|
32
32
|
],
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"big-float-ts": "^4.0.
|
|
34
|
+
"big-float-ts": "^4.0.3",
|
|
35
35
|
"double-double": "^3.0.4",
|
|
36
|
-
"flo-bezier3": "^
|
|
37
|
-
"flo-boolean": "^5.0.
|
|
36
|
+
"flo-bezier3": "^7.0.3",
|
|
37
|
+
"flo-boolean": "^5.0.5",
|
|
38
38
|
"flo-draw": "^2.0.5",
|
|
39
39
|
"flo-gauss-quadrature": "^2.1.4",
|
|
40
40
|
"flo-ll-rb-tree": "^0.3.4",
|
|
41
41
|
"flo-memoize": "^2.0.1",
|
|
42
|
-
"flo-poly": "^
|
|
42
|
+
"flo-poly": "^8.1.2",
|
|
43
43
|
"flo-vector2d": "^4.0.6"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@jest/globals": "^30.4.1",
|
|
47
|
-
"@swc/core": "^1.15.
|
|
47
|
+
"@swc/core": "^1.15.43",
|
|
48
48
|
"@swc/jest": "^0.2.39",
|
|
49
49
|
"@types/jest": "^30.0.0",
|
|
50
|
-
"@types/node": "^
|
|
50
|
+
"@types/node": "^26.1.1",
|
|
51
51
|
"jest": "^30.4.2",
|
|
52
52
|
"jest-ts-webcompat-resolver": "^1.0.1",
|
|
53
53
|
"c8": "^11.0.0",
|
|
@@ -56,11 +56,11 @@
|
|
|
56
56
|
"mocha": "^11.7.6",
|
|
57
57
|
"rimraf": "^6.1.3",
|
|
58
58
|
"source-map-support": "^0.5.21",
|
|
59
|
-
"ts-loader": "^9.
|
|
59
|
+
"ts-loader": "^9.6.2",
|
|
60
60
|
"ts-node": "^10.9.2",
|
|
61
61
|
"typescript": "^6.0.3",
|
|
62
|
-
"webpack": "^5.
|
|
63
|
-
"webpack-cli": "^7.
|
|
62
|
+
"webpack": "^5.108.4",
|
|
63
|
+
"webpack-cli": "^7.2.1"
|
|
64
64
|
},
|
|
65
65
|
"scripts": {
|
|
66
66
|
"build": "npm run build-browser && npm run build-node",
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { Curve } from 'flo-boolean';
|
|
2
|
+
import type { CurvePiece } from '../mat/curve-piece.js';
|
|
3
|
+
import type { FootAndEndpointInfo } from './foot-and-endpoint-info.js';
|
|
4
|
+
import type { PointOnShape } from '../point-on-shape/point-on-shape.js';
|
|
5
|
+
import { createPos } from '../point-on-shape/create-pos.js';
|
|
2
6
|
import { getPotentialClosestPointsOnCurveCertified } from './get-potential-closest-points-on-curve-certified.js';
|
|
3
7
|
import { cullCurvePieces1 } from './cull-bezier-pieces.js';
|
|
4
|
-
import { Curve } from '../curve/curve.js';
|
|
5
|
-
import { FootAndEndpointInfo } from './foot-and-endpoint-info.js';
|
|
6
|
-
import { PointOnShape } from '../point-on-shape/point-on-shape.js';
|
|
7
|
-
import { createPos } from '../point-on-shape/create-pos.js';
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
/**
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
+
import type { Curve } from "flo-boolean";
|
|
2
|
+
import type { FootAndEndpointInfo } from './foot-and-endpoint-info.js';
|
|
1
3
|
import { allRootsCertified } from 'flo-poly';
|
|
4
|
+
import { eDeflate } from 'flo-poly';
|
|
2
5
|
import { getFootPointsOnBezierPolysCertified, getIntervalBox } from 'flo-bezier3';
|
|
3
|
-
import { Curve } from "../curve/curve.js";
|
|
4
6
|
import { ddDeflateWithRunningError } from './dd-deflate-with-running-error.js';
|
|
5
|
-
import { eDeflate } from 'flo-poly';
|
|
6
7
|
import { γγ } from '../error-analysis/gamma.js';
|
|
7
8
|
import { rootIntervalToDistanceSquaredInterval } from './root-interval-to-distance-squared-interval.js';
|
|
8
9
|
import { getPFromBox } from './get-p-from-box.js';
|
|
9
|
-
import { FootAndEndpointInfo } from './foot-and-endpoint-info.js';
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
const γγ3 = γγ(3);
|
|
@@ -87,19 +87,19 @@ function getPotentialClosestPointsOnCurveCertified(
|
|
|
87
87
|
);
|
|
88
88
|
|
|
89
89
|
if (tS === 0) {
|
|
90
|
-
if (!dontPush0) { ris.push({ tS: 0, tE: 0, multiplicity: 1 }); }
|
|
90
|
+
if (!dontPush0) { ris.push({ t: 0, tS: 0, tE: 0, multiplicity: 1 }); }
|
|
91
91
|
} else if (tS === 1) {
|
|
92
|
-
if (!dontPush1) { ris.push({ tS: 1, tE: 1, multiplicity: 1 }); }
|
|
92
|
+
if (!dontPush1) { ris.push({ t: 1, tS: 1, tE: 1, multiplicity: 1 }); }
|
|
93
93
|
} else {
|
|
94
|
-
ris.push({ tS: tS, tE: tS, multiplicity: 1 });
|
|
94
|
+
ris.push({ t: tS, tS: tS, tE: tS, multiplicity: 1 });
|
|
95
95
|
}
|
|
96
96
|
|
|
97
97
|
if (tE === 0) {
|
|
98
|
-
if (!dontPush0) { ris.push({ tS: 0, tE: 0, multiplicity: 1 }); }
|
|
98
|
+
if (!dontPush0) { ris.push({ t: 0, tS: 0, tE: 0, multiplicity: 1 }); }
|
|
99
99
|
} else if (tE === 1) {
|
|
100
|
-
if (!dontPush1) { ris.push({ tS: 1, tE: 1, multiplicity: 1 }); }
|
|
100
|
+
if (!dontPush1) { ris.push({ t: 1, tS: 1, tE: 1, multiplicity: 1 }); }
|
|
101
101
|
} else {
|
|
102
|
-
ris.push({ tS: tE, tE: tE, multiplicity: 1 });
|
|
102
|
+
ris.push({ t: tE, tS: tE, tE: tE, multiplicity: 1 });
|
|
103
103
|
}
|
|
104
104
|
|
|
105
105
|
const infos = ris
|
package/src/cp-node/cp-node.ts
CHANGED
|
@@ -50,12 +50,20 @@ import { ContactPoint } from '../contact-point/contact-point.js';
|
|
|
50
50
|
* in opposite directions.
|
|
51
51
|
*/
|
|
52
52
|
interface CpNode {
|
|
53
|
+
/** For debugging / easy identification only */
|
|
54
|
+
id: number;
|
|
55
|
+
|
|
53
56
|
/** The shape boundary contact point, i.e. a `CpNode` without its edges. */
|
|
54
57
|
cp: ContactPoint;
|
|
55
58
|
/** If true, this `CpNode` belongs to a hole-closing maximal disk. */
|
|
56
59
|
isHoleClosing: boolean;
|
|
57
60
|
/** true if this `CpNode` is at a shape boundary intersection point, false otherwise */
|
|
58
61
|
isIntersection: boolean;
|
|
62
|
+
|
|
63
|
+
//------------------------
|
|
64
|
+
// EDGES TO OTHER CpNodes
|
|
65
|
+
//------------------------
|
|
66
|
+
|
|
59
67
|
/** The previous (going clockwise around the boundary) contact point `CpNode`. */
|
|
60
68
|
prev: CpNode;
|
|
61
69
|
/** The next (going anti-clockwise around the boundary) contact point `CpNode`. */
|
|
@@ -76,9 +84,6 @@ interface CpNode {
|
|
|
76
84
|
* next `CpNode` on the same loop.
|
|
77
85
|
*/
|
|
78
86
|
holeCloserTwin?: CpNode | undefined;
|
|
79
|
-
|
|
80
|
-
/** For debugging / easy identification only */
|
|
81
|
-
id: number;
|
|
82
87
|
}
|
|
83
88
|
|
|
84
89
|
|
|
@@ -1,50 +1,50 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
//------------------------------
|
|
2
|
+
// KEEP FOR POSSIBLE FUTURE USE
|
|
3
|
+
//------------------------------
|
|
4
4
|
|
|
5
|
+
// import { getTAtLength, length } from "flo-bezier3";
|
|
6
|
+
// import { createPos } from "../../point-on-shape/create-pos.js";
|
|
7
|
+
// import { CpNode } from "../cp-node.js";
|
|
5
8
|
|
|
6
|
-
function addDistanceFrom(
|
|
7
|
-
d: number,
|
|
8
|
-
cpNode: CpNode) {
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
// function addDistanceFrom(
|
|
11
|
+
// d: number,
|
|
12
|
+
// cpNode: CpNode) {
|
|
12
13
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
let dist = 0;
|
|
16
|
-
let curve = curveS;
|
|
17
|
-
let ps;
|
|
18
|
-
let dLeft = d;
|
|
19
|
-
while (true) {
|
|
20
|
-
ps = curve.ps;
|
|
21
|
-
dist = length([tS,1], ps);
|
|
22
|
-
cumL += dist;
|
|
14
|
+
// const posS = cpNode.cp.pointOnShape;
|
|
15
|
+
// const curveS = posS.curve;
|
|
23
16
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
17
|
+
// let tS = posS.t;
|
|
18
|
+
// let cumL = 0;
|
|
19
|
+
// let dist = 0;
|
|
20
|
+
// let curve = curveS;
|
|
21
|
+
// let ps;
|
|
22
|
+
// let dLeft = d;
|
|
23
|
+
// while (true) {
|
|
24
|
+
// ps = curve.ps;
|
|
25
|
+
// dist = length([tS,1], ps);
|
|
26
|
+
// cumL += dist;
|
|
32
27
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
28
|
+
// if (cumL < d) {
|
|
29
|
+
// tS = 0;
|
|
30
|
+
// dLeft -= dist;
|
|
31
|
+
// curve = curve.next;
|
|
32
|
+
// } else {
|
|
33
|
+
// break;
|
|
34
|
+
// }
|
|
35
|
+
// }
|
|
36
36
|
|
|
37
|
-
|
|
37
|
+
// // const overshoot = cumL - d;
|
|
38
|
+
// const lL = length([0,tS], curve.ps);
|
|
39
|
+
// const l = lL + dLeft;
|
|
38
40
|
|
|
39
|
-
|
|
41
|
+
// const t = getTAtLength(curve.ps, l);
|
|
40
42
|
|
|
41
|
-
|
|
42
|
-
}
|
|
43
|
+
// const posE = createPos(curve, t);
|
|
43
44
|
|
|
45
|
+
// return posE;
|
|
46
|
+
// }
|
|
44
47
|
|
|
45
48
|
|
|
46
|
-
export { addDistanceFrom }
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
// TESTING
|
|
50
49
|
|
|
50
|
+
// export { addDistanceFrom }
|
package/src/cp-node/fs/clone.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CpNode } from "../cp-node.js";
|
|
1
|
+
import type { CpNode } from "../cp-node.js";
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
/** @internal */
|
|
@@ -6,14 +6,15 @@ type Edge =
|
|
|
6
6
|
| 'prev'
|
|
7
7
|
| 'next'
|
|
8
8
|
| 'prevOnCircle'
|
|
9
|
-
| 'nextOnCircle'
|
|
9
|
+
| 'nextOnCircle'
|
|
10
|
+
| 'holeCloserTwin';
|
|
10
11
|
|
|
11
12
|
/** @internal */
|
|
12
|
-
const EDGES: Edge[] = ['prev', 'next', 'prevOnCircle', 'nextOnCircle'];
|
|
13
|
+
const EDGES: Edge[] = ['prev', 'next', 'prevOnCircle', 'nextOnCircle', 'holeCloserTwin'];
|
|
13
14
|
|
|
14
15
|
|
|
15
16
|
type CpNodeWithoutEdges =
|
|
16
|
-
Omit<CpNode, 'prev' | 'next' | 'prevOnCircle' | 'nextOnCircle'>;
|
|
17
|
+
Omit<CpNode, 'prev' | 'next' | 'prevOnCircle' | 'nextOnCircle' | 'holeCloserTwin'>;
|
|
17
18
|
|
|
18
19
|
|
|
19
20
|
/**
|
|
@@ -21,13 +22,15 @@ type CpNodeWithoutEdges =
|
|
|
21
22
|
* since cloning a single `CpNode` necessarily implies cloning all
|
|
22
23
|
* `CpNode`s on the same MAT tree.
|
|
23
24
|
*/
|
|
24
|
-
function clone(
|
|
25
|
+
function clone(
|
|
26
|
+
cpNode: CpNode): CpNode {
|
|
27
|
+
|
|
25
28
|
// Don't change this function to be recursive, the call stack may
|
|
26
|
-
// overflow if there are too many
|
|
29
|
+
// overflow if there are too many `CpNode`s.
|
|
27
30
|
|
|
28
31
|
const nodeMap: Map<CpNode, CpNodeWithoutEdges> = new Map();
|
|
29
32
|
|
|
30
|
-
const newCpNode: CpNodeWithoutEdges =
|
|
33
|
+
const newCpNode: CpNodeWithoutEdges = cloneWithoutEdges(cpNode);
|
|
31
34
|
|
|
32
35
|
nodeMap.set(cpNode, newCpNode);
|
|
33
36
|
const cpStack = [{ cpNode, newCpNode }];
|
|
@@ -37,14 +40,16 @@ function clone(cpNode: CpNode): CpNode {
|
|
|
37
40
|
|
|
38
41
|
for (const edge of EDGES) {
|
|
39
42
|
const node = cpNode[edge];
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
+
if (node === undefined) { continue; }
|
|
44
|
+
|
|
45
|
+
let node_ = nodeMap.get(node);
|
|
46
|
+
if (!node_) {
|
|
47
|
+
node_ = cloneWithoutEdges(node);
|
|
43
48
|
|
|
44
|
-
nodeMap.set(node,
|
|
45
|
-
cpStack.push({cpNode: node, newCpNode:
|
|
49
|
+
nodeMap.set(node, node_);
|
|
50
|
+
cpStack.push({ cpNode: node, newCpNode: node_ });
|
|
46
51
|
}
|
|
47
|
-
(newCpNode as CpNode)[edge] =
|
|
52
|
+
(newCpNode as CpNode)[edge] = node_ as CpNode;
|
|
48
53
|
}
|
|
49
54
|
}
|
|
50
55
|
|
|
@@ -52,18 +57,19 @@ function clone(cpNode: CpNode): CpNode {
|
|
|
52
57
|
}
|
|
53
58
|
|
|
54
59
|
|
|
55
|
-
function
|
|
56
|
-
const
|
|
60
|
+
function cloneWithoutEdges(cpNode: CpNode) {
|
|
61
|
+
const cpNode_ = {
|
|
57
62
|
...cpNode,
|
|
58
63
|
...{
|
|
59
64
|
prev: undefined,
|
|
60
65
|
next: undefined,
|
|
61
66
|
prevOnCircle: undefined,
|
|
62
|
-
nextOnCircle: undefined
|
|
67
|
+
nextOnCircle: undefined,
|
|
68
|
+
holeCloserTwin: undefined
|
|
63
69
|
}
|
|
64
70
|
};
|
|
65
71
|
|
|
66
|
-
return
|
|
72
|
+
return cpNode_;
|
|
67
73
|
}
|
|
68
74
|
|
|
69
75
|
|
|
@@ -1,22 +1,25 @@
|
|
|
1
|
-
import { CpNode } from "../cp-node.js";
|
|
2
|
-
import { CpNodeFs } from "../cp-node-fs.js";
|
|
1
|
+
import type { CpNode } from "../cp-node.js";
|
|
3
2
|
|
|
4
3
|
|
|
4
|
+
/**
|
|
5
|
+
* Finds the first `CpNode` in the same MAT tree for which `f` returns a
|
|
6
|
+
* truthy value. Returns `undefined` if no such `CpNode` exists.
|
|
7
|
+
*
|
|
8
|
+
* @param f a function that takes a `CpNode` and returns a `CpNode` or `undefined`
|
|
9
|
+
* @param cpNode a `CpNode` on the MAT tree to search from
|
|
10
|
+
*/
|
|
5
11
|
function findFirst(
|
|
6
|
-
f: (cpNode: CpNode) =>
|
|
12
|
+
f: (cpNode: CpNode) => boolean,
|
|
7
13
|
cpNode: CpNode): CpNode | undefined {
|
|
8
14
|
|
|
9
15
|
const cpStart = cpNode;
|
|
10
16
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
while (cpNode_ !== cpStart) {
|
|
15
|
-
if (f(cpNode_)) {
|
|
16
|
-
return cpNode_;
|
|
17
|
+
do {
|
|
18
|
+
if (f(cpNode)) {
|
|
19
|
+
return cpNode;
|
|
17
20
|
}
|
|
18
|
-
|
|
19
|
-
}
|
|
21
|
+
cpNode = cpNode.next;
|
|
22
|
+
} while (cpNode !== cpStart);
|
|
20
23
|
|
|
21
24
|
return undefined;
|
|
22
25
|
}
|
|
@@ -9,13 +9,12 @@ function getAllOnLoop(
|
|
|
9
9
|
cpNode: CpNode) {
|
|
10
10
|
|
|
11
11
|
const cpStart = cpNode;
|
|
12
|
-
const cpNodes: CpNode[] = [
|
|
13
|
-
let cpNode_ = cpNode.next;
|
|
12
|
+
const cpNodes: CpNode[] = [];
|
|
14
13
|
|
|
15
|
-
|
|
16
|
-
cpNodes.push(
|
|
17
|
-
|
|
18
|
-
}
|
|
14
|
+
do {
|
|
15
|
+
cpNodes.push(cpNode);
|
|
16
|
+
cpNode = cpNode.next;
|
|
17
|
+
} while (cpNode !== cpStart);
|
|
19
18
|
|
|
20
19
|
return cpNodes;
|
|
21
20
|
}
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
} from 'flo-vector2d';
|
|
1
|
+
import type { Curve } from 'flo-boolean';
|
|
2
|
+
import type { CpNode } from '../cp-node.js';
|
|
3
|
+
import { toUnitVector, fromTo, rotate, translate, rotate90Degrees, reverse, dot } from 'flo-vector2d';
|
|
4
4
|
import { tangent } from 'flo-bezier3';
|
|
5
|
-
import { CpNode } from '../cp-node.js';
|
|
6
5
|
import { isPosSharpCorner } from '../../point-on-shape/is-pos-sharp-corner.js';
|
|
7
|
-
import { Curve } from '../../curve/curve.js';
|
|
8
6
|
|
|
9
7
|
|
|
10
8
|
/**
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
// import type { Loop } from "flo-boolean";
|
|
2
|
+
import type { Circle } from "../../geometry/circle";
|
|
3
|
+
import type { CpNode } from "../cp-node";
|
|
4
|
+
import type { LoopStringifyable } from "./loop-stringifyable";
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
/** @internal */
|
|
8
|
+
type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>
|
|
9
|
+
/** @internal */
|
|
10
|
+
type PartialBy<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
/** @internal */
|
|
14
|
+
type Edge =
|
|
15
|
+
| 'prev' | 'next'
|
|
16
|
+
| 'prevOnCircle' | 'nextOnCircle'
|
|
17
|
+
| 'holeCloserTwin';
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
/** @internal */
|
|
21
|
+
type PointOnShapeSimplified = {
|
|
22
|
+
readonly loopIdx: number;
|
|
23
|
+
readonly curveIdx: number;
|
|
24
|
+
readonly p: number[];
|
|
25
|
+
readonly t: number;
|
|
26
|
+
readonly isSource?: boolean;
|
|
27
|
+
}
|
|
28
|
+
/** @internal */
|
|
29
|
+
type ContactPointSimplified = {
|
|
30
|
+
readonly circle: Circle;
|
|
31
|
+
readonly pointOnShape: PointOnShapeSimplified;
|
|
32
|
+
readonly order: number;
|
|
33
|
+
readonly order2: number;
|
|
34
|
+
}
|
|
35
|
+
/** @internal */
|
|
36
|
+
type CpNodeSimplified = Omit<CpNode, 'cp'> & {
|
|
37
|
+
readonly cp: ContactPointSimplified;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** @internal */
|
|
41
|
+
type CpNodeSimplifiedEdgeless = Omit<CpNodeSimplified, Edge>;
|
|
42
|
+
|
|
43
|
+
/** @internal */
|
|
44
|
+
type CpNodeWithAnyEdges = PartialBy<
|
|
45
|
+
CpNodeSimplifiedEdgeless & Record<Edge, CpNode | number>,
|
|
46
|
+
'holeCloserTwin'
|
|
47
|
+
>
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
interface CpNodeStringifyable {
|
|
51
|
+
cpNodes: CpNodeWithAnyEdges[];
|
|
52
|
+
loops: LoopStringifyable[];
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
const EDGES: Edge[] = [
|
|
57
|
+
'prev', 'next',
|
|
58
|
+
'prevOnCircle', 'nextOnCircle',
|
|
59
|
+
'holeCloserTwin'
|
|
60
|
+
];
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
export { EDGES }
|
|
64
|
+
export type {
|
|
65
|
+
PointOnShapeSimplified, ContactPointSimplified,
|
|
66
|
+
CpNodeSimplified, CpNodeSimplifiedEdgeless,
|
|
67
|
+
CpNodeStringifyable, CpNodeWithAnyEdges,
|
|
68
|
+
}
|