brepjs 8.8.2 → 8.8.3

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.
Files changed (98) hide show
  1. package/dist/2d/curves.d.ts.map +1 -1
  2. package/dist/2d/lib/Curve2D.d.ts.map +1 -1
  3. package/dist/2d/lib/approximations.d.ts.map +1 -1
  4. package/dist/2d/lib/makeCurves.d.ts.map +1 -1
  5. package/dist/2d/lib/ocWrapper.d.ts.map +1 -1
  6. package/dist/2d.cjs +2 -2
  7. package/dist/2d.js +3 -3
  8. package/dist/Blueprint-BmFJ4caY.cjs +1439 -0
  9. package/dist/Blueprint-DsoGiJNJ.js +1440 -0
  10. package/dist/{boolean2D-q5FOdOQW.cjs → boolean2D-BQk8LNmZ.cjs} +212 -127
  11. package/dist/{boolean2D-Dgnuy63w.js → boolean2D-D5O0F3J8.js} +212 -127
  12. package/dist/{booleanFns-CFit7JYt.cjs → booleanFns-CVM3dOTP.cjs} +210 -130
  13. package/dist/{booleanFns--Orezl-b.js → booleanFns-DOyKxL7q.js} +210 -130
  14. package/dist/brepjs.cjs +457 -304
  15. package/dist/brepjs.js +551 -398
  16. package/dist/core/disposal.d.ts +44 -3
  17. package/dist/core/disposal.d.ts.map +1 -1
  18. package/dist/core/geometryHelpers.d.ts.map +1 -1
  19. package/dist/core/kernelCall.d.ts +20 -0
  20. package/dist/core/kernelCall.d.ts.map +1 -1
  21. package/dist/core/memory.d.ts +1 -1
  22. package/dist/core/memory.d.ts.map +1 -1
  23. package/dist/core.cjs +4 -1
  24. package/dist/core.d.ts +1 -1
  25. package/dist/core.d.ts.map +1 -1
  26. package/dist/core.js +11 -8
  27. package/dist/{cornerFinder-KNTFoGrm.js → cornerFinder-DH6EwYfL.js} +1 -1
  28. package/dist/{cornerFinder-v4un1Fr9.cjs → cornerFinder-XAV2ywVS.cjs} +1 -1
  29. package/dist/curveFns-BHRYwxBM.js +281 -0
  30. package/dist/{curveFns-6ovDM_sR.cjs → curveFns-BsAHC3Qv.cjs} +137 -36
  31. package/dist/{drawFns-WgXeXHH1.cjs → drawFns-CsmUF97U.cjs} +181 -101
  32. package/dist/{drawFns-XwroLxdb.js → drawFns-hD05g0ZQ.js} +181 -101
  33. package/dist/faceFns-DNQss51F.cjs +358 -0
  34. package/dist/faceFns-q5CR9pOW.js +359 -0
  35. package/dist/{helpers-CRfqaW0Y.cjs → helpers-aylLv0_I.cjs} +13 -10
  36. package/dist/{helpers-CtBCzEqs.js → helpers-tNdaX01G.js} +13 -10
  37. package/dist/index.d.ts +2 -2
  38. package/dist/index.d.ts.map +1 -1
  39. package/dist/io/importFns.d.ts.map +1 -1
  40. package/dist/io.cjs +131 -63
  41. package/dist/io.js +131 -63
  42. package/dist/loft-CjEEqz2P.cjs +530 -0
  43. package/dist/loft-DTRcYrq2.js +531 -0
  44. package/dist/measurement-B6_cxjpw.cjs +200 -0
  45. package/dist/measurement-BXqFvcGh.js +201 -0
  46. package/dist/measurement.cjs +1 -1
  47. package/dist/measurement.js +1 -1
  48. package/dist/{meshFns-CPNNlpbw.cjs → meshFns-CTc1CRkF.cjs} +1 -1
  49. package/dist/{meshFns-DAmWVyEp.js → meshFns-DDFl7gLN.js} +1 -1
  50. package/dist/operations/exporterFns.d.ts.map +1 -1
  51. package/dist/operations/exporterUtils.d.ts +3 -3
  52. package/dist/operations/exporterUtils.d.ts.map +1 -1
  53. package/dist/operations/exporters.d.ts.map +1 -1
  54. package/dist/operations/extrude.d.ts.map +1 -1
  55. package/dist/operations/extrudeFns.d.ts.map +1 -1
  56. package/dist/operations/loft.d.ts.map +1 -1
  57. package/dist/operations/multiSweepFns.d.ts.map +1 -1
  58. package/dist/{operations-vN0tcoaU.js → operations-jRE2QbPo.js} +261 -166
  59. package/dist/{operations-BQ25CPI8.cjs → operations-pxjbW4Er.cjs} +261 -166
  60. package/dist/operations.cjs +2 -2
  61. package/dist/operations.js +2 -2
  62. package/dist/query/shapeDistanceFilter.d.ts.map +1 -1
  63. package/dist/query.cjs +66 -14
  64. package/dist/query.js +67 -15
  65. package/dist/{shapeFns-C785aeVn.cjs → shapeFns-D4CRxxmF.cjs} +61 -7
  66. package/dist/{shapeFns-ClpALED4.js → shapeFns-DNnBK8fG.js} +61 -7
  67. package/dist/{shapeTypes-DnwCo942.js → shapeTypes-Bi_9RZa2.js} +50 -19
  68. package/dist/{shapeTypes-CIijJxCz.cjs → shapeTypes-CWuX602K.cjs} +32 -1
  69. package/dist/sketching/CompoundSketch.d.ts.map +1 -1
  70. package/dist/sketching/Sketch.d.ts.map +1 -1
  71. package/dist/sketching/Sketcher.d.ts.map +1 -1
  72. package/dist/sketching/Sketcher2d.d.ts.map +1 -1
  73. package/dist/sketching/cannedSketches.d.ts.map +1 -1
  74. package/dist/sketching/draw.d.ts.map +1 -1
  75. package/dist/sketching.cjs +2 -2
  76. package/dist/sketching.js +2 -2
  77. package/dist/surfaceBuilders-CLal3WlK.cjs +429 -0
  78. package/dist/surfaceBuilders-W9Y25CIb.js +430 -0
  79. package/dist/topology/curveBuilders.d.ts.map +1 -1
  80. package/dist/topology/shapeFns.d.ts.map +1 -1
  81. package/dist/topology/solidBuilders.d.ts.map +1 -1
  82. package/dist/topology/surfaceBuilders.d.ts.map +1 -1
  83. package/dist/{topology-CqyxpmEh.js → topology-CMM6vAzx.js} +6 -6
  84. package/dist/{topology-zG8maSDK.cjs → topology-CNw-wsmG.cjs} +6 -6
  85. package/dist/topology.cjs +6 -6
  86. package/dist/topology.js +6 -6
  87. package/package.json +4 -1
  88. package/dist/Blueprint-BmbNUnGI.cjs +0 -1185
  89. package/dist/Blueprint-C-JJkkwL.js +0 -1186
  90. package/dist/curveFns-BhQECv8e.js +0 -180
  91. package/dist/faceFns-3PDjBeW7.js +0 -272
  92. package/dist/faceFns-CxaLWOjc.cjs +0 -271
  93. package/dist/loft-CVb-IjEI.cjs +0 -372
  94. package/dist/loft-DMFjK6lk.js +0 -373
  95. package/dist/measurement-CecYIt3s.cjs +0 -134
  96. package/dist/measurement-DHDLAH7-.js +0 -135
  97. package/dist/surfaceBuilders-CC0ZQGix.cjs +0 -289
  98. package/dist/surfaceBuilders-CrJtFu2a.js +0 -290
