brepjs 8.0.0 → 8.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (124) hide show
  1. package/dist/2d/blueprints/booleanHelpers.d.ts +32 -0
  2. package/dist/2d/blueprints/booleanHelpers.d.ts.map +1 -0
  3. package/dist/2d/blueprints/booleanOperations.d.ts +5 -3
  4. package/dist/2d/blueprints/booleanOperations.d.ts.map +1 -1
  5. package/dist/2d/blueprints/intersectionSegments.d.ts +12 -0
  6. package/dist/2d/blueprints/intersectionSegments.d.ts.map +1 -0
  7. package/dist/2d/blueprints/segmentAssembly.d.ts +31 -0
  8. package/dist/2d/blueprints/segmentAssembly.d.ts.map +1 -0
  9. package/dist/2d.cjs +2 -2
  10. package/dist/2d.js +8 -8
  11. package/dist/{Blueprint-D3JfGJTz.js → Blueprint-B9fhnpFp.js} +117 -30
  12. package/dist/{Blueprint-CVctc41Z.cjs → Blueprint-VGbo3izk.cjs} +111 -24
  13. package/dist/{boolean2D-BdZATaHs.cjs → boolean2D-B1XrGVgx.cjs} +426 -345
  14. package/dist/{boolean2D-hOw5Qay5.js → boolean2D-_WiqPxWZ.js} +391 -310
  15. package/dist/{booleanFns-BBSVKhL2.cjs → booleanFns-BxW-N3rP.cjs} +12 -16
  16. package/dist/{booleanFns-CqehfzcK.js → booleanFns-CkccZ7UL.js} +14 -18
  17. package/dist/brepjs.cjs +133 -62
  18. package/dist/brepjs.js +290 -217
  19. package/dist/{cast-DQaUibmm.js → cast-C4Ff_1Qe.js} +2 -2
  20. package/dist/{cast-DkB0GKmQ.cjs → cast-DIiyxDLo.cjs} +2 -2
  21. package/dist/core/disposal.d.ts +1 -1
  22. package/dist/core/disposal.d.ts.map +1 -1
  23. package/dist/core.cjs +3 -3
  24. package/dist/core.js +3 -3
  25. package/dist/cornerFinder-BndBNtJE.cjs +58 -0
  26. package/dist/cornerFinder-DzGzfiqb.js +59 -0
  27. package/dist/curveBuilders-BUoFO1UG.cjs +196 -0
  28. package/dist/curveBuilders-CBlIWlbU.js +197 -0
  29. package/dist/{curveFns-BilyYL_s.cjs → curveFns-BrJDkaWi.cjs} +31 -44
  30. package/dist/{curveFns-CdVE4da7.js → curveFns-BshHA9Ys.js} +31 -44
  31. package/dist/{drawFns-921SkhDL.js → drawFns-Btmlh_Oz.js} +13 -14
  32. package/dist/{drawFns-CUyx50gi.cjs → drawFns-D2eDcf4k.cjs} +58 -59
  33. package/dist/{faceFns-DHu-2JpA.js → faceFns-DDzCECn3.js} +3 -3
  34. package/dist/{faceFns-BwK7FP7N.cjs → faceFns-NDRFeekj.cjs} +3 -3
  35. package/dist/helpers-Ck8GJ58k.cjs +203 -0
  36. package/dist/helpers-jku2V1DY.js +204 -0
  37. package/dist/io.cjs +4 -4
  38. package/dist/io.js +4 -4
  39. package/dist/kernel/occtAdapter.d.ts +1 -0
  40. package/dist/kernel/occtAdapter.d.ts.map +1 -1
  41. package/dist/kernel/sweepOps.d.ts +8 -0
  42. package/dist/kernel/sweepOps.d.ts.map +1 -1
  43. package/dist/kernel/types.d.ts +1 -0
  44. package/dist/kernel/types.d.ts.map +1 -1
  45. package/dist/loft-Bk9EM0gZ.js +373 -0
  46. package/dist/loft-DJXwxV_L.cjs +372 -0
  47. package/dist/{measurement-C5JGCuUP.js → measurement-DlXaTzKc.js} +3 -3
  48. package/dist/{measurement-fxm_pW7x.cjs → measurement-LcGh4wV0.cjs} +3 -3
  49. package/dist/measurement.cjs +1 -1
  50. package/dist/measurement.js +1 -1
  51. package/dist/{meshFns-AqAjTTVl.js → meshFns-Djzdn-CS.js} +1 -1
  52. package/dist/{meshFns-BhrZGi6w.cjs → meshFns-c8lDKfYy.cjs} +1 -1
  53. package/dist/{occtBoundary-du8_ex-p.cjs → occtBoundary-6kQSl3cF.cjs} +21 -0
  54. package/dist/{occtBoundary-CwegMzqc.js → occtBoundary-CqXvDhZY.js} +26 -5
  55. package/dist/operations/extrude.d.ts.map +1 -1
  56. package/dist/operations/extrudeFns.d.ts.map +1 -1
  57. package/dist/operations/extrudeUtils.d.ts +17 -0
  58. package/dist/operations/extrudeUtils.d.ts.map +1 -1
  59. package/dist/{operations-C1rWoba2.js → operations-CrQlFDHc.js} +30 -7
  60. package/dist/{operations-BP1wVDw0.cjs → operations-Do-WZGXc.cjs} +30 -7
  61. package/dist/operations.cjs +2 -2
  62. package/dist/operations.js +4 -4
  63. package/dist/query/cornerFinder.d.ts +48 -0
  64. package/dist/query/cornerFinder.d.ts.map +1 -0
  65. package/dist/query/directionUtils.d.ts +6 -0
  66. package/dist/query/directionUtils.d.ts.map +1 -0
  67. package/dist/query/edgeFinder.d.ts +15 -0
  68. package/dist/query/edgeFinder.d.ts.map +1 -0
  69. package/dist/query/faceFinder.d.ts +15 -0
  70. package/dist/query/faceFinder.d.ts.map +1 -0
  71. package/dist/query/finderCore.d.ts +35 -0
  72. package/dist/query/finderCore.d.ts.map +1 -0
  73. package/dist/query/finderFns.d.ts +21 -106
  74. package/dist/query/finderFns.d.ts.map +1 -1
  75. package/dist/query/shapeDistanceFilter.d.ts +11 -0
  76. package/dist/query/shapeDistanceFilter.d.ts.map +1 -0
  77. package/dist/query/vertexFinder.d.ts +16 -0
  78. package/dist/query/vertexFinder.d.ts.map +1 -0
  79. package/dist/query/wireFinder.d.ts +10 -0
  80. package/dist/query/wireFinder.d.ts.map +1 -0
  81. package/dist/query.cjs +42 -5
  82. package/dist/query.js +40 -2
  83. package/dist/{shapeFns-BrF97sKt.js → shapeFns-DQtpzndX.js} +17 -18
  84. package/dist/{shapeFns-BvOndshS.cjs → shapeFns-cN4qGpbO.cjs} +6 -7
  85. package/dist/{shapeTypes-DKhwEnUM.cjs → shapeTypes-BJ3Hmskg.cjs} +24 -20
  86. package/dist/{shapeTypes-BlSElW8z.js → shapeTypes-C9sUsmEW.js} +32 -28
  87. package/dist/sketching/Sketcher.d.ts.map +1 -1
  88. package/dist/sketching/Sketcher2d.d.ts +12 -4
  89. package/dist/sketching/Sketcher2d.d.ts.map +1 -1
  90. package/dist/sketching/ellipseUtils.d.ts +29 -0
  91. package/dist/sketching/ellipseUtils.d.ts.map +1 -0
  92. package/dist/sketching.cjs +2 -2
  93. package/dist/sketching.js +2 -2
  94. package/dist/topology/booleanFns.d.ts.map +1 -1
  95. package/dist/topology/curveBuilders.d.ts +75 -0
  96. package/dist/topology/curveBuilders.d.ts.map +1 -0
  97. package/dist/topology/curveFns.d.ts.map +1 -1
  98. package/dist/topology/primitiveFns.d.ts.map +1 -1
  99. package/dist/topology/shapeFns.d.ts.map +1 -1
  100. package/dist/topology/shapeHelpers.d.ts +6 -173
  101. package/dist/topology/shapeHelpers.d.ts.map +1 -1
  102. package/dist/topology/shapeUtils.d.ts +13 -0
  103. package/dist/topology/shapeUtils.d.ts.map +1 -0
  104. package/dist/topology/solidBuilders.d.ts +70 -0
  105. package/dist/topology/solidBuilders.d.ts.map +1 -0
  106. package/dist/topology/surfaceBuilders.d.ts +35 -0
  107. package/dist/topology/surfaceBuilders.d.ts.map +1 -0
  108. package/dist/topology/wrapperFns.d.ts +1 -0
  109. package/dist/topology/wrapperFns.d.ts.map +1 -1
  110. package/dist/{topology-tFzqSrGH.js → topology-CtfUZwLR.js} +8 -8
  111. package/dist/{topology-CIooytHH.cjs → topology-DXq8dLsi.cjs} +8 -8
  112. package/dist/topology.cjs +7 -7
  113. package/dist/topology.js +31 -31
  114. package/dist/{vectors-CBuaMeZv.js → vectors-BVgXsYWl.js} +1 -1
  115. package/dist/{vectors-ChWEZPwy.cjs → vectors-DK2hEKcI.cjs} +1 -1
  116. package/dist/vectors.cjs +2 -2
  117. package/dist/vectors.js +2 -2
  118. package/package.json +1 -1
  119. package/dist/loft-BzWFokmC.cjs +0 -178
  120. package/dist/loft-CtG5nMq5.js +0 -179
  121. package/dist/query-V6nV-VfL.js +0 -396
  122. package/dist/query-hMSmOWJP.cjs +0 -395
  123. package/dist/shapeHelpers-B2SXz1p4.cjs +0 -488
  124. package/dist/shapeHelpers-BcoZf2N9.js +0 -489
