brepjs 13.2.0 → 14.1.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 (147) hide show
  1. package/dist/2d/curve2dGeometryFns.d.ts +107 -0
  2. package/dist/2d/curve2dGeometryFns.d.ts.map +1 -0
  3. package/dist/2d.cjs +230 -3
  4. package/dist/2d.d.ts +2 -0
  5. package/dist/2d.d.ts.map +1 -1
  6. package/dist/2d.js +207 -4
  7. package/dist/arrayAccess-CmulMesb.cjs +40 -0
  8. package/dist/arrayAccess-xxcB3YNq.js +23 -0
  9. package/dist/{blueprint-DYCdRlW5.js → blueprint-B3A5x7P9.js} +10 -10
  10. package/dist/{blueprint-PLJan-W5.cjs → blueprint-D0XChcek.cjs} +14 -14
  11. package/dist/{blueprintFns-eWh7NpZx.js → blueprintFns-BwAMXY3t.js} +3 -3
  12. package/dist/{blueprintFns-Bsx25BG7.cjs → blueprintFns-COrEYX29.cjs} +3 -3
  13. package/dist/{boolean2D-CtB21ajK.cjs → boolean2D-BPsyKImE.cjs} +20 -19
  14. package/dist/{boolean2D-52qVCooY.js → boolean2D-D_Te-6N6.js} +13 -12
  15. package/dist/{booleanFns-BrptUFkP.cjs → booleanFns-B6M6Lm0V.cjs} +24 -22
  16. package/dist/{booleanFns-iM6UPb8e.js → booleanFns-CgsaJFBf.js} +8 -6
  17. package/dist/brepjs.cjs +304 -211
  18. package/dist/brepjs.js +188 -145
  19. package/dist/constants-B9u763C3.js +9 -0
  20. package/dist/constants-unWN8k4c.cjs +26 -0
  21. package/dist/core/curve2dHandle.d.ts +27 -0
  22. package/dist/core/curve2dHandle.d.ts.map +1 -0
  23. package/dist/core/errors.d.ts +11 -1
  24. package/dist/core/errors.d.ts.map +1 -1
  25. package/dist/core/kernelCall.d.ts.map +1 -1
  26. package/dist/core/kernelErrorTranslation.d.ts +2 -0
  27. package/dist/core/kernelErrorTranslation.d.ts.map +1 -1
  28. package/dist/core.cjs +9 -8
  29. package/dist/core.js +6 -5
  30. package/dist/{cornerFinder-C7aDyYLJ.js → cornerFinder-AEFnAxt4.js} +3 -3
  31. package/dist/{cornerFinder-SF-xmMO1.cjs → cornerFinder-DTt_SvtC.cjs} +4 -4
  32. package/dist/{curveFns-C-jU1_Y_.js → curveFns-CcInoOEA.js} +2 -2
  33. package/dist/{curveFns-ywh7Ctyk.cjs → curveFns-DCEcwcpd.cjs} +2 -2
  34. package/dist/{drawFns-DknEB-Qs.cjs → drawFns-BOwBIzPa.cjs} +35 -18
  35. package/dist/{drawFns-D-0p86Lf.js → drawFns-n9qif7QN.js} +17 -15
  36. package/dist/{errors-DupKEMqI.cjs → errors-9zQcQK1H.cjs} +34 -0
  37. package/dist/{errors-B_T0aMQF.js → errors-C-cgQA3w.js} +29 -1
  38. package/dist/{extrudeFns-LsH1rDMa.js → extrudeFns-DrDr9-nU.js} +3 -3
  39. package/dist/{extrudeFns-CGCIbydL.cjs → extrudeFns-Rcut7h8S.cjs} +3 -3
  40. package/dist/{faceFns-EnGcKFAr.js → faceFns-TSH54pPQ.js} +94 -4
  41. package/dist/{faceFns-8dGb8q3J.cjs → faceFns-cE2WxY6I.cjs} +111 -3
  42. package/dist/{helpers-pQpV9Mwh.cjs → helpers-DZje6XWE.cjs} +18 -17
  43. package/dist/{helpers-Rf0vhX6I.js → helpers-XrXlKm8D.js} +8 -7
  44. package/dist/{historyFns-XkjLAQyu.js → historyFns-2hCWrX_X.js} +10 -10
  45. package/dist/{historyFns-lNalnOdR.cjs → historyFns-BiQ9dmzp.cjs} +10 -10
  46. package/dist/{importFns-BSH9cGIp.cjs → importFns-DGE5nCSW.cjs} +4 -4
  47. package/dist/{importFns-Bgs-FYAP.js → importFns-m0xyj0Zt.js} +4 -4
  48. package/dist/index.d.ts +14 -0
  49. package/dist/index.d.ts.map +1 -1
  50. package/dist/io.cjs +2 -2
  51. package/dist/io.js +2 -2
  52. package/dist/kernel/brepkit/brepkitAdapter.d.ts +150 -241
  53. package/dist/kernel/brepkit/brepkitAdapter.d.ts.map +1 -1
  54. package/dist/kernel/brepkit/evolutionOps.d.ts +1 -0
  55. package/dist/kernel/brepkit/evolutionOps.d.ts.map +1 -1
  56. package/dist/kernel/index.d.ts +1 -1
  57. package/dist/kernel/index.d.ts.map +1 -1
  58. package/dist/kernel/interfaces/curveOps.d.ts +3 -1
  59. package/dist/kernel/interfaces/curveOps.d.ts.map +1 -1
  60. package/dist/kernel/interfaces/surfaceOps.d.ts +3 -1
  61. package/dist/kernel/interfaces/surfaceOps.d.ts.map +1 -1
  62. package/dist/kernel/occt/defaultAdapter.d.ts +3 -1
  63. package/dist/kernel/occt/defaultAdapter.d.ts.map +1 -1
  64. package/dist/kernel/occt/nurbsQueryOps.d.ts +12 -0
  65. package/dist/kernel/occt/nurbsQueryOps.d.ts.map +1 -0
  66. package/dist/kernel/types.d.ts +26 -0
  67. package/dist/kernel/types.d.ts.map +1 -1
  68. package/dist/{measureFns-D7J6qUY_.js → measureFns-DHByqdmn.js} +9 -16
  69. package/dist/{measureFns-CFdHa_fj.cjs → measureFns-D_QKZ5yg.cjs} +9 -16
  70. package/dist/measurement/measureFns.d.ts.map +1 -1
  71. package/dist/measurement.cjs +1 -1
  72. package/dist/measurement.js +1 -1
  73. package/dist/{meshFns-2XnDXgIh.cjs → meshFns-CVe3Kc77.cjs} +4 -4
  74. package/dist/{meshFns-B7uklc4M.js → meshFns-DL4Djz3w.js} +3 -3
  75. package/dist/ns/booleans.d.ts +10 -0
  76. package/dist/ns/booleans.d.ts.map +1 -0
  77. package/dist/ns/construction.d.ts +10 -0
  78. package/dist/ns/construction.d.ts.map +1 -0
  79. package/dist/ns/ioNs.d.ts +18 -0
  80. package/dist/ns/ioNs.d.ts.map +1 -0
  81. package/dist/ns/measurement.d.ts +6 -0
  82. package/dist/ns/measurement.d.ts.map +1 -0
  83. package/dist/ns/modifiers.d.ts +6 -0
  84. package/dist/ns/modifiers.d.ts.map +1 -0
  85. package/dist/ns/patterns.d.ts +5 -0
  86. package/dist/ns/patterns.d.ts.map +1 -0
  87. package/dist/ns/primitives.d.ts +7 -0
  88. package/dist/ns/primitives.d.ts.map +1 -0
  89. package/dist/ns/query.d.ts +6 -0
  90. package/dist/ns/query.d.ts.map +1 -0
  91. package/dist/ns/transforms.d.ts +5 -0
  92. package/dist/ns/transforms.d.ts.map +1 -0
  93. package/dist/operations.cjs +2 -2
  94. package/dist/operations.js +2 -2
  95. package/dist/{planeOps-cTxDywpG.cjs → planeOps-6Wu7dMDN.cjs} +5 -4
  96. package/dist/{planeOps-BuBXTLBr.js → planeOps-gTOEarV2.js} +4 -3
  97. package/dist/{primitiveFns-DKtvEA0i.cjs → primitiveFns-CRPGjIFg.cjs} +101 -69
  98. package/dist/{primitiveFns-CASk8g16.js → primitiveFns-CeKiYSSW.js} +28 -8
  99. package/dist/query.cjs +2 -2
  100. package/dist/query.js +2 -2
  101. package/dist/result.cjs +1 -1
  102. package/dist/result.js +1 -1
  103. package/dist/{arrayAccess-Dps31ERU.js → shapeFns-DCi9O27X.js} +8 -30
  104. package/dist/{arrayAccess-peFKE9Ob.cjs → shapeFns-aEeSHNqX.cjs} +24 -64
  105. package/dist/shapeRef.cjs +8 -0
  106. package/dist/shapeRef.d.ts +5 -0
  107. package/dist/shapeRef.d.ts.map +1 -0
  108. package/dist/shapeRef.js +2 -0
  109. package/dist/shapeRefFns-B1TODUMl.js +194 -0
  110. package/dist/shapeRefFns-CVdS6jWS.cjs +229 -0
  111. package/dist/{shapeTypes-CYb8Byqj.js → shapeTypes-BO1aiDhi.js} +3937 -3697
  112. package/dist/{shapeTypes-CElaawp7.cjs → shapeTypes-BqWQlrYE.cjs} +3937 -3697
  113. package/dist/sketching.cjs +2 -2
  114. package/dist/sketching.js +2 -2
  115. package/dist/{solidBuilders-Cs4XyL58.cjs → solidBuilders-0iVdiZUw.cjs} +3 -3
  116. package/dist/{solidBuilders-ClJxiUa3.js → solidBuilders-jk7HfWs8.js} +3 -3
  117. package/dist/{surfaceBuilders-ZUTb3z6i.cjs → surfaceBuilders-C_8rs79F.cjs} +3 -3
  118. package/dist/{surfaceBuilders-DnGdDW8i.js → surfaceBuilders-DE5e6bp8.js} +3 -3
  119. package/dist/topology/api.d.ts +3 -3
  120. package/dist/topology/api.d.ts.map +1 -1
  121. package/dist/topology/nurbsFns.d.ts +13 -0
  122. package/dist/topology/nurbsFns.d.ts.map +1 -0
  123. package/dist/topology/shapeFns.d.ts +4 -3
  124. package/dist/topology/shapeFns.d.ts.map +1 -1
  125. package/dist/topology/shapeRef/index.d.ts +7 -0
  126. package/dist/topology/shapeRef/index.d.ts.map +1 -0
  127. package/dist/topology/shapeRef/scoring.d.ts +16 -0
  128. package/dist/topology/shapeRef/scoring.d.ts.map +1 -0
  129. package/dist/topology/shapeRef/shapeRefFns.d.ts +47 -0
  130. package/dist/topology/shapeRef/shapeRefFns.d.ts.map +1 -0
  131. package/dist/topology/shapeRef/shapeRefTypes.d.ts +40 -0
  132. package/dist/topology/shapeRef/shapeRefTypes.d.ts.map +1 -0
  133. package/dist/topology.cjs +22 -20
  134. package/dist/topology.d.ts +1 -0
  135. package/dist/topology.d.ts.map +1 -1
  136. package/dist/topology.js +7 -7
  137. package/dist/{vecOps-4iBMiet9.cjs → vecOps-BXvBYIor.cjs} +0 -26
  138. package/dist/{vecOps-B9-MTeC8.js → vecOps-D9etjPgV.js} +1 -9
  139. package/dist/vectors.cjs +6 -5
  140. package/dist/vectors.js +4 -3
  141. package/dist/worker.cjs +1 -1
  142. package/dist/worker.js +1 -1
  143. package/package.json +14 -4
  144. /package/dist/{types-Bb4KK_iG.js → types-BWBlwp6w.js} +0 -0
  145. /package/dist/{types-BD-VVaWB.cjs → types-BjDcsS7l.cjs} +0 -0
  146. /package/dist/{workerHandler-nLkvSOKX.cjs → workerHandler-C-7OUJsa.cjs} +0 -0
  147. /package/dist/{workerHandler-BrOTzYRI.js → workerHandler-o2xzAfFk.js} +0 -0
