brepjs 20.12.4 → 20.12.6

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 (102) hide show
  1. package/dist/2d/lib/offset.d.ts +1 -1
  2. package/dist/2d.cjs +6 -6
  3. package/dist/2d.js +6 -6
  4. package/dist/{adjacencyFns-54UTqtan.js → adjacencyFns--KmBIKYJ.js} +3 -3
  5. package/dist/{adjacencyFns-C_Vb1AeW.cjs → adjacencyFns-BFJfaUwX.cjs} +3 -3
  6. package/dist/{blueprint-DFpjcrlm.js → blueprint-BhIk9Pvm.js} +7 -8
  7. package/dist/{blueprint-D0VEeTzJ.cjs → blueprint-D83DDDPb.cjs} +7 -8
  8. package/dist/{blueprintFns-Douf5ZdX.cjs → blueprintFns-C4TQn-x_.cjs} +2 -2
  9. package/dist/{blueprintFns-Dye1jezD.js → blueprintFns-eULVgkq9.js} +2 -2
  10. package/dist/{blueprintSketcher-Cr0Lr1Dq.js → blueprintSketcher-D_Faf0GO.js} +32 -14
  11. package/dist/{blueprintSketcher-W9yON-UC.cjs → blueprintSketcher-Di376t-0.cjs} +32 -14
  12. package/dist/{boolean2D-C9VghXHG.cjs → boolean2D-CNZFI_y8.cjs} +4 -4
  13. package/dist/{boolean2D-CCV3R6lN.js → boolean2D-DqpCF72W.js} +4 -4
  14. package/dist/brepjs.cjs +128 -100
  15. package/dist/brepjs.js +128 -100
  16. package/dist/{cameraFns-DZOI_ewG.js → cameraFns-CrClIkmV.js} +3 -3
  17. package/dist/{cameraFns-x3L6dtA8.cjs → cameraFns-RqraCXIc.cjs} +3 -3
  18. package/dist/core.cjs +2 -2
  19. package/dist/core.js +2 -2
  20. package/dist/{cornerFinder-BY10jciz.js → cornerFinder-BZuQkRp2.js} +1 -1
  21. package/dist/{cornerFinder-B8PqO4um.cjs → cornerFinder-CdOe1Wrb.cjs} +1 -1
  22. package/dist/{curveFns-B4308HNM.js → curveFns-BP3srCfK.js} +1 -1
  23. package/dist/{curveFns-8lUhNquZ.cjs → curveFns-CyIvQNYT.cjs} +1 -1
  24. package/dist/{drawFns-C7zAvera.cjs → drawFns-71cOhWD-.cjs} +29 -16
  25. package/dist/{drawFns-DjnU3fEd.js → drawFns-DxDwJ5zZ.js} +29 -16
  26. package/dist/{faceFns-BjmlYcc9.cjs → faceFns-B7MiDYj1.cjs} +2 -2
  27. package/dist/{faceFns-7eHqNM0P.js → faceFns-iVPbTxki.js} +2 -2
  28. package/dist/{healingFns-BW7mZ_SW.js → healingFns-BhP8zfp1.js} +5 -5
  29. package/dist/{healingFns-CYLIcIWv.cjs → healingFns-DWljGTNR.cjs} +5 -5
  30. package/dist/{helpers-BQ6XMFcm.js → helpers-D2hANLRu.js} +14 -10
  31. package/dist/{helpers-De0Z_6iV.cjs → helpers-DKEVm6Hu.cjs} +14 -10
  32. package/dist/{importFns-BCL4-H8e.js → importFns-DUzIkns7.js} +2 -2
  33. package/dist/{importFns-3IMBHQrQ.cjs → importFns-KEPAgbjj.cjs} +2 -2
  34. package/dist/index.d.ts +2 -2
  35. package/dist/io.cjs +2 -2
  36. package/dist/io.js +2 -2
  37. package/dist/kernel/bspline2dFit.d.ts +42 -0
  38. package/dist/kernel/geometry2d.d.ts +45 -0
  39. package/dist/kernel/occt/kernel2dOps.d.ts +1 -1
  40. package/dist/kernel/occtWasm/constructionOps.d.ts +1 -1
  41. package/dist/kernel/occtWasm/kernel2dOps.d.ts +7 -4
  42. package/dist/kernel/occtWasm/occtWasmAdapter.cjs +1 -1
  43. package/dist/kernel/occtWasm/occtWasmAdapter.d.ts +3 -3
  44. package/dist/kernel/occtWasm/occtWasmAdapter.js +1 -1
  45. package/dist/kernel/occtWasm/occtWasmTypes.d.ts +7 -0
  46. package/dist/{loftFns-DlG5oR0X.cjs → loftFns-D5AvfCGG.cjs} +17 -2
  47. package/dist/{loftFns-H4ZOpRAk.js → loftFns-D5NJpHLZ.js} +17 -2
  48. package/dist/{measureFns-Ce01LVwq.cjs → measureFns-CZHNWkiA.cjs} +102 -35
  49. package/dist/{measureFns-1IfNe629.js → measureFns-mxBdPiWa.js} +102 -35
  50. package/dist/measurement/measureFns.d.ts +3 -2
  51. package/dist/measurement.cjs +2 -2
  52. package/dist/measurement.js +2 -2
  53. package/dist/{meshFns-nEvfwNRF.cjs → meshFns-Czlt-GBJ.cjs} +3 -3
  54. package/dist/{meshFns-DaRZxa7B.js → meshFns-DmjMzNbH.js} +3 -3
  55. package/dist/{occtWasmAdapter-ipKUdNLN.js → occtWasmAdapter-B9d0Q0Vl.js} +1160 -261
  56. package/dist/{occtWasmAdapter-CRd9RFEu.cjs → occtWasmAdapter-DVxLkjlJ.cjs} +1171 -260
  57. package/dist/operations/patternFns.d.ts +6 -1
  58. package/dist/operations.cjs +2 -2
  59. package/dist/operations.js +2 -2
  60. package/dist/{originTrackingFns-zrksCJTa.js → originTrackingFns-CBnyKLm7.js} +2 -2
  61. package/dist/{originTrackingFns-9gyCMFFQ.cjs → originTrackingFns-CHymOLLm.cjs} +2 -2
  62. package/dist/{primitiveFns-BRXZ7jnP.cjs → primitiveFns-BVeBEaa4.cjs} +7 -14
  63. package/dist/{primitiveFns-ClQP6zMQ.js → primitiveFns-DeNl60Rw.js} +7 -14
  64. package/dist/{principalBoxFns-DsfWOoXg.js → principalBoxFns-3mW_hA6z.js} +3 -3
  65. package/dist/{principalBoxFns-tIv-crMB.cjs → principalBoxFns-CG6kG7vT.cjs} +3 -3
  66. package/dist/projection.cjs +1 -1
  67. package/dist/projection.js +1 -1
  68. package/dist/query/finderCore.d.ts +7 -7
  69. package/dist/query.cjs +2 -2
  70. package/dist/query.js +2 -2
  71. package/dist/{refResolveFns-BZdUlv9f.cjs → refResolveFns-BAs4p9z7.cjs} +6 -6
  72. package/dist/{refResolveFns-BG3JGs--.js → refResolveFns-DHx1Y3GG.js} +6 -6
  73. package/dist/{shapeFns-BbXqiNqY.cjs → shapeFns-C0w8vvfb.cjs} +2 -2
  74. package/dist/{shapeFns-BCgegapL.js → shapeFns-CgqKICF_.js} +2 -2
  75. package/dist/shapeRef.cjs +1 -1
  76. package/dist/shapeRef.js +1 -1
  77. package/dist/{shapeTypes-DJT3SnGK.cjs → shapeTypes-Dc7j-MYg.cjs} +10 -16
  78. package/dist/{shapeTypes-DAz6aAnJ.js → shapeTypes-DwvQUp9M.js} +10 -16
  79. package/dist/sketching/sketches.d.ts +2 -0
  80. package/dist/sketching.cjs +3 -3
  81. package/dist/sketching.js +3 -3
  82. package/dist/{solidBuilders-8xytLt8-.js → solidBuilders-DT1gpVWM.js} +5 -5
  83. package/dist/{solidBuilders-BWbqhbyv.cjs → solidBuilders-iS5DDwg8.cjs} +5 -5
  84. package/dist/{surfaceBuilders-CwG_RPdZ.cjs → surfaceBuilders-BvwSgD3C.cjs} +3 -3
  85. package/dist/{surfaceBuilders-BO96DMCH.js → surfaceBuilders-CPLe0bbk.js} +3 -3
  86. package/dist/text.cjs +2 -2
  87. package/dist/text.js +2 -2
  88. package/dist/{textBlueprints-Dhe8_Uvc.js → textBlueprints-BU0Rhk54.js} +19 -11
  89. package/dist/{textBlueprints-DHfYmLtP.cjs → textBlueprints-CNPCPJix.cjs} +19 -11
  90. package/dist/{textMetrics-CwYDH9js.cjs → textMetrics-C71g4TmO.cjs} +1 -1
  91. package/dist/{textMetrics-Bbf-Dllw.js → textMetrics-Df9aLYK2.js} +1 -1
  92. package/dist/{threadFns-B23RqugN.cjs → threadFns-CzXEnnmo.cjs} +37 -29
  93. package/dist/{threadFns-Cn7_bmux.js → threadFns-DESH7lcs.js} +36 -28
  94. package/dist/topology/apiTypes.d.ts +13 -7
  95. package/dist/topology.cjs +9 -9
  96. package/dist/topology.d.ts +1 -1
  97. package/dist/topology.js +9 -9
  98. package/dist/{topologyQueryFns-xh11vEQw.cjs → topologyQueryFns-5Frx8Y-0.cjs} +1 -1
  99. package/dist/{topologyQueryFns-BfYdGOJc.js → topologyQueryFns-LXV1nTaS.js} +1 -1
  100. package/dist/{validityTypes-CXkecqMw.cjs → validityTypes-C6rROGTP.cjs} +1 -1
  101. package/dist/{validityTypes-BfOuvfyp.js → validityTypes-DM-Iwe8N.js} +1 -1
  102. package/package.json +2 -1