@@ -1,20 +1,21 @@
1
1
  "use strict";
2
2
  const errors = require("./errors-DK1VAdP4.cjs");
3
- const shapeHelpers = require("./shapeHelpers-B2SXz1p4.cjs");
4
- const vectors = require("./vectors-ChWEZPwy.cjs");
5
- const occtBoundary = require("./occtBoundary-du8_ex-p.cjs");
3
+ const vectors = require("./vectors-DK2hEKcI.cjs");
4
+ const occtBoundary = require("./occtBoundary-6kQSl3cF.cjs");
6
5
  const vecOps = require("./vecOps-CjRL1jau.cjs");
7
- const boolean2D = require("./boolean2D-BdZATaHs.cjs");
8
- const faceFns = require("./faceFns-BwK7FP7N.cjs");
9
- const curveFns = require("./curveFns-BilyYL_s.cjs");
10
- const shapeTypes = require("./shapeTypes-DKhwEnUM.cjs");
11
- const cast = require("./cast-DkB0GKmQ.cjs");
12
- const Blueprint = require("./Blueprint-CVctc41Z.cjs");
6
+ const boolean2D = require("./boolean2D-B1XrGVgx.cjs");
7
+ const faceFns = require("./faceFns-NDRFeekj.cjs");
8
+ const curveFns = require("./curveFns-BrJDkaWi.cjs");
9
+ const curveBuilders = require("./curveBuilders-BUoFO1UG.cjs");
10
+ const shapeTypes = require("./shapeTypes-BJ3Hmskg.cjs");
11
+ const cast = require("./cast-DIiyxDLo.cjs");
12
+ const Blueprint = require("./Blueprint-VGbo3izk.cjs");
13
13
  const result = require("./result.cjs");
14
- const query = require("./query-hMSmOWJP.cjs");
15
- const shapeFns = require("./shapeFns-BvOndshS.cjs");
16
- const loft = require("./loft-BzWFokmC.cjs");
14
+ const helpers = require("./helpers-Ck8GJ58k.cjs");
15
+ const shapeFns = require("./shapeFns-cN4qGpbO.cjs");
16
+ const loft = require("./loft-DJXwxV_L.cjs");
17
17
  const opentype = require("opentype.js");