@@ -0,0 +1,229 @@
1
+ const require_faceFns = require("./faceFns-cE2WxY6I.cjs");
2
+ const require_shapeFns = require("./shapeFns-aEeSHNqX.cjs");
3
+ const require_measureFns = require("./measureFns-D_QKZ5yg.cjs");
4
+ //#region src/topology/shapeRef/scoring.ts
5
+ /**
6
+ * Default face scorer combining surface type, normal alignment, centroid proximity,
7
+ * and area similarity.
8
+ *
9
+ * Scoring breakdown:
10
+ * - Surface type match: +1.0 (mismatch when both defined: -Infinity)
11
+ * - Normal dot product: weighted contribution (rejected if < 0.707)
12
+ * - Centroid distance: quadratic penalty (rejected if distSq > 100)
13
+ * - Area ratio: penalized if |log(hintArea / faceArea)| > 1.0
14
+ */
15
+ function defaultScorer(hint, face) {
16
+ let score = 0;
17
+ const faceType = require_faceFns.faceGeomType(face);
18
+ if (hint.surfaceType !== void 0) if (faceType === hint.surfaceType) score += 1;
19
+ else return -Infinity;
20
+ if (hint.normal !== void 0) {
21
+ const faceNormal = require_faceFns.normalAt(face);
22
+ const dot = hint.normal[0] * faceNormal[0] + hint.normal[1] * faceNormal[1] + hint.normal[2] * faceNormal[2];
23
+ if (dot < .707) return -Infinity;
24
+ score += dot;
25
+ }
26
+ if (hint.centroid !== void 0) {
27
+ const faceCentroid = require_faceFns.faceCenter(face);
28
+ const dx = hint.centroid[0] - faceCentroid[0];
29
+ const dy = hint.centroid[1] - faceCentroid[1];
30
+ const dz = hint.centroid[2] - faceCentroid[2];
31
+ const distSq = dx * dx + dy * dy + dz * dz;
32
+ if (distSq > 100) return -Infinity;
33
+ score -= distSq / 100;
34
+ }
35
+ if (hint.area !== void 0 && hint.area > 0) {
36
+ const areaResult = require_measureFns.measureArea(face);
37
+ if (areaResult.ok && areaResult.value > 0) {
38
+ const logRatio = Math.abs(Math.log(hint.area / areaResult.value));
39
+ if (logRatio > 1) score -= logRatio;
40
+ }
41
+ }
42
+ return score;
43
+ }
44
+ //#endregion
45
+ //#region src/topology/shapeRef/shapeRefFns.ts
46
+ /** Snapshot the geometric properties of a face for later matching. */
47
+ function captureHint(face) {
48
+ const surfaceType = require_faceFns.faceGeomType(face);
49
+ const normal = require_faceFns.normalAt(face);
50
+ const centroid = require_faceFns.faceCenter(face);
51
+ const areaResult = require_measureFns.measureArea(face);
52
+ return {
53
+ entityType: "face",
54
+ surfaceType,
55
+ normal,
56
+ centroid,
57
+ area: areaResult.ok ? areaResult.value : void 0
58
+ };
59
+ }
60
+ /** Threshold for dominant-axis detection (abs(component) > 0.9). */
61
+ var AXIS_THRESHOLD = .9;
62
+ /** Determine the cardinal role name for a box face from its outward normal. */
63
+ function boxRoleFromNormal(n) {
64
+ if (n[2] > AXIS_THRESHOLD) return "box:top";
65
+ if (n[2] < -AXIS_THRESHOLD) return "box:bottom";
66
+ if (n[1] > AXIS_THRESHOLD) return "box:back";
67
+ if (n[1] < -AXIS_THRESHOLD) return "box:front";
68
+ if (n[0] > AXIS_THRESHOLD) return "box:right";
69
+ if (n[0] < -AXIS_THRESHOLD) return "box:left";
70
+ }
71
+ /**
72
+ * Auto-assign role names to the faces of a shape based on operation type.
73
+ *
74
+ * For 'box': uses face normals to assign cardinal names
75
+ * ('box:top', 'box:bottom', 'box:front', 'box:back', 'box:left', 'box:right').
76
+ * **Note:** Box role detection assumes axis-aligned faces (normal within 0.9 of
77
+ * a cardinal axis). Rotated boxes may receive fewer than 6 named roles; remaining
78
+ * faces fall through to sequential naming.
79
+ *
80
+ * For other types: sequential naming ('opType:face_0', 'opType:face_1', ...).
81
+ *
82
+ * @returns Map from role name to face hash code
83
+ */
84
+ function assignRoles(shape, operationType) {
85
+ const faces = require_shapeFns.getFaces(shape);
86
+ const roles = /* @__PURE__ */ new Map();
87
+ if (operationType === "box") {
88
+ for (const face of faces) {
89
+ const role = boxRoleFromNormal(require_faceFns.normalAt(face));
90
+ if (role !== void 0 && !roles.has(role)) roles.set(role, require_shapeFns.getHashCode(face));
91
+ }
92
+ return roles;
93
+ }
94
+ let index = 0;
95
+ for (const face of faces) {
96
+ roles.set(`${operationType}:face_${index}`, require_shapeFns.getHashCode(face));
97
+ index++;
98
+ }
99
+ return roles;
100
+ }
101
+ /** Create a ShapeRef from an origin ID, role name, and face. */
102
+ function createRef(origin, role, face) {
103
+ return {
104
+ origin,
105
+ role,
106
+ hint: captureHint(face)
107
+ };
108
+ }
109
+ /**
110
+ * Propagate a role table through a ShapeEvolution record.
111
+ * Returns a new RoleTable with hashes updated according to the evolution.
112
+ *
113
+ * - Deleted faces: role removed
114
+ * - Modified faces: hash updated to first result hash
115
+ * - Unchanged faces: hash preserved
116
+ *
117
+ * **Limitation:** When a face splits (1→many in `evolution.modified`), only the
118
+ * first successor hash is tracked. The geometric fallback in `resolveRef` handles
119
+ * cases where this picks the "wrong" successor. A future version may return
120
+ * multi-hash mappings for split-aware resolution.
121
+ */
122
+ function updateRoles(roles, origin, evolution) {
123
+ const originRoles = roles.get(origin);
124
+ if (!originRoles) return roles;
125
+ const updatedOriginRoles = /* @__PURE__ */ new Map();
126
+ for (const [role, hash] of originRoles) {
127
+ if (evolution.deleted.has(hash)) continue;
128
+ const modifiedHashes = evolution.modified.get(hash);
129
+ if (modifiedHashes && modifiedHashes.length > 0) updatedOriginRoles.set(role, modifiedHashes[0]);
130
+ else updatedOriginRoles.set(role, hash);
131
+ }
132
+ const newRoles = /* @__PURE__ */ new Map();
133
+ for (const [key, value] of roles) if (key === origin) newRoles.set(key, updatedOriginRoles);
134
+ else newRoles.set(key, value);
135
+ return newRoles;
136
+ }
137
+ /** Ambiguity threshold: if two scores are within this range, it's ambiguous. */
138
+ var AMBIGUITY_THRESHOLD = .1;
139
+ /** Minimum score for geometric fallback to accept a match. */
140
+ var MIN_SCORE = .5;
141
+ /**
142
+ * Resolve a ShapeRef to a face in the current shape.
143
+ *
144
+ * Resolution strategy:
145
+ * 1. Exact lookup via role table hash match
146
+ * 2. Geometric fallback using scorer against all faces
147
+ * 3. Ambiguous if multiple faces score within threshold
148
+ * 4. Not-found if no match above minimum score
149
+ */
150
+ function resolveRef(ref, roles, currentShape, scorer) {
151
+ const faces = require_shapeFns.getFaces(currentShape);
152
+ const scoreFn = scorer ?? defaultScorer;
153
+ const targetHash = roles.get(ref.origin)?.get(ref.role);
154
+ if (targetHash !== void 0) {
155
+ for (const face of faces) if (require_shapeFns.getHashCode(face) === targetHash) return {
156
+ face,
157
+ confidence: "exact"
158
+ };
159
+ return {
160
+ ref,
161
+ reason: "deleted"
162
+ };
163
+ }
164
+ let bestScore = -Infinity;
165
+ let bestFace;
166
+ let secondBestScore = -Infinity;
167
+ const scored = [];
168
+ for (const face of faces) {
169
+ const score = scoreFn(ref.hint, face);
170
+ if (score > MIN_SCORE) scored.push([face, score]);
171
+ if (score > bestScore) {
172
+ secondBestScore = bestScore;
173
+ bestScore = score;
174
+ bestFace = face;
175
+ } else if (score > secondBestScore) secondBestScore = score;
176
+ }
177
+ if (bestFace !== void 0 && bestScore > MIN_SCORE) {
178
+ if (bestScore - secondBestScore < AMBIGUITY_THRESHOLD && scored.length > 1) return {
179
+ ref,
180
+ reason: "ambiguous",
181
+ candidates: scored.filter(([, s]) => s >= bestScore - AMBIGUITY_THRESHOLD).map(([f]) => f)
182
+ };
183
+ return {
184
+ face: bestFace,
185
+ confidence: "geometric-fallback"
186
+ };
187
+ }
188
+ return {
189
+ ref,
190
+ reason: "not-found"
191
+ };
192
+ }
193
+ //#endregion
194
+ Object.defineProperty(exports, "assignRoles", {
195
+ enumerable: true,
196
+ get: function() {
197
+ return assignRoles;
198
+ }
199
+ });
200
+ Object.defineProperty(exports, "captureHint", {
201
+ enumerable: true,
202
+ get: function() {
203
+ return captureHint;
204
+ }
205
+ });
206
+ Object.defineProperty(exports, "createRef", {
207
+ enumerable: true,
208
+ get: function() {
209
+ return createRef;
210
+ }
211
+ });
212
+ Object.defineProperty(exports, "defaultScorer", {
213
+ enumerable: true,
214
+ get: function() {
215
+ return defaultScorer;
216
+ }
217
+ });
218
+ Object.defineProperty(exports, "resolveRef", {
219
+ enumerable: true,
220
+ get: function() {
221
+ return resolveRef;
222
+ }
223
+ });
224
+ Object.defineProperty(exports, "updateRoles", {
225
+ enumerable: true,
226
+ get: function() {
227
+ return updateRoles;
228
+ }
229
+ });