flo-mat 4.0.2 → 4.0.3

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 (101) hide show
  1. package/__tests__/specific-cases/specific-cases.spec.ts +6 -0
  2. package/browser/index.js +4511 -7115
  3. package/browser/index.min.js +1 -1
  4. package/node/cp-node/fs/is-on-same-loop.d.ts +3 -0
  5. package/node/cp-node/fs/is-on-same-loop.js +6 -0
  6. package/node/cp-node/fs/is-on-same-loop.js.map +1 -0
  7. package/node/debug/debug.d.ts +10 -15
  8. package/node/debug/debug.js +35 -46
  9. package/node/debug/debug.js.map +1 -1
  10. package/node/find-2-prong/add-1-prong.js +1 -4
  11. package/node/find-2-prong/add-1-prong.js.map +1 -1
  12. package/node/find-mat/find-mat.js +1 -2
  13. package/node/find-mat/find-mat.js.map +1 -1
  14. package/node/find-mat/get-meta.d.ts +1 -6
  15. package/node/find-mat/get-meta.js +4 -26
  16. package/node/find-mat/get-meta.js.map +1 -1
  17. package/node/index.d.ts +4 -2
  18. package/node/index.js +3 -1
  19. package/node/index.js.map +1 -1
  20. package/node/reconstruct-from-mat/filter-zero-length.d.ts +10 -0
  21. package/node/reconstruct-from-mat/filter-zero-length.js +14 -0
  22. package/node/reconstruct-from-mat/filter-zero-length.js.map +1 -0
  23. package/node/reconstruct-from-mat/get-all-on-loop-by-loop.d.ts +7 -0
  24. package/node/reconstruct-from-mat/get-all-on-loop-by-loop.js +38 -0
  25. package/node/reconstruct-from-mat/get-all-on-loop-by-loop.js.map +1 -0
  26. package/node/reconstruct-from-mat/get-bezier-piece-length.d.ts +3 -0
  27. package/node/reconstruct-from-mat/get-bezier-piece-length.js +6 -0
  28. package/node/reconstruct-from-mat/get-bezier-piece-length.js.map +1 -0
  29. package/node/reconstruct-from-mat/get-boundary.d.ts +7 -0
  30. package/node/reconstruct-from-mat/get-boundary.js +18 -0
  31. package/node/reconstruct-from-mat/get-boundary.js.map +1 -0
  32. package/node/reconstruct-from-mat/get-cp-nodess-for-sat.d.ts +4 -0
  33. package/node/reconstruct-from-mat/get-cp-nodess-for-sat.js +15 -0
  34. package/node/reconstruct-from-mat/get-cp-nodess-for-sat.js.map +1 -0
  35. package/node/reconstruct-from-mat/get-matching-beziers.d.ts +10 -0
  36. package/node/reconstruct-from-mat/get-matching-beziers.js +29 -0
  37. package/node/reconstruct-from-mat/get-matching-beziers.js.map +1 -0
  38. package/node/reconstruct-from-mat/get-mbss-by-loop-per-sat.d.ts +6 -0
  39. package/node/reconstruct-from-mat/get-mbss-by-loop-per-sat.js +10 -0
  40. package/node/reconstruct-from-mat/get-mbss-by-loop-per-sat.js.map +1 -0
  41. package/node/reconstruct-from-mat/get-mbss-by-loop-with-opp-arr.d.ts +7 -0
  42. package/node/reconstruct-from-mat/get-mbss-by-loop-with-opp-arr.js +47 -0
  43. package/node/reconstruct-from-mat/get-mbss-by-loop-with-opp-arr.js.map +1 -0
  44. package/node/reconstruct-from-mat/get-sats2.d.ts +10 -0
  45. package/node/reconstruct-from-mat/get-sats2.js +16 -0
  46. package/node/reconstruct-from-mat/get-sats2.js.map +1 -0
  47. package/node/reconstruct-from-mat/is-fully-terminating.d.ts +3 -0
  48. package/node/reconstruct-from-mat/is-fully-terminating.js +19 -0
  49. package/node/reconstruct-from-mat/is-fully-terminating.js.map +1 -0
  50. package/node/reconstruct-from-mat/matched-beziers.d.ts +10 -0
  51. package/node/reconstruct-from-mat/matched-beziers.js +2 -0
  52. package/node/reconstruct-from-mat/matched-beziers.js.map +1 -0
  53. package/node/reconstruct-from-mat/reconstruct-from-mat.d.ts +4 -0
  54. package/node/reconstruct-from-mat/reconstruct-from-mat.js +28 -0
  55. package/node/reconstruct-from-mat/reconstruct-from-mat.js.map +1 -0
  56. package/node/reconstruct-from-mat/remove-sat-induced-trivial-3prongs.d.ts +12 -0
  57. package/node/reconstruct-from-mat/remove-sat-induced-trivial-3prongs.js +46 -0
  58. package/node/reconstruct-from-mat/remove-sat-induced-trivial-3prongs.js.map +1 -0
  59. package/node/reconstruct-from-mat/split-tri-path.d.ts +5 -0
  60. package/node/reconstruct-from-mat/split-tri-path.js +209 -0
  61. package/node/reconstruct-from-mat/split-tri-path.js.map +1 -0
  62. package/node/sat/add-debug-info.js +1 -2
  63. package/node/sat/add-debug-info.js.map +1 -1
  64. package/node/utils/clip.d.ts +2 -0
  65. package/node/utils/clip.js +6 -0
  66. package/node/utils/clip.js.map +1 -0
  67. package/package.json +2 -2
  68. package/src/cp-node/fs/is-on-same-loop.ts +15 -0
  69. package/src/debug/debug.ts +54 -72
  70. package/src/find-2-prong/add-1-prong.ts +1 -5
  71. package/src/find-mat/find-mat.ts +1 -2
  72. package/src/find-mat/get-meta.ts +3 -38
  73. package/src/index.ts +5 -3
  74. package/src/reconstruct-from-mat/filter-zero-length.ts +23 -0
  75. package/src/reconstruct-from-mat/get-all-on-loop-by-loop.ts +52 -0
  76. package/src/reconstruct-from-mat/get-bezier-piece-length.ts +12 -0
  77. package/src/reconstruct-from-mat/get-boundary.ts +32 -0
  78. package/src/reconstruct-from-mat/get-cp-nodess-for-sat.ts +24 -0
  79. package/src/reconstruct-from-mat/get-matching-beziers.ts +46 -0
  80. package/src/reconstruct-from-mat/get-mbss-by-loop-per-sat.ts +19 -0
  81. package/src/reconstruct-from-mat/get-mbss-by-loop-with-opp-arr.ts +69 -0
  82. package/src/reconstruct-from-mat/get-sats2.ts +25 -0
  83. package/src/reconstruct-from-mat/is-fully-terminating.ts +27 -0
  84. package/src/reconstruct-from-mat/matched-beziers.ts +14 -0
  85. package/src/reconstruct-from-mat/reconstruct-from-mat.ts +45 -0
  86. package/src/reconstruct-from-mat/remove-sat-induced-trivial-3prongs.ts +62 -0
  87. package/src/reconstruct-from-mat/split-tri-path.ts +280 -0
  88. package/src/sat/add-debug-info.ts +1 -2
  89. package/src/utils/clip.ts +13 -0
  90. package/node/debug/functions/general.d.ts +0 -48
  91. package/node/debug/functions/general.js +0 -53
  92. package/node/debug/functions/general.js.map +0 -1
  93. package/node/point-on-shape/pos-to-human-string.d.ts +0 -8
  94. package/node/point-on-shape/pos-to-human-string.js +0 -12
  95. package/node/point-on-shape/pos-to-human-string.js.map +0 -1
  96. package/src/debug/elem-type-two-prong.ts +0 -8
  97. package/src/debug/functions/cmp-cp-on-delta.ts +0 -54
  98. package/src/debug/functions/general.ts +0 -79
  99. package/src/debug/functions/three-prong.ts +0 -249
  100. package/src/debug/functions/two-prong.ts +0 -203
  101. package/src/find-2-prong/add-debug-info.ts +0 -45
