brepjs 8.2.0 → 8.4.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/lib/Curve2D.d.ts.map +1 -1
- package/dist/2d.cjs +2 -2
- package/dist/2d.js +3 -3
- package/dist/{Blueprint-D_luVeES.js → Blueprint-Bp45tnh0.js} +16 -12
- package/dist/{Blueprint-CTAwjJMN.cjs → Blueprint-zgFe_5Qj.cjs} +17 -13
- package/dist/{boolean2D-B5axNhjN.cjs → boolean2D-CfEbRMPF.cjs} +11 -11
- package/dist/{boolean2D-vw76Gayn.js → boolean2D-DN6ETTCq.js} +11 -11
- package/dist/{booleanFns-Yc3EBxdm.cjs → booleanFns-5dDG0jpA.cjs} +46 -9
- package/dist/{booleanFns-BhqXpQoZ.js → booleanFns-C-M6qqvB.js} +46 -9
- package/dist/brepjs.cjs +364 -109
- package/dist/brepjs.js +433 -177
- package/dist/{cast-C107o5ow.cjs → cast-CPNOTNFm.cjs} +3 -3
- package/dist/{cast-D0OhP1nV.js → cast-Cerqtxtb.js} +3 -3
- package/dist/core/errors.d.ts +7 -0
- package/dist/core/errors.d.ts.map +1 -1
- package/dist/core.cjs +4 -4
- package/dist/core.js +4 -4
- package/dist/{cornerFinder-DuStF5jK.cjs → cornerFinder-BQ-_VJx0.cjs} +1 -1
- package/dist/{cornerFinder-CPm2baSJ.js → cornerFinder-CC_MunIh.js} +1 -1
- package/dist/{curveBuilders-CN72XaIQ.js → curveBuilders-BREwqvuc.js} +3 -3
- package/dist/{curveBuilders-Du03_Yyf.cjs → curveBuilders-BkEJ-RVn.cjs} +3 -3
- package/dist/curveFns-VMxgfkqw.cjs +177 -0
- package/dist/curveFns-ZuQUBZvd.js +178 -0
- package/dist/{drawFns-CzBbcoXA.js → drawFns-BbhX1IUq.js} +19 -15
- package/dist/{drawFns-CiNxPu6J.cjs → drawFns-CKaHgGSK.cjs} +22 -18
- package/dist/{errors-wGhcJMpB.js → errors-CSYOlCCR.js} +10 -1
- package/dist/{errors-DK1VAdP4.cjs → errors-D13q2HCk.cjs} +10 -1
- package/dist/{faceFns-ub3CugDN.js → faceFns-CfJIbHY3.js} +4 -4
- package/dist/{faceFns-D1Sqnlu6.cjs → faceFns-es3GENII.cjs} +4 -4
- package/dist/{helpers-Dje6wrKi.cjs → helpers-C0q_FVxq.cjs} +10 -10
- package/dist/{helpers-BSQfs538.js → helpers-CmVkMubc.js} +7 -7
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/io.cjs +5 -5
- package/dist/io.js +5 -5
- package/dist/kernel/hullOps.d.ts +22 -0
- package/dist/kernel/hullOps.d.ts.map +1 -0
- package/dist/kernel/occtAdapter.d.ts +6 -0
- package/dist/kernel/occtAdapter.d.ts.map +1 -1
- package/dist/kernel/types.d.ts +6 -0
- package/dist/kernel/types.d.ts.map +1 -1
- package/dist/{loft-PMRx9iMG.cjs → loft-B-UCPW9P.cjs} +5 -5
- package/dist/{loft-BHn7GKm8.js → loft-oJq2OD3A.js} +5 -5
- package/dist/{measurement-B06hNs89.cjs → measurement-CYmT-C77.cjs} +3 -3
- package/dist/{measurement-BfhEneUl.js → measurement-Cf_SoIiR.js} +3 -3
- package/dist/measurement.cjs +1 -1
- package/dist/measurement.js +1 -1
- package/dist/{meshFns-BKSPaPXS.js → meshFns-CqNwW0PO.js} +6 -3
- package/dist/{meshFns-CFVxKBlE.cjs → meshFns-DDC_2U81.cjs} +6 -3
- package/dist/{occtBoundary-BFAaUtA7.cjs → occtBoundary-CocN2VKx.cjs} +419 -2
- package/dist/{occtBoundary-CoXB2xvx.js → occtBoundary-D_gjqgzo.js} +419 -2
- package/dist/{operations-CjQHEu1h.js → operations-6hdpuYmY.js} +6 -6
- package/dist/{operations-CdGb6IBU.cjs → operations-BQeW_DSM.cjs} +6 -6
- package/dist/operations.cjs +2 -2
- package/dist/operations.js +2 -2
- package/dist/query.cjs +5 -5
- package/dist/query.js +6 -6
- package/dist/result.cjs +1 -1
- package/dist/result.js +1 -1
- package/dist/{curveFns-ByeCqutv.cjs → shapeFns-B0zSdO9c.cjs} +98 -177
- package/dist/{curveFns-C5gSZ5EY.js → shapeFns-k1YHFwmB.js} +117 -196
- package/dist/{shapeTypes-UqVCIO_T.cjs → shapeTypes-BxVxLdiD.cjs} +1 -1
- package/dist/{shapeTypes-BU2LKv2S.js → shapeTypes-c-_pgYCx.js} +1 -1
- package/dist/sketching.cjs +2 -2
- package/dist/sketching.js +2 -2
- package/dist/text/textBlueprints.d.ts.map +1 -1
- package/dist/topology/booleanFns.d.ts.map +1 -1
- package/dist/topology/hullFns.d.ts +16 -0
- package/dist/topology/hullFns.d.ts.map +1 -0
- package/dist/topology/meshFns.d.ts +1 -0
- package/dist/topology/meshFns.d.ts.map +1 -1
- package/dist/topology/minkowskiFns.d.ts +20 -0
- package/dist/topology/minkowskiFns.d.ts.map +1 -0
- 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-CycEc6Oe.cjs} +14 -13
- package/dist/{topology-BFB3LI_y.js → topology-tMKHJgw2.js} +9 -8
- package/dist/topology.cjs +34 -33
- package/dist/topology.js +59 -58
- package/dist/{vectors-BhfKwL9J.js → vectors-DE0XriuQ.js} +2 -2
- package/dist/{vectors-t1XG4LpL.cjs → vectors-DVmHF4zt.cjs} +2 -2
- package/dist/vectors.cjs +2 -2
- package/dist/vectors.js +2 -2
- package/package.json +5 -5
|
@@ -1,33 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
const occtBoundary = require("./occtBoundary-
|
|
3
|
-
const shapeTypes = require("./shapeTypes-
|
|
2
|
+
const occtBoundary = require("./occtBoundary-CocN2VKx.cjs");
|
|
3
|
+
const shapeTypes = require("./shapeTypes-BxVxLdiD.cjs");
|
|
4
4
|
const vecOps = require("./vecOps-CjRL1jau.cjs");
|
|
5
|
-
const cast = require("./cast-
|
|
6
|
-
const errors = require("./errors-
|
|
7
|
-
let CURVE_TYPES_MAP = null;
|
|
8
|
-
const getCurveTypesMap = (refresh) => {
|
|
9
|
-
if (CURVE_TYPES_MAP && !refresh) return CURVE_TYPES_MAP;
|
|
10
|
-
const oc = occtBoundary.getKernel().oc;
|
|
11
|
-
const ga = oc.GeomAbs_CurveType;
|
|
12
|
-
CURVE_TYPES_MAP = /* @__PURE__ */ new Map([
|
|
13
|
-
[ga.GeomAbs_Line, "LINE"],
|
|
14
|
-
[ga.GeomAbs_Circle, "CIRCLE"],
|
|
15
|
-
[ga.GeomAbs_Ellipse, "ELLIPSE"],
|
|
16
|
-
[ga.GeomAbs_Hyperbola, "HYPERBOLA"],
|
|
17
|
-
[ga.GeomAbs_Parabola, "PARABOLA"],
|
|
18
|
-
[ga.GeomAbs_BezierCurve, "BEZIER_CURVE"],
|
|
19
|
-
[ga.GeomAbs_BSplineCurve, "BSPLINE_CURVE"],
|
|
20
|
-
[ga.GeomAbs_OffsetCurve, "OFFSET_CURVE"],
|
|
21
|
-
[ga.GeomAbs_OtherCurve, "OTHER_CURVE"]
|
|
22
|
-
]);
|
|
23
|
-
return CURVE_TYPES_MAP;
|
|
24
|
-
};
|
|
25
|
-
const findCurveType = (type) => {
|
|
26
|
-
let shapeType = getCurveTypesMap().get(type);
|
|
27
|
-
if (!shapeType) shapeType = getCurveTypesMap(true).get(type);
|
|
28
|
-
if (!shapeType) return errors.err(errors.typeCastError("UNKNOWN_CURVE_TYPE", "Unknown curve type"));
|
|
29
|
-
return errors.ok(shapeType);
|
|
30
|
-
};
|
|
5
|
+
const cast = require("./cast-CPNOTNFm.cjs");
|
|
6
|
+
const errors = require("./errors-D13q2HCk.cjs");
|
|
31
7
|
function clone(shape) {
|
|
32
8
|
return shapeTypes.castShape(errors.unwrap(cast.downcast(shape.wrapped)));
|
|
33
9
|
}
|
|
@@ -61,6 +37,7 @@ function translate(shape, v) {
|
|
|
61
37
|
trsf.SetTranslation_1(vec);
|
|
62
38
|
const transformer = new oc.BRepBuilderAPI_Transform_2(shape.wrapped, trsf, true);
|
|
63
39
|
const result = shapeTypes.castShape(transformer.Shape());
|
|
40
|
+
propagateOrigins(transformer, [shape], result);
|
|
64
41
|
transformer.delete();
|
|
65
42
|
trsf.delete();
|
|
66
43
|
vec.delete();
|
|
@@ -73,6 +50,7 @@ function rotate(shape, angle, position = [0, 0, 0], direction = [0, 0, 1]) {
|
|
|
73
50
|
trsf.SetRotation_1(ax1, angle * vecOps.DEG2RAD);
|
|
74
51
|
const transformer = new oc.BRepBuilderAPI_Transform_2(shape.wrapped, trsf, true);
|
|
75
52
|
const result = shapeTypes.castShape(transformer.Shape());
|
|
53
|
+
propagateOrigins(transformer, [shape], result);
|
|
76
54
|
transformer.delete();
|
|
77
55
|
trsf.delete();
|
|
78
56
|
ax1.delete();
|
|
@@ -85,6 +63,7 @@ function mirror(shape, planeNormal = [0, 1, 0], planeOrigin = [0, 0, 0]) {
|
|
|
85
63
|
trsf.SetMirror_3(ax2);
|
|
86
64
|
const transformer = new oc.BRepBuilderAPI_Transform_2(shape.wrapped, trsf, true);
|
|
87
65
|
const result = shapeTypes.castShape(transformer.Shape());
|
|
66
|
+
propagateOrigins(transformer, [shape], result);
|
|
88
67
|
transformer.delete();
|
|
89
68
|
trsf.delete();
|
|
90
69
|
ax2.delete();
|
|
@@ -97,6 +76,7 @@ function scale(shape, factor, center = [0, 0, 0]) {
|
|
|
97
76
|
trsf.SetScale(pnt, factor);
|
|
98
77
|
const transformer = new oc.BRepBuilderAPI_Transform_2(shape.wrapped, trsf, true);
|
|
99
78
|
const result = shapeTypes.castShape(transformer.Shape());
|
|
79
|
+
propagateOrigins(transformer, [shape], result);
|
|
100
80
|
transformer.delete();
|
|
101
81
|
trsf.delete();
|
|
102
82
|
pnt.delete();
|
|
@@ -164,6 +144,7 @@ function applyMatrix(shape, matrix) {
|
|
|
164
144
|
);
|
|
165
145
|
const transformer2 = new oc.BRepBuilderAPI_Transform_2(shape.wrapped, trsf, true);
|
|
166
146
|
const result2 = shapeTypes.castShape(transformer2.Shape());
|
|
147
|
+
propagateOrigins(transformer2, [shape], result2);
|
|
167
148
|
transformer2.delete();
|
|
168
149
|
trsf.delete();
|
|
169
150
|
return result2;
|
|
@@ -179,6 +160,7 @@ function applyMatrix(shape, matrix) {
|
|
|
179
160
|
xyz.delete();
|
|
180
161
|
const transformer = new oc.BRepBuilderAPI_GTransform_2(shape.wrapped, gtrsf, true);
|
|
181
162
|
const result = shapeTypes.castShape(transformer.Shape());
|
|
163
|
+
propagateOrigins(transformer, [shape], result);
|
|
182
164
|
transformer.delete();
|
|
183
165
|
gtrsf.delete();
|
|
184
166
|
return result;
|
|
@@ -206,6 +188,7 @@ function transformCopy(shape, composed) {
|
|
|
206
188
|
const oc = occtBoundary.getKernel().oc;
|
|
207
189
|
const transformer = new oc.BRepBuilderAPI_Transform_2(shape.wrapped, composed.trsf, true);
|
|
208
190
|
const result = shapeTypes.castShape(transformer.Shape());
|
|
191
|
+
propagateOrigins(transformer, [shape], result);
|
|
209
192
|
transformer.delete();
|
|
210
193
|
return result;
|
|
211
194
|
}
|
|
@@ -245,6 +228,89 @@ function getWires(shape) {
|
|
|
245
228
|
cache.wires = wires;
|
|
246
229
|
return wires;
|
|
247
230
|
}
|
|
231
|
+
function setShapeOrigin(shape, origin) {
|
|
232
|
+
const cache = getOrCreateCache(shape);
|
|
233
|
+
const map = /* @__PURE__ */ new Map();
|
|
234
|
+
for (const f of getFaces(shape)) {
|
|
235
|
+
map.set(f.wrapped.HashCode(vecOps.HASH_CODE_MAX), origin);
|
|
236
|
+
}
|
|
237
|
+
cache.faceOrigins = map;
|
|
238
|
+
}
|
|
239
|
+
function getFaceOrigins(shape) {
|
|
240
|
+
return topoCache.get(shape.wrapped)?.faceOrigins;
|
|
241
|
+
}
|
|
242
|
+
function iterOcList(list, callback) {
|
|
243
|
+
const oc = occtBoundary.getKernel().oc;
|
|
244
|
+
const copy = new oc.TopTools_ListOfShape_3(list);
|
|
245
|
+
while (copy.Size() > 0) {
|
|
246
|
+
callback(copy.First_1());
|
|
247
|
+
copy.RemoveFirst();
|
|
248
|
+
}
|
|
249
|
+
copy.delete();
|
|
250
|
+
}
|
|
251
|
+
function propagateOrigins(op, inputs, result) {
|
|
252
|
+
const inputOrigins = [];
|
|
253
|
+
for (const input of inputs) {
|
|
254
|
+
const origins = getFaceOrigins(input);
|
|
255
|
+
if (!origins) continue;
|
|
256
|
+
for (const f of getFaces(input)) {
|
|
257
|
+
const hash = f.wrapped.HashCode(vecOps.HASH_CODE_MAX);
|
|
258
|
+
const origin = origins.get(hash);
|
|
259
|
+
if (origin !== void 0) {
|
|
260
|
+
inputOrigins.push({ face: f.wrapped, origin });
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
if (inputOrigins.length === 0) return;
|
|
265
|
+
const resultMap = /* @__PURE__ */ new Map();
|
|
266
|
+
for (const { face, origin } of inputOrigins) {
|
|
267
|
+
if (op.IsDeleted?.(face)) continue;
|
|
268
|
+
const modifiedList = op.Modified(face);
|
|
269
|
+
if (modifiedList.Size() > 0) {
|
|
270
|
+
iterOcList(modifiedList, (modFace) => {
|
|
271
|
+
resultMap.set(modFace.HashCode(vecOps.HASH_CODE_MAX), origin);
|
|
272
|
+
});
|
|
273
|
+
} else {
|
|
274
|
+
resultMap.set(face.HashCode(vecOps.HASH_CODE_MAX), origin);
|
|
275
|
+
}
|
|
276
|
+
const generatedList = op.Generated(face);
|
|
277
|
+
if (generatedList.Size() > 0) {
|
|
278
|
+
iterOcList(generatedList, (genFace) => {
|
|
279
|
+
const hash = genFace.HashCode(vecOps.HASH_CODE_MAX);
|
|
280
|
+
if (!resultMap.has(hash)) {
|
|
281
|
+
resultMap.set(hash, 0);
|
|
282
|
+
}
|
|
283
|
+
});
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
if (resultMap.size > 0) {
|
|
287
|
+
const cache = getOrCreateCache(result);
|
|
288
|
+
cache.faceOrigins = resultMap;
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
function propagateOriginsByHash(inputs, result) {
|
|
292
|
+
const lookup = /* @__PURE__ */ new Map();
|
|
293
|
+
for (const input of inputs) {
|
|
294
|
+
const origins = getFaceOrigins(input);
|
|
295
|
+
if (!origins) continue;
|
|
296
|
+
for (const [hash, origin] of origins) {
|
|
297
|
+
lookup.set(hash, origin);
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
if (lookup.size === 0) return;
|
|
301
|
+
const resultMap = /* @__PURE__ */ new Map();
|
|
302
|
+
for (const f of getFaces(result)) {
|
|
303
|
+
const hash = f.wrapped.HashCode(vecOps.HASH_CODE_MAX);
|
|
304
|
+
const origin = lookup.get(hash);
|
|
305
|
+
if (origin !== void 0) {
|
|
306
|
+
resultMap.set(hash, origin);
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
if (resultMap.size > 0) {
|
|
310
|
+
const cache = getOrCreateCache(result);
|
|
311
|
+
cache.faceOrigins = resultMap;
|
|
312
|
+
}
|
|
313
|
+
}
|
|
248
314
|
function getVertices(shape) {
|
|
249
315
|
return Array.from(cast.iterTopo(shape.wrapped, "vertex")).map(
|
|
250
316
|
(e) => shapeTypes.castShape(errors.unwrap(cast.downcast(e)))
|
|
@@ -309,164 +375,17 @@ function vertexPosition(vertex) {
|
|
|
309
375
|
pnt.delete();
|
|
310
376
|
return result;
|
|
311
377
|
}
|
|
312
|
-
function getAdaptor(shape) {
|
|
313
|
-
const oc = occtBoundary.getKernel().oc;
|
|
314
|
-
const st = shape.wrapped.ShapeType();
|
|
315
|
-
const e = oc.TopAbs_ShapeEnum;
|
|
316
|
-
if (st === e.TopAbs_WIRE) {
|
|
317
|
-
return new oc.BRepAdaptor_CompCurve_2(shape.wrapped, false);
|
|
318
|
-
}
|
|
319
|
-
return new oc.BRepAdaptor_Curve_2(shape.wrapped);
|
|
320
|
-
}
|
|
321
|
-
function mapParam(adaptor, t) {
|
|
322
|
-
const first = Number(adaptor.FirstParameter());
|
|
323
|
-
const last = Number(adaptor.LastParameter());
|
|
324
|
-
return first + (last - first) * t;
|
|
325
|
-
}
|
|
326
|
-
function getCurveType(shape) {
|
|
327
|
-
const r = shapeTypes.gcWithScope();
|
|
328
|
-
const adaptor = r(getAdaptor(shape));
|
|
329
|
-
const technicalType = adaptor.GetType && adaptor.GetType();
|
|
330
|
-
return errors.unwrap(findCurveType(technicalType));
|
|
331
|
-
}
|
|
332
|
-
function curveStartPoint(shape) {
|
|
333
|
-
const r = shapeTypes.gcWithScope();
|
|
334
|
-
const adaptor = r(getAdaptor(shape));
|
|
335
|
-
const pnt = r(adaptor.Value(adaptor.FirstParameter()));
|
|
336
|
-
return [pnt.X(), pnt.Y(), pnt.Z()];
|
|
337
|
-
}
|
|
338
|
-
function curveEndPoint(shape) {
|
|
339
|
-
const r = shapeTypes.gcWithScope();
|
|
340
|
-
const adaptor = r(getAdaptor(shape));
|
|
341
|
-
const pnt = r(adaptor.Value(adaptor.LastParameter()));
|
|
342
|
-
return [pnt.X(), pnt.Y(), pnt.Z()];
|
|
343
|
-
}
|
|
344
|
-
function curvePointAt(shape, position = 0.5) {
|
|
345
|
-
const r = shapeTypes.gcWithScope();
|
|
346
|
-
const adaptor = r(getAdaptor(shape));
|
|
347
|
-
const pnt = r(adaptor.Value(mapParam(adaptor, position)));
|
|
348
|
-
return [pnt.X(), pnt.Y(), pnt.Z()];
|
|
349
|
-
}
|
|
350
|
-
function curveTangentAt(shape, position = 0.5) {
|
|
351
|
-
const oc = occtBoundary.getKernel().oc;
|
|
352
|
-
const r = shapeTypes.gcWithScope();
|
|
353
|
-
const adaptor = r(getAdaptor(shape));
|
|
354
|
-
const param = mapParam(adaptor, position);
|
|
355
|
-
const tmpPnt = r(new oc.gp_Pnt_1());
|
|
356
|
-
const tmpVec = r(new oc.gp_Vec_1());
|
|
357
|
-
adaptor.D1(param, tmpPnt, tmpVec);
|
|
358
|
-
return [tmpVec.X(), tmpVec.Y(), tmpVec.Z()];
|
|
359
|
-
}
|
|
360
|
-
function curveLength(shape) {
|
|
361
|
-
const oc = occtBoundary.getKernel().oc;
|
|
362
|
-
const r = shapeTypes.gcWithScope();
|
|
363
|
-
const props = r(new oc.GProp_GProps_1());
|
|
364
|
-
oc.BRepGProp.LinearProperties(shape.wrapped, props, true, false);
|
|
365
|
-
return props.Mass();
|
|
366
|
-
}
|
|
367
|
-
function curveIsClosed(shape) {
|
|
368
|
-
const r = shapeTypes.gcWithScope();
|
|
369
|
-
const adaptor = r(getAdaptor(shape));
|
|
370
|
-
return adaptor.IsClosed();
|
|
371
|
-
}
|
|
372
|
-
function curveIsPeriodic(shape) {
|
|
373
|
-
const r = shapeTypes.gcWithScope();
|
|
374
|
-
const adaptor = r(getAdaptor(shape));
|
|
375
|
-
return adaptor.IsPeriodic();
|
|
376
|
-
}
|
|
377
|
-
function curvePeriod(shape) {
|
|
378
|
-
const adaptor = getAdaptor(shape);
|
|
379
|
-
const result = adaptor.Period();
|
|
380
|
-
adaptor.delete();
|
|
381
|
-
return result;
|
|
382
|
-
}
|
|
383
|
-
function getOrientation(shape) {
|
|
384
|
-
const oc = occtBoundary.getKernel().oc;
|
|
385
|
-
const orient = shape.wrapped.Orientation_1();
|
|
386
|
-
return orient === oc.TopAbs_Orientation.TopAbs_FORWARD ? "forward" : "backward";
|
|
387
|
-
}
|
|
388
|
-
function flipOrientation(shape) {
|
|
389
|
-
return shapeTypes.castShape(shape.wrapped.Reversed());
|
|
390
|
-
}
|
|
391
|
-
function interpolateCurve(points, options = {}) {
|
|
392
|
-
if (points.length < 2) {
|
|
393
|
-
return errors.err(errors.typeCastError("INTERPOLATE_MIN_POINTS", "Interpolation requires at least 2 points"));
|
|
394
|
-
}
|
|
395
|
-
try {
|
|
396
|
-
const result = occtBoundary.getKernel().interpolatePoints(points, options);
|
|
397
|
-
const cast2 = shapeTypes.castShape(result);
|
|
398
|
-
if (!shapeTypes.isEdge(cast2)) {
|
|
399
|
-
return errors.err(errors.typeCastError("INTERPOLATE_NOT_EDGE", "Interpolation did not produce an edge"));
|
|
400
|
-
}
|
|
401
|
-
return errors.ok(cast2);
|
|
402
|
-
} catch (e) {
|
|
403
|
-
return errors.err(
|
|
404
|
-
errors.typeCastError(
|
|
405
|
-
"INTERPOLATE_FAILED",
|
|
406
|
-
`Interpolation failed: ${e instanceof Error ? e.message : String(e)}`
|
|
407
|
-
)
|
|
408
|
-
);
|
|
409
|
-
}
|
|
410
|
-
}
|
|
411
|
-
function approximateCurve(points, options = {}) {
|
|
412
|
-
if (points.length < 2) {
|
|
413
|
-
return errors.err(errors.typeCastError("APPROXIMATE_MIN_POINTS", "Approximation requires at least 2 points"));
|
|
414
|
-
}
|
|
415
|
-
try {
|
|
416
|
-
const result = occtBoundary.getKernel().approximatePoints(points, options);
|
|
417
|
-
const cast2 = shapeTypes.castShape(result);
|
|
418
|
-
if (!shapeTypes.isEdge(cast2)) {
|
|
419
|
-
return errors.err(errors.typeCastError("APPROXIMATE_NOT_EDGE", "Approximation did not produce an edge"));
|
|
420
|
-
}
|
|
421
|
-
return errors.ok(cast2);
|
|
422
|
-
} catch (e) {
|
|
423
|
-
return errors.err(
|
|
424
|
-
errors.typeCastError(
|
|
425
|
-
"APPROXIMATE_FAILED",
|
|
426
|
-
`Approximation failed: ${e instanceof Error ? e.message : String(e)}`
|
|
427
|
-
)
|
|
428
|
-
);
|
|
429
|
-
}
|
|
430
|
-
}
|
|
431
|
-
function offsetWire2D(wire, offset, kind = "arc") {
|
|
432
|
-
const oc = occtBoundary.getKernel().oc;
|
|
433
|
-
const joinTypes = {
|
|
434
|
-
arc: oc.GeomAbs_JoinType.GeomAbs_Arc,
|
|
435
|
-
intersection: oc.GeomAbs_JoinType.GeomAbs_Intersection,
|
|
436
|
-
tangent: oc.GeomAbs_JoinType.GeomAbs_Tangent
|
|
437
|
-
};
|
|
438
|
-
const resultShape = occtBoundary.getKernel().offsetWire2D(wire.wrapped, offset, joinTypes[kind]);
|
|
439
|
-
const wrapped = shapeTypes.castShape(resultShape);
|
|
440
|
-
if (!shapeTypes.isWire(wrapped)) {
|
|
441
|
-
wrapped[Symbol.dispose]();
|
|
442
|
-
return errors.err(errors.typeCastError("OFFSET_NOT_WIRE", "Offset did not produce a Wire"));
|
|
443
|
-
}
|
|
444
|
-
return errors.ok(wrapped);
|
|
445
|
-
}
|
|
446
378
|
exports.applyMatrix = applyMatrix;
|
|
447
|
-
exports.approximateCurve = approximateCurve;
|
|
448
379
|
exports.clone = clone;
|
|
449
380
|
exports.composeTransforms = composeTransforms;
|
|
450
|
-
exports.curveEndPoint = curveEndPoint;
|
|
451
|
-
exports.curveIsClosed = curveIsClosed;
|
|
452
|
-
exports.curveIsPeriodic = curveIsPeriodic;
|
|
453
|
-
exports.curveLength = curveLength;
|
|
454
|
-
exports.curvePeriod = curvePeriod;
|
|
455
|
-
exports.curvePointAt = curvePointAt;
|
|
456
|
-
exports.curveStartPoint = curveStartPoint;
|
|
457
|
-
exports.curveTangentAt = curveTangentAt;
|
|
458
381
|
exports.describe = describe;
|
|
459
|
-
exports.findCurveType = findCurveType;
|
|
460
|
-
exports.flipOrientation = flipOrientation;
|
|
461
382
|
exports.getBounds = getBounds;
|
|
462
|
-
exports.getCurveType = getCurveType;
|
|
463
383
|
exports.getEdges = getEdges;
|
|
384
|
+
exports.getFaceOrigins = getFaceOrigins;
|
|
464
385
|
exports.getFaces = getFaces;
|
|
465
386
|
exports.getHashCode = getHashCode;
|
|
466
|
-
exports.getOrientation = getOrientation;
|
|
467
387
|
exports.getVertices = getVertices;
|
|
468
388
|
exports.getWires = getWires;
|
|
469
|
-
exports.interpolateCurve = interpolateCurve;
|
|
470
389
|
exports.isEmpty = isEmpty;
|
|
471
390
|
exports.isEqualShape = isEqualShape;
|
|
472
391
|
exports.isSameShape = isSameShape;
|
|
@@ -475,9 +394,11 @@ exports.iterFaces = iterFaces;
|
|
|
475
394
|
exports.iterVertices = iterVertices;
|
|
476
395
|
exports.iterWires = iterWires;
|
|
477
396
|
exports.mirror = mirror;
|
|
478
|
-
exports.
|
|
397
|
+
exports.propagateOrigins = propagateOrigins;
|
|
398
|
+
exports.propagateOriginsByHash = propagateOriginsByHash;
|
|
479
399
|
exports.rotate = rotate;
|
|
480
400
|
exports.scale = scale;
|
|
401
|
+
exports.setShapeOrigin = setShapeOrigin;
|
|
481
402
|
exports.simplify = simplify;
|
|
482
403
|
exports.toBREP = toBREP;
|
|
483
404
|
exports.transformCopy = transformCopy;
|