brepjs 8.0.0 → 8.0.2
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/blueprints/booleanHelpers.d.ts +32 -0
- package/dist/2d/blueprints/booleanHelpers.d.ts.map +1 -0
- package/dist/2d/blueprints/booleanOperations.d.ts +5 -3
- package/dist/2d/blueprints/booleanOperations.d.ts.map +1 -1
- package/dist/2d/blueprints/intersectionSegments.d.ts +12 -0
- package/dist/2d/blueprints/intersectionSegments.d.ts.map +1 -0
- package/dist/2d/blueprints/segmentAssembly.d.ts +31 -0
- package/dist/2d/blueprints/segmentAssembly.d.ts.map +1 -0
- package/dist/2d.cjs +2 -2
- package/dist/2d.js +8 -8
- package/dist/{Blueprint-D3JfGJTz.js → Blueprint-B9fhnpFp.js} +117 -30
- package/dist/{Blueprint-CVctc41Z.cjs → Blueprint-VGbo3izk.cjs} +111 -24
- package/dist/{boolean2D-BdZATaHs.cjs → boolean2D-B1XrGVgx.cjs} +426 -345
- package/dist/{boolean2D-hOw5Qay5.js → boolean2D-_WiqPxWZ.js} +391 -310
- package/dist/{booleanFns-BBSVKhL2.cjs → booleanFns-BxW-N3rP.cjs} +12 -16
- package/dist/{booleanFns-CqehfzcK.js → booleanFns-CkccZ7UL.js} +14 -18
- package/dist/brepjs.cjs +133 -62
- package/dist/brepjs.js +290 -217
- package/dist/{cast-DQaUibmm.js → cast-C4Ff_1Qe.js} +2 -2
- package/dist/{cast-DkB0GKmQ.cjs → cast-DIiyxDLo.cjs} +2 -2
- package/dist/core/disposal.d.ts +1 -1
- package/dist/core/disposal.d.ts.map +1 -1
- package/dist/core.cjs +3 -3
- package/dist/core.js +3 -3
- package/dist/cornerFinder-BndBNtJE.cjs +58 -0
- package/dist/cornerFinder-DzGzfiqb.js +59 -0
- package/dist/curveBuilders-BUoFO1UG.cjs +196 -0
- package/dist/curveBuilders-CBlIWlbU.js +197 -0
- package/dist/{curveFns-BilyYL_s.cjs → curveFns-BrJDkaWi.cjs} +31 -44
- package/dist/{curveFns-CdVE4da7.js → curveFns-BshHA9Ys.js} +31 -44
- package/dist/{drawFns-921SkhDL.js → drawFns-Btmlh_Oz.js} +13 -14
- package/dist/{drawFns-CUyx50gi.cjs → drawFns-D2eDcf4k.cjs} +58 -59
- package/dist/{faceFns-DHu-2JpA.js → faceFns-DDzCECn3.js} +3 -3
- package/dist/{faceFns-BwK7FP7N.cjs → faceFns-NDRFeekj.cjs} +3 -3
- package/dist/helpers-Ck8GJ58k.cjs +203 -0
- package/dist/helpers-jku2V1DY.js +204 -0
- package/dist/io.cjs +4 -4
- package/dist/io.js +4 -4
- package/dist/kernel/occtAdapter.d.ts +1 -0
- package/dist/kernel/occtAdapter.d.ts.map +1 -1
- package/dist/kernel/sweepOps.d.ts +8 -0
- package/dist/kernel/sweepOps.d.ts.map +1 -1
- package/dist/kernel/types.d.ts +1 -0
- package/dist/kernel/types.d.ts.map +1 -1
- package/dist/loft-Bk9EM0gZ.js +373 -0
- package/dist/loft-DJXwxV_L.cjs +372 -0
- package/dist/{measurement-C5JGCuUP.js → measurement-DlXaTzKc.js} +3 -3
- package/dist/{measurement-fxm_pW7x.cjs → measurement-LcGh4wV0.cjs} +3 -3
- package/dist/measurement.cjs +1 -1
- package/dist/measurement.js +1 -1
- package/dist/{meshFns-AqAjTTVl.js → meshFns-Djzdn-CS.js} +1 -1
- package/dist/{meshFns-BhrZGi6w.cjs → meshFns-c8lDKfYy.cjs} +1 -1
- package/dist/{occtBoundary-du8_ex-p.cjs → occtBoundary-6kQSl3cF.cjs} +21 -0
- package/dist/{occtBoundary-CwegMzqc.js → occtBoundary-CqXvDhZY.js} +26 -5
- package/dist/operations/extrude.d.ts.map +1 -1
- package/dist/operations/extrudeFns.d.ts.map +1 -1
- package/dist/operations/extrudeUtils.d.ts +17 -0
- package/dist/operations/extrudeUtils.d.ts.map +1 -1
- package/dist/{operations-C1rWoba2.js → operations-CrQlFDHc.js} +30 -7
- package/dist/{operations-BP1wVDw0.cjs → operations-Do-WZGXc.cjs} +30 -7
- package/dist/operations.cjs +2 -2
- package/dist/operations.js +4 -4
- package/dist/query/cornerFinder.d.ts +48 -0
- package/dist/query/cornerFinder.d.ts.map +1 -0
- package/dist/query/directionUtils.d.ts +6 -0
- package/dist/query/directionUtils.d.ts.map +1 -0
- package/dist/query/edgeFinder.d.ts +15 -0
- package/dist/query/edgeFinder.d.ts.map +1 -0
- package/dist/query/faceFinder.d.ts +15 -0
- package/dist/query/faceFinder.d.ts.map +1 -0
- package/dist/query/finderCore.d.ts +35 -0
- package/dist/query/finderCore.d.ts.map +1 -0
- package/dist/query/finderFns.d.ts +21 -106
- package/dist/query/finderFns.d.ts.map +1 -1
- package/dist/query/shapeDistanceFilter.d.ts +11 -0
- package/dist/query/shapeDistanceFilter.d.ts.map +1 -0
- package/dist/query/vertexFinder.d.ts +16 -0
- package/dist/query/vertexFinder.d.ts.map +1 -0
- package/dist/query/wireFinder.d.ts +10 -0
- package/dist/query/wireFinder.d.ts.map +1 -0
- package/dist/query.cjs +42 -5
- package/dist/query.js +40 -2
- package/dist/{shapeFns-BrF97sKt.js → shapeFns-DQtpzndX.js} +17 -18
- package/dist/{shapeFns-BvOndshS.cjs → shapeFns-cN4qGpbO.cjs} +6 -7
- package/dist/{shapeTypes-DKhwEnUM.cjs → shapeTypes-BJ3Hmskg.cjs} +24 -20
- package/dist/{shapeTypes-BlSElW8z.js → shapeTypes-C9sUsmEW.js} +32 -28
- package/dist/sketching/Sketcher.d.ts.map +1 -1
- package/dist/sketching/Sketcher2d.d.ts +12 -4
- package/dist/sketching/Sketcher2d.d.ts.map +1 -1
- package/dist/sketching/ellipseUtils.d.ts +29 -0
- package/dist/sketching/ellipseUtils.d.ts.map +1 -0
- package/dist/sketching.cjs +2 -2
- package/dist/sketching.js +2 -2
- package/dist/topology/booleanFns.d.ts.map +1 -1
- package/dist/topology/curveBuilders.d.ts +75 -0
- package/dist/topology/curveBuilders.d.ts.map +1 -0
- package/dist/topology/curveFns.d.ts.map +1 -1
- package/dist/topology/primitiveFns.d.ts.map +1 -1
- package/dist/topology/shapeFns.d.ts.map +1 -1
- package/dist/topology/shapeHelpers.d.ts +6 -173
- package/dist/topology/shapeHelpers.d.ts.map +1 -1
- package/dist/topology/shapeUtils.d.ts +13 -0
- package/dist/topology/shapeUtils.d.ts.map +1 -0
- package/dist/topology/solidBuilders.d.ts +70 -0
- package/dist/topology/solidBuilders.d.ts.map +1 -0
- package/dist/topology/surfaceBuilders.d.ts +35 -0
- package/dist/topology/surfaceBuilders.d.ts.map +1 -0
- package/dist/topology/wrapperFns.d.ts +1 -0
- package/dist/topology/wrapperFns.d.ts.map +1 -1
- package/dist/{topology-tFzqSrGH.js → topology-CtfUZwLR.js} +8 -8
- package/dist/{topology-CIooytHH.cjs → topology-DXq8dLsi.cjs} +8 -8
- package/dist/topology.cjs +7 -7
- package/dist/topology.js +31 -31
- package/dist/{vectors-CBuaMeZv.js → vectors-BVgXsYWl.js} +1 -1
- package/dist/{vectors-ChWEZPwy.cjs → vectors-DK2hEKcI.cjs} +1 -1
- package/dist/vectors.cjs +2 -2
- package/dist/vectors.js +2 -2
- package/package.json +1 -1
- package/dist/loft-BzWFokmC.cjs +0 -178
- package/dist/loft-CtG5nMq5.js +0 -179
- package/dist/query-V6nV-VfL.js +0 -396
- package/dist/query-hMSmOWJP.cjs +0 -395
- package/dist/shapeHelpers-B2SXz1p4.cjs +0 -488
- package/dist/shapeHelpers-BcoZf2N9.js +0 -489
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { c as castShape, h as isShape3D$1, m as isWire$1 } from "./shapeTypes-
|
|
2
|
-
import { g as getKernel } from "./occtBoundary-
|
|
1
|
+
import { c as castShape, h as isShape3D$1, m as isWire$1 } from "./shapeTypes-C9sUsmEW.js";
|
|
2
|
+
import { g as getKernel } from "./occtBoundary-CqXvDhZY.js";
|
|
3
3
|
import { e as err, p as typeCastError, l as ok, a as andThen } from "./errors-wGhcJMpB.js";
|
|
4
4
|
let _topoMap = null;
|
|
5
5
|
const asTopo = (entity) => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
const shapeTypes = require("./shapeTypes-
|
|
3
|
-
const occtBoundary = require("./occtBoundary-
|
|
2
|
+
const shapeTypes = require("./shapeTypes-BJ3Hmskg.cjs");
|
|
3
|
+
const occtBoundary = require("./occtBoundary-6kQSl3cF.cjs");
|
|
4
4
|
const errors = require("./errors-DK1VAdP4.cjs");
|
|
5
5
|
let _topoMap = null;
|
|
6
6
|
const asTopo = (entity) => {
|
package/dist/core/disposal.d.ts
CHANGED
|
@@ -43,7 +43,7 @@ export declare function unregisterFromCleanup(deletable: Deletable): void;
|
|
|
43
43
|
/** Register a deletable value for GC when the scope function is collected. */
|
|
44
44
|
export declare function gcWithScope(): <T extends Deletable>(value: T) => T;
|
|
45
45
|
/** Register a deletable value for GC when the given object is collected. */
|
|
46
|
-
export declare function gcWithObject(obj:
|
|
46
|
+
export declare function gcWithObject(obj: object): <T extends Deletable>(value: T) => T;
|
|
47
47
|
/** Create a local GC scope. Returns [register, cleanup, debugSet?]. */
|
|
48
48
|
export declare function localGC(debug?: boolean): [<T extends Deletable>(v: T) => T, () => void, Set<Deletable> | undefined];
|
|
49
49
|
//# sourceMappingURL=disposal.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"disposal.d.ts","sourceRoot":"","sources":["../../src/core/disposal.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAMlD,mFAAmF;AACnF,MAAM,WAAW,SAAS;IACxB,MAAM,EAAE,MAAM,IAAI,CAAC;CACpB;
|
|
1
|
+
{"version":3,"file":"disposal.d.ts","sourceRoot":"","sources":["../../src/core/disposal.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAMlD,mFAAmF;AACnF,MAAM,WAAW,SAAS;IACxB,MAAM,EAAE,MAAM,IAAI,CAAC;CACpB;AAqCD,4DAA4D;AAC5D,MAAM,WAAW,WAAW;IAC1B,gCAAgC;IAChC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAE1B,uCAAuC;IACvC,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,IAAI,CAAC;IAEzB,iFAAiF;IACjF,MAAM,IAAI,IAAI,CAAC;IAEf,6CAA6C;IAC7C,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;CAC5B;AAED,wCAAwC;AACxC,wBAAgB,YAAY,CAAC,OAAO,EAAE,OAAO,GAAG,WAAW,CAoC1D;AAMD,gDAAgD;AAChD,MAAM,WAAW,QAAQ,CAAC,CAAC,SAAS,SAAS;IAC3C,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAC;IAClB,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC3B,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,IAAI,CAAC;CAC1B;AAED,sDAAsD;AACtD,wBAAgB,cAAc,CAAC,CAAC,SAAS,SAAS,EAAE,KAAK,EAAE,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CA4BzE;AAMD,wDAAwD;AACxD,qBAAa,aAAc,YAAW,UAAU;IAC9C,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAsB;IAE9C,wDAAwD;IACxD,QAAQ,CAAC,CAAC,SAAS,SAAS,EAAE,QAAQ,EAAE,CAAC,GAAG,CAAC;IAW7C,0DAA0D;IAC1D,KAAK,CAAC,CAAC,SAAS,UAAU,EAAE,UAAU,EAAE,CAAC,GAAG,CAAC;IAO7C,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,IAAI;CAOzB;AAED;8DAC8D;AAC9D,wBAAgB,SAAS,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,CAAC,GAAG,CAAC,CAG/D;AAMD,qEAAqE;AACrE,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,GAAG,IAAI,CAE5E;AAED,gFAAgF;AAChF,wBAAgB,qBAAqB,CAAC,SAAS,EAAE,SAAS,GAAG,IAAI,CAEhE;AAMD,8EAA8E;AAC9E,wBAAgB,WAAW,IAAI,CAAC,CAAC,SAAS,SAAS,EAAE,KAAK,EAAE,CAAC,KAAK,CAAC,CAMlE;AAED,4EAA4E;AAC5E,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,CAAC,CAAC,SAAS,SAAS,EAAE,KAAK,EAAE,CAAC,KAAK,CAAC,CAM9E;AAED,uEAAuE;AACvE,wBAAgB,OAAO,CACrB,KAAK,CAAC,EAAE,OAAO,GACd,CAAC,CAAC,CAAC,SAAS,SAAS,EAAE,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE,MAAM,IAAI,EAAE,GAAG,CAAC,SAAS,CAAC,GAAG,SAAS,CAAC,CAoB5E"}
|
package/dist/core.cjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const occtBoundary = require("./occtBoundary-
|
|
3
|
+
const occtBoundary = require("./occtBoundary-6kQSl3cF.cjs");
|
|
4
4
|
const vecOps = require("./vecOps-CjRL1jau.cjs");
|
|
5
5
|
const errors = require("./errors-DK1VAdP4.cjs");
|
|
6
|
-
const vectors = require("./vectors-
|
|
7
|
-
const shapeTypes = require("./shapeTypes-
|
|
6
|
+
const vectors = require("./vectors-DK2hEKcI.cjs");
|
|
7
|
+
const shapeTypes = require("./shapeTypes-BJ3Hmskg.cjs");
|
|
8
8
|
const result = require("./result.cjs");
|
|
9
9
|
exports.resolveDirection = occtBoundary.resolveDirection;
|
|
10
10
|
exports.toVec2 = occtBoundary.toVec2;
|
package/dist/core.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { r, t, a } from "./occtBoundary-
|
|
1
|
+
import { r, t, a } from "./occtBoundary-CqXvDhZY.js";
|
|
2
2
|
import { D, H, R, v, a as a2, b, c, d, e, f, g, h, i, j, k, l, m, n, o } from "./vecOps-ZDdZWbwT.js";
|
|
3
3
|
import { O, a as a3, c as c2, b as b2, e as e2, f as f2, i as i2, d as d2, g as g2, m as m2, h as h2, j as j2, k as k2, o as o2, l as l2, q, s, t as t2, n as n2, p, u, r as r2, v as v2, w, x } from "./errors-wGhcJMpB.js";
|
|
4
|
-
import { c as c3, a as a4, p as p2, r as r3, t as t3 } from "./vectors-
|
|
5
|
-
import { D as D2, c as c4, a as a5, b as b3, g as g3, i as i3, d as d3, e as e3, f as f3, h as h3, j as j3, k as k3, l as l3, m as m3, w as w2 } from "./shapeTypes-
|
|
4
|
+
import { c as c3, a as a4, p as p2, r as r3, t as t3 } from "./vectors-BVgXsYWl.js";
|
|
5
|
+
import { D as D2, c as c4, a as a5, b as b3, g as g3, i as i3, d as d3, e as e3, f as f3, h as h3, j as j3, k as k3, l as l3, m as m3, w as w2 } from "./shapeTypes-C9sUsmEW.js";
|
|
6
6
|
import { BrepBugError, bug } from "./result.js";
|
|
7
7
|
export {
|
|
8
8
|
BrepBugError,
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const helpers = require("./helpers-Ck8GJ58k.cjs");
|
|
3
|
+
const vecOps = require("./vecOps-CjRL1jau.cjs");
|
|
4
|
+
const PI_2 = 2 * Math.PI;
|
|
5
|
+
function positiveHalfAngle(angle) {
|
|
6
|
+
const limitedAngle = angle % PI_2;
|
|
7
|
+
const coterminalAngle = limitedAngle < 0 ? limitedAngle + PI_2 : limitedAngle;
|
|
8
|
+
if (coterminalAngle < Math.PI) return coterminalAngle;
|
|
9
|
+
if (coterminalAngle === Math.PI) return 0;
|
|
10
|
+
return Math.abs(coterminalAngle - PI_2);
|
|
11
|
+
}
|
|
12
|
+
function blueprintCorners(blueprint) {
|
|
13
|
+
return blueprint.curves.map((curve, index) => ({
|
|
14
|
+
firstCurve: curve,
|
|
15
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
16
|
+
secondCurve: blueprint.curves[(index + 1) % blueprint.curves.length],
|
|
17
|
+
point: curve.lastPoint
|
|
18
|
+
}));
|
|
19
|
+
}
|
|
20
|
+
function buildCornerFinder(filters) {
|
|
21
|
+
const withFilter = (pred) => buildCornerFinder([...filters, pred]);
|
|
22
|
+
const shouldKeep = (corner) => filters.every((f) => f(corner));
|
|
23
|
+
return {
|
|
24
|
+
shouldKeep,
|
|
25
|
+
when: (pred) => withFilter(pred),
|
|
26
|
+
inList: (points) => withFilter((corner) => points.some((p) => helpers.samePoint(p, corner.point))),
|
|
27
|
+
atDistance: (distance, point = [0, 0]) => withFilter((corner) => Math.abs(helpers.distance2d(point, corner.point) - distance) < 1e-9),
|
|
28
|
+
atPoint: (point) => withFilter((corner) => helpers.samePoint(point, corner.point)),
|
|
29
|
+
inBox: (corner1, corner2) => {
|
|
30
|
+
const minX = Math.min(corner1[0], corner2[0]);
|
|
31
|
+
const maxX = Math.max(corner1[0], corner2[0]);
|
|
32
|
+
const minY = Math.min(corner1[1], corner2[1]);
|
|
33
|
+
const maxY = Math.max(corner1[1], corner2[1]);
|
|
34
|
+
return withFilter((corner) => {
|
|
35
|
+
const [x, y] = corner.point;
|
|
36
|
+
return x >= minX && x <= maxX && y >= minY && y <= maxY;
|
|
37
|
+
});
|
|
38
|
+
},
|
|
39
|
+
ofAngle: (angle) => withFilter((corner) => {
|
|
40
|
+
const tgt1 = corner.firstCurve.tangentAt(1);
|
|
41
|
+
const tgt2 = corner.secondCurve.tangentAt(0);
|
|
42
|
+
return Math.abs(positiveHalfAngle(helpers.angle2d(tgt1, tgt2)) - positiveHalfAngle(vecOps.DEG2RAD * angle)) < 1e-9;
|
|
43
|
+
}),
|
|
44
|
+
not: (fn) => {
|
|
45
|
+
const inner = fn(buildCornerFinder([]));
|
|
46
|
+
return withFilter((corner) => !inner.shouldKeep(corner));
|
|
47
|
+
},
|
|
48
|
+
either: (fns) => {
|
|
49
|
+
const builtFinders = fns.map((fn) => fn(buildCornerFinder([])));
|
|
50
|
+
return withFilter((corner) => builtFinders.some((f) => f.shouldKeep(corner)));
|
|
51
|
+
},
|
|
52
|
+
find: (blueprint) => blueprintCorners(blueprint).filter(shouldKeep)
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
function cornerFinder() {
|
|
56
|
+
return buildCornerFinder([]);
|
|
57
|
+
}
|
|
58
|
+
exports.cornerFinder = cornerFinder;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { a as angle2d, s as samePoint, d as distance2d } from "./helpers-jku2V1DY.js";
|
|
2
|
+
import { D as DEG2RAD } from "./vecOps-ZDdZWbwT.js";
|
|
3
|
+
const PI_2 = 2 * Math.PI;
|
|
4
|
+
function positiveHalfAngle(angle) {
|
|
5
|
+
const limitedAngle = angle % PI_2;
|
|
6
|
+
const coterminalAngle = limitedAngle < 0 ? limitedAngle + PI_2 : limitedAngle;
|
|
7
|
+
if (coterminalAngle < Math.PI) return coterminalAngle;
|
|
8
|
+
if (coterminalAngle === Math.PI) return 0;
|
|
9
|
+
return Math.abs(coterminalAngle - PI_2);
|
|
10
|
+
}
|
|
11
|
+
function blueprintCorners(blueprint) {
|
|
12
|
+
return blueprint.curves.map((curve, index) => ({
|
|
13
|
+
firstCurve: curve,
|
|
14
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
15
|
+
secondCurve: blueprint.curves[(index + 1) % blueprint.curves.length],
|
|
16
|
+
point: curve.lastPoint
|
|
17
|
+
}));
|
|
18
|
+
}
|
|
19
|
+
function buildCornerFinder(filters) {
|
|
20
|
+
const withFilter = (pred) => buildCornerFinder([...filters, pred]);
|
|
21
|
+
const shouldKeep = (corner) => filters.every((f) => f(corner));
|
|
22
|
+
return {
|
|
23
|
+
shouldKeep,
|
|
24
|
+
when: (pred) => withFilter(pred),
|
|
25
|
+
inList: (points) => withFilter((corner) => points.some((p) => samePoint(p, corner.point))),
|
|
26
|
+
atDistance: (distance, point = [0, 0]) => withFilter((corner) => Math.abs(distance2d(point, corner.point) - distance) < 1e-9),
|
|
27
|
+
atPoint: (point) => withFilter((corner) => samePoint(point, corner.point)),
|
|
28
|
+
inBox: (corner1, corner2) => {
|
|
29
|
+
const minX = Math.min(corner1[0], corner2[0]);
|
|
30
|
+
const maxX = Math.max(corner1[0], corner2[0]);
|
|
31
|
+
const minY = Math.min(corner1[1], corner2[1]);
|
|
32
|
+
const maxY = Math.max(corner1[1], corner2[1]);
|
|
33
|
+
return withFilter((corner) => {
|
|
34
|
+
const [x, y] = corner.point;
|
|
35
|
+
return x >= minX && x <= maxX && y >= minY && y <= maxY;
|
|
36
|
+
});
|
|
37
|
+
},
|
|
38
|
+
ofAngle: (angle) => withFilter((corner) => {
|
|
39
|
+
const tgt1 = corner.firstCurve.tangentAt(1);
|
|
40
|
+
const tgt2 = corner.secondCurve.tangentAt(0);
|
|
41
|
+
return Math.abs(positiveHalfAngle(angle2d(tgt1, tgt2)) - positiveHalfAngle(DEG2RAD * angle)) < 1e-9;
|
|
42
|
+
}),
|
|
43
|
+
not: (fn) => {
|
|
44
|
+
const inner = fn(buildCornerFinder([]));
|
|
45
|
+
return withFilter((corner) => !inner.shouldKeep(corner));
|
|
46
|
+
},
|
|
47
|
+
either: (fns) => {
|
|
48
|
+
const builtFinders = fns.map((fn) => fn(buildCornerFinder([])));
|
|
49
|
+
return withFilter((corner) => builtFinders.some((f) => f.shouldKeep(corner)));
|
|
50
|
+
},
|
|
51
|
+
find: (blueprint) => blueprintCorners(blueprint).filter(shouldKeep)
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
function cornerFinder() {
|
|
55
|
+
return buildCornerFinder([]);
|
|
56
|
+
}
|
|
57
|
+
export {
|
|
58
|
+
cornerFinder as c
|
|
59
|
+
};
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const occtBoundary = require("./occtBoundary-6kQSl3cF.cjs");
|
|
3
|
+
const shapeTypes = require("./shapeTypes-BJ3Hmskg.cjs");
|
|
4
|
+
const errors = require("./errors-DK1VAdP4.cjs");
|
|
5
|
+
function makeLine(v1, v2) {
|
|
6
|
+
const oc = occtBoundary.getKernel().oc;
|
|
7
|
+
const r = shapeTypes.gcWithScope();
|
|
8
|
+
const p1 = r(occtBoundary.toOcPnt(v1));
|
|
9
|
+
const p2 = r(occtBoundary.toOcPnt(v2));
|
|
10
|
+
const maker = r(new oc.BRepBuilderAPI_MakeEdge_3(p1, p2));
|
|
11
|
+
return shapeTypes.createEdge(maker.Edge());
|
|
12
|
+
}
|
|
13
|
+
function makeCircle(radius, center = [0, 0, 0], normal = [0, 0, 1]) {
|
|
14
|
+
const oc = occtBoundary.getKernel().oc;
|
|
15
|
+
const r = shapeTypes.gcWithScope();
|
|
16
|
+
const ax = r(occtBoundary.makeOcAx2(center, normal));
|
|
17
|
+
const circleGp = r(new oc.gp_Circ_2(ax, radius));
|
|
18
|
+
const edgeMaker = r(new oc.BRepBuilderAPI_MakeEdge_8(circleGp));
|
|
19
|
+
return shapeTypes.createEdge(edgeMaker.Edge());
|
|
20
|
+
}
|
|
21
|
+
function makeEllipse(majorRadius, minorRadius, center = [0, 0, 0], normal = [0, 0, 1], xDir) {
|
|
22
|
+
if (minorRadius > majorRadius) {
|
|
23
|
+
return errors.err(
|
|
24
|
+
errors.validationError("ELLIPSE_RADII", "The minor radius must be smaller than the major one")
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
const oc = occtBoundary.getKernel().oc;
|
|
28
|
+
const r = shapeTypes.gcWithScope();
|
|
29
|
+
const ax = r(occtBoundary.makeOcAx2(center, normal, xDir));
|
|
30
|
+
const ellipseGp = r(new oc.gp_Elips_2(ax, majorRadius, minorRadius));
|
|
31
|
+
const edgeMaker = r(new oc.BRepBuilderAPI_MakeEdge_12(ellipseGp));
|
|
32
|
+
return errors.ok(shapeTypes.createEdge(edgeMaker.Edge()));
|
|
33
|
+
}
|
|
34
|
+
function makeHelix(pitch, height, radius, center = [0, 0, 0], dir = [0, 0, 1], lefthand = false) {
|
|
35
|
+
const oc = occtBoundary.getKernel().oc;
|
|
36
|
+
const r = shapeTypes.gcWithScope();
|
|
37
|
+
const angularStep = lefthand ? -2 * Math.PI : 2 * Math.PI;
|
|
38
|
+
const geomLine = r(
|
|
39
|
+
new oc.Geom2d_Line_3(r(new oc.gp_Pnt2d_3(0, 0)), r(new oc.gp_Dir2d_4(angularStep, pitch)))
|
|
40
|
+
);
|
|
41
|
+
const nTurns = height / pitch;
|
|
42
|
+
const uStart = r(geomLine.Value(0));
|
|
43
|
+
const uStop = r(geomLine.Value(nTurns * Math.sqrt((2 * Math.PI) ** 2 + pitch ** 2)));
|
|
44
|
+
const geomSeg = r(new oc.GCE2d_MakeSegment_1(uStart, uStop));
|
|
45
|
+
const geomSurf = new oc.Geom_CylindricalSurface_1(r(occtBoundary.makeOcAx3(center, dir)), radius);
|
|
46
|
+
const e = r(
|
|
47
|
+
new oc.BRepBuilderAPI_MakeEdge_30(
|
|
48
|
+
r(new oc.Handle_Geom2d_Curve_2(geomSeg.Value().get())),
|
|
49
|
+
r(new oc.Handle_Geom_Surface_2(geomSurf))
|
|
50
|
+
)
|
|
51
|
+
).Edge();
|
|
52
|
+
const w = r(new oc.BRepBuilderAPI_MakeWire_2(e)).Wire();
|
|
53
|
+
oc.BRepLib.BuildCurves3d_2(w);
|
|
54
|
+
return shapeTypes.createWire(w);
|
|
55
|
+
}
|
|
56
|
+
function makeThreePointArc(v1, v2, v3) {
|
|
57
|
+
const oc = occtBoundary.getKernel().oc;
|
|
58
|
+
const r = shapeTypes.gcWithScope();
|
|
59
|
+
const p1 = r(occtBoundary.toOcPnt(v1));
|
|
60
|
+
const p2 = r(occtBoundary.toOcPnt(v2));
|
|
61
|
+
const p3 = r(occtBoundary.toOcPnt(v3));
|
|
62
|
+
const arcMaker = r(new oc.GC_MakeArcOfCircle_4(p1, p2, p3));
|
|
63
|
+
const circleGeom = r(arcMaker.Value());
|
|
64
|
+
const curve = r(new oc.Handle_Geom_Curve_2(circleGeom.get()));
|
|
65
|
+
const edgeMaker = r(new oc.BRepBuilderAPI_MakeEdge_24(curve));
|
|
66
|
+
return shapeTypes.createEdge(edgeMaker.Edge());
|
|
67
|
+
}
|
|
68
|
+
function makeEllipseArc(majorRadius, minorRadius, startAngle, endAngle, center = [0, 0, 0], normal = [0, 0, 1], xDir) {
|
|
69
|
+
if (minorRadius > majorRadius) {
|
|
70
|
+
return errors.err(
|
|
71
|
+
errors.validationError("ELLIPSE_RADII", "The minor radius must be smaller than the major one")
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
const oc = occtBoundary.getKernel().oc;
|
|
75
|
+
const r = shapeTypes.gcWithScope();
|
|
76
|
+
const ax = r(occtBoundary.makeOcAx2(center, normal, xDir));
|
|
77
|
+
const ellipseGp = r(new oc.gp_Elips_2(ax, majorRadius, minorRadius));
|
|
78
|
+
const edgeMaker = r(new oc.BRepBuilderAPI_MakeEdge_13(ellipseGp, startAngle, endAngle));
|
|
79
|
+
return errors.ok(shapeTypes.createEdge(edgeMaker.Edge()));
|
|
80
|
+
}
|
|
81
|
+
function makeBSplineApproximation(points, { tolerance = 1e-3, smoothing = null, degMax = 6, degMin = 1 } = {}) {
|
|
82
|
+
const oc = occtBoundary.getKernel().oc;
|
|
83
|
+
const r = shapeTypes.gcWithScope();
|
|
84
|
+
const pnts = r(new oc.TColgp_Array1OfPnt_2(1, points.length));
|
|
85
|
+
points.forEach((point, index) => {
|
|
86
|
+
pnts.SetValue(index + 1, r(occtBoundary.toOcPnt(point)));
|
|
87
|
+
});
|
|
88
|
+
let splineBuilder;
|
|
89
|
+
if (smoothing) {
|
|
90
|
+
splineBuilder = r(
|
|
91
|
+
new oc.GeomAPI_PointsToBSpline_5(
|
|
92
|
+
pnts,
|
|
93
|
+
smoothing[0],
|
|
94
|
+
smoothing[1],
|
|
95
|
+
smoothing[2],
|
|
96
|
+
degMax,
|
|
97
|
+
oc.GeomAbs_Shape.GeomAbs_C2,
|
|
98
|
+
tolerance
|
|
99
|
+
)
|
|
100
|
+
);
|
|
101
|
+
} else {
|
|
102
|
+
splineBuilder = r(
|
|
103
|
+
new oc.GeomAPI_PointsToBSpline_2(
|
|
104
|
+
pnts,
|
|
105
|
+
degMin,
|
|
106
|
+
degMax,
|
|
107
|
+
oc.GeomAbs_Shape.GeomAbs_C2,
|
|
108
|
+
tolerance
|
|
109
|
+
)
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
if (!splineBuilder.IsDone()) {
|
|
113
|
+
return errors.err(errors.occtError("BSPLINE_FAILED", "B-spline approximation failed"));
|
|
114
|
+
}
|
|
115
|
+
const splineGeom = r(splineBuilder.Curve());
|
|
116
|
+
const curve = r(new oc.Handle_Geom_Curve_2(splineGeom.get()));
|
|
117
|
+
return errors.ok(shapeTypes.createEdge(new oc.BRepBuilderAPI_MakeEdge_24(curve).Edge()));
|
|
118
|
+
}
|
|
119
|
+
function makeBezierCurve(points) {
|
|
120
|
+
if (points.length < 2) {
|
|
121
|
+
return errors.err(
|
|
122
|
+
errors.validationError(
|
|
123
|
+
"BEZIER_MIN_POINTS",
|
|
124
|
+
`Need at least 2 points for a Bezier curve, got ${points.length}`,
|
|
125
|
+
void 0,
|
|
126
|
+
{
|
|
127
|
+
pointCount: points.length
|
|
128
|
+
}
|
|
129
|
+
)
|
|
130
|
+
);
|
|
131
|
+
}
|
|
132
|
+
const oc = occtBoundary.getKernel().oc;
|
|
133
|
+
const r = shapeTypes.gcWithScope();
|
|
134
|
+
const arrayOfPoints = r(new oc.TColgp_Array1OfPnt_2(1, points.length));
|
|
135
|
+
points.forEach((p, i) => {
|
|
136
|
+
arrayOfPoints.SetValue(i + 1, r(occtBoundary.toOcPnt(p)));
|
|
137
|
+
});
|
|
138
|
+
const bezCurve = new oc.Geom_BezierCurve_1(arrayOfPoints);
|
|
139
|
+
const curve = r(new oc.Handle_Geom_Curve_2(bezCurve));
|
|
140
|
+
const edgeMaker = r(new oc.BRepBuilderAPI_MakeEdge_24(curve));
|
|
141
|
+
return errors.ok(shapeTypes.createEdge(edgeMaker.Edge()));
|
|
142
|
+
}
|
|
143
|
+
function makeTangentArc(startPoint, startTgt, endPoint) {
|
|
144
|
+
const oc = occtBoundary.getKernel().oc;
|
|
145
|
+
const r = shapeTypes.gcWithScope();
|
|
146
|
+
const circleGeom = r(
|
|
147
|
+
new oc.GC_MakeArcOfCircle_5(
|
|
148
|
+
r(occtBoundary.toOcPnt(startPoint)),
|
|
149
|
+
r(occtBoundary.toOcVec(startTgt)),
|
|
150
|
+
r(occtBoundary.toOcPnt(endPoint))
|
|
151
|
+
).Value()
|
|
152
|
+
);
|
|
153
|
+
const curve = r(new oc.Handle_Geom_Curve_2(circleGeom.get()));
|
|
154
|
+
const edgeMaker = r(new oc.BRepBuilderAPI_MakeEdge_24(curve));
|
|
155
|
+
return shapeTypes.createEdge(edgeMaker.Edge());
|
|
156
|
+
}
|
|
157
|
+
function assembleWire(listOfEdges) {
|
|
158
|
+
const oc = occtBoundary.getKernel().oc;
|
|
159
|
+
const r = shapeTypes.gcWithScope();
|
|
160
|
+
const wireBuilder = r(new oc.BRepBuilderAPI_MakeWire_1());
|
|
161
|
+
listOfEdges.forEach((e) => {
|
|
162
|
+
if (shapeTypes.isEdge(e)) {
|
|
163
|
+
wireBuilder.Add_1(e.wrapped);
|
|
164
|
+
}
|
|
165
|
+
if (shapeTypes.isWire(e)) {
|
|
166
|
+
wireBuilder.Add_2(e.wrapped);
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
const progress = r(new oc.Message_ProgressRange_1());
|
|
170
|
+
wireBuilder.Build(progress);
|
|
171
|
+
const res = wireBuilder.Error();
|
|
172
|
+
if (res !== oc.BRepBuilderAPI_WireError.BRepBuilderAPI_WireDone) {
|
|
173
|
+
const errorNames = /* @__PURE__ */ new Map([
|
|
174
|
+
[oc.BRepBuilderAPI_WireError.BRepBuilderAPI_EmptyWire, "empty wire"],
|
|
175
|
+
[oc.BRepBuilderAPI_WireError.BRepBuilderAPI_NonManifoldWire, "non manifold wire"],
|
|
176
|
+
[oc.BRepBuilderAPI_WireError.BRepBuilderAPI_DisconnectedWire, "disconnected wire"]
|
|
177
|
+
]);
|
|
178
|
+
return errors.err(
|
|
179
|
+
errors.occtError(
|
|
180
|
+
"WIRE_BUILD_FAILED",
|
|
181
|
+
`Failed to build the wire, ${errorNames.get(res) || "unknown error"}`
|
|
182
|
+
)
|
|
183
|
+
);
|
|
184
|
+
}
|
|
185
|
+
return errors.ok(shapeTypes.createWire(wireBuilder.Wire()));
|
|
186
|
+
}
|
|
187
|
+
exports.assembleWire = assembleWire;
|
|
188
|
+
exports.makeBSplineApproximation = makeBSplineApproximation;
|
|
189
|
+
exports.makeBezierCurve = makeBezierCurve;
|
|
190
|
+
exports.makeCircle = makeCircle;
|
|
191
|
+
exports.makeEllipse = makeEllipse;
|
|
192
|
+
exports.makeEllipseArc = makeEllipseArc;
|
|
193
|
+
exports.makeHelix = makeHelix;
|
|
194
|
+
exports.makeLine = makeLine;
|
|
195
|
+
exports.makeTangentArc = makeTangentArc;
|
|
196
|
+
exports.makeThreePointArc = makeThreePointArc;
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import { g as getKernel, b as toOcPnt, c as toOcVec, m as makeOcAx2, d as makeOcAx3 } from "./occtBoundary-CqXvDhZY.js";
|
|
2
|
+
import { d as isEdge, m as isWire, n as createWire, o as createEdge, p as gcWithScope } from "./shapeTypes-C9sUsmEW.js";
|
|
3
|
+
import { e as err, o as occtError, l as ok, x as validationError } from "./errors-wGhcJMpB.js";
|
|
4
|
+
function makeLine(v1, v2) {
|
|
5
|
+
const oc = getKernel().oc;
|
|
6
|
+
const r = gcWithScope();
|
|
7
|
+
const p1 = r(toOcPnt(v1));
|
|
8
|
+
const p2 = r(toOcPnt(v2));
|
|
9
|
+
const maker = r(new oc.BRepBuilderAPI_MakeEdge_3(p1, p2));
|
|
10
|
+
return createEdge(maker.Edge());
|
|
11
|
+
}
|
|
12
|
+
function makeCircle(radius, center = [0, 0, 0], normal = [0, 0, 1]) {
|
|
13
|
+
const oc = getKernel().oc;
|
|
14
|
+
const r = gcWithScope();
|
|
15
|
+
const ax = r(makeOcAx2(center, normal));
|
|
16
|
+
const circleGp = r(new oc.gp_Circ_2(ax, radius));
|
|
17
|
+
const edgeMaker = r(new oc.BRepBuilderAPI_MakeEdge_8(circleGp));
|
|
18
|
+
return createEdge(edgeMaker.Edge());
|
|
19
|
+
}
|
|
20
|
+
function makeEllipse(majorRadius, minorRadius, center = [0, 0, 0], normal = [0, 0, 1], xDir) {
|
|
21
|
+
if (minorRadius > majorRadius) {
|
|
22
|
+
return err(
|
|
23
|
+
validationError("ELLIPSE_RADII", "The minor radius must be smaller than the major one")
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
const oc = getKernel().oc;
|
|
27
|
+
const r = gcWithScope();
|
|
28
|
+
const ax = r(makeOcAx2(center, normal, xDir));
|
|
29
|
+
const ellipseGp = r(new oc.gp_Elips_2(ax, majorRadius, minorRadius));
|
|
30
|
+
const edgeMaker = r(new oc.BRepBuilderAPI_MakeEdge_12(ellipseGp));
|
|
31
|
+
return ok(createEdge(edgeMaker.Edge()));
|
|
32
|
+
}
|
|
33
|
+
function makeHelix(pitch, height, radius, center = [0, 0, 0], dir = [0, 0, 1], lefthand = false) {
|
|
34
|
+
const oc = getKernel().oc;
|
|
35
|
+
const r = gcWithScope();
|
|
36
|
+
const angularStep = lefthand ? -2 * Math.PI : 2 * Math.PI;
|
|
37
|
+
const geomLine = r(
|
|
38
|
+
new oc.Geom2d_Line_3(r(new oc.gp_Pnt2d_3(0, 0)), r(new oc.gp_Dir2d_4(angularStep, pitch)))
|
|
39
|
+
);
|
|
40
|
+
const nTurns = height / pitch;
|
|
41
|
+
const uStart = r(geomLine.Value(0));
|
|
42
|
+
const uStop = r(geomLine.Value(nTurns * Math.sqrt((2 * Math.PI) ** 2 + pitch ** 2)));
|
|
43
|
+
const geomSeg = r(new oc.GCE2d_MakeSegment_1(uStart, uStop));
|
|
44
|
+
const geomSurf = new oc.Geom_CylindricalSurface_1(r(makeOcAx3(center, dir)), radius);
|
|
45
|
+
const e = r(
|
|
46
|
+
new oc.BRepBuilderAPI_MakeEdge_30(
|
|
47
|
+
r(new oc.Handle_Geom2d_Curve_2(geomSeg.Value().get())),
|
|
48
|
+
r(new oc.Handle_Geom_Surface_2(geomSurf))
|
|
49
|
+
)
|
|
50
|
+
).Edge();
|
|
51
|
+
const w = r(new oc.BRepBuilderAPI_MakeWire_2(e)).Wire();
|
|
52
|
+
oc.BRepLib.BuildCurves3d_2(w);
|
|
53
|
+
return createWire(w);
|
|
54
|
+
}
|
|
55
|
+
function makeThreePointArc(v1, v2, v3) {
|
|
56
|
+
const oc = getKernel().oc;
|
|
57
|
+
const r = gcWithScope();
|
|
58
|
+
const p1 = r(toOcPnt(v1));
|
|
59
|
+
const p2 = r(toOcPnt(v2));
|
|
60
|
+
const p3 = r(toOcPnt(v3));
|
|
61
|
+
const arcMaker = r(new oc.GC_MakeArcOfCircle_4(p1, p2, p3));
|
|
62
|
+
const circleGeom = r(arcMaker.Value());
|
|
63
|
+
const curve = r(new oc.Handle_Geom_Curve_2(circleGeom.get()));
|
|
64
|
+
const edgeMaker = r(new oc.BRepBuilderAPI_MakeEdge_24(curve));
|
|
65
|
+
return createEdge(edgeMaker.Edge());
|
|
66
|
+
}
|
|
67
|
+
function makeEllipseArc(majorRadius, minorRadius, startAngle, endAngle, center = [0, 0, 0], normal = [0, 0, 1], xDir) {
|
|
68
|
+
if (minorRadius > majorRadius) {
|
|
69
|
+
return err(
|
|
70
|
+
validationError("ELLIPSE_RADII", "The minor radius must be smaller than the major one")
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
const oc = getKernel().oc;
|
|
74
|
+
const r = gcWithScope();
|
|
75
|
+
const ax = r(makeOcAx2(center, normal, xDir));
|
|
76
|
+
const ellipseGp = r(new oc.gp_Elips_2(ax, majorRadius, minorRadius));
|
|
77
|
+
const edgeMaker = r(new oc.BRepBuilderAPI_MakeEdge_13(ellipseGp, startAngle, endAngle));
|
|
78
|
+
return ok(createEdge(edgeMaker.Edge()));
|
|
79
|
+
}
|
|
80
|
+
function makeBSplineApproximation(points, { tolerance = 1e-3, smoothing = null, degMax = 6, degMin = 1 } = {}) {
|
|
81
|
+
const oc = getKernel().oc;
|
|
82
|
+
const r = gcWithScope();
|
|
83
|
+
const pnts = r(new oc.TColgp_Array1OfPnt_2(1, points.length));
|
|
84
|
+
points.forEach((point, index) => {
|
|
85
|
+
pnts.SetValue(index + 1, r(toOcPnt(point)));
|
|
86
|
+
});
|
|
87
|
+
let splineBuilder;
|
|
88
|
+
if (smoothing) {
|
|
89
|
+
splineBuilder = r(
|
|
90
|
+
new oc.GeomAPI_PointsToBSpline_5(
|
|
91
|
+
pnts,
|
|
92
|
+
smoothing[0],
|
|
93
|
+
smoothing[1],
|
|
94
|
+
smoothing[2],
|
|
95
|
+
degMax,
|
|
96
|
+
oc.GeomAbs_Shape.GeomAbs_C2,
|
|
97
|
+
tolerance
|
|
98
|
+
)
|
|
99
|
+
);
|
|
100
|
+
} else {
|
|
101
|
+
splineBuilder = r(
|
|
102
|
+
new oc.GeomAPI_PointsToBSpline_2(
|
|
103
|
+
pnts,
|
|
104
|
+
degMin,
|
|
105
|
+
degMax,
|
|
106
|
+
oc.GeomAbs_Shape.GeomAbs_C2,
|
|
107
|
+
tolerance
|
|
108
|
+
)
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
if (!splineBuilder.IsDone()) {
|
|
112
|
+
return err(occtError("BSPLINE_FAILED", "B-spline approximation failed"));
|
|
113
|
+
}
|
|
114
|
+
const splineGeom = r(splineBuilder.Curve());
|
|
115
|
+
const curve = r(new oc.Handle_Geom_Curve_2(splineGeom.get()));
|
|
116
|
+
return ok(createEdge(new oc.BRepBuilderAPI_MakeEdge_24(curve).Edge()));
|
|
117
|
+
}
|
|
118
|
+
function makeBezierCurve(points) {
|
|
119
|
+
if (points.length < 2) {
|
|
120
|
+
return err(
|
|
121
|
+
validationError(
|
|
122
|
+
"BEZIER_MIN_POINTS",
|
|
123
|
+
`Need at least 2 points for a Bezier curve, got ${points.length}`,
|
|
124
|
+
void 0,
|
|
125
|
+
{
|
|
126
|
+
pointCount: points.length
|
|
127
|
+
}
|
|
128
|
+
)
|
|
129
|
+
);
|
|
130
|
+
}
|
|
131
|
+
const oc = getKernel().oc;
|
|
132
|
+
const r = gcWithScope();
|
|
133
|
+
const arrayOfPoints = r(new oc.TColgp_Array1OfPnt_2(1, points.length));
|
|
134
|
+
points.forEach((p, i) => {
|
|
135
|
+
arrayOfPoints.SetValue(i + 1, r(toOcPnt(p)));
|
|
136
|
+
});
|
|
137
|
+
const bezCurve = new oc.Geom_BezierCurve_1(arrayOfPoints);
|
|
138
|
+
const curve = r(new oc.Handle_Geom_Curve_2(bezCurve));
|
|
139
|
+
const edgeMaker = r(new oc.BRepBuilderAPI_MakeEdge_24(curve));
|
|
140
|
+
return ok(createEdge(edgeMaker.Edge()));
|
|
141
|
+
}
|
|
142
|
+
function makeTangentArc(startPoint, startTgt, endPoint) {
|
|
143
|
+
const oc = getKernel().oc;
|
|
144
|
+
const r = gcWithScope();
|
|
145
|
+
const circleGeom = r(
|
|
146
|
+
new oc.GC_MakeArcOfCircle_5(
|
|
147
|
+
r(toOcPnt(startPoint)),
|
|
148
|
+
r(toOcVec(startTgt)),
|
|
149
|
+
r(toOcPnt(endPoint))
|
|
150
|
+
).Value()
|
|
151
|
+
);
|
|
152
|
+
const curve = r(new oc.Handle_Geom_Curve_2(circleGeom.get()));
|
|
153
|
+
const edgeMaker = r(new oc.BRepBuilderAPI_MakeEdge_24(curve));
|
|
154
|
+
return createEdge(edgeMaker.Edge());
|
|
155
|
+
}
|
|
156
|
+
function assembleWire(listOfEdges) {
|
|
157
|
+
const oc = getKernel().oc;
|
|
158
|
+
const r = gcWithScope();
|
|
159
|
+
const wireBuilder = r(new oc.BRepBuilderAPI_MakeWire_1());
|
|
160
|
+
listOfEdges.forEach((e) => {
|
|
161
|
+
if (isEdge(e)) {
|
|
162
|
+
wireBuilder.Add_1(e.wrapped);
|
|
163
|
+
}
|
|
164
|
+
if (isWire(e)) {
|
|
165
|
+
wireBuilder.Add_2(e.wrapped);
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
const progress = r(new oc.Message_ProgressRange_1());
|
|
169
|
+
wireBuilder.Build(progress);
|
|
170
|
+
const res = wireBuilder.Error();
|
|
171
|
+
if (res !== oc.BRepBuilderAPI_WireError.BRepBuilderAPI_WireDone) {
|
|
172
|
+
const errorNames = /* @__PURE__ */ new Map([
|
|
173
|
+
[oc.BRepBuilderAPI_WireError.BRepBuilderAPI_EmptyWire, "empty wire"],
|
|
174
|
+
[oc.BRepBuilderAPI_WireError.BRepBuilderAPI_NonManifoldWire, "non manifold wire"],
|
|
175
|
+
[oc.BRepBuilderAPI_WireError.BRepBuilderAPI_DisconnectedWire, "disconnected wire"]
|
|
176
|
+
]);
|
|
177
|
+
return err(
|
|
178
|
+
occtError(
|
|
179
|
+
"WIRE_BUILD_FAILED",
|
|
180
|
+
`Failed to build the wire, ${errorNames.get(res) || "unknown error"}`
|
|
181
|
+
)
|
|
182
|
+
);
|
|
183
|
+
}
|
|
184
|
+
return ok(createWire(wireBuilder.Wire()));
|
|
185
|
+
}
|
|
186
|
+
export {
|
|
187
|
+
assembleWire as a,
|
|
188
|
+
makeHelix as b,
|
|
189
|
+
makeBezierCurve as c,
|
|
190
|
+
makeBSplineApproximation as d,
|
|
191
|
+
makeCircle as e,
|
|
192
|
+
makeEllipse as f,
|
|
193
|
+
makeEllipseArc as g,
|
|
194
|
+
makeTangentArc as h,
|
|
195
|
+
makeThreePointArc as i,
|
|
196
|
+
makeLine as m
|
|
197
|
+
};
|