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,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
const occtBoundary = require("./occtBoundary-
|
|
3
|
-
const shapeTypes = require("./shapeTypes-
|
|
2
|
+
const occtBoundary = require("./occtBoundary-6kQSl3cF.cjs");
|
|
3
|
+
const shapeTypes = require("./shapeTypes-BJ3Hmskg.cjs");
|
|
4
4
|
const errors = require("./errors-DK1VAdP4.cjs");
|
|
5
|
-
const vectors = require("./vectors-
|
|
5
|
+
const vectors = require("./vectors-DK2hEKcI.cjs");
|
|
6
6
|
const vecOps = require("./vecOps-CjRL1jau.cjs");
|
|
7
7
|
function applyGlue(op, optimisation) {
|
|
8
8
|
const oc = occtBoundary.getKernel().oc;
|
|
@@ -167,30 +167,26 @@ function makeSectionFace(plane, size) {
|
|
|
167
167
|
vecOps.vecAdd(vecOps.vecAdd(o, hx), hy),
|
|
168
168
|
vecOps.vecAdd(vecOps.vecAdd(o, nhx), hy)
|
|
169
169
|
];
|
|
170
|
-
const
|
|
170
|
+
const r = shapeTypes.gcWithScope();
|
|
171
|
+
const pts = corners.map((c) => r(new oc.gp_Pnt_3(c[0], c[1], c[2])));
|
|
171
172
|
const edges = [
|
|
172
|
-
new oc.BRepBuilderAPI_MakeEdge_3(pts[0], pts[1]),
|
|
173
|
-
new oc.BRepBuilderAPI_MakeEdge_3(pts[1], pts[2]),
|
|
174
|
-
new oc.BRepBuilderAPI_MakeEdge_3(pts[2], pts[3]),
|
|
175
|
-
new oc.BRepBuilderAPI_MakeEdge_3(pts[3], pts[0])
|
|
173
|
+
r(new oc.BRepBuilderAPI_MakeEdge_3(pts[0], pts[1])),
|
|
174
|
+
r(new oc.BRepBuilderAPI_MakeEdge_3(pts[1], pts[2])),
|
|
175
|
+
r(new oc.BRepBuilderAPI_MakeEdge_3(pts[2], pts[3])),
|
|
176
|
+
r(new oc.BRepBuilderAPI_MakeEdge_3(pts[3], pts[0]))
|
|
176
177
|
];
|
|
177
|
-
const wireBuilder = new oc.BRepBuilderAPI_MakeWire_1();
|
|
178
|
+
const wireBuilder = r(new oc.BRepBuilderAPI_MakeWire_1());
|
|
178
179
|
for (const e of edges) {
|
|
179
180
|
const edge = e.Edge();
|
|
180
181
|
wireBuilder.Add_1(edge);
|
|
181
182
|
edge.delete();
|
|
182
183
|
}
|
|
183
|
-
const progress = new oc.Message_ProgressRange_1();
|
|
184
|
+
const progress = r(new oc.Message_ProgressRange_1());
|
|
184
185
|
wireBuilder.Build(progress);
|
|
185
186
|
const wire = wireBuilder.Wire();
|
|
186
|
-
const faceBuilder = new oc.BRepBuilderAPI_MakeFace_15(wire, true);
|
|
187
|
+
const faceBuilder = r(new oc.BRepBuilderAPI_MakeFace_15(wire, true));
|
|
187
188
|
const face = faceBuilder.Face();
|
|
188
|
-
faceBuilder.delete();
|
|
189
189
|
wire.delete();
|
|
190
|
-
wireBuilder.delete();
|
|
191
|
-
progress.delete();
|
|
192
|
-
for (const e of edges) e.delete();
|
|
193
|
-
for (const p of pts) p.delete();
|
|
194
190
|
return face;
|
|
195
191
|
}
|
|
196
192
|
function section(shape, plane, { approximation = true, planeSize = 1e4 } = {}) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { g as getKernel } from "./occtBoundary-
|
|
2
|
-
import {
|
|
1
|
+
import { g as getKernel } from "./occtBoundary-CqXvDhZY.js";
|
|
2
|
+
import { p as gcWithScope, c as castShape, h as isShape3D } from "./shapeTypes-C9sUsmEW.js";
|
|
3
3
|
import { l as ok, d as isErr, e as err, x as validationError, B as BrepErrorCode, p as typeCastError, o as occtError } from "./errors-wGhcJMpB.js";
|
|
4
|
-
import { r as resolvePlane } from "./vectors-
|
|
4
|
+
import { r as resolvePlane } from "./vectors-BVgXsYWl.js";
|
|
5
5
|
import { n as vecScale, v as vecAdd } from "./vecOps-ZDdZWbwT.js";
|
|
6
6
|
function applyGlue(op, optimisation) {
|
|
7
7
|
const oc = getKernel().oc;
|
|
@@ -166,30 +166,26 @@ function makeSectionFace(plane, size) {
|
|
|
166
166
|
vecAdd(vecAdd(o, hx), hy),
|
|
167
167
|
vecAdd(vecAdd(o, nhx), hy)
|
|
168
168
|
];
|
|
169
|
-
const
|
|
169
|
+
const r = gcWithScope();
|
|
170
|
+
const pts = corners.map((c) => r(new oc.gp_Pnt_3(c[0], c[1], c[2])));
|
|
170
171
|
const edges = [
|
|
171
|
-
new oc.BRepBuilderAPI_MakeEdge_3(pts[0], pts[1]),
|
|
172
|
-
new oc.BRepBuilderAPI_MakeEdge_3(pts[1], pts[2]),
|
|
173
|
-
new oc.BRepBuilderAPI_MakeEdge_3(pts[2], pts[3]),
|
|
174
|
-
new oc.BRepBuilderAPI_MakeEdge_3(pts[3], pts[0])
|
|
172
|
+
r(new oc.BRepBuilderAPI_MakeEdge_3(pts[0], pts[1])),
|
|
173
|
+
r(new oc.BRepBuilderAPI_MakeEdge_3(pts[1], pts[2])),
|
|
174
|
+
r(new oc.BRepBuilderAPI_MakeEdge_3(pts[2], pts[3])),
|
|
175
|
+
r(new oc.BRepBuilderAPI_MakeEdge_3(pts[3], pts[0]))
|
|
175
176
|
];
|
|
176
|
-
const wireBuilder = new oc.BRepBuilderAPI_MakeWire_1();
|
|
177
|
+
const wireBuilder = r(new oc.BRepBuilderAPI_MakeWire_1());
|
|
177
178
|
for (const e of edges) {
|
|
178
179
|
const edge = e.Edge();
|
|
179
180
|
wireBuilder.Add_1(edge);
|
|
180
181
|
edge.delete();
|
|
181
182
|
}
|
|
182
|
-
const progress = new oc.Message_ProgressRange_1();
|
|
183
|
+
const progress = r(new oc.Message_ProgressRange_1());
|
|
183
184
|
wireBuilder.Build(progress);
|
|
184
185
|
const wire = wireBuilder.Wire();
|
|
185
|
-
const faceBuilder = new oc.BRepBuilderAPI_MakeFace_15(wire, true);
|
|
186
|
+
const faceBuilder = r(new oc.BRepBuilderAPI_MakeFace_15(wire, true));
|
|
186
187
|
const face = faceBuilder.Face();
|
|
187
|
-
faceBuilder.delete();
|
|
188
188
|
wire.delete();
|
|
189
|
-
wireBuilder.delete();
|
|
190
|
-
progress.delete();
|
|
191
|
-
for (const e of edges) e.delete();
|
|
192
|
-
for (const p of pts) p.delete();
|
|
193
189
|
return face;
|
|
194
190
|
}
|
|
195
191
|
function section(shape, plane, { approximation = true, planeSize = 1e4 } = {}) {
|
|
@@ -261,9 +257,9 @@ export {
|
|
|
261
257
|
split as b,
|
|
262
258
|
cut as c,
|
|
263
259
|
cutAll as d,
|
|
264
|
-
|
|
260
|
+
fuseAll as e,
|
|
265
261
|
fuse as f,
|
|
266
|
-
|
|
262
|
+
applyGlue as g,
|
|
267
263
|
intersect as i,
|
|
268
264
|
section as s
|
|
269
265
|
};
|
package/dist/brepjs.cjs
CHANGED
|
@@ -1,28 +1,30 @@
|
|
|
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 errors = require("./errors-DK1VAdP4.cjs");
|
|
5
|
-
const shapeTypes = require("./shapeTypes-
|
|
5
|
+
const shapeTypes = require("./shapeTypes-BJ3Hmskg.cjs");
|
|
6
6
|
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-
|
|
7
|
+
const Blueprint = require("./Blueprint-VGbo3izk.cjs");
|
|
8
|
+
const curveFns = require("./curveFns-BrJDkaWi.cjs");
|
|
9
|
+
const loft$2 = require("./loft-DJXwxV_L.cjs");
|
|
10
|
+
const operations = require("./operations-Do-WZGXc.cjs");
|
|
11
|
+
const boolean2D = require("./boolean2D-B1XrGVgx.cjs");
|
|
12
12
|
const _2d = require("./2d.cjs");
|
|
13
|
-
const
|
|
13
|
+
const helpers = require("./helpers-Ck8GJ58k.cjs");
|
|
14
14
|
const io = require("./io.cjs");
|
|
15
|
-
const drawFns = require("./drawFns-
|
|
16
|
-
const vectors = require("./vectors-
|
|
17
|
-
const shapeFns = require("./shapeFns-
|
|
18
|
-
const topology = require("./topology-
|
|
19
|
-
const faceFns = require("./faceFns-
|
|
20
|
-
const meshFns = require("./meshFns-
|
|
21
|
-
const booleanFns = require("./booleanFns-
|
|
22
|
-
const measurement = require("./measurement-
|
|
23
|
-
const
|
|
24
|
-
const cast = require("./cast-
|
|
15
|
+
const drawFns = require("./drawFns-D2eDcf4k.cjs");
|
|
16
|
+
const vectors = require("./vectors-DK2hEKcI.cjs");
|
|
17
|
+
const shapeFns = require("./shapeFns-cN4qGpbO.cjs");
|
|
18
|
+
const topology = require("./topology-DXq8dLsi.cjs");
|
|
19
|
+
const faceFns = require("./faceFns-NDRFeekj.cjs");
|
|
20
|
+
const meshFns = require("./meshFns-c8lDKfYy.cjs");
|
|
21
|
+
const booleanFns = require("./booleanFns-BxW-N3rP.cjs");
|
|
22
|
+
const measurement = require("./measurement-LcGh4wV0.cjs");
|
|
23
|
+
const curveBuilders = require("./curveBuilders-BUoFO1UG.cjs");
|
|
24
|
+
const cast = require("./cast-DIiyxDLo.cjs");
|
|
25
|
+
const query = require("./query.cjs");
|
|
25
26
|
const result = require("./result.cjs");
|
|
27
|
+
const cornerFinder = require("./cornerFinder-BndBNtJE.cjs");
|
|
26
28
|
const worker = require("./worker.cjs");
|
|
27
29
|
const errorFactories = {
|
|
28
30
|
OCCT_OPERATION: (code, message, cause) => ({ kind: "OCCT_OPERATION", code, message, cause }),
|
|
@@ -70,6 +72,79 @@ function isFilletRadius(r) {
|
|
|
70
72
|
}
|
|
71
73
|
return false;
|
|
72
74
|
}
|
|
75
|
+
function buildWireFinder(filters) {
|
|
76
|
+
return helpers.createTypedFinder(
|
|
77
|
+
"wire",
|
|
78
|
+
filters,
|
|
79
|
+
buildWireFinder,
|
|
80
|
+
(_base, withFilter) => ({
|
|
81
|
+
isClosed: () => withFilter((wire2) => curveFns.curveIsClosed(wire2)),
|
|
82
|
+
isOpen: () => withFilter((wire2) => !curveFns.curveIsClosed(wire2)),
|
|
83
|
+
ofEdgeCount: (count) => withFilter((wire2) => {
|
|
84
|
+
let edgeCount = 0;
|
|
85
|
+
for (const _raw of cast.iterTopo(wire2.wrapped, "edge")) {
|
|
86
|
+
edgeCount++;
|
|
87
|
+
}
|
|
88
|
+
return edgeCount === count;
|
|
89
|
+
})
|
|
90
|
+
})
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
function wireFinder() {
|
|
94
|
+
return buildWireFinder([]);
|
|
95
|
+
}
|
|
96
|
+
function withNearestPostFilter(baseFinder, nearestPoint) {
|
|
97
|
+
const findAllNearest = (shape2) => {
|
|
98
|
+
const candidates = baseFinder.findAll(shape2);
|
|
99
|
+
if (candidates.length === 0) return [];
|
|
100
|
+
let bestIdx = 0;
|
|
101
|
+
let bestDist = vecOps.vecDistance(shapeFns.vertexPosition(candidates[0]), nearestPoint);
|
|
102
|
+
for (let i = 1; i < candidates.length; i++) {
|
|
103
|
+
const d = vecOps.vecDistance(shapeFns.vertexPosition(candidates[i]), nearestPoint);
|
|
104
|
+
if (d < bestDist) {
|
|
105
|
+
bestDist = d;
|
|
106
|
+
bestIdx = i;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
return [candidates[bestIdx]];
|
|
110
|
+
};
|
|
111
|
+
const findUniqueNearest = (shape2) => {
|
|
112
|
+
const nearest = findAllNearest(shape2);
|
|
113
|
+
if (nearest.length === 0) {
|
|
114
|
+
return errors.err(
|
|
115
|
+
errors.queryError("FINDER_NOT_UNIQUE", "Finder expected a unique match but found 0 element(s)")
|
|
116
|
+
);
|
|
117
|
+
}
|
|
118
|
+
return errors.ok(nearest[0]);
|
|
119
|
+
};
|
|
120
|
+
return {
|
|
121
|
+
...baseFinder,
|
|
122
|
+
findAll: findAllNearest,
|
|
123
|
+
findUnique: findUniqueNearest
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
function buildVertexFinder(filters) {
|
|
127
|
+
return helpers.createTypedFinder(
|
|
128
|
+
"vertex",
|
|
129
|
+
filters,
|
|
130
|
+
buildVertexFinder,
|
|
131
|
+
(_base, withFilter) => ({
|
|
132
|
+
nearestTo: (point) => withNearestPostFilter(buildVertexFinder(filters), point),
|
|
133
|
+
atPosition: (point, tolerance = 1e-4) => withFilter((vertex2) => vecOps.vecDistance(shapeFns.vertexPosition(vertex2), point) < tolerance),
|
|
134
|
+
withinBox: (min, max) => withFilter((vertex2) => {
|
|
135
|
+
const pos = shapeFns.vertexPosition(vertex2);
|
|
136
|
+
return pos[0] >= min[0] - 1e-6 && pos[0] <= max[0] + 1e-6 && pos[1] >= min[1] - 1e-6 && pos[1] <= max[1] + 1e-6 && pos[2] >= min[2] - 1e-6 && pos[2] <= max[2] + 1e-6;
|
|
137
|
+
}),
|
|
138
|
+
atDistance: (distance, point = [0, 0, 0], tolerance = 1e-4) => withFilter((vertex2) => {
|
|
139
|
+
const pos = shapeFns.vertexPosition(vertex2);
|
|
140
|
+
return Math.abs(vecOps.vecDistance(pos, point) - distance) < tolerance;
|
|
141
|
+
})
|
|
142
|
+
})
|
|
143
|
+
);
|
|
144
|
+
}
|
|
145
|
+
function vertexFinder() {
|
|
146
|
+
return buildVertexFinder([]);
|
|
147
|
+
}
|
|
73
148
|
function checkInterference(shape1, shape2, tolerance = 1e-6) {
|
|
74
149
|
if (shape1.wrapped.IsNull()) {
|
|
75
150
|
return errors.err(
|
|
@@ -118,24 +193,19 @@ function resolve3D(s) {
|
|
|
118
193
|
}
|
|
119
194
|
function box(width, depth, height, options) {
|
|
120
195
|
const oc = occtBoundary.getKernel().oc;
|
|
121
|
-
const
|
|
196
|
+
const r = shapeTypes.gcWithScope();
|
|
122
197
|
const maker = r(new oc.BRepPrimAPI_MakeBox_2(width, depth, height));
|
|
123
|
-
|
|
124
|
-
gc();
|
|
198
|
+
const solid2 = shapeTypes.createSolid(maker.Solid());
|
|
125
199
|
const center = options?.at ?? (options?.centered ? [0, 0, 0] : void 0);
|
|
126
200
|
if (center) {
|
|
127
|
-
|
|
128
|
-
center[0] - width / 2,
|
|
129
|
-
center[1] - depth / 2,
|
|
130
|
-
center[2] - height / 2
|
|
131
|
-
]);
|
|
201
|
+
return shapeFns.translate(solid2, [center[0] - width / 2, center[1] - depth / 2, center[2] - height / 2]);
|
|
132
202
|
}
|
|
133
203
|
return solid2;
|
|
134
204
|
}
|
|
135
205
|
function cylinder(radius, height, options) {
|
|
136
206
|
const at = options?.at ?? [0, 0, 0];
|
|
137
207
|
const axis = options?.axis ?? [0, 0, 1];
|
|
138
|
-
let solid2 =
|
|
208
|
+
let solid2 = loft$2.makeCylinder(radius, height, at, axis);
|
|
139
209
|
if (options?.centered) {
|
|
140
210
|
const halfShift = [
|
|
141
211
|
-axis[0] * height * 0.5,
|
|
@@ -147,7 +217,7 @@ function cylinder(radius, height, options) {
|
|
|
147
217
|
return solid2;
|
|
148
218
|
}
|
|
149
219
|
function sphere(radius, options) {
|
|
150
|
-
let solid2 =
|
|
220
|
+
let solid2 = loft$2.makeSphere(radius);
|
|
151
221
|
if (options?.at) {
|
|
152
222
|
solid2 = shapeFns.translate(solid2, options.at);
|
|
153
223
|
}
|
|
@@ -156,7 +226,7 @@ function sphere(radius, options) {
|
|
|
156
226
|
function cone(bottomRadius, topRadius, height, options) {
|
|
157
227
|
const at = options?.at ?? [0, 0, 0];
|
|
158
228
|
const axis = options?.axis ?? [0, 0, 1];
|
|
159
|
-
let solid2 =
|
|
229
|
+
let solid2 = loft$2.makeCone(bottomRadius, topRadius, height, at, axis);
|
|
160
230
|
if (options?.centered) {
|
|
161
231
|
const halfShift = [
|
|
162
232
|
-axis[0] * height * 0.5,
|
|
@@ -168,28 +238,28 @@ function cone(bottomRadius, topRadius, height, options) {
|
|
|
168
238
|
return solid2;
|
|
169
239
|
}
|
|
170
240
|
function torus(majorRadius, minorRadius, options) {
|
|
171
|
-
return
|
|
241
|
+
return loft$2.makeTorus(majorRadius, minorRadius, options?.at ?? [0, 0, 0], options?.axis ?? [0, 0, 1]);
|
|
172
242
|
}
|
|
173
243
|
function ellipsoid(rx, ry, rz, options) {
|
|
174
|
-
let solid2 =
|
|
244
|
+
let solid2 = loft$2.makeEllipsoid(rx, ry, rz);
|
|
175
245
|
if (options?.at) {
|
|
176
246
|
solid2 = shapeFns.translate(solid2, options.at);
|
|
177
247
|
}
|
|
178
248
|
return solid2;
|
|
179
249
|
}
|
|
180
250
|
function line(from, to) {
|
|
181
|
-
return
|
|
251
|
+
return curveBuilders.makeLine(from, to);
|
|
182
252
|
}
|
|
183
253
|
function circle(radius, options) {
|
|
184
254
|
const axisDir = options?.axis ?? [0, 0, 1];
|
|
185
|
-
return
|
|
255
|
+
return curveBuilders.makeCircle(radius, options?.at ?? [0, 0, 0], axisDir);
|
|
186
256
|
}
|
|
187
257
|
function ellipse(majorRadius, minorRadius, options) {
|
|
188
258
|
const axisDir = options?.axis ?? [0, 0, 1];
|
|
189
|
-
return
|
|
259
|
+
return curveBuilders.makeEllipse(majorRadius, minorRadius, options?.at ?? [0, 0, 0], axisDir, options?.xDir);
|
|
190
260
|
}
|
|
191
261
|
function helix(pitch, height, radius, options) {
|
|
192
|
-
return
|
|
262
|
+
return curveBuilders.makeHelix(
|
|
193
263
|
pitch,
|
|
194
264
|
height,
|
|
195
265
|
radius,
|
|
@@ -199,11 +269,11 @@ function helix(pitch, height, radius, options) {
|
|
|
199
269
|
);
|
|
200
270
|
}
|
|
201
271
|
function threePointArc(p1, p2, p3) {
|
|
202
|
-
return
|
|
272
|
+
return curveBuilders.makeThreePointArc(p1, p2, p3);
|
|
203
273
|
}
|
|
204
274
|
function ellipseArc(majorRadius, minorRadius, startAngle, endAngle, options) {
|
|
205
275
|
const axisDir = options?.axis ?? [0, 0, 1];
|
|
206
|
-
return
|
|
276
|
+
return curveBuilders.makeEllipseArc(
|
|
207
277
|
majorRadius,
|
|
208
278
|
minorRadius,
|
|
209
279
|
startAngle * vecOps.DEG2RAD,
|
|
@@ -214,46 +284,46 @@ function ellipseArc(majorRadius, minorRadius, startAngle, endAngle, options) {
|
|
|
214
284
|
);
|
|
215
285
|
}
|
|
216
286
|
function bsplineApprox(points, config) {
|
|
217
|
-
return
|
|
287
|
+
return curveBuilders.makeBSplineApproximation(points, config);
|
|
218
288
|
}
|
|
219
289
|
function bezier(points) {
|
|
220
|
-
return
|
|
290
|
+
return curveBuilders.makeBezierCurve(points);
|
|
221
291
|
}
|
|
222
292
|
function tangentArc(startPoint, startTgt, endPoint) {
|
|
223
|
-
return
|
|
293
|
+
return curveBuilders.makeTangentArc(startPoint, startTgt, endPoint);
|
|
224
294
|
}
|
|
225
295
|
function wire(listOfEdges) {
|
|
226
|
-
return
|
|
296
|
+
return curveBuilders.assembleWire(listOfEdges);
|
|
227
297
|
}
|
|
228
298
|
function face(w, holes) {
|
|
229
|
-
return
|
|
299
|
+
return Blueprint.makeFace(w, holes);
|
|
230
300
|
}
|
|
231
301
|
function filledFace(w) {
|
|
232
|
-
return
|
|
302
|
+
return Blueprint.makeNonPlanarFace(w);
|
|
233
303
|
}
|
|
234
304
|
function subFace(originFace, w) {
|
|
235
|
-
return
|
|
305
|
+
return Blueprint.makeNewFaceWithinFace(originFace, w);
|
|
236
306
|
}
|
|
237
307
|
function polygon(points) {
|
|
238
|
-
return
|
|
308
|
+
return Blueprint.makePolygon(points);
|
|
239
309
|
}
|
|
240
310
|
function vertex(point) {
|
|
241
|
-
return
|
|
311
|
+
return loft$2.makeVertex(point);
|
|
242
312
|
}
|
|
243
313
|
function compound(shapeArray) {
|
|
244
|
-
return
|
|
314
|
+
return loft$2.makeCompound(shapeArray);
|
|
245
315
|
}
|
|
246
316
|
function solid(facesOrShells) {
|
|
247
|
-
return
|
|
317
|
+
return loft$2.makeSolid(facesOrShells);
|
|
248
318
|
}
|
|
249
319
|
function offsetFace(f, distance, tolerance) {
|
|
250
|
-
return
|
|
320
|
+
return loft$2.makeOffset(f, distance, tolerance);
|
|
251
321
|
}
|
|
252
322
|
function sewShells(facesOrShells, ignoreType) {
|
|
253
|
-
return
|
|
323
|
+
return loft$2.weldShellsAndFaces(facesOrShells, ignoreType);
|
|
254
324
|
}
|
|
255
325
|
function addHoles(f, holes) {
|
|
256
|
-
return
|
|
326
|
+
return Blueprint.addHolesInFace(f, holes);
|
|
257
327
|
}
|
|
258
328
|
function validateNotNull(shape2, label) {
|
|
259
329
|
if (shape2.wrapped.IsNull()) {
|
|
@@ -489,7 +559,7 @@ function resolveFaces(facesOrFn, shape2) {
|
|
|
489
559
|
if (typeof facesOrFn === "object" && "findAll" in facesOrFn) {
|
|
490
560
|
return facesOrFn.findAll(shape2);
|
|
491
561
|
}
|
|
492
|
-
const finder = facesOrFn(
|
|
562
|
+
const finder = facesOrFn(helpers.faceFinder());
|
|
493
563
|
return finder.findAll(shape2);
|
|
494
564
|
}
|
|
495
565
|
function normalizeFilletRadius(radius) {
|
|
@@ -654,7 +724,7 @@ function resolveTargetFace(shape2, faceSpec) {
|
|
|
654
724
|
return best;
|
|
655
725
|
}
|
|
656
726
|
if (typeof faceSpec === "function") {
|
|
657
|
-
const finder = faceSpec(
|
|
727
|
+
const finder = faceSpec(helpers.faceFinder());
|
|
658
728
|
const found = finder.findAll(shape2);
|
|
659
729
|
if (found.length === 0) {
|
|
660
730
|
throw new Error("compoundOps: face finder matched no faces");
|
|
@@ -689,7 +759,7 @@ function drill(shape2, options) {
|
|
|
689
759
|
const dz = b.zMax - b.zMin;
|
|
690
760
|
depth = Math.sqrt(dx * dx + dy * dy + dz * dz) + 1;
|
|
691
761
|
}
|
|
692
|
-
const cyl =
|
|
762
|
+
const cyl = loft$2.makeCylinder(radius, depth, pos, dir);
|
|
693
763
|
const startOffset = options.depth === void 0 ? vecOps.vecScale(dir, -depth / 2) : [0, 0, 0];
|
|
694
764
|
const tool = startOffset[0] !== 0 || startOffset[1] !== 0 || startOffset[2] !== 0 ? shapeFns.translate(cyl, startOffset) : cyl;
|
|
695
765
|
return booleanFns.cut(s, tool);
|
|
@@ -703,7 +773,7 @@ function pocket(shape2, options) {
|
|
|
703
773
|
const targetFace = resolveTargetFace(s, options.face);
|
|
704
774
|
const normal = faceFns.normalAt(targetFace);
|
|
705
775
|
const w = toWire(profile);
|
|
706
|
-
const faceResult =
|
|
776
|
+
const faceResult = Blueprint.makeFace(w);
|
|
707
777
|
if (errors.isErr(faceResult)) return faceResult;
|
|
708
778
|
const extDir = vecOps.vecScale(vecOps.vecNormalize(normal), -depth);
|
|
709
779
|
const toolResult = operations.extrude(faceResult.value, extDir);
|
|
@@ -719,7 +789,7 @@ function boss(shape2, options) {
|
|
|
719
789
|
const targetFace = resolveTargetFace(s, options.face);
|
|
720
790
|
const normal = faceFns.normalAt(targetFace);
|
|
721
791
|
const w = toWire(profile);
|
|
722
|
-
const faceResult =
|
|
792
|
+
const faceResult = Blueprint.makeFace(w);
|
|
723
793
|
if (errors.isErr(faceResult)) return faceResult;
|
|
724
794
|
const extDir = vecOps.vecScale(vecOps.vecNormalize(normal), height);
|
|
725
795
|
const toolResult = operations.extrude(faceResult.value, extDir);
|
|
@@ -834,6 +904,7 @@ function createWrapped3D(val) {
|
|
|
834
904
|
cut: (tool, opts) => wrap3D(unwrapOrThrow(cut(val, resolve(tool), opts))),
|
|
835
905
|
intersect: (tool, opts) => wrap3D(unwrapOrThrow(intersect(val, resolve(tool), opts))),
|
|
836
906
|
// Batch booleans
|
|
907
|
+
fuseAll: (tools, opts) => wrap3D(unwrapOrThrow(booleanFns.fuseAll([val, ...tools.map(resolve)], opts))),
|
|
837
908
|
cutAll: (tools, opts) => wrap3D(unwrapOrThrow(booleanFns.cutAll(val, tools, opts))),
|
|
838
909
|
// Boolean variants
|
|
839
910
|
section: (plane, opts) => wrapAny(unwrapOrThrow(section(val, plane, opts))),
|
|
@@ -1101,12 +1172,8 @@ exports.sketch2DOnPlane = _2d.sketch2DOnPlane;
|
|
|
1101
1172
|
exports.stretch2D = _2d.stretch2D;
|
|
1102
1173
|
exports.toSVGPathD = _2d.toSVGPathD;
|
|
1103
1174
|
exports.translate2D = _2d.translate2D;
|
|
1104
|
-
exports.
|
|
1105
|
-
exports.
|
|
1106
|
-
exports.faceFinder = query.faceFinder;
|
|
1107
|
-
exports.getSingleFace = query.getSingleFace;
|
|
1108
|
-
exports.vertexFinder = query.vertexFinder;
|
|
1109
|
-
exports.wireFinder = query.wireFinder;
|
|
1175
|
+
exports.faceFinder = helpers.faceFinder;
|
|
1176
|
+
exports.getSingleFace = helpers.getSingleFace;
|
|
1110
1177
|
exports.blueprintToDXF = io.blueprintToDXF;
|
|
1111
1178
|
exports.exportDXF = io.exportDXF;
|
|
1112
1179
|
exports.exportGlb = io.exportGlb;
|
|
@@ -1247,8 +1314,10 @@ exports.downcast = cast.downcast;
|
|
|
1247
1314
|
exports.isCompSolid = cast.isCompSolid;
|
|
1248
1315
|
exports.iterTopo = cast.iterTopo;
|
|
1249
1316
|
exports.shapeType = cast.shapeType;
|
|
1317
|
+
exports.edgeFinder = query.edgeFinder;
|
|
1250
1318
|
exports.BrepBugError = result.BrepBugError;
|
|
1251
1319
|
exports.bug = result.bug;
|
|
1320
|
+
exports.cornerFinder = cornerFinder.cornerFinder;
|
|
1252
1321
|
exports.createOperationRegistry = worker.createOperationRegistry;
|
|
1253
1322
|
exports.createTaskQueue = worker.createTaskQueue;
|
|
1254
1323
|
exports.createWorkerClient = worker.createWorkerClient;
|
|
@@ -1333,4 +1402,6 @@ exports.toBREP = toBREP;
|
|
|
1333
1402
|
exports.torus = torus;
|
|
1334
1403
|
exports.translate = translate;
|
|
1335
1404
|
exports.vertex = vertex;
|
|
1405
|
+
exports.vertexFinder = vertexFinder;
|
|
1336
1406
|
exports.wire = wire;
|
|
1407
|
+
exports.wireFinder = wireFinder;
|