brepjs 8.8.2 → 8.8.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/curves.d.ts.map +1 -1
- package/dist/2d/lib/Curve2D.d.ts.map +1 -1
- package/dist/2d/lib/approximations.d.ts.map +1 -1
- package/dist/2d/lib/makeCurves.d.ts.map +1 -1
- package/dist/2d/lib/ocWrapper.d.ts.map +1 -1
- package/dist/2d.cjs +2 -2
- package/dist/2d.js +3 -3
- package/dist/Blueprint-BmFJ4caY.cjs +1439 -0
- package/dist/Blueprint-DsoGiJNJ.js +1440 -0
- package/dist/{boolean2D-q5FOdOQW.cjs → boolean2D-BQk8LNmZ.cjs} +212 -127
- package/dist/{boolean2D-Dgnuy63w.js → boolean2D-D5O0F3J8.js} +212 -127
- package/dist/{booleanFns-CFit7JYt.cjs → booleanFns-CVM3dOTP.cjs} +210 -130
- package/dist/{booleanFns--Orezl-b.js → booleanFns-DOyKxL7q.js} +210 -130
- package/dist/brepjs.cjs +457 -304
- package/dist/brepjs.js +551 -398
- package/dist/core/disposal.d.ts +44 -3
- package/dist/core/disposal.d.ts.map +1 -1
- package/dist/core/geometryHelpers.d.ts.map +1 -1
- package/dist/core/kernelCall.d.ts +20 -0
- package/dist/core/kernelCall.d.ts.map +1 -1
- package/dist/core/memory.d.ts +1 -1
- package/dist/core/memory.d.ts.map +1 -1
- package/dist/core.cjs +4 -1
- package/dist/core.d.ts +1 -1
- package/dist/core.d.ts.map +1 -1
- package/dist/core.js +11 -8
- package/dist/{cornerFinder-KNTFoGrm.js → cornerFinder-DH6EwYfL.js} +1 -1
- package/dist/{cornerFinder-v4un1Fr9.cjs → cornerFinder-XAV2ywVS.cjs} +1 -1
- package/dist/curveFns-BHRYwxBM.js +281 -0
- package/dist/{curveFns-6ovDM_sR.cjs → curveFns-BsAHC3Qv.cjs} +137 -36
- package/dist/{drawFns-WgXeXHH1.cjs → drawFns-CsmUF97U.cjs} +181 -101
- package/dist/{drawFns-XwroLxdb.js → drawFns-hD05g0ZQ.js} +181 -101
- package/dist/faceFns-DNQss51F.cjs +358 -0
- package/dist/faceFns-q5CR9pOW.js +359 -0
- package/dist/{helpers-CRfqaW0Y.cjs → helpers-aylLv0_I.cjs} +13 -10
- package/dist/{helpers-CtBCzEqs.js → helpers-tNdaX01G.js} +13 -10
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/io/importFns.d.ts.map +1 -1
- package/dist/io.cjs +131 -63
- package/dist/io.js +131 -63
- package/dist/loft-CjEEqz2P.cjs +530 -0
- package/dist/loft-DTRcYrq2.js +531 -0
- package/dist/measurement-B6_cxjpw.cjs +200 -0
- package/dist/measurement-BXqFvcGh.js +201 -0
- package/dist/measurement.cjs +1 -1
- package/dist/measurement.js +1 -1
- package/dist/{meshFns-CPNNlpbw.cjs → meshFns-CTc1CRkF.cjs} +1 -1
- package/dist/{meshFns-DAmWVyEp.js → meshFns-DDFl7gLN.js} +1 -1
- package/dist/operations/exporterFns.d.ts.map +1 -1
- package/dist/operations/exporterUtils.d.ts +3 -3
- package/dist/operations/exporterUtils.d.ts.map +1 -1
- package/dist/operations/exporters.d.ts.map +1 -1
- package/dist/operations/extrude.d.ts.map +1 -1
- package/dist/operations/extrudeFns.d.ts.map +1 -1
- package/dist/operations/loft.d.ts.map +1 -1
- package/dist/operations/multiSweepFns.d.ts.map +1 -1
- package/dist/{operations-vN0tcoaU.js → operations-jRE2QbPo.js} +261 -166
- package/dist/{operations-BQ25CPI8.cjs → operations-pxjbW4Er.cjs} +261 -166
- package/dist/operations.cjs +2 -2
- package/dist/operations.js +2 -2
- package/dist/query/shapeDistanceFilter.d.ts.map +1 -1
- package/dist/query.cjs +66 -14
- package/dist/query.js +67 -15
- package/dist/{shapeFns-C785aeVn.cjs → shapeFns-D4CRxxmF.cjs} +61 -7
- package/dist/{shapeFns-ClpALED4.js → shapeFns-DNnBK8fG.js} +61 -7
- package/dist/{shapeTypes-DnwCo942.js → shapeTypes-Bi_9RZa2.js} +50 -19
- package/dist/{shapeTypes-CIijJxCz.cjs → shapeTypes-CWuX602K.cjs} +32 -1
- package/dist/sketching/CompoundSketch.d.ts.map +1 -1
- package/dist/sketching/Sketch.d.ts.map +1 -1
- package/dist/sketching/Sketcher.d.ts.map +1 -1
- package/dist/sketching/Sketcher2d.d.ts.map +1 -1
- package/dist/sketching/cannedSketches.d.ts.map +1 -1
- package/dist/sketching/draw.d.ts.map +1 -1
- package/dist/sketching.cjs +2 -2
- package/dist/sketching.js +2 -2
- package/dist/surfaceBuilders-CLal3WlK.cjs +429 -0
- package/dist/surfaceBuilders-W9Y25CIb.js +430 -0
- package/dist/topology/curveBuilders.d.ts.map +1 -1
- package/dist/topology/shapeFns.d.ts.map +1 -1
- package/dist/topology/solidBuilders.d.ts.map +1 -1
- package/dist/topology/surfaceBuilders.d.ts.map +1 -1
- package/dist/{topology-CqyxpmEh.js → topology-CMM6vAzx.js} +6 -6
- package/dist/{topology-zG8maSDK.cjs → topology-CNw-wsmG.cjs} +6 -6
- package/dist/topology.cjs +6 -6
- package/dist/topology.js +6 -6
- package/package.json +4 -1
- package/dist/Blueprint-BmbNUnGI.cjs +0 -1185
- package/dist/Blueprint-C-JJkkwL.js +0 -1186
- package/dist/curveFns-BhQECv8e.js +0 -180
- package/dist/faceFns-3PDjBeW7.js +0 -272
- package/dist/faceFns-CxaLWOjc.cjs +0 -271
- package/dist/loft-CVb-IjEI.cjs +0 -372
- package/dist/loft-DMFjK6lk.js +0 -373
- package/dist/measurement-CecYIt3s.cjs +0 -134
- package/dist/measurement-DHDLAH7-.js +0 -135
- package/dist/surfaceBuilders-CC0ZQGix.cjs +0 -289
- package/dist/surfaceBuilders-CrJtFu2a.js +0 -290
|
@@ -1,15 +1,60 @@
|
|
|
1
|
+
var __knownSymbol = (name, symbol) => (symbol = Symbol[name]) ? symbol : /* @__PURE__ */ Symbol.for("Symbol." + name);
|
|
2
|
+
var __typeError = (msg) => {
|
|
3
|
+
throw TypeError(msg);
|
|
4
|
+
};
|
|
5
|
+
var __using = (stack, value, async) => {
|
|
6
|
+
if (value != null) {
|
|
7
|
+
if (typeof value !== "object" && typeof value !== "function") __typeError("Object expected");
|
|
8
|
+
var dispose, inner;
|
|
9
|
+
if (async) dispose = value[__knownSymbol("asyncDispose")];
|
|
10
|
+
if (dispose === void 0) {
|
|
11
|
+
dispose = value[__knownSymbol("dispose")];
|
|
12
|
+
if (async) inner = dispose;
|
|
13
|
+
}
|
|
14
|
+
if (typeof dispose !== "function") __typeError("Object not disposable");
|
|
15
|
+
if (inner) dispose = function() {
|
|
16
|
+
try {
|
|
17
|
+
inner.call(this);
|
|
18
|
+
} catch (e) {
|
|
19
|
+
return Promise.reject(e);
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
stack.push([async, dispose, value]);
|
|
23
|
+
} else if (async) {
|
|
24
|
+
stack.push([async]);
|
|
25
|
+
}
|
|
26
|
+
return value;
|
|
27
|
+
};
|
|
28
|
+
var __callDispose = (stack, error, hasError) => {
|
|
29
|
+
var E = typeof SuppressedError === "function" ? SuppressedError : function(e, s, m, _) {
|
|
30
|
+
return _ = Error(m), _.name = "SuppressedError", _.error = e, _.suppressed = s, _;
|
|
31
|
+
};
|
|
32
|
+
var fail = (e) => error = hasError ? new E(e, error, "An error was suppressed during disposal") : (hasError = true, e);
|
|
33
|
+
var next = (it) => {
|
|
34
|
+
while (it = stack.pop()) {
|
|
35
|
+
try {
|
|
36
|
+
var result = it[1] && it[1].call(it[2]);
|
|
37
|
+
if (it[0]) return Promise.resolve(result).then(next, (e) => (fail(e), next()));
|
|
38
|
+
} catch (e) {
|
|
39
|
+
fail(e);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
if (hasError) throw error;
|
|
43
|
+
};
|
|
44
|
+
return next();
|
|
45
|
+
};
|
|
1
46
|
import { a as createPlane } from "./vectors-2lOjaa8N.js";
|
|
2
47
|
import { l as ok, e as err, b as computationError, u as unwrap, g as isOk } from "./errors-DJ92ermb.js";
|
|
3
|
-
import { d as downcast, u as uvBounds, p as pointOnSurface, n as normalAt } from "./faceFns-
|
|
48
|
+
import { d as downcast, u as uvBounds, p as pointOnSurface, n as normalAt } from "./faceFns-q5CR9pOW.js";
|
|
4
49
|
import { g as getKernel, a as toVec3 } from "./occtBoundary-DvBywHyU.js";
|
|
5
50
|
import { n as vecScale, j as vecNormalize, b as vecCross, D as DEG2RAD, R as RAD2DEG } from "./vecOps-ZDdZWbwT.js";
|
|
6
|
-
import { r as revolution, c as complexExtrude, t as twistExtrude, b as basicFaceExtrusion, g as genericSweep, l as loft } from "./loft-
|
|
7
|
-
import {
|
|
8
|
-
import { d as curveStartPoint, c as curveTangentAt, e as curveIsClosed } from "./curveFns-
|
|
9
|
-
import { m as makeFace, l as makeNewFaceWithinFace, b as assembleWire, z as zip } from "./surfaceBuilders-
|
|
51
|
+
import { r as revolution, c as complexExtrude, t as twistExtrude, b as basicFaceExtrusion, g as genericSweep, l as loft } from "./loft-DTRcYrq2.js";
|
|
52
|
+
import { D as DisposalScope, s as createFace, q as createWire, r as createEdge } from "./shapeTypes-Bi_9RZa2.js";
|
|
53
|
+
import { d as curveStartPoint, c as curveTangentAt, e as curveIsClosed } from "./curveFns-BHRYwxBM.js";
|
|
54
|
+
import { m as makeFace, l as makeNewFaceWithinFace, b as assembleWire, z as zip } from "./surfaceBuilders-W9Y25CIb.js";
|
|
10
55
|
import { bug } from "./result.js";
|
|
11
|
-
import { s as samePoint$1, n as normalize2d, e as subtract2d, c as add2d, i as crossProduct2d, b as scalarMultiply2d, f as polarToCartesian, r as rotate2d, j as cartesianToPolar, d as distance2d, p as polarAngle2d, k as PRECISION_INTERSECTION } from "./helpers-
|
|
12
|
-
import { C as Curve2D, a as make2dSegmentCurve, j as approximateAsBSpline, b as make2dArcFromCenter, k as isPoint2D, g as make2dCircle, l as make2dThreePointArc, d as BoundingBox2d, v as viewbox, n as asSVG, B as Blueprint, o as make2dEllipseArc, p as make2dTangentArc, q as make2dBezierCurve, r as axis2d, s as removeDuplicatePoints } from "./Blueprint-
|
|
56
|
+
import { s as samePoint$1, n as normalize2d, e as subtract2d, c as add2d, i as crossProduct2d, b as scalarMultiply2d, f as polarToCartesian, r as rotate2d, j as cartesianToPolar, d as distance2d, p as polarAngle2d, k as PRECISION_INTERSECTION } from "./helpers-tNdaX01G.js";
|
|
57
|
+
import { C as Curve2D, a as make2dSegmentCurve, j as approximateAsBSpline, b as make2dArcFromCenter, k as isPoint2D, g as make2dCircle, l as make2dThreePointArc, d as BoundingBox2d, v as viewbox, n as asSVG, B as Blueprint, o as make2dEllipseArc, p as make2dTangentArc, q as make2dBezierCurve, r as axis2d, s as removeDuplicatePoints } from "./Blueprint-DsoGiJNJ.js";
|
|
13
58
|
function* pointsIteration(intersector) {
|
|
14
59
|
const nPoints = intersector.NbPoints();
|
|
15
60
|
if (!nPoints) return;
|
|
@@ -19,56 +64,77 @@ function* pointsIteration(intersector) {
|
|
|
19
64
|
}
|
|
20
65
|
}
|
|
21
66
|
function* commonSegmentsIteration(intersector) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
67
|
+
var _stack = [];
|
|
68
|
+
try {
|
|
69
|
+
const nSegments = intersector.NbSegments();
|
|
70
|
+
if (!nSegments) return;
|
|
71
|
+
const oc = getKernel().oc;
|
|
72
|
+
const scope = __using(_stack, new DisposalScope());
|
|
73
|
+
for (let i = 1; i <= nSegments; i++) {
|
|
74
|
+
const h1 = new oc.Handle_Geom2d_Curve_1();
|
|
75
|
+
const h2 = scope.register(new oc.Handle_Geom2d_Curve_1());
|
|
76
|
+
try {
|
|
77
|
+
intersector.Segment(i, h1, h2);
|
|
78
|
+
} catch {
|
|
79
|
+
continue;
|
|
80
|
+
}
|
|
81
|
+
yield new Curve2D(h1);
|
|
33
82
|
}
|
|
34
|
-
|
|
83
|
+
} catch (_) {
|
|
84
|
+
var _error = _, _hasError = true;
|
|
85
|
+
} finally {
|
|
86
|
+
__callDispose(_stack, _error, _hasError);
|
|
35
87
|
}
|
|
36
88
|
}
|
|
37
89
|
const intersectCurves = (first, second, precision = 1e-9) => {
|
|
38
|
-
|
|
39
|
-
return ok({ intersections: [], commonSegments: [], commonSegmentsPoints: [] });
|
|
40
|
-
const oc = getKernel().oc;
|
|
41
|
-
const r = gcWithScope();
|
|
42
|
-
const intersector = r(new oc.Geom2dAPI_InterCurveCurve_1());
|
|
43
|
-
let intersections;
|
|
44
|
-
let commonSegments;
|
|
90
|
+
var _stack = [];
|
|
45
91
|
try {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
92
|
+
if (first.boundingBox.isOut(second.boundingBox))
|
|
93
|
+
return ok({ intersections: [], commonSegments: [], commonSegmentsPoints: [] });
|
|
94
|
+
const oc = getKernel().oc;
|
|
95
|
+
const scope = __using(_stack, new DisposalScope());
|
|
96
|
+
const intersector = scope.register(new oc.Geom2dAPI_InterCurveCurve_1());
|
|
97
|
+
let intersections;
|
|
98
|
+
let commonSegments;
|
|
99
|
+
try {
|
|
100
|
+
intersector.Init_1(first.wrapped, second.wrapped, precision);
|
|
101
|
+
intersections = Array.from(pointsIteration(intersector));
|
|
102
|
+
commonSegments = Array.from(commonSegmentsIteration(intersector));
|
|
103
|
+
} catch (e) {
|
|
104
|
+
return err(computationError("INTERSECTION_FAILED", "Intersections failed between curves", e));
|
|
105
|
+
}
|
|
106
|
+
const segmentsAsPoints = commonSegments.filter((c) => samePoint$1(c.firstPoint, c.lastPoint, precision)).map((c) => c.firstPoint);
|
|
107
|
+
if (segmentsAsPoints.length) {
|
|
108
|
+
intersections.push(...segmentsAsPoints);
|
|
109
|
+
commonSegments = commonSegments.filter((c) => !samePoint$1(c.firstPoint, c.lastPoint, precision));
|
|
110
|
+
}
|
|
111
|
+
const commonSegmentsPoints = commonSegments.flatMap((c) => [c.firstPoint, c.lastPoint]);
|
|
112
|
+
return ok({ intersections, commonSegments, commonSegmentsPoints });
|
|
113
|
+
} catch (_) {
|
|
114
|
+
var _error = _, _hasError = true;
|
|
115
|
+
} finally {
|
|
116
|
+
__callDispose(_stack, _error, _hasError);
|
|
117
|
+
}
|
|
59
118
|
};
|
|
60
119
|
const selfIntersections = (curve, precision = 1e-9) => {
|
|
61
|
-
|
|
62
|
-
const r = gcWithScope();
|
|
63
|
-
const intersector = r(new oc.Geom2dAPI_InterCurveCurve_1());
|
|
64
|
-
let intersections;
|
|
120
|
+
var _stack = [];
|
|
65
121
|
try {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
122
|
+
const oc = getKernel().oc;
|
|
123
|
+
const scope = __using(_stack, new DisposalScope());
|
|
124
|
+
const intersector = scope.register(new oc.Geom2dAPI_InterCurveCurve_1());
|
|
125
|
+
let intersections;
|
|
126
|
+
try {
|
|
127
|
+
intersector.Init_1(curve.wrapped, curve.wrapped, precision);
|
|
128
|
+
intersections = Array.from(pointsIteration(intersector));
|
|
129
|
+
} catch (e) {
|
|
130
|
+
return err(computationError("SELF_INTERSECTION_FAILED", "Self intersection failed", e));
|
|
131
|
+
}
|
|
132
|
+
return ok(intersections);
|
|
133
|
+
} catch (_) {
|
|
134
|
+
var _error = _, _hasError = true;
|
|
135
|
+
} finally {
|
|
136
|
+
__callDispose(_stack, _error, _hasError);
|
|
70
137
|
}
|
|
71
|
-
return ok(intersections);
|
|
72
138
|
};
|
|
73
139
|
const offsetEndPoints = (firstPoint, lastPoint, offset) => {
|
|
74
140
|
const tangent = normalize2d(subtract2d(lastPoint, firstPoint));
|
|
@@ -80,58 +146,65 @@ const offsetEndPoints = (firstPoint, lastPoint, offset) => {
|
|
|
80
146
|
};
|
|
81
147
|
};
|
|
82
148
|
const make2dOffset = (curve, offset) => {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
const
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
const
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
const
|
|
96
|
-
|
|
97
|
-
|
|
149
|
+
var _stack = [];
|
|
150
|
+
try {
|
|
151
|
+
const scope = __using(_stack, new DisposalScope());
|
|
152
|
+
const curveType = curve.geomType;
|
|
153
|
+
if (curveType === "CIRCLE") {
|
|
154
|
+
const circle = scope.register(scope.register(curve.adaptor()).Circle());
|
|
155
|
+
const radius = circle.Radius();
|
|
156
|
+
const orientationCorrection = circle.IsDirect() ? 1 : -1;
|
|
157
|
+
const orientedOffset = offset * orientationCorrection;
|
|
158
|
+
const newRadius = Number(radius) + orientedOffset;
|
|
159
|
+
if (newRadius < 1e-10) {
|
|
160
|
+
const centerPos = scope.register(circle.Location());
|
|
161
|
+
const center = [centerPos.X(), centerPos.Y()];
|
|
162
|
+
const offsetViaCenter = (point) => {
|
|
163
|
+
const [x, y] = normalize2d(subtract2d(point, center));
|
|
164
|
+
return add2d(point, [orientedOffset * x, orientedOffset * y]);
|
|
165
|
+
};
|
|
166
|
+
return {
|
|
167
|
+
collapsed: true,
|
|
168
|
+
firstPoint: offsetViaCenter(curve.firstPoint),
|
|
169
|
+
lastPoint: offsetViaCenter(curve.lastPoint)
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
const oc2 = getKernel().oc;
|
|
173
|
+
const newCircle = new oc2.gp_Circ2d_3(circle.Axis(), newRadius);
|
|
174
|
+
const newInnerCurve = new oc2.Geom2d_Circle_1(newCircle);
|
|
175
|
+
newCircle.delete();
|
|
176
|
+
const newCurve = new oc2.Geom2d_TrimmedCurve(
|
|
177
|
+
new oc2.Handle_Geom2d_Curve_2(newInnerCurve),
|
|
178
|
+
curve.firstParameter,
|
|
179
|
+
curve.lastParameter,
|
|
180
|
+
true,
|
|
181
|
+
true
|
|
182
|
+
);
|
|
183
|
+
return new Curve2D(new oc2.Handle_Geom2d_Curve_2(newCurve));
|
|
184
|
+
}
|
|
185
|
+
if (curveType === "LINE") {
|
|
186
|
+
const { firstPoint, lastPoint } = offsetEndPoints(curve.firstPoint, curve.lastPoint, offset);
|
|
187
|
+
return make2dSegmentCurve(firstPoint, lastPoint);
|
|
188
|
+
}
|
|
189
|
+
const oc = getKernel().oc;
|
|
190
|
+
const offsetCurve = new Curve2D(
|
|
191
|
+
new oc.Handle_Geom2d_Curve_2(new oc.Geom2d_OffsetCurve(curve.wrapped, offset, true))
|
|
192
|
+
);
|
|
193
|
+
const approximation = approximateAsBSpline(offsetCurve.adaptor());
|
|
194
|
+
const selfIntersects = unwrap(selfIntersections(approximation));
|
|
195
|
+
if (selfIntersects.length) {
|
|
98
196
|
return {
|
|
99
197
|
collapsed: true,
|
|
100
|
-
firstPoint:
|
|
101
|
-
lastPoint:
|
|
198
|
+
firstPoint: approximation.firstPoint,
|
|
199
|
+
lastPoint: approximation.lastPoint
|
|
102
200
|
};
|
|
103
201
|
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
new oc2.Handle_Geom2d_Curve_2(newInnerCurve),
|
|
110
|
-
curve.firstParameter,
|
|
111
|
-
curve.lastParameter,
|
|
112
|
-
true,
|
|
113
|
-
true
|
|
114
|
-
);
|
|
115
|
-
return new Curve2D(new oc2.Handle_Geom2d_Curve_2(newCurve));
|
|
116
|
-
}
|
|
117
|
-
if (curveType === "LINE") {
|
|
118
|
-
const { firstPoint, lastPoint } = offsetEndPoints(curve.firstPoint, curve.lastPoint, offset);
|
|
119
|
-
return make2dSegmentCurve(firstPoint, lastPoint);
|
|
120
|
-
}
|
|
121
|
-
const oc = getKernel().oc;
|
|
122
|
-
const offsetCurve = new Curve2D(
|
|
123
|
-
new oc.Handle_Geom2d_Curve_2(new oc.Geom2d_OffsetCurve(curve.wrapped, offset, true))
|
|
124
|
-
);
|
|
125
|
-
const approximation = approximateAsBSpline(offsetCurve.adaptor());
|
|
126
|
-
const selfIntersects = unwrap(selfIntersections(approximation));
|
|
127
|
-
if (selfIntersects.length) {
|
|
128
|
-
return {
|
|
129
|
-
collapsed: true,
|
|
130
|
-
firstPoint: approximation.firstPoint,
|
|
131
|
-
lastPoint: approximation.lastPoint
|
|
132
|
-
};
|
|
202
|
+
return approximation;
|
|
203
|
+
} catch (_) {
|
|
204
|
+
var _error = _, _hasError = true;
|
|
205
|
+
} finally {
|
|
206
|
+
__callDispose(_stack, _error, _hasError);
|
|
133
207
|
}
|
|
134
|
-
return approximation;
|
|
135
208
|
};
|
|
136
209
|
function removeCorner(firstCurve, secondCurve, radius) {
|
|
137
210
|
const sinAngle = crossProduct2d(firstCurve.tangentAt(1), secondCurve.tangentAt(0));
|
|
@@ -1036,7 +1109,6 @@ class Sketch {
|
|
|
1036
1109
|
twistAngle,
|
|
1037
1110
|
origin
|
|
1038
1111
|
} = {}) {
|
|
1039
|
-
const gc = localGC()[1];
|
|
1040
1112
|
const direction = extrusionDirection ? toVec3(extrusionDirection) : this.defaultDirection;
|
|
1041
1113
|
const extrusionVec = vecScale(vecNormalize(direction), extrusionDistance);
|
|
1042
1114
|
const originVec = origin ? toVec3(origin) : this.defaultOrigin;
|
|
@@ -1044,7 +1116,6 @@ class Sketch {
|
|
|
1044
1116
|
const solid2 = unwrap(
|
|
1045
1117
|
complexExtrude(this.wire, [...originVec], [...extrusionVec], extrusionProfile)
|
|
1046
1118
|
);
|
|
1047
|
-
gc();
|
|
1048
1119
|
this.delete();
|
|
1049
1120
|
return solid2;
|
|
1050
1121
|
}
|
|
@@ -1052,13 +1123,11 @@ class Sketch {
|
|
|
1052
1123
|
const solid2 = unwrap(
|
|
1053
1124
|
twistExtrude(this.wire, twistAngle, [...originVec], [...extrusionVec], extrusionProfile)
|
|
1054
1125
|
);
|
|
1055
|
-
gc();
|
|
1056
1126
|
this.delete();
|
|
1057
1127
|
return solid2;
|
|
1058
1128
|
}
|
|
1059
1129
|
const face = unwrap(makeFace(this.wire));
|
|
1060
1130
|
const solid = basicFaceExtrusion(face, [...extrusionVec]);
|
|
1061
|
-
gc();
|
|
1062
1131
|
this.delete();
|
|
1063
1132
|
return solid;
|
|
1064
1133
|
}
|
|
@@ -1648,38 +1717,54 @@ class FaceSketcher extends BaseSketcher2d {
|
|
|
1648
1717
|
* @ignore
|
|
1649
1718
|
*/
|
|
1650
1719
|
buildWire() {
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1720
|
+
var _stack = [];
|
|
1721
|
+
try {
|
|
1722
|
+
const scope = __using(_stack, new DisposalScope());
|
|
1723
|
+
const oc = getKernel().oc;
|
|
1724
|
+
const geomSurf = scope.register(this._adaptSurface());
|
|
1725
|
+
const edges = this.pendingCurves.map((curve) => {
|
|
1726
|
+
return scope.register(
|
|
1727
|
+
createEdge(
|
|
1728
|
+
scope.register(new oc.BRepBuilderAPI_MakeEdge_30(curve.wrapped, geomSurf)).Edge()
|
|
1729
|
+
)
|
|
1730
|
+
);
|
|
1731
|
+
});
|
|
1732
|
+
const wire = unwrap(assembleWire(edges));
|
|
1733
|
+
oc.BRepLib.BuildCurves3d_2(wire.wrapped);
|
|
1734
|
+
return wire;
|
|
1735
|
+
} catch (_) {
|
|
1736
|
+
var _error = _, _hasError = true;
|
|
1737
|
+
} finally {
|
|
1738
|
+
__callDispose(_stack, _error, _hasError);
|
|
1739
|
+
}
|
|
1661
1740
|
}
|
|
1662
1741
|
/** Finish drawing and return the resulting {@link Sketch} (does not close the path). */
|
|
1663
1742
|
done() {
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
const
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1743
|
+
var _stack = [];
|
|
1744
|
+
try {
|
|
1745
|
+
const scope = __using(_stack, new DisposalScope());
|
|
1746
|
+
const wire = this.buildWire();
|
|
1747
|
+
const sketch = new Sketch(wire);
|
|
1748
|
+
if (curveIsClosed(wire)) {
|
|
1749
|
+
const face = scope.register(sketch.clone().face());
|
|
1750
|
+
const origin = pointOnSurface(face, 0.5, 0.5);
|
|
1751
|
+
const normal = normalAt(face);
|
|
1752
|
+
const direction = vecScale(normal, -1);
|
|
1753
|
+
sketch.defaultOrigin = [origin[0], origin[1], origin[2]];
|
|
1754
|
+
sketch.defaultDirection = [direction[0], direction[1], direction[2]];
|
|
1755
|
+
} else {
|
|
1756
|
+
const startPoint = curveStartPoint(wire);
|
|
1757
|
+
const normal = normalAt(this.face, [startPoint[0], startPoint[1], startPoint[2]]);
|
|
1758
|
+
sketch.defaultOrigin = [startPoint[0], startPoint[1], startPoint[2]];
|
|
1759
|
+
sketch.defaultDirection = [normal[0], normal[1], normal[2]];
|
|
1760
|
+
}
|
|
1761
|
+
sketch.baseFace = this.face;
|
|
1762
|
+
return sketch;
|
|
1763
|
+
} catch (_) {
|
|
1764
|
+
var _error = _, _hasError = true;
|
|
1765
|
+
} finally {
|
|
1766
|
+
__callDispose(_stack, _error, _hasError);
|
|
1679
1767
|
}
|
|
1680
|
-
sketch.baseFace = this.face;
|
|
1681
|
-
gc();
|
|
1682
|
-
return sketch;
|
|
1683
1768
|
}
|
|
1684
1769
|
/** Close the path with a straight line to the start point and return the Sketch. */
|
|
1685
1770
|
close() {
|