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,11 +1,56 @@
|
|
|
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
48
|
const vecOps = require("./vecOps-CjRL1jau.cjs");
|
|
4
|
-
const shapeTypes = require("./shapeTypes-
|
|
5
|
-
const faceFns = require("./faceFns-
|
|
49
|
+
const shapeTypes = require("./shapeTypes-CWuX602K.cjs");
|
|
50
|
+
const faceFns = require("./faceFns-DNQss51F.cjs");
|
|
6
51
|
const errors = require("./errors-NNmTtM5u.cjs");
|
|
7
|
-
const loft = require("./loft-
|
|
8
|
-
const booleanFns = require("./booleanFns-
|
|
52
|
+
const loft = require("./loft-CjEEqz2P.cjs");
|
|
53
|
+
const booleanFns = require("./booleanFns-CVM3dOTP.cjs");
|
|
9
54
|
function uuidv() {
|
|
10
55
|
return (String([1e7]) + String(-1e3) + String(-4e3) + String(-8e3) + String(-1e11)).replace(
|
|
11
56
|
/[018]/g,
|
|
@@ -33,10 +78,10 @@ function wrapColor(hex, alpha = 1) {
|
|
|
33
78
|
const [red, green, blue] = colorFromHex(hex);
|
|
34
79
|
return new oc.Quantity_ColorRGBA_5(red / 255, green / 255, blue / 255, alpha);
|
|
35
80
|
}
|
|
36
|
-
function configureStepUnits(unit, modelUnit,
|
|
81
|
+
function configureStepUnits(unit, modelUnit, scope) {
|
|
37
82
|
if (!unit && !modelUnit) return;
|
|
38
83
|
const oc = occtBoundary.getKernel().oc;
|
|
39
|
-
|
|
84
|
+
scope.register(new oc.STEPCAFControl_Writer_1());
|
|
40
85
|
oc.Interface_Static.SetCVal("xstep.cascade.unit", (modelUnit || unit || "MM").toUpperCase());
|
|
41
86
|
oc.Interface_Static.SetCVal("write.step.unit", (unit || modelUnit || "MM").toUpperCase());
|
|
42
87
|
}
|
|
@@ -71,38 +116,55 @@ function createAssembly(shapes = []) {
|
|
|
71
116
|
return shapeTypes.createOcHandle(doc);
|
|
72
117
|
}
|
|
73
118
|
function makeSpineWire(start, end) {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
119
|
+
var _stack = [];
|
|
120
|
+
try {
|
|
121
|
+
const oc = occtBoundary.getKernel().oc;
|
|
122
|
+
const scope = __using(_stack, new shapeTypes.DisposalScope());
|
|
123
|
+
const pnt1 = scope.register(occtBoundary.toOcPnt(start));
|
|
124
|
+
const pnt2 = scope.register(occtBoundary.toOcPnt(end));
|
|
125
|
+
const edgeMaker = scope.register(new oc.BRepBuilderAPI_MakeEdge_3(pnt1, pnt2));
|
|
126
|
+
const wireMaker = scope.register(new oc.BRepBuilderAPI_MakeWire_2(edgeMaker.Edge()));
|
|
127
|
+
return shapeTypes.castShape(wireMaker.Wire());
|
|
128
|
+
} catch (_) {
|
|
129
|
+
var _error = _, _hasError = true;
|
|
130
|
+
} finally {
|
|
131
|
+
__callDispose(_stack, _error, _hasError);
|
|
132
|
+
}
|
|
81
133
|
}
|
|
82
134
|
function makeHelixWire(pitch, height, radius, center, dir, lefthand = false) {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
new oc.
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
)
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
135
|
+
var _stack = [];
|
|
136
|
+
try {
|
|
137
|
+
const oc = occtBoundary.getKernel().oc;
|
|
138
|
+
const scope = __using(_stack, new shapeTypes.DisposalScope());
|
|
139
|
+
let myDir = 2 * Math.PI;
|
|
140
|
+
if (lefthand) myDir = -2 * Math.PI;
|
|
141
|
+
const geomLine = scope.register(
|
|
142
|
+
new oc.Geom2d_Line_3(
|
|
143
|
+
scope.register(new oc.gp_Pnt2d_3(0, 0)),
|
|
144
|
+
scope.register(new oc.gp_Dir2d_4(myDir, pitch))
|
|
145
|
+
)
|
|
146
|
+
);
|
|
147
|
+
const nTurns = height / pitch;
|
|
148
|
+
const uStart = scope.register(geomLine.Value(0));
|
|
149
|
+
const uStop = scope.register(geomLine.Value(nTurns * Math.sqrt((2 * Math.PI) ** 2 + pitch ** 2)));
|
|
150
|
+
const geomSeg = scope.register(new oc.GCE2d_MakeSegment_1(uStart, uStop));
|
|
151
|
+
const ax3 = occtBoundary.makeOcAx3(center, dir);
|
|
152
|
+
const geomSurf = new oc.Geom_CylindricalSurface_1(ax3, radius);
|
|
153
|
+
ax3.delete();
|
|
154
|
+
const e = scope.register(
|
|
155
|
+
new oc.BRepBuilderAPI_MakeEdge_30(
|
|
156
|
+
scope.register(new oc.Handle_Geom2d_Curve_2(geomSeg.Value().get())),
|
|
157
|
+
scope.register(new oc.Handle_Geom_Surface_2(geomSurf))
|
|
158
|
+
)
|
|
159
|
+
).Edge();
|
|
160
|
+
const w = scope.register(new oc.BRepBuilderAPI_MakeWire_2(e)).Wire();
|
|
161
|
+
oc.BRepLib.BuildCurves3d_2(w);
|
|
162
|
+
return shapeTypes.castShape(w);
|
|
163
|
+
} catch (_) {
|
|
164
|
+
var _error = _, _hasError = true;
|
|
165
|
+
} finally {
|
|
166
|
+
__callDispose(_stack, _error, _hasError);
|
|
167
|
+
}
|
|
106
168
|
}
|
|
107
169
|
function extrude(face, extrusionVec) {
|
|
108
170
|
if (face.wrapped.IsNull()) {
|
|
@@ -112,17 +174,24 @@ function extrude(face, extrusionVec) {
|
|
|
112
174
|
return errors.err(errors.validationError("EXTRUDE_ZERO_VECTOR", "extrude: extrusion vector has zero length"));
|
|
113
175
|
}
|
|
114
176
|
try {
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
177
|
+
var _stack = [];
|
|
178
|
+
try {
|
|
179
|
+
const oc = occtBoundary.getKernel().oc;
|
|
180
|
+
const scope = __using(_stack, new shapeTypes.DisposalScope());
|
|
181
|
+
const vec = scope.register(occtBoundary.toOcVec(extrusionVec));
|
|
182
|
+
const builder = scope.register(new oc.BRepPrimAPI_MakePrism_1(face.wrapped, vec, false, true));
|
|
183
|
+
const shape = builder.Shape();
|
|
184
|
+
const downcastResult = faceFns.downcast(shape);
|
|
185
|
+
if (errors.isErr(downcastResult)) {
|
|
186
|
+
return downcastResult;
|
|
187
|
+
}
|
|
188
|
+
const solid = shapeTypes.createSolid(downcastResult.value);
|
|
189
|
+
return errors.ok(solid);
|
|
190
|
+
} catch (_) {
|
|
191
|
+
var _error = _, _hasError = true;
|
|
192
|
+
} finally {
|
|
193
|
+
__callDispose(_stack, _error, _hasError);
|
|
123
194
|
}
|
|
124
|
-
const solid = shapeTypes.createSolid(downcastResult.value);
|
|
125
|
-
return errors.ok(solid);
|
|
126
195
|
} catch (e) {
|
|
127
196
|
return errors.err(
|
|
128
197
|
errors.occtError("EXTRUDE_FAILED", "Extrusion operation failed", e, {
|
|
@@ -133,95 +202,111 @@ function extrude(face, extrusionVec) {
|
|
|
133
202
|
}
|
|
134
203
|
}
|
|
135
204
|
function revolve(face, center = [0, 0, 0], direction = [0, 0, 1], angle = 360) {
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
205
|
+
var _stack = [];
|
|
206
|
+
try {
|
|
207
|
+
if (face.wrapped.IsNull()) {
|
|
208
|
+
return errors.err(errors.validationError(errors.BrepErrorCode.NULL_SHAPE_INPUT, "revolve: face is a null shape"));
|
|
209
|
+
}
|
|
210
|
+
const oc = occtBoundary.getKernel().oc;
|
|
211
|
+
const scope = __using(_stack, new shapeTypes.DisposalScope());
|
|
212
|
+
const pnt = scope.register(new oc.gp_Pnt_3(center[0], center[1], center[2]));
|
|
213
|
+
const dir = scope.register(new oc.gp_Dir_4(direction[0], direction[1], direction[2]));
|
|
214
|
+
const ax = scope.register(new oc.gp_Ax1_2(pnt, dir));
|
|
215
|
+
const builder = scope.register(
|
|
216
|
+
new oc.BRepPrimAPI_MakeRevol_1(face.wrapped, ax, angle * vecOps.DEG2RAD, false)
|
|
217
|
+
);
|
|
218
|
+
const result = shapeTypes.castShape(builder.Shape());
|
|
219
|
+
if (!shapeTypes.isShape3D(result)) {
|
|
220
|
+
return errors.err(errors.typeCastError("REVOLUTION_NOT_3D", "Revolution did not produce a 3D shape"));
|
|
221
|
+
}
|
|
222
|
+
return errors.ok(result);
|
|
223
|
+
} catch (_) {
|
|
224
|
+
var _error = _, _hasError = true;
|
|
225
|
+
} finally {
|
|
226
|
+
__callDispose(_stack, _error, _hasError);
|
|
148
227
|
}
|
|
149
|
-
return errors.ok(result);
|
|
150
228
|
}
|
|
151
229
|
function sweep(wire, spine, config = {}, shellMode = false) {
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
230
|
+
var _stack = [];
|
|
231
|
+
try {
|
|
232
|
+
if (config.mode === "simple" && !shellMode) {
|
|
233
|
+
const kernel = occtBoundary.getKernel();
|
|
234
|
+
const resultOc = kernel.simplePipe(wire.wrapped, spine.wrapped);
|
|
235
|
+
const shape2 = shapeTypes.castShape(resultOc);
|
|
236
|
+
if (!shapeTypes.isShape3D(shape2)) {
|
|
237
|
+
return errors.err(errors.typeCastError("SWEEP_NOT_3D", "Simple pipe did not produce a 3D shape"));
|
|
238
|
+
}
|
|
239
|
+
return errors.ok(shape2);
|
|
158
240
|
}
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
if (maxSegments !== void 0) {
|
|
186
|
-
builder.SetMaxSegments(maxSegments);
|
|
187
|
-
}
|
|
188
|
-
{
|
|
189
|
-
const mode = {
|
|
190
|
-
transformed: oc.BRepBuilderAPI_TransitionMode.BRepBuilderAPI_Transformed,
|
|
191
|
-
round: oc.BRepBuilderAPI_TransitionMode.BRepBuilderAPI_RoundCorner,
|
|
192
|
-
right: oc.BRepBuilderAPI_TransitionMode.BRepBuilderAPI_RightCorner
|
|
193
|
-
}[transitionMode];
|
|
194
|
-
if (mode) builder.SetTransitionMode(mode);
|
|
195
|
-
}
|
|
196
|
-
if (support) {
|
|
197
|
-
builder.SetMode_4(support);
|
|
198
|
-
} else if (frenet) {
|
|
199
|
-
builder.SetMode_1(frenet);
|
|
200
|
-
}
|
|
201
|
-
if (auxiliarySpine) {
|
|
202
|
-
builder.SetMode_5(auxiliarySpine.wrapped, false, oc.BRepFill_TypeOfContact.BRepFill_NoContact);
|
|
203
|
-
}
|
|
204
|
-
if (!law) builder.Add_1(wire.wrapped, !!withContact, withCorrection);
|
|
205
|
-
else builder.SetLaw_1(wire.wrapped, law, !!withContact, withCorrection);
|
|
206
|
-
const progress = r(new oc.Message_ProgressRange_1());
|
|
207
|
-
builder.Build(progress);
|
|
208
|
-
if (!shellMode) builder.MakeSolid();
|
|
209
|
-
const shape = shapeTypes.castShape(builder.Shape());
|
|
210
|
-
if (!shapeTypes.isShape3D(shape)) {
|
|
211
|
-
return errors.err(errors.typeCastError("SWEEP_NOT_3D", "Sweep did not produce a 3D shape"));
|
|
212
|
-
}
|
|
213
|
-
if (shellMode) {
|
|
214
|
-
const startWire = shapeTypes.castShape(builder.FirstShape());
|
|
215
|
-
const endWire = shapeTypes.castShape(builder.LastShape());
|
|
216
|
-
if (!shapeTypes.isWire(startWire)) {
|
|
217
|
-
return errors.err(errors.typeCastError("SWEEP_START_NOT_WIRE", "Sweep did not produce a start Wire"));
|
|
241
|
+
const oc = occtBoundary.getKernel().oc;
|
|
242
|
+
const scope = __using(_stack, new shapeTypes.DisposalScope());
|
|
243
|
+
const {
|
|
244
|
+
frenet = false,
|
|
245
|
+
auxiliarySpine,
|
|
246
|
+
law = null,
|
|
247
|
+
transitionMode = "right",
|
|
248
|
+
withContact,
|
|
249
|
+
support,
|
|
250
|
+
forceProfileSpineOthogonality,
|
|
251
|
+
tolerance,
|
|
252
|
+
boundTolerance,
|
|
253
|
+
angularTolerance,
|
|
254
|
+
maxDegree,
|
|
255
|
+
maxSegments
|
|
256
|
+
} = config;
|
|
257
|
+
const withCorrection = transitionMode === "round" ? true : !!forceProfileSpineOthogonality;
|
|
258
|
+
const builder = scope.register(new oc.BRepOffsetAPI_MakePipeShell(spine.wrapped));
|
|
259
|
+
if (tolerance !== void 0) {
|
|
260
|
+
builder.SetTolerance(tolerance, boundTolerance ?? tolerance, angularTolerance ?? 1e-7);
|
|
261
|
+
}
|
|
262
|
+
if (maxDegree !== void 0) {
|
|
263
|
+
builder.SetMaxDegree(maxDegree);
|
|
264
|
+
}
|
|
265
|
+
if (maxSegments !== void 0) {
|
|
266
|
+
builder.SetMaxSegments(maxSegments);
|
|
218
267
|
}
|
|
219
|
-
|
|
220
|
-
|
|
268
|
+
{
|
|
269
|
+
const mode = {
|
|
270
|
+
transformed: oc.BRepBuilderAPI_TransitionMode.BRepBuilderAPI_Transformed,
|
|
271
|
+
round: oc.BRepBuilderAPI_TransitionMode.BRepBuilderAPI_RoundCorner,
|
|
272
|
+
right: oc.BRepBuilderAPI_TransitionMode.BRepBuilderAPI_RightCorner
|
|
273
|
+
}[transitionMode];
|
|
274
|
+
if (mode) builder.SetTransitionMode(mode);
|
|
221
275
|
}
|
|
222
|
-
|
|
276
|
+
if (support) {
|
|
277
|
+
builder.SetMode_4(support);
|
|
278
|
+
} else if (frenet) {
|
|
279
|
+
builder.SetMode_1(frenet);
|
|
280
|
+
}
|
|
281
|
+
if (auxiliarySpine) {
|
|
282
|
+
builder.SetMode_5(auxiliarySpine.wrapped, false, oc.BRepFill_TypeOfContact.BRepFill_NoContact);
|
|
283
|
+
}
|
|
284
|
+
if (!law) builder.Add_1(wire.wrapped, !!withContact, withCorrection);
|
|
285
|
+
else builder.SetLaw_1(wire.wrapped, law, !!withContact, withCorrection);
|
|
286
|
+
const progress = scope.register(new oc.Message_ProgressRange_1());
|
|
287
|
+
builder.Build(progress);
|
|
288
|
+
if (!shellMode) builder.MakeSolid();
|
|
289
|
+
const shape = shapeTypes.castShape(builder.Shape());
|
|
290
|
+
if (!shapeTypes.isShape3D(shape)) {
|
|
291
|
+
return errors.err(errors.typeCastError("SWEEP_NOT_3D", "Sweep did not produce a 3D shape"));
|
|
292
|
+
}
|
|
293
|
+
if (shellMode) {
|
|
294
|
+
const startWire = shapeTypes.castShape(builder.FirstShape());
|
|
295
|
+
const endWire = shapeTypes.castShape(builder.LastShape());
|
|
296
|
+
if (!shapeTypes.isWire(startWire)) {
|
|
297
|
+
return errors.err(errors.typeCastError("SWEEP_START_NOT_WIRE", "Sweep did not produce a start Wire"));
|
|
298
|
+
}
|
|
299
|
+
if (!shapeTypes.isWire(endWire)) {
|
|
300
|
+
return errors.err(errors.typeCastError("SWEEP_END_NOT_WIRE", "Sweep did not produce an end Wire"));
|
|
301
|
+
}
|
|
302
|
+
return errors.ok([shape, startWire, endWire]);
|
|
303
|
+
}
|
|
304
|
+
return errors.ok(shape);
|
|
305
|
+
} catch (_) {
|
|
306
|
+
var _error = _, _hasError = true;
|
|
307
|
+
} finally {
|
|
308
|
+
__callDispose(_stack, _error, _hasError);
|
|
223
309
|
}
|
|
224
|
-
return errors.ok(shape);
|
|
225
310
|
}
|
|
226
311
|
function supportExtrude(wire, center, normal, support) {
|
|
227
312
|
const endPoint = vecOps.vecAdd(center, normal);
|
|
@@ -258,48 +343,58 @@ function twistExtrude(wire, angleDegrees, center, normal, profileShape, shellMod
|
|
|
258
343
|
return sweep(wire, spine, { auxiliarySpine, law }, shellMode);
|
|
259
344
|
}
|
|
260
345
|
function exportAssemblySTEP(shapes = [], { unit, modelUnit } = {}) {
|
|
261
|
-
|
|
262
|
-
const r = shapeTypes.gcWithScope();
|
|
263
|
-
const doc = new oc.TDocStd_Document(wrapString("XmlOcaf"));
|
|
346
|
+
var _stack = [];
|
|
264
347
|
try {
|
|
265
|
-
oc.
|
|
266
|
-
const
|
|
267
|
-
const
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
const
|
|
271
|
-
tool.
|
|
272
|
-
oc.
|
|
273
|
-
|
|
274
|
-
shapeNode
|
|
275
|
-
|
|
276
|
-
oc.
|
|
348
|
+
const oc = occtBoundary.getKernel().oc;
|
|
349
|
+
const scope = __using(_stack, new shapeTypes.DisposalScope());
|
|
350
|
+
const doc = new oc.TDocStd_Document(wrapString("XmlOcaf"));
|
|
351
|
+
try {
|
|
352
|
+
oc.XCAFDoc_ShapeTool.SetAutoNaming(false);
|
|
353
|
+
const mainLabel = doc.Main();
|
|
354
|
+
const tool = oc.XCAFDoc_DocumentTool.ShapeTool(mainLabel).get();
|
|
355
|
+
const ctool = oc.XCAFDoc_DocumentTool.ColorTool(mainLabel).get();
|
|
356
|
+
for (const { shape, name, color, alpha } of shapes) {
|
|
357
|
+
const shapeNode = tool.NewShape();
|
|
358
|
+
tool.SetShape(shapeNode, shape.wrapped);
|
|
359
|
+
oc.TDataStd_Name.Set_1(shapeNode, wrapString(name || uuidv()));
|
|
360
|
+
ctool.SetColor_3(
|
|
361
|
+
shapeNode,
|
|
362
|
+
wrapColor(color || "#f00", alpha ?? 1),
|
|
363
|
+
oc.XCAFDoc_ColorType.XCAFDoc_ColorSurf
|
|
364
|
+
);
|
|
365
|
+
}
|
|
366
|
+
tool.UpdateAssemblies();
|
|
367
|
+
configureStepUnits(unit, modelUnit, scope);
|
|
368
|
+
const session = scope.register(new oc.XSControl_WorkSession());
|
|
369
|
+
const writer = scope.register(
|
|
370
|
+
new oc.STEPCAFControl_Writer_2(
|
|
371
|
+
scope.register(new oc.Handle_XSControl_WorkSession_2(session)),
|
|
372
|
+
false
|
|
373
|
+
)
|
|
277
374
|
);
|
|
375
|
+
configureStepWriter(writer);
|
|
376
|
+
const progress = scope.register(new oc.Message_ProgressRange_1());
|
|
377
|
+
writer.Transfer_1(
|
|
378
|
+
new oc.Handle_TDocStd_Document_2(doc),
|
|
379
|
+
oc.STEPControl_StepModelType.STEPControl_AsIs,
|
|
380
|
+
null,
|
|
381
|
+
progress
|
|
382
|
+
);
|
|
383
|
+
const filename = occtBoundary.uniqueIOFilename("_export", "step");
|
|
384
|
+
const done = writer.Write(filename);
|
|
385
|
+
if (done === oc.IFSelect_ReturnStatus.IFSelect_RetDone) {
|
|
386
|
+
const file = oc.FS.readFile("/" + filename);
|
|
387
|
+
oc.FS.unlink("/" + filename);
|
|
388
|
+
return errors.ok(new Blob([file], { type: "application/STEP" }));
|
|
389
|
+
}
|
|
390
|
+
return errors.err(errors.ioError("STEP_EXPORT_FAILED", "Failed to write STEP file"));
|
|
391
|
+
} finally {
|
|
392
|
+
doc.delete();
|
|
278
393
|
}
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
const session = r(new oc.XSControl_WorkSession());
|
|
282
|
-
const writer = r(
|
|
283
|
-
new oc.STEPCAFControl_Writer_2(r(new oc.Handle_XSControl_WorkSession_2(session)), false)
|
|
284
|
-
);
|
|
285
|
-
configureStepWriter(writer);
|
|
286
|
-
const progress = r(new oc.Message_ProgressRange_1());
|
|
287
|
-
writer.Transfer_1(
|
|
288
|
-
new oc.Handle_TDocStd_Document_2(doc),
|
|
289
|
-
oc.STEPControl_StepModelType.STEPControl_AsIs,
|
|
290
|
-
null,
|
|
291
|
-
progress
|
|
292
|
-
);
|
|
293
|
-
const filename = occtBoundary.uniqueIOFilename("_export", "step");
|
|
294
|
-
const done = writer.Write(filename);
|
|
295
|
-
if (done === oc.IFSelect_ReturnStatus.IFSelect_RetDone) {
|
|
296
|
-
const file = oc.FS.readFile("/" + filename);
|
|
297
|
-
oc.FS.unlink("/" + filename);
|
|
298
|
-
return errors.ok(new Blob([file], { type: "application/STEP" }));
|
|
299
|
-
}
|
|
300
|
-
return errors.err(errors.ioError("STEP_EXPORT_FAILED", "Failed to write STEP file"));
|
|
394
|
+
} catch (_) {
|
|
395
|
+
var _error = _, _hasError = true;
|
|
301
396
|
} finally {
|
|
302
|
-
|
|
397
|
+
__callDispose(_stack, _error, _hasError);
|
|
303
398
|
}
|
|
304
399
|
}
|
|
305
400
|
function linearPattern(shape, direction, count, spacing, options) {
|
package/dist/operations.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const operations = require("./operations-
|
|
4
|
-
const loft = require("./loft-
|
|
3
|
+
const operations = require("./operations-pxjbW4Er.cjs");
|
|
4
|
+
const loft = require("./loft-CjEEqz2P.cjs");
|
|
5
5
|
exports.addChild = operations.addChild;
|
|
6
6
|
exports.addStep = operations.addStep;
|
|
7
7
|
exports.circularPattern = operations.circularPattern;
|
package/dist/operations.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a, b, c, d, f, g, h, i, j, k, m, n, o, p, l, q, t, u, v, x, y, z, A, B, s, C, D, E, w } from "./operations-
|
|
2
|
-
import { b as b2, g as g2, l as l2, r } from "./loft-
|
|
1
|
+
import { a, b, c, d, f, g, h, i, j, k, m, n, o, p, l, q, t, u, v, x, y, z, A, B, s, C, D, E, w } from "./operations-jRE2QbPo.js";
|
|
2
|
+
import { b as b2, g as g2, l as l2, r } from "./loft-DTRcYrq2.js";
|
|
3
3
|
export {
|
|
4
4
|
a as addChild,
|
|
5
5
|
b as addStep,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shapeDistanceFilter.d.ts","sourceRoot":"","sources":["../../src/query/shapeDistanceFilter.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAItD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEjD;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,CAAC,SAAS,QAAQ,EACxD,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,IAAI,EACX,SAAS,EAAE,MAAM,GAChB,SAAS,CAAC,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"shapeDistanceFilter.d.ts","sourceRoot":"","sources":["../../src/query/shapeDistanceFilter.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAItD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEjD;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,CAAC,SAAS,QAAQ,EACxD,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,IAAI,EACX,SAAS,EAAE,MAAM,GAChB,SAAS,CAAC,CAAC,CAAC,CA2Bd"}
|
package/dist/query.cjs
CHANGED
|
@@ -1,24 +1,76 @@
|
|
|
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
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const helpers = require("./helpers-
|
|
4
|
-
const cornerFinder = require("./cornerFinder-
|
|
48
|
+
const helpers = require("./helpers-aylLv0_I.cjs");
|
|
49
|
+
const cornerFinder = require("./cornerFinder-XAV2ywVS.cjs");
|
|
5
50
|
const occtBoundary = require("./occtBoundary-Cqfsau2c.cjs");
|
|
6
|
-
const shapeTypes = require("./shapeTypes-
|
|
51
|
+
const shapeTypes = require("./shapeTypes-CWuX602K.cjs");
|
|
7
52
|
const vecOps = require("./vecOps-CjRL1jau.cjs");
|
|
8
|
-
const curveFns = require("./curveFns-
|
|
53
|
+
const curveFns = require("./curveFns-BsAHC3Qv.cjs");
|
|
9
54
|
function edgeDirectionFilter(dir, angle) {
|
|
10
55
|
const d = vecOps.vecNormalize(helpers.resolveDir(dir));
|
|
11
56
|
return (edge) => {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
57
|
+
var _stack = [];
|
|
58
|
+
try {
|
|
59
|
+
const oc = occtBoundary.getKernel().oc;
|
|
60
|
+
const scope = __using(_stack, new shapeTypes.DisposalScope());
|
|
61
|
+
const adaptor = scope.register(new oc.BRepAdaptor_Curve_2(edge.wrapped));
|
|
62
|
+
const tmpPnt = scope.register(new oc.gp_Pnt_1());
|
|
63
|
+
const tmpVec = scope.register(new oc.gp_Vec_1());
|
|
64
|
+
const mid = (Number(adaptor.FirstParameter()) + Number(adaptor.LastParameter())) / 2;
|
|
65
|
+
adaptor.D1(mid, tmpPnt, tmpVec);
|
|
66
|
+
const tangent = vecOps.vecNormalize([tmpVec.X(), tmpVec.Y(), tmpVec.Z()]);
|
|
67
|
+
const ang = Math.acos(Math.min(1, Math.abs(vecOps.vecDot(tangent, d))));
|
|
68
|
+
return Math.abs(ang - vecOps.DEG2RAD * angle) < 1e-6;
|
|
69
|
+
} catch (_) {
|
|
70
|
+
var _error = _, _hasError = true;
|
|
71
|
+
} finally {
|
|
72
|
+
__callDispose(_stack, _error, _hasError);
|
|
73
|
+
}
|
|
22
74
|
};
|
|
23
75
|
}
|
|
24
76
|
function buildEdgeFinder(filters) {
|