brepjs 8.2.0 → 8.3.0
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-D_luVeES.js → Blueprint-CdVaHDSx.js} +3 -2
- package/dist/{Blueprint-CTAwjJMN.cjs → Blueprint-a3ukJMG4.cjs} +4 -3
- package/dist/{boolean2D-vw76Gayn.js → boolean2D-DzA0STqC.js} +3 -3
- package/dist/{boolean2D-B5axNhjN.cjs → boolean2D-pvPIs21j.cjs} +3 -3
- package/dist/{booleanFns-BhqXpQoZ.js → booleanFns-BcQUqjUu.js} +42 -5
- package/dist/{booleanFns-Yc3EBxdm.cjs → booleanFns-Cd414V3l.cjs} +42 -5
- package/dist/brepjs.cjs +189 -100
- package/dist/brepjs.js +255 -165
- package/dist/{cornerFinder-DuStF5jK.cjs → cornerFinder-BdKtobgb.cjs} +1 -1
- package/dist/{cornerFinder-CPm2baSJ.js → cornerFinder-DvPiz-VR.js} +1 -1
- package/dist/curveFns-B5EQsSwv.cjs +177 -0
- package/dist/curveFns-CyHyk29c.js +178 -0
- package/dist/{drawFns-CzBbcoXA.js → drawFns-CAAE4Z88.js} +6 -5
- package/dist/{drawFns-CiNxPu6J.cjs → drawFns-Mr2pghU8.cjs} +9 -8
- package/dist/{helpers-Dje6wrKi.cjs → helpers-CP2KrBZl.cjs} +4 -4
- package/dist/{helpers-BSQfs538.js → helpers-r_e-u1JM.js} +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/io.cjs +2 -2
- package/dist/io.js +2 -2
- package/dist/{meshFns-BKSPaPXS.js → meshFns-BEvGVcym.js} +4 -1
- package/dist/{meshFns-CFVxKBlE.cjs → meshFns-CJV_k_EQ.cjs} +4 -1
- package/dist/{operations-CjQHEu1h.js → operations-B314mytX.js} +1 -1
- package/dist/{operations-CdGb6IBU.cjs → operations-CYGNxn5D.cjs} +1 -1
- package/dist/operations.cjs +1 -1
- package/dist/operations.js +1 -1
- package/dist/query.cjs +3 -3
- package/dist/query.js +4 -4
- package/dist/{curveFns-C5gSZ5EY.js → shapeFns-CWd_ASDV.js} +115 -194
- package/dist/{curveFns-ByeCqutv.cjs → shapeFns-Z_ScEjmn.cjs} +94 -173
- package/dist/sketching.cjs +2 -2
- package/dist/sketching.js +2 -2
- package/dist/topology/booleanFns.d.ts.map +1 -1
- package/dist/topology/meshFns.d.ts +1 -0
- package/dist/topology/meshFns.d.ts.map +1 -1
- package/dist/topology/modifierFns.d.ts.map +1 -1
- package/dist/topology/shapeFns.d.ts +30 -0
- package/dist/topology/shapeFns.d.ts.map +1 -1
- package/dist/{topology-D8Au8q4i.cjs → topology-A7-jUtHB.cjs} +9 -8
- package/dist/{topology-BFB3LI_y.js → topology-BupialMm.js} +4 -3
- package/dist/topology.cjs +32 -31
- package/dist/topology.js +57 -56
- package/package.json +1 -1
package/dist/query.cjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const helpers = require("./helpers-
|
|
4
|
-
const cornerFinder = require("./cornerFinder-
|
|
3
|
+
const helpers = require("./helpers-CP2KrBZl.cjs");
|
|
4
|
+
const cornerFinder = require("./cornerFinder-BdKtobgb.cjs");
|
|
5
5
|
const occtBoundary = require("./occtBoundary-BFAaUtA7.cjs");
|
|
6
6
|
const shapeTypes = require("./shapeTypes-UqVCIO_T.cjs");
|
|
7
7
|
const vecOps = require("./vecOps-CjRL1jau.cjs");
|
|
8
|
-
const curveFns = require("./curveFns-
|
|
8
|
+
const curveFns = require("./curveFns-B5EQsSwv.cjs");
|
|
9
9
|
function edgeDirectionFilter(dir, angle) {
|
|
10
10
|
const d = vecOps.vecNormalize(helpers.resolveDir(dir));
|
|
11
11
|
return (edge) => {
|
package/dist/query.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { c as createTypedFinder, o as distanceFromPointFilter, q as resolveDir } from "./helpers-
|
|
2
|
-
import { f, g } from "./helpers-
|
|
3
|
-
import { c } from "./cornerFinder-
|
|
1
|
+
import { c as createTypedFinder, o as distanceFromPointFilter, q as resolveDir } from "./helpers-r_e-u1JM.js";
|
|
2
|
+
import { f, g } from "./helpers-r_e-u1JM.js";
|
|
3
|
+
import { c } from "./cornerFinder-DvPiz-VR.js";
|
|
4
4
|
import { g as getKernel } from "./occtBoundary-CoXB2xvx.js";
|
|
5
5
|
import { p as gcWithScope } from "./shapeTypes-BU2LKv2S.js";
|
|
6
6
|
import { j as vecNormalize, d as vecDot, D as DEG2RAD } from "./vecOps-ZDdZWbwT.js";
|
|
7
|
-
import {
|
|
7
|
+
import { l as getCurveType, f as curveLength } from "./curveFns-CyHyk29c.js";
|
|
8
8
|
function edgeDirectionFilter(dir, angle) {
|
|
9
9
|
const d = vecNormalize(resolveDir(dir));
|
|
10
10
|
return (edge) => {
|
|
@@ -1,32 +1,8 @@
|
|
|
1
1
|
import { g as getKernel, c as toOcVec, e as makeOcAx1, m as makeOcAx2, b as toOcPnt } from "./occtBoundary-CoXB2xvx.js";
|
|
2
|
-
import { c as castShape, g as getShapeKind, p as gcWithScope
|
|
2
|
+
import { c as castShape, g as getShapeKind, p as gcWithScope } from "./shapeTypes-BU2LKv2S.js";
|
|
3
3
|
import { D as DEG2RAD, H as HASH_CODE_MAX } from "./vecOps-ZDdZWbwT.js";
|
|
4
4
|
import { i as iterTopo, d as downcast } from "./cast-D0OhP1nV.js";
|
|
5
|
-
import {
|
|
6
|
-
let CURVE_TYPES_MAP = null;
|
|
7
|
-
const getCurveTypesMap = (refresh) => {
|
|
8
|
-
if (CURVE_TYPES_MAP && !refresh) return CURVE_TYPES_MAP;
|
|
9
|
-
const oc = getKernel().oc;
|
|
10
|
-
const ga = oc.GeomAbs_CurveType;
|
|
11
|
-
CURVE_TYPES_MAP = /* @__PURE__ */ new Map([
|
|
12
|
-
[ga.GeomAbs_Line, "LINE"],
|
|
13
|
-
[ga.GeomAbs_Circle, "CIRCLE"],
|
|
14
|
-
[ga.GeomAbs_Ellipse, "ELLIPSE"],
|
|
15
|
-
[ga.GeomAbs_Hyperbola, "HYPERBOLA"],
|
|
16
|
-
[ga.GeomAbs_Parabola, "PARABOLA"],
|
|
17
|
-
[ga.GeomAbs_BezierCurve, "BEZIER_CURVE"],
|
|
18
|
-
[ga.GeomAbs_BSplineCurve, "BSPLINE_CURVE"],
|
|
19
|
-
[ga.GeomAbs_OffsetCurve, "OFFSET_CURVE"],
|
|
20
|
-
[ga.GeomAbs_OtherCurve, "OTHER_CURVE"]
|
|
21
|
-
]);
|
|
22
|
-
return CURVE_TYPES_MAP;
|
|
23
|
-
};
|
|
24
|
-
const findCurveType = (type) => {
|
|
25
|
-
let shapeType = getCurveTypesMap().get(type);
|
|
26
|
-
if (!shapeType) shapeType = getCurveTypesMap(true).get(type);
|
|
27
|
-
if (!shapeType) return err(typeCastError("UNKNOWN_CURVE_TYPE", "Unknown curve type"));
|
|
28
|
-
return ok(shapeType);
|
|
29
|
-
};
|
|
5
|
+
import { u as unwrap } from "./errors-wGhcJMpB.js";
|
|
30
6
|
function clone(shape) {
|
|
31
7
|
return castShape(unwrap(downcast(shape.wrapped)));
|
|
32
8
|
}
|
|
@@ -60,6 +36,7 @@ function translate(shape, v) {
|
|
|
60
36
|
trsf.SetTranslation_1(vec);
|
|
61
37
|
const transformer = new oc.BRepBuilderAPI_Transform_2(shape.wrapped, trsf, true);
|
|
62
38
|
const result = castShape(transformer.Shape());
|
|
39
|
+
propagateOrigins(transformer, [shape], result);
|
|
63
40
|
transformer.delete();
|
|
64
41
|
trsf.delete();
|
|
65
42
|
vec.delete();
|
|
@@ -72,6 +49,7 @@ function rotate(shape, angle, position = [0, 0, 0], direction = [0, 0, 1]) {
|
|
|
72
49
|
trsf.SetRotation_1(ax1, angle * DEG2RAD);
|
|
73
50
|
const transformer = new oc.BRepBuilderAPI_Transform_2(shape.wrapped, trsf, true);
|
|
74
51
|
const result = castShape(transformer.Shape());
|
|
52
|
+
propagateOrigins(transformer, [shape], result);
|
|
75
53
|
transformer.delete();
|
|
76
54
|
trsf.delete();
|
|
77
55
|
ax1.delete();
|
|
@@ -84,6 +62,7 @@ function mirror(shape, planeNormal = [0, 1, 0], planeOrigin = [0, 0, 0]) {
|
|
|
84
62
|
trsf.SetMirror_3(ax2);
|
|
85
63
|
const transformer = new oc.BRepBuilderAPI_Transform_2(shape.wrapped, trsf, true);
|
|
86
64
|
const result = castShape(transformer.Shape());
|
|
65
|
+
propagateOrigins(transformer, [shape], result);
|
|
87
66
|
transformer.delete();
|
|
88
67
|
trsf.delete();
|
|
89
68
|
ax2.delete();
|
|
@@ -96,6 +75,7 @@ function scale(shape, factor, center = [0, 0, 0]) {
|
|
|
96
75
|
trsf.SetScale(pnt, factor);
|
|
97
76
|
const transformer = new oc.BRepBuilderAPI_Transform_2(shape.wrapped, trsf, true);
|
|
98
77
|
const result = castShape(transformer.Shape());
|
|
78
|
+
propagateOrigins(transformer, [shape], result);
|
|
99
79
|
transformer.delete();
|
|
100
80
|
trsf.delete();
|
|
101
81
|
pnt.delete();
|
|
@@ -163,6 +143,7 @@ function applyMatrix(shape, matrix) {
|
|
|
163
143
|
);
|
|
164
144
|
const transformer2 = new oc.BRepBuilderAPI_Transform_2(shape.wrapped, trsf, true);
|
|
165
145
|
const result2 = castShape(transformer2.Shape());
|
|
146
|
+
propagateOrigins(transformer2, [shape], result2);
|
|
166
147
|
transformer2.delete();
|
|
167
148
|
trsf.delete();
|
|
168
149
|
return result2;
|
|
@@ -178,6 +159,7 @@ function applyMatrix(shape, matrix) {
|
|
|
178
159
|
xyz.delete();
|
|
179
160
|
const transformer = new oc.BRepBuilderAPI_GTransform_2(shape.wrapped, gtrsf, true);
|
|
180
161
|
const result = castShape(transformer.Shape());
|
|
162
|
+
propagateOrigins(transformer, [shape], result);
|
|
181
163
|
transformer.delete();
|
|
182
164
|
gtrsf.delete();
|
|
183
165
|
return result;
|
|
@@ -205,6 +187,7 @@ function transformCopy(shape, composed) {
|
|
|
205
187
|
const oc = getKernel().oc;
|
|
206
188
|
const transformer = new oc.BRepBuilderAPI_Transform_2(shape.wrapped, composed.trsf, true);
|
|
207
189
|
const result = castShape(transformer.Shape());
|
|
190
|
+
propagateOrigins(transformer, [shape], result);
|
|
208
191
|
transformer.delete();
|
|
209
192
|
return result;
|
|
210
193
|
}
|
|
@@ -244,6 +227,89 @@ function getWires(shape) {
|
|
|
244
227
|
cache.wires = wires;
|
|
245
228
|
return wires;
|
|
246
229
|
}
|
|
230
|
+
function setShapeOrigin(shape, origin) {
|
|
231
|
+
const cache = getOrCreateCache(shape);
|
|
232
|
+
const map = /* @__PURE__ */ new Map();
|
|
233
|
+
for (const f of getFaces(shape)) {
|
|
234
|
+
map.set(f.wrapped.HashCode(HASH_CODE_MAX), origin);
|
|
235
|
+
}
|
|
236
|
+
cache.faceOrigins = map;
|
|
237
|
+
}
|
|
238
|
+
function getFaceOrigins(shape) {
|
|
239
|
+
return topoCache.get(shape.wrapped)?.faceOrigins;
|
|
240
|
+
}
|
|
241
|
+
function iterOcList(list, callback) {
|
|
242
|
+
const oc = getKernel().oc;
|
|
243
|
+
const copy = new oc.TopTools_ListOfShape_3(list);
|
|
244
|
+
while (copy.Size() > 0) {
|
|
245
|
+
callback(copy.First_1());
|
|
246
|
+
copy.RemoveFirst();
|
|
247
|
+
}
|
|
248
|
+
copy.delete();
|
|
249
|
+
}
|
|
250
|
+
function propagateOrigins(op, inputs, result) {
|
|
251
|
+
const inputOrigins = [];
|
|
252
|
+
for (const input of inputs) {
|
|
253
|
+
const origins = getFaceOrigins(input);
|
|
254
|
+
if (!origins) continue;
|
|
255
|
+
for (const f of getFaces(input)) {
|
|
256
|
+
const hash = f.wrapped.HashCode(HASH_CODE_MAX);
|
|
257
|
+
const origin = origins.get(hash);
|
|
258
|
+
if (origin !== void 0) {
|
|
259
|
+
inputOrigins.push({ face: f.wrapped, origin });
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
if (inputOrigins.length === 0) return;
|
|
264
|
+
const resultMap = /* @__PURE__ */ new Map();
|
|
265
|
+
for (const { face, origin } of inputOrigins) {
|
|
266
|
+
if (op.IsDeleted?.(face)) continue;
|
|
267
|
+
const modifiedList = op.Modified(face);
|
|
268
|
+
if (modifiedList.Size() > 0) {
|
|
269
|
+
iterOcList(modifiedList, (modFace) => {
|
|
270
|
+
resultMap.set(modFace.HashCode(HASH_CODE_MAX), origin);
|
|
271
|
+
});
|
|
272
|
+
} else {
|
|
273
|
+
resultMap.set(face.HashCode(HASH_CODE_MAX), origin);
|
|
274
|
+
}
|
|
275
|
+
const generatedList = op.Generated(face);
|
|
276
|
+
if (generatedList.Size() > 0) {
|
|
277
|
+
iterOcList(generatedList, (genFace) => {
|
|
278
|
+
const hash = genFace.HashCode(HASH_CODE_MAX);
|
|
279
|
+
if (!resultMap.has(hash)) {
|
|
280
|
+
resultMap.set(hash, 0);
|
|
281
|
+
}
|
|
282
|
+
});
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
if (resultMap.size > 0) {
|
|
286
|
+
const cache = getOrCreateCache(result);
|
|
287
|
+
cache.faceOrigins = resultMap;
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
function propagateOriginsByHash(inputs, result) {
|
|
291
|
+
const lookup = /* @__PURE__ */ new Map();
|
|
292
|
+
for (const input of inputs) {
|
|
293
|
+
const origins = getFaceOrigins(input);
|
|
294
|
+
if (!origins) continue;
|
|
295
|
+
for (const [hash, origin] of origins) {
|
|
296
|
+
lookup.set(hash, origin);
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
if (lookup.size === 0) return;
|
|
300
|
+
const resultMap = /* @__PURE__ */ new Map();
|
|
301
|
+
for (const f of getFaces(result)) {
|
|
302
|
+
const hash = f.wrapped.HashCode(HASH_CODE_MAX);
|
|
303
|
+
const origin = lookup.get(hash);
|
|
304
|
+
if (origin !== void 0) {
|
|
305
|
+
resultMap.set(hash, origin);
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
if (resultMap.size > 0) {
|
|
309
|
+
const cache = getOrCreateCache(result);
|
|
310
|
+
cache.faceOrigins = resultMap;
|
|
311
|
+
}
|
|
312
|
+
}
|
|
247
313
|
function getVertices(shape) {
|
|
248
314
|
return Array.from(iterTopo(shape.wrapped, "vertex")).map(
|
|
249
315
|
(e) => castShape(unwrap(downcast(e)))
|
|
@@ -308,179 +374,34 @@ function vertexPosition(vertex) {
|
|
|
308
374
|
pnt.delete();
|
|
309
375
|
return result;
|
|
310
376
|
}
|
|
311
|
-
function getAdaptor(shape) {
|
|
312
|
-
const oc = getKernel().oc;
|
|
313
|
-
const st = shape.wrapped.ShapeType();
|
|
314
|
-
const e = oc.TopAbs_ShapeEnum;
|
|
315
|
-
if (st === e.TopAbs_WIRE) {
|
|
316
|
-
return new oc.BRepAdaptor_CompCurve_2(shape.wrapped, false);
|
|
317
|
-
}
|
|
318
|
-
return new oc.BRepAdaptor_Curve_2(shape.wrapped);
|
|
319
|
-
}
|
|
320
|
-
function mapParam(adaptor, t) {
|
|
321
|
-
const first = Number(adaptor.FirstParameter());
|
|
322
|
-
const last = Number(adaptor.LastParameter());
|
|
323
|
-
return first + (last - first) * t;
|
|
324
|
-
}
|
|
325
|
-
function getCurveType(shape) {
|
|
326
|
-
const r = gcWithScope();
|
|
327
|
-
const adaptor = r(getAdaptor(shape));
|
|
328
|
-
const technicalType = adaptor.GetType && adaptor.GetType();
|
|
329
|
-
return unwrap(findCurveType(technicalType));
|
|
330
|
-
}
|
|
331
|
-
function curveStartPoint(shape) {
|
|
332
|
-
const r = gcWithScope();
|
|
333
|
-
const adaptor = r(getAdaptor(shape));
|
|
334
|
-
const pnt = r(adaptor.Value(adaptor.FirstParameter()));
|
|
335
|
-
return [pnt.X(), pnt.Y(), pnt.Z()];
|
|
336
|
-
}
|
|
337
|
-
function curveEndPoint(shape) {
|
|
338
|
-
const r = gcWithScope();
|
|
339
|
-
const adaptor = r(getAdaptor(shape));
|
|
340
|
-
const pnt = r(adaptor.Value(adaptor.LastParameter()));
|
|
341
|
-
return [pnt.X(), pnt.Y(), pnt.Z()];
|
|
342
|
-
}
|
|
343
|
-
function curvePointAt(shape, position = 0.5) {
|
|
344
|
-
const r = gcWithScope();
|
|
345
|
-
const adaptor = r(getAdaptor(shape));
|
|
346
|
-
const pnt = r(adaptor.Value(mapParam(adaptor, position)));
|
|
347
|
-
return [pnt.X(), pnt.Y(), pnt.Z()];
|
|
348
|
-
}
|
|
349
|
-
function curveTangentAt(shape, position = 0.5) {
|
|
350
|
-
const oc = getKernel().oc;
|
|
351
|
-
const r = gcWithScope();
|
|
352
|
-
const adaptor = r(getAdaptor(shape));
|
|
353
|
-
const param = mapParam(adaptor, position);
|
|
354
|
-
const tmpPnt = r(new oc.gp_Pnt_1());
|
|
355
|
-
const tmpVec = r(new oc.gp_Vec_1());
|
|
356
|
-
adaptor.D1(param, tmpPnt, tmpVec);
|
|
357
|
-
return [tmpVec.X(), tmpVec.Y(), tmpVec.Z()];
|
|
358
|
-
}
|
|
359
|
-
function curveLength(shape) {
|
|
360
|
-
const oc = getKernel().oc;
|
|
361
|
-
const r = gcWithScope();
|
|
362
|
-
const props = r(new oc.GProp_GProps_1());
|
|
363
|
-
oc.BRepGProp.LinearProperties(shape.wrapped, props, true, false);
|
|
364
|
-
return props.Mass();
|
|
365
|
-
}
|
|
366
|
-
function curveIsClosed(shape) {
|
|
367
|
-
const r = gcWithScope();
|
|
368
|
-
const adaptor = r(getAdaptor(shape));
|
|
369
|
-
return adaptor.IsClosed();
|
|
370
|
-
}
|
|
371
|
-
function curveIsPeriodic(shape) {
|
|
372
|
-
const r = gcWithScope();
|
|
373
|
-
const adaptor = r(getAdaptor(shape));
|
|
374
|
-
return adaptor.IsPeriodic();
|
|
375
|
-
}
|
|
376
|
-
function curvePeriod(shape) {
|
|
377
|
-
const adaptor = getAdaptor(shape);
|
|
378
|
-
const result = adaptor.Period();
|
|
379
|
-
adaptor.delete();
|
|
380
|
-
return result;
|
|
381
|
-
}
|
|
382
|
-
function getOrientation(shape) {
|
|
383
|
-
const oc = getKernel().oc;
|
|
384
|
-
const orient = shape.wrapped.Orientation_1();
|
|
385
|
-
return orient === oc.TopAbs_Orientation.TopAbs_FORWARD ? "forward" : "backward";
|
|
386
|
-
}
|
|
387
|
-
function flipOrientation(shape) {
|
|
388
|
-
return castShape(shape.wrapped.Reversed());
|
|
389
|
-
}
|
|
390
|
-
function interpolateCurve(points, options = {}) {
|
|
391
|
-
if (points.length < 2) {
|
|
392
|
-
return err(typeCastError("INTERPOLATE_MIN_POINTS", "Interpolation requires at least 2 points"));
|
|
393
|
-
}
|
|
394
|
-
try {
|
|
395
|
-
const result = getKernel().interpolatePoints(points, options);
|
|
396
|
-
const cast = castShape(result);
|
|
397
|
-
if (!isEdge(cast)) {
|
|
398
|
-
return err(typeCastError("INTERPOLATE_NOT_EDGE", "Interpolation did not produce an edge"));
|
|
399
|
-
}
|
|
400
|
-
return ok(cast);
|
|
401
|
-
} catch (e) {
|
|
402
|
-
return err(
|
|
403
|
-
typeCastError(
|
|
404
|
-
"INTERPOLATE_FAILED",
|
|
405
|
-
`Interpolation failed: ${e instanceof Error ? e.message : String(e)}`
|
|
406
|
-
)
|
|
407
|
-
);
|
|
408
|
-
}
|
|
409
|
-
}
|
|
410
|
-
function approximateCurve(points, options = {}) {
|
|
411
|
-
if (points.length < 2) {
|
|
412
|
-
return err(typeCastError("APPROXIMATE_MIN_POINTS", "Approximation requires at least 2 points"));
|
|
413
|
-
}
|
|
414
|
-
try {
|
|
415
|
-
const result = getKernel().approximatePoints(points, options);
|
|
416
|
-
const cast = castShape(result);
|
|
417
|
-
if (!isEdge(cast)) {
|
|
418
|
-
return err(typeCastError("APPROXIMATE_NOT_EDGE", "Approximation did not produce an edge"));
|
|
419
|
-
}
|
|
420
|
-
return ok(cast);
|
|
421
|
-
} catch (e) {
|
|
422
|
-
return err(
|
|
423
|
-
typeCastError(
|
|
424
|
-
"APPROXIMATE_FAILED",
|
|
425
|
-
`Approximation failed: ${e instanceof Error ? e.message : String(e)}`
|
|
426
|
-
)
|
|
427
|
-
);
|
|
428
|
-
}
|
|
429
|
-
}
|
|
430
|
-
function offsetWire2D(wire, offset, kind = "arc") {
|
|
431
|
-
const oc = getKernel().oc;
|
|
432
|
-
const joinTypes = {
|
|
433
|
-
arc: oc.GeomAbs_JoinType.GeomAbs_Arc,
|
|
434
|
-
intersection: oc.GeomAbs_JoinType.GeomAbs_Intersection,
|
|
435
|
-
tangent: oc.GeomAbs_JoinType.GeomAbs_Tangent
|
|
436
|
-
};
|
|
437
|
-
const resultShape = getKernel().offsetWire2D(wire.wrapped, offset, joinTypes[kind]);
|
|
438
|
-
const wrapped = castShape(resultShape);
|
|
439
|
-
if (!isWire(wrapped)) {
|
|
440
|
-
wrapped[Symbol.dispose]();
|
|
441
|
-
return err(typeCastError("OFFSET_NOT_WIRE", "Offset did not produce a Wire"));
|
|
442
|
-
}
|
|
443
|
-
return ok(wrapped);
|
|
444
|
-
}
|
|
445
377
|
export {
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
iterVertices as L,
|
|
458
|
-
iterWires as M,
|
|
459
|
-
offsetWire2D as N,
|
|
460
|
-
getEdges as a,
|
|
461
|
-
applyMatrix as b,
|
|
462
|
-
curveIsClosed as c,
|
|
463
|
-
clone as d,
|
|
464
|
-
describe as e,
|
|
465
|
-
isEmpty as f,
|
|
466
|
-
getHashCode as g,
|
|
467
|
-
simplify as h,
|
|
378
|
+
iterVertices as A,
|
|
379
|
+
iterWires as B,
|
|
380
|
+
setShapeOrigin as C,
|
|
381
|
+
propagateOriginsByHash as a,
|
|
382
|
+
getHashCode as b,
|
|
383
|
+
getEdges as c,
|
|
384
|
+
applyMatrix as d,
|
|
385
|
+
clone as e,
|
|
386
|
+
describe as f,
|
|
387
|
+
getFaceOrigins as g,
|
|
388
|
+
isEmpty as h,
|
|
468
389
|
isSameShape as i,
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
390
|
+
simplify as j,
|
|
391
|
+
toBREP as k,
|
|
392
|
+
transformCopy as l,
|
|
472
393
|
mirror as m,
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
394
|
+
getBounds as n,
|
|
395
|
+
getFaces as o,
|
|
396
|
+
propagateOrigins as p,
|
|
397
|
+
getVertices as q,
|
|
477
398
|
rotate as r,
|
|
478
399
|
scale as s,
|
|
479
400
|
translate as t,
|
|
480
|
-
|
|
401
|
+
getWires as u,
|
|
481
402
|
vertexPosition as v,
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
403
|
+
composeTransforms as w,
|
|
404
|
+
isEqualShape as x,
|
|
405
|
+
iterEdges as y,
|
|
406
|
+
iterFaces as z
|
|
486
407
|
};
|