@@ -0,0 +1,45 @@
1
+ import type { BezierPiece } from 'flo-bezier3';
2
+ import type { Mat } from '../mat/mat.js';
3
+ import { getMbssByLoopPerSat } from './get-mbss-by-loop-per-sat.js';
4
+ import { getMbssByLoopWithOppArr } from './get-mbss-by-loop-with-opp-arr.js';
5
+
6
+
7
+ function reconstructFromMats(
8
+ mats: Mat[]) {
9
+
10
+ const loopss: number[][][][] = [];
11
+
12
+ const bzs: BezierPiece[] = [];
13
+
14
+ const mbssByLoopPerSat = getMbssByLoopPerSat(mats, 1.5)!;
15
+
16
+ for (const mbssByLoopPS of mbssByLoopPerSat) {
17
+ const { mbssByLoop, oppArr } = mbssByLoopPS;
18
+
19
+ for (let l=0; l<mbssByLoop.length; l++) {
20
+ const rs = mbssByLoop[l];
21
+
22
+ for (let i=0; i<rs.length; i++) {
23
+ const r = mbssByLoop[l][i];
24
+
25
+ if (r === undefined) { continue; }
26
+
27
+ const matchedBezierss = r;
28
+
29
+ for (let j=0; j<matchedBezierss.length; j++) {
30
+ const mb = matchedBezierss[j];
31
+ const { boundaryBezier, medialBezier } = mb;
32
+
33
+ bzs.push(boundaryBezier)
34
+ }
35
+ }
36
+ }
37
+ }
38
+
39
+
40
+ return bzs;
41
+ // return loopss;
42
+ }
43
+
44
+
45
+ export { reconstructFromMats }
@@ -0,0 +1,62 @@
1
+ import type { Mutable } from '../utils/mutable.js';
2
+ import type { Mat } from '../mat/mat.js';
3
+ import { isFullyTerminating } from './is-fully-terminating.js';
4
+
5
+
6
+ /**
7
+ * In-place removes trivial 3-prongs from the SAT graph; just to simplify
8
+ * subsequent processing.
9
+ *
10
+ * These are 3-prongs that are induced by the SAT construction, and do
11
+ * not correspond to actual 3-prongs in the shape.
12
+ *
13
+ * @param sat the SAT
14
+ */
15
+ function removeSatInducedTrivial3Prongs(
16
+ sat: Mat): Mat {
17
+
18
+ let { cpNode } = sat;
19
+
20
+ let cpStart = cpNode;
21
+ do {
22
+ if (isFullyTerminating(cpNode) ||
23
+ // cpNode.isHoleClosing || // hole-closers are fully terminating
24
+ cpNode.next !== cpNode.nextOnCircle) {
25
+
26
+ cpNode = cpNode.next;
27
+ continue;
28
+ }
29
+
30
+ //-----------------------------
31
+ // Delete the trivial 3-prong
32
+ //-----------------------------
33
+ // console.log('Removing SAT-induced trivial 3-prong');
34
+
35
+ const next = cpNode.next;
36
+ const nextNext = next.next;
37
+ const nextNextOC = cpNode.next.nextOnCircle;
38
+
39
+ //-------------------------------------------------------------
40
+ // In-place update of links to remove the trivial 3-prong node
41
+ //-------------------------------------------------------------
42
+ (cpNode as Mutable<typeof cpNode>).next = nextNext;
43
+ (cpNode as Mutable<typeof cpNode>).nextOnCircle = nextNextOC;
44
+ (nextNext as Mutable<typeof nextNext>).prev = cpNode;
45
+ (nextNextOC as Mutable<typeof nextNextOC>).prevOnCircle = cpNode;
46
+ //-------------------------------------------------------------
47
+
48
+ if (cpStart === next) {
49
+ cpStart = cpNode; // ...otherwise the loop will never terminate
50
+ }
51
+
52
+ cpNode = cpNode.next;
53
+ } while (cpNode !== cpStart)
54
+
55
+ // ...otherwise the caller will have a reference to a node that has been removed from the graph
56
+ (sat as Mutable<Mat>).cpNode = cpNode;
57
+
58
+ return sat;
59
+ }
60
+
61
+
62
+ export { removeSatInducedTrivial3Prongs }
@@ -0,0 +1,280 @@
1
+ import type { BezierPiece } from 'flo-bezier3';
2
+ import type { MatchedBeziers } from './matched-beziers.js';
3
+ import { getTAtLength } from 'flo-bezier3';
4
+ import { sum } from '../utils/sum.js';
5
+ import { clip } from '../utils/clip.js';
6
+ import { getBezierPieceLength } from './get-bezier-piece-length.js';
7
+
8
+
9
+ const EPS = 1e-9;
10
+
11
+
12
+ function splitTriPath(
13
+ boundaryBeziers: BezierPiece[],
14
+ medialBezier: BezierPiece,
15
+ boundaryBeziersOpp: BezierPiece[] | undefined): MatchedBeziers[] {
16
+
17
+ const _boundaryBeziersOpp = boundaryBeziersOpp ?? [];
18
+
19
+ const boundaryBeziersOpp_ =
20
+ _boundaryBeziersOpp.map(reverseBezierPiece).toReversed();
21
+
22
+ // Importantly, we need to split on boundaryBeziersOpp_ as well, to ensure
23
+ // the number of returned pieces is the same for both sides, so that they
24
+ // can be interpolated.
25
+ const _paths = boundaryBeziersOpp_.length > 0
26
+ ? [boundaryBeziers, [medialBezier], boundaryBeziersOpp_]
27
+ : [boundaryBeziers, [medialBezier]];
28
+
29
+ const paths = splitTriPath_(_paths);
30
+
31
+ const matchedBezierss: MatchedBeziers[] = [];
32
+ for (let i=0; i<paths.length; i++) {
33
+ const path = paths[i];
34
+ // const pathOpp = paths[paths.length - 1 - i];
35
+
36
+ const [boundaryBezier, medialBezier] = path;
37
+ // const boundaryBezierOpp = pathOpp[2];
38
+ const matchedBeziers: MatchedBeziers = {
39
+ boundaryBezier,
40
+ medialBezier,
41
+ // boundaryBezierOpp
42
+ };
43
+ matchedBezierss.push(matchedBeziers);
44
+ }
45
+
46
+ return matchedBezierss;
47
+ }
48
+
49
+
50
+ function reverseBezierPiece(
51
+ bezierPiece: BezierPiece) {
52
+
53
+ const { ps, ts: [tS, tE] } = bezierPiece;
54
+
55
+ return {
56
+ ps: ps.toReversed(),
57
+ ts: [1 - tE, 1 - tS]
58
+ };
59
+ }
60
+
61
+
62
+ /**
63
+ * Returns an array of arrays of `BezierPiece`s, where each inner array
64
+ * contains `BezierPiece`s that correspond to each other across the different
65
+ * paths by normalized length.
66
+ *
67
+ * For example, if there are 3 paths, then each inner array will contain 3
68
+ * `BezierPiece`s, one from each path, that correspond to each other by normalized
69
+ * length.
70
+ *
71
+ * @param bezierPiecess
72
+ */
73
+ function splitTriPath_(
74
+ bezierPiecess: BezierPiece[][]): BezierPiece[][] {
75
+
76
+ const lenss = mapmap(bezierPiecess, getBezierPieceLength);
77
+ const lens = lenss.map(sum);
78
+ const cums = lenss.map(getCumLengths);
79
+
80
+ const normCums = cums.map((cum,i) => {
81
+ const len = lens[i];
82
+ if (len <= EPS) {
83
+ return cum.map((_,j) => j === 0 ? 0 : 1);
84
+ // return cum.map(() => Number.POSITIVE_INFINITY);
85
+ }
86
+
87
+ return cum.map(l => l/len);
88
+ });
89
+
90
+
91
+ /** Current position of start t */
92
+ let ts = new Array(bezierPiecess.length).fill(0);
93
+ /** Current position of i */
94
+ let is = new Array(bezierPiecess.length).fill(0);
95
+
96
+ const matchedBezierss: BezierPiece[][] = [];
97
+
98
+ normCums;//?
99
+
100
+ let ii = 0;
101
+ const maxIterations = 100;
102
+ while (ts.some(t => t < 1) && ii++ < maxIterations) {
103
+ const normCumsNext: number[] = [];
104
+ for (let k=0; k<bezierPiecess.length; k++) {
105
+ const i_ = is[k];
106
+
107
+ const normCum_ = normCums[k][i_ + 1];//?
108
+ const normCum = normCum_ === undefined
109
+ ? Number.POSITIVE_INFINITY
110
+ : normCum_;
111
+
112
+ normCumsNext.push(normCum);
113
+ }
114
+
115
+ normCumsNext;//?
116
+
117
+ const minIdx = getMinIdx(normCumsNext)!;//?
118
+ const idxs = getIdxs(normCumsNext, normCumsNext[minIdx]);//?
119
+ const curCum = normCumsNext[minIdx];
120
+
121
+ // if (idxs.length === 0) {
122
+ // throw new Error('splitTriPath_: unable to make progress');
123
+ // }
124
+
125
+ const nextPieces: BezierPiece[] = new Array(bezierPiecess.length).fill([]);
126
+ for (let m=0; m<bezierPiecess.length; m++) {
127
+ const bezierPieces = bezierPiecess[m];
128
+ const _i = is[m];
129
+
130
+ // This path is already finished; keep emitting a degenerate tail.
131
+ if (_i >= bezierPieces.length) {
132
+ const lastBezierPiece = bezierPieces[bezierPieces.length - 1];
133
+ nextPieces[m] = {
134
+ ps: lastBezierPiece.ps,
135
+ ts: [1, 1]
136
+ };
137
+ ts[m] = 1;
138
+ continue;
139
+ }
140
+
141
+ if (idxs.includes(m)) {
142
+ const _t = ts[m];
143
+ const bezierPiece = bezierPieces[_i];
144
+ const [pieceTS, pieceTE] = bezierPiece.ts;
145
+ const pieceDt = pieceTE - pieceTS;
146
+
147
+ nextPieces[m] = {
148
+ ps: bezierPiece.ps,
149
+ ts: [pieceTS + _t*pieceDt, pieceTE]
150
+ };
151
+
152
+ const nextI = _i + 1;
153
+ is[m] = nextI;
154
+ ts[m] = nextI >= bezierPieces.length ? 1 : 0;
155
+ } else {
156
+ const _t = ts[m];
157
+ const bezierPiece = bezierPieces[_i];
158
+ const [pieceTS, pieceTE] = bezierPiece.ts;
159
+ const pieceDt = pieceTE - pieceTS;
160
+ const bezierLen = getBezierPieceLength({ ps: bezierPiece.ps, ts: [0, 1] });
161
+
162
+ const normCumStart = normCums[m][_i];
163
+ const normCumEnd = normCums[m][_i + 1];
164
+ const normCumDt = normCumEnd - normCumStart;
165
+ const normWithinPiece = normCumDt <= EPS
166
+ ? _t
167
+ : clip((curCum - normCumStart) / normCumDt, _t, 1);
168
+
169
+ const t1 = bezierLen <= EPS
170
+ ? _t
171
+ : clip(getTAtLength(bezierPiece.ps, bezierLen * normWithinPiece), _t, 1);
172
+
173
+ nextPieces[m] = {
174
+ ps: bezierPiece.ps,
175
+ ts: [pieceTS + _t*pieceDt, pieceTS + t1*pieceDt]
176
+ };
177
+
178
+ if (closeToEps(t1, 1)) {
179
+ const nextI = _i + 1;
180
+ is[m] = nextI;
181
+ ts[m] = nextI >= bezierPieces.length ? 1 : 0;
182
+ } else {
183
+ is[m] = _i;
184
+ ts[m] = t1;
185
+ }
186
+ }
187
+ }
188
+
189
+ matchedBezierss.push(nextPieces);
190
+ }
191
+
192
+ if (ts.some(t => t < 1)) {
193
+ throw new Error('splitTriPath_: exceeded maximum iterations');
194
+ }
195
+
196
+ return matchedBezierss;
197
+ }
198
+
199
+
200
+ function getCumLengths(lens: number[]) {
201
+ const cum: number[] = [0];
202
+ let cumLen = 0;
203
+ for (let j=0; j<lens.length; j++) {
204
+ cumLen += lens[j];
205
+ cum.push(cumLen);
206
+ }
207
+ return cum;
208
+ }
209
+
210
+
211
+ /**
212
+ * Returns the index within the given array of the number with the highest
213
+ * value.
214
+ *
215
+ * * returns `undefined` if the array is empty
216
+ */
217
+ function getMinIdx(
218
+ vs: number[]): number | undefined {
219
+
220
+ let minIdx: number | undefined = undefined;
221
+ let minVal = Number.POSITIVE_INFINITY;
222
+ for (let i=0; i<vs.length; i++) {
223
+ if (vs[i] <= minVal) {
224
+ minVal = vs[i];
225
+ minIdx = i;
226
+ }
227
+ }
228
+
229
+ return minIdx;
230
+ }
231
+
232
+
233
+ /**
234
+ * Returns the indices within the given array of the numbers that are equal to
235
+ * the given max value (within an EPS value).
236
+ *
237
+ * @param vs
238
+ * @param maxVal
239
+ */
240
+ function getIdxs(
241
+ vs: number[],
242
+ maxVal: number): number[] {
243
+
244
+ const maxIdxs: number[] = [];
245
+ for (let i=0; i<vs.length; i++) {
246
+ if (vs[i] === maxVal || closeToEps(vs[i], maxVal)) {
247
+ maxIdxs.push(i);
248
+ }
249
+ }
250
+
251
+ return maxIdxs;
252
+ }
253
+
254
+
255
+ function closeToEps(a: number, b: number) {
256
+ return Math.abs(a - b) <= EPS;
257
+ }
258
+
259
+
260
+ export { splitTriPath, getCumLengths };
261
+
262
+
263
+
264
+ // KEEP FOR TESTING! - one in opentype-ts doesn't work with tests due to aliases
265
+ function mapmap<T,U>(
266
+ tss: T[][],
267
+ f: (t: T) => U): U[][] {
268
+
269
+ const tss_: U[][] = [];
270
+ for (let i=0; i<tss.length; i++) {
271
+ const ts = tss[i];
272
+ const ts_: U[] = [];
273
+ for (let j=0; j<ts.length; j++) {
274
+ ts_.push(f(ts[j]));
275
+ }
276
+ tss_.push(ts_);
277
+ }
278
+
279
+ return tss_;
280
+ }
@@ -12,8 +12,7 @@ function addDebugInfo(
12
12
 
13
13
  if (typeof _debug_ === 'undefined') { return; }
14
14
 
15
- const timing = _debug_.generated.timing;
16
- timing.sats = performance.now() - timingStart;
15
+ _debug_.timing.sats = performance.now() - timingStart;
17
16
  }
