brepjs 8.4.0 → 8.7.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (114) hide show
  1. package/dist/2d.cjs +2 -2
  2. package/dist/2d.js +13 -13
  3. package/dist/{Blueprint-zgFe_5Qj.cjs → Blueprint-BcbOBF-9.cjs} +11 -99
  4. package/dist/{Blueprint-Bp45tnh0.js → Blueprint-Cmh8lKc4.js} +29 -117
  5. package/dist/{boolean2D-CfEbRMPF.cjs → boolean2D-CqacqjME.cjs} +24 -25
  6. package/dist/{boolean2D-DN6ETTCq.js → boolean2D-D94Axs3i.js} +23 -24
  7. package/dist/{booleanFns-C-M6qqvB.js → booleanFns-DdjtpcM6.js} +306 -12
  8. package/dist/{booleanFns-5dDG0jpA.cjs → booleanFns-NtKxkiXn.cjs} +299 -5
  9. package/dist/brepjs.cjs +1619 -71
  10. package/dist/brepjs.js +1880 -333
  11. package/dist/core/errors.d.ts +18 -0
  12. package/dist/core/errors.d.ts.map +1 -1
  13. package/dist/core.cjs +4 -4
  14. package/dist/core.js +4 -4
  15. package/dist/{cornerFinder-CC_MunIh.js → cornerFinder-BBOYfsXl.js} +1 -1
  16. package/dist/{cornerFinder-BQ-_VJx0.cjs → cornerFinder-Bqy8Lw2p.cjs} +1 -1
  17. package/dist/{curveFns-ZuQUBZvd.js → curveFns-B85Glnfo.js} +19 -17
  18. package/dist/{curveFns-VMxgfkqw.cjs → curveFns-BXCbASW-.cjs} +6 -4
  19. package/dist/{drawFns-BbhX1IUq.js → drawFns-B-gJ2WUc.js} +47 -21
  20. package/dist/{drawFns-CKaHgGSK.cjs → drawFns-CAmFEqd1.cjs} +63 -37
  21. package/dist/{errors-CSYOlCCR.js → errors-Coh_5_19.js} +26 -1
  22. package/dist/{errors-D13q2HCk.cjs → errors-eRQu29oc.cjs} +26 -1
  23. package/dist/{faceFns-CfJIbHY3.js → faceFns-CltrEfOo.js} +109 -12
  24. package/dist/{faceFns-es3GENII.cjs → faceFns-DcndPHWm.cjs} +103 -6
  25. package/dist/{helpers-C0q_FVxq.cjs → helpers-CC21GeAr.cjs} +8 -9
  26. package/dist/{helpers-CmVkMubc.js → helpers-SksQIreB.js} +16 -17
  27. package/dist/index.d.ts +18 -3
  28. package/dist/index.d.ts.map +1 -1
  29. package/dist/io/dxfImportFns.d.ts +17 -0
  30. package/dist/io/dxfImportFns.d.ts.map +1 -0
  31. package/dist/io/objImportFns.d.ts +19 -0
  32. package/dist/io/objImportFns.d.ts.map +1 -0
  33. package/dist/io/threemfImportFns.d.ts +19 -0
  34. package/dist/io/threemfImportFns.d.ts.map +1 -0
  35. package/dist/io.cjs +5 -5
  36. package/dist/io.js +5 -5
  37. package/dist/kernel/hullOps.d.ts +1 -0
  38. package/dist/kernel/hullOps.d.ts.map +1 -1
  39. package/dist/kernel/occtAdapter.d.ts +5 -0
  40. package/dist/kernel/occtAdapter.d.ts.map +1 -1
  41. package/dist/kernel/solverAdapter.d.ts +39 -0
  42. package/dist/kernel/solverAdapter.d.ts.map +1 -0
  43. package/dist/kernel/types.d.ts +5 -0
  44. package/dist/kernel/types.d.ts.map +1 -1
  45. package/dist/{loft-B-UCPW9P.cjs → loft-BcyyvWCj.cjs} +28 -28
  46. package/dist/{loft-oJq2OD3A.js → loft-CJMPx1NQ.js} +16 -16
  47. package/dist/{measurement-Cf_SoIiR.js → measurement-ByOztLxb.js} +3 -3
  48. package/dist/{measurement-CYmT-C77.cjs → measurement-DU3ry-0Q.cjs} +3 -3
  49. package/dist/measurement.cjs +1 -1
  50. package/dist/measurement.js +1 -1
  51. package/dist/{meshFns-CqNwW0PO.js → meshFns-D2gLyLFt.js} +3 -3
  52. package/dist/{meshFns-DDC_2U81.cjs → meshFns-DawUwI3W.cjs} +3 -3
  53. package/dist/{occtBoundary-D_gjqgzo.js → occtBoundary-CWzWqBCm.js} +17 -5
  54. package/dist/{occtBoundary-CocN2VKx.cjs → occtBoundary-DH2VO-rq.cjs} +12 -0
  55. package/dist/operations/assemblyFns.d.ts +1 -0
  56. package/dist/operations/assemblyFns.d.ts.map +1 -1
  57. package/dist/operations/guidedSweepFns.d.ts +25 -0
  58. package/dist/operations/guidedSweepFns.d.ts.map +1 -0
  59. package/dist/operations/mateFns.d.ts +50 -0
  60. package/dist/operations/mateFns.d.ts.map +1 -0
  61. package/dist/operations/multiSweepFns.d.ts +32 -0
  62. package/dist/operations/multiSweepFns.d.ts.map +1 -0
  63. package/dist/operations/roofFns.d.ts +16 -0
  64. package/dist/operations/roofFns.d.ts.map +1 -0
  65. package/dist/operations/straightSkeleton.d.ts +28 -0
  66. package/dist/operations/straightSkeleton.d.ts.map +1 -0
  67. package/dist/{operations-BQeW_DSM.cjs → operations-CdELWxgv.cjs} +7 -7
  68. package/dist/{operations-6hdpuYmY.js → operations-DiXo_4t9.js} +15 -15
  69. package/dist/operations.cjs +2 -2
  70. package/dist/operations.js +13 -13
  71. package/dist/query.cjs +5 -5
  72. package/dist/query.js +7 -7
  73. package/dist/result.cjs +1 -1
  74. package/dist/result.js +1 -1
  75. package/dist/{shapeFns-B0zSdO9c.cjs → shapeFns-3RYtsUVY.cjs} +54 -21
  76. package/dist/{shapeFns-k1YHFwmB.js → shapeFns-4ioRrhih.js} +52 -19
  77. package/dist/{shapeTypes-BxVxLdiD.cjs → shapeTypes-CMjrTv36.cjs} +1 -1
  78. package/dist/{shapeTypes-c-_pgYCx.js → shapeTypes-D0vfRxWb.js} +13 -13
  79. package/dist/sketching.cjs +2 -2
  80. package/dist/sketching.js +2 -2
  81. package/dist/{curveBuilders-BREwqvuc.js → surfaceBuilders-B7Jxob8g.js} +106 -13
  82. package/dist/{curveBuilders-BkEJ-RVn.cjs → surfaceBuilders-Xx9DRRxs.cjs} +96 -3
  83. package/dist/text/textBlueprints.d.ts +38 -0
  84. package/dist/text/textBlueprints.d.ts.map +1 -1
  85. package/dist/topology/api.d.ts +5 -0
  86. package/dist/topology/api.d.ts.map +1 -1
  87. package/dist/topology/booleanFns.d.ts +10 -1
  88. package/dist/topology/booleanFns.d.ts.map +1 -1
  89. package/dist/topology/colorFns.d.ts +38 -0
  90. package/dist/topology/colorFns.d.ts.map +1 -0
  91. package/dist/topology/curveFns.d.ts +1 -1
  92. package/dist/topology/curveFns.d.ts.map +1 -1
  93. package/dist/topology/faceTagFns.d.ts +44 -0
  94. package/dist/topology/faceTagFns.d.ts.map +1 -0
  95. package/dist/topology/modifierFns.d.ts.map +1 -1
  96. package/dist/topology/polyhedronFns.d.ts +8 -0
  97. package/dist/topology/polyhedronFns.d.ts.map +1 -0
  98. package/dist/topology/shapeFns.d.ts +4 -0
  99. package/dist/topology/shapeFns.d.ts.map +1 -1
  100. package/dist/topology/surfaceBuilders.d.ts +7 -0
  101. package/dist/topology/surfaceBuilders.d.ts.map +1 -1
  102. package/dist/topology/surfaceFns.d.ts +38 -0
  103. package/dist/topology/surfaceFns.d.ts.map +1 -0
  104. package/dist/{topology-CycEc6Oe.cjs → topology-D-nGjCzV.cjs} +19 -20
  105. package/dist/{topology-tMKHJgw2.js → topology-DRP9zreU.js} +8 -9
  106. package/dist/topology.cjs +13 -14
  107. package/dist/topology.js +51 -52
  108. package/dist/{vectors-DE0XriuQ.js → vectors-CZV4ZrTz.js} +2 -2
  109. package/dist/{vectors-DVmHF4zt.cjs → vectors-DwFeX0Ja.cjs} +2 -2
  110. package/dist/vectors.cjs +2 -2
  111. package/dist/vectors.js +2 -2
  112. package/package.json +4 -3
  113. package/dist/cast-CPNOTNFm.cjs +0 -102
  114. package/dist/cast-Cerqtxtb.js +0 -103
