brepjs 8.0.2 → 8.0.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.cjs +2 -2
- package/dist/2d.js +3 -3
- package/dist/{Blueprint-B9fhnpFp.js → Blueprint-2_aAKNQR.js} +8 -9
- package/dist/{Blueprint-VGbo3izk.cjs → Blueprint-DLrTLXzX.cjs} +9 -10
- package/dist/{boolean2D-B1XrGVgx.cjs → boolean2D-DeFQSg1m.cjs} +10 -10
- package/dist/{boolean2D-_WiqPxWZ.js → boolean2D-XbuOXTHG.js} +10 -10
- package/dist/{booleanFns-CkccZ7UL.js → booleanFns-DGMIgJl_.js} +5 -5
- package/dist/{booleanFns-BxW-N3rP.cjs → booleanFns-ND7sZvhu.cjs} +3 -3
- package/dist/brepjs.cjs +65 -69
- package/dist/brepjs.js +114 -119
- package/dist/{cast-C4Ff_1Qe.js → cast-BEg1mN7n.js} +2 -2
- package/dist/{cast-DIiyxDLo.cjs → cast-CqDc8oFW.cjs} +2 -2
- package/dist/core.cjs +3 -3
- package/dist/core.js +3 -3
- package/dist/{cornerFinder-DzGzfiqb.js → cornerFinder-D52Bk6bt.js} +1 -1
- package/dist/{cornerFinder-BndBNtJE.cjs → cornerFinder-DhbwiYQK.cjs} +1 -1
- package/dist/{curveBuilders-BUoFO1UG.cjs → curveBuilders-BjtdNw1B.cjs} +2 -2
- package/dist/{curveBuilders-CBlIWlbU.js → curveBuilders-U26XDfxg.js} +2 -2
- package/dist/curveFns-BoG_iA07.cjs +375 -0
- package/dist/curveFns-Cg99XKe2.js +376 -0
- package/dist/{drawFns-Btmlh_Oz.js → drawFns-CqfB685D.js} +12 -13
- package/dist/{drawFns-D2eDcf4k.cjs → drawFns-DJIg_iZh.cjs} +15 -16
- package/dist/{faceFns-DDzCECn3.js → faceFns-CyokaCDr.js} +3 -3
- package/dist/{faceFns-NDRFeekj.cjs → faceFns-DcSCjDG0.cjs} +3 -3
- package/dist/{helpers-jku2V1DY.js → helpers-BCWmNSKh.js} +14 -14
- package/dist/{helpers-Ck8GJ58k.cjs → helpers-DwmieP38.cjs} +17 -17
- package/dist/io.cjs +4 -4
- package/dist/io.js +4 -4
- package/dist/kernel/curveOps.d.ts.map +1 -1
- package/dist/kernel/meshOps.d.ts.map +1 -1
- package/dist/kernel/modifierOps.d.ts.map +1 -1
- package/dist/{loft-DJXwxV_L.cjs → loft-8asn63t4.cjs} +4 -4
- package/dist/{loft-Bk9EM0gZ.js → loft-jIkZRqHm.js} +4 -4
- package/dist/{measurement-DlXaTzKc.js → measurement-DWv8kK6J.js} +3 -3
- package/dist/{measurement-LcGh4wV0.cjs → measurement-lRLwaoqD.cjs} +3 -3
- package/dist/measurement.cjs +1 -1
- package/dist/measurement.js +1 -1
- package/dist/{meshFns-c8lDKfYy.cjs → meshFns-DWuLC3fk.cjs} +29 -9
- package/dist/{meshFns-Djzdn-CS.js → meshFns-DgAIL1B-.js} +29 -9
- package/dist/{occtBoundary-6kQSl3cF.cjs → occtBoundary-DHtzU4tz.cjs} +72 -61
- package/dist/{occtBoundary-CqXvDhZY.js → occtBoundary-DYsksDtE.js} +72 -61
- package/dist/operations/patternFns.d.ts.map +1 -1
- package/dist/{operations-CrQlFDHc.js → operations-BtwU1X9p.js} +32 -10
- package/dist/{operations-Do-WZGXc.cjs → operations-CCFPvtd-.cjs} +32 -10
- 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 +5 -5
- package/dist/query.js +6 -6
- package/dist/{shapeTypes-BJ3Hmskg.cjs → shapeTypes-b_lhwQB7.cjs} +1 -1
- package/dist/{shapeTypes-C9sUsmEW.js → shapeTypes-i7VwMRwc.js} +1 -1
- package/dist/sketching.cjs +2 -2
- package/dist/sketching.js +2 -2
- package/dist/topology/adjacencyFns.d.ts.map +1 -1
- package/dist/topology/compoundOpsFns.d.ts.map +1 -1
- package/dist/topology/meshFns.d.ts.map +1 -1
- package/dist/{topology-CtfUZwLR.js → topology-DXDdiKaF.js} +39 -18
- package/dist/{topology-DXq8dLsi.cjs → topology-uexRi0i6.cjs} +44 -23
- package/dist/topology.cjs +33 -34
- package/dist/topology.js +52 -53
- package/dist/{vectors-BVgXsYWl.js → vectors-DWLjb9-P.js} +1 -1
- package/dist/{vectors-DK2hEKcI.cjs → vectors-aQBZK0Sb.cjs} +1 -1
- package/dist/vectors.cjs +2 -2
- package/dist/vectors.js +2 -2
- package/package.json +1 -1
- package/dist/curveFns-BrJDkaWi.cjs +0 -177
- package/dist/curveFns-BshHA9Ys.js +0 -178
- package/dist/shapeFns-DQtpzndX.js +0 -203
- package/dist/shapeFns-cN4qGpbO.cjs +0 -202
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
const occtBoundary = require("./occtBoundary-
|
|
2
|
+
const occtBoundary = require("./occtBoundary-DHtzU4tz.cjs");
|
|
3
3
|
const vecOps = require("./vecOps-CjRL1jau.cjs");
|
|
4
|
-
const cast = require("./cast-
|
|
4
|
+
const cast = require("./cast-CqDc8oFW.cjs");
|
|
5
5
|
const errors = require("./errors-DK1VAdP4.cjs");
|
|
6
|
-
const shapeTypes = require("./shapeTypes-
|
|
7
|
-
const curveBuilders = require("./curveBuilders-
|
|
6
|
+
const shapeTypes = require("./shapeTypes-b_lhwQB7.cjs");
|
|
7
|
+
const curveBuilders = require("./curveBuilders-BjtdNw1B.cjs");
|
|
8
8
|
function buildLawFromProfile(extrusionLength, { profile, endFactor = 1 }) {
|
|
9
9
|
const oc = occtBoundary.getKernel().oc;
|
|
10
10
|
const r = shapeTypes.gcWithScope();
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { g as getKernel, b as toOcPnt, m as makeOcAx2, e as makeOcAx1, a as toVec3 } from "./occtBoundary-
|
|
1
|
+
import { g as getKernel, b as toOcPnt, m as makeOcAx2, e as makeOcAx1, a as toVec3 } from "./occtBoundary-DYsksDtE.js";
|
|
2
2
|
import { D as DEG2RAD, v as vecAdd, g as vecLength } from "./vecOps-ZDdZWbwT.js";
|
|
3
|
-
import { c as cast, d as downcast, a as isShape3D$1, b as isWire } from "./cast-
|
|
3
|
+
import { c as cast, d as downcast, a as isShape3D$1, b as isWire } from "./cast-BEg1mN7n.js";
|
|
4
4
|
import { e as err, x as validationError, l as ok, u as unwrap, p as typeCastError, a as andThen, o as occtError } from "./errors-wGhcJMpB.js";
|
|
5
|
-
import { p as gcWithScope, j as isShell, q as createCompound, r as createVertex, s as createSolid, h as isShape3D, k as isSolid, t as localGC } from "./shapeTypes-
|
|
6
|
-
import { m as makeLine, a as assembleWire, b as makeHelix } from "./curveBuilders-
|
|
5
|
+
import { p as gcWithScope, j as isShell, q as createCompound, r as createVertex, s as createSolid, h as isShape3D, k as isSolid, t as localGC } from "./shapeTypes-i7VwMRwc.js";
|
|
6
|
+
import { m as makeLine, a as assembleWire, b as makeHelix } from "./curveBuilders-U26XDfxg.js";
|
|
7
7
|
function buildLawFromProfile(extrusionLength, { profile, endFactor = 1 }) {
|
|
8
8
|
const oc = getKernel().oc;
|
|
9
9
|
const r = gcWithScope();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { g as getKernel, s as surfaceCurvature } from "./occtBoundary-
|
|
2
|
-
import { p as gcWithScope } from "./shapeTypes-
|
|
3
|
-
import { u as uvBounds } from "./faceFns-
|
|
1
|
+
import { g as getKernel, s as surfaceCurvature } from "./occtBoundary-DYsksDtE.js";
|
|
2
|
+
import { p as gcWithScope } from "./shapeTypes-i7VwMRwc.js";
|
|
3
|
+
import { u as uvBounds } from "./faceFns-CyokaCDr.js";
|
|
4
4
|
function assertShapeNotNull(shape, fn) {
|
|
5
5
|
if (shape.wrapped.IsNull()) {
|
|
6
6
|
throw new Error(`${fn}: shape is a null shape`);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
const occtBoundary = require("./occtBoundary-
|
|
3
|
-
const shapeTypes = require("./shapeTypes-
|
|
4
|
-
const faceFns = require("./faceFns-
|
|
2
|
+
const occtBoundary = require("./occtBoundary-DHtzU4tz.cjs");
|
|
3
|
+
const shapeTypes = require("./shapeTypes-b_lhwQB7.cjs");
|
|
4
|
+
const faceFns = require("./faceFns-DcSCjDG0.cjs");
|
|
5
5
|
function assertShapeNotNull(shape, fn) {
|
|
6
6
|
if (shape.wrapped.IsNull()) {
|
|
7
7
|
throw new Error(`${fn}: shape is a null shape`);
|
package/dist/measurement.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const measurement = require("./measurement-
|
|
3
|
+
const measurement = require("./measurement-lRLwaoqD.cjs");
|
|
4
4
|
exports.createDistanceQuery = measurement.createDistanceQuery;
|
|
5
5
|
exports.measureArea = measurement.measureArea;
|
|
6
6
|
exports.measureDistance = measurement.measureDistance;
|
package/dist/measurement.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
const occtBoundary = require("./occtBoundary-
|
|
2
|
+
const occtBoundary = require("./occtBoundary-DHtzU4tz.cjs");
|
|
3
3
|
const errors = require("./errors-DK1VAdP4.cjs");
|
|
4
4
|
function buildMeshCacheKey(tolerance, angularTolerance, skipNormals) {
|
|
5
5
|
return `${tolerance}:${angularTolerance}:${skipNormals}`;
|
|
@@ -71,6 +71,24 @@ function createMeshCache() {
|
|
|
71
71
|
}
|
|
72
72
|
};
|
|
73
73
|
}
|
|
74
|
+
function shapeHasTriangulation(oc, shape) {
|
|
75
|
+
const explorer = new oc.TopExp_Explorer_2(
|
|
76
|
+
shape,
|
|
77
|
+
oc.TopAbs_ShapeEnum.TopAbs_FACE,
|
|
78
|
+
oc.TopAbs_ShapeEnum.TopAbs_SHAPE
|
|
79
|
+
);
|
|
80
|
+
let hasTri = false;
|
|
81
|
+
if (explorer.More()) {
|
|
82
|
+
const face = oc.TopoDS.Face_1(explorer.Current());
|
|
83
|
+
const loc = new oc.TopLoc_Location_1();
|
|
84
|
+
const tri = oc.BRep_Tool.Triangulation(face, loc, 0);
|
|
85
|
+
hasTri = !tri.IsNull();
|
|
86
|
+
loc.delete();
|
|
87
|
+
tri.delete();
|
|
88
|
+
}
|
|
89
|
+
explorer.delete();
|
|
90
|
+
return hasTri;
|
|
91
|
+
}
|
|
74
92
|
function mesh(shape, {
|
|
75
93
|
tolerance = 1e-3,
|
|
76
94
|
angularTolerance = 0.1,
|
|
@@ -159,14 +177,16 @@ function exportSTL(shape, {
|
|
|
159
177
|
binary = false
|
|
160
178
|
} = {}) {
|
|
161
179
|
const oc = occtBoundary.getKernel().oc;
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
180
|
+
if (!shapeHasTriangulation(oc, shape.wrapped)) {
|
|
181
|
+
const mesher = new oc.BRepMesh_IncrementalMesh_2(
|
|
182
|
+
shape.wrapped,
|
|
183
|
+
tolerance,
|
|
184
|
+
false,
|
|
185
|
+
angularTolerance,
|
|
186
|
+
false
|
|
187
|
+
);
|
|
188
|
+
mesher.delete();
|
|
189
|
+
}
|
|
170
190
|
const filename = occtBoundary.uniqueIOFilename("_blob", "stl");
|
|
171
191
|
const done = oc.StlAPI.Write(shape.wrapped, filename, !binary);
|
|
172
192
|
if (done) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { g as getKernel, u as uniqueIOFilename } from "./occtBoundary-
|
|
1
|
+
import { g as getKernel, u as uniqueIOFilename } from "./occtBoundary-DYsksDtE.js";
|
|
2
2
|
import { l as ok, e as err, i as ioError } from "./errors-wGhcJMpB.js";
|
|
3
3
|
function buildMeshCacheKey(tolerance, angularTolerance, skipNormals) {
|
|
4
4
|
return `${tolerance}:${angularTolerance}:${skipNormals}`;
|
|
@@ -70,6 +70,24 @@ function createMeshCache() {
|
|
|
70
70
|
}
|
|
71
71
|
};
|
|
72
72
|
}
|
|
73
|
+
function shapeHasTriangulation(oc, shape) {
|
|
74
|
+
const explorer = new oc.TopExp_Explorer_2(
|
|
75
|
+
shape,
|
|
76
|
+
oc.TopAbs_ShapeEnum.TopAbs_FACE,
|
|
77
|
+
oc.TopAbs_ShapeEnum.TopAbs_SHAPE
|
|
78
|
+
);
|
|
79
|
+
let hasTri = false;
|
|
80
|
+
if (explorer.More()) {
|
|
81
|
+
const face = oc.TopoDS.Face_1(explorer.Current());
|
|
82
|
+
const loc = new oc.TopLoc_Location_1();
|
|
83
|
+
const tri = oc.BRep_Tool.Triangulation(face, loc, 0);
|
|
84
|
+
hasTri = !tri.IsNull();
|
|
85
|
+
loc.delete();
|
|
86
|
+
tri.delete();
|
|
87
|
+
}
|
|
88
|
+
explorer.delete();
|
|
89
|
+
return hasTri;
|
|
90
|
+
}
|
|
73
91
|
function mesh(shape, {
|
|
74
92
|
tolerance = 1e-3,
|
|
75
93
|
angularTolerance = 0.1,
|
|
@@ -158,14 +176,16 @@ function exportSTL(shape, {
|
|
|
158
176
|
binary = false
|
|
159
177
|
} = {}) {
|
|
160
178
|
const oc = getKernel().oc;
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
179
|
+
if (!shapeHasTriangulation(oc, shape.wrapped)) {
|
|
180
|
+
const mesher = new oc.BRepMesh_IncrementalMesh_2(
|
|
181
|
+
shape.wrapped,
|
|
182
|
+
tolerance,
|
|
183
|
+
false,
|
|
184
|
+
angularTolerance,
|
|
185
|
+
false
|
|
186
|
+
);
|
|
187
|
+
mesher.delete();
|
|
188
|
+
}
|
|
169
189
|
const filename = uniqueIOFilename("_blob", "stl");
|
|
170
190
|
const done = oc.StlAPI.Write(shape.wrapped, filename, !binary);
|
|
171
191
|
if (done) {
|
|
@@ -536,6 +536,24 @@ function cutAll(oc, shape, tools, options = {}) {
|
|
|
536
536
|
toolCompound.delete();
|
|
537
537
|
return result;
|
|
538
538
|
}
|
|
539
|
+
function hasTriangulation(oc, shape) {
|
|
540
|
+
const explorer = new oc.TopExp_Explorer_2(
|
|
541
|
+
shape,
|
|
542
|
+
oc.TopAbs_ShapeEnum.TopAbs_FACE,
|
|
543
|
+
oc.TopAbs_ShapeEnum.TopAbs_SHAPE
|
|
544
|
+
);
|
|
545
|
+
let hasTri = false;
|
|
546
|
+
if (explorer.More()) {
|
|
547
|
+
const face = oc.TopoDS.Face_1(explorer.Current());
|
|
548
|
+
const loc = new oc.TopLoc_Location_1();
|
|
549
|
+
const tri = oc.BRep_Tool.Triangulation(face, loc, 0);
|
|
550
|
+
hasTri = !tri.IsNull();
|
|
551
|
+
loc.delete();
|
|
552
|
+
tri.delete();
|
|
553
|
+
}
|
|
554
|
+
explorer.delete();
|
|
555
|
+
return hasTri;
|
|
556
|
+
}
|
|
539
557
|
function meshBulk(oc, shape, options) {
|
|
540
558
|
const raw = oc.MeshExtractor.extract(
|
|
541
559
|
shape,
|
|
@@ -722,14 +740,16 @@ function meshEdgesBulk(oc, shape, tolerance, angularTolerance) {
|
|
|
722
740
|
return { lines, edgeGroups };
|
|
723
741
|
}
|
|
724
742
|
function meshEdgesJS(oc, shape, tolerance, angularTolerance) {
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
743
|
+
if (!hasTriangulation(oc, shape)) {
|
|
744
|
+
const mesher = new oc.BRepMesh_IncrementalMesh_2(
|
|
745
|
+
shape,
|
|
746
|
+
tolerance,
|
|
747
|
+
false,
|
|
748
|
+
angularTolerance,
|
|
749
|
+
false
|
|
750
|
+
);
|
|
751
|
+
mesher.delete();
|
|
752
|
+
}
|
|
733
753
|
const lines = [];
|
|
734
754
|
const edgeGroups = [];
|
|
735
755
|
const seenHashes = /* @__PURE__ */ new Set();
|
|
@@ -1161,41 +1181,37 @@ function fillet(oc, shape, edges, radius) {
|
|
|
1161
1181
|
}
|
|
1162
1182
|
function chamfer(oc, shape, edges, distance2) {
|
|
1163
1183
|
const builder = new oc.BRepFilletAPI_MakeChamfer(shape);
|
|
1164
|
-
let
|
|
1165
|
-
function
|
|
1166
|
-
if (
|
|
1167
|
-
|
|
1168
|
-
const
|
|
1184
|
+
let edgeFaceMap = null;
|
|
1185
|
+
function getEdgeFaceMap() {
|
|
1186
|
+
if (edgeFaceMap) return edgeFaceMap;
|
|
1187
|
+
edgeFaceMap = /* @__PURE__ */ new Map();
|
|
1188
|
+
const faceExp = new oc.TopExp_Explorer_2(
|
|
1169
1189
|
shape,
|
|
1170
1190
|
oc.TopAbs_ShapeEnum.TopAbs_FACE,
|
|
1171
1191
|
oc.TopAbs_ShapeEnum.TopAbs_SHAPE
|
|
1172
1192
|
);
|
|
1173
|
-
while (
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
}
|
|
1177
|
-
explorer.delete();
|
|
1178
|
-
return faces;
|
|
1179
|
-
}
|
|
1180
|
-
function findContainingFace(edge) {
|
|
1181
|
-
for (const face of getFaces()) {
|
|
1182
|
-
const edgeExplorer = new oc.TopExp_Explorer_2(
|
|
1193
|
+
while (faceExp.More()) {
|
|
1194
|
+
const face = oc.TopoDS.Face_1(faceExp.Current());
|
|
1195
|
+
const edgeExp = new oc.TopExp_Explorer_2(
|
|
1183
1196
|
face,
|
|
1184
1197
|
oc.TopAbs_ShapeEnum.TopAbs_EDGE,
|
|
1185
1198
|
oc.TopAbs_ShapeEnum.TopAbs_SHAPE
|
|
1186
1199
|
);
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
if (
|
|
1190
|
-
|
|
1191
|
-
break;
|
|
1200
|
+
while (edgeExp.More()) {
|
|
1201
|
+
const hash = edgeExp.Current().HashCode(2147483647);
|
|
1202
|
+
if (!edgeFaceMap.has(hash)) {
|
|
1203
|
+
edgeFaceMap.set(hash, face);
|
|
1192
1204
|
}
|
|
1193
|
-
|
|
1205
|
+
edgeExp.Next();
|
|
1194
1206
|
}
|
|
1195
|
-
|
|
1196
|
-
|
|
1207
|
+
edgeExp.delete();
|
|
1208
|
+
faceExp.Next();
|
|
1197
1209
|
}
|
|
1198
|
-
|
|
1210
|
+
faceExp.delete();
|
|
1211
|
+
return edgeFaceMap;
|
|
1212
|
+
}
|
|
1213
|
+
function findContainingFace(edge) {
|
|
1214
|
+
return getEdgeFaceMap().get(edge.HashCode(2147483647)) ?? null;
|
|
1199
1215
|
}
|
|
1200
1216
|
for (const edge of edges) {
|
|
1201
1217
|
const d = typeof distance2 === "function" ? distance2(edge) : distance2;
|
|
@@ -1253,39 +1269,32 @@ function thicken(oc, shape, thickness) {
|
|
|
1253
1269
|
function chamferDistAngle(oc, shape, edges, distance2, angleDeg) {
|
|
1254
1270
|
const builder = new oc.BRepFilletAPI_MakeChamfer(shape);
|
|
1255
1271
|
const angleRad = angleDeg * Math.PI / 180;
|
|
1256
|
-
const
|
|
1272
|
+
const edgeFaceMap = /* @__PURE__ */ new Map();
|
|
1257
1273
|
const faceExplorer = new oc.TopExp_Explorer_2(
|
|
1258
1274
|
shape,
|
|
1259
1275
|
oc.TopAbs_ShapeEnum.TopAbs_FACE,
|
|
1260
1276
|
oc.TopAbs_ShapeEnum.TopAbs_SHAPE
|
|
1261
1277
|
);
|
|
1262
1278
|
while (faceExplorer.More()) {
|
|
1263
|
-
|
|
1279
|
+
const face = oc.TopoDS.Face_1(faceExplorer.Current());
|
|
1280
|
+
const edgeExp = new oc.TopExp_Explorer_2(
|
|
1281
|
+
face,
|
|
1282
|
+
oc.TopAbs_ShapeEnum.TopAbs_EDGE,
|
|
1283
|
+
oc.TopAbs_ShapeEnum.TopAbs_SHAPE
|
|
1284
|
+
);
|
|
1285
|
+
while (edgeExp.More()) {
|
|
1286
|
+
const hash = edgeExp.Current().HashCode(2147483647);
|
|
1287
|
+
if (!edgeFaceMap.has(hash)) {
|
|
1288
|
+
edgeFaceMap.set(hash, face);
|
|
1289
|
+
}
|
|
1290
|
+
edgeExp.Next();
|
|
1291
|
+
}
|
|
1292
|
+
edgeExp.delete();
|
|
1264
1293
|
faceExplorer.Next();
|
|
1265
1294
|
}
|
|
1266
1295
|
faceExplorer.delete();
|
|
1267
1296
|
for (const edge of edges) {
|
|
1268
|
-
|
|
1269
|
-
for (const face of faces) {
|
|
1270
|
-
const edgeExplorer = new oc.TopExp_Explorer_2(
|
|
1271
|
-
face,
|
|
1272
|
-
oc.TopAbs_ShapeEnum.TopAbs_EDGE,
|
|
1273
|
-
oc.TopAbs_ShapeEnum.TopAbs_SHAPE
|
|
1274
|
-
);
|
|
1275
|
-
let found = false;
|
|
1276
|
-
while (edgeExplorer.More()) {
|
|
1277
|
-
if (edgeExplorer.Current().IsSame(edge)) {
|
|
1278
|
-
found = true;
|
|
1279
|
-
break;
|
|
1280
|
-
}
|
|
1281
|
-
edgeExplorer.Next();
|
|
1282
|
-
}
|
|
1283
|
-
edgeExplorer.delete();
|
|
1284
|
-
if (found) {
|
|
1285
|
-
containingFace = face;
|
|
1286
|
-
break;
|
|
1287
|
-
}
|
|
1288
|
-
}
|
|
1297
|
+
const containingFace = edgeFaceMap.get(edge.HashCode(2147483647)) ?? null;
|
|
1289
1298
|
if (containingFace && distance2 > 0) {
|
|
1290
1299
|
builder.AddDA(distance2, angleRad, oc.TopoDS.Edge_1(edge), containingFace);
|
|
1291
1300
|
}
|
|
@@ -1324,12 +1333,13 @@ function offset(oc, shape, distance2, tolerance = 1e-6) {
|
|
|
1324
1333
|
function interpolatePoints(oc, points, options = {}) {
|
|
1325
1334
|
const { tolerance = 1e-8 } = options;
|
|
1326
1335
|
const pnts = new oc.TColgp_Array1OfPnt_2(1, points.length);
|
|
1336
|
+
const reusePnt = new oc.gp_Pnt_1();
|
|
1327
1337
|
let idx = 1;
|
|
1328
1338
|
for (const pt of points) {
|
|
1329
|
-
|
|
1330
|
-
pnts.SetValue(idx++,
|
|
1331
|
-
pnt.delete();
|
|
1339
|
+
reusePnt.SetCoord_2(pt[0], pt[1], pt[2]);
|
|
1340
|
+
pnts.SetValue(idx++, reusePnt);
|
|
1332
1341
|
}
|
|
1342
|
+
reusePnt.delete();
|
|
1333
1343
|
const splineBuilder = new oc.GeomAPI_PointsToBSpline_2(
|
|
1334
1344
|
pnts,
|
|
1335
1345
|
3,
|
|
@@ -1353,12 +1363,13 @@ function interpolatePoints(oc, points, options = {}) {
|
|
|
1353
1363
|
function approximatePoints(oc, points, options = {}) {
|
|
1354
1364
|
const { tolerance = 1e-3, degMin = 1, degMax = 6, smoothing = null } = options;
|
|
1355
1365
|
const pnts = new oc.TColgp_Array1OfPnt_2(1, points.length);
|
|
1366
|
+
const reusePnt = new oc.gp_Pnt_1();
|
|
1356
1367
|
let idx = 1;
|
|
1357
1368
|
for (const pt of points) {
|
|
1358
|
-
|
|
1359
|
-
pnts.SetValue(idx++,
|
|
1360
|
-
pnt.delete();
|
|
1369
|
+
reusePnt.SetCoord_2(pt[0], pt[1], pt[2]);
|
|
1370
|
+
pnts.SetValue(idx++, reusePnt);
|
|
1361
1371
|
}
|
|
1372
|
+
reusePnt.delete();
|
|
1362
1373
|
let splineBuilder;
|
|
1363
1374
|
if (smoothing) {
|
|
1364
1375
|
splineBuilder = new oc.GeomAPI_PointsToBSpline_5(
|
|
@@ -535,6 +535,24 @@ function cutAll(oc, shape, tools, options = {}) {
|
|
|
535
535
|
toolCompound.delete();
|
|
536
536
|
return result;
|
|
537
537
|
}
|
|
538
|
+
function hasTriangulation(oc, shape) {
|
|
539
|
+
const explorer = new oc.TopExp_Explorer_2(
|
|
540
|
+
shape,
|
|
541
|
+
oc.TopAbs_ShapeEnum.TopAbs_FACE,
|
|
542
|
+
oc.TopAbs_ShapeEnum.TopAbs_SHAPE
|
|
543
|
+
);
|
|
544
|
+
let hasTri = false;
|
|
545
|
+
if (explorer.More()) {
|
|
546
|
+
const face = oc.TopoDS.Face_1(explorer.Current());
|
|
547
|
+
const loc = new oc.TopLoc_Location_1();
|
|
548
|
+
const tri = oc.BRep_Tool.Triangulation(face, loc, 0);
|
|
549
|
+
hasTri = !tri.IsNull();
|
|
550
|
+
loc.delete();
|
|
551
|
+
tri.delete();
|
|
552
|
+
}
|
|
553
|
+
explorer.delete();
|
|
554
|
+
return hasTri;
|
|
555
|
+
}
|
|
538
556
|
function meshBulk(oc, shape, options) {
|
|
539
557
|
const raw = oc.MeshExtractor.extract(
|
|
540
558
|
shape,
|
|
@@ -721,14 +739,16 @@ function meshEdgesBulk(oc, shape, tolerance, angularTolerance) {
|
|
|
721
739
|
return { lines, edgeGroups };
|
|
722
740
|
}
|
|
723
741
|
function meshEdgesJS(oc, shape, tolerance, angularTolerance) {
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
742
|
+
if (!hasTriangulation(oc, shape)) {
|
|
743
|
+
const mesher = new oc.BRepMesh_IncrementalMesh_2(
|
|
744
|
+
shape,
|
|
745
|
+
tolerance,
|
|
746
|
+
false,
|
|
747
|
+
angularTolerance,
|
|
748
|
+
false
|
|
749
|
+
);
|
|
750
|
+
mesher.delete();
|
|
751
|
+
}
|
|
732
752
|
const lines = [];
|
|
733
753
|
const edgeGroups = [];
|
|
734
754
|
const seenHashes = /* @__PURE__ */ new Set();
|
|
@@ -1160,41 +1180,37 @@ function fillet(oc, shape, edges, radius) {
|
|
|
1160
1180
|
}
|
|
1161
1181
|
function chamfer(oc, shape, edges, distance2) {
|
|
1162
1182
|
const builder = new oc.BRepFilletAPI_MakeChamfer(shape);
|
|
1163
|
-
let
|
|
1164
|
-
function
|
|
1165
|
-
if (
|
|
1166
|
-
|
|
1167
|
-
const
|
|
1183
|
+
let edgeFaceMap = null;
|
|
1184
|
+
function getEdgeFaceMap() {
|
|
1185
|
+
if (edgeFaceMap) return edgeFaceMap;
|
|
1186
|
+
edgeFaceMap = /* @__PURE__ */ new Map();
|
|
1187
|
+
const faceExp = new oc.TopExp_Explorer_2(
|
|
1168
1188
|
shape,
|
|
1169
1189
|
oc.TopAbs_ShapeEnum.TopAbs_FACE,
|
|
1170
1190
|
oc.TopAbs_ShapeEnum.TopAbs_SHAPE
|
|
1171
1191
|
);
|
|
1172
|
-
while (
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
}
|
|
1176
|
-
explorer.delete();
|
|
1177
|
-
return faces;
|
|
1178
|
-
}
|
|
1179
|
-
function findContainingFace(edge) {
|
|
1180
|
-
for (const face of getFaces()) {
|
|
1181
|
-
const edgeExplorer = new oc.TopExp_Explorer_2(
|
|
1192
|
+
while (faceExp.More()) {
|
|
1193
|
+
const face = oc.TopoDS.Face_1(faceExp.Current());
|
|
1194
|
+
const edgeExp = new oc.TopExp_Explorer_2(
|
|
1182
1195
|
face,
|
|
1183
1196
|
oc.TopAbs_ShapeEnum.TopAbs_EDGE,
|
|
1184
1197
|
oc.TopAbs_ShapeEnum.TopAbs_SHAPE
|
|
1185
1198
|
);
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
if (
|
|
1189
|
-
|
|
1190
|
-
break;
|
|
1199
|
+
while (edgeExp.More()) {
|
|
1200
|
+
const hash = edgeExp.Current().HashCode(2147483647);
|
|
1201
|
+
if (!edgeFaceMap.has(hash)) {
|
|
1202
|
+
edgeFaceMap.set(hash, face);
|
|
1191
1203
|
}
|
|
1192
|
-
|
|
1204
|
+
edgeExp.Next();
|
|
1193
1205
|
}
|
|
1194
|
-
|
|
1195
|
-
|
|
1206
|
+
edgeExp.delete();
|
|
1207
|
+
faceExp.Next();
|
|
1196
1208
|
}
|
|
1197
|
-
|
|
1209
|
+
faceExp.delete();
|
|
1210
|
+
return edgeFaceMap;
|
|
1211
|
+
}
|
|
1212
|
+
function findContainingFace(edge) {
|
|
1213
|
+
return getEdgeFaceMap().get(edge.HashCode(2147483647)) ?? null;
|
|
1198
1214
|
}
|
|
1199
1215
|
for (const edge of edges) {
|
|
1200
1216
|
const d = typeof distance2 === "function" ? distance2(edge) : distance2;
|
|
@@ -1252,39 +1268,32 @@ function thicken(oc, shape, thickness) {
|
|
|
1252
1268
|
function chamferDistAngle(oc, shape, edges, distance2, angleDeg) {
|
|
1253
1269
|
const builder = new oc.BRepFilletAPI_MakeChamfer(shape);
|
|
1254
1270
|
const angleRad = angleDeg * Math.PI / 180;
|
|
1255
|
-
const
|
|
1271
|
+
const edgeFaceMap = /* @__PURE__ */ new Map();
|
|
1256
1272
|
const faceExplorer = new oc.TopExp_Explorer_2(
|
|
1257
1273
|
shape,
|
|
1258
1274
|
oc.TopAbs_ShapeEnum.TopAbs_FACE,
|
|
1259
1275
|
oc.TopAbs_ShapeEnum.TopAbs_SHAPE
|
|
1260
1276
|
);
|
|
1261
1277
|
while (faceExplorer.More()) {
|
|
1262
|
-
|
|
1278
|
+
const face = oc.TopoDS.Face_1(faceExplorer.Current());
|
|
1279
|
+
const edgeExp = new oc.TopExp_Explorer_2(
|
|
1280
|
+
face,
|
|
1281
|
+
oc.TopAbs_ShapeEnum.TopAbs_EDGE,
|
|
1282
|
+
oc.TopAbs_ShapeEnum.TopAbs_SHAPE
|
|
1283
|
+
);
|
|
1284
|
+
while (edgeExp.More()) {
|
|
1285
|
+
const hash = edgeExp.Current().HashCode(2147483647);
|
|
1286
|
+
if (!edgeFaceMap.has(hash)) {
|
|
1287
|
+
edgeFaceMap.set(hash, face);
|
|
1288
|
+
}
|
|
1289
|
+
edgeExp.Next();
|
|
1290
|
+
}
|
|
1291
|
+
edgeExp.delete();
|
|
1263
1292
|
faceExplorer.Next();
|
|
1264
1293
|
}
|
|
1265
1294
|
faceExplorer.delete();
|
|
1266
1295
|
for (const edge of edges) {
|
|
1267
|
-
|
|
1268
|
-
for (const face of faces) {
|
|
1269
|
-
const edgeExplorer = new oc.TopExp_Explorer_2(
|
|
1270
|
-
face,
|
|
1271
|
-
oc.TopAbs_ShapeEnum.TopAbs_EDGE,
|
|
1272
|
-
oc.TopAbs_ShapeEnum.TopAbs_SHAPE
|
|
1273
|
-
);
|
|
1274
|
-
let found = false;
|
|
1275
|
-
while (edgeExplorer.More()) {
|
|
1276
|
-
if (edgeExplorer.Current().IsSame(edge)) {
|
|
1277
|
-
found = true;
|
|
1278
|
-
break;
|
|
1279
|
-
}
|
|
1280
|
-
edgeExplorer.Next();
|
|
1281
|
-
}
|
|
1282
|
-
edgeExplorer.delete();
|
|
1283
|
-
if (found) {
|
|
1284
|
-
containingFace = face;
|
|
1285
|
-
break;
|
|
1286
|
-
}
|
|
1287
|
-
}
|
|
1296
|
+
const containingFace = edgeFaceMap.get(edge.HashCode(2147483647)) ?? null;
|
|
1288
1297
|
if (containingFace && distance2 > 0) {
|
|
1289
1298
|
builder.AddDA(distance2, angleRad, oc.TopoDS.Edge_1(edge), containingFace);
|
|
1290
1299
|
}
|
|
@@ -1323,12 +1332,13 @@ function offset(oc, shape, distance2, tolerance = 1e-6) {
|
|
|
1323
1332
|
function interpolatePoints(oc, points, options = {}) {
|
|
1324
1333
|
const { tolerance = 1e-8 } = options;
|
|
1325
1334
|
const pnts = new oc.TColgp_Array1OfPnt_2(1, points.length);
|
|
1335
|
+
const reusePnt = new oc.gp_Pnt_1();
|
|
1326
1336
|
let idx = 1;
|
|
1327
1337
|
for (const pt of points) {
|
|
1328
|
-
|
|
1329
|
-
pnts.SetValue(idx++,
|
|
1330
|
-
pnt.delete();
|
|
1338
|
+
reusePnt.SetCoord_2(pt[0], pt[1], pt[2]);
|
|
1339
|
+
pnts.SetValue(idx++, reusePnt);
|
|
1331
1340
|
}
|
|
1341
|
+
reusePnt.delete();
|
|
1332
1342
|
const splineBuilder = new oc.GeomAPI_PointsToBSpline_2(
|
|
1333
1343
|
pnts,
|
|
1334
1344
|
3,
|
|
@@ -1352,12 +1362,13 @@ function interpolatePoints(oc, points, options = {}) {
|
|
|
1352
1362
|
function approximatePoints(oc, points, options = {}) {
|
|
1353
1363
|
const { tolerance = 1e-3, degMin = 1, degMax = 6, smoothing = null } = options;
|
|
1354
1364
|
const pnts = new oc.TColgp_Array1OfPnt_2(1, points.length);
|
|
1365
|
+
const reusePnt = new oc.gp_Pnt_1();
|
|
1355
1366
|
let idx = 1;
|
|
1356
1367
|
for (const pt of points) {
|
|
1357
|
-
|
|
1358
|
-
pnts.SetValue(idx++,
|
|
1359
|
-
pnt.delete();
|
|
1368
|
+
reusePnt.SetCoord_2(pt[0], pt[1], pt[2]);
|
|
1369
|
+
pnts.SetValue(idx++, reusePnt);
|
|
1360
1370
|
}
|
|
1371
|
+
reusePnt.delete();
|
|
1361
1372
|
let splineBuilder;
|
|
1362
1373
|
if (smoothing) {
|
|
1363
1374
|
splineBuilder = new oc.GeomAPI_PointsToBSpline_5(
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"patternFns.d.ts","sourceRoot":"","sources":["../../src/operations/patternFns.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"patternFns.d.ts","sourceRoot":"","sources":["../../src/operations/patternFns.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAGhD,OAAO,EAAW,KAAK,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAKzE;;;;;;;;;GASG;AACH,wBAAgB,aAAa,CAC3B,KAAK,EAAE,OAAO,EACd,SAAS,EAAE,IAAI,EACf,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,cAAc,GACvB,MAAM,CAAC,OAAO,CAAC,CA2BjB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,eAAe,CAC7B,KAAK,EAAE,OAAO,EACd,IAAI,EAAE,IAAI,EACV,KAAK,EAAE,MAAM,EACb,SAAS,GAAE,MAAY,EACvB,MAAM,GAAE,IAAgB,EACxB,OAAO,CAAC,EAAE,cAAc,GACvB,MAAM,CAAC,OAAO,CAAC,CA6BjB"}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import { g as getKernel, c as toOcVec, b as toOcPnt, d as makeOcAx3, u as uniqueIOFilename } from "./occtBoundary-
|
|
1
|
+
import { g as getKernel, c as toOcVec, b as toOcPnt, d as makeOcAx3, u as uniqueIOFilename } from "./occtBoundary-DYsksDtE.js";
|
|
2
2
|
import { g as vecLength, v as vecAdd, D as DEG2RAD, f as vecIsZero, j as vecNormalize, n as vecScale } from "./vecOps-ZDdZWbwT.js";
|
|
3
|
-
import { b as createOcHandle, c as castShape, h as isShape3D, m as isWire, p as gcWithScope, s as createSolid } from "./shapeTypes-
|
|
4
|
-
import { d as downcast } from "./cast-
|
|
3
|
+
import { b as createOcHandle, c as castShape, h as isShape3D, m as isWire, p as gcWithScope, s as createSolid } from "./shapeTypes-i7VwMRwc.js";
|
|
4
|
+
import { d as downcast } from "./cast-BEg1mN7n.js";
|
|
5
5
|
import { e as err, x as validationError, u as unwrap, p as typeCastError, l as ok, B as BrepErrorCode, d as isErr, o as occtError, i as ioError, b as computationError } from "./errors-wGhcJMpB.js";
|
|
6
|
-
import { n as buildLawFromProfile } from "./loft-
|
|
7
|
-
import {
|
|
8
|
-
import { e as fuseAll } from "./booleanFns-CkccZ7UL.js";
|
|
6
|
+
import { n as buildLawFromProfile } from "./loft-jIkZRqHm.js";
|
|
7
|
+
import { d as fuseAll } from "./booleanFns-DGMIgJl_.js";
|
|
9
8
|
function uuidv() {
|
|
10
9
|
return (String([1e7]) + String(-1e3) + String(-4e3) + String(-8e3) + String(-1e11)).replace(
|
|
11
10
|
/[018]/g,
|
|
@@ -310,10 +309,20 @@ function linearPattern(shape, direction, count, spacing, options) {
|
|
|
310
309
|
return err(validationError("PATTERN_ZERO_DIRECTION", "Pattern direction cannot be zero"));
|
|
311
310
|
const dir = vecNormalize(direction);
|
|
312
311
|
const copies = [shape];
|
|
312
|
+
const oc = getKernel().oc;
|
|
313
|
+
const trsf = new oc.gp_Trsf_1();
|
|
314
|
+
const vec = new oc.gp_Vec_4(0, 0, 0);
|
|
313
315
|
for (let i = 1; i < count; i++) {
|
|
314
316
|
const offset = vecScale(dir, spacing * i);
|
|
315
|
-
|
|
316
|
-
|
|
317
|
+
vec.SetCoord_2(offset[0], offset[1], offset[2]);
|
|
318
|
+
trsf.SetTranslation_1(vec);
|
|
319
|
+
const transformer = new oc.BRepBuilderAPI_Transform_2(shape.wrapped, trsf, true);
|
|
320
|
+
const result = transformer.ModifiedShape(shape.wrapped);
|
|
321
|
+
transformer.delete();
|
|
322
|
+
copies.push(castShape(result));
|
|
323
|
+
}
|
|
324
|
+
trsf.delete();
|
|
325
|
+
vec.delete();
|
|
317
326
|
return fuseAll(copies, options);
|
|
318
327
|
}
|
|
319
328
|
function circularPattern(shape, axis, count, fullAngle = 360, center = [0, 0, 0], options) {
|
|
@@ -324,9 +333,22 @@ function circularPattern(shape, axis, count, fullAngle = 360, center = [0, 0, 0]
|
|
|
324
333
|
return err(validationError("PATTERN_ZERO_AXIS", "Pattern axis cannot be zero"));
|
|
325
334
|
const angleStep = fullAngle / count;
|
|
326
335
|
const copies = [shape];
|
|
336
|
+
const oc = getKernel().oc;
|
|
337
|
+
const trsf = new oc.gp_Trsf_1();
|
|
338
|
+
const origin = new oc.gp_Pnt_3(center[0], center[1], center[2]);
|
|
339
|
+
const dir = new oc.gp_Dir_4(axis[0], axis[1], axis[2]);
|
|
340
|
+
const ax1 = new oc.gp_Ax1_2(origin, dir);
|
|
327
341
|
for (let i = 1; i < count; i++) {
|
|
328
|
-
|
|
329
|
-
|
|
342
|
+
trsf.SetRotation_1(ax1, angleStep * i * Math.PI / 180);
|
|
343
|
+
const transformer = new oc.BRepBuilderAPI_Transform_2(shape.wrapped, trsf, true);
|
|
344
|
+
const result = transformer.ModifiedShape(shape.wrapped);
|
|
345
|
+
transformer.delete();
|
|
346
|
+
copies.push(castShape(result));
|
|
347
|
+
}
|
|
348
|
+
trsf.delete();
|
|
349
|
+
ax1.delete();
|
|
350
|
+
origin.delete();
|
|
351
|
+
dir.delete();
|
|
330
352
|
return fuseAll(copies, options);
|
|
331
353
|
}
|
|
332
354
|
function createAssemblyNode(name, options = {}) {
|