18
17
 
19
18
 
@@ -0,0 +1,13 @@
1
+
2
+ const { max, min } = Math;
3
+
4
+ function clip(
5
+ v: number,
6
+ vMin: number,
7
+ vMax: number): number {
8
+
9
+ return max(vMin, min(vMax, v));
10
+ }
11
+
12
+
13
+ export { clip }
@@ -1,48 +0,0 @@
1
- import { CpNode } from '../../cp-node/cp-node.js';
2
- /** @internal */
3
- export interface IGeneralDebugFunctions {
4
- nameObj: (obj: any, pre?: string) => void;
5
- δToString: (cpNodes: CpNode[]) => string[];
6
- δsToString: (cpNodes: CpNode[][]) => string[][];
7
- pointToStr: (p: number[], decimalPlaces?: number) => string;
8
- pointsToStr: (ps: number[][], decimalPlaces?: number) => string[];
9
- }
10
- /**
11
- * @internal
12
- * Name the given object - for debugging purposes only
13
- */
14
- declare function nameObj(o: any, pre?: string): void;
15
- /**
16
- * @internal
17
- * Transforms a boundary piece (δ) into a human readable string.
18
- * @param cpNodes A boundary piece given by two CpNodes.
19
- */
20
- declare function δToString(cpNodes: CpNode[]): string[];
21
- /**
22
- * @internal
23
- * Transforms an array of boundary pieces (δs) into a human readable string.
24
- * @param cpNodes An array of boundary pieces.
25
- */
26
- declare function δsToString(cpNodes: CpNode[][]): string[][];
27
- /**
28
- * @internal
29
- * Convert the given points into a human readable string.
30
- * @param ps
31
- */
32
- declare function pointsToStr(ps: number[][], decimalPlaces?: number): string[];
33
- /**
34
- * @internal
35
- * Converts the given point into a human readable string.
36
- * @param p The point
37
- * @param decimalPlaces number of decimal places
38
- */
39
- declare function pointToStr(p: number[], decimalPlaces?: number): string;
40
- /** @internal */
41
- declare const generalDebugFunctions: {
42
- δToString: typeof δToString;
43
- δsToString: typeof δsToString;
44
- pointToStr: typeof pointToStr;
45
- pointsToStr: typeof pointsToStr;
46
- nameObj: typeof nameObj;
47
- };
48
- export { generalDebugFunctions };
@@ -1,53 +0,0 @@
1
- import { posToHumanString } from '../../point-on-shape/pos-to-human-string.js';
2
- /** @internal */
3
- let i = 0;
4
- /**
5
- * @internal
6
- * Name the given object - for debugging purposes only
7
- */
8
- function nameObj(o, pre = '') {
9
- o.name = '' + pre + i++;
10
- }
11
- /**
12
- * @internal
13
- * Transforms a boundary piece (δ) into a human readable string.
14
- * @param cpNodes A boundary piece given by two CpNodes.
15
- */
16
- function δToString(cpNodes) {
17
- return cpNodes.map(cpNode => posToHumanString(cpNode.pointOnShape));
18
- }
19
- /**
20
- * @internal
21
- * Transforms an array of boundary pieces (δs) into a human readable string.
22
- * @param cpNodes An array of boundary pieces.
23
- */
24
- function δsToString(cpNodes) {
25
- return cpNodes.map(δToString);
26
- }
27
- /**
28
- * @internal
29
- * Convert the given points into a human readable string.
30
- * @param ps
31
- */
32
- function pointsToStr(ps, decimalPlaces = 3) {
33
- return ps.map(p => pointToStr(p, decimalPlaces));
34
- }
35
- /**
36
- * @internal
37
- * Converts the given point into a human readable string.
38
- * @param p The point
39
- * @param decimalPlaces number of decimal places
40
- */
41
- function pointToStr(p, decimalPlaces = 3) {
42
- return p[0].toFixed(decimalPlaces) + ', ' + p[1].toFixed(decimalPlaces);
43
- }
44
- /** @internal */
45
- const generalDebugFunctions /*: IGeneralDebugFunctions*/ = {
46
- δToString,
47
- δsToString,
48
- pointToStr,
49
- pointsToStr,
50
- nameObj,
51
- };
52
- export { generalDebugFunctions };
53
- //# sourceMappingURL=general.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"general.js","sourceRoot":"","sources":["../../../src/debug/functions/general.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,6CAA6C,CAAC;AAa/E,gBAAgB;AAChB,IAAI,CAAC,GAAG,CAAC,CAAC;AACV;;;GAGG;AACH,SAAS,OAAO,CAAC,CAAM,EAAE,GAAG,GAAG,EAAE;IAC7B,CAAC,CAAC,IAAI,GAAG,EAAE,GAAG,GAAG,GAAG,CAAC,EAAE,CAAC;AAC5B,CAAC;AAGD;;;;GAIG;AACH,SAAS,SAAS,CAAC,OAAiB;IAChC,OAAO,OAAO,CAAC,GAAG,CACd,MAAM,CAAC,EAAE,CAAC,gBAAgB,CAAC,MAAM,CAAC,YAAY,CAAC,CAClD,CAAC;AACN,CAAC;AAGD;;;;GAIG;AACH,SAAS,UAAU,CAAC,OAAmB;IACnC,OAAO,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;AAClC,CAAC;AAGD;;;;GAIG;AACH,SAAS,WAAW,CAAC,EAAc,EAAE,aAAa,GAAG,CAAC;IAClD,OAAO,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,UAAU,CAAC,CAAC,EAAE,aAAa,CAAC,CAAC,CAAC;AACrD,CAAC;AAGD;;;;;GAKG;AACH,SAAS,UAAU,CAAC,CAAW,EAAE,aAAa,GAAG,CAAC;IAC9C,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,aAAa,CAAC,GAAG,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;AAC5E,CAAC;AAGD,gBAAgB;AAChB,MAAM,qBAAqB,CAAA,4BAA4B,GAAG;IACtD,SAAS;IACT,UAAU;IACV,UAAU;IACV,WAAW;IACX,OAAO;CACV,CAAA;AAGD,OAAO,EAAE,qBAAqB,EAAE,CAAA"}
@@ -1,8 +0,0 @@
1
- import type { PointOnShape } from "./point-on-shape.js";
2
- /**
3
- * Returns a human-readable string of the given `PointOnShape`.
4
- * For debugging only.
5
- * @internal
6
- */
7
- declare function posToHumanString(pos: PointOnShape): string;
8
- export { posToHumanString };
@@ -1,12 +0,0 @@
1
- /**
2
- * Returns a human-readable string of the given `PointOnShape`.
3
- * For debugging only.
4
- * @internal
5
- */
6
- function posToHumanString(pos) {
7
- return '' + pos.p[0] + ', ' + pos.p[1] +
8
- ' | bz: ' + pos.curve.idx +
9
- ' | t: ' + pos.t;
10
- }
11
- export { posToHumanString };
12
- //# sourceMappingURL=pos-to-human-string.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"pos-to-human-string.js","sourceRoot":"","sources":["../../src/point-on-shape/pos-to-human-string.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AACH,SAAS,gBAAgB,CACjB,GAAiB;IAErB,OAAO,EAAE,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QAClC,SAAS,GAAK,GAAG,CAAC,KAAK,CAAC,GAAG;QAC3B,QAAQ,GAAM,GAAG,CAAC,CAAC,CAAA;AAC3B,CAAC;AAGD,OAAO,EAAE,gBAAgB,EAAE,CAAA"}
@@ -1,8 +0,0 @@
1
-
2
- /** @internal */
3
- type ElemType_TwoProng =
4
- | 'twoProng_regular'
5
- | 'twoProng_holeClosing';
6
-
7
-
8
- export type { ElemType_TwoProng }
@@ -1,54 +0,0 @@
1
- import type { CpNode } from '../../cp-node/cp-node.js';
2
- import { PointOnShape } from '../../point-on-shape/point-on-shape.js';
3
-
4
-
5
- /**
6
- * @internal
7
- *
8
- * Note: For debugging only
9
- *
10
- * Checks the position of the ContactPoint (cp) on the boundary piece.
11
- * Returns < 0 if the cp is not on δ, > 0 if it is on the boundary piece
12
- * excluding the endpoints and 0 if it is on the endpoints. Also returns > 0 if
13
- * δ === undefined.
14
- *
15
- * @param δ The boundary piece
16
- * @param cp The contact point
17
- */
18
- function cmpCpOnδ(
19
- δ: CpNode[],
20
- cp: PointOnShape) {
21
-
22
- if (δ[0] === undefined) {
23
- return 1;
24
- }
25
-
26
- const cpBef = δ[0].cp;
27
- const cpAft = δ[1].cp;
28
-
29
- const cmp = compareCps(cpBef, cpAft);
30
- const cmpPrev = compareCps(cpBef, cp);
31
- const cmpNext = compareCps(cp, cpAft);
32
-
33
- if (cmp < 0) {
34
- if (cmpPrev > 0 || cmpNext > 0) {
35
- // console.log(`2-PRONG (antipode) Order is wrong - cmpPrev and cmpNext should be > 0; cmp: ${cmp}, cmpPrev: ${cmpPrev}, cmpNext ${cmpNext}`);
36
- return -1;
37
- }
38
- } else if (cmp > 0) {
39
- if (cmpPrev > 0 && cmpNext > 0) {
40
- // console.log(`2-PRONG (antipode) Order is wrong: ${cmpPrev}, ${cmpNext}`);
41
- return -1;
42
- }
43
- }
44
-
45
- if (cmpPrev === 0 || cmpNext === 0) {
46
- // console.log('2-PRONG orders are equal.');
47
- return 0;
48
- }
49
-
50
- return 1;
51
- }
52
-
53
-
54
- export { cmpCpOnδ }
@@ -1,79 +0,0 @@
1
- import { CpNode } from '../../cp-node/cp-node.js';
2
- import { posToHumanString } from '../../point-on-shape/pos-to-human-string.js';
3
-
4
-
5
- /** @internal */
6
- export interface IGeneralDebugFunctions {
7
- nameObj : (obj: any, pre?: string) => void,
8
- δToString : (cpNodes: CpNode[]) => string[],
9
- δsToString : (cpNodes: CpNode[][]) => string[][],
10
- pointToStr : (p: number[], decimalPlaces?: number) => string
11
- pointsToStr : (ps: number[][], decimalPlaces?: number) => string[],
12
- }
13
-
14
-
15
- /** @internal */
16
- let i = 0;
17
- /**
18
- * @internal
19
- * Name the given object - for debugging purposes only
20
- */
21
- function nameObj(o: any, pre = '') {
22
- o.name = '' + pre + i++;
23
- }
24
-
25
-
26
- /**
27
- * @internal
28
- * Transforms a boundary piece (δ) into a human readable string.
29
- * @param cpNodes A boundary piece given by two CpNodes.
30
- */
31
- function δToString(cpNodes: CpNode[]) {
32
- return cpNodes.map(
33
- cpNode => posToHumanString(cpNode.pointOnShape)
34
- );
35
- }
36
-
37
-
38
- /**
39
- * @internal
40
- * Transforms an array of boundary pieces (δs) into a human readable string.
41
- * @param cpNodes An array of boundary pieces.
42
- */
43
- function δsToString(cpNodes: CpNode[][]) {
44
- return cpNodes.map(δToString);
45
- }
46
-
47
-
48
- /**
49
- * @internal
50
- * Convert the given points into a human readable string.
51
- * @param ps
52
- */
53
- function pointsToStr(ps: number[][], decimalPlaces = 3) {
54
- return ps.map(p => pointToStr(p, decimalPlaces));
55
- }
56
-
57
-
58
- /**
59
- * @internal
60
- * Converts the given point into a human readable string.
61
- * @param p The point
62
- * @param decimalPlaces number of decimal places
63
- */
64
- function pointToStr(p: number[], decimalPlaces = 3) {
65
- return p[0].toFixed(decimalPlaces) + ', ' + p[1].toFixed(decimalPlaces);
66
- }
67
-
68
-
69
- /** @internal */
70
- const generalDebugFunctions/*: IGeneralDebugFunctions*/ = {
71
- δToString,
72
- δsToString,
73
- pointToStr,
74
- pointsToStr,
75
- nameObj,
76
- }
77
-
78
-
79
- export { generalDebugFunctions }