brepjs 8.8.2 → 8.8.4
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-C4Rx89oe.js +1440 -0
- package/dist/Blueprint-D1Dik12C.cjs +1439 -0
- package/dist/{boolean2D-q5FOdOQW.cjs → boolean2D-BZnkU_aH.cjs} +215 -130
- package/dist/{boolean2D-Dgnuy63w.js → boolean2D-D4j89vF_.js} +215 -130
- package/dist/{booleanFns-CFit7JYt.cjs → booleanFns-Cf_0aWNe.cjs} +214 -133
- package/dist/{booleanFns--Orezl-b.js → booleanFns-D6SeHoCv.js} +214 -133
- package/dist/brepjs.cjs +478 -314
- package/dist/brepjs.js +574 -410
- package/dist/core/disposal.d.ts +44 -3
- package/dist/core/disposal.d.ts.map +1 -1
- package/dist/core/errors.d.ts +2 -0
- package/dist/core/errors.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 +7 -4
- package/dist/core.d.ts +1 -1
- package/dist/core.d.ts.map +1 -1
- package/dist/core.js +14 -11
- package/dist/{cornerFinder-KNTFoGrm.js → cornerFinder-CypY3T_w.js} +1 -1
- package/dist/{cornerFinder-v4un1Fr9.cjs → cornerFinder-DbRL42YI.cjs} +1 -1
- package/dist/{curveFns-6ovDM_sR.cjs → curveFns-KDpL9iyo.cjs} +139 -38
- package/dist/curveFns-VDZEhY97.js +281 -0
- package/dist/{drawFns-WgXeXHH1.cjs → drawFns-B52K-9DJ.cjs} +184 -104
- package/dist/{drawFns-XwroLxdb.js → drawFns-CVPwl2No.js} +184 -104
- package/dist/{errors-NNmTtM5u.cjs → errors-BYb4tL5h.cjs} +3 -0
- package/dist/{errors-DJ92ermb.js → errors-CHfaHQSt.js} +3 -0
- package/dist/faceFns-B8xnZw-f.cjs +358 -0
- package/dist/faceFns-DG4bu-QB.js +359 -0
- package/dist/{helpers-CRfqaW0Y.cjs → helpers-Cfibxk7U.cjs} +15 -12
- package/dist/{helpers-CtBCzEqs.js → helpers-zsENdJlc.js} +15 -12
- 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 +133 -65
- package/dist/io.js +133 -65
- package/dist/kernel/booleanOps.d.ts.map +1 -1
- package/dist/loft-Bhnw5Rfr.cjs +530 -0
- package/dist/loft-fSnlFn-j.js +531 -0
- package/dist/measurement-C4Ofuy_y.cjs +200 -0
- package/dist/measurement-DzRb6oYN.js +201 -0
- package/dist/measurement.cjs +1 -1
- package/dist/measurement.js +1 -1
- package/dist/{meshFns-CPNNlpbw.cjs → meshFns-C-6Cq3V-.cjs} +3 -3
- package/dist/{meshFns-DAmWVyEp.js → meshFns-Cw3IFJjg.js} +3 -3
- package/dist/{occtBoundary-Cqfsau2c.cjs → occtBoundary-CN_uQJtA.cjs} +4 -3
- package/dist/{occtBoundary-DvBywHyU.js → occtBoundary-Ct0tN8cs.js} +4 -3
- 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-BQ25CPI8.cjs → operations-DvwWDqIp.cjs} +263 -168
- package/dist/{operations-vN0tcoaU.js → operations-PYuj8GLd.js} +263 -168
- 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 +67 -15
- package/dist/query.js +68 -16
- package/dist/result.cjs +1 -1
- package/dist/result.js +1 -1
- package/dist/{shapeFns-C785aeVn.cjs → shapeFns-ByLUl6KE.cjs} +63 -9
- package/dist/{shapeFns-ClpALED4.js → shapeFns-QL3zx6uW.js} +63 -9
- package/dist/{shapeTypes-DnwCo942.js → shapeTypes-D34s68Xi.js} +51 -20
- package/dist/{shapeTypes-CIijJxCz.cjs → shapeTypes-sXITvFkF.cjs} +33 -2
- 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-DYX6h68y.js +436 -0
- package/dist/surfaceBuilders-hupjYn0W.cjs +435 -0
- package/dist/topology/booleanFns.d.ts.map +1 -1
- package/dist/topology/compoundOpsFns.d.ts.map +1 -1
- 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-zG8maSDK.cjs → topology-DWe9SYAy.cjs} +8 -8
- package/dist/{topology-CqyxpmEh.js → topology-psR8Hqiz.js} +8 -8
- package/dist/topology.cjs +6 -6
- package/dist/topology.js +6 -6
- package/dist/{vectors-CGLqemPY.cjs → vectors-9rrStq8t.cjs} +2 -2
- package/dist/{vectors-2lOjaa8N.js → vectors-Dp5Iu1KH.js} +2 -2
- package/dist/vectors.cjs +2 -2
- package/dist/vectors.js +2 -2
- 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
package/dist/brepjs.cjs
CHANGED
|
@@ -1,29 +1,74 @@
|
|
|
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
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const occtBoundary = require("./occtBoundary-
|
|
4
|
-
const errors = require("./errors-
|
|
5
|
-
const shapeTypes = require("./shapeTypes-
|
|
48
|
+
const occtBoundary = require("./occtBoundary-CN_uQJtA.cjs");
|
|
49
|
+
const errors = require("./errors-BYb4tL5h.cjs");
|
|
50
|
+
const shapeTypes = require("./shapeTypes-sXITvFkF.cjs");
|
|
6
51
|
const vecOps = require("./vecOps-CjRL1jau.cjs");
|
|
7
|
-
const Blueprint = require("./Blueprint-
|
|
8
|
-
const curveFns = require("./curveFns-
|
|
9
|
-
const loft$2 = require("./loft-
|
|
10
|
-
const operations = require("./operations-
|
|
11
|
-
const boolean2D = require("./boolean2D-
|
|
52
|
+
const Blueprint = require("./Blueprint-D1Dik12C.cjs");
|
|
53
|
+
const curveFns = require("./curveFns-KDpL9iyo.cjs");
|
|
54
|
+
const loft$2 = require("./loft-Bhnw5Rfr.cjs");
|
|
55
|
+
const operations = require("./operations-DvwWDqIp.cjs");
|
|
56
|
+
const boolean2D = require("./boolean2D-BZnkU_aH.cjs");
|
|
12
57
|
const _2d = require("./2d.cjs");
|
|
13
|
-
const helpers = require("./helpers-
|
|
58
|
+
const helpers = require("./helpers-Cfibxk7U.cjs");
|
|
14
59
|
const io = require("./io.cjs");
|
|
15
|
-
const drawFns = require("./drawFns-
|
|
16
|
-
const vectors = require("./vectors-
|
|
17
|
-
const shapeFns = require("./shapeFns-
|
|
18
|
-
const booleanFns = require("./booleanFns-
|
|
19
|
-
const topology = require("./topology-
|
|
20
|
-
const faceFns = require("./faceFns-
|
|
21
|
-
const meshFns = require("./meshFns-
|
|
22
|
-
const measurement = require("./measurement-
|
|
23
|
-
const surfaceBuilders = require("./surfaceBuilders-
|
|
60
|
+
const drawFns = require("./drawFns-B52K-9DJ.cjs");
|
|
61
|
+
const vectors = require("./vectors-9rrStq8t.cjs");
|
|
62
|
+
const shapeFns = require("./shapeFns-ByLUl6KE.cjs");
|
|
63
|
+
const booleanFns = require("./booleanFns-Cf_0aWNe.cjs");
|
|
64
|
+
const topology = require("./topology-DWe9SYAy.cjs");
|
|
65
|
+
const faceFns = require("./faceFns-B8xnZw-f.cjs");
|
|
66
|
+
const meshFns = require("./meshFns-C-6Cq3V-.cjs");
|
|
67
|
+
const measurement = require("./measurement-C4Ofuy_y.cjs");
|
|
68
|
+
const surfaceBuilders = require("./surfaceBuilders-hupjYn0W.cjs");
|
|
24
69
|
const query = require("./query.cjs");
|
|
25
70
|
const result = require("./result.cjs");
|
|
26
|
-
const cornerFinder = require("./cornerFinder-
|
|
71
|
+
const cornerFinder = require("./cornerFinder-DbRL42YI.cjs");
|
|
27
72
|
const worker = require("./worker.cjs");
|
|
28
73
|
const errorFactories = {
|
|
29
74
|
OCCT_OPERATION: (code, message, cause) => ({ kind: "OCCT_OPERATION", code, message, cause }),
|
|
@@ -53,6 +98,17 @@ function kernelCallRaw(fn, code, message, kind = "OCCT_OPERATION") {
|
|
|
53
98
|
return errors.err(errorFactories[kind](code, `${message}: ${translatedMessage}`, e));
|
|
54
99
|
}
|
|
55
100
|
}
|
|
101
|
+
function kernelCallScoped(fn, code, message, kind = "OCCT_OPERATION") {
|
|
102
|
+
var _stack = [];
|
|
103
|
+
try {
|
|
104
|
+
const scope = __using(_stack, new shapeTypes.DisposalScope());
|
|
105
|
+
return kernelCall(() => fn(scope), code, message, kind);
|
|
106
|
+
} catch (_) {
|
|
107
|
+
var _error = _, _hasError = true;
|
|
108
|
+
} finally {
|
|
109
|
+
__callDispose(_stack, _error, _hasError);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
56
112
|
function isNumber(r) {
|
|
57
113
|
return typeof r === "number";
|
|
58
114
|
}
|
|
@@ -414,56 +470,70 @@ function hull(shapes, options = {}) {
|
|
|
414
470
|
}
|
|
415
471
|
}
|
|
416
472
|
function detectSphere(shape2) {
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
473
|
+
var _stack = [];
|
|
474
|
+
try {
|
|
475
|
+
const oc = occtBoundary.getKernel().oc;
|
|
476
|
+
const faces = shapeFns.getFaces(shape2);
|
|
477
|
+
if (faces.length !== 1) return null;
|
|
478
|
+
const face2 = faces[0];
|
|
479
|
+
const scope = __using(_stack, new shapeTypes.DisposalScope());
|
|
480
|
+
const adaptor = scope.register(new oc.BRepAdaptor_Surface_2(face2.wrapped, true));
|
|
481
|
+
const surfType = adaptor.GetType();
|
|
482
|
+
if (surfType !== oc.GeomAbs_SurfaceType.GeomAbs_Sphere) return null;
|
|
483
|
+
const ocSphere = adaptor.Sphere();
|
|
484
|
+
const radius = ocSphere.Radius();
|
|
485
|
+
ocSphere.delete();
|
|
486
|
+
return radius;
|
|
487
|
+
} catch (_) {
|
|
488
|
+
var _error = _, _hasError = true;
|
|
489
|
+
} finally {
|
|
490
|
+
__callDispose(_stack, _error, _hasError);
|
|
491
|
+
}
|
|
429
492
|
}
|
|
430
493
|
function minkowskiSphere(shape2, radius, tolerance) {
|
|
431
|
-
|
|
432
|
-
const r = shapeTypes.gcWithScope();
|
|
494
|
+
var _stack = [];
|
|
433
495
|
try {
|
|
434
|
-
const
|
|
435
|
-
const
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
496
|
+
const oc = occtBoundary.getKernel().oc;
|
|
497
|
+
const scope = __using(_stack, new shapeTypes.DisposalScope());
|
|
498
|
+
try {
|
|
499
|
+
const offsetMaker = scope.register(new oc.BRepOffsetAPI_MakeOffsetShape());
|
|
500
|
+
const progress = scope.register(new oc.Message_ProgressRange_1());
|
|
501
|
+
offsetMaker.PerformByJoin(
|
|
502
|
+
shape2.wrapped,
|
|
503
|
+
radius,
|
|
504
|
+
tolerance,
|
|
505
|
+
oc.BRepOffset_Mode.BRepOffset_Skin,
|
|
506
|
+
false,
|
|
507
|
+
false,
|
|
508
|
+
oc.GeomAbs_JoinType.GeomAbs_Arc,
|
|
509
|
+
false,
|
|
510
|
+
progress
|
|
511
|
+
);
|
|
512
|
+
const resultShape = offsetMaker.Shape();
|
|
513
|
+
const wrapped = shapeTypes.castShape(resultShape);
|
|
514
|
+
if (!shapeTypes.isShape3D(wrapped)) {
|
|
515
|
+
wrapped[Symbol.dispose]();
|
|
516
|
+
return errors.err(
|
|
517
|
+
errors.typeCastError(
|
|
518
|
+
errors.BrepErrorCode.MINKOWSKI_NOT_3D,
|
|
519
|
+
"Minkowski sphere offset did not produce a 3D shape"
|
|
520
|
+
)
|
|
521
|
+
);
|
|
522
|
+
}
|
|
523
|
+
return errors.ok(wrapped);
|
|
524
|
+
} catch (e) {
|
|
525
|
+
const raw = e instanceof Error ? e.message : String(e);
|
|
451
526
|
return errors.err(
|
|
452
|
-
errors.
|
|
453
|
-
|
|
454
|
-
"
|
|
455
|
-
)
|
|
527
|
+
errors.occtError(errors.BrepErrorCode.MINKOWSKI_FAILED, `Minkowski sphere offset failed: ${raw}`, e, {
|
|
528
|
+
operation: "minkowski",
|
|
529
|
+
fastPath: "sphere"
|
|
530
|
+
})
|
|
456
531
|
);
|
|
457
532
|
}
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
errors.occtError(errors.BrepErrorCode.MINKOWSKI_FAILED, `Minkowski sphere offset failed: ${raw}`, e, {
|
|
463
|
-
operation: "minkowski",
|
|
464
|
-
fastPath: "sphere"
|
|
465
|
-
})
|
|
466
|
-
);
|
|
533
|
+
} catch (_) {
|
|
534
|
+
var _error = _, _hasError = true;
|
|
535
|
+
} finally {
|
|
536
|
+
__callDispose(_stack, _error, _hasError);
|
|
467
537
|
}
|
|
468
538
|
}
|
|
469
539
|
function minkowskiGeneral(shape2, tool, tolerance) {
|
|
@@ -485,14 +555,28 @@ function minkowskiGeneral(shape2, tool, tolerance) {
|
|
|
485
555
|
}
|
|
486
556
|
const sumPoints = [];
|
|
487
557
|
for (const sv of shapeVerts) {
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
const
|
|
493
|
-
const
|
|
494
|
-
|
|
495
|
-
|
|
558
|
+
var _stack2 = [];
|
|
559
|
+
try {
|
|
560
|
+
const scope1 = __using(_stack2, new shapeTypes.DisposalScope());
|
|
561
|
+
const pa = scope1.register(oc.BRep_Tool.Pnt(sv.wrapped));
|
|
562
|
+
const ax = pa.X(), ay = pa.Y(), az = pa.Z();
|
|
563
|
+
for (const tv of toolVerts) {
|
|
564
|
+
var _stack = [];
|
|
565
|
+
try {
|
|
566
|
+
const scope2 = __using(_stack, new shapeTypes.DisposalScope());
|
|
567
|
+
const pb = scope2.register(oc.BRep_Tool.Pnt(tv.wrapped));
|
|
568
|
+
const bx = pb.X(), by = pb.Y(), bz = pb.Z();
|
|
569
|
+
sumPoints.push({ x: ax + bx, y: ay + by, z: az + bz });
|
|
570
|
+
} catch (_) {
|
|
571
|
+
var _error = _, _hasError = true;
|
|
572
|
+
} finally {
|
|
573
|
+
__callDispose(_stack, _error, _hasError);
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
} catch (_2) {
|
|
577
|
+
var _error2 = _2, _hasError2 = true;
|
|
578
|
+
} finally {
|
|
579
|
+
__callDispose(_stack2, _error2, _hasError2);
|
|
496
580
|
}
|
|
497
581
|
}
|
|
498
582
|
const kernel = occtBoundary.getKernel();
|
|
@@ -597,48 +681,57 @@ function multiSectionSweep(sections, spine, options) {
|
|
|
597
681
|
}
|
|
598
682
|
const { solid: solid2 = true, ruled = false, tolerance = 1e-6 } = options ?? {};
|
|
599
683
|
try {
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
684
|
+
var _stack = [];
|
|
685
|
+
try {
|
|
686
|
+
const oc = occtBoundary.getKernel().oc;
|
|
687
|
+
const scope = __using(_stack, new shapeTypes.DisposalScope());
|
|
688
|
+
const adaptor = scope.register(new oc.BRepAdaptor_CompCurve_2(spine.wrapped, false));
|
|
689
|
+
const uFirst = Number(adaptor.FirstParameter());
|
|
690
|
+
const uLast = Number(adaptor.LastParameter());
|
|
691
|
+
const uRange = uLast - uFirst;
|
|
692
|
+
const params = sections.map((s, i) => {
|
|
693
|
+
if (s.location !== void 0) {
|
|
694
|
+
return uFirst + s.location * uRange;
|
|
695
|
+
}
|
|
696
|
+
return uFirst + i / (sections.length - 1) * uRange;
|
|
697
|
+
});
|
|
698
|
+
const builder = scope.register(new oc.BRepOffsetAPI_ThruSections(solid2, ruled, tolerance));
|
|
699
|
+
for (let i = 0; i < sections.length; i++) {
|
|
700
|
+
const param = params[i];
|
|
701
|
+
const section2 = sections[i];
|
|
702
|
+
if (param === void 0 || section2 === void 0) continue;
|
|
703
|
+
const pnt = scope.register(new oc.gp_Pnt_1());
|
|
704
|
+
const tangent = scope.register(new oc.gp_Vec_1());
|
|
705
|
+
adaptor.D1(param, pnt, tangent);
|
|
706
|
+
const tangentDir = scope.register(new oc.gp_Dir_2(tangent));
|
|
707
|
+
const toAx3 = scope.register(new oc.gp_Ax3_4(pnt, tangentDir));
|
|
708
|
+
const trsf = scope.register(new oc.gp_Trsf_1());
|
|
709
|
+
trsf.SetTransformation_2(toAx3);
|
|
710
|
+
trsf.Invert();
|
|
711
|
+
const transformer = scope.register(
|
|
712
|
+
new oc.BRepBuilderAPI_Transform_2(section2.wire.wrapped, trsf, true)
|
|
713
|
+
);
|
|
714
|
+
const transformedShape = transformer.Shape();
|
|
715
|
+
const transformedWire = oc.TopoDS.Wire_1(transformedShape);
|
|
716
|
+
builder.AddWire(transformedWire);
|
|
609
717
|
}
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
const
|
|
616
|
-
if (
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
const transformedShape = transformer.Shape();
|
|
627
|
-
const transformedWire = oc.TopoDS.Wire_1(transformedShape);
|
|
628
|
-
builder.AddWire(transformedWire);
|
|
629
|
-
}
|
|
630
|
-
const progress = r(new oc.Message_ProgressRange_1());
|
|
631
|
-
builder.Build(progress);
|
|
632
|
-
if (!builder.IsDone()) {
|
|
633
|
-
return errors.err(errors.occtError(errors.BrepErrorCode.MULTI_SWEEP_FAILED, "Multi-section sweep build failed"));
|
|
634
|
-
}
|
|
635
|
-
const result2 = shapeTypes.castShape(builder.Shape());
|
|
636
|
-
if (!shapeTypes.isShape3D(result2)) {
|
|
637
|
-
return errors.err(
|
|
638
|
-
errors.typeCastError("MULTI_SWEEP_NOT_3D", "Multi-section sweep did not produce a 3D shape")
|
|
639
|
-
);
|
|
718
|
+
const progress = scope.register(new oc.Message_ProgressRange_1());
|
|
719
|
+
builder.Build(progress);
|
|
720
|
+
if (!builder.IsDone()) {
|
|
721
|
+
return errors.err(errors.occtError(errors.BrepErrorCode.MULTI_SWEEP_FAILED, "Multi-section sweep build failed"));
|
|
722
|
+
}
|
|
723
|
+
const result2 = shapeTypes.castShape(builder.Shape());
|
|
724
|
+
if (!shapeTypes.isShape3D(result2)) {
|
|
725
|
+
return errors.err(
|
|
726
|
+
errors.typeCastError("MULTI_SWEEP_NOT_3D", "Multi-section sweep did not produce a 3D shape")
|
|
727
|
+
);
|
|
728
|
+
}
|
|
729
|
+
return errors.ok(result2);
|
|
730
|
+
} catch (_) {
|
|
731
|
+
var _error = _, _hasError = true;
|
|
732
|
+
} finally {
|
|
733
|
+
__callDispose(_stack, _error, _hasError);
|
|
640
734
|
}
|
|
641
|
-
return errors.ok(result2);
|
|
642
735
|
} catch (e) {
|
|
643
736
|
const raw = e instanceof Error ? e.message : String(e);
|
|
644
737
|
return errors.err(
|
|
@@ -649,36 +742,43 @@ function multiSectionSweep(sections, spine, options) {
|
|
|
649
742
|
function guidedSweep(profile, spine, guides, options = {}) {
|
|
650
743
|
const { transition = "transformed", solid: solid2 = true, tolerance } = options;
|
|
651
744
|
try {
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
builder.
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
745
|
+
var _stack = [];
|
|
746
|
+
try {
|
|
747
|
+
const oc = occtBoundary.getKernel().oc;
|
|
748
|
+
const scope = __using(_stack, new shapeTypes.DisposalScope());
|
|
749
|
+
const builder = scope.register(new oc.BRepOffsetAPI_MakePipeShell(spine.wrapped));
|
|
750
|
+
const modeMap = {
|
|
751
|
+
transformed: oc.BRepBuilderAPI_TransitionMode.BRepBuilderAPI_Transformed,
|
|
752
|
+
round: oc.BRepBuilderAPI_TransitionMode.BRepBuilderAPI_RoundCorner,
|
|
753
|
+
right: oc.BRepBuilderAPI_TransitionMode.BRepBuilderAPI_RightCorner
|
|
754
|
+
};
|
|
755
|
+
builder.SetTransitionMode(modeMap[transition]);
|
|
756
|
+
if (tolerance !== void 0) {
|
|
757
|
+
builder.SetTolerance(tolerance, tolerance, 1e-7);
|
|
758
|
+
}
|
|
759
|
+
if (guides.length > 0) {
|
|
760
|
+
const firstGuide = guides[0];
|
|
761
|
+
builder.SetMode_5(firstGuide.wrapped, false, oc.BRepFill_TypeOfContact.BRepFill_NoContact);
|
|
762
|
+
}
|
|
763
|
+
builder.Add_1(profile.wrapped, false, false);
|
|
764
|
+
const progress = scope.register(new oc.Message_ProgressRange_1());
|
|
765
|
+
builder.Build(progress);
|
|
766
|
+
if (!builder.IsDone()) {
|
|
767
|
+
return errors.err(errors.occtError(errors.BrepErrorCode.GUIDED_SWEEP_FAILED, "Guided sweep build failed"));
|
|
768
|
+
}
|
|
769
|
+
if (solid2) {
|
|
770
|
+
builder.MakeSolid();
|
|
771
|
+
}
|
|
772
|
+
const result2 = shapeTypes.castShape(builder.Shape());
|
|
773
|
+
if (!shapeTypes.isShape3D(result2)) {
|
|
774
|
+
return errors.err(errors.typeCastError("GUIDED_SWEEP_NOT_3D", "Guided sweep did not produce a 3D shape"));
|
|
775
|
+
}
|
|
776
|
+
return errors.ok(result2);
|
|
777
|
+
} catch (_) {
|
|
778
|
+
var _error = _, _hasError = true;
|
|
779
|
+
} finally {
|
|
780
|
+
__callDispose(_stack, _error, _hasError);
|
|
680
781
|
}
|
|
681
|
-
return errors.ok(result2);
|
|
682
782
|
} catch (e) {
|
|
683
783
|
const raw = e instanceof Error ? e.message : String(e);
|
|
684
784
|
return errors.err(errors.occtError(errors.BrepErrorCode.GUIDED_SWEEP_FAILED, `Guided sweep failed: ${raw}`, e));
|
|
@@ -1753,15 +1853,22 @@ function resolve3D(s) {
|
|
|
1753
1853
|
return resolve(s);
|
|
1754
1854
|
}
|
|
1755
1855
|
function box(width, depth, height, options) {
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1856
|
+
var _stack = [];
|
|
1857
|
+
try {
|
|
1858
|
+
const oc = occtBoundary.getKernel().oc;
|
|
1859
|
+
const scope = __using(_stack, new shapeTypes.DisposalScope());
|
|
1860
|
+
const maker = scope.register(new oc.BRepPrimAPI_MakeBox_2(width, depth, height));
|
|
1861
|
+
const solid2 = shapeTypes.createSolid(maker.Solid());
|
|
1862
|
+
const center = options?.at ?? (options?.centered ? [0, 0, 0] : void 0);
|
|
1863
|
+
if (center) {
|
|
1864
|
+
return shapeFns.translate(solid2, [center[0] - width / 2, center[1] - depth / 2, center[2] - height / 2]);
|
|
1865
|
+
}
|
|
1866
|
+
return solid2;
|
|
1867
|
+
} catch (_) {
|
|
1868
|
+
var _error = _, _hasError = true;
|
|
1869
|
+
} finally {
|
|
1870
|
+
__callDispose(_stack, _error, _hasError);
|
|
1763
1871
|
}
|
|
1764
|
-
return solid2;
|
|
1765
1872
|
}
|
|
1766
1873
|
function cylinder(radius, height, options) {
|
|
1767
1874
|
const at = options?.at ?? [0, 0, 0];
|
|
@@ -1896,18 +2003,25 @@ function thicken$1(shape2, thickness) {
|
|
|
1896
2003
|
const check = validateNotNull(shape2, "thicken: shape");
|
|
1897
2004
|
if (errors.isErr(check)) return check;
|
|
1898
2005
|
try {
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
2006
|
+
var _stack = [];
|
|
2007
|
+
try {
|
|
2008
|
+
const oc = occtBoundary.getKernel().oc;
|
|
2009
|
+
const scope = __using(_stack, new shapeTypes.DisposalScope());
|
|
2010
|
+
const builder = scope.register(new oc.BRepOffsetAPI_MakeThickSolid());
|
|
2011
|
+
builder.MakeThickSolidBySimple(shape2.wrapped, thickness);
|
|
2012
|
+
const progress = scope.register(new oc.Message_ProgressRange_1());
|
|
2013
|
+
builder.Build(progress);
|
|
2014
|
+
const resultOc = builder.Shape();
|
|
2015
|
+
const cast = shapeTypes.castShape(resultOc);
|
|
2016
|
+
shapeFns.propagateOrigins(builder, [shape2], cast);
|
|
2017
|
+
booleanFns.propagateFaceTags(builder, [shape2], cast);
|
|
2018
|
+
booleanFns.propagateColors(builder, [shape2], cast);
|
|
2019
|
+
return errors.ok(cast);
|
|
2020
|
+
} catch (_) {
|
|
2021
|
+
var _error = _, _hasError = true;
|
|
2022
|
+
} finally {
|
|
2023
|
+
__callDispose(_stack, _error, _hasError);
|
|
2024
|
+
}
|
|
1911
2025
|
} catch (e) {
|
|
1912
2026
|
const raw = e instanceof Error ? e.message : String(e);
|
|
1913
2027
|
return errors.err(errors.occtError("THICKEN_FAILED", `Thicken operation failed: ${raw}`, e));
|
|
@@ -1951,29 +2065,36 @@ function fillet$1(shape2, edges, radius) {
|
|
|
1951
2065
|
);
|
|
1952
2066
|
}
|
|
1953
2067
|
try {
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
2068
|
+
var _stack = [];
|
|
2069
|
+
try {
|
|
2070
|
+
const oc = occtBoundary.getKernel().oc;
|
|
2071
|
+
const scope = __using(_stack, new shapeTypes.DisposalScope());
|
|
2072
|
+
const builder = scope.register(
|
|
2073
|
+
new oc.BRepFilletAPI_MakeFillet(shape2.wrapped, oc.ChFi3d_FilletShape.ChFi3d_Rational)
|
|
2074
|
+
);
|
|
2075
|
+
for (const edge of selectedEdges) {
|
|
2076
|
+
const rad = typeof radius === "function" ? radius(edge) ?? 0 : radius;
|
|
2077
|
+
if (typeof rad === "number") {
|
|
2078
|
+
if (rad > 0) builder.Add_2(rad, edge.wrapped);
|
|
2079
|
+
} else {
|
|
2080
|
+
const [r1, r2] = rad;
|
|
2081
|
+
if (r1 > 0 && r2 > 0) builder.Add_3(r1, r2, edge.wrapped);
|
|
2082
|
+
}
|
|
1966
2083
|
}
|
|
2084
|
+
const resultOc = builder.Shape();
|
|
2085
|
+
const cast = shapeTypes.castShape(resultOc);
|
|
2086
|
+
if (!shapeTypes.isShape3D(cast)) {
|
|
2087
|
+
return errors.err(errors.occtError(errors.BrepErrorCode.FILLET_NOT_3D, "Fillet result is not a 3D shape"));
|
|
2088
|
+
}
|
|
2089
|
+
shapeFns.propagateOrigins(builder, [shape2], cast);
|
|
2090
|
+
booleanFns.propagateFaceTags(builder, [shape2], cast);
|
|
2091
|
+
booleanFns.propagateColors(builder, [shape2], cast);
|
|
2092
|
+
return errors.ok(cast);
|
|
2093
|
+
} catch (_) {
|
|
2094
|
+
var _error = _, _hasError = true;
|
|
2095
|
+
} finally {
|
|
2096
|
+
__callDispose(_stack, _error, _hasError);
|
|
1967
2097
|
}
|
|
1968
|
-
const resultOc = builder.Shape();
|
|
1969
|
-
const cast = shapeTypes.castShape(resultOc);
|
|
1970
|
-
if (!shapeTypes.isShape3D(cast)) {
|
|
1971
|
-
return errors.err(errors.occtError(errors.BrepErrorCode.FILLET_NOT_3D, "Fillet result is not a 3D shape"));
|
|
1972
|
-
}
|
|
1973
|
-
shapeFns.propagateOrigins(builder, [shape2], cast);
|
|
1974
|
-
booleanFns.propagateFaceTags(builder, [shape2], cast);
|
|
1975
|
-
booleanFns.propagateColors(builder, [shape2], cast);
|
|
1976
|
-
return errors.ok(cast);
|
|
1977
2098
|
} catch (e) {
|
|
1978
2099
|
const raw = e instanceof Error ? e.message : String(e);
|
|
1979
2100
|
return errors.err(
|
|
@@ -2015,61 +2136,68 @@ function chamfer$1(shape2, edges, distance) {
|
|
|
2015
2136
|
return errors.err(errors.validationError(errors.BrepErrorCode.CHAMFER_NO_EDGES, "No edges found for chamfer"));
|
|
2016
2137
|
}
|
|
2017
2138
|
try {
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
oc.
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
while (faceExp.More()) {
|
|
2027
|
-
const face2 = oc.TopoDS.Face_1(faceExp.Current());
|
|
2028
|
-
const edgeExp = new oc.TopExp_Explorer_2(
|
|
2029
|
-
face2,
|
|
2030
|
-
oc.TopAbs_ShapeEnum.TopAbs_EDGE,
|
|
2139
|
+
var _stack = [];
|
|
2140
|
+
try {
|
|
2141
|
+
let getEdgeFaceMap = function() {
|
|
2142
|
+
if (edgeFaceMap) return edgeFaceMap;
|
|
2143
|
+
edgeFaceMap = /* @__PURE__ */ new Map();
|
|
2144
|
+
const faceExp = new oc.TopExp_Explorer_2(
|
|
2145
|
+
shape2.wrapped,
|
|
2146
|
+
oc.TopAbs_ShapeEnum.TopAbs_FACE,
|
|
2031
2147
|
oc.TopAbs_ShapeEnum.TopAbs_SHAPE
|
|
2032
2148
|
);
|
|
2033
|
-
while (
|
|
2034
|
-
const
|
|
2035
|
-
|
|
2036
|
-
|
|
2149
|
+
while (faceExp.More()) {
|
|
2150
|
+
const face2 = oc.TopoDS.Face_1(faceExp.Current());
|
|
2151
|
+
const edgeExp = new oc.TopExp_Explorer_2(
|
|
2152
|
+
face2,
|
|
2153
|
+
oc.TopAbs_ShapeEnum.TopAbs_EDGE,
|
|
2154
|
+
oc.TopAbs_ShapeEnum.TopAbs_SHAPE
|
|
2155
|
+
);
|
|
2156
|
+
while (edgeExp.More()) {
|
|
2157
|
+
const hash = edgeExp.Current().HashCode(2147483647);
|
|
2158
|
+
if (!edgeFaceMap.has(hash)) {
|
|
2159
|
+
edgeFaceMap.set(hash, face2);
|
|
2160
|
+
}
|
|
2161
|
+
edgeExp.Next();
|
|
2037
2162
|
}
|
|
2038
|
-
edgeExp.
|
|
2163
|
+
edgeExp.delete();
|
|
2164
|
+
faceExp.Next();
|
|
2039
2165
|
}
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
}
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
if (face2) {
|
|
2059
|
-
builder.Add_3(d1, d2, oc.TopoDS.Edge_1(edge.wrapped), face2);
|
|
2166
|
+
faceExp.delete();
|
|
2167
|
+
return edgeFaceMap;
|
|
2168
|
+
};
|
|
2169
|
+
const oc = occtBoundary.getKernel().oc;
|
|
2170
|
+
const scope = __using(_stack, new shapeTypes.DisposalScope());
|
|
2171
|
+
const builder = scope.register(new oc.BRepFilletAPI_MakeChamfer(shape2.wrapped));
|
|
2172
|
+
let edgeFaceMap = null;
|
|
2173
|
+
for (const edge of selectedEdges) {
|
|
2174
|
+
const d = typeof distance === "function" ? distance(edge) ?? 0 : distance;
|
|
2175
|
+
if (typeof d === "number") {
|
|
2176
|
+
if (d > 0) builder.Add_2(d, edge.wrapped);
|
|
2177
|
+
} else {
|
|
2178
|
+
const [d1, d2] = d;
|
|
2179
|
+
if (d1 > 0 && d2 > 0) {
|
|
2180
|
+
const face2 = getEdgeFaceMap().get(edge.wrapped.HashCode(2147483647));
|
|
2181
|
+
if (face2) {
|
|
2182
|
+
builder.Add_3(d1, d2, oc.TopoDS.Edge_1(edge.wrapped), face2);
|
|
2183
|
+
}
|
|
2060
2184
|
}
|
|
2061
2185
|
}
|
|
2062
2186
|
}
|
|
2187
|
+
const resultOc = builder.Shape();
|
|
2188
|
+
const cast = shapeTypes.castShape(resultOc);
|
|
2189
|
+
if (!shapeTypes.isShape3D(cast)) {
|
|
2190
|
+
return errors.err(errors.occtError(errors.BrepErrorCode.CHAMFER_NOT_3D, "Chamfer result is not a 3D shape"));
|
|
2191
|
+
}
|
|
2192
|
+
shapeFns.propagateOrigins(builder, [shape2], cast);
|
|
2193
|
+
booleanFns.propagateFaceTags(builder, [shape2], cast);
|
|
2194
|
+
booleanFns.propagateColors(builder, [shape2], cast);
|
|
2195
|
+
return errors.ok(cast);
|
|
2196
|
+
} catch (_) {
|
|
2197
|
+
var _error = _, _hasError = true;
|
|
2198
|
+
} finally {
|
|
2199
|
+
__callDispose(_stack, _error, _hasError);
|
|
2063
2200
|
}
|
|
2064
|
-
const resultOc = builder.Shape();
|
|
2065
|
-
const cast = shapeTypes.castShape(resultOc);
|
|
2066
|
-
if (!shapeTypes.isShape3D(cast)) {
|
|
2067
|
-
return errors.err(errors.occtError(errors.BrepErrorCode.CHAMFER_NOT_3D, "Chamfer result is not a 3D shape"));
|
|
2068
|
-
}
|
|
2069
|
-
shapeFns.propagateOrigins(builder, [shape2], cast);
|
|
2070
|
-
booleanFns.propagateFaceTags(builder, [shape2], cast);
|
|
2071
|
-
booleanFns.propagateColors(builder, [shape2], cast);
|
|
2072
|
-
return errors.ok(cast);
|
|
2073
2201
|
} catch (e) {
|
|
2074
2202
|
const raw = e instanceof Error ? e.message : String(e);
|
|
2075
2203
|
return errors.err(
|
|
@@ -2091,35 +2219,42 @@ function shell$1(shape2, faces, thickness, tolerance = 1e-3) {
|
|
|
2091
2219
|
return errors.err(errors.validationError("NO_FACES", "At least one face must be specified for shell"));
|
|
2092
2220
|
}
|
|
2093
2221
|
try {
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
facesToRemove.
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2222
|
+
var _stack = [];
|
|
2223
|
+
try {
|
|
2224
|
+
const oc = occtBoundary.getKernel().oc;
|
|
2225
|
+
const scope = __using(_stack, new shapeTypes.DisposalScope());
|
|
2226
|
+
const facesToRemove = scope.register(new oc.TopTools_ListOfShape_1());
|
|
2227
|
+
for (const face2 of faces) {
|
|
2228
|
+
facesToRemove.Append_1(face2.wrapped);
|
|
2229
|
+
}
|
|
2230
|
+
const progress = scope.register(new oc.Message_ProgressRange_1());
|
|
2231
|
+
const builder = scope.register(new oc.BRepOffsetAPI_MakeThickSolid());
|
|
2232
|
+
builder.MakeThickSolidByJoin(
|
|
2233
|
+
shape2.wrapped,
|
|
2234
|
+
facesToRemove,
|
|
2235
|
+
-thickness,
|
|
2236
|
+
tolerance,
|
|
2237
|
+
oc.BRepOffset_Mode.BRepOffset_Skin,
|
|
2238
|
+
false,
|
|
2239
|
+
false,
|
|
2240
|
+
oc.GeomAbs_JoinType.GeomAbs_Arc,
|
|
2241
|
+
false,
|
|
2242
|
+
progress
|
|
2243
|
+
);
|
|
2244
|
+
const resultOc = builder.Shape();
|
|
2245
|
+
const cast = shapeTypes.castShape(resultOc);
|
|
2246
|
+
if (!shapeTypes.isShape3D(cast)) {
|
|
2247
|
+
return errors.err(errors.occtError("SHELL_RESULT_NOT_3D", "Shell result is not a 3D shape"));
|
|
2248
|
+
}
|
|
2249
|
+
shapeFns.propagateOrigins(builder, [shape2], cast);
|
|
2250
|
+
booleanFns.propagateFaceTags(builder, [shape2], cast);
|
|
2251
|
+
booleanFns.propagateColors(builder, [shape2], cast);
|
|
2252
|
+
return errors.ok(cast);
|
|
2253
|
+
} catch (_) {
|
|
2254
|
+
var _error = _, _hasError = true;
|
|
2255
|
+
} finally {
|
|
2256
|
+
__callDispose(_stack, _error, _hasError);
|
|
2118
2257
|
}
|
|
2119
|
-
shapeFns.propagateOrigins(builder, [shape2], cast);
|
|
2120
|
-
booleanFns.propagateFaceTags(builder, [shape2], cast);
|
|
2121
|
-
booleanFns.propagateColors(builder, [shape2], cast);
|
|
2122
|
-
return errors.ok(cast);
|
|
2123
2258
|
} catch (e) {
|
|
2124
2259
|
const raw = e instanceof Error ? e.message : String(e);
|
|
2125
2260
|
return errors.err(
|
|
@@ -2138,30 +2273,37 @@ function offset$1(shape2, distance, tolerance = 1e-6) {
|
|
|
2138
2273
|
return errors.err(errors.validationError("ZERO_OFFSET", "Offset distance cannot be zero"));
|
|
2139
2274
|
}
|
|
2140
2275
|
try {
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
|
|
2276
|
+
var _stack = [];
|
|
2277
|
+
try {
|
|
2278
|
+
const oc = occtBoundary.getKernel().oc;
|
|
2279
|
+
const scope = __using(_stack, new shapeTypes.DisposalScope());
|
|
2280
|
+
const progress = scope.register(new oc.Message_ProgressRange_1());
|
|
2281
|
+
const builder = scope.register(new oc.BRepOffsetAPI_MakeOffsetShape());
|
|
2282
|
+
builder.PerformByJoin(
|
|
2283
|
+
shape2.wrapped,
|
|
2284
|
+
distance,
|
|
2285
|
+
tolerance,
|
|
2286
|
+
oc.BRepOffset_Mode.BRepOffset_Skin,
|
|
2287
|
+
false,
|
|
2288
|
+
false,
|
|
2289
|
+
oc.GeomAbs_JoinType.GeomAbs_Arc,
|
|
2290
|
+
false,
|
|
2291
|
+
progress
|
|
2292
|
+
);
|
|
2293
|
+
const resultOc = builder.Shape();
|
|
2294
|
+
const cast = shapeTypes.castShape(resultOc);
|
|
2295
|
+
if (!shapeTypes.isShape3D(cast)) {
|
|
2296
|
+
return errors.err(errors.occtError("OFFSET_RESULT_NOT_3D", "Offset result is not a 3D shape"));
|
|
2297
|
+
}
|
|
2298
|
+
shapeFns.propagateOrigins(builder, [shape2], cast);
|
|
2299
|
+
booleanFns.propagateFaceTags(builder, [shape2], cast);
|
|
2300
|
+
booleanFns.propagateColors(builder, [shape2], cast);
|
|
2301
|
+
return errors.ok(cast);
|
|
2302
|
+
} catch (_) {
|
|
2303
|
+
var _error = _, _hasError = true;
|
|
2304
|
+
} finally {
|
|
2305
|
+
__callDispose(_stack, _error, _hasError);
|
|
2160
2306
|
}
|
|
2161
|
-
shapeFns.propagateOrigins(builder, [shape2], cast);
|
|
2162
|
-
booleanFns.propagateFaceTags(builder, [shape2], cast);
|
|
2163
|
-
booleanFns.propagateColors(builder, [shape2], cast);
|
|
2164
|
-
return errors.ok(cast);
|
|
2165
2307
|
} catch (e) {
|
|
2166
2308
|
const raw = e instanceof Error ? e.message : String(e);
|
|
2167
2309
|
return errors.err(errors.occtError("OFFSET_FAILED", `Offset operation failed: ${raw}`, e));
|
|
@@ -2320,35 +2462,42 @@ function isEmpty(shape2) {
|
|
|
2320
2462
|
return shapeFns.isEmpty(resolve(shape2));
|
|
2321
2463
|
}
|
|
2322
2464
|
function loft$1(wires, { ruled = true, startPoint, endPoint } = {}, returnShell = false) {
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
|
|
2326
|
-
|
|
2327
|
-
|
|
2328
|
-
|
|
2329
|
-
|
|
2330
|
-
const
|
|
2331
|
-
|
|
2332
|
-
|
|
2333
|
-
|
|
2334
|
-
|
|
2335
|
-
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
|
|
2348
|
-
|
|
2349
|
-
|
|
2465
|
+
var _stack = [];
|
|
2466
|
+
try {
|
|
2467
|
+
if (wires.length === 0 && !startPoint && !endPoint) {
|
|
2468
|
+
return errors.err(errors.validationError("LOFT_EMPTY", "Loft requires at least one wire or start/end point"));
|
|
2469
|
+
}
|
|
2470
|
+
const oc = occtBoundary.getKernel().oc;
|
|
2471
|
+
const scope = __using(_stack, new shapeTypes.DisposalScope());
|
|
2472
|
+
const builder = scope.register(new oc.BRepOffsetAPI_ThruSections(!returnShell, ruled, 1e-6));
|
|
2473
|
+
if (startPoint) {
|
|
2474
|
+
const pnt = scope.register(occtBoundary.toOcPnt(occtBoundary.toVec3(startPoint)));
|
|
2475
|
+
const vMaker = scope.register(new oc.BRepBuilderAPI_MakeVertex(pnt));
|
|
2476
|
+
builder.AddVertex(vMaker.Vertex());
|
|
2477
|
+
}
|
|
2478
|
+
for (const w of wires) {
|
|
2479
|
+
builder.AddWire(w.wrapped);
|
|
2480
|
+
}
|
|
2481
|
+
if (endPoint) {
|
|
2482
|
+
const pnt = scope.register(occtBoundary.toOcPnt(occtBoundary.toVec3(endPoint)));
|
|
2483
|
+
const vMaker = scope.register(new oc.BRepBuilderAPI_MakeVertex(pnt));
|
|
2484
|
+
builder.AddVertex(vMaker.Vertex());
|
|
2485
|
+
}
|
|
2486
|
+
const progress = scope.register(new oc.Message_ProgressRange_1());
|
|
2487
|
+
builder.Build(progress);
|
|
2488
|
+
if (!builder.IsDone()) {
|
|
2489
|
+
return errors.err(errors.occtError("LOFT_FAILED", "Loft operation failed"));
|
|
2490
|
+
}
|
|
2491
|
+
const result2 = shapeTypes.castShape(builder.Shape());
|
|
2492
|
+
if (!shapeTypes.isShape3D(result2)) {
|
|
2493
|
+
return errors.err(errors.typeCastError("LOFT_NOT_3D", "Loft did not produce a 3D shape"));
|
|
2494
|
+
}
|
|
2495
|
+
return errors.ok(result2);
|
|
2496
|
+
} catch (_) {
|
|
2497
|
+
var _error = _, _hasError = true;
|
|
2498
|
+
} finally {
|
|
2499
|
+
__callDispose(_stack, _error, _hasError);
|
|
2350
2500
|
}
|
|
2351
|
-
return errors.ok(result2);
|
|
2352
2501
|
}
|
|
2353
2502
|
function extrude(face2, height) {
|
|
2354
2503
|
const f = resolve(face2);
|
|
@@ -2372,7 +2521,9 @@ function resolveTargetFace(shape2, faceSpec) {
|
|
|
2372
2521
|
if (faceSpec === void 0) {
|
|
2373
2522
|
const faces = shapeFns.getFaces(shape2);
|
|
2374
2523
|
if (faces.length === 0) {
|
|
2375
|
-
|
|
2524
|
+
return errors.err(
|
|
2525
|
+
errors.validationError(errors.BrepErrorCode.COMPOUND_NO_FACES, "compoundOps: shape has no faces")
|
|
2526
|
+
);
|
|
2376
2527
|
}
|
|
2377
2528
|
let best = faces[0];
|
|
2378
2529
|
let bestZ = faceFns.faceCenter(best)[2];
|
|
@@ -2384,17 +2535,22 @@ function resolveTargetFace(shape2, faceSpec) {
|
|
|
2384
2535
|
bestZ = z;
|
|
2385
2536
|
}
|
|
2386
2537
|
}
|
|
2387
|
-
return best;
|
|
2538
|
+
return errors.ok(best);
|
|
2388
2539
|
}
|
|
2389
2540
|
if (typeof faceSpec === "function") {
|
|
2390
2541
|
const finder = faceSpec(helpers.faceFinder());
|
|
2391
2542
|
const found = finder.findAll(shape2);
|
|
2392
2543
|
if (found.length === 0) {
|
|
2393
|
-
|
|
2544
|
+
return errors.err(
|
|
2545
|
+
errors.queryError(
|
|
2546
|
+
errors.BrepErrorCode.COMPOUND_FACE_NOT_FOUND,
|
|
2547
|
+
"compoundOps: face finder matched no faces"
|
|
2548
|
+
)
|
|
2549
|
+
);
|
|
2394
2550
|
}
|
|
2395
|
-
return found[0];
|
|
2551
|
+
return errors.ok(found[0]);
|
|
2396
2552
|
}
|
|
2397
|
-
return faceSpec;
|
|
2553
|
+
return errors.ok(faceSpec);
|
|
2398
2554
|
}
|
|
2399
2555
|
function toWire(profile) {
|
|
2400
2556
|
if ("sketchOnPlane" in profile && typeof profile.sketchOnPlane === "function") {
|
|
@@ -2433,7 +2589,9 @@ function pocket(shape2, options) {
|
|
|
2433
2589
|
if (depth <= 0) {
|
|
2434
2590
|
return errors.err(errors.validationError("POCKET_INVALID_DEPTH", "Pocket depth must be positive"));
|
|
2435
2591
|
}
|
|
2436
|
-
const
|
|
2592
|
+
const targetResult = resolveTargetFace(s, options.face);
|
|
2593
|
+
if (errors.isErr(targetResult)) return targetResult;
|
|
2594
|
+
const targetFace = targetResult.value;
|
|
2437
2595
|
const normal = faceFns.normalAt(targetFace);
|
|
2438
2596
|
const w = toWire(profile);
|
|
2439
2597
|
const faceResult = surfaceBuilders.makeFace(w);
|
|
@@ -2449,7 +2607,9 @@ function boss(shape2, options) {
|
|
|
2449
2607
|
if (height <= 0) {
|
|
2450
2608
|
return errors.err(errors.validationError("BOSS_INVALID_HEIGHT", "Boss height must be positive"));
|
|
2451
2609
|
}
|
|
2452
|
-
const
|
|
2610
|
+
const targetResult = resolveTargetFace(s, options.face);
|
|
2611
|
+
if (errors.isErr(targetResult)) return targetResult;
|
|
2612
|
+
const targetFace = targetResult.value;
|
|
2453
2613
|
const normal = faceFns.normalAt(targetFace);
|
|
2454
2614
|
const w = toWire(profile);
|
|
2455
2615
|
const faceResult = surfaceBuilders.makeFace(w);
|
|
@@ -2718,6 +2878,7 @@ exports.getShapeKind = shapeTypes.getShapeKind;
|
|
|
2718
2878
|
exports.isCompound = shapeTypes.isCompound;
|
|
2719
2879
|
exports.isEdge = shapeTypes.isEdge;
|
|
2720
2880
|
exports.isFace = shapeTypes.isFace;
|
|
2881
|
+
exports.isLive = shapeTypes.isLive;
|
|
2721
2882
|
exports.isShape1D = shapeTypes.isShape1D;
|
|
2722
2883
|
exports.isShape3D = shapeTypes.isShape3D;
|
|
2723
2884
|
exports.isShell = shapeTypes.isShell;
|
|
@@ -2726,6 +2887,8 @@ exports.isVertex = shapeTypes.isVertex;
|
|
|
2726
2887
|
exports.isWire = shapeTypes.isWire;
|
|
2727
2888
|
exports.localGC = shapeTypes.localGC;
|
|
2728
2889
|
exports.withScope = shapeTypes.withScope;
|
|
2890
|
+
exports.withScopeResult = shapeTypes.withScopeResult;
|
|
2891
|
+
exports.withScopeResultAsync = shapeTypes.withScopeResultAsync;
|
|
2729
2892
|
exports.DEG2RAD = vecOps.DEG2RAD;
|
|
2730
2893
|
exports.HASH_CODE_MAX = vecOps.HASH_CODE_MAX;
|
|
2731
2894
|
exports.RAD2DEG = vecOps.RAD2DEG;
|
|
@@ -3054,6 +3217,7 @@ exports.isNumber = isNumber;
|
|
|
3054
3217
|
exports.isValid = isValid;
|
|
3055
3218
|
exports.kernelCall = kernelCall;
|
|
3056
3219
|
exports.kernelCallRaw = kernelCallRaw;
|
|
3220
|
+
exports.kernelCallScoped = kernelCallScoped;
|
|
3057
3221
|
exports.line = line;
|
|
3058
3222
|
exports.loft = loft;
|
|
3059
3223
|
exports.mesh = mesh;
|