@@ -1,11 +1,11 @@
1
1
  "use strict";
2
- const occtBoundary = require("./occtBoundary-CocN2VKx.cjs");
2
+ const occtBoundary = require("./occtBoundary-DH2VO-rq.cjs");
3
3
  const vecOps = require("./vecOps-CjRL1jau.cjs");
4
- const shapeTypes = require("./shapeTypes-BxVxLdiD.cjs");
5
- const cast = require("./cast-CPNOTNFm.cjs");
6
- const errors = require("./errors-D13q2HCk.cjs");
7
- const loft = require("./loft-B-UCPW9P.cjs");
8
- const booleanFns = require("./booleanFns-5dDG0jpA.cjs");
4
+ const shapeTypes = require("./shapeTypes-CMjrTv36.cjs");
5
+ const faceFns = require("./faceFns-DcndPHWm.cjs");
6
+ const errors = require("./errors-eRQu29oc.cjs");
7
+ const loft = require("./loft-BcyyvWCj.cjs");
8
+ const booleanFns = require("./booleanFns-NtKxkiXn.cjs");
9
9
  function uuidv() {
10
10
  return (String([1e7]) + String(-1e3) + String(-4e3) + String(-8e3) + String(-1e11)).replace(
11
11
  /[018]/g,
@@ -117,7 +117,7 @@ function extrude(face, extrusionVec) {
117
117
  const vec = r(occtBoundary.toOcVec(extrusionVec));
118
118
  const builder = r(new oc.BRepPrimAPI_MakePrism_1(face.wrapped, vec, false, true));
119
119
  const shape = builder.Shape();
120
- const downcastResult = cast.downcast(shape);
120
+ const downcastResult = faceFns.downcast(shape);
121
121
  if (errors.isErr(downcastResult)) {
122
122
  return downcastResult;
123
123
  }
@@ -1,10 +1,10 @@
1
- import { g as getKernel, c as toOcVec, b as toOcPnt, d as makeOcAx3, u as uniqueIOFilename } from "./occtBoundary-D_gjqgzo.js";
1
+ import { g as getKernel, b as toOcVec, d as toOcPnt, e as makeOcAx3, u as uniqueIOFilename } from "./occtBoundary-CWzWqBCm.js";
2
2
  import { g as vecLength, v as vecAdd, D as DEG2RAD, f as vecIsZero, j as vecNormalize, n as vecScale } from "./vecOps-ZDdZWbwT.js";
3
- import { b as createOcHandle, c as castShape, h as isShape3D, m as isWire, p as gcWithScope, s as createSolid } from "./shapeTypes-c-_pgYCx.js";
4
- import { d as downcast } from "./cast-Cerqtxtb.js";
5
- import { e as err, x as validationError, u as unwrap, p as typeCastError, l as ok, B as BrepErrorCode, d as isErr, o as occtError, i as ioError, b as computationError } from "./errors-CSYOlCCR.js";
6
- import { n as buildLawFromProfile } from "./loft-oJq2OD3A.js";
7
- import { d as fuseAll } from "./booleanFns-C-M6qqvB.js";
3
+ import { b as createOcHandle, c as castShape, h as isShape3D, m as isWire, n as gcWithScope, u as createSolid } from "./shapeTypes-D0vfRxWb.js";
4
+ import { d as downcast } from "./faceFns-CltrEfOo.js";
5
+ import { e as err, x as validationError, u as unwrap, p as typeCastError, l as ok, B as BrepErrorCode, d as isErr, o as occtError, i as ioError, b as computationError } from "./errors-Coh_5_19.js";
6
+ import { n as buildLawFromProfile } from "./loft-CJMPx1NQ.js";
7
+ import { g as fuseAll } from "./booleanFns-DdjtpcM6.js";
8
8
  function uuidv() {
9
9
  return (String([1e7]) + String(-1e3) + String(-4e3) + String(-8e3) + String(-1e11)).replace(
10
10
  /[018]/g,
@@ -580,11 +580,11 @@ function modifyStep(history, stepId, newParams, registry) {
580
580
  return replayFrom(modifiedHistory, stepId, registry);
581
581
  }
582
582
  export {
583
- supportExtrude as A,
584
- twistExtrude as B,
585
- undoLast as C,
586
- updateNode as D,
587
- walkAssembly as E,
583
+ stepsFrom as A,
584
+ supportExtrude as B,
585
+ twistExtrude as C,
586
+ undoLast as D,
587
+ updateNode as E,
588
588
  addChild as a,
589
589
  addStep as b,
590
590
  circularPattern as c,
@@ -607,8 +607,8 @@ export {
607
607
  registerOperation as t,
608
608
  registerShape as u,
609
609
  removeChild as v,
610
- replayFrom as w,
611
- replayHistory as x,
612
- stepCount as y,
613
- stepsFrom as z
610
+ walkAssembly as w,
611
+ replayFrom as x,
612
+ replayHistory as y,
613
+ stepCount as z
614
614
  };
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const operations = require("./operations-BQeW_DSM.cjs");
4
- const loft = require("./loft-B-UCPW9P.cjs");
3
+ const operations = require("./operations-CdELWxgv.cjs");
4
+ const loft = require("./loft-BcyyvWCj.cjs");
5
5
  exports.addChild = operations.addChild;
6
6
  exports.addStep = operations.addStep;
7
7
  exports.circularPattern = operations.circularPattern;
@@ -1,9 +1,9 @@
1
- import { a, b, c, d, f, g, h, i, j, k, m, n, o, p, l, q, t, u, v, w, x, y, z, A, s, B, C, D, E } from "./operations-6hdpuYmY.js";
2
- import { i as i2, j as j2, l as l2, r } from "./loft-oJq2OD3A.js";
1
+ import { a, b, c, d, f, g, h, i, j, k, m, n, o, p, l, q, t, u, v, x, y, z, A, B, s, C, D, E, w } from "./operations-DiXo_4t9.js";
2
+ import { b as b2, g as g2, l as l2, r } from "./loft-CJMPx1NQ.js";
3
3
  export {
4
4
  a as addChild,
5
5
  b as addStep,
6
- i2 as basicFaceExtrusion,
6
+ b2 as basicFaceExtrusion,
7
7
  c as circularPattern,
8
8
  d as collectShapes,
9
9
  f as complexExtrude,
@@ -15,7 +15,7 @@ export {
15
15
  m as exportAssemblySTEP,
16
16
  n as findNode,
17
17
  o as findStep,
18
- j2 as genericSweep,
18
+ g2 as genericSweep,
19
19
  p as getHistoryShape,
20
20
  l as linearPattern,
21
21
  l2 as loft,
@@ -23,15 +23,15 @@ export {
23
23
  t as registerOperation,
24
24
  u as registerShape,
25
25
  v as removeChild,
26
- w as replayFrom,
27
- x as replayHistory,
26
+ x as replayFrom,
27
+ y as replayHistory,
28
28
  r as revolution,
29
- y as stepCount,
30
- z as stepsFrom,
31
- A as supportExtrude,
29
+ z as stepCount,
30
+ A as stepsFrom,
31
+ B as supportExtrude,
32
32
  s as sweep,
33
- B as twistExtrude,
34
- C as undoLast,
35
- D as updateNode,
36
- E as walkAssembly
33
+ C as twistExtrude,
34
+ D as undoLast,
35
+ E as updateNode,
36
+ w as walkAssembly
37
37
  };
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-C0q_FVxq.cjs");
4
- const cornerFinder = require("./cornerFinder-BQ-_VJx0.cjs");
5
- const occtBoundary = require("./occtBoundary-CocN2VKx.cjs");
6
- const shapeTypes = require("./shapeTypes-BxVxLdiD.cjs");
3
+ const helpers = require("./helpers-CC21GeAr.cjs");
4
+ const cornerFinder = require("./cornerFinder-Bqy8Lw2p.cjs");
5
+ const occtBoundary = require("./occtBoundary-DH2VO-rq.cjs");
6
+ const shapeTypes = require("./shapeTypes-CMjrTv36.cjs");
7
7
  const vecOps = require("./vecOps-CjRL1jau.cjs");
8
- const curveFns = require("./curveFns-VMxgfkqw.cjs");
8
+ const curveFns = require("./curveFns-BXCbASW-.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-CmVkMubc.js";
2
- import { f, g } from "./helpers-CmVkMubc.js";
3
- import { c } from "./cornerFinder-CC_MunIh.js";
4
- import { g as getKernel } from "./occtBoundary-D_gjqgzo.js";
5
- import { p as gcWithScope } from "./shapeTypes-c-_pgYCx.js";
1
+ import { l as createTypedFinder, o as distanceFromPointFilter, q as resolveDir } from "./helpers-SksQIreB.js";
2
+ import { m, g } from "./helpers-SksQIreB.js";
3
+ import { c } from "./cornerFinder-BBOYfsXl.js";
4
+ import { g as getKernel } from "./occtBoundary-CWzWqBCm.js";
5
+ import { n as gcWithScope } from "./shapeTypes-D0vfRxWb.js";
6
6
  import { j as vecNormalize, d as vecDot, D as DEG2RAD } from "./vecOps-ZDdZWbwT.js";
7
- import { l as getCurveType, f as curveLength } from "./curveFns-ZuQUBZvd.js";
7
+ import { b as getCurveType, i as curveLength } from "./curveFns-B85Glnfo.js";
8
8
  function edgeDirectionFilter(dir, angle) {
9
9
  const d = vecNormalize(resolveDir(dir));
10
10
  return (edge) => {
@@ -40,6 +40,6 @@ function edgeFinder() {
40
40
  export {
41
41
  c as cornerFinder,
42
42
  edgeFinder,
43
- f as faceFinder,
43
+ m as faceFinder,
44
44
  g as getSingleFace
45
45
  };
package/dist/result.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const errors = require("./errors-D13q2HCk.cjs");
3
+ const errors = require("./errors-eRQu29oc.cjs");
4
4
  class BrepBugError extends Error {
5
5
  location;
6
6
  constructor(location, message) {
package/dist/result.js CHANGED
@@ -1,4 +1,4 @@
1
- import { B, O, a, c, b, e, f, i, d, g, m, h, j, k, o, l, z, q, s, t, n, p, u, r, v, w, x } from "./errors-CSYOlCCR.js";
1
+ import { B, O, a, c, b, e, f, i, d, g, m, h, j, k, o, l, z, q, s, t, n, p, u, r, v, w, x } from "./errors-Coh_5_19.js";
2
2
  class BrepBugError extends Error {
3
3
  location;
4
4
  constructor(location, message) {
@@ -1,11 +1,11 @@
1
1
  "use strict";
2
- const occtBoundary = require("./occtBoundary-CocN2VKx.cjs");
3
- const shapeTypes = require("./shapeTypes-BxVxLdiD.cjs");
2
+ const occtBoundary = require("./occtBoundary-DH2VO-rq.cjs");
3
+ const shapeTypes = require("./shapeTypes-CMjrTv36.cjs");
4
4
  const vecOps = require("./vecOps-CjRL1jau.cjs");
5
- const cast = require("./cast-CPNOTNFm.cjs");
6
- const errors = require("./errors-D13q2HCk.cjs");
5
+ const faceFns = require("./faceFns-DcndPHWm.cjs");
6
+ const errors = require("./errors-eRQu29oc.cjs");
7
7
  function clone(shape) {
8
- return shapeTypes.castShape(errors.unwrap(cast.downcast(shape.wrapped)));
8
+ return shapeTypes.castShape(errors.unwrap(faceFns.downcast(shape.wrapped)));
9
9
  }
10
10
  function toBREP(shape) {
11
11
  const oc = occtBoundary.getKernel().oc;
@@ -82,6 +82,38 @@ function scale(shape, factor, center = [0, 0, 0]) {
82
82
  pnt.delete();
83
83
  return result;
84
84
  }
85
+ function resize(shape, dimensions, options) {
86
+ const bbox = occtBoundary.getKernel().boundingBox(shape.wrapped);
87
+ const size = [
88
+ bbox.max[0] - bbox.min[0],
89
+ bbox.max[1] - bbox.min[1],
90
+ bbox.max[2] - bbox.min[2]
91
+ ];
92
+ const auto = options?.auto === true;
93
+ function factor(dim, sz, baseFactor) {
94
+ if (dim !== void 0 && sz > 1e-12) return dim / sz;
95
+ if (dim === void 0 && auto) return baseFactor;
96
+ return 1;
97
+ }
98
+ let autoFactor = 1;
99
+ if (auto) {
100
+ if (dimensions[0] !== void 0 && size[0] > 1e-12) autoFactor = dimensions[0] / size[0];
101
+ else if (dimensions[1] !== void 0 && size[1] > 1e-12) autoFactor = dimensions[1] / size[1];
102
+ else if (dimensions[2] !== void 0 && size[2] > 1e-12) autoFactor = dimensions[2] / size[2];
103
+ }
104
+ const factors = [
105
+ factor(dimensions[0], size[0], autoFactor),
106
+ factor(dimensions[1], size[1], autoFactor),
107
+ factor(dimensions[2], size[2], autoFactor)
108
+ ];
109
+ const isUniform = Math.abs(factors[0] - factors[1]) < 1e-6 && Math.abs(factors[1] - factors[2]) < 1e-6;
110
+ if (!isUniform) {
111
+ throw new Error(
112
+ "resize: non-uniform scaling is not supported (WASM build lacks BRepBuilderAPI_GTransform). Use auto: true to scale proportionally, or set all three dimensions to achieve uniform scaling."
113
+ );
114
+ }
115
+ return scale(shape, factors[0]);
116
+ }
85
117
  function parseMatrixInput(input) {
86
118
  if ("linear" in input) {
87
119
  return { linear: input.linear, translation: input.translation };
@@ -204,8 +236,8 @@ function getOrCreateCache(shape) {
204
236
  function getEdges(shape) {
205
237
  const cache = getOrCreateCache(shape);
206
238
  if (cache.edges) return cache.edges;
207
- const edges = Array.from(cast.iterTopo(shape.wrapped, "edge")).map(
208
- (e) => shapeTypes.castShape(errors.unwrap(cast.downcast(e)))
239
+ const edges = Array.from(faceFns.iterTopo(shape.wrapped, "edge")).map(
240
+ (e) => shapeTypes.castShape(errors.unwrap(faceFns.downcast(e)))
209
241
  );
210
242
  cache.edges = edges;
211
243
  return edges;
@@ -213,8 +245,8 @@ function getEdges(shape) {
213
245
  function getFaces(shape) {
214
246
  const cache = getOrCreateCache(shape);
215
247
  if (cache.faces) return cache.faces;
216
- const faces = Array.from(cast.iterTopo(shape.wrapped, "face")).map(
217
- (e) => shapeTypes.castShape(errors.unwrap(cast.downcast(e)))
248
+ const faces = Array.from(faceFns.iterTopo(shape.wrapped, "face")).map(
249
+ (e) => shapeTypes.castShape(errors.unwrap(faceFns.downcast(e)))
218
250
  );
219
251
  cache.faces = faces;
220
252
  return faces;
@@ -222,8 +254,8 @@ function getFaces(shape) {
222
254
  function getWires(shape) {
223
255
  const cache = getOrCreateCache(shape);
224
256
  if (cache.wires) return cache.wires;
225
- const wires = Array.from(cast.iterTopo(shape.wrapped, "wire")).map(
226
- (e) => shapeTypes.castShape(errors.unwrap(cast.downcast(e)))
257
+ const wires = Array.from(faceFns.iterTopo(shape.wrapped, "wire")).map(
258
+ (e) => shapeTypes.castShape(errors.unwrap(faceFns.downcast(e)))
227
259
  );
228
260
  cache.wires = wires;
229
261
  return wires;
@@ -312,28 +344,28 @@ function propagateOriginsByHash(inputs, result) {
312
344
  }
313
345
  }
314
346
  function getVertices(shape) {
315
- return Array.from(cast.iterTopo(shape.wrapped, "vertex")).map(
316
- (e) => shapeTypes.castShape(errors.unwrap(cast.downcast(e)))
347
+ return Array.from(faceFns.iterTopo(shape.wrapped, "vertex")).map(
348
+ (e) => shapeTypes.castShape(errors.unwrap(faceFns.downcast(e)))
317
349
  );
318
350
  }
319
351
  function* iterEdges(shape) {
320
- for (const e of cast.iterTopo(shape.wrapped, "edge")) {
321
- yield shapeTypes.castShape(errors.unwrap(cast.downcast(e)));
352
+ for (const e of faceFns.iterTopo(shape.wrapped, "edge")) {
353
+ yield shapeTypes.castShape(errors.unwrap(faceFns.downcast(e)));
322
354
  }
323
355
  }
324
356
  function* iterFaces(shape) {
325
- for (const f of cast.iterTopo(shape.wrapped, "face")) {
326
- yield shapeTypes.castShape(errors.unwrap(cast.downcast(f)));
357
+ for (const f of faceFns.iterTopo(shape.wrapped, "face")) {
358
+ yield shapeTypes.castShape(errors.unwrap(faceFns.downcast(f)));
327
359
  }
328
360
  }
329
361
  function* iterWires(shape) {
330
- for (const w of cast.iterTopo(shape.wrapped, "wire")) {
331
- yield shapeTypes.castShape(errors.unwrap(cast.downcast(w)));
362
+ for (const w of faceFns.iterTopo(shape.wrapped, "wire")) {
363
+ yield shapeTypes.castShape(errors.unwrap(faceFns.downcast(w)));
332
364
  }
333
365
  }
334
366
  function* iterVertices(shape) {
335
- for (const v of cast.iterTopo(shape.wrapped, "vertex")) {
336
- yield shapeTypes.castShape(errors.unwrap(cast.downcast(v)));
367
+ for (const v of faceFns.iterTopo(shape.wrapped, "vertex")) {
368
+ yield shapeTypes.castShape(errors.unwrap(faceFns.downcast(v)));
337
369
  }
338
370
  }
339
371
  function getBounds(shape) {
@@ -396,6 +428,7 @@ exports.iterWires = iterWires;
396
428
  exports.mirror = mirror;
397
429
  exports.propagateOrigins = propagateOrigins;
398
430
  exports.propagateOriginsByHash = propagateOriginsByHash;
431
+ exports.resize = resize;
399
432
  exports.rotate = rotate;
400
433
  exports.scale = scale;
401
434
  exports.setShapeOrigin = setShapeOrigin;
@@ -1,8 +1,8 @@
1
- import { g as getKernel, c as toOcVec, e as makeOcAx1, m as makeOcAx2, b as toOcPnt } from "./occtBoundary-D_gjqgzo.js";
2
- import { c as castShape, g as getShapeKind, p as gcWithScope } from "./shapeTypes-c-_pgYCx.js";
1
+ import { g as getKernel, b as toOcVec, m as makeOcAx1, c as makeOcAx2, d as toOcPnt } from "./occtBoundary-CWzWqBCm.js";
2
+ import { c as castShape, g as getShapeKind, n as gcWithScope } from "./shapeTypes-D0vfRxWb.js";
3
3
  import { D as DEG2RAD, H as HASH_CODE_MAX } from "./vecOps-ZDdZWbwT.js";
4
- import { i as iterTopo, d as downcast } from "./cast-Cerqtxtb.js";
5
- import { u as unwrap } from "./errors-CSYOlCCR.js";
4
+ import { i as iterTopo, d as downcast } from "./faceFns-CltrEfOo.js";
5
+ import { u as unwrap } from "./errors-Coh_5_19.js";
6
6
  function clone(shape) {
7
7
  return castShape(unwrap(downcast(shape.wrapped)));
8
8
  }
@@ -81,6 +81,38 @@ function scale(shape, factor, center = [0, 0, 0]) {
81
81
  pnt.delete();
82
82
  return result;
83
83
  }
84
+ function resize(shape, dimensions, options) {
85
+ const bbox = getKernel().boundingBox(shape.wrapped);
86
+ const size = [
87
+ bbox.max[0] - bbox.min[0],
88
+ bbox.max[1] - bbox.min[1],
89
+ bbox.max[2] - bbox.min[2]
90
+ ];
91
+ const auto = options?.auto === true;
92
+ function factor(dim, sz, baseFactor) {
93
+ if (dim !== void 0 && sz > 1e-12) return dim / sz;
94
+ if (dim === void 0 && auto) return baseFactor;
95
+ return 1;
96
+ }
97
+ let autoFactor = 1;
98
+ if (auto) {
99
+ if (dimensions[0] !== void 0 && size[0] > 1e-12) autoFactor = dimensions[0] / size[0];
100
+ else if (dimensions[1] !== void 0 && size[1] > 1e-12) autoFactor = dimensions[1] / size[1];
101
+ else if (dimensions[2] !== void 0 && size[2] > 1e-12) autoFactor = dimensions[2] / size[2];
102
+ }
103
+ const factors = [
104
+ factor(dimensions[0], size[0], autoFactor),
105
+ factor(dimensions[1], size[1], autoFactor),
106
+ factor(dimensions[2], size[2], autoFactor)
107
+ ];
108
+ const isUniform = Math.abs(factors[0] - factors[1]) < 1e-6 && Math.abs(factors[1] - factors[2]) < 1e-6;
109
+ if (!isUniform) {
110
+ throw new Error(
111
+ "resize: non-uniform scaling is not supported (WASM build lacks BRepBuilderAPI_GTransform). Use auto: true to scale proportionally, or set all three dimensions to achieve uniform scaling."
112
+ );
113
+ }
114
+ return scale(shape, factors[0]);
115
+ }
84
116
  function parseMatrixInput(input) {
85
117
  if ("linear" in input) {
86
118
  return { linear: input.linear, translation: input.translation };
@@ -377,28 +409,29 @@ function vertexPosition(vertex) {
377
409
  export {
378
410
  iterVertices as A,
379
411
  iterWires as B,
380
- setShapeOrigin as C,
381
- propagateOriginsByHash as a,
382
- getHashCode as b,
383
- getFaces as c,
384
- getVertices as d,
385
- getEdges as e,
386
- applyMatrix as f,
412
+ resize as C,
413
+ setShapeOrigin as D,
414
+ getFaces as a,
415
+ propagateOriginsByHash as b,
416
+ getWires as c,
417
+ getEdges as d,
418
+ getHashCode as e,
419
+ getVertices as f,
387
420
  getFaceOrigins as g,
388
- clone as h,
421
+ applyMatrix as h,
389
422
  isSameShape as i,
390
- describe as j,
391
- isEmpty as k,
392
- simplify as l,
423
+ clone as j,
424
+ describe as k,
425
+ isEmpty as l,
393
426
  mirror as m,
394
- toBREP as n,
395
- transformCopy as o,
427
+ simplify as n,
428
+ toBREP as o,
396
429
  propagateOrigins as p,
397
- getBounds as q,
430
+ transformCopy as q,
398
431
  rotate as r,
399
432
  scale as s,
400
433
  translate as t,
401
- getWires as u,
434
+ getBounds as u,
402
435
  vertexPosition as v,
403
436
  composeTransforms as w,
404
437
  isEqualShape as x,
@@ -44,7 +44,7 @@ var __callDispose = (stack, error, hasError) => {
44
44
  };
45
45
  return next();
46
46
  };
47
- const occtBoundary = require("./occtBoundary-CocN2VKx.cjs");
47
+ const occtBoundary = require("./occtBoundary-DH2VO-rq.cjs");
48
48
  const globalWithRegistry = globalThis;
49
49
  if (!globalWithRegistry.FinalizationRegistry) {
50
50
  console.warn("brepjs: FinalizationRegistry unavailable — garbage collection will not work");
@@ -43,7 +43,7 @@ var __callDispose = (stack, error, hasError) => {
43
43
  };
44
44
  return next();
45
45
  };
46
- import { g as getKernel } from "./occtBoundary-D_gjqgzo.js";
46
+ import { g as getKernel } from "./occtBoundary-CWzWqBCm.js";
47
47
  const globalWithRegistry = globalThis;
48
48
  if (!globalWithRegistry.FinalizationRegistry) {
49
49
  console.warn("brepjs: FinalizationRegistry unavailable — garbage collection will not work");
@@ -300,17 +300,17 @@ export {
300
300
  isSolid as k,
301
301
  isVertex as l,
302
302
  isWire as m,
303
- createWire as n,
304
- createEdge as o,
305
- gcWithScope as p,
306
- createCompound as q,
307
- createVertex as r,
308
- createSolid as s,
309
- localGC as t,
310
- createFace as u,
311
- createShell as v,
303
+ gcWithScope as n,
304
+ createWire as o,
305
+ createEdge as p,
306
+ createFace as q,
307
+ localGC as r,
308
+ createCompound as s,
309
+ createVertex as t,
310
+ createSolid as u,
311
+ registerForCleanup as v,
312
312
  withScope as w,
313
- gcWithObject as x,
314
- registerForCleanup as y,
315
- unregisterFromCleanup as z
313
+ unregisterFromCleanup as x,
314
+ createShell as y,
315
+ gcWithObject as z
316
316
  };
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const drawFns = require("./drawFns-CKaHgGSK.cjs");
4
- const boolean2D = require("./boolean2D-CfEbRMPF.cjs");
3
+ const drawFns = require("./drawFns-CAmFEqd1.cjs");
4
+ const boolean2D = require("./boolean2D-CqacqjME.cjs");
5
5
  exports.CompoundSketch = drawFns.CompoundSketch;
6
6
  exports.Drawing = drawFns.Drawing;
7
7
  exports.DrawingPen = drawFns.DrawingPen;
package/dist/sketching.js CHANGED
@@ -1,5 +1,5 @@
1
- import { C, D, a, S, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, A, B, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, T, U, V, W } from "./drawFns-BbhX1IUq.js";
2
- import { B as B2, a as a2, F as F2, S as S2 } from "./boolean2D-DN6ETTCq.js";
1
+ import { C, D, a, S, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, A, B, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, T, U, V, W } from "./drawFns-B-gJ2WUc.js";
2
+ import { B as B2, a as a2, F as F2, S as S2 } from "./boolean2D-D94Axs3i.js";
3
3
  export {
4
4
  B2 as BaseSketcher2d,
5
5
  a2 as BlueprintSketcher,
@@ -1,6 +1,15 @@
1
- import { g as getKernel, b as toOcPnt, c as toOcVec, m as makeOcAx2, d as makeOcAx3 } from "./occtBoundary-D_gjqgzo.js";
2
- import { d as isEdge, m as isWire, n as createWire, o as createEdge, p as gcWithScope } from "./shapeTypes-c-_pgYCx.js";
3
- import { e as err, o as occtError, l as ok, x as validationError } from "./errors-CSYOlCCR.js";
1
+ import { g as getKernel, d as toOcPnt, b as toOcVec, c as makeOcAx2, e as makeOcAx3 } from "./occtBoundary-CWzWqBCm.js";
2
+ import { e as err, o as occtError, l as ok, x as validationError, a as andThen } from "./errors-Coh_5_19.js";
3
+ import { d as isEdge, m as isWire, o as createWire, p as createEdge, n as gcWithScope, q as createFace, r as localGC, e as isFace } from "./shapeTypes-D0vfRxWb.js";
4
+ import { d as getEdges } from "./shapeFns-4ioRrhih.js";
5
+ import { o as outerWire, c as cast } from "./faceFns-CltrEfOo.js";
6
+ function range(len) {
7
+ return Array.from(Array(len).keys());
8
+ }
9
+ function zip(arrays) {
10
+ const minLength = Math.min(...arrays.map((arr) => arr.length));
11
+ return range(minLength).map((i) => arrays.map((arr) => arr[i]));
12
+ }
4
13
  function makeLine(v1, v2) {
5
14
  const oc = getKernel().oc;
6
15
  const r = gcWithScope();
@@ -183,15 +192,99 @@ function assembleWire(listOfEdges) {
183
192
  }
184
193
  return ok(createWire(wireBuilder.Wire()));
185
194
  }
195
+ function makeFace(wire, holes) {
196
+ const oc = getKernel().oc;
197
+ const faceBuilder = new oc.BRepBuilderAPI_MakeFace_15(wire.wrapped, false);
198
+ holes?.forEach((hole) => {
199
+ faceBuilder.Add(hole.wrapped);
200
+ });
201
+ if (!faceBuilder.IsDone()) {
202
+ faceBuilder.delete();
203
+ return err(
204
+ occtError("FACE_BUILD_FAILED", "Failed to build the face. Your wire might be non planar.")
205
+ );
206
+ }
207
+ const face = faceBuilder.Face();
208
+ faceBuilder.delete();
209
+ return ok(createFace(face));
210
+ }
211
+ function fill(face) {
212
+ const outer = outerWire(face);
213
+ return makeFace(outer);
214
+ }
215
+ function makeNewFaceWithinFace(originFace, wire) {
216
+ const oc = getKernel().oc;
217
+ const [r, gc] = localGC();
218
+ const surface = r(oc.BRep_Tool.Surface_2(originFace.wrapped));
219
+ const faceBuilder = r(new oc.BRepBuilderAPI_MakeFace_21(surface, wire.wrapped, true));
220
+ const face = faceBuilder.Face();
221
+ gc();
222
+ return createFace(face);
223
+ }
224
+ function makeNonPlanarFace(wire) {
225
+ const oc = getKernel().oc;
226
+ const [r, gc] = localGC();
227
+ const faceBuilder = r(
228
+ new oc.BRepOffsetAPI_MakeFilling(3, 15, 2, false, 1e-5, 1e-4, 0.01, 0.1, 8, 9)
229
+ );
230
+ getEdges(wire).forEach((edge) => {
231
+ faceBuilder.Add_1(
232
+ edge.wrapped,
233
+ oc.GeomAbs_Shape.GeomAbs_C0,
234
+ true
235
+ );
236
+ });
237
+ const progress = r(new oc.Message_ProgressRange_1());
238
+ faceBuilder.Build(progress);
239
+ return andThen(cast(faceBuilder.Shape()), (newFace) => {
240
+ gc();
241
+ if (!isFace(newFace)) {
242
+ return err(occtError("FACE_BUILD_FAILED", "Failed to create a face"));
243
+ }
244
+ return ok(newFace);
245
+ });
246
+ }
247
+ function addHolesInFace(face, holes) {
248
+ const oc = getKernel().oc;
249
+ const [r, gc] = localGC();
250
+ const faceMaker = r(new oc.BRepBuilderAPI_MakeFace_2(face.wrapped));
251
+ holes.forEach((wire) => {
252
+ faceMaker.Add(wire.wrapped);
253
+ });
254
+ const builtFace = r(faceMaker.Face());
255
+ const fixer = r(new oc.ShapeFix_Face_2(builtFace));
256
+ fixer.FixOrientation_1();
257
+ const newFace = fixer.Face();
258
+ gc();
259
+ return createFace(newFace);
260
+ }
261
+ function makePolygon(points) {
262
+ if (points.length < 3)
263
+ return err(
264
+ validationError("POLYGON_MIN_POINTS", "You need at least 3 points to make a polygon")
265
+ );
266
+ const edges = zip([points, [...points.slice(1), points[0]]]).map(
267
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any -- zip returns untyped pairs
268
+ ([p1, p2]) => makeLine(p1, p2)
269
+ );
270
+ return andThen(assembleWire(edges), (wire) => makeFace(wire));
271
+ }
186
272
  export {
187
- assembleWire as a,
188
- makeHelix as b,
189
- makeBezierCurve as c,
190
- makeBSplineApproximation as d,
191
- makeCircle as e,
192
- makeEllipse as f,
193
- makeEllipseArc as g,
194
- makeTangentArc as h,
195
- makeThreePointArc as i,
196
- makeLine as m
273
+ makeLine as a,
274
+ assembleWire as b,
275
+ makeHelix as c,
276
+ makeThreePointArc as d,
277
+ makeTangentArc as e,
278
+ makeEllipseArc as f,
279
+ makeBezierCurve as g,
280
+ addHolesInFace as h,
281
+ makeCircle as i,
282
+ makeEllipse as j,
283
+ makeBSplineApproximation as k,
284
+ makeNewFaceWithinFace as l,
285
+ makeFace as m,
286
+ makeNonPlanarFace as n,
287
+ makePolygon as o,
288
+ fill as p,
289
+ zip as z
197
290
  };