@@ -1,373 +0,0 @@
1
- import { g as getKernel, d as toOcPnt, c as makeOcAx2, m as makeOcAx1, a as toVec3 } from "./occtBoundary-DvBywHyU.js";
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 "./faceFns-3PDjBeW7.js";
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-DJ92ermb.js";
5
- import { n as gcWithScope, j as isShell, s as createCompound, t as createVertex, u as createSolid, h as isShape3D, k as isSolid, r as localGC } from "./shapeTypes-DnwCo942.js";
6
- import { a as makeLine, b as assembleWire, c as makeHelix } from "./surfaceBuilders-CrJtFu2a.js";
7
- function buildLawFromProfile(extrusionLength, { profile, endFactor = 1 }) {
8
- const oc = getKernel().oc;
9
- const r = gcWithScope();
10
- let law;
11
- if (profile === "s-curve") {
12
- law = r(new oc.Law_S());
13
- law.Set_1(0, 1, extrusionLength, endFactor);
14
- } else if (profile === "linear") {
15
- law = r(new oc.Law_Linear());
16
- law.Set(0, 1, extrusionLength, endFactor);
17
- } else {
18
- return err(
19
- validationError("UNSUPPORTED_PROFILE", `Unsupported extrusion profile: ${String(profile)}`)
20
- );
21
- }
22
- return ok(law.Trim(0, extrusionLength, 1e-6));
23
- }
24
- function weldShapes(facesOrShells) {
25
- const sewn = getKernel().sew(facesOrShells.map((s) => s.wrapped));
26
- return unwrap(cast(unwrap(downcast(sewn))));
27
- }
28
- function weldShellsAndFaces(facesOrShells, ignoreType = false) {
29
- const shell = weldShapes(facesOrShells);
30
- if (!ignoreType && !isShell(shell))
31
- return err(typeCastError("WELD_NOT_SHELL", "Could not make a shell from faces and shells"));
32
- return ok(shell);
33
- }
34
- function makeCylinder(radius, height, location = [0, 0, 0], direction = [0, 0, 1]) {
35
- const oc = getKernel().oc;
36
- const r = gcWithScope();
37
- const axis = r(makeOcAx2(location, direction));
38
- const cylinder = r(new oc.BRepPrimAPI_MakeCylinder_3(axis, radius, height));
39
- return createSolid(cylinder.Shape());
40
- }
41
- function makeSphere(radius) {
42
- const oc = getKernel().oc;
43
- const r = gcWithScope();
44
- const sphereMaker = r(new oc.BRepPrimAPI_MakeSphere_1(radius));
45
- return createSolid(sphereMaker.Shape());
46
- }
47
- function makeCone(radius1, radius2, height, location = [0, 0, 0], direction = [0, 0, 1]) {
48
- const oc = getKernel().oc;
49
- const r = gcWithScope();
50
- const axis = r(makeOcAx2(location, direction));
51
- const coneMaker = r(new oc.BRepPrimAPI_MakeCone_3(axis, radius1, radius2, height));
52
- return createSolid(coneMaker.Shape());
53
- }
54
- function makeTorus(majorRadius, minorRadius, location = [0, 0, 0], direction = [0, 0, 1]) {
55
- const oc = getKernel().oc;
56
- const r = gcWithScope();
57
- const axis = r(makeOcAx2(location, direction));
58
- const torusMaker = r(new oc.BRepPrimAPI_MakeTorus_5(axis, majorRadius, minorRadius));
59
- return createSolid(torusMaker.Shape());
60
- }
61
- function makeEllipsoidTransform(x, y, z) {
62
- const oc = getKernel().oc;
63
- const r = gcWithScope();
64
- const xyRatio = Math.sqrt(x * y / z);
65
- const xzRatio = x / xyRatio;
66
- const yzRatio = y / xyRatio;
67
- const ax1 = r(makeOcAx1([0, 0, 0], [0, 1, 0]));
68
- const ax2 = r(makeOcAx1([0, 0, 0], [0, 0, 1]));
69
- const ax3 = r(makeOcAx1([0, 0, 0], [1, 0, 0]));
70
- const transform = new oc.gp_GTrsf_1();
71
- transform.SetAffinity_1(ax1, xzRatio);
72
- const xy = r(new oc.gp_GTrsf_1());
73
- xy.SetAffinity_1(ax2, xyRatio);
74
- const yz = r(new oc.gp_GTrsf_1());
75
- yz.SetAffinity_1(ax3, yzRatio);
76
- transform.Multiply(xy);
77
- transform.Multiply(yz);
78
- return {
79
- transform,
80
- applyToPoint(p) {
81
- const r2 = gcWithScope();
82
- const coords = r2(p.XYZ());
83
- transform.Transforms_1(coords);
84
- return new oc.gp_Pnt_2(coords);
85
- }
86
- };
87
- }
88
- function convertToJSArray(arrayOfPoints) {
89
- const newArray = [];
90
- for (let row = arrayOfPoints.LowerRow(); row <= arrayOfPoints.UpperRow(); row++) {
91
- const rowArr = [];
92
- newArray.push(rowArr);
93
- for (let c = arrayOfPoints.LowerCol(); c <= arrayOfPoints.UpperCol(); c++) {
94
- const pnt = arrayOfPoints.Value(row, c);
95
- rowArr.push(pnt);
96
- }
97
- }
98
- return newArray;
99
- }
100
- function makeEllipsoid(aLength, bLength, cLength) {
101
- const oc = getKernel().oc;
102
- const r = gcWithScope();
103
- const sphere = r(new oc.gp_Sphere_1());
104
- sphere.SetRadius(1);
105
- const sphericalSurface = r(new oc.Geom_SphericalSurface_2(sphere));
106
- const baseSurface = oc.GeomConvert.SurfaceToBSplineSurface(sphericalSurface.UReversed()).get();
107
- try {
108
- const poles = convertToJSArray(baseSurface.Poles_2());
109
- const ellipsoidTrsf = makeEllipsoidTransform(aLength, bLength, cLength);
110
- poles.forEach((columns, rowIdx) => {
111
- columns.forEach((value, colIdx) => {
112
- const newPoint = ellipsoidTrsf.applyToPoint(value);
113
- baseSurface.SetPole_1(rowIdx + 1, colIdx + 1, newPoint);
114
- newPoint.delete();
115
- });
116
- });
117
- ellipsoidTrsf.transform.delete();
118
- const shell = unwrap(
119
- cast(r(new oc.BRepBuilderAPI_MakeShell_2(baseSurface.UReversed(), false)).Shell())
120
- );
121
- return unwrap(makeSolid([shell]));
122
- } finally {
123
- baseSurface.delete();
124
- }
125
- }
126
- function makeVertex(point) {
127
- const oc = getKernel().oc;
128
- const r = gcWithScope();
129
- const pnt = r(toOcPnt(point));
130
- const vertexMaker = r(new oc.BRepBuilderAPI_MakeVertex(pnt));
131
- return createVertex(vertexMaker.Vertex());
132
- }
133
- function makeOffset(face, offset, tolerance = 1e-6) {
134
- const oc = getKernel().oc;
135
- const progress = new oc.Message_ProgressRange_1();
136
- const offsetBuilder = new oc.BRepOffsetAPI_MakeOffsetShape();
137
- try {
138
- offsetBuilder.PerformByJoin(
139
- face.wrapped,
140
- offset,
141
- tolerance,
142
- oc.BRepOffset_Mode.BRepOffset_Skin,
143
- false,
144
- false,
145
- oc.GeomAbs_JoinType.GeomAbs_Arc,
146
- false,
147
- progress
148
- );
149
- return andThen(
150
- downcast(offsetBuilder.Shape()),
151
- (downcasted) => andThen(cast(downcasted), (newShape) => {
152
- if (!isShape3D(newShape))
153
- return err(typeCastError("OFFSET_NOT_3D", "Could not offset to a 3d shape"));
154
- return ok(newShape);
155
- })
156
- );
157
- } finally {
158
- offsetBuilder.delete();
159
- progress.delete();
160
- }
161
- }
162
- function makeCompound(shapeArray) {
163
- const oc = getKernel().oc;
164
- const builder = new oc.TopoDS_Builder();
165
- const compound = new oc.TopoDS_Compound();
166
- builder.MakeCompound(compound);
167
- for (const s of shapeArray) {
168
- builder.Add(compound, s.wrapped);
169
- }
170
- builder.delete();
171
- return createCompound(compound);
172
- }
173
- function makeSolid(facesOrShells) {
174
- const r = gcWithScope();
175
- const oc = getKernel().oc;
176
- const shell = weldShapes(facesOrShells);
177
- return andThen(cast(r(new oc.ShapeFix_Solid_1()).SolidFromShell(shell.wrapped)), (solid) => {
178
- if (!isSolid(solid))
179
- return err(typeCastError("SOLID_BUILD_FAILED", "Could not make a solid of faces and shells"));
180
- return ok(solid);
181
- });
182
- }
183
- const basicFaceExtrusion = (face, extrusionVec) => {
184
- const oc = getKernel().oc;
185
- const [r, gc] = localGC();
186
- const vec = toVec3(extrusionVec);
187
- const ocVec = r(new oc.gp_Vec_4(vec[0], vec[1], vec[2]));
188
- const solidBuilder = r(new oc.BRepPrimAPI_MakePrism_1(face.wrapped, ocVec, false, true));
189
- const solid = createSolid(unwrap(downcast(solidBuilder.Shape())));
190
- gc();
191
- return solid;
192
- };
193
- const revolution = (face, center = [0, 0, 0], direction = [0, 0, 1], angle = 360) => {
194
- const oc = getKernel().oc;
195
- const [r, gc] = localGC();
196
- const centerVec = toVec3(center);
197
- const directionVec = toVec3(direction);
198
- const ax = r(makeOcAx1(centerVec, directionVec));
199
- const revolBuilder = r(new oc.BRepPrimAPI_MakeRevol_1(face.wrapped, ax, angle * DEG2RAD, false));
200
- const result = andThen(cast(revolBuilder.Shape()), (shape) => {
201
- if (!isShape3D$1(shape))
202
- return err(typeCastError("REVOLUTION_NOT_3D", "Revolution did not produce a 3D shape"));
203
- return ok(shape);
204
- });
205
- gc();
206
- return result;
207
- };
208
- function genericSweep(wire, spine, {
209
- frenet = false,
210
- auxiliarySpine,
211
- law = null,
212
- transitionMode = "right",
213
- withContact,
214
- support,
215
- forceProfileSpineOthogonality,
216
- mode: sweepMode,
217
- tolerance,
218
- boundTolerance,
219
- angularTolerance,
220
- maxDegree,
221
- maxSegments
222
- } = {}, shellMode = false) {
223
- if (sweepMode === "simple" && !shellMode) {
224
- const kernel = getKernel();
225
- const resultOc = kernel.simplePipe(wire.wrapped, spine.wrapped);
226
- const result = andThen(cast(resultOc), (shape2) => {
227
- if (!isShape3D$1(shape2))
228
- return err(typeCastError("SWEEP_NOT_3D", "Simple pipe did not produce a 3D shape"));
229
- return ok(shape2);
230
- });
231
- return result;
232
- }
233
- const oc = getKernel().oc;
234
- const [r, gc] = localGC();
235
- const withCorrection = transitionMode === "round" ? true : !!forceProfileSpineOthogonality;
236
- const sweepBuilder = r(new oc.BRepOffsetAPI_MakePipeShell(spine.wrapped));
237
- if (tolerance !== void 0) {
238
- sweepBuilder.SetTolerance(tolerance, boundTolerance ?? tolerance, angularTolerance ?? 1e-7);
239
- }
240
- if (maxDegree !== void 0) {
241
- sweepBuilder.SetMaxDegree(maxDegree);
242
- }
243
- if (maxSegments !== void 0) {
244
- sweepBuilder.SetMaxSegments(maxSegments);
245
- }
246
- {
247
- const mode = {
248
- transformed: oc.BRepBuilderAPI_TransitionMode.BRepBuilderAPI_Transformed,
249
- round: oc.BRepBuilderAPI_TransitionMode.BRepBuilderAPI_RoundCorner,
250
- right: oc.BRepBuilderAPI_TransitionMode.BRepBuilderAPI_RightCorner
251
- }[transitionMode];
252
- if (mode) sweepBuilder.SetTransitionMode(mode);
253
- }
254
- if (support) {
255
- sweepBuilder.SetMode_4(support);
256
- } else if (frenet) {
257
- sweepBuilder.SetMode_1(frenet);
258
- }
259
- if (auxiliarySpine) {
260
- sweepBuilder.SetMode_5(
261
- auxiliarySpine.wrapped,
262
- false,
263
- oc.BRepFill_TypeOfContact.BRepFill_NoContact
264
- );
265
- }
266
- if (!law) sweepBuilder.Add_1(wire.wrapped, !!withContact, withCorrection);
267
- else sweepBuilder.SetLaw_1(wire.wrapped, law, !!withContact, withCorrection);
268
- const progress = r(new oc.Message_ProgressRange_1());
269
- sweepBuilder.Build(progress);
270
- if (!sweepBuilder.IsDone()) {
271
- gc();
272
- return err(occtError("SWEEP_FAILED", "Sweep operation failed"));
273
- }
274
- if (!shellMode) {
275
- sweepBuilder.MakeSolid();
276
- }
277
- const shape = unwrap(cast(sweepBuilder.Shape()));
278
- if (!isShape3D$1(shape)) {
279
- gc();
280
- return err(typeCastError("SWEEP_NOT_3D", "Sweep did not produce a 3D shape"));
281
- }
282
- if (shellMode) {
283
- const startWire = unwrap(cast(sweepBuilder.FirstShape()));
284
- const endWire = unwrap(cast(sweepBuilder.LastShape()));
285
- if (!isWire(startWire)) {
286
- gc();
287
- return err(typeCastError("SWEEP_START_NOT_WIRE", "Sweep did not produce a start Wire"));
288
- }
289
- if (!isWire(endWire)) {
290
- gc();
291
- return err(typeCastError("SWEEP_END_NOT_WIRE", "Sweep did not produce an end Wire"));
292
- }
293
- gc();
294
- return ok([shape, startWire, endWire]);
295
- }
296
- gc();
297
- return ok(shape);
298
- }
299
- function complexExtrude(wire, center, normal, profileShape, shellMode = false) {
300
- const [r, gc] = localGC();
301
- const centerVec = toVec3(center);
302
- const normalVec = toVec3(normal);
303
- const endVec = vecAdd(centerVec, normalVec);
304
- const mainSpineEdge = r(makeLine(centerVec, endVec));
305
- const spine = r(unwrap(assembleWire([mainSpineEdge])));
306
- const law = profileShape ? r(unwrap(buildLawFromProfile(vecLength(normalVec), profileShape))) : null;
307
- const result = shellMode ? genericSweep(wire, spine, { law }, shellMode) : genericSweep(wire, spine, { law });
308
- gc();
309
- return result;
310
- }
311
- function twistExtrude(wire, angleDegrees, center, normal, profileShape, shellMode = false) {
312
- const [r, gc] = localGC();
313
- const centerVec = toVec3(center);
314
- const normalVec = toVec3(normal);
315
- const endVec = vecAdd(centerVec, normalVec);
316
- const mainSpineEdge = r(makeLine(centerVec, endVec));
317
- const spine = r(unwrap(assembleWire([mainSpineEdge])));
318
- const extrusionLength = vecLength(normalVec);
319
- const pitch = 360 / angleDegrees * extrusionLength;
320
- const radius = 1;
321
- const auxiliarySpine = r(makeHelix(pitch, extrusionLength, radius, centerVec, normalVec));
322
- const law = profileShape ? r(unwrap(buildLawFromProfile(extrusionLength, profileShape))) : null;
323
- const result = shellMode ? genericSweep(wire, spine, { auxiliarySpine, law }, shellMode) : genericSweep(wire, spine, { auxiliarySpine, law });
324
- gc();
325
- return result;
326
- }
327
- const loft = (wires, { ruled = true, startPoint, endPoint } = {}, returnShell = false) => {
328
- if (wires.length === 0 && !startPoint && !endPoint) {
329
- return err(validationError("LOFT_EMPTY", "Loft requires at least one wire or start/end point"));
330
- }
331
- const oc = getKernel().oc;
332
- const [r, gc] = localGC();
333
- const loftBuilder = r(new oc.BRepOffsetAPI_ThruSections(!returnShell, ruled, 1e-6));
334
- if (startPoint) {
335
- loftBuilder.AddVertex(r(makeVertex(toVec3(startPoint))).wrapped);
336
- }
337
- wires.forEach((w) => loftBuilder.AddWire(w.wrapped));
338
- if (endPoint) {
339
- loftBuilder.AddVertex(r(makeVertex(toVec3(endPoint))).wrapped);
340
- }
341
- const progress = r(new oc.Message_ProgressRange_1());
342
- loftBuilder.Build(progress);
343
- if (!loftBuilder.IsDone()) {
344
- gc();
345
- return err(occtError("LOFT_FAILED", "Loft operation failed"));
346
- }
347
- const result = andThen(cast(loftBuilder.Shape()), (shape) => {
348
- if (!isShape3D$1(shape))
349
- return err(typeCastError("LOFT_NOT_3D", "Loft did not produce a 3D shape"));
350
- return ok(shape);
351
- });
352
- gc();
353
- return result;
354
- };
355
- export {
356
- makeSolid as a,
357
- basicFaceExtrusion as b,
358
- complexExtrude as c,
359
- makeCone as d,
360
- makeCylinder as e,
361
- makeEllipsoid as f,
362
- genericSweep as g,
363
- makeOffset as h,
364
- makeSphere as i,
365
- makeTorus as j,
366
- makeVertex as k,
367
- loft as l,
368
- makeCompound as m,
369
- buildLawFromProfile as n,
370
- revolution as r,
371
- twistExtrude as t,
372
- weldShellsAndFaces as w
373
- };
@@ -1,134 +0,0 @@
1
- "use strict";
2
- const occtBoundary = require("./occtBoundary-Cqfsau2c.cjs");
3
- const shapeTypes = require("./shapeTypes-CIijJxCz.cjs");
4
- const faceFns = require("./faceFns-CxaLWOjc.cjs");
5
- let cache = /* @__PURE__ */ new WeakMap();
6
- function getCachedMeasurement(shape, key) {
7
- return cache.get(shape)?.get(key);
8
- }
9
- function setCachedMeasurement(shape, key, value) {
10
- let map = cache.get(shape);
11
- if (!map) {
12
- map = /* @__PURE__ */ new Map();
13
- cache.set(shape, map);
14
- }
15
- map.set(key, value);
16
- }
17
- function assertShapeNotNull(shape, fn) {
18
- if (shape.wrapped.IsNull()) {
19
- throw new Error(`${fn}: shape is a null shape`);
20
- }
21
- }
22
- function measureVolumeProps(shape) {
23
- assertShapeNotNull(shape, "measureVolumeProps");
24
- const cached = getCachedMeasurement(shape.wrapped, "volume");
25
- if (cached) return cached;
26
- const oc = occtBoundary.getKernel().oc;
27
- const r = shapeTypes.gcWithScope();
28
- const props = r(new oc.GProp_GProps_1());
29
- oc.BRepGProp.VolumeProperties_1(shape.wrapped, props, false, false, false);
30
- const pnt = r(props.CentreOfMass());
31
- const m = props.Mass();
32
- const result = {
33
- mass: m,
34
- volume: m,
35
- centerOfMass: [pnt.X(), pnt.Y(), pnt.Z()]
36
- };
37
- setCachedMeasurement(shape.wrapped, "volume", result);
38
- return result;
39
- }
40
- function measureSurfaceProps(shape) {
41
- assertShapeNotNull(shape, "measureSurfaceProps");
42
- const cached = getCachedMeasurement(shape.wrapped, "surface");
43
- if (cached) return cached;
44
- const oc = occtBoundary.getKernel().oc;
45
- const r = shapeTypes.gcWithScope();
46
- const props = r(new oc.GProp_GProps_1());
47
- oc.BRepGProp.SurfaceProperties_1(shape.wrapped, props, false, false);
48
- const pnt = r(props.CentreOfMass());
49
- const m = props.Mass();
50
- const result = {
51
- mass: m,
52
- area: m,
53
- centerOfMass: [pnt.X(), pnt.Y(), pnt.Z()]
54
- };
55
- setCachedMeasurement(shape.wrapped, "surface", result);
56
- return result;
57
- }
58
- function measureLinearProps(shape) {
59
- assertShapeNotNull(shape, "measureLinearProps");
60
- const cached = getCachedMeasurement(shape.wrapped, "linear");
61
- if (cached) return cached;
62
- const oc = occtBoundary.getKernel().oc;
63
- const r = shapeTypes.gcWithScope();
64
- const props = r(new oc.GProp_GProps_1());
65
- oc.BRepGProp.LinearProperties(shape.wrapped, props, false, false);
66
- const pnt = r(props.CentreOfMass());
67
- const m = props.Mass();
68
- const result = {
69
- mass: m,
70
- length: m,
71
- centerOfMass: [pnt.X(), pnt.Y(), pnt.Z()]
72
- };
73
- setCachedMeasurement(shape.wrapped, "linear", result);
74
- return result;
75
- }
76
- function measureVolume(shape) {
77
- return measureVolumeProps(shape).mass;
78
- }
79
- function measureArea(shape) {
80
- return measureSurfaceProps(shape).mass;
81
- }
82
- function measureLength(shape) {
83
- return measureLinearProps(shape).mass;
84
- }
85
- function measureDistance(shape1, shape2) {
86
- assertShapeNotNull(shape1, "measureDistance");
87
- assertShapeNotNull(shape2, "measureDistance");
88
- return occtBoundary.getKernel().distance(shape1.wrapped, shape2.wrapped).value;
89
- }
90
- function createDistanceQuery(referenceShape) {
91
- assertShapeNotNull(referenceShape, "createDistanceQuery");
92
- const oc = occtBoundary.getKernel().oc;
93
- const distTool = new oc.BRepExtrema_DistShapeShape_1();
94
- distTool.LoadS1(referenceShape.wrapped);
95
- return {
96
- distanceTo(other) {
97
- assertShapeNotNull(other, "createDistanceQuery.distanceTo");
98
- distTool.LoadS2(other.wrapped);
99
- const progress = new oc.Message_ProgressRange_1();
100
- try {
101
- distTool.Perform(progress);
102
- return distTool.Value();
103
- } finally {
104
- progress.delete();
105
- }
106
- },
107
- dispose() {
108
- distTool.delete();
109
- }
110
- };
111
- }
112
- function measureCurvatureAt(face, u, v) {
113
- assertShapeNotNull(face, "measureCurvatureAt");
114
- const oc = occtBoundary.getKernel().oc;
115
- return occtBoundary.surfaceCurvature(oc, face.wrapped, u, v);
116
- }
117
- function measureCurvatureAtMid(face) {
118
- assertShapeNotNull(face, "measureCurvatureAtMid");
119
- const oc = occtBoundary.getKernel().oc;
120
- const bounds = faceFns.uvBounds(face);
121
- const uMid = (bounds.uMin + bounds.uMax) / 2;
122
- const vMid = (bounds.vMin + bounds.vMax) / 2;
123
- return occtBoundary.surfaceCurvature(oc, face.wrapped, uMid, vMid);
124
- }
125
- exports.createDistanceQuery = createDistanceQuery;
126
- exports.measureArea = measureArea;
127
- exports.measureCurvatureAt = measureCurvatureAt;
128
- exports.measureCurvatureAtMid = measureCurvatureAtMid;
129
- exports.measureDistance = measureDistance;
130
- exports.measureLength = measureLength;
131
- exports.measureLinearProps = measureLinearProps;
132
- exports.measureSurfaceProps = measureSurfaceProps;
133
- exports.measureVolume = measureVolume;
134
- exports.measureVolumeProps = measureVolumeProps;
@@ -1,135 +0,0 @@
1
- import { g as getKernel, s as surfaceCurvature } from "./occtBoundary-DvBywHyU.js";
2
- import { n as gcWithScope } from "./shapeTypes-DnwCo942.js";
3
- import { u as uvBounds } from "./faceFns-3PDjBeW7.js";
4
- let cache = /* @__PURE__ */ new WeakMap();
5
- function getCachedMeasurement(shape, key) {
6
- return cache.get(shape)?.get(key);
7
- }
8
- function setCachedMeasurement(shape, key, value) {
9
- let map = cache.get(shape);
10
- if (!map) {
11
- map = /* @__PURE__ */ new Map();
12
- cache.set(shape, map);
13
- }
14
- map.set(key, value);
15
- }
16
- function assertShapeNotNull(shape, fn) {
17
- if (shape.wrapped.IsNull()) {
18
- throw new Error(`${fn}: shape is a null shape`);
19
- }
20
- }
21
- function measureVolumeProps(shape) {
22
- assertShapeNotNull(shape, "measureVolumeProps");
23
- const cached = getCachedMeasurement(shape.wrapped, "volume");
24
- if (cached) return cached;
25
- const oc = getKernel().oc;
26
- const r = gcWithScope();
27
- const props = r(new oc.GProp_GProps_1());
28
- oc.BRepGProp.VolumeProperties_1(shape.wrapped, props, false, false, false);
29
- const pnt = r(props.CentreOfMass());
30
- const m = props.Mass();
31
- const result = {
32
- mass: m,
33
- volume: m,
34
- centerOfMass: [pnt.X(), pnt.Y(), pnt.Z()]
35
- };
36
- setCachedMeasurement(shape.wrapped, "volume", result);
37
- return result;
38
- }
39
- function measureSurfaceProps(shape) {
40
- assertShapeNotNull(shape, "measureSurfaceProps");
41
- const cached = getCachedMeasurement(shape.wrapped, "surface");
42
- if (cached) return cached;
43
- const oc = getKernel().oc;
44
- const r = gcWithScope();
45
- const props = r(new oc.GProp_GProps_1());
46
- oc.BRepGProp.SurfaceProperties_1(shape.wrapped, props, false, false);
47
- const pnt = r(props.CentreOfMass());
48
- const m = props.Mass();
49
- const result = {
50
- mass: m,
51
- area: m,
52
- centerOfMass: [pnt.X(), pnt.Y(), pnt.Z()]
53
- };
54
- setCachedMeasurement(shape.wrapped, "surface", result);
55
- return result;
56
- }
57
- function measureLinearProps(shape) {
58
- assertShapeNotNull(shape, "measureLinearProps");
59
- const cached = getCachedMeasurement(shape.wrapped, "linear");
60
- if (cached) return cached;
61
- const oc = getKernel().oc;
62
- const r = gcWithScope();
63
- const props = r(new oc.GProp_GProps_1());
64
- oc.BRepGProp.LinearProperties(shape.wrapped, props, false, false);
65
- const pnt = r(props.CentreOfMass());
66
- const m = props.Mass();
67
- const result = {
68
- mass: m,
69
- length: m,
70
- centerOfMass: [pnt.X(), pnt.Y(), pnt.Z()]
71
- };
72
- setCachedMeasurement(shape.wrapped, "linear", result);
73
- return result;
74
- }
75
- function measureVolume(shape) {
76
- return measureVolumeProps(shape).mass;
77
- }
78
- function measureArea(shape) {
79
- return measureSurfaceProps(shape).mass;
80
- }
81
- function measureLength(shape) {
82
- return measureLinearProps(shape).mass;
83
- }
84
- function measureDistance(shape1, shape2) {
85
- assertShapeNotNull(shape1, "measureDistance");
86
- assertShapeNotNull(shape2, "measureDistance");
87
- return getKernel().distance(shape1.wrapped, shape2.wrapped).value;
88
- }
89
- function createDistanceQuery(referenceShape) {
90
- assertShapeNotNull(referenceShape, "createDistanceQuery");
91
- const oc = getKernel().oc;
92
- const distTool = new oc.BRepExtrema_DistShapeShape_1();
93
- distTool.LoadS1(referenceShape.wrapped);
94
- return {
95
- distanceTo(other) {
96
- assertShapeNotNull(other, "createDistanceQuery.distanceTo");
97
- distTool.LoadS2(other.wrapped);
98
- const progress = new oc.Message_ProgressRange_1();
99
- try {
100
- distTool.Perform(progress);
101
- return distTool.Value();
102
- } finally {
103
- progress.delete();
104
- }
105
- },
106
- dispose() {
107
- distTool.delete();
108
- }
109
- };
110
- }
111
- function measureCurvatureAt(face, u, v) {
112
- assertShapeNotNull(face, "measureCurvatureAt");
113
- const oc = getKernel().oc;
114
- return surfaceCurvature(oc, face.wrapped, u, v);
115
- }
116
- function measureCurvatureAtMid(face) {
117
- assertShapeNotNull(face, "measureCurvatureAtMid");
118
- const oc = getKernel().oc;
119
- const bounds = uvBounds(face);
120
- const uMid = (bounds.uMin + bounds.uMax) / 2;
121
- const vMid = (bounds.vMin + bounds.vMax) / 2;
122
- return surfaceCurvature(oc, face.wrapped, uMid, vMid);
123
- }
124
- export {
125
- measureSurfaceProps as a,
126
- measureVolumeProps as b,
127
- measureVolume as c,
128
- createDistanceQuery as d,
129
- measureCurvatureAt as e,
130
- measureCurvatureAtMid as f,
131
- measureDistance as g,
132
- measureLength as h,
133
- measureLinearProps as i,
134
- measureArea as m
135
- };