18
+ const cornerFinder = require("./cornerFinder-BndBNtJE.cjs");
18
19
  const stitchCurves = (curves, precision = 1e-7) => {
19
20
  const startPoints = new boolean2D.Flatbush(curves.length);
20
21
  curves.forEach((c) => {
@@ -97,7 +98,7 @@ class Sketcher {
97
98
  /** Draw a straight line to an absolute 2D point on the sketch plane. */
98
99
  lineTo([x, y]) {
99
100
  const endPoint = vectors.planeToWorld(this.plane, [x, y]);
100
- this.pendingEdges.push(shapeHelpers.makeLine(this.pointer, endPoint));
101
+ this.pendingEdges.push(curveBuilders.makeLine(this.pointer, endPoint));
101
102
  this._updatePointer(endPoint);
102
103
  return this;
103
104
  }
@@ -127,13 +128,13 @@ class Sketcher {
127
128
  /** Draw a line in polar coordinates (distance and angle in degrees) from the current point. */
128
129
  polarLine(distance, angle) {
129
130
  const angleInRads = angle * vecOps.DEG2RAD;
130
- const [x, y] = query.polarToCartesian(distance, angleInRads);
131
+ const [x, y] = helpers.polarToCartesian(distance, angleInRads);
131
132
  return this.line(x, y);
132
133
  }
133
134
  /** Draw a line to a point given in polar coordinates [r, theta] from the origin. */
134
135
  polarLineTo([r, theta]) {
135
136
  const angleInRads = theta * vecOps.DEG2RAD;
136
- const point = query.polarToCartesian(r, angleInRads);
137
+ const point = helpers.polarToCartesian(r, angleInRads);
137
138
  return this.lineTo(point);
138
139
  }
139
140
  /** Draw a line tangent to the previous edge, extending by the given distance. */
@@ -144,7 +145,7 @@ class Sketcher {
144
145
  const tangent = curveFns.curveTangentAt(previousEdge, 1);
145
146
  const scaledTangent = vecOps.vecScale(vecOps.vecNormalize(tangent), distance);
146
147
  const endPoint = vecOps.vecAdd(scaledTangent, this.pointer);
147
- this.pendingEdges.push(shapeHelpers.makeLine(this.pointer, endPoint));
148
+ this.pendingEdges.push(curveBuilders.makeLine(this.pointer, endPoint));
148
149
  this._updatePointer(endPoint);
149
150
  return this;
150
151
  }
@@ -152,7 +153,7 @@ class Sketcher {
152
153
  threePointsArcTo(end, innerPoint) {
153
154
  const gpoint1 = vectors.planeToWorld(this.plane, innerPoint);
154
155
  const gpoint2 = vectors.planeToWorld(this.plane, end);
155
- this.pendingEdges.push(shapeHelpers.makeThreePointArc(this.pointer, gpoint1, gpoint2));
156
+ this.pendingEdges.push(curveBuilders.makeThreePointArc(this.pointer, gpoint1, gpoint2));
156
157
  this._updatePointer(gpoint2);
157
158
  return this;
158
159
  }
@@ -169,7 +170,7 @@ class Sketcher {
169
170
  result.bug("Sketcher.tangentArcTo", "You need a previous edge to create a tangent arc");
170
171
  const prevEnd = curveFns.curveEndPoint(previousEdge);
171
172
  const prevTangent = curveFns.curveTangentAt(previousEdge, 1);
172
- this.pendingEdges.push(shapeHelpers.makeTangentArc(prevEnd, prevTangent, endPoint));
173
+ this.pendingEdges.push(curveBuilders.makeTangentArc(prevEnd, prevTangent, endPoint));
173
174
  this._updatePointer(endPoint);
174
175
  return this;
175
176
  }
@@ -189,7 +190,7 @@ class Sketcher {
189
190
  const sagDirection = vecOps.vecNormalize(crossResult);
190
191
  const sagVector = vecOps.vecScale(sagDirection, sagitta);
191
192
  const sagPoint = vecOps.vecAdd(midPoint, sagVector);
192
- this.pendingEdges.push(shapeHelpers.makeThreePointArc(this.pointer, sagPoint, endPoint));
193
+ this.pendingEdges.push(curveBuilders.makeThreePointArc(this.pointer, sagPoint, endPoint));
193
194
  this._updatePointer(endPoint);
194
195
  return this;
195
196
  }
@@ -210,7 +211,7 @@ class Sketcher {
210
211
  bulgeArcTo(end, bulge) {
211
212
  if (!bulge) return this.lineTo(end);
212
213
  const [px, py] = vectors.planeToLocal(this.plane, this.pointer);
213
- const halfChord = query.distance2d([px, py], end) / 2;
214
+ const halfChord = helpers.distance2d([px, py], end) / 2;
214
215
  const bulgeAsSagitta = -bulge * halfChord;
215
216
  return this.sagittaArcTo(end, bulgeAsSagitta);
216
217
  }
@@ -229,7 +230,6 @@ class Sketcher {
229
230
  }
230
231
  /** Draw an elliptical arc to an absolute end point (SVG-style parameters). */
231
232
  ellipseTo(end, horizontalRadius, verticalRadius, rotation = 0, longAxis = false, sweep = false) {
232
- const [, gc] = shapeTypes.localGC();
233
233
  const [startX, startY] = vectors.planeToLocal(this.plane, this.pointer);
234
234
  let rotationAngle = rotation;
235
235
  let majorRadius = horizontalRadius;
@@ -250,7 +250,7 @@ class Sketcher {
250
250
  );
251
251
  const xDir = vecOps.vecRotate(this.plane.xDir, this.plane.zDir, rotationAngle * vecOps.DEG2RAD);
252
252
  const arc = errors.unwrap(
253
- shapeHelpers.makeEllipseArc(
253
+ curveBuilders.makeEllipseArc(
254
254
  rx,
255
255
  ry,
256
256
  clockwise ? startAngle : endAngle,
@@ -265,7 +265,6 @@ class Sketcher {
265
265
  }
266
266
  this.pendingEdges.push(arc);
267
267
  this._updatePointer(vectors.planeToWorld(this.plane, end));
268
- gc();
269
268
  return this;
270
269
  }
271
270
  /** Draw an elliptical arc to a relative end point (SVG-style parameters). */
@@ -284,8 +283,8 @@ class Sketcher {
284
283
  halfEllipseTo(end, verticalRadius, sweep = false) {
285
284
  const [px, py] = vectors.planeToLocal(this.plane, this.pointer);
286
285
  const start = [px, py];
287
- const angle = query.polarAngle2d(end, start);
288
- const distance = query.distance2d(end, start);
286
+ const angle = helpers.polarAngle2d(end, start);
287
+ const distance = helpers.distance2d(end, start);
289
288
  return this.ellipseTo(end, distance / 2, verticalRadius, angle * vecOps.RAD2DEG, false, sweep);
290
289
  }
291
290
  /** Draw a half-ellipse arc to a relative end point with a given minor radius. */
@@ -303,7 +302,7 @@ class Sketcher {
303
302
  }
304
303
  const inWorldPoints = cp.map((p) => vectors.planeToWorld(this.plane, p));
305
304
  const endPoint = vectors.planeToWorld(this.plane, end);
306
- this.pendingEdges.push(errors.unwrap(shapeHelpers.makeBezierCurve([this.pointer, ...inWorldPoints, endPoint])));
305
+ this.pendingEdges.push(errors.unwrap(curveBuilders.makeBezierCurve([this.pointer, ...inWorldPoints, endPoint])));
307
306
  this._updatePointer(endPoint);
308
307
  return this;
309
308
  }
@@ -352,7 +351,7 @@ class Sketcher {
352
351
  const endPoleDistance = vecOps.vecScale(vecOps.vecNormalize(endPoleDirection), endFactor * defaultDistance);
353
352
  const endControl = vecOps.vecSub(endPoint, endPoleDistance);
354
353
  this.pendingEdges.push(
355
- errors.unwrap(shapeHelpers.makeBezierCurve([this.pointer, startControl, endControl, endPoint]))
354
+ errors.unwrap(curveBuilders.makeBezierCurve([this.pointer, startControl, endControl, endPoint]))
356
355
  );
357
356
  this._updatePointer(endPoint);
358
357
  return this;
@@ -373,12 +372,12 @@ class Sketcher {
373
372
  const mirroredRaw = Blueprint.mirror(clonedWrapped, normal, this.pointer);
374
373
  const mirroredWrapped = errors.unwrap(cast.downcast(mirroredRaw));
375
374
  const mirroredWire = shapeTypes.createWire(mirroredWrapped);
376
- const combinedWire = errors.unwrap(shapeHelpers.assembleWire([wire, mirroredWire]));
375
+ const combinedWire = errors.unwrap(curveBuilders.assembleWire([wire, mirroredWire]));
377
376
  return combinedWire;
378
377
  }
379
378
  buildWire() {
380
379
  if (!this.pendingEdges.length) result.bug("Sketcher.buildWire", "No lines to convert into a wire");
381
- let wire = errors.unwrap(shapeHelpers.assembleWire(this.pendingEdges));
380
+ let wire = errors.unwrap(curveBuilders.assembleWire(this.pendingEdges));
382
381
  if (this._mirrorWire) {
383
382
  wire = this._mirrorWireOnStartEnd(wire);
384
383
  }
@@ -440,7 +439,7 @@ const fixWire = (wire, baseFace) => {
440
439
  const faceFromWires = (wires) => {
441
440
  let baseFace;
442
441
  let holeWires;
443
- const faceResult = shapeHelpers.makeFace(wires[0]);
442
+ const faceResult = Blueprint.makeFace(wires[0]);
444
443
  if (errors.isOk(faceResult)) {
445
444
  baseFace = faceResult.value;
446
445
  holeWires = wires.slice(1);
@@ -448,7 +447,7 @@ const faceFromWires = (wires) => {
448
447
  baseFace = guessFaceFromWires(wires);
449
448
  holeWires = wires.slice(1).map((w) => fixWire(w, baseFace));
450
449
  }
451
- return shapeHelpers.addHolesInFace(baseFace, holeWires);
450
+ return Blueprint.addHolesInFace(baseFace, holeWires);
452
451
  };
453
452
  const solidFromShellGenerator = (sketches, shellGenerator) => {
454
453
  const shells = [];
@@ -462,7 +461,7 @@ const solidFromShellGenerator = (sketches, shellGenerator) => {
462
461
  });
463
462
  const startFace = faceFromWires(startWires);
464
463
  const endFace = faceFromWires(endWires);
465
- const solid = errors.unwrap(shapeHelpers.makeSolid([startFace, ...shells, endFace]));
464
+ const solid = errors.unwrap(loft.makeSolid([startFace, ...shells, endFace]));
466
465
  return solid;
467
466
  };
468
467
  class CompoundSketch {
@@ -490,12 +489,12 @@ class CompoundSketch {
490
489
  /** Return all wires (outer + holes) combined into a compound shape. */
491
490
  get wires() {
492
491
  const wires = this.sketches.map((s) => s.wire);
493
- return shapeHelpers.makeCompound(wires);
492
+ return loft.makeCompound(wires);
494
493
  }
495
494
  /** Build a face from the outer boundary with inner wires subtracted as holes. */
496
495
  face() {
497
496
  const baseFace = this.outerSketch.face();
498
- const newFace = shapeHelpers.addHolesInFace(
497
+ const newFace = Blueprint.addHolesInFace(
499
498
  baseFace,
500
499
  this.innerSketches.map((s) => s.wire)
501
500
  );
@@ -574,7 +573,7 @@ class CompoundSketch {
574
573
  const baseFaceRaw = this.face();
575
574
  const baseFace = shapeTypes.createFace(errors.unwrap(cast.downcast(baseFaceRaw.wrapped)));
576
575
  shells.push(baseFace, otherCompound.face());
577
- return errors.unwrap(shapeHelpers.makeSolid(shells));
576
+ return errors.unwrap(loft.makeSolid(shells));
578
577
  }
579
578
  }
580
579
  class Sketches {
@@ -585,12 +584,12 @@ class Sketches {
585
584
  /** Return all wires combined into a single compound shape. */
586
585
  wires() {
587
586
  const wires = this.sketches.map((s) => s instanceof boolean2D.Sketch ? s.wire : s.wires);
588
- return shapeHelpers.makeCompound(wires);
587
+ return loft.makeCompound(wires);
589
588
  }
590
589
  /** Return all sketch faces combined into a single compound shape. */
591
590
  faces() {
592
591
  const faces = this.sketches.map((s) => s.face());
593
- return shapeHelpers.makeCompound(faces);
592
+ return loft.makeCompound(faces);
594
593
  }
595
594
  /** Extrudes the sketch to a certain distance (along the default direction
596
595
  * and origin of the sketch).
@@ -604,19 +603,19 @@ class Sketches {
604
603
  */
605
604
  extrude(extrusionDistance, extrusionConfig = {}) {
606
605
  const extruded = this.sketches.map((s) => s.extrude(extrusionDistance, extrusionConfig));
607
- return shapeHelpers.makeCompound(extruded);
606
+ return loft.makeCompound(extruded);
608
607
  }
609
608
  /**
610
609
  * Revolves the drawing on an axis (defined by its direction and an origin
611
610
  * (defaults to the sketch origin)
612
611
  */
613
612
  revolve(revolutionAxis, config) {
614
- return shapeHelpers.makeCompound(this.sketches.map((s) => s.revolve(revolutionAxis, config)));
613
+ return loft.makeCompound(this.sketches.map((s) => s.revolve(revolutionAxis, config)));
615
614
  }
616
615
  }
617
616
  const sketchCircle = (radius, planeConfig = {}) => {
618
617
  const plane = planeConfig.plane && typeof planeConfig.plane !== "string" ? { ...planeConfig.plane } : vectors.resolvePlane(planeConfig.plane ?? "XY", planeConfig.origin);
619
- const wire = errors.unwrap(shapeHelpers.assembleWire([shapeHelpers.makeCircle(radius, plane.origin, plane.zDir)]));
618
+ const wire = errors.unwrap(curveBuilders.assembleWire([curveBuilders.makeCircle(radius, plane.origin, plane.zDir)]));
620
619
  const sketch = new boolean2D.Sketch(wire, {
621
620
  defaultOrigin: [...plane.origin],
622
621
  defaultDirection: [...plane.zDir]
@@ -634,7 +633,7 @@ const sketchEllipse = (xRadius = 1, yRadius = 2, planeConfig = {}) => {
634
633
  minR = xRadius;
635
634
  }
636
635
  const wire = errors.unwrap(
637
- shapeHelpers.assembleWire([errors.unwrap(shapeHelpers.makeEllipse(majR, minR, plane.origin, plane.zDir, xDir))])
636
+ curveBuilders.assembleWire([errors.unwrap(curveBuilders.makeEllipse(majR, minR, plane.origin, plane.zDir, xDir))])
638
637
  );
639
638
  const sketch = new boolean2D.Sketch(wire, {
640
639
  defaultOrigin: [...plane.origin],
@@ -696,7 +695,7 @@ const sketchParametricFunction = (func, planeConfig = {}, { pointsCount = 400, s
696
695
  return vectors.planeToWorld(plane, point);
697
696
  });
698
697
  const wire = errors.unwrap(
699
- shapeHelpers.assembleWire([r(errors.unwrap(shapeHelpers.makeBSplineApproximation(points, approximationConfig)))])
698
+ curveBuilders.assembleWire([r(errors.unwrap(curveBuilders.makeBSplineApproximation(points, approximationConfig)))])
700
699
  );
701
700
  const sketch = new boolean2D.Sketch(wire, {
702
701
  defaultOrigin: [...plane.origin],
@@ -709,13 +708,13 @@ const sketchHelix = (pitch, height, radius, center = [0, 0, 0], dir = [0, 0, 1],
709
708
  const centerVec3 = occtBoundary.toVec3(center);
710
709
  const dirVec3 = occtBoundary.toVec3(dir);
711
710
  return new boolean2D.Sketch(
712
- errors.unwrap(shapeHelpers.assembleWire([shapeHelpers.makeHelix(pitch, height, radius, centerVec3, dirVec3, lefthand)]))
711
+ errors.unwrap(curveBuilders.assembleWire([curveBuilders.makeHelix(pitch, height, radius, centerVec3, dirVec3, lefthand)]))
713
712
  );
714
713
  };
715
714
  const makeBaseBox = (xLength, yLength, zLength) => {
716
715
  return new Sketcher().movePointerTo([-xLength / 2, yLength / 2]).hLine(xLength).vLine(-yLength).hLine(-xLength).close().extrude(zLength);
717
716
  };
718
- const samePoint = (x, y) => query.samePoint(x, y, query.PRECISION_OFFSET * 10);
717
+ const samePoint = (x, y) => helpers.samePoint(x, y, helpers.PRECISION_OFFSET * 10);
719
718
  const getIntersectionPoint = (line1Start, line1End, line2Start, line2End) => {
720
719
  const dx1 = line1Start[0] - line1End[0];
721
720
  const dy1 = line1Start[1] - line1End[1];
@@ -744,8 +743,8 @@ function joinBevel(appendCurve, previousLastPoint, firstPoint, previousCurve, _c
744
743
  appendCurve(bevelJoiner);
745
744
  }
746
745
  function joinMiter(appendCurve, previousLastPoint, firstPoint, previousCurve, curve) {
747
- const previousOtherPoint = previousCurve.offset instanceof Blueprint.Curve2D ? query.subtract2d(previousLastPoint, previousCurve.offset.tangentAt(1)) : previousCurve.offset.firstPoint;
748
- const nextOtherPoint = curve.offset instanceof Blueprint.Curve2D ? query.add2d(firstPoint, curve.offset.tangentAt(0)) : curve.offset.lastPoint;
746
+ const previousOtherPoint = previousCurve.offset instanceof Blueprint.Curve2D ? helpers.subtract2d(previousLastPoint, previousCurve.offset.tangentAt(1)) : previousCurve.offset.firstPoint;
747
+ const nextOtherPoint = curve.offset instanceof Blueprint.Curve2D ? helpers.add2d(firstPoint, curve.offset.tangentAt(0)) : curve.offset.lastPoint;
749
748
  const offsetIntersectionPoint = getIntersectionPoint(
750
749
  previousOtherPoint,
751
750
  previousLastPoint,
@@ -810,7 +809,7 @@ function rawOffsets(blueprint, offset2, offsetConfig = {}) {
810
809
  let intersections = [];
811
810
  if (previousCurve.offset instanceof Blueprint.Curve2D && curve.offset instanceof Blueprint.Curve2D) {
812
811
  const { intersections: pointIntersections, commonSegmentsPoints } = errors.unwrap(
813
- boolean2D.intersectCurves(previousCurve.offset, curve.offset, query.PRECISION_OFFSET / 100)
812
+ boolean2D.intersectCurves(previousCurve.offset, curve.offset, helpers.PRECISION_OFFSET / 100)
814
813
  );
815
814
  intersections = [...pointIntersections, ...commonSegmentsPoints];
816
815
  }
@@ -818,10 +817,10 @@ function rawOffsets(blueprint, offset2, offsetConfig = {}) {
818
817
  let intersection = intersections[0];
819
818
  if (intersections.length > 1) {
820
819
  const originalEndpoint = previousCurve.original.lastPoint;
821
- let minDist = query.squareDistance2d(intersection, originalEndpoint);
820
+ let minDist = helpers.squareDistance2d(intersection, originalEndpoint);
822
821
  for (let i = 1; i < intersections.length; i++) {
823
822
  const point = intersections[i];
824
- const d = query.squareDistance2d(point, originalEndpoint);
823
+ const d = helpers.squareDistance2d(point, originalEndpoint);
825
824
  if (d < minDist) {
826
825
  minDist = d;
827
826
  intersection = point;
@@ -830,9 +829,9 @@ function rawOffsets(blueprint, offset2, offsetConfig = {}) {
830
829
  }
831
830
  const splitPreviousCurve = previousCurve.offset.splitAt(
832
831
  [intersection],
833
- query.PRECISION_OFFSET
832
+ helpers.PRECISION_OFFSET
834
833
  )[0];
835
- const splitCurve = curve.offset.splitAt([intersection], query.PRECISION_OFFSET).at(-1);
834
+ const splitCurve = curve.offset.splitAt([intersection], helpers.PRECISION_OFFSET).at(-1);
836
835
  if (!splitCurve) result.bug("offset.rawOffsets", "Split produced no trailing curve segment");
837
836
  appendCurve({
838
837
  offset: splitPreviousCurve,
@@ -873,7 +872,7 @@ function offsetBlueprint(blueprint, offset2, offsetConfig = {}) {
873
872
  testedPairs.add(pairKey);
874
873
  const secondCurve = offsettedArray[secondIndex];
875
874
  const { intersections: rawIntersections, commonSegmentsPoints } = errors.unwrap(
876
- boolean2D.intersectCurves(firstCurve, secondCurve, query.PRECISION_OFFSET)
875
+ boolean2D.intersectCurves(firstCurve, secondCurve, helpers.PRECISION_OFFSET)
877
876
  );
878
877
  const intersections = [...rawIntersections, ...commonSegmentsPoints].filter(
879
878
  (intersection) => {
@@ -895,12 +894,12 @@ function offsetBlueprint(blueprint, offset2, offsetConfig = {}) {
895
894
  const splitCurves = offsettedArray.flatMap((curve, index) => {
896
895
  if (!allIntersections.has(index)) return curve;
897
896
  const intersections = allIntersections.get(index) || [];
898
- const splitCurves2 = curve.splitAt(intersections, query.PRECISION_OFFSET * 100);
897
+ const splitCurves2 = curve.splitAt(intersections, helpers.PRECISION_OFFSET * 100);
899
898
  return splitCurves2;
900
899
  });
901
900
  const prunedCurves = splitCurves.filter((curve) => {
902
901
  const closeCurve = blueprint.curves.find(
903
- (c) => c.distanceFrom(curve) < Math.abs(offset2) - query.PRECISION_OFFSET
902
+ (c) => c.distanceFrom(curve) < Math.abs(offset2) - helpers.PRECISION_OFFSET
904
903
  );
905
904
  return !closeCurve;
906
905
  });
@@ -971,7 +970,7 @@ function modifyCorners(makeCorner, blueprint, radius, finder) {
971
970
  result.bug("customCorners.modifyCorners", "Unexpected empty curve list during corner modification");
972
971
  if (
973
972
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
974
- query.samePoint(curves[0].firstPoint, lastCurve.lastPoint) && curves.length > 1
973
+ helpers.samePoint(curves[0].firstPoint, lastCurve.lastPoint) && curves.length > 1
975
974
  ) {
976
975
  const firstCurve = curves.pop();
977
976
  const secondCurve = curves.shift();
@@ -1302,7 +1301,7 @@ class Drawing {
1302
1301
  * @category Drawing Modifications
1303
1302
  */
1304
1303
  fillet(radius, filter) {
1305
- const finder = filter && filter(query.cornerFinder());
1304
+ const finder = filter && filter(cornerFinder.cornerFinder());
1306
1305
  return new Drawing(fillet2D(this.innerShape, radius, finder));
1307
1306
  }
1308
1307
  /**
@@ -1312,7 +1311,7 @@ class Drawing {
1312
1311
  * @category Drawing Modifications
1313
1312
  */
1314
1313
  chamfer(radius, filter) {
1315
- const finder = filter && filter(query.cornerFinder());
1314
+ const finder = filter && filter(cornerFinder.cornerFinder());
1316
1315
  return new Drawing(chamfer2D(this.innerShape, radius, finder));
1317
1316
  }
1318
1317
  sketchOnPlane(inputPlane, origin) {
@@ -1459,7 +1458,7 @@ const drawPointsInterpolation = (points, approximationConfig = {}, options = {})
1459
1458
  const curves = [errors.unwrap(Blueprint.make2dInerpolatedBSplineCurve(points, approximationConfig))];
1460
1459
  const firstPoint = points[0];
1461
1460
  const lastPoint = points[points.length - 1];
1462
- if (options.closeShape && firstPoint && lastPoint && !query.samePoint(firstPoint, lastPoint)) {
1461
+ if (options.closeShape && firstPoint && lastPoint && !helpers.samePoint(firstPoint, lastPoint)) {
1463
1462
  curves.push(Blueprint.make2dSegmentCurve(lastPoint, firstPoint));
1464
1463
  }
1465
1464
  return new Drawing(new Blueprint.Blueprint(curves));
@@ -1474,7 +1473,7 @@ const drawParametricFunction = (func, { pointsCount = 400, start = 0, stop = 1,
1474
1473
  const edgesToDrawing = (edges) => {
1475
1474
  const [r, gc] = shapeTypes.localGC();
1476
1475
  const planeSketch = drawRectangle(1e3, 1e3).sketchOnPlane();
1477
- const planeFace = r(errors.unwrap(shapeHelpers.makeFace(planeSketch.wire)));
1476
+ const planeFace = r(errors.unwrap(Blueprint.makeFace(planeSketch.wire)));
1478
1477
  const curves = edges.map((e) => Blueprint.edgeToCurve(e, planeFace));
1479
1478
  gc();
1480
1479
  const stitchedCurves = stitchCurves(curves).map((s) => new Blueprint.Blueprint(s));
@@ -1,7 +1,7 @@
1
- import { g as getKernel, a as toVec3, d as toOcPnt } from "./occtBoundary-CwegMzqc.js";
2
- import { c as castShape, n as gcWithScope } from "./shapeTypes-BlSElW8z.js";
1
+ import { g as getKernel, a as toVec3, b as toOcPnt } from "./occtBoundary-CqXvDhZY.js";
2
+ import { c as castShape, p as gcWithScope } from "./shapeTypes-C9sUsmEW.js";
3
3
  import { u as unwrap, e as err, p as typeCastError, l as ok } from "./errors-wGhcJMpB.js";
4
- import { i as iterTopo, d as downcast } from "./cast-DQaUibmm.js";
4
+ import { i as iterTopo, d as downcast } from "./cast-C4Ff_1Qe.js";
5
5
  function getSurfaceType(face) {
6
6
  const oc = getKernel().oc;
7
7
  const r = gcWithScope();
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
- const occtBoundary = require("./occtBoundary-du8_ex-p.cjs");
3
- const shapeTypes = require("./shapeTypes-DKhwEnUM.cjs");
2
+ const occtBoundary = require("./occtBoundary-6kQSl3cF.cjs");
3
+ const shapeTypes = require("./shapeTypes-BJ3Hmskg.cjs");
4
4
  const errors = require("./errors-DK1VAdP4.cjs");
5
- const cast = require("./cast-DkB0GKmQ.cjs");
5
+ const cast = require("./cast-DIiyxDLo.cjs");
6
6
  function getSurfaceType(face) {
7
7
  const oc = occtBoundary.getKernel().oc;
8
8
  const r = shapeTypes.gcWithScope();
@@ -0,0 +1,203 @@
1
+ "use strict";
2
+ const result = require("./result.cjs");
3
+ const shapeTypes = require("./shapeTypes-BJ3Hmskg.cjs");
4
+ const errors = require("./errors-DK1VAdP4.cjs");
5
+ const vecOps = require("./vecOps-CjRL1jau.cjs");
6
+ const faceFns = require("./faceFns-NDRFeekj.cjs");
7
+ const measurement = require("./measurement-LcGh4wV0.cjs");
8
+ const shapeFns = require("./shapeFns-cN4qGpbO.cjs");
9
+ const cast = require("./cast-DIiyxDLo.cjs");
10
+ const occtBoundary = require("./occtBoundary-6kQSl3cF.cjs");
11
+ const PRECISION_INTERSECTION = 1e-9;
12
+ const PRECISION_OFFSET = 1e-8;
13
+ const PRECISION_POINT = 1e-6;
14
+ const samePoint = ([x0, y0], [x1, y1], precision = PRECISION_POINT) => {
15
+ return Math.abs(x0 - x1) <= precision && Math.abs(y0 - y1) <= precision;
16
+ };
17
+ const add2d = ([x0, y0], [x1, y1]) => {
18
+ return [x0 + x1, y0 + y1];
19
+ };
20
+ const subtract2d = ([x0, y0], [x1, y1]) => {
21
+ return [x0 - x1, y0 - y1];
22
+ };
23
+ const scalarMultiply2d = ([x0, y0], scalar) => {
24
+ return [x0 * scalar, y0 * scalar];
25
+ };
26
+ const distance2d = ([x0, y0], [x1, y1] = [0, 0]) => {
27
+ return Math.sqrt((x0 - x1) ** 2 + (y0 - y1) ** 2);
28
+ };
29
+ const squareDistance2d = ([x0, y0], [x1, y1] = [0, 0]) => {
30
+ return (x0 - x1) ** 2 + (y0 - y1) ** 2;
31
+ };
32
+ function crossProduct2d([x0, y0], [x1, y1]) {
33
+ return x0 * y1 - y0 * x1;
34
+ }
35
+ const angle2d = ([x0, y0], [x1, y1] = [0, 0]) => {
36
+ return Math.atan2(y1 * x0 - y0 * x1, x0 * x1 + y0 * y1);
37
+ };
38
+ const polarAngle2d = ([x0, y0], [x1, y1] = [0, 0]) => {
39
+ return Math.atan2(y1 - y0, x1 - x0);
40
+ };
41
+ const normalize2d = ([x0, y0]) => {
42
+ const l = distance2d([x0, y0]);
43
+ if (l < 1e-12) {
44
+ result.bug("normalize2d", "Cannot normalize zero-length vector");
45
+ }
46
+ return [x0 / l, y0 / l];
47
+ };
48
+ const rotate2d = (point, angle, center = [0, 0]) => {
49
+ const [px0, py0] = point;
50
+ const [cx, cy] = center;
51
+ const px = px0 - cx;
52
+ const py = py0 - cy;
53
+ const sinA = Math.sin(angle);
54
+ const cosA = Math.cos(angle);
55
+ const xnew = px * cosA - py * sinA;
56
+ const ynew = px * sinA + py * cosA;
57
+ return [xnew + cx, ynew + cy];
58
+ };
59
+ const polarToCartesian = (r, theta) => {
60
+ const x = Math.cos(theta) * r;
61
+ const y = Math.sin(theta) * r;
62
+ return [x, y];
63
+ };
64
+ const cartesianToPolar = ([x, y]) => {
65
+ const r = distance2d([x, y]);
66
+ const theta = Math.atan2(y, x);
67
+ return [r, theta];
68
+ };
69
+ function createTypedFinder(topoKind, filters, rebuild, extend) {
70
+ const withFilter = (pred) => rebuild([...filters, pred]);
71
+ const shouldKeep = (element) => filters.every((f) => f(element));
72
+ const extractElements = (shape) => {
73
+ const result2 = [];
74
+ for (const raw of cast.iterTopo(shape.wrapped, topoKind)) {
75
+ const element = shapeTypes.castShape(errors.unwrap(cast.downcast(raw)));
76
+ if (shouldKeep(element)) {
77
+ result2.push(element);
78
+ }
79
+ }
80
+ return result2;
81
+ };
82
+ const emptyFinder = () => createTypedFinder(topoKind, [], rebuild, extend);
83
+ const base = {
84
+ _filters: filters,
85
+ _topoKind: topoKind,
86
+ when: (pred) => withFilter(pred),
87
+ inList: (elements) => {
88
+ const hashSet = /* @__PURE__ */ new Map();
89
+ for (const e of elements) {
90
+ const h = shapeFns.getHashCode(e);
91
+ const bucket = hashSet.get(h);
92
+ if (bucket) bucket.push(e);
93
+ else hashSet.set(h, [e]);
94
+ }
95
+ return withFilter((el) => {
96
+ const bucket = hashSet.get(shapeFns.getHashCode(el));
97
+ return !!bucket && bucket.some((e) => shapeFns.isSameShape(e, el));
98
+ });
99
+ },
100
+ not: (builderFn) => {
101
+ const inner = builderFn(emptyFinder());
102
+ return withFilter((el) => !inner.shouldKeep(el));
103
+ },
104
+ either: (fns) => {
105
+ const builtFinders = fns.map((fn) => fn(emptyFinder()));
106
+ return withFilter((el) => builtFinders.some((f) => f.shouldKeep(el)));
107
+ },
108
+ findAll: (shape) => extractElements(shape),
109
+ findUnique: (shape) => {
110
+ const elements = extractElements(shape);
111
+ if (elements.length !== 1) {
112
+ return errors.err(
113
+ errors.queryError(
114
+ "FINDER_NOT_UNIQUE",
115
+ `Finder expected a unique match but found ${elements.length} element(s)`
116
+ )
117
+ );
118
+ }
119
+ return errors.ok(elements[0]);
120
+ },
121
+ shouldKeep
122
+ };
123
+ const extensions = extend(base, withFilter);
124
+ return { ...base, ...extensions };
125
+ }
126
+ const DIRECTIONS = {
127
+ X: [1, 0, 0],
128
+ Y: [0, 1, 0],
129
+ Z: [0, 0, 1]
130
+ };
131
+ function resolveDir(dir) {
132
+ if (typeof dir === "string") return DIRECTIONS[dir] ?? [0, 0, 1];
133
+ return dir;
134
+ }
135
+ function distanceFromPointFilter(distance, point, tolerance) {
136
+ return (element) => {
137
+ const oc = occtBoundary.getKernel().oc;
138
+ const r = shapeTypes.gcWithScope();
139
+ const pnt = r(occtBoundary.toOcPnt(point));
140
+ const vtxMaker = r(new oc.BRepBuilderAPI_MakeVertex(pnt));
141
+ const vtx = vtxMaker.Vertex();
142
+ const distTool = r(new oc.BRepExtrema_DistShapeShape_1());
143
+ distTool.LoadS1(vtx);
144
+ distTool.LoadS2(element.wrapped);
145
+ const progress = r(new oc.Message_ProgressRange_1());
146
+ distTool.Perform(progress);
147
+ const d = distTool.Value();
148
+ return Math.abs(d - distance) < tolerance;
149
+ };
150
+ }
151
+ function faceDirectionFilter(dir, angle) {
152
+ const d = vecOps.vecNormalize(resolveDir(dir));
153
+ return (face) => {
154
+ const n = faceFns.normalAt(face);
155
+ const ang = Math.acos(Math.min(1, Math.abs(vecOps.vecDot(vecOps.vecNormalize(n), d))));
156
+ return Math.abs(ang - vecOps.DEG2RAD * angle) < 1e-6;
157
+ };
158
+ }
159
+ function buildFaceFinder(filters) {
160
+ return createTypedFinder(
161
+ "face",
162
+ filters,
163
+ buildFaceFinder,
164
+ (_base, withFilter) => ({
165
+ inDirection: (dir = "Z", angle = 0) => withFilter(faceDirectionFilter(dir, angle)),
166
+ parallelTo: (dir = "Z") => buildFaceFinder(filters).inDirection(dir, 0),
167
+ ofSurfaceType: (surfaceType) => withFilter((face) => errors.unwrap(faceFns.getSurfaceType(face)) === surfaceType),
168
+ ofArea: (area, tolerance = 1e-3) => withFilter((face) => Math.abs(measurement.measureArea(face) - area) < tolerance),
169
+ atDistance: (distance, point = [0, 0, 0]) => withFilter(distanceFromPointFilter(distance, point, 1e-6))
170
+ })
171
+ );
172
+ }
173
+ function faceFinder() {
174
+ return buildFaceFinder([]);
175
+ }
176
+ function getSingleFace(f, shape) {
177
+ if (typeof f === "object" && "_topoKind" in f) {
178
+ return f.findUnique(shape);
179
+ }
180
+ if (typeof f !== "function" && shapeTypes.isFace(f)) return errors.ok(f);
181
+ const fnResult = f(faceFinder());
182
+ return fnResult.findUnique(shape);
183
+ }
184
+ exports.PRECISION_INTERSECTION = PRECISION_INTERSECTION;
185
+ exports.PRECISION_OFFSET = PRECISION_OFFSET;
186
+ exports.add2d = add2d;
187
+ exports.angle2d = angle2d;
188
+ exports.cartesianToPolar = cartesianToPolar;
189
+ exports.createTypedFinder = createTypedFinder;
190
+ exports.crossProduct2d = crossProduct2d;
191
+ exports.distance2d = distance2d;
192
+ exports.distanceFromPointFilter = distanceFromPointFilter;
193
+ exports.faceFinder = faceFinder;
194
+ exports.getSingleFace = getSingleFace;
195
+ exports.normalize2d = normalize2d;
196
+ exports.polarAngle2d = polarAngle2d;
197
+ exports.polarToCartesian = polarToCartesian;
198
+ exports.resolveDir = resolveDir;
199
+ exports.rotate2d = rotate2d;
200
+ exports.samePoint = samePoint;
201
+ exports.scalarMultiply2d = scalarMultiply2d;
202
+ exports.squareDistance2d = squareDistance2d;
203
+ exports.subtract2d = subtract2d;