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
|
@@ -0,0 +1,531 @@
|
|
|
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
|
+
};
|
|
46
|
+
import { g as getKernel, d as toOcPnt, c as makeOcAx2, m as makeOcAx1, a as toVec3 } from "./occtBoundary-DvBywHyU.js";
|
|
47
|
+
import { D as DEG2RAD, v as vecAdd, g as vecLength } from "./vecOps-ZDdZWbwT.js";
|
|
48
|
+
import { c as cast, d as downcast, a as isShape3D$1, b as isWire } from "./faceFns-q5CR9pOW.js";
|
|
49
|
+
import { e as err, x as validationError, l as ok, u as unwrap, p as typeCastError, a as andThen, o as occtError } from "./errors-DJ92ermb.js";
|
|
50
|
+
import { D as DisposalScope, k as isShell, t as createCompound, u as createVertex, v as createSolid, j as isShape3D, l as isSolid } from "./shapeTypes-Bi_9RZa2.js";
|
|
51
|
+
import { a as makeLine, b as assembleWire, c as makeHelix } from "./surfaceBuilders-W9Y25CIb.js";
|
|
52
|
+
function buildLawFromProfile(extrusionLength, { profile, endFactor = 1 }) {
|
|
53
|
+
var _stack = [];
|
|
54
|
+
try {
|
|
55
|
+
const oc = getKernel().oc;
|
|
56
|
+
const scope = __using(_stack, new DisposalScope());
|
|
57
|
+
let law;
|
|
58
|
+
if (profile === "s-curve") {
|
|
59
|
+
law = scope.register(new oc.Law_S());
|
|
60
|
+
law.Set_1(0, 1, extrusionLength, endFactor);
|
|
61
|
+
} else if (profile === "linear") {
|
|
62
|
+
law = scope.register(new oc.Law_Linear());
|
|
63
|
+
law.Set(0, 1, extrusionLength, endFactor);
|
|
64
|
+
} else {
|
|
65
|
+
return err(
|
|
66
|
+
validationError("UNSUPPORTED_PROFILE", `Unsupported extrusion profile: ${String(profile)}`)
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
return ok(law.Trim(0, extrusionLength, 1e-6));
|
|
70
|
+
} catch (_) {
|
|
71
|
+
var _error = _, _hasError = true;
|
|
72
|
+
} finally {
|
|
73
|
+
__callDispose(_stack, _error, _hasError);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
function weldShapes(facesOrShells) {
|
|
77
|
+
const sewn = getKernel().sew(facesOrShells.map((s) => s.wrapped));
|
|
78
|
+
return unwrap(cast(unwrap(downcast(sewn))));
|
|
79
|
+
}
|
|
80
|
+
function weldShellsAndFaces(facesOrShells, ignoreType = false) {
|
|
81
|
+
const shell = weldShapes(facesOrShells);
|
|
82
|
+
if (!ignoreType && !isShell(shell))
|
|
83
|
+
return err(typeCastError("WELD_NOT_SHELL", "Could not make a shell from faces and shells"));
|
|
84
|
+
return ok(shell);
|
|
85
|
+
}
|
|
86
|
+
function makeCylinder(radius, height, location = [0, 0, 0], direction = [0, 0, 1]) {
|
|
87
|
+
var _stack = [];
|
|
88
|
+
try {
|
|
89
|
+
const oc = getKernel().oc;
|
|
90
|
+
const scope = __using(_stack, new DisposalScope());
|
|
91
|
+
const axis = scope.register(makeOcAx2(location, direction));
|
|
92
|
+
const cylinder = scope.register(new oc.BRepPrimAPI_MakeCylinder_3(axis, radius, height));
|
|
93
|
+
return createSolid(cylinder.Shape());
|
|
94
|
+
} catch (_) {
|
|
95
|
+
var _error = _, _hasError = true;
|
|
96
|
+
} finally {
|
|
97
|
+
__callDispose(_stack, _error, _hasError);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
function makeSphere(radius) {
|
|
101
|
+
var _stack = [];
|
|
102
|
+
try {
|
|
103
|
+
const oc = getKernel().oc;
|
|
104
|
+
const scope = __using(_stack, new DisposalScope());
|
|
105
|
+
const sphereMaker = scope.register(new oc.BRepPrimAPI_MakeSphere_1(radius));
|
|
106
|
+
return createSolid(sphereMaker.Shape());
|
|
107
|
+
} catch (_) {
|
|
108
|
+
var _error = _, _hasError = true;
|
|
109
|
+
} finally {
|
|
110
|
+
__callDispose(_stack, _error, _hasError);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
function makeCone(radius1, radius2, height, location = [0, 0, 0], direction = [0, 0, 1]) {
|
|
114
|
+
var _stack = [];
|
|
115
|
+
try {
|
|
116
|
+
const oc = getKernel().oc;
|
|
117
|
+
const scope = __using(_stack, new DisposalScope());
|
|
118
|
+
const axis = scope.register(makeOcAx2(location, direction));
|
|
119
|
+
const coneMaker = scope.register(new oc.BRepPrimAPI_MakeCone_3(axis, radius1, radius2, height));
|
|
120
|
+
return createSolid(coneMaker.Shape());
|
|
121
|
+
} catch (_) {
|
|
122
|
+
var _error = _, _hasError = true;
|
|
123
|
+
} finally {
|
|
124
|
+
__callDispose(_stack, _error, _hasError);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
function makeTorus(majorRadius, minorRadius, location = [0, 0, 0], direction = [0, 0, 1]) {
|
|
128
|
+
var _stack = [];
|
|
129
|
+
try {
|
|
130
|
+
const oc = getKernel().oc;
|
|
131
|
+
const scope = __using(_stack, new DisposalScope());
|
|
132
|
+
const axis = scope.register(makeOcAx2(location, direction));
|
|
133
|
+
const torusMaker = scope.register(new oc.BRepPrimAPI_MakeTorus_5(axis, majorRadius, minorRadius));
|
|
134
|
+
return createSolid(torusMaker.Shape());
|
|
135
|
+
} catch (_) {
|
|
136
|
+
var _error = _, _hasError = true;
|
|
137
|
+
} finally {
|
|
138
|
+
__callDispose(_stack, _error, _hasError);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
function makeEllipsoidTransform(x, y, z) {
|
|
142
|
+
var _stack = [];
|
|
143
|
+
try {
|
|
144
|
+
const oc = getKernel().oc;
|
|
145
|
+
const scope = __using(_stack, new DisposalScope());
|
|
146
|
+
const xyRatio = Math.sqrt(x * y / z);
|
|
147
|
+
const xzRatio = x / xyRatio;
|
|
148
|
+
const yzRatio = y / xyRatio;
|
|
149
|
+
const ax1 = scope.register(makeOcAx1([0, 0, 0], [0, 1, 0]));
|
|
150
|
+
const ax2 = scope.register(makeOcAx1([0, 0, 0], [0, 0, 1]));
|
|
151
|
+
const ax3 = scope.register(makeOcAx1([0, 0, 0], [1, 0, 0]));
|
|
152
|
+
const transform = new oc.gp_GTrsf_1();
|
|
153
|
+
transform.SetAffinity_1(ax1, xzRatio);
|
|
154
|
+
const xy = scope.register(new oc.gp_GTrsf_1());
|
|
155
|
+
xy.SetAffinity_1(ax2, xyRatio);
|
|
156
|
+
const yz = scope.register(new oc.gp_GTrsf_1());
|
|
157
|
+
yz.SetAffinity_1(ax3, yzRatio);
|
|
158
|
+
transform.Multiply(xy);
|
|
159
|
+
transform.Multiply(yz);
|
|
160
|
+
return {
|
|
161
|
+
transform,
|
|
162
|
+
applyToPoint(p) {
|
|
163
|
+
var _stack2 = [];
|
|
164
|
+
try {
|
|
165
|
+
const scope2 = __using(_stack2, new DisposalScope());
|
|
166
|
+
const coords = scope2.register(p.XYZ());
|
|
167
|
+
transform.Transforms_1(coords);
|
|
168
|
+
return new oc.gp_Pnt_2(coords);
|
|
169
|
+
} catch (_2) {
|
|
170
|
+
var _error2 = _2, _hasError2 = true;
|
|
171
|
+
} finally {
|
|
172
|
+
__callDispose(_stack2, _error2, _hasError2);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
};
|
|
176
|
+
} catch (_) {
|
|
177
|
+
var _error = _, _hasError = true;
|
|
178
|
+
} finally {
|
|
179
|
+
__callDispose(_stack, _error, _hasError);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
function convertToJSArray(arrayOfPoints) {
|
|
183
|
+
const newArray = [];
|
|
184
|
+
for (let row = arrayOfPoints.LowerRow(); row <= arrayOfPoints.UpperRow(); row++) {
|
|
185
|
+
const rowArr = [];
|
|
186
|
+
newArray.push(rowArr);
|
|
187
|
+
for (let c = arrayOfPoints.LowerCol(); c <= arrayOfPoints.UpperCol(); c++) {
|
|
188
|
+
const pnt = arrayOfPoints.Value(row, c);
|
|
189
|
+
rowArr.push(pnt);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
return newArray;
|
|
193
|
+
}
|
|
194
|
+
function makeEllipsoid(aLength, bLength, cLength) {
|
|
195
|
+
var _stack = [];
|
|
196
|
+
try {
|
|
197
|
+
const oc = getKernel().oc;
|
|
198
|
+
const scope = __using(_stack, new DisposalScope());
|
|
199
|
+
const sphere = scope.register(new oc.gp_Sphere_1());
|
|
200
|
+
sphere.SetRadius(1);
|
|
201
|
+
const sphericalSurface = scope.register(new oc.Geom_SphericalSurface_2(sphere));
|
|
202
|
+
const baseSurface = oc.GeomConvert.SurfaceToBSplineSurface(sphericalSurface.UReversed()).get();
|
|
203
|
+
try {
|
|
204
|
+
const poles = convertToJSArray(baseSurface.Poles_2());
|
|
205
|
+
const ellipsoidTrsf = makeEllipsoidTransform(aLength, bLength, cLength);
|
|
206
|
+
poles.forEach((columns, rowIdx) => {
|
|
207
|
+
columns.forEach((value, colIdx) => {
|
|
208
|
+
const newPoint = ellipsoidTrsf.applyToPoint(value);
|
|
209
|
+
baseSurface.SetPole_1(rowIdx + 1, colIdx + 1, newPoint);
|
|
210
|
+
newPoint.delete();
|
|
211
|
+
});
|
|
212
|
+
});
|
|
213
|
+
ellipsoidTrsf.transform.delete();
|
|
214
|
+
const shell = unwrap(
|
|
215
|
+
cast(
|
|
216
|
+
scope.register(new oc.BRepBuilderAPI_MakeShell_2(baseSurface.UReversed(), false)).Shell()
|
|
217
|
+
)
|
|
218
|
+
);
|
|
219
|
+
return unwrap(makeSolid([shell]));
|
|
220
|
+
} finally {
|
|
221
|
+
baseSurface.delete();
|
|
222
|
+
}
|
|
223
|
+
} catch (_) {
|
|
224
|
+
var _error = _, _hasError = true;
|
|
225
|
+
} finally {
|
|
226
|
+
__callDispose(_stack, _error, _hasError);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
function makeVertex(point) {
|
|
230
|
+
var _stack = [];
|
|
231
|
+
try {
|
|
232
|
+
const oc = getKernel().oc;
|
|
233
|
+
const scope = __using(_stack, new DisposalScope());
|
|
234
|
+
const pnt = scope.register(toOcPnt(point));
|
|
235
|
+
const vertexMaker = scope.register(new oc.BRepBuilderAPI_MakeVertex(pnt));
|
|
236
|
+
return createVertex(vertexMaker.Vertex());
|
|
237
|
+
} catch (_) {
|
|
238
|
+
var _error = _, _hasError = true;
|
|
239
|
+
} finally {
|
|
240
|
+
__callDispose(_stack, _error, _hasError);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
function makeOffset(face, offset, tolerance = 1e-6) {
|
|
244
|
+
const oc = getKernel().oc;
|
|
245
|
+
const progress = new oc.Message_ProgressRange_1();
|
|
246
|
+
const offsetBuilder = new oc.BRepOffsetAPI_MakeOffsetShape();
|
|
247
|
+
try {
|
|
248
|
+
offsetBuilder.PerformByJoin(
|
|
249
|
+
face.wrapped,
|
|
250
|
+
offset,
|
|
251
|
+
tolerance,
|
|
252
|
+
oc.BRepOffset_Mode.BRepOffset_Skin,
|
|
253
|
+
false,
|
|
254
|
+
false,
|
|
255
|
+
oc.GeomAbs_JoinType.GeomAbs_Arc,
|
|
256
|
+
false,
|
|
257
|
+
progress
|
|
258
|
+
);
|
|
259
|
+
return andThen(
|
|
260
|
+
downcast(offsetBuilder.Shape()),
|
|
261
|
+
(downcasted) => andThen(cast(downcasted), (newShape) => {
|
|
262
|
+
if (!isShape3D(newShape))
|
|
263
|
+
return err(typeCastError("OFFSET_NOT_3D", "Could not offset to a 3d shape"));
|
|
264
|
+
return ok(newShape);
|
|
265
|
+
})
|
|
266
|
+
);
|
|
267
|
+
} finally {
|
|
268
|
+
offsetBuilder.delete();
|
|
269
|
+
progress.delete();
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
function makeCompound(shapeArray) {
|
|
273
|
+
const oc = getKernel().oc;
|
|
274
|
+
const builder = new oc.TopoDS_Builder();
|
|
275
|
+
const compound = new oc.TopoDS_Compound();
|
|
276
|
+
builder.MakeCompound(compound);
|
|
277
|
+
for (const s of shapeArray) {
|
|
278
|
+
builder.Add(compound, s.wrapped);
|
|
279
|
+
}
|
|
280
|
+
builder.delete();
|
|
281
|
+
return createCompound(compound);
|
|
282
|
+
}
|
|
283
|
+
function makeSolid(facesOrShells) {
|
|
284
|
+
var _stack = [];
|
|
285
|
+
try {
|
|
286
|
+
const scope = __using(_stack, new DisposalScope());
|
|
287
|
+
const oc = getKernel().oc;
|
|
288
|
+
const shell = weldShapes(facesOrShells);
|
|
289
|
+
return andThen(
|
|
290
|
+
cast(scope.register(new oc.ShapeFix_Solid_1()).SolidFromShell(shell.wrapped)),
|
|
291
|
+
(solid) => {
|
|
292
|
+
if (!isSolid(solid))
|
|
293
|
+
return err(
|
|
294
|
+
typeCastError("SOLID_BUILD_FAILED", "Could not make a solid of faces and shells")
|
|
295
|
+
);
|
|
296
|
+
return ok(solid);
|
|
297
|
+
}
|
|
298
|
+
);
|
|
299
|
+
} catch (_) {
|
|
300
|
+
var _error = _, _hasError = true;
|
|
301
|
+
} finally {
|
|
302
|
+
__callDispose(_stack, _error, _hasError);
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
const basicFaceExtrusion = (face, extrusionVec) => {
|
|
306
|
+
var _stack = [];
|
|
307
|
+
try {
|
|
308
|
+
const oc = getKernel().oc;
|
|
309
|
+
const scope = __using(_stack, new DisposalScope());
|
|
310
|
+
const vec = toVec3(extrusionVec);
|
|
311
|
+
const ocVec = scope.register(new oc.gp_Vec_4(vec[0], vec[1], vec[2]));
|
|
312
|
+
const solidBuilder = scope.register(
|
|
313
|
+
new oc.BRepPrimAPI_MakePrism_1(face.wrapped, ocVec, false, true)
|
|
314
|
+
);
|
|
315
|
+
const solid = createSolid(unwrap(downcast(solidBuilder.Shape())));
|
|
316
|
+
return solid;
|
|
317
|
+
} catch (_) {
|
|
318
|
+
var _error = _, _hasError = true;
|
|
319
|
+
} finally {
|
|
320
|
+
__callDispose(_stack, _error, _hasError);
|
|
321
|
+
}
|
|
322
|
+
};
|
|
323
|
+
const revolution = (face, center = [0, 0, 0], direction = [0, 0, 1], angle = 360) => {
|
|
324
|
+
var _stack = [];
|
|
325
|
+
try {
|
|
326
|
+
const oc = getKernel().oc;
|
|
327
|
+
const scope = __using(_stack, new DisposalScope());
|
|
328
|
+
const centerVec = toVec3(center);
|
|
329
|
+
const directionVec = toVec3(direction);
|
|
330
|
+
const ax = scope.register(makeOcAx1(centerVec, directionVec));
|
|
331
|
+
const revolBuilder = scope.register(
|
|
332
|
+
new oc.BRepPrimAPI_MakeRevol_1(face.wrapped, ax, angle * DEG2RAD, false)
|
|
333
|
+
);
|
|
334
|
+
const result = andThen(cast(revolBuilder.Shape()), (shape) => {
|
|
335
|
+
if (!isShape3D$1(shape))
|
|
336
|
+
return err(typeCastError("REVOLUTION_NOT_3D", "Revolution did not produce a 3D shape"));
|
|
337
|
+
return ok(shape);
|
|
338
|
+
});
|
|
339
|
+
return result;
|
|
340
|
+
} catch (_) {
|
|
341
|
+
var _error = _, _hasError = true;
|
|
342
|
+
} finally {
|
|
343
|
+
__callDispose(_stack, _error, _hasError);
|
|
344
|
+
}
|
|
345
|
+
};
|
|
346
|
+
function genericSweep(wire, spine, {
|
|
347
|
+
frenet = false,
|
|
348
|
+
auxiliarySpine,
|
|
349
|
+
law = null,
|
|
350
|
+
transitionMode = "right",
|
|
351
|
+
withContact,
|
|
352
|
+
support,
|
|
353
|
+
forceProfileSpineOthogonality,
|
|
354
|
+
mode: sweepMode,
|
|
355
|
+
tolerance,
|
|
356
|
+
boundTolerance,
|
|
357
|
+
angularTolerance,
|
|
358
|
+
maxDegree,
|
|
359
|
+
maxSegments
|
|
360
|
+
} = {}, shellMode = false) {
|
|
361
|
+
var _stack = [];
|
|
362
|
+
try {
|
|
363
|
+
if (sweepMode === "simple" && !shellMode) {
|
|
364
|
+
const kernel = getKernel();
|
|
365
|
+
const resultOc = kernel.simplePipe(wire.wrapped, spine.wrapped);
|
|
366
|
+
const result = andThen(cast(resultOc), (shape2) => {
|
|
367
|
+
if (!isShape3D$1(shape2))
|
|
368
|
+
return err(typeCastError("SWEEP_NOT_3D", "Simple pipe did not produce a 3D shape"));
|
|
369
|
+
return ok(shape2);
|
|
370
|
+
});
|
|
371
|
+
return result;
|
|
372
|
+
}
|
|
373
|
+
const oc = getKernel().oc;
|
|
374
|
+
const scope = __using(_stack, new DisposalScope());
|
|
375
|
+
const withCorrection = transitionMode === "round" ? true : !!forceProfileSpineOthogonality;
|
|
376
|
+
const sweepBuilder = scope.register(new oc.BRepOffsetAPI_MakePipeShell(spine.wrapped));
|
|
377
|
+
if (tolerance !== void 0) {
|
|
378
|
+
sweepBuilder.SetTolerance(tolerance, boundTolerance ?? tolerance, angularTolerance ?? 1e-7);
|
|
379
|
+
}
|
|
380
|
+
if (maxDegree !== void 0) {
|
|
381
|
+
sweepBuilder.SetMaxDegree(maxDegree);
|
|
382
|
+
}
|
|
383
|
+
if (maxSegments !== void 0) {
|
|
384
|
+
sweepBuilder.SetMaxSegments(maxSegments);
|
|
385
|
+
}
|
|
386
|
+
{
|
|
387
|
+
const mode = {
|
|
388
|
+
transformed: oc.BRepBuilderAPI_TransitionMode.BRepBuilderAPI_Transformed,
|
|
389
|
+
round: oc.BRepBuilderAPI_TransitionMode.BRepBuilderAPI_RoundCorner,
|
|
390
|
+
right: oc.BRepBuilderAPI_TransitionMode.BRepBuilderAPI_RightCorner
|
|
391
|
+
}[transitionMode];
|
|
392
|
+
if (mode) sweepBuilder.SetTransitionMode(mode);
|
|
393
|
+
}
|
|
394
|
+
if (support) {
|
|
395
|
+
sweepBuilder.SetMode_4(support);
|
|
396
|
+
} else if (frenet) {
|
|
397
|
+
sweepBuilder.SetMode_1(frenet);
|
|
398
|
+
}
|
|
399
|
+
if (auxiliarySpine) {
|
|
400
|
+
sweepBuilder.SetMode_5(
|
|
401
|
+
auxiliarySpine.wrapped,
|
|
402
|
+
false,
|
|
403
|
+
oc.BRepFill_TypeOfContact.BRepFill_NoContact
|
|
404
|
+
);
|
|
405
|
+
}
|
|
406
|
+
if (!law) sweepBuilder.Add_1(wire.wrapped, !!withContact, withCorrection);
|
|
407
|
+
else sweepBuilder.SetLaw_1(wire.wrapped, law, !!withContact, withCorrection);
|
|
408
|
+
const progress = scope.register(new oc.Message_ProgressRange_1());
|
|
409
|
+
sweepBuilder.Build(progress);
|
|
410
|
+
if (!sweepBuilder.IsDone()) {
|
|
411
|
+
return err(occtError("SWEEP_FAILED", "Sweep operation failed"));
|
|
412
|
+
}
|
|
413
|
+
if (!shellMode) {
|
|
414
|
+
sweepBuilder.MakeSolid();
|
|
415
|
+
}
|
|
416
|
+
const shape = unwrap(cast(sweepBuilder.Shape()));
|
|
417
|
+
if (!isShape3D$1(shape)) {
|
|
418
|
+
return err(typeCastError("SWEEP_NOT_3D", "Sweep did not produce a 3D shape"));
|
|
419
|
+
}
|
|
420
|
+
if (shellMode) {
|
|
421
|
+
const startWire = unwrap(cast(sweepBuilder.FirstShape()));
|
|
422
|
+
const endWire = unwrap(cast(sweepBuilder.LastShape()));
|
|
423
|
+
if (!isWire(startWire)) {
|
|
424
|
+
return err(typeCastError("SWEEP_START_NOT_WIRE", "Sweep did not produce a start Wire"));
|
|
425
|
+
}
|
|
426
|
+
if (!isWire(endWire)) {
|
|
427
|
+
return err(typeCastError("SWEEP_END_NOT_WIRE", "Sweep did not produce an end Wire"));
|
|
428
|
+
}
|
|
429
|
+
return ok([shape, startWire, endWire]);
|
|
430
|
+
}
|
|
431
|
+
return ok(shape);
|
|
432
|
+
} catch (_) {
|
|
433
|
+
var _error = _, _hasError = true;
|
|
434
|
+
} finally {
|
|
435
|
+
__callDispose(_stack, _error, _hasError);
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
function complexExtrude(wire, center, normal, profileShape, shellMode = false) {
|
|
439
|
+
var _stack = [];
|
|
440
|
+
try {
|
|
441
|
+
const scope = __using(_stack, new DisposalScope());
|
|
442
|
+
const centerVec = toVec3(center);
|
|
443
|
+
const normalVec = toVec3(normal);
|
|
444
|
+
const endVec = vecAdd(centerVec, normalVec);
|
|
445
|
+
const mainSpineEdge = scope.register(makeLine(centerVec, endVec));
|
|
446
|
+
const spine = scope.register(unwrap(assembleWire([mainSpineEdge])));
|
|
447
|
+
const law = profileShape ? scope.register(unwrap(buildLawFromProfile(vecLength(normalVec), profileShape))) : null;
|
|
448
|
+
const result = shellMode ? genericSweep(wire, spine, { law }, shellMode) : genericSweep(wire, spine, { law });
|
|
449
|
+
return result;
|
|
450
|
+
} catch (_) {
|
|
451
|
+
var _error = _, _hasError = true;
|
|
452
|
+
} finally {
|
|
453
|
+
__callDispose(_stack, _error, _hasError);
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
function twistExtrude(wire, angleDegrees, center, normal, profileShape, shellMode = false) {
|
|
457
|
+
var _stack = [];
|
|
458
|
+
try {
|
|
459
|
+
const scope = __using(_stack, new DisposalScope());
|
|
460
|
+
const centerVec = toVec3(center);
|
|
461
|
+
const normalVec = toVec3(normal);
|
|
462
|
+
const endVec = vecAdd(centerVec, normalVec);
|
|
463
|
+
const mainSpineEdge = scope.register(makeLine(centerVec, endVec));
|
|
464
|
+
const spine = scope.register(unwrap(assembleWire([mainSpineEdge])));
|
|
465
|
+
const extrusionLength = vecLength(normalVec);
|
|
466
|
+
const pitch = 360 / angleDegrees * extrusionLength;
|
|
467
|
+
const radius = 1;
|
|
468
|
+
const auxiliarySpine = scope.register(
|
|
469
|
+
makeHelix(pitch, extrusionLength, radius, centerVec, normalVec)
|
|
470
|
+
);
|
|
471
|
+
const law = profileShape ? scope.register(unwrap(buildLawFromProfile(extrusionLength, profileShape))) : null;
|
|
472
|
+
const result = shellMode ? genericSweep(wire, spine, { auxiliarySpine, law }, shellMode) : genericSweep(wire, spine, { auxiliarySpine, law });
|
|
473
|
+
return result;
|
|
474
|
+
} catch (_) {
|
|
475
|
+
var _error = _, _hasError = true;
|
|
476
|
+
} finally {
|
|
477
|
+
__callDispose(_stack, _error, _hasError);
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
const loft = (wires, { ruled = true, startPoint, endPoint } = {}, returnShell = false) => {
|
|
481
|
+
var _stack = [];
|
|
482
|
+
try {
|
|
483
|
+
if (wires.length === 0 && !startPoint && !endPoint) {
|
|
484
|
+
return err(validationError("LOFT_EMPTY", "Loft requires at least one wire or start/end point"));
|
|
485
|
+
}
|
|
486
|
+
const oc = getKernel().oc;
|
|
487
|
+
const scope = __using(_stack, new DisposalScope());
|
|
488
|
+
const loftBuilder = scope.register(new oc.BRepOffsetAPI_ThruSections(!returnShell, ruled, 1e-6));
|
|
489
|
+
if (startPoint) {
|
|
490
|
+
loftBuilder.AddVertex(scope.register(makeVertex(toVec3(startPoint))).wrapped);
|
|
491
|
+
}
|
|
492
|
+
wires.forEach((w) => loftBuilder.AddWire(w.wrapped));
|
|
493
|
+
if (endPoint) {
|
|
494
|
+
loftBuilder.AddVertex(scope.register(makeVertex(toVec3(endPoint))).wrapped);
|
|
495
|
+
}
|
|
496
|
+
const progress = scope.register(new oc.Message_ProgressRange_1());
|
|
497
|
+
loftBuilder.Build(progress);
|
|
498
|
+
if (!loftBuilder.IsDone()) {
|
|
499
|
+
return err(occtError("LOFT_FAILED", "Loft operation failed"));
|
|
500
|
+
}
|
|
501
|
+
const result = andThen(cast(loftBuilder.Shape()), (shape) => {
|
|
502
|
+
if (!isShape3D$1(shape))
|
|
503
|
+
return err(typeCastError("LOFT_NOT_3D", "Loft did not produce a 3D shape"));
|
|
504
|
+
return ok(shape);
|
|
505
|
+
});
|
|
506
|
+
return result;
|
|
507
|
+
} catch (_) {
|
|
508
|
+
var _error = _, _hasError = true;
|
|
509
|
+
} finally {
|
|
510
|
+
__callDispose(_stack, _error, _hasError);
|
|
511
|
+
}
|
|
512
|
+
};
|
|
513
|
+
export {
|
|
514
|
+
makeSolid as a,
|
|
515
|
+
basicFaceExtrusion as b,
|
|
516
|
+
complexExtrude as c,
|
|
517
|
+
makeCone as d,
|
|
518
|
+
makeCylinder as e,
|
|
519
|
+
makeEllipsoid as f,
|
|
520
|
+
genericSweep as g,
|
|
521
|
+
makeOffset as h,
|
|
522
|
+
makeSphere as i,
|
|
523
|
+
makeTorus as j,
|
|
524
|
+
makeVertex as k,
|
|
525
|
+
loft as l,
|
|
526
|
+
makeCompound as m,
|
|
527
|
+
buildLawFromProfile as n,
|
|
528
|
+
revolution as r,
|
|
529
|
+
twistExtrude as t,
|
|
530
|
+
weldShellsAndFaces as w
|
|
531
|
+
};
|