@@ -1,7 +1,7 @@
1
- import { q as getKernel } from "./shapeTypes-DAz6aAnJ.js";
1
+ import { q as getKernel } from "./shapeTypes-DwvQUp9M.js";
2
2
  import { E as ok, d as validationError, g as err, t as BrepErrorCode } from "./errors-BTccWbtE.js";
3
- import { E as kernelCallRaw } from "./topologyQueryFns-BfYdGOJc.js";
4
- import { m as uvBounds } from "./faceFns-7eHqNM0P.js";
3
+ import { E as kernelCallRaw } from "./topologyQueryFns-LXV1nTaS.js";
4
+ import { m as uvBounds } from "./faceFns-iVPbTxki.js";
5
5
  // src/measurement/measureCache.ts
6
6
  var cache = /* @__PURE__ */ new WeakMap();
7
7
  function getCachedMeasurement(shape, key) {
@@ -27,6 +27,66 @@ function nullShapeErr(fn) {
27
27
  return err(validationError(BrepErrorCode.NULL_SHAPE_INPUT, `${fn}: shape is a null shape`));
28
28
  }
29
29
  /**
30
+ * Run `fn` on fresh handles to the distinct sub-shapes of `type`, releasing them
31
+ * afterwards. Unlike getFaces and friends this leaves the shape's topology cache
32
+ * alone, so a measurement allocates nothing that outlives it.
33
+ */
34
+ function withSubShapes(shape, type, fn) {
35
+ const kernel = getKernel();
36
+ const items = kernel.iterShapes(shape.wrapped, type);
37
+ try {
38
+ return fn(items);
39
+ } finally {
40
+ for (const item of items) kernel.dispose(item);
41
+ }
42
+ }
43
+ /** Run `fn` on a throwaway compound of `parts`, releasing the compound afterwards. */
44
+ function withCompoundOf(parts, fn) {
45
+ const kernel = getKernel();
46
+ const c = kernel.makeCompound(parts);
47
+ try {
48
+ return fn(c);
49
+ } finally {
50
+ kernel.dispose(c);
51
+ }
52
+ }
53
+ function volumeOf(target) {
54
+ const kernel = getKernel();
55
+ const m = kernel.volume(target);
56
+ const comResult = kernelCallRaw(() => kernel.centerOfMass(target), BrepErrorCode.CENTER_OF_MASS_FAILED, "Failed to compute center of mass");
57
+ if (!comResult.ok) return comResult;
58
+ return ok({
59
+ mass: m,
60
+ volume: m,
61
+ centerOfMass: comResult.value
62
+ });
63
+ }
64
+ /** Area-weighted centroid of `faces`, from each face's own surface center of mass. */
65
+ function surfaceCentroid(faces) {
66
+ const kernel = getKernel();
67
+ let total = 0;
68
+ let x = 0;
69
+ let y = 0;
70
+ let z = 0;
71
+ for (const f of faces) {
72
+ const a = kernel.area(f);
73
+ const [cx, cy, cz] = kernel.surfaceCenterOfMass(f);
74
+ total += a;
75
+ x += a * cx;
76
+ y += a * cy;
77
+ z += a * cz;
78
+ }
79
+ return total > 0 ? [
80
+ x / total,
81
+ y / total,
82
+ z / total
83
+ ] : [
84
+ 0,
85
+ 0,
86
+ 0
87
+ ];
88
+ }
89
+ /**
30
90
  * Measure volume properties of a 3D shape.
31
91
  *
32
92
  * @param shape - A solid or compound shape.
@@ -37,31 +97,23 @@ function measureVolumeProps(shape) {
37
97
  const cached = getCachedMeasurement(shape.wrapped, "volume");
38
98
  if (cached) return ok(cached);
39
99
  if (shapeIsNull(shape)) return nullShapeErr("measureVolumeProps");
40
- const kernel = getKernel();
41
- const type = kernel.shapeType(shape.wrapped);
42
- if (type !== "solid" && type !== "compsolid" && type !== "compound") {
43
- const zero = {
44
- mass: 0,
45
- volume: 0,
46
- centerOfMass: [
47
- 0,
48
- 0,
49
- 0
50
- ]
51
- };
52
- setCachedMeasurement(shape.wrapped, "volume", zero);
53
- return ok(zero);
54
- }
55
- const m = kernel.volume(shape.wrapped);
56
- const comResult = kernelCallRaw(() => kernel.centerOfMass(shape.wrapped), BrepErrorCode.CENTER_OF_MASS_FAILED, "Failed to compute center of mass");
57
- if (!comResult.ok) return comResult;
58
- const result = {
59
- mass: m,
60
- volume: m,
61
- centerOfMass: comResult.value
100
+ const type = getKernel().shapeType(shape.wrapped);
101
+ const zero = {
102
+ mass: 0,
103
+ volume: 0,
104
+ centerOfMass: [
105
+ 0,
106
+ 0,
107
+ 0
108
+ ]
62
109
  };
63
- setCachedMeasurement(shape.wrapped, "volume", result);
64
- return ok(result);
110
+ let result;
111
+ if (type === "solid" || type === "compsolid") result = volumeOf(shape.wrapped);
112
+ else if (type === "compound") result = withSubShapes(shape, "solid", (solids) => solids.length === 0 ? ok(zero) : withCompoundOf(solids, volumeOf));
113
+ else result = ok(zero);
114
+ if (!result.ok) return result;
115
+ setCachedMeasurement(shape.wrapped, "volume", result.value);
116
+ return result;
65
117
  }
66
118
  /**
67
119
  * Measure surface properties of a face or 3D shape.
@@ -76,7 +128,7 @@ function measureSurfaceProps(shape) {
76
128
  if (shapeIsNull(shape)) return nullShapeErr("measureSurfaceProps");
77
129
  const kernel = getKernel();
78
130
  const m = kernel.area(shape.wrapped);
79
- const comResult = kernelCallRaw(() => kernel.centerOfMass(shape.wrapped), BrepErrorCode.CENTER_OF_MASS_FAILED, "Failed to compute center of mass");
131
+ const comResult = kernelCallRaw(() => kernel.shapeType(shape.wrapped) === "face" ? kernel.surfaceCenterOfMass(shape.wrapped) : withSubShapes(shape, "face", surfaceCentroid), BrepErrorCode.CENTER_OF_MASS_FAILED, "Failed to compute center of mass");
80
132
  if (!comResult.ok) return comResult;
81
133
  const result = {
82
134
  mass: m,
@@ -89,8 +141,9 @@ function measureSurfaceProps(shape) {
89
141
  /**
90
142
  * Measure linear properties of any shape.
91
143
  *
92
- * For edges this is the arc length; for wires/compounds it is the total
93
- * length of all edges.
144
+ * For edges this is the arc length; for wires and faces it is the total length
145
+ * of their edges; for shells, solids, and compounds it is the total length of
146
+ * their distinct edges, each counted once.
94
147
  *
95
148
  * @param shape - Any shape whose linear extent is to be measured.
96
149
  * @returns `Result` containing length, center of mass, and raw mass property.
@@ -101,12 +154,26 @@ function measureLinearProps(shape) {
101
154
  if (cached) return ok(cached);
102
155
  if (shapeIsNull(shape)) return nullShapeErr("measureLinearProps");
103
156
  const kernel = getKernel();
104
- const m = kernel.length(shape.wrapped);
105
- const result = {
106
- mass: m,
107
- length: m,
108
- centerOfMass: kernel.linearCenterOfMass(shape.wrapped)
157
+ const type = kernel.shapeType(shape.wrapped);
158
+ const linearOf = (target) => {
159
+ const m = kernel.length(target);
160
+ return {
161
+ mass: m,
162
+ length: m,
163
+ centerOfMass: kernel.linearCenterOfMass(target)
164
+ };
109
165
  };
166
+ let result;
167
+ if (type === "vertex" || type === "edge" || type === "wire" || type === "face") result = linearOf(shape.wrapped);
168
+ else result = withSubShapes(shape, "edge", (edges) => edges.length === 0 ? {
169
+ mass: 0,
170
+ length: 0,
171
+ centerOfMass: [
172
+ 0,
173
+ 0,
174
+ 0
175
+ ]
176
+ } : withCompoundOf(edges, linearOf));
110
177
  setCachedMeasurement(shape.wrapped, "linear", result);
111
178
  return ok(result);
112
179
  }
@@ -22,8 +22,9 @@ export declare function measureSurfaceProps(shape: Face<Dimension> | Shape3D): R
22
22
  /**
23
23
  * Measure linear properties of any shape.
24
24
  *
25
- * For edges this is the arc length; for wires/compounds it is the total
26
- * length of all edges.
25
+ * For edges this is the arc length; for wires and faces it is the total length
26
+ * of their edges; for shells, solids, and compounds it is the total length of
27
+ * their distinct edges, each counted once.
27
28
  *
28
29
  * @param shape - Any shape whose linear extent is to be measured.
29
30
  * @returns `Result` containing length, center of mass, and raw mass property.
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_measureFns = require("./measureFns-Ce01LVwq.cjs");
3
- const require_principalBoxFns = require("./principalBoxFns-tIv-crMB.cjs");
2
+ const require_measureFns = require("./measureFns-CZHNWkiA.cjs");
3
+ const require_principalBoxFns = require("./principalBoxFns-CG6kG7vT.cjs");
4
4
  exports.createDistanceQuery = require_measureFns.createDistanceQuery;
5
5
  exports.measureArea = require_measureFns.measureArea;
6
6
  exports.measureDistance = require_measureFns.measureDistance;
@@ -1,3 +1,3 @@
1
- import { a as measureDistance, c as measureLinearProps, d as measureVolumeProps, l as measureSurfaceProps, n as measureArea, o as measureDistanceProps, s as measureLength, t as createDistanceQuery, u as measureVolume } from "./measureFns-1IfNe629.js";
2
- import { t as principalBoundingBox } from "./principalBoxFns-DsfWOoXg.js";
1
+ import { a as measureDistance, c as measureLinearProps, d as measureVolumeProps, l as measureSurfaceProps, n as measureArea, o as measureDistanceProps, s as measureLength, t as createDistanceQuery, u as measureVolume } from "./measureFns-mxBdPiWa.js";
2
+ import { t as principalBoundingBox } from "./principalBoxFns-3mW_hA6z.js";
3
3
  export { createDistanceQuery, measureArea, measureDistance, measureDistanceProps, measureLength, measureLinearProps, measureSurfaceProps, measureVolume, measureVolumeProps, principalBoundingBox };
@@ -1,7 +1,7 @@
1
- const require_shapeTypes = require("./shapeTypes-DJT3SnGK.cjs");
1
+ const require_shapeTypes = require("./shapeTypes-Dc7j-MYg.cjs");
2
2
  const require_errors = require("./errors-O_blYTWT.cjs");
3
- const require_topologyQueryFns = require("./topologyQueryFns-xh11vEQw.cjs");
4
- const require_originTrackingFns = require("./originTrackingFns-9gyCMFFQ.cjs");
3
+ const require_topologyQueryFns = require("./topologyQueryFns-5Frx8Y-0.cjs");
4
+ const require_originTrackingFns = require("./originTrackingFns-CHymOLLm.cjs");
5
5
  // src/topology/meshCache.ts
6
6
  /**
7
7
  * Build a parameter key for the inner cache map (excludes shape identity).
@@ -1,7 +1,7 @@
1
- import { q as getKernel, ut as qualityDeflection } from "./shapeTypes-DAz6aAnJ.js";
1
+ import { q as getKernel, ut as qualityDeflection } from "./shapeTypes-DwvQUp9M.js";
2
2
  import { E as ok, g as err, r as ioError } from "./errors-BTccWbtE.js";
3
- import { d as getSolids, n as getBounds } from "./topologyQueryFns-BfYdGOJc.js";
4
- import { t as getFaceOrigins } from "./originTrackingFns-zrksCJTa.js";
3
+ import { d as getSolids, n as getBounds } from "./topologyQueryFns-LXV1nTaS.js";
4
+ import { t as getFaceOrigins } from "./originTrackingFns-CBnyKLm7.js";
5
5
  // src/topology/meshCache.ts
6
6
  /**
7
7
  * Build a parameter key for the inner cache map (excludes shape identity).