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,6 +1,51 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __knownSymbol = (name, symbol) => (symbol = Symbol[name]) ? symbol : /* @__PURE__ */ Symbol.for("Symbol." + name);
|
|
3
|
+
var __typeError = (msg) => {
|
|
4
|
+
throw TypeError(msg);
|
|
5
|
+
};
|
|
6
|
+
var __using = (stack, value, async) => {
|
|
7
|
+
if (value != null) {
|
|
8
|
+
if (typeof value !== "object" && typeof value !== "function") __typeError("Object expected");
|
|
9
|
+
var dispose, inner;
|
|
10
|
+
if (async) dispose = value[__knownSymbol("asyncDispose")];
|
|
11
|
+
if (dispose === void 0) {
|
|
12
|
+
dispose = value[__knownSymbol("dispose")];
|
|
13
|
+
if (async) inner = dispose;
|
|
14
|
+
}
|
|
15
|
+
if (typeof dispose !== "function") __typeError("Object not disposable");
|
|
16
|
+
if (inner) dispose = function() {
|
|
17
|
+
try {
|
|
18
|
+
inner.call(this);
|
|
19
|
+
} catch (e) {
|
|
20
|
+
return Promise.reject(e);
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
stack.push([async, dispose, value]);
|
|
24
|
+
} else if (async) {
|
|
25
|
+
stack.push([async]);
|
|
26
|
+
}
|
|
27
|
+
return value;
|
|
28
|
+
};
|
|
29
|
+
var __callDispose = (stack, error, hasError) => {
|
|
30
|
+
var E = typeof SuppressedError === "function" ? SuppressedError : function(e, s, m, _) {
|
|
31
|
+
return _ = Error(m), _.name = "SuppressedError", _.error = e, _.suppressed = s, _;
|
|
32
|
+
};
|
|
33
|
+
var fail = (e) => error = hasError ? new E(e, error, "An error was suppressed during disposal") : (hasError = true, e);
|
|
34
|
+
var next = (it) => {
|
|
35
|
+
while (it = stack.pop()) {
|
|
36
|
+
try {
|
|
37
|
+
var result = it[1] && it[1].call(it[2]);
|
|
38
|
+
if (it[0]) return Promise.resolve(result).then(next, (e) => (fail(e), next()));
|
|
39
|
+
} catch (e) {
|
|
40
|
+
fail(e);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
if (hasError) throw error;
|
|
44
|
+
};
|
|
45
|
+
return next();
|
|
46
|
+
};
|
|
2
47
|
const occtBoundary = require("./occtBoundary-Cqfsau2c.cjs");
|
|
3
|
-
const shapeTypes = require("./shapeTypes-
|
|
48
|
+
const shapeTypes = require("./shapeTypes-CWuX602K.cjs");
|
|
4
49
|
const errors = require("./errors-NNmTtM5u.cjs");
|
|
5
50
|
let CURVE_TYPES_MAP = null;
|
|
6
51
|
const getCurveTypesMap = (refresh) => {
|
|
@@ -41,55 +86,111 @@ function mapParam(adaptor, t) {
|
|
|
41
86
|
return first + (last - first) * t;
|
|
42
87
|
}
|
|
43
88
|
function getCurveType(shape) {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
89
|
+
var _stack = [];
|
|
90
|
+
try {
|
|
91
|
+
const scope = __using(_stack, new shapeTypes.DisposalScope());
|
|
92
|
+
const adaptor = scope.register(getAdaptor(shape));
|
|
93
|
+
const technicalType = adaptor.GetType && adaptor.GetType();
|
|
94
|
+
return errors.unwrap(findCurveType(technicalType));
|
|
95
|
+
} catch (_) {
|
|
96
|
+
var _error = _, _hasError = true;
|
|
97
|
+
} finally {
|
|
98
|
+
__callDispose(_stack, _error, _hasError);
|
|
99
|
+
}
|
|
48
100
|
}
|
|
49
101
|
function curveStartPoint(shape) {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
102
|
+
var _stack = [];
|
|
103
|
+
try {
|
|
104
|
+
const scope = __using(_stack, new shapeTypes.DisposalScope());
|
|
105
|
+
const adaptor = scope.register(getAdaptor(shape));
|
|
106
|
+
const pnt = scope.register(adaptor.Value(adaptor.FirstParameter()));
|
|
107
|
+
return [pnt.X(), pnt.Y(), pnt.Z()];
|
|
108
|
+
} catch (_) {
|
|
109
|
+
var _error = _, _hasError = true;
|
|
110
|
+
} finally {
|
|
111
|
+
__callDispose(_stack, _error, _hasError);
|
|
112
|
+
}
|
|
54
113
|
}
|
|
55
114
|
function curveEndPoint(shape) {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
115
|
+
var _stack = [];
|
|
116
|
+
try {
|
|
117
|
+
const scope = __using(_stack, new shapeTypes.DisposalScope());
|
|
118
|
+
const adaptor = scope.register(getAdaptor(shape));
|
|
119
|
+
const pnt = scope.register(adaptor.Value(adaptor.LastParameter()));
|
|
120
|
+
return [pnt.X(), pnt.Y(), pnt.Z()];
|
|
121
|
+
} catch (_) {
|
|
122
|
+
var _error = _, _hasError = true;
|
|
123
|
+
} finally {
|
|
124
|
+
__callDispose(_stack, _error, _hasError);
|
|
125
|
+
}
|
|
60
126
|
}
|
|
61
127
|
function curvePointAt(shape, position = 0.5) {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
128
|
+
var _stack = [];
|
|
129
|
+
try {
|
|
130
|
+
const scope = __using(_stack, new shapeTypes.DisposalScope());
|
|
131
|
+
const adaptor = scope.register(getAdaptor(shape));
|
|
132
|
+
const pnt = scope.register(adaptor.Value(mapParam(adaptor, position)));
|
|
133
|
+
return [pnt.X(), pnt.Y(), pnt.Z()];
|
|
134
|
+
} catch (_) {
|
|
135
|
+
var _error = _, _hasError = true;
|
|
136
|
+
} finally {
|
|
137
|
+
__callDispose(_stack, _error, _hasError);
|
|
138
|
+
}
|
|
66
139
|
}
|
|
67
140
|
function curveTangentAt(shape, position = 0.5) {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
141
|
+
var _stack = [];
|
|
142
|
+
try {
|
|
143
|
+
const oc = occtBoundary.getKernel().oc;
|
|
144
|
+
const scope = __using(_stack, new shapeTypes.DisposalScope());
|
|
145
|
+
const adaptor = scope.register(getAdaptor(shape));
|
|
146
|
+
const param = mapParam(adaptor, position);
|
|
147
|
+
const tmpPnt = scope.register(new oc.gp_Pnt_1());
|
|
148
|
+
const tmpVec = scope.register(new oc.gp_Vec_1());
|
|
149
|
+
adaptor.D1(param, tmpPnt, tmpVec);
|
|
150
|
+
return [tmpVec.X(), tmpVec.Y(), tmpVec.Z()];
|
|
151
|
+
} catch (_) {
|
|
152
|
+
var _error = _, _hasError = true;
|
|
153
|
+
} finally {
|
|
154
|
+
__callDispose(_stack, _error, _hasError);
|
|
155
|
+
}
|
|
76
156
|
}
|
|
77
157
|
function curveLength(shape) {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
158
|
+
var _stack = [];
|
|
159
|
+
try {
|
|
160
|
+
const oc = occtBoundary.getKernel().oc;
|
|
161
|
+
const scope = __using(_stack, new shapeTypes.DisposalScope());
|
|
162
|
+
const props = scope.register(new oc.GProp_GProps_1());
|
|
163
|
+
oc.BRepGProp.LinearProperties(shape.wrapped, props, true, false);
|
|
164
|
+
return props.Mass();
|
|
165
|
+
} catch (_) {
|
|
166
|
+
var _error = _, _hasError = true;
|
|
167
|
+
} finally {
|
|
168
|
+
__callDispose(_stack, _error, _hasError);
|
|
169
|
+
}
|
|
83
170
|
}
|
|
84
171
|
function curveIsClosed(shape) {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
172
|
+
var _stack = [];
|
|
173
|
+
try {
|
|
174
|
+
const scope = __using(_stack, new shapeTypes.DisposalScope());
|
|
175
|
+
const adaptor = scope.register(getAdaptor(shape));
|
|
176
|
+
return adaptor.IsClosed();
|
|
177
|
+
} catch (_) {
|
|
178
|
+
var _error = _, _hasError = true;
|
|
179
|
+
} finally {
|
|
180
|
+
__callDispose(_stack, _error, _hasError);
|
|
181
|
+
}
|
|
88
182
|
}
|
|
89
183
|
function curveIsPeriodic(shape) {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
184
|
+
var _stack = [];
|
|
185
|
+
try {
|
|
186
|
+
const scope = __using(_stack, new shapeTypes.DisposalScope());
|
|
187
|
+
const adaptor = scope.register(getAdaptor(shape));
|
|
188
|
+
return adaptor.IsPeriodic();
|
|
189
|
+
} catch (_) {
|
|
190
|
+
var _error = _, _hasError = true;
|
|
191
|
+
} finally {
|
|
192
|
+
__callDispose(_stack, _error, _hasError);
|
|
193
|
+
}
|
|
93
194
|
}
|
|
94
195
|
function curvePeriod(shape) {
|
|
95
196
|
const adaptor = getAdaptor(shape);
|
|
@@ -1,20 +1,65 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __knownSymbol = (name, symbol) => (symbol = Symbol[name]) ? symbol : /* @__PURE__ */ Symbol.for("Symbol." + name);
|
|
3
|
+
var __typeError = (msg) => {
|
|
4
|
+
throw TypeError(msg);
|
|
5
|
+
};
|
|
6
|
+
var __using = (stack, value, async) => {
|
|
7
|
+
if (value != null) {
|
|
8
|
+
if (typeof value !== "object" && typeof value !== "function") __typeError("Object expected");
|
|
9
|
+
var dispose, inner;
|
|
10
|
+
if (async) dispose = value[__knownSymbol("asyncDispose")];
|
|
11
|
+
if (dispose === void 0) {
|
|
12
|
+
dispose = value[__knownSymbol("dispose")];
|
|
13
|
+
if (async) inner = dispose;
|
|
14
|
+
}
|
|
15
|
+
if (typeof dispose !== "function") __typeError("Object not disposable");
|
|
16
|
+
if (inner) dispose = function() {
|
|
17
|
+
try {
|
|
18
|
+
inner.call(this);
|
|
19
|
+
} catch (e) {
|
|
20
|
+
return Promise.reject(e);
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
stack.push([async, dispose, value]);
|
|
24
|
+
} else if (async) {
|
|
25
|
+
stack.push([async]);
|
|
26
|
+
}
|
|
27
|
+
return value;
|
|
28
|
+
};
|
|
29
|
+
var __callDispose = (stack, error, hasError) => {
|
|
30
|
+
var E = typeof SuppressedError === "function" ? SuppressedError : function(e, s, m, _) {
|
|
31
|
+
return _ = Error(m), _.name = "SuppressedError", _.error = e, _.suppressed = s, _;
|
|
32
|
+
};
|
|
33
|
+
var fail = (e) => error = hasError ? new E(e, error, "An error was suppressed during disposal") : (hasError = true, e);
|
|
34
|
+
var next = (it) => {
|
|
35
|
+
while (it = stack.pop()) {
|
|
36
|
+
try {
|
|
37
|
+
var result2 = it[1] && it[1].call(it[2]);
|
|
38
|
+
if (it[0]) return Promise.resolve(result2).then(next, (e) => (fail(e), next()));
|
|
39
|
+
} catch (e) {
|
|
40
|
+
fail(e);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
if (hasError) throw error;
|
|
44
|
+
};
|
|
45
|
+
return next();
|
|
46
|
+
};
|
|
2
47
|
const errors = require("./errors-NNmTtM5u.cjs");
|
|
3
48
|
const vectors = require("./vectors-CGLqemPY.cjs");
|
|
4
49
|
const occtBoundary = require("./occtBoundary-Cqfsau2c.cjs");
|
|
5
50
|
const vecOps = require("./vecOps-CjRL1jau.cjs");
|
|
6
|
-
const boolean2D = require("./boolean2D-
|
|
7
|
-
const faceFns = require("./faceFns-
|
|
8
|
-
const curveFns = require("./curveFns-
|
|
9
|
-
const surfaceBuilders = require("./surfaceBuilders-
|
|
10
|
-
const shapeTypes = require("./shapeTypes-
|
|
11
|
-
const Blueprint = require("./Blueprint-
|
|
51
|
+
const boolean2D = require("./boolean2D-BQk8LNmZ.cjs");
|
|
52
|
+
const faceFns = require("./faceFns-DNQss51F.cjs");
|
|
53
|
+
const curveFns = require("./curveFns-BsAHC3Qv.cjs");
|
|
54
|
+
const surfaceBuilders = require("./surfaceBuilders-CLal3WlK.cjs");
|
|
55
|
+
const shapeTypes = require("./shapeTypes-CWuX602K.cjs");
|
|
56
|
+
const Blueprint = require("./Blueprint-BmFJ4caY.cjs");
|
|
12
57
|
const result = require("./result.cjs");
|
|
13
|
-
const helpers = require("./helpers-
|
|
14
|
-
const shapeFns = require("./shapeFns-
|
|
15
|
-
const loft = require("./loft-
|
|
58
|
+
const helpers = require("./helpers-aylLv0_I.cjs");
|
|
59
|
+
const shapeFns = require("./shapeFns-D4CRxxmF.cjs");
|
|
60
|
+
const loft = require("./loft-CjEEqz2P.cjs");
|
|
16
61
|
const opentype = require("opentype.js");
|
|
17
|
-
const cornerFinder = require("./cornerFinder-
|
|
62
|
+
const cornerFinder = require("./cornerFinder-XAV2ywVS.cjs");
|
|
18
63
|
const stitchCurves = (curves, precision = 1e-7) => {
|
|
19
64
|
const startPoints = new boolean2D.Flatbush(curves.length);
|
|
20
65
|
curves.forEach((c) => {
|
|
@@ -315,8 +360,9 @@ class Sketcher {
|
|
|
315
360
|
}
|
|
316
361
|
/** Draw a smooth cubic Bezier spline to an absolute end point, blending tangent with the previous edge. */
|
|
317
362
|
smoothSplineTo(end, config) {
|
|
318
|
-
|
|
363
|
+
var _stack = [];
|
|
319
364
|
try {
|
|
365
|
+
const scope = __using(_stack, new shapeTypes.DisposalScope());
|
|
320
366
|
const { endTangent, startTangent, startFactor, endFactor } = boolean2D.defaultsSplineOptions(config);
|
|
321
367
|
const endPoint = vectors.planeToWorld(this.plane, end);
|
|
322
368
|
const previousEdge = this.pendingEdges.length ? this.pendingEdges[this.pendingEdges.length - 1] : null;
|
|
@@ -329,17 +375,14 @@ class Sketcher {
|
|
|
329
375
|
startPoleDirection = vectors.planeToWorld(this.plane, [1, 0]);
|
|
330
376
|
} else if (curveFns.getCurveType(previousEdge) === "BEZIER_CURVE") {
|
|
331
377
|
const oc = occtBoundary.getKernel().oc;
|
|
332
|
-
const adaptor =
|
|
378
|
+
const adaptor = scope.register(new oc.BRepAdaptor_Curve_2(previousEdge.wrapped));
|
|
333
379
|
const rawCurve = adaptor.Bezier().get();
|
|
334
380
|
const previousPole = occtBoundary.toVec3(rawCurve.Pole(rawCurve.NbPoles() - 1));
|
|
335
381
|
startPoleDirection = vecOps.vecSub(this.pointer, previousPole);
|
|
336
382
|
} else {
|
|
337
383
|
startPoleDirection = curveFns.curveTangentAt(previousEdge, 1);
|
|
338
384
|
}
|
|
339
|
-
const poleDistance = vecOps.vecScale(
|
|
340
|
-
vecOps.vecNormalize(startPoleDirection),
|
|
341
|
-
startFactor * defaultDistance
|
|
342
|
-
);
|
|
385
|
+
const poleDistance = vecOps.vecScale(vecOps.vecNormalize(startPoleDirection), startFactor * defaultDistance);
|
|
343
386
|
const startControl = vecOps.vecAdd(this.pointer, poleDistance);
|
|
344
387
|
let endPoleDirection;
|
|
345
388
|
if (endTangent === "symmetric") {
|
|
@@ -354,8 +397,10 @@ class Sketcher {
|
|
|
354
397
|
);
|
|
355
398
|
this._updatePointer(endPoint);
|
|
356
399
|
return this;
|
|
400
|
+
} catch (_) {
|
|
401
|
+
var _error = _, _hasError = true;
|
|
357
402
|
} finally {
|
|
358
|
-
|
|
403
|
+
__callDispose(_stack, _error, _hasError);
|
|
359
404
|
}
|
|
360
405
|
}
|
|
361
406
|
/** Draw a smooth cubic Bezier spline to a relative end point, blending tangent with the previous edge. */
|
|
@@ -408,32 +453,44 @@ class Sketcher {
|
|
|
408
453
|
}
|
|
409
454
|
}
|
|
410
455
|
const guessFaceFromWires = (wires) => {
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
456
|
+
var _stack = [];
|
|
457
|
+
try {
|
|
458
|
+
const oc = occtBoundary.getKernel().oc;
|
|
459
|
+
const scope = __using(_stack, new shapeTypes.DisposalScope());
|
|
460
|
+
const faceBuilder = scope.register(
|
|
461
|
+
new oc.BRepOffsetAPI_MakeFilling(3, 15, 2, false, 1e-5, 1e-4, 0.01, 0.1, 8, 9)
|
|
462
|
+
);
|
|
463
|
+
wires.forEach((wire, wireIndex) => {
|
|
464
|
+
shapeFns.getEdges(wire).forEach((edge) => {
|
|
465
|
+
faceBuilder.Add_1(edge.wrapped, oc.GeomAbs_Shape.GeomAbs_C0, wireIndex === 0);
|
|
466
|
+
});
|
|
419
467
|
});
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
}
|
|
428
|
-
|
|
468
|
+
const progress = scope.register(new oc.Message_ProgressRange_1());
|
|
469
|
+
faceBuilder.Build(progress);
|
|
470
|
+
const newFace = errors.unwrap(faceFns.cast(faceBuilder.Shape()));
|
|
471
|
+
if (!shapeTypes.isFace(newFace)) {
|
|
472
|
+
result.bug("guessFaceFromWires", "Failed to create a face");
|
|
473
|
+
}
|
|
474
|
+
return newFace;
|
|
475
|
+
} catch (_) {
|
|
476
|
+
var _error = _, _hasError = true;
|
|
477
|
+
} finally {
|
|
478
|
+
__callDispose(_stack, _error, _hasError);
|
|
479
|
+
}
|
|
429
480
|
};
|
|
430
481
|
const fixWire = (wire, baseFace) => {
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
482
|
+
var _stack = [];
|
|
483
|
+
try {
|
|
484
|
+
const oc = occtBoundary.getKernel().oc;
|
|
485
|
+
const scope = __using(_stack, new shapeTypes.DisposalScope());
|
|
486
|
+
const wireFixer = scope.register(new oc.ShapeFix_Wire_2(wire.wrapped, baseFace.wrapped, 1e-9));
|
|
487
|
+
wireFixer.FixEdgeCurves();
|
|
488
|
+
return wire;
|
|
489
|
+
} catch (_) {
|
|
490
|
+
var _error = _, _hasError = true;
|
|
491
|
+
} finally {
|
|
492
|
+
__callDispose(_stack, _error, _hasError);
|
|
493
|
+
}
|
|
437
494
|
};
|
|
438
495
|
const faceFromWires = (wires) => {
|
|
439
496
|
let baseFace;
|
|
@@ -511,7 +568,6 @@ class CompoundSketch {
|
|
|
511
568
|
twistAngle,
|
|
512
569
|
origin
|
|
513
570
|
} = {}) {
|
|
514
|
-
const [, gc] = shapeTypes.localGC();
|
|
515
571
|
const rawVec = extrusionDirection ? occtBoundary.toVec3(extrusionDirection) : this.outerSketch.defaultDirection;
|
|
516
572
|
const normVec = vecOps.vecNormalize(rawVec);
|
|
517
573
|
const extrusionVec = vecOps.vecScale(normVec, extrusionDistance);
|
|
@@ -542,7 +598,6 @@ class CompoundSketch {
|
|
|
542
598
|
} else {
|
|
543
599
|
result2 = loft.basicFaceExtrusion(this.face(), extrusionVec);
|
|
544
600
|
}
|
|
545
|
-
gc();
|
|
546
601
|
return result2;
|
|
547
602
|
}
|
|
548
603
|
/**
|
|
@@ -686,22 +741,28 @@ const sketchFaceOffset = (face, offset2) => {
|
|
|
686
741
|
return sketch;
|
|
687
742
|
};
|
|
688
743
|
const sketchParametricFunction = (func, planeConfig = {}, { pointsCount = 400, start = 0, stop = 1 } = {}, approximationConfig = {}) => {
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
const
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
744
|
+
var _stack = [];
|
|
745
|
+
try {
|
|
746
|
+
const scope = __using(_stack, new shapeTypes.DisposalScope());
|
|
747
|
+
const plane = planeConfig.plane && typeof planeConfig.plane !== "string" ? { ...planeConfig.plane } : vectors.resolvePlane(planeConfig.plane ?? "XY", planeConfig.origin);
|
|
748
|
+
const stepSize = (stop - start) / pointsCount;
|
|
749
|
+
const points = [...Array(pointsCount + 1).keys()].map((t) => {
|
|
750
|
+
const point = func(start + t * stepSize);
|
|
751
|
+
return vectors.planeToWorld(plane, point);
|
|
752
|
+
});
|
|
753
|
+
const wire = errors.unwrap(
|
|
754
|
+
surfaceBuilders.assembleWire([scope.register(errors.unwrap(surfaceBuilders.makeBSplineApproximation(points, approximationConfig)))])
|
|
755
|
+
);
|
|
756
|
+
const sketch = new boolean2D.Sketch(wire, {
|
|
757
|
+
defaultOrigin: [...plane.origin],
|
|
758
|
+
defaultDirection: [...plane.zDir]
|
|
759
|
+
});
|
|
760
|
+
return sketch;
|
|
761
|
+
} catch (_) {
|
|
762
|
+
var _error = _, _hasError = true;
|
|
763
|
+
} finally {
|
|
764
|
+
__callDispose(_stack, _error, _hasError);
|
|
765
|
+
}
|
|
705
766
|
};
|
|
706
767
|
const sketchHelix = (pitch, height, radius, center = [0, 0, 0], dir = [0, 0, 1], lefthand = false) => {
|
|
707
768
|
const centerVec3 = occtBoundary.toVec3(center);
|
|
@@ -1150,31 +1211,38 @@ const getEdgesFromOc = (shape) => {
|
|
|
1150
1211
|
return shapeFns.getEdges(shapeTypes.castShape(shape));
|
|
1151
1212
|
};
|
|
1152
1213
|
function makeProjectedEdges(shape, camera, withHiddenLines = true) {
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1214
|
+
var _stack = [];
|
|
1215
|
+
try {
|
|
1216
|
+
const oc = occtBoundary.getKernel().oc;
|
|
1217
|
+
const scope = __using(_stack, new shapeTypes.DisposalScope());
|
|
1218
|
+
const hiddenLineRemoval = scope.register(new oc.HLRBRep_Algo_1());
|
|
1219
|
+
hiddenLineRemoval.Add_2(shape.wrapped, 0);
|
|
1220
|
+
const ax2 = scope.register(occtBoundary.makeOcAx2(camera.position, camera.direction, camera.xAxis));
|
|
1221
|
+
const projector = scope.register(new oc.HLRAlgo_Projector_2(ax2));
|
|
1222
|
+
hiddenLineRemoval.Projector_1(projector);
|
|
1223
|
+
hiddenLineRemoval.Update();
|
|
1224
|
+
hiddenLineRemoval.Hide_1();
|
|
1225
|
+
const hlrShapes = scope.register(
|
|
1226
|
+
new oc.HLRBRep_HLRToShape(scope.register(new oc.Handle_HLRBRep_Algo_2(hiddenLineRemoval)))
|
|
1227
|
+
);
|
|
1228
|
+
const visible = [
|
|
1229
|
+
...getEdgesFromOc(hlrShapes.VCompound_1()),
|
|
1230
|
+
...getEdgesFromOc(hlrShapes.Rg1LineVCompound_1()),
|
|
1231
|
+
...getEdgesFromOc(hlrShapes.OutLineVCompound_1())
|
|
1232
|
+
];
|
|
1233
|
+
visible.forEach((e) => oc.BRepLib.BuildCurves3d_2(e.wrapped));
|
|
1234
|
+
const hidden = withHiddenLines ? [
|
|
1235
|
+
...getEdgesFromOc(hlrShapes.HCompound_1()),
|
|
1236
|
+
...getEdgesFromOc(hlrShapes.Rg1LineHCompound_1()),
|
|
1237
|
+
...getEdgesFromOc(hlrShapes.OutLineHCompound_1())
|
|
1238
|
+
] : [];
|
|
1239
|
+
hidden.forEach((e) => oc.BRepLib.BuildCurves3d_2(e.wrapped));
|
|
1240
|
+
return { visible, hidden };
|
|
1241
|
+
} catch (_) {
|
|
1242
|
+
var _error = _, _hasError = true;
|
|
1243
|
+
} finally {
|
|
1244
|
+
__callDispose(_stack, _error, _hasError);
|
|
1245
|
+
}
|
|
1178
1246
|
}
|
|
1179
1247
|
function createCamera(position = [0, 0, 0], direction = [0, 0, 1], xAxis) {
|
|
1180
1248
|
const dirLength = vecOps.vecLength(direction);
|
|
@@ -1498,15 +1566,21 @@ const drawParametricFunction = (func, { pointsCount = 400, start = 0, stop = 1,
|
|
|
1498
1566
|
return drawPointsInterpolation(points, approximationConfig, { closeShape });
|
|
1499
1567
|
};
|
|
1500
1568
|
const edgesToDrawing = (edges) => {
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1569
|
+
var _stack = [];
|
|
1570
|
+
try {
|
|
1571
|
+
const scope = __using(_stack, new shapeTypes.DisposalScope());
|
|
1572
|
+
const planeSketch = drawRectangle(1e3, 1e3).sketchOnPlane();
|
|
1573
|
+
const planeFace = scope.register(errors.unwrap(surfaceBuilders.makeFace(planeSketch.wire)));
|
|
1574
|
+
const curves = edges.map((e) => Blueprint.edgeToCurve(e, planeFace));
|
|
1575
|
+
const stitchedCurves = stitchCurves(curves).map((s) => new Blueprint.Blueprint(s));
|
|
1576
|
+
if (stitchedCurves.length === 0) return new Drawing();
|
|
1577
|
+
if (stitchedCurves.length === 1) return new Drawing(stitchedCurves[0]);
|
|
1578
|
+
return new Drawing(new boolean2D.Blueprints(stitchedCurves));
|
|
1579
|
+
} catch (_) {
|
|
1580
|
+
var _error = _, _hasError = true;
|
|
1581
|
+
} finally {
|
|
1582
|
+
__callDispose(_stack, _error, _hasError);
|
|
1583
|
+
}
|
|
1510
1584
|
};
|
|
1511
1585
|
function drawProjection(shape, projectionCamera = "front") {
|
|
1512
1586
|
let camera;
|
|
@@ -1522,15 +1596,21 @@ function drawProjection(shape, projectionCamera = "front") {
|
|
|
1522
1596
|
};
|
|
1523
1597
|
}
|
|
1524
1598
|
function drawFaceOutline(face) {
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1599
|
+
var _stack = [];
|
|
1600
|
+
try {
|
|
1601
|
+
const scope = __using(_stack, new shapeTypes.DisposalScope());
|
|
1602
|
+
const clonedFace = scope.register(shapeTypes.createFace(errors.unwrap(faceFns.downcast(face.wrapped))));
|
|
1603
|
+
const faceOuterWire = scope.register(faceFns.outerWire(clonedFace));
|
|
1604
|
+
const curves = shapeFns.getEdges(faceOuterWire).map((e) => Blueprint.edgeToCurve(e, face));
|
|
1605
|
+
const stitchedCurves = stitchCurves(curves).map((s) => new Blueprint.Blueprint(s));
|
|
1606
|
+
if (stitchedCurves.length === 0) return new Drawing();
|
|
1607
|
+
if (stitchedCurves.length === 1) return new Drawing(stitchedCurves[0]);
|
|
1608
|
+
return new Drawing(new boolean2D.Blueprints(stitchedCurves));
|
|
1609
|
+
} catch (_) {
|
|
1610
|
+
var _error = _, _hasError = true;
|
|
1611
|
+
} finally {
|
|
1612
|
+
__callDispose(_stack, _error, _hasError);
|
|
1613
|
+
}
|
|
1534
1614
|
}
|
|
1535
1615
|
function sketchExtrude(sketch, height, config) {
|
|
1536
1616
|
return sketch.extrude(height, config);
|