brepjs 18.119.1 → 18.119.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.
- package/dist/2d/lib/curve2D.d.ts +6 -1
- package/dist/2d/lib/curve2dFns.d.ts +6 -1
- package/dist/2d.cjs +7 -7
- package/dist/2d.js +7 -7
- package/dist/{adjacencyFns-CUFf2tRu.js → adjacencyFns-DLityMyV.js} +2 -2
- package/dist/{adjacencyFns-y48qfoSJ.cjs → adjacencyFns-DSxuQYnb.cjs} +2 -2
- package/dist/{blueprint-DmbWJqGH.cjs → blueprint-BGcBMy3b.cjs} +39 -9
- package/dist/{blueprint-sEiMTO6b.js → blueprint-CAG6jseD.js} +33 -9
- package/dist/{blueprintFns-B00x9B3d.js → blueprintFns-B4C3zH7N.js} +9 -4
- package/dist/{blueprintFns-2l6WQaiA.cjs → blueprintFns-CnoqynzI.cjs} +9 -4
- package/dist/{blueprintSketcher-B0--w0ms.cjs → blueprintSketcher-BNz6f36D.cjs} +166 -61
- package/dist/{blueprintSketcher-Dl65HO9X.js → blueprintSketcher-CKKxvxB-.js} +159 -54
- package/dist/{boolean2D-DUCzYBTW.cjs → boolean2D-B-0xobBP.cjs} +5 -5
- package/dist/{boolean2D-rVisWMVU.js → boolean2D-C_1gMcZ6.js} +5 -5
- package/dist/brepjs.cjs +105 -92
- package/dist/brepjs.js +39 -27
- package/dist/{cameraFns-CHY1Bpfi.cjs → cameraFns-2-haLzLi.cjs} +4 -4
- package/dist/{cameraFns-CspYs7P6.js → cameraFns-CG_J66Hl.js} +4 -4
- package/dist/core.cjs +12 -11
- package/dist/core.js +4 -3
- package/dist/{cornerFinder-DVFgHVlV.js → cornerFinder-CPFM7bA0.js} +1 -1
- package/dist/{cornerFinder-Nm7Qt1B5.cjs → cornerFinder-mfsUMi5g.cjs} +1 -1
- package/dist/{curveFns-yyB3QmwJ.js → curveFns-DX13KRh2.js} +2 -2
- package/dist/{curveFns-GEdU0r2K.cjs → curveFns-GmFnqNo3.cjs} +2 -2
- package/dist/{drawFns-1icEtH6h.cjs → drawFns-B14M5M68.cjs} +14 -14
- package/dist/{drawFns-BCsTmK-A.js → drawFns-BShGVVXW.js} +14 -14
- package/dist/{errors-B3CDG537.js → errors-MHLiNE-C.js} +1 -92
- package/dist/{errors-CJU8CHng.cjs → errors-RHkKO5bZ.cjs} +0 -103
- package/dist/{faceFns-DDeMMiWW.cjs → faceFns-BK4r7Dxk.cjs} +3 -3
- package/dist/{faceFns-D538regr.js → faceFns-DJj9Nb6T.js} +3 -3
- package/dist/{healingFns-DNJeh8v9.js → healingFns-DxcRyVCG.js} +5 -6
- package/dist/{healingFns-fgBZgj_9.cjs → healingFns-Hx4oTlq8.cjs} +27 -28
- package/dist/{helpers-Du76j4Vi.cjs → helpers-BfkBvokP.cjs} +8 -24
- package/dist/{helpers-B-t-HN_a.js → helpers-Du_OdHuy.js} +9 -25
- package/dist/{importFns-Ca5jD096.js → importFns-BHs19muu.js} +3 -3
- package/dist/{importFns-DQUXpfRv.cjs → importFns-GySbuvVv.cjs} +3 -3
- package/dist/io.cjs +2 -2
- package/dist/io.js +2 -2
- package/dist/kernel/brepkit/meshOps.test.d.ts +1 -0
- package/dist/{loftFns-LCgAh1pe.cjs → loftFns-BdpZ8FMN.cjs} +2 -125
- package/dist/{loftFns-Bii92046.js → loftFns-BeGJ6dxx.js} +4 -109
- package/dist/{measureFns-k7rf6ka6.cjs → measureFns-CJGrmhHT.cjs} +4 -4
- package/dist/{measureFns-BJrqkYUs.js → measureFns-CMnbcUZC.js} +4 -4
- package/dist/measurement.cjs +1 -1
- package/dist/measurement.js +1 -1
- package/dist/{meshFns-vJ3diglE.js → meshFns-Cs5EBsf7.js} +4 -4
- package/dist/{meshFns-C6N_kGLT.cjs → meshFns-Dqf5QBhQ.cjs} +5 -5
- package/dist/operations.cjs +2 -2
- package/dist/operations.js +2 -2
- package/dist/originTrackingFns-DZmdiQ-O.js +203 -0
- package/dist/originTrackingFns-fpEgTIwV.cjs +226 -0
- package/dist/{planeOps-Cp6GQ23-.js → planeOps-CQahLrCx.js} +1 -1
- package/dist/{planeOps-Cr25KWWA.cjs → planeOps-VlFxtvzY.cjs} +1 -1
- package/dist/primitiveFns-B_rflH83.cjs +773 -0
- package/dist/primitiveFns-Cxo3xDKY.js +558 -0
- package/dist/projection.cjs +1 -1
- package/dist/projection.js +1 -1
- package/dist/query.cjs +2 -2
- package/dist/query.js +2 -2
- package/dist/{refResolveFns-CxYx9TjR.js → refResolveFns-BbRLD8LA.js} +6 -6
- package/dist/{refResolveFns-Bw78l4fJ.cjs → refResolveFns-CVDLwh12.cjs} +6 -6
- package/dist/result.cjs +1 -1
- package/dist/result.js +1 -1
- package/dist/rolldown-runtime-DakpK96I.cjs +43 -0
- package/dist/shapeFns-BTFx-os7.js +43 -0
- package/dist/shapeFns-D_5TgiUi.cjs +84 -0
- package/dist/shapeRef.cjs +1 -1
- package/dist/shapeRef.js +1 -1
- package/dist/{shapeTypes-BU7SQ1y6.cjs → shapeTypes-CkcIL7zv.cjs} +13 -225
- package/dist/{shapeTypes-CxF4itPM.js → shapeTypes-t49f64Dx.js} +14 -142
- package/dist/sketching.cjs +3 -3
- package/dist/sketching.js +3 -3
- package/dist/{solidBuilders-BFzmgFl0.js → solidBuilders-DTgqQC3W.js} +310 -8
- package/dist/{solidBuilders-BuMNoLzt.cjs → solidBuilders-IiIzjKAr.cjs} +401 -15
- package/dist/{surfaceBuilders-BtZhuox5.cjs → surfaceBuilders-Biqx51el.cjs} +6 -5
- package/dist/{surfaceBuilders-BbRikJ0w.js → surfaceBuilders-BryY-i0F.js} +4 -3
- package/dist/text.cjs +2 -2
- package/dist/text.js +2 -2
- package/dist/{textBlueprints-BT2CZxAI.cjs → textBlueprints-8EcWreab.cjs} +138 -51
- package/dist/{textBlueprints-BvRolv7L.js → textBlueprints-rA1HT6j1.js} +116 -11
- package/dist/{textMetrics-CHmQrB6U.js → textMetrics-Bcbso1Ns.js} +2 -2
- package/dist/{textMetrics-BzITyHY6.cjs → textMetrics-GPBu9JKi.cjs} +2 -2
- package/dist/{threadFns-DbxiJ3Is.js → threadFns-BOtXTHZ9.js} +8 -8
- package/dist/{threadFns-Cw7gzV_Y.cjs → threadFns-DRrk9Qod.cjs} +8 -8
- package/dist/topology.cjs +9 -9
- package/dist/topology.js +9 -9
- package/dist/{topologyQueryFns-C5Z8m7Jg.cjs → topologyQueryFns-Bia7o8l_.cjs} +97 -6
- package/dist/{topologyQueryFns-D0rXN3v5.js → topologyQueryFns-BkQ6Q7gN.js} +93 -2
- package/dist/validityTypes-DiTgeCD9.js +129 -0
- package/dist/validityTypes-ZGMVlv7b.cjs +200 -0
- package/dist/vectors.cjs +1 -1
- package/dist/vectors.js +1 -1
- package/package.json +8 -8
- package/dist/primitiveFns-CeN9-EFA.cjs +0 -492
- package/dist/primitiveFns-DLWUMWq4.js +0 -331
- package/dist/shapeFns-B46P-8hf.cjs +0 -962
- package/dist/shapeFns-D0BBI3yY.js +0 -771
package/dist/2d/lib/curve2D.d.ts
CHANGED
|
@@ -27,7 +27,12 @@ export declare class Curve2D {
|
|
|
27
27
|
get wrapped(): KernelType;
|
|
28
28
|
delete(): void;
|
|
29
29
|
[Symbol.dispose](): void;
|
|
30
|
-
/**
|
|
30
|
+
/**
|
|
31
|
+
* Compute (and cache) the 2D bounding box of this curve.
|
|
32
|
+
*
|
|
33
|
+
* @remarks The returned box is owned by the curve and is disposed when the
|
|
34
|
+
* curve is deleted. Clone it if it must outlive the curve.
|
|
35
|
+
*/
|
|
31
36
|
get boundingBox(): BoundingBox2d;
|
|
32
37
|
/** Return a human-readable representation, e.g. `LINE (0,0) - (1,1)`. */
|
|
33
38
|
get repr(): string;
|
|
@@ -8,7 +8,12 @@ import { Result } from '../../core/result.js';
|
|
|
8
8
|
* @returns A new `Curve2D` with swapped start/end orientation.
|
|
9
9
|
*/
|
|
10
10
|
export declare function reverseCurve(curve: Curve2D): Curve2D;
|
|
11
|
-
/**
|
|
11
|
+
/**
|
|
12
|
+
* Get the bounding box of a 2D curve.
|
|
13
|
+
*
|
|
14
|
+
* @remarks The box is borrowed from the curve's cache and is disposed with the
|
|
15
|
+
* curve. Clone it if it must outlive the curve.
|
|
16
|
+
*/
|
|
12
17
|
export declare function curve2dBoundingBox(curve: Curve2D): BoundingBox2d;
|
|
13
18
|
/** Get the first point of a 2D curve. */
|
|
14
19
|
export declare function curve2dFirstPoint(curve: Curve2D): Point2D;
|
package/dist/2d.cjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_shapeTypes = require("./shapeTypes-
|
|
3
|
-
const require_errors = require("./errors-
|
|
4
|
-
const require_topologyQueryFns = require("./topologyQueryFns-
|
|
5
|
-
const require_blueprintSketcher = require("./blueprintSketcher-
|
|
6
|
-
const require_blueprint = require("./blueprint-
|
|
7
|
-
const require_boolean2D = require("./boolean2D-
|
|
8
|
-
const require_blueprintFns = require("./blueprintFns-
|
|
2
|
+
const require_shapeTypes = require("./shapeTypes-CkcIL7zv.cjs");
|
|
3
|
+
const require_errors = require("./errors-RHkKO5bZ.cjs");
|
|
4
|
+
const require_topologyQueryFns = require("./topologyQueryFns-Bia7o8l_.cjs");
|
|
5
|
+
const require_blueprintSketcher = require("./blueprintSketcher-BNz6f36D.cjs");
|
|
6
|
+
const require_blueprint = require("./blueprint-BGcBMy3b.cjs");
|
|
7
|
+
const require_boolean2D = require("./boolean2D-B-0xobBP.cjs");
|
|
8
|
+
const require_blueprintFns = require("./blueprintFns-CnoqynzI.cjs");
|
|
9
9
|
//#region src/core/curve2dHandle.ts
|
|
10
10
|
/**
|
|
11
11
|
* Wrap a raw kernel 2D curve handle with brand + disposal tracking.
|
package/dist/2d.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { T as kernelCallRaw } from "./topologyQueryFns-
|
|
4
|
-
import { a as Blueprints, i as CompoundBlueprint, r as organiseBlueprints } from "./blueprintSketcher-
|
|
5
|
-
import { _ as Curve2D,
|
|
6
|
-
import { a as fuseBlueprints, c as roundedRectangleBlueprint, i as cutBlueprints, n as fuse2D, o as intersectBlueprints, r as intersect2D, s as polysidesBlueprint, t as cut2D } from "./boolean2D-
|
|
7
|
-
import { S as reverseCurve, _ as curve2dIsOnCurve, a as isInside2D, b as curve2dSplitAt, c as scale2D, d as stretch2D, f as toSVGPathD, g as curve2dFirstPoint, h as curve2dDistanceFrom, i as getOrientation2D, l as sketchOnFace2D, m as curve2dBoundingBox, o as mirror2D, p as translate2D, r as getBounds2D, s as rotate2D, t as createBlueprint, u as sketchOnPlane2D, v as curve2dLastPoint, x as curve2dTangentAt, y as curve2dParameter } from "./blueprintFns-
|
|
1
|
+
import { P as createKernelHandle, c as createEdge, q as getKernel2D } from "./shapeTypes-t49f64Dx.js";
|
|
2
|
+
import { E as ok, d as validationError, g as err, t as BrepErrorCode } from "./errors-MHLiNE-C.js";
|
|
3
|
+
import { T as kernelCallRaw } from "./topologyQueryFns-BkQ6Q7gN.js";
|
|
4
|
+
import { a as Blueprints, i as CompoundBlueprint, r as organiseBlueprints } from "./blueprintSketcher-CKKxvxB-.js";
|
|
5
|
+
import { _ as Curve2D, b as BoundingBox2d, t as Blueprint } from "./blueprint-CAG6jseD.js";
|
|
6
|
+
import { a as fuseBlueprints, c as roundedRectangleBlueprint, i as cutBlueprints, n as fuse2D, o as intersectBlueprints, r as intersect2D, s as polysidesBlueprint, t as cut2D } from "./boolean2D-C_1gMcZ6.js";
|
|
7
|
+
import { S as reverseCurve, _ as curve2dIsOnCurve, a as isInside2D, b as curve2dSplitAt, c as scale2D, d as stretch2D, f as toSVGPathD, g as curve2dFirstPoint, h as curve2dDistanceFrom, i as getOrientation2D, l as sketchOnFace2D, m as curve2dBoundingBox, o as mirror2D, p as translate2D, r as getBounds2D, s as rotate2D, t as createBlueprint, u as sketchOnPlane2D, v as curve2dLastPoint, x as curve2dTangentAt, y as curve2dParameter } from "./blueprintFns-B4C3zH7N.js";
|
|
8
8
|
//#region src/core/curve2dHandle.ts
|
|
9
9
|
/**
|
|
10
10
|
* Wrap a raw kernel 2D curve handle with brand + disposal tracking.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { G as getActiveKernelId, K as getKernel, r as castResultShapeWithKnownType, t as borrowShapeWithKnownType } from "./shapeTypes-t49f64Dx.js";
|
|
2
2
|
import { O as isUnsupportedKernelOperationError } from "./occtWasmAdapter-CE6nV8_2.js";
|
|
3
|
-
import { c as getFaces, f as getVertices, l as getOrCreateCache, s as getEdges } from "./topologyQueryFns-
|
|
3
|
+
import { c as getFaces, f as getVertices, l as getOrCreateCache, s as getEdges } from "./topologyQueryFns-BkQ6Q7gN.js";
|
|
4
4
|
import { n as HASH_CODE_MAX } from "./constants-ITRzCnCp.js";
|
|
5
5
|
//#region src/topology/adjacencyFns.ts
|
|
6
6
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
const require_shapeTypes = require("./shapeTypes-
|
|
1
|
+
const require_shapeTypes = require("./shapeTypes-CkcIL7zv.cjs");
|
|
2
2
|
const require_occtWasmAdapter = require("./occtWasmAdapter-BAzyxAJw.cjs");
|
|
3
|
-
const require_topologyQueryFns = require("./topologyQueryFns-
|
|
3
|
+
const require_topologyQueryFns = require("./topologyQueryFns-Bia7o8l_.cjs");
|
|
4
4
|
const require_constants = require("./constants-BOVyEYGH.cjs");
|
|
5
5
|
//#region src/topology/adjacencyFns.ts
|
|
6
6
|
/**
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
const require_shapeTypes = require("./shapeTypes-
|
|
1
|
+
const require_shapeTypes = require("./shapeTypes-CkcIL7zv.cjs");
|
|
2
2
|
const require_bug = require("./bug-O02CsAmt.cjs");
|
|
3
|
-
const require_errors = require("./errors-
|
|
3
|
+
const require_errors = require("./errors-RHkKO5bZ.cjs");
|
|
4
4
|
const require_constants = require("./constants-BOVyEYGH.cjs");
|
|
5
5
|
const require_types = require("./types-KjA8tY4Y.cjs");
|
|
6
|
-
const require_planeOps = require("./planeOps-
|
|
7
|
-
const require_faceFns = require("./faceFns-
|
|
8
|
-
const require_curveFns = require("./curveFns-
|
|
6
|
+
const require_planeOps = require("./planeOps-VlFxtvzY.cjs");
|
|
7
|
+
const require_faceFns = require("./faceFns-BK4r7Dxk.cjs");
|
|
8
|
+
const require_curveFns = require("./curveFns-GmFnqNo3.cjs");
|
|
9
9
|
const require_arrayAccess = require("./arrayAccess-e4H9cBfh.cjs");
|
|
10
|
-
const require_surfaceBuilders = require("./surfaceBuilders-
|
|
11
|
-
const require_helpers = require("./helpers-
|
|
10
|
+
const require_surfaceBuilders = require("./surfaceBuilders-Biqx51el.cjs");
|
|
11
|
+
const require_helpers = require("./helpers-BfkBvokP.cjs");
|
|
12
12
|
//#region src/2d/lib/definitions.ts
|
|
13
13
|
/** Type guard that checks whether a value is a `Point2D`. */
|
|
14
14
|
function isPoint2D(point) {
|
|
@@ -133,6 +133,21 @@ var BoundingBox2d = class {
|
|
|
133
133
|
}
|
|
134
134
|
};
|
|
135
135
|
//#endregion
|
|
136
|
+
//#region src/2d/lib/vectorOperations.ts
|
|
137
|
+
/**
|
|
138
|
+
* Normalize a 2D vector to unit length.
|
|
139
|
+
*
|
|
140
|
+
* Unlike the Layer 0 version (which returns [0,0] for zero-length vectors),
|
|
141
|
+
* this throws a BrepBugError — Layer 2 code should never pass zero-length vectors.
|
|
142
|
+
*
|
|
143
|
+
* @throws When the vector has near-zero length.
|
|
144
|
+
*/
|
|
145
|
+
var normalize2d = ([x, y]) => {
|
|
146
|
+
const result = require_helpers.normalize2d([x, y]);
|
|
147
|
+
if (result[0] === 0 && result[1] === 0) require_bug.bug("normalize2d", "Cannot normalize zero-length vector");
|
|
148
|
+
return result;
|
|
149
|
+
};
|
|
150
|
+
//#endregion
|
|
136
151
|
//#region src/2d/lib/curve2D.ts
|
|
137
152
|
/**
|
|
138
153
|
* Deserialize a curve from a string produced by {@link Curve2D.serialize}.
|
|
@@ -168,6 +183,10 @@ var Curve2D = class Curve2D {
|
|
|
168
183
|
delete() {
|
|
169
184
|
if (!this._deleted) {
|
|
170
185
|
this._deleted = true;
|
|
186
|
+
if (this._boundingBox) {
|
|
187
|
+
this._boundingBox.delete();
|
|
188
|
+
this._boundingBox = null;
|
|
189
|
+
}
|
|
171
190
|
if (typeof this._wrapped.delete === "function") {
|
|
172
191
|
require_shapeTypes.unregisterFromCleanup(this._wrapped);
|
|
173
192
|
this._wrapped.delete();
|
|
@@ -177,7 +196,12 @@ var Curve2D = class Curve2D {
|
|
|
177
196
|
[Symbol.dispose]() {
|
|
178
197
|
this.delete();
|
|
179
198
|
}
|
|
180
|
-
/**
|
|
199
|
+
/**
|
|
200
|
+
* Compute (and cache) the 2D bounding box of this curve.
|
|
201
|
+
*
|
|
202
|
+
* @remarks The returned box is owned by the curve and is disposed when the
|
|
203
|
+
* curve is deleted. Clone it if it must outlive the curve.
|
|
204
|
+
*/
|
|
181
205
|
get boundingBox() {
|
|
182
206
|
if (this._boundingBox) return this._boundingBox;
|
|
183
207
|
const kernel = require_shapeTypes.getKernel();
|
|
@@ -499,7 +523,7 @@ function make2dInerpolatedBSplineCurve(points, { tolerance = .001, smoothing = n
|
|
|
499
523
|
var make2dArcFromCenter = (startPoint, endPoint, center, longArc = false) => {
|
|
500
524
|
const midChord = require_helpers.scalarMultiply2d(require_helpers.add2d(startPoint, endPoint), .5);
|
|
501
525
|
const orientedRadius = require_helpers.distance2d(center, startPoint) * (longArc ? -1 : 1);
|
|
502
|
-
const midChordDir =
|
|
526
|
+
const midChordDir = normalize2d(require_helpers.subtract2d(midChord, center));
|
|
503
527
|
return make2dThreePointArc(startPoint, require_helpers.add2d(require_helpers.scalarMultiply2d(midChordDir, orientedRadius), center), endPoint);
|
|
504
528
|
};
|
|
505
529
|
//#endregion
|
|
@@ -1116,6 +1140,12 @@ Object.defineProperty(exports, "make2dThreePointArc", {
|
|
|
1116
1140
|
return make2dThreePointArc;
|
|
1117
1141
|
}
|
|
1118
1142
|
});
|
|
1143
|
+
Object.defineProperty(exports, "normalize2d", {
|
|
1144
|
+
enumerable: true,
|
|
1145
|
+
get: function() {
|
|
1146
|
+
return normalize2d;
|
|
1147
|
+
}
|
|
1148
|
+
});
|
|
1119
1149
|
Object.defineProperty(exports, "removeDuplicatePoints", {
|
|
1120
1150
|
enumerable: true,
|
|
1121
1151
|
get: function() {
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { K as getKernel, L as registerForCleanup, c as createEdge, p as createWire, q as getKernel2D, z as unregisterFromCleanup } from "./shapeTypes-t49f64Dx.js";
|
|
2
2
|
import { i as wasmIndex, n as bug } from "./bug-BdOHwn_e.js";
|
|
3
|
-
import {
|
|
3
|
+
import { E as ok, P as unwrap, d as validationError, g as err, n as computationError } from "./errors-MHLiNE-C.js";
|
|
4
4
|
import { r as RAD2DEG, t as DEG2RAD } from "./constants-ITRzCnCp.js";
|
|
5
5
|
import { r as toVec3 } from "./types-D24Y27N0.js";
|
|
6
|
-
import { r as makePlane } from "./planeOps-
|
|
7
|
-
import { _ as cast, h as uvCoordinates, i as faceGeomType, m as uvBounds, r as faceCenter } from "./faceFns-
|
|
8
|
-
import { p as getOrientation } from "./curveFns-
|
|
6
|
+
import { r as makePlane } from "./planeOps-CQahLrCx.js";
|
|
7
|
+
import { _ as cast, h as uvCoordinates, i as faceGeomType, m as uvBounds, r as faceCenter } from "./faceFns-DJj9Nb6T.js";
|
|
8
|
+
import { p as getOrientation } from "./curveFns-DX13KRh2.js";
|
|
9
9
|
import { n as getAtOrThrow, r as lastOrThrow, t as firstOrThrow } from "./arrayAccess-DrUGPADn.js";
|
|
10
|
-
import { r as makeFace } from "./surfaceBuilders-
|
|
11
|
-
import { _ as samePoint, b as subtract2d,
|
|
10
|
+
import { r as makeFace } from "./surfaceBuilders-BryY-i0F.js";
|
|
11
|
+
import { _ as samePoint, b as subtract2d, c as add2d, f as distance2d, p as normalize2d$1, t as getSingleFace, v as scalarMultiply2d } from "./helpers-Du_OdHuy.js";
|
|
12
12
|
//#region src/2d/lib/definitions.ts
|
|
13
13
|
/** Type guard that checks whether a value is a `Point2D`. */
|
|
14
14
|
function isPoint2D(point) {
|
|
@@ -133,6 +133,21 @@ var BoundingBox2d = class {
|
|
|
133
133
|
}
|
|
134
134
|
};
|
|
135
135
|
//#endregion
|
|
136
|
+
//#region src/2d/lib/vectorOperations.ts
|
|
137
|
+
/**
|
|
138
|
+
* Normalize a 2D vector to unit length.
|
|
139
|
+
*
|
|
140
|
+
* Unlike the Layer 0 version (which returns [0,0] for zero-length vectors),
|
|
141
|
+
* this throws a BrepBugError — Layer 2 code should never pass zero-length vectors.
|
|
142
|
+
*
|
|
143
|
+
* @throws When the vector has near-zero length.
|
|
144
|
+
*/
|
|
145
|
+
var normalize2d = ([x, y]) => {
|
|
146
|
+
const result = normalize2d$1([x, y]);
|
|
147
|
+
if (result[0] === 0 && result[1] === 0) bug("normalize2d", "Cannot normalize zero-length vector");
|
|
148
|
+
return result;
|
|
149
|
+
};
|
|
150
|
+
//#endregion
|
|
136
151
|
//#region src/2d/lib/curve2D.ts
|
|
137
152
|
/**
|
|
138
153
|
* Deserialize a curve from a string produced by {@link Curve2D.serialize}.
|
|
@@ -168,6 +183,10 @@ var Curve2D = class Curve2D {
|
|
|
168
183
|
delete() {
|
|
169
184
|
if (!this._deleted) {
|
|
170
185
|
this._deleted = true;
|
|
186
|
+
if (this._boundingBox) {
|
|
187
|
+
this._boundingBox.delete();
|
|
188
|
+
this._boundingBox = null;
|
|
189
|
+
}
|
|
171
190
|
if (typeof this._wrapped.delete === "function") {
|
|
172
191
|
unregisterFromCleanup(this._wrapped);
|
|
173
192
|
this._wrapped.delete();
|
|
@@ -177,7 +196,12 @@ var Curve2D = class Curve2D {
|
|
|
177
196
|
[Symbol.dispose]() {
|
|
178
197
|
this.delete();
|
|
179
198
|
}
|
|
180
|
-
/**
|
|
199
|
+
/**
|
|
200
|
+
* Compute (and cache) the 2D bounding box of this curve.
|
|
201
|
+
*
|
|
202
|
+
* @remarks The returned box is owned by the curve and is disposed when the
|
|
203
|
+
* curve is deleted. Clone it if it must outlive the curve.
|
|
204
|
+
*/
|
|
181
205
|
get boundingBox() {
|
|
182
206
|
if (this._boundingBox) return this._boundingBox;
|
|
183
207
|
const kernel = getKernel();
|
|
@@ -1001,4 +1025,4 @@ var Blueprint = class Blueprint {
|
|
|
1001
1025
|
}
|
|
1002
1026
|
};
|
|
1003
1027
|
//#endregion
|
|
1004
|
-
export { Curve2D as _, edgeToCurve as a,
|
|
1028
|
+
export { isPoint2D as S, Curve2D as _, edgeToCurve as a, BoundingBox2d as b, make2dCircle as c, make2dInerpolatedBSplineCurve as d, make2dSegmentCurve as f, approximateAsSvgCompatibleCurve as g, approximateAsBSpline as h, curvesAsEdgesOnPlane as i, make2dEllipse as l, make2dThreePointArc as m, asSVG as n, make2dArcFromCenter as o, make2dTangentArc as p, viewbox as r, make2dBezierCurve as s, Blueprint as t, make2dEllipseArc as u, deserializeCurve2D as v, removeDuplicatePoints as x, normalize2d as y };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { i as CompoundBlueprint } from "./blueprintSketcher-
|
|
3
|
-
import { t as Blueprint } from "./blueprint-
|
|
1
|
+
import { E as ok, d as validationError, g as err, t as BrepErrorCode } from "./errors-MHLiNE-C.js";
|
|
2
|
+
import { i as CompoundBlueprint } from "./blueprintSketcher-CKKxvxB-.js";
|
|
3
|
+
import { t as Blueprint } from "./blueprint-CAG6jseD.js";
|
|
4
4
|
//#region src/2d/lib/curve2dFns.ts
|
|
5
5
|
/**
|
|
6
6
|
* Return a reversed copy of the curve (non-mutating).
|
|
@@ -12,7 +12,12 @@ function reverseCurve(curve) {
|
|
|
12
12
|
cloned.reverse();
|
|
13
13
|
return cloned;
|
|
14
14
|
}
|
|
15
|
-
/**
|
|
15
|
+
/**
|
|
16
|
+
* Get the bounding box of a 2D curve.
|
|
17
|
+
*
|
|
18
|
+
* @remarks The box is borrowed from the curve's cache and is disposed with the
|
|
19
|
+
* curve. Clone it if it must outlive the curve.
|
|
20
|
+
*/
|
|
16
21
|
function curve2dBoundingBox(curve) {
|
|
17
22
|
return curve.boundingBox;
|
|
18
23
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
const require_errors = require("./errors-
|
|
2
|
-
const require_blueprintSketcher = require("./blueprintSketcher-
|
|
3
|
-
const require_blueprint = require("./blueprint-
|
|
1
|
+
const require_errors = require("./errors-RHkKO5bZ.cjs");
|
|
2
|
+
const require_blueprintSketcher = require("./blueprintSketcher-BNz6f36D.cjs");
|
|
3
|
+
const require_blueprint = require("./blueprint-BGcBMy3b.cjs");
|
|
4
4
|
//#region src/2d/lib/curve2dFns.ts
|
|
5
5
|
/**
|
|
6
6
|
* Return a reversed copy of the curve (non-mutating).
|
|
@@ -12,7 +12,12 @@ function reverseCurve(curve) {
|
|
|
12
12
|
cloned.reverse();
|
|
13
13
|
return cloned;
|
|
14
14
|
}
|
|
15
|
-
/**
|
|
15
|
+
/**
|
|
16
|
+
* Get the bounding box of a 2D curve.
|
|
17
|
+
*
|
|
18
|
+
* @remarks The box is borrowed from the curve's cache and is disposed with the
|
|
19
|
+
* curve. Clone it if it must outlive the curve.
|
|
20
|
+
*/
|
|
16
21
|
function curve2dBoundingBox(curve) {
|
|
17
22
|
return curve.boundingBox;
|
|
18
23
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
const require_shapeTypes = require("./shapeTypes-
|
|
1
|
+
const require_shapeTypes = require("./shapeTypes-CkcIL7zv.cjs");
|
|
2
2
|
const require_bug = require("./bug-O02CsAmt.cjs");
|
|
3
|
-
const require_errors = require("./errors-
|
|
3
|
+
const require_errors = require("./errors-RHkKO5bZ.cjs");
|
|
4
4
|
const require_constants = require("./constants-BOVyEYGH.cjs");
|
|
5
5
|
const require_arrayAccess = require("./arrayAccess-e4H9cBfh.cjs");
|
|
6
|
-
const require_helpers = require("./helpers-
|
|
7
|
-
const require_blueprint = require("./blueprint-
|
|
6
|
+
const require_helpers = require("./helpers-BfkBvokP.cjs");
|
|
7
|
+
const require_blueprint = require("./blueprint-BGcBMy3b.cjs");
|
|
8
8
|
//#region node_modules/flatqueue/index.js
|
|
9
9
|
/**
|
|
10
10
|
* @typedef {Float64ArrayConstructor | Float32ArrayConstructor |
|
|
@@ -587,7 +587,7 @@ var selfIntersections = (curve, precision = 1e-9) => {
|
|
|
587
587
|
//#endregion
|
|
588
588
|
//#region src/2d/lib/offset.ts
|
|
589
589
|
var offsetEndPoints = (firstPoint, lastPoint, offset) => {
|
|
590
|
-
const tangent =
|
|
590
|
+
const tangent = require_blueprint.normalize2d(require_helpers.subtract2d(lastPoint, firstPoint));
|
|
591
591
|
const normal = [tangent[1], -tangent[0]];
|
|
592
592
|
const offsetVec = [require_bug.wasmIndex(normal, 0) * offset, require_bug.wasmIndex(normal, 1) * offset];
|
|
593
593
|
return {
|
|
@@ -629,7 +629,7 @@ var make2dOffset = (curve, offset) => {
|
|
|
629
629
|
if (newRadius < 1e-10) {
|
|
630
630
|
const center = [cx, cy];
|
|
631
631
|
const offsetViaCenter = (point) => {
|
|
632
|
-
const [x, y] =
|
|
632
|
+
const [x, y] = require_blueprint.normalize2d(require_helpers.subtract2d(point, center));
|
|
633
633
|
return require_helpers.add2d(point, [orientedOffset * x, orientedOffset * y]);
|
|
634
634
|
};
|
|
635
635
|
return {
|
|
@@ -668,32 +668,99 @@ var make2dOffset = (curve, offset) => {
|
|
|
668
668
|
};
|
|
669
669
|
//#endregion
|
|
670
670
|
//#region src/2d/lib/customCorners.ts
|
|
671
|
+
/** Unwrap an intersection, discarding the common-segment curves the caller does not use. */
|
|
672
|
+
function intersectionPoints(first, second) {
|
|
673
|
+
const result = require_errors.unwrap(intersectCurves(first, second));
|
|
674
|
+
result.commonSegments.forEach((c) => {
|
|
675
|
+
c.delete();
|
|
676
|
+
});
|
|
677
|
+
return result.intersections;
|
|
678
|
+
}
|
|
679
|
+
/**
|
|
680
|
+
* Delete the split pieces the caller is discarding. `splitAt` returns the curve
|
|
681
|
+
* itself when there is nothing to split, so the source is never deleted here.
|
|
682
|
+
*/
|
|
683
|
+
function disposeSplitPieces(pieces, source, kept) {
|
|
684
|
+
pieces.forEach((piece) => {
|
|
685
|
+
if (piece !== source && piece !== kept) piece.delete();
|
|
686
|
+
});
|
|
687
|
+
}
|
|
688
|
+
/**
|
|
689
|
+
* Run `split` and, if it throws, dispose the pieces an earlier split already
|
|
690
|
+
* produced. Splitting the second curve of a corner can fail (its parameter may
|
|
691
|
+
* not project onto the offset), stranding the first curve's pieces.
|
|
692
|
+
*/
|
|
693
|
+
function splitOrDiscard(split, earlier) {
|
|
694
|
+
try {
|
|
695
|
+
return split();
|
|
696
|
+
} catch (e) {
|
|
697
|
+
disposeSplitPieces(earlier.pieces, earlier.source);
|
|
698
|
+
throw e;
|
|
699
|
+
}
|
|
700
|
+
}
|
|
701
|
+
/**
|
|
702
|
+
* Build the corner result, disposing the trimmed halves if the connecting curve
|
|
703
|
+
* cannot be built. They are unreachable once the error propagates.
|
|
704
|
+
*/
|
|
705
|
+
function discardTrimsOnError(firstCurve, secondCurve, first, second, build) {
|
|
706
|
+
try {
|
|
707
|
+
return build();
|
|
708
|
+
} catch (e) {
|
|
709
|
+
if (first !== firstCurve) first.delete();
|
|
710
|
+
if (second !== secondCurve) second.delete();
|
|
711
|
+
throw e;
|
|
712
|
+
}
|
|
713
|
+
}
|
|
671
714
|
function removeCorner(firstCurve, secondCurve, radius) {
|
|
672
715
|
const sinAngle = require_helpers.crossProduct2d(firstCurve.tangentAt(1), secondCurve.tangentAt(0));
|
|
673
716
|
if (Math.abs(sinAngle) < 1e-10) return null;
|
|
674
717
|
const offset = Math.abs(radius) * (sinAngle > 0 ? -1 : 1);
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
718
|
+
let firstOffset = null;
|
|
719
|
+
let secondOffset = null;
|
|
720
|
+
try {
|
|
721
|
+
firstOffset = make2dOffset(firstCurve, offset);
|
|
722
|
+
secondOffset = make2dOffset(secondCurve, offset);
|
|
723
|
+
if (!(firstOffset instanceof require_blueprint.Curve2D) || !(secondOffset instanceof require_blueprint.Curve2D)) return null;
|
|
724
|
+
const firstOffsetCurve = firstOffset;
|
|
725
|
+
const secondOffsetCurve = secondOffset;
|
|
726
|
+
const intersectionResult = intersectCurves(firstOffsetCurve, secondOffsetCurve, 1e-9);
|
|
727
|
+
if (!require_errors.isOk(intersectionResult)) return null;
|
|
728
|
+
intersectionResult.value.commonSegments.forEach((c) => {
|
|
729
|
+
c.delete();
|
|
730
|
+
});
|
|
731
|
+
const potentialCenter = intersectionResult.value.intersections.at(-1);
|
|
732
|
+
if (!require_blueprint.isPoint2D(potentialCenter)) return null;
|
|
733
|
+
const center = potentialCenter;
|
|
734
|
+
const splitForFillet = (curve, offsetCurve) => {
|
|
735
|
+
const [x, y] = offsetCurve.tangentAt(center);
|
|
736
|
+
const normal = require_blueprint.normalize2d([-y, x]);
|
|
737
|
+
const splitPoint = require_helpers.add2d(center, require_helpers.scalarMultiply2d(normal, offset));
|
|
738
|
+
const splitParam = require_errors.unwrap(curve.parameter(splitPoint, 1e-6));
|
|
739
|
+
return curve.splitAt([splitParam]);
|
|
740
|
+
};
|
|
741
|
+
const firstSplit = splitForFillet(firstCurve, firstOffsetCurve);
|
|
742
|
+
const secondSplit = splitOrDiscard(() => splitForFillet(secondCurve, secondOffsetCurve), {
|
|
743
|
+
pieces: firstSplit,
|
|
744
|
+
source: firstCurve
|
|
745
|
+
});
|
|
746
|
+
const first = firstSplit[0];
|
|
747
|
+
const second = secondSplit[1];
|
|
748
|
+
if (!first || !second) {
|
|
749
|
+
disposeSplitPieces(firstSplit, firstCurve);
|
|
750
|
+
disposeSplitPieces(secondSplit, secondCurve);
|
|
751
|
+
return null;
|
|
752
|
+
}
|
|
753
|
+
disposeSplitPieces(firstSplit, firstCurve, first);
|
|
754
|
+
disposeSplitPieces(secondSplit, secondCurve, second);
|
|
755
|
+
return {
|
|
756
|
+
first,
|
|
757
|
+
second,
|
|
758
|
+
center
|
|
759
|
+
};
|
|
760
|
+
} finally {
|
|
761
|
+
if (firstOffset instanceof require_blueprint.Curve2D) firstOffset.delete();
|
|
762
|
+
if (secondOffset instanceof require_blueprint.Curve2D) secondOffset.delete();
|
|
763
|
+
}
|
|
697
764
|
}
|
|
698
765
|
/**
|
|
699
766
|
* Insert a circular fillet arc at the corner between two curves.
|
|
@@ -711,11 +778,11 @@ function filletCurves(firstCurve, secondCurve, radius) {
|
|
|
711
778
|
const cornerRemoved = removeCorner(firstCurve, secondCurve, radius);
|
|
712
779
|
if (!cornerRemoved) return [firstCurve, secondCurve];
|
|
713
780
|
const { first, second, center } = cornerRemoved;
|
|
714
|
-
return [
|
|
781
|
+
return discardTrimsOnError(firstCurve, secondCurve, first, second, () => [
|
|
715
782
|
first,
|
|
716
783
|
require_blueprint.make2dArcFromCenter(first.lastPoint, second.firstPoint, center),
|
|
717
784
|
second
|
|
718
|
-
];
|
|
785
|
+
]);
|
|
719
786
|
}
|
|
720
787
|
/**
|
|
721
788
|
* Insert a straight chamfer segment at the corner between two curves.
|
|
@@ -727,11 +794,11 @@ function chamferCurves(firstCurve, secondCurve, radius) {
|
|
|
727
794
|
const cornerRemoved = removeCorner(firstCurve, secondCurve, radius);
|
|
728
795
|
if (!cornerRemoved) return [firstCurve, secondCurve];
|
|
729
796
|
const { first, second } = cornerRemoved;
|
|
730
|
-
return [
|
|
797
|
+
return discardTrimsOnError(firstCurve, secondCurve, first, second, () => [
|
|
731
798
|
first,
|
|
732
799
|
require_blueprint.make2dSegmentCurve(first.lastPoint, second.firstPoint),
|
|
733
800
|
second
|
|
734
|
-
];
|
|
801
|
+
]);
|
|
735
802
|
}
|
|
736
803
|
/**
|
|
737
804
|
* Insert a dogbone fillet at an inner corner for CNC milling clearance.
|
|
@@ -740,34 +807,58 @@ function chamferCurves(firstCurve, secondCurve, radius) {
|
|
|
740
807
|
* round end-mill of the given radius can fully reach the corner.
|
|
741
808
|
*/
|
|
742
809
|
function dogboneFilletCurves(firstCurve, secondCurve, radius) {
|
|
743
|
-
const sinAngle = require_helpers.crossProduct2d(
|
|
810
|
+
const sinAngle = require_helpers.crossProduct2d(require_blueprint.normalize2d(firstCurve.tangentAt(1)), require_blueprint.normalize2d(secondCurve.tangentAt(0)));
|
|
744
811
|
const a = Math.asin(sinAngle);
|
|
745
812
|
if (Math.abs(sinAngle) < 1e-10) return [firstCurve, secondCurve];
|
|
746
813
|
const orientationCorrection = sinAngle > 0 ? -1 : 1;
|
|
747
814
|
const offset = Math.abs(radius) * Math.sin(a / 2) * orientationCorrection;
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
const intersectionResult2 = intersectCurves(firstOffset, secondOffset, 1e-9);
|
|
752
|
-
if (!require_errors.isOk(intersectionResult2)) return [firstCurve, secondCurve];
|
|
753
|
-
const potentialCenter = intersectionResult2.value.intersections.at(-1);
|
|
754
|
-
if (!require_blueprint.isPoint2D(potentialCenter)) return [firstCurve, secondCurve];
|
|
755
|
-
const circle = require_blueprint.make2dCircle(radius, potentialCenter);
|
|
756
|
-
const firstInt = require_errors.unwrap(intersectCurves(firstCurve, circle)).intersections[0];
|
|
757
|
-
const secondInt = require_errors.unwrap(intersectCurves(secondCurve, circle)).intersections.at(-1);
|
|
758
|
-
if (!firstInt || !secondInt) return [firstCurve, secondCurve];
|
|
759
|
-
const firstSplit = firstCurve.splitAt([firstInt]);
|
|
760
|
-
const secondSplit = secondCurve.splitAt([secondInt]);
|
|
761
|
-
const firstPart = require_bug.wasmIndex(firstSplit, 0);
|
|
762
|
-
const secondPart = require_bug.wasmIndex(secondSplit, secondSplit.length - 1);
|
|
815
|
+
let firstOffset = null;
|
|
816
|
+
let secondOffset = null;
|
|
817
|
+
let circle = null;
|
|
763
818
|
try {
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
];
|
|
769
|
-
|
|
770
|
-
|
|
819
|
+
firstOffset = make2dOffset(firstCurve, offset);
|
|
820
|
+
secondOffset = make2dOffset(secondCurve, offset);
|
|
821
|
+
if (!(firstOffset instanceof require_blueprint.Curve2D) || !(secondOffset instanceof require_blueprint.Curve2D)) return [firstCurve, secondCurve];
|
|
822
|
+
const intersectionResult2 = intersectCurves(firstOffset, secondOffset, 1e-9);
|
|
823
|
+
if (!require_errors.isOk(intersectionResult2)) return [firstCurve, secondCurve];
|
|
824
|
+
intersectionResult2.value.commonSegments.forEach((c) => {
|
|
825
|
+
c.delete();
|
|
826
|
+
});
|
|
827
|
+
const potentialCenter = intersectionResult2.value.intersections.at(-1);
|
|
828
|
+
if (!require_blueprint.isPoint2D(potentialCenter)) return [firstCurve, secondCurve];
|
|
829
|
+
circle = require_blueprint.make2dCircle(radius, potentialCenter);
|
|
830
|
+
const firstInt = intersectionPoints(firstCurve, circle)[0];
|
|
831
|
+
const secondInt = intersectionPoints(secondCurve, circle).at(-1);
|
|
832
|
+
if (!firstInt || !secondInt) return [firstCurve, secondCurve];
|
|
833
|
+
const firstSplit = firstCurve.splitAt([firstInt]);
|
|
834
|
+
const secondSplit = splitOrDiscard(() => secondCurve.splitAt([secondInt]), {
|
|
835
|
+
pieces: firstSplit,
|
|
836
|
+
source: firstCurve
|
|
837
|
+
});
|
|
838
|
+
const firstPart = firstSplit[0];
|
|
839
|
+
const secondPart = secondSplit[secondSplit.length - 1];
|
|
840
|
+
if (!firstPart || !secondPart) {
|
|
841
|
+
disposeSplitPieces(firstSplit, firstCurve);
|
|
842
|
+
disposeSplitPieces(secondSplit, secondCurve);
|
|
843
|
+
return [firstCurve, secondCurve];
|
|
844
|
+
}
|
|
845
|
+
disposeSplitPieces(firstSplit, firstCurve, firstPart);
|
|
846
|
+
disposeSplitPieces(secondSplit, secondCurve, secondPart);
|
|
847
|
+
try {
|
|
848
|
+
return [
|
|
849
|
+
firstPart,
|
|
850
|
+
require_blueprint.make2dThreePointArc(firstPart.lastPoint, firstCurve.lastPoint, secondPart.firstPoint),
|
|
851
|
+
secondPart
|
|
852
|
+
];
|
|
853
|
+
} catch {
|
|
854
|
+
if (firstPart !== firstCurve) firstPart.delete();
|
|
855
|
+
if (secondPart !== secondCurve) secondPart.delete();
|
|
856
|
+
return [firstCurve, secondCurve];
|
|
857
|
+
}
|
|
858
|
+
} finally {
|
|
859
|
+
if (firstOffset instanceof require_blueprint.Curve2D) firstOffset.delete();
|
|
860
|
+
if (secondOffset instanceof require_blueprint.Curve2D) secondOffset.delete();
|
|
861
|
+
circle?.delete();
|
|
771
862
|
}
|
|
772
863
|
}
|
|
773
864
|
//#endregion
|
|
@@ -1121,7 +1212,7 @@ function makeEllipseArcFromSvgParams(startUV, endUV, majorRadius, minorRadius, r
|
|
|
1121
1212
|
const convertAxis = (ax) => require_helpers.distance2d(convertToUV(ax));
|
|
1122
1213
|
const r1 = convertAxis(require_helpers.polarToCartesian(majorRadius, radRotationAngle));
|
|
1123
1214
|
const r2 = convertAxis(require_helpers.polarToCartesian(minorRadius, radRotationAngle + Math.PI / 2));
|
|
1124
|
-
const xDir =
|
|
1215
|
+
const xDir = require_blueprint.normalize2d(convertToUV(require_helpers.rotate2d([1, 0], radRotationAngle)));
|
|
1125
1216
|
const [, newRotationAngle] = require_helpers.cartesianToPolar(xDir);
|
|
1126
1217
|
const { cx, cy, startAngle, endAngle, clockwise, rx, ry } = convertSvgEllipseParams(startUV, endUV, r1, r2, newRotationAngle, longAxis, sweep);
|
|
1127
1218
|
const arc = require_blueprint.make2dEllipseArc(rx, ry, clockwise ? startAngle : endAngle, clockwise ? endAngle : startAngle, [cx, cy], xDir);
|
|
@@ -1213,6 +1304,16 @@ var cornerModeFns = {
|
|
|
1213
1304
|
dogbone: dogboneFilletCurves,
|
|
1214
1305
|
fillet: filletCurves
|
|
1215
1306
|
};
|
|
1307
|
+
/**
|
|
1308
|
+
* Delete the curves a corner function consumed. Corner functions return their
|
|
1309
|
+
* inputs untouched when they bail (collinear curves, failed offset), so only
|
|
1310
|
+
* the ones absent from the result are ours to free.
|
|
1311
|
+
*/
|
|
1312
|
+
function disposeConsumedCurves(consumed, produced) {
|
|
1313
|
+
consumed.forEach((curve) => {
|
|
1314
|
+
if (!produced.includes(curve)) curve.delete();
|
|
1315
|
+
});
|
|
1316
|
+
}
|
|
1216
1317
|
function buildCornerFunction(radius, mode) {
|
|
1217
1318
|
if (typeof radius === "function") return radius;
|
|
1218
1319
|
const makeFn = cornerModeFns[mode];
|
|
@@ -1295,7 +1396,9 @@ var BaseSketcher2d = class {
|
|
|
1295
1396
|
}
|
|
1296
1397
|
const previousCurve = this.pendingCurves.pop();
|
|
1297
1398
|
if (!previousCurve) require_bug.bug("Sketcher2d.saveCurve", "No previous curve available for custom corner");
|
|
1298
|
-
this.
|
|
1399
|
+
const cornered = this._nextCorner(previousCurve, curve);
|
|
1400
|
+
disposeConsumedCurves([previousCurve, curve], cornered);
|
|
1401
|
+
this.pendingCurves.push(...cornered);
|
|
1299
1402
|
this._nextCorner = null;
|
|
1300
1403
|
}
|
|
1301
1404
|
/** Draw a straight line to an absolute 2D point. */
|
|
@@ -1335,7 +1438,7 @@ var BaseSketcher2d = class {
|
|
|
1335
1438
|
/** Draw a line tangent to the previous curve, extending by the given distance. */
|
|
1336
1439
|
tangentLine(distance) {
|
|
1337
1440
|
const previousCurve = this._requireLastCurve("Sketcher2d.tangentLine", "sketch a tangent line");
|
|
1338
|
-
const direction =
|
|
1441
|
+
const direction = require_blueprint.normalize2d(this._convertFromUV(previousCurve.tangentAt(1)));
|
|
1339
1442
|
return this.line(direction[0] * distance, direction[1] * distance);
|
|
1340
1443
|
}
|
|
1341
1444
|
/** Draw a circular arc passing through a mid-point to an absolute end point. */
|
|
@@ -1445,12 +1548,12 @@ var BaseSketcher2d = class {
|
|
|
1445
1548
|
if (startTangent) startPoleDirection = startTangent;
|
|
1446
1549
|
else if (!previousCurve) startPoleDirection = [1, 0];
|
|
1447
1550
|
else startPoleDirection = this._convertFromUV(previousCurve.tangentAt(1));
|
|
1448
|
-
startPoleDirection =
|
|
1551
|
+
startPoleDirection = require_blueprint.normalize2d(startPoleDirection);
|
|
1449
1552
|
const startControl = [this.pointer[0] + startPoleDirection[0] * startFactor * defaultDistance, this.pointer[1] + startPoleDirection[1] * startFactor * defaultDistance];
|
|
1450
1553
|
let endPoleDirection;
|
|
1451
1554
|
if (endTangent === "symmetric") endPoleDirection = [-startPoleDirection[0], -startPoleDirection[1]];
|
|
1452
1555
|
else endPoleDirection = endTangent;
|
|
1453
|
-
endPoleDirection =
|
|
1556
|
+
endPoleDirection = require_blueprint.normalize2d(endPoleDirection);
|
|
1454
1557
|
const endControl = [end[0] - endPoleDirection[0] * endFactor * defaultDistance, end[1] - endPoleDirection[1] * endFactor * defaultDistance];
|
|
1455
1558
|
return this.cubicBezierCurveTo(end, startControl, endControl);
|
|
1456
1559
|
}
|
|
@@ -1469,7 +1572,9 @@ var BaseSketcher2d = class {
|
|
|
1469
1572
|
const previousCurve = this.pendingCurves.pop();
|
|
1470
1573
|
const curve = this.pendingCurves.shift();
|
|
1471
1574
|
if (!previousCurve || !curve) require_bug.bug("Sketcher2d._customCornerLastWithFirst", "Not enough curves to close and fillet");
|
|
1472
|
-
|
|
1575
|
+
const cornered = buildCornerFunction(radius, mode)(previousCurve, curve);
|
|
1576
|
+
disposeConsumedCurves([previousCurve, curve], cornered);
|
|
1577
|
+
this.pendingCurves.push(...cornered);
|
|
1473
1578
|
}
|
|
1474
1579
|
_closeSketch() {
|
|
1475
1580
|
if (!require_helpers.samePoint(this.pointer, this.firstPoint)) this.lineTo(this.firstPoint);
|