brepjs 18.119.2 → 18.119.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 (100) hide show
  1. package/dist/2d/blueprints/blueprints.d.ts +3 -0
  2. package/dist/2d/blueprints/compoundBlueprint.d.ts +3 -0
  3. package/dist/2d/blueprints/lib.d.ts +6 -0
  4. package/dist/2d/lib/curve2D.d.ts +6 -1
  5. package/dist/2d/lib/curve2dFns.d.ts +6 -1
  6. package/dist/2d.cjs +7 -7
  7. package/dist/2d.js +7 -7
  8. package/dist/{adjacencyFns-BdM5p58J.js → adjacencyFns-DLityMyV.js} +2 -2
  9. package/dist/{adjacencyFns-Brrc7jlS.cjs → adjacencyFns-DSxuQYnb.cjs} +2 -2
  10. package/dist/{blueprint-DJJo8WkI.js → blueprint-DEMSX-hc.js} +37 -10
  11. package/dist/{blueprint-DTNT4qYJ.cjs → blueprint-DUnNPwQL.cjs} +43 -10
  12. package/dist/{blueprintFns-CcpboZ80.js → blueprintFns-DSj4RTjU.js} +9 -4
  13. package/dist/{blueprintFns-2XDZfCxX.cjs → blueprintFns-Dg8V99O9.cjs} +9 -4
  14. package/dist/{blueprintSketcher-DDPyypmC.js → blueprintSketcher-gMuUUPb-.js} +185 -54
  15. package/dist/{blueprintSketcher-C0EXFVb2.cjs → blueprintSketcher-gXVPrPlj.cjs} +192 -61
  16. package/dist/{boolean2D-Ddfo_dd0.cjs → boolean2D-BpmxQ1AH.cjs} +5 -5
  17. package/dist/{boolean2D-C_PVz8xT.js → boolean2D-DKT0BgZs.js} +5 -5
  18. package/dist/brepjs.cjs +105 -92
  19. package/dist/brepjs.js +39 -27
  20. package/dist/{cameraFns-Czr5vABD.cjs → cameraFns-2-haLzLi.cjs} +4 -4
  21. package/dist/{cameraFns-D9tdBYLM.js → cameraFns-CG_J66Hl.js} +4 -4
  22. package/dist/core.cjs +12 -11
  23. package/dist/core.js +4 -3
  24. package/dist/{cornerFinder-Cqg-Dz74.js → cornerFinder-CPFM7bA0.js} +1 -1
  25. package/dist/{cornerFinder-DETRDOMz.cjs → cornerFinder-mfsUMi5g.cjs} +1 -1
  26. package/dist/{curveFns-RENXKp64.js → curveFns-DX13KRh2.js} +2 -2
  27. package/dist/{curveFns-D7utcbnf.cjs → curveFns-GmFnqNo3.cjs} +2 -2
  28. package/dist/{drawFns-D9Rf4foW.cjs → drawFns-CI6CpqO8.cjs} +35 -16
  29. package/dist/{drawFns-B9HbtAoc.js → drawFns-CrfBz_wj.js} +35 -16
  30. package/dist/{errors-B3CDG537.js → errors-MHLiNE-C.js} +1 -92
  31. package/dist/{errors-CJU8CHng.cjs → errors-RHkKO5bZ.cjs} +0 -103
  32. package/dist/{faceFns-CPswi9Cm.cjs → faceFns-BK4r7Dxk.cjs} +3 -3
  33. package/dist/{faceFns-CB6uzvOg.js → faceFns-DJj9Nb6T.js} +3 -3
  34. package/dist/{healingFns-BFTYLiAm.js → healingFns-DxcRyVCG.js} +5 -6
  35. package/dist/{healingFns-bhMxTTqw.cjs → healingFns-Hx4oTlq8.cjs} +27 -28
  36. package/dist/{helpers-Cu4ag5bh.cjs → helpers-BfkBvokP.cjs} +8 -24
  37. package/dist/{helpers-BiN4qQZP.js → helpers-Du_OdHuy.js} +9 -25
  38. package/dist/{importFns-X8vBhZI2.js → importFns-DqxAZFb-.js} +3 -3
  39. package/dist/{importFns-DS4J1xLv.cjs → importFns-pr-r5qiV.cjs} +3 -3
  40. package/dist/io.cjs +2 -2
  41. package/dist/io.js +2 -2
  42. package/dist/{loftFns-ChHjzUK-.cjs → loftFns-BdpZ8FMN.cjs} +2 -125
  43. package/dist/{loftFns-BF5X7ltI.js → loftFns-BeGJ6dxx.js} +4 -109
  44. package/dist/{measureFns-B5Zzg1qM.cjs → measureFns-CJGrmhHT.cjs} +4 -4
  45. package/dist/{measureFns-CC7HhAH3.js → measureFns-CMnbcUZC.js} +4 -4
  46. package/dist/measurement.cjs +1 -1
  47. package/dist/measurement.js +1 -1
  48. package/dist/{meshFns-D57Fyqyf.js → meshFns-Cs5EBsf7.js} +4 -4
  49. package/dist/{meshFns-CaXmWmhe.cjs → meshFns-Dqf5QBhQ.cjs} +5 -5
  50. package/dist/operations.cjs +2 -2
  51. package/dist/operations.js +2 -2
  52. package/dist/originTrackingFns-DZmdiQ-O.js +203 -0
  53. package/dist/originTrackingFns-fpEgTIwV.cjs +226 -0
  54. package/dist/{planeOps-Cp6GQ23-.js → planeOps-CQahLrCx.js} +1 -1
  55. package/dist/{planeOps-Cr25KWWA.cjs → planeOps-VlFxtvzY.cjs} +1 -1
  56. package/dist/primitiveFns-B_rflH83.cjs +773 -0
  57. package/dist/primitiveFns-Cxo3xDKY.js +558 -0
  58. package/dist/projection.cjs +1 -1
  59. package/dist/projection.js +1 -1
  60. package/dist/query.cjs +2 -2
  61. package/dist/query.js +2 -2
  62. package/dist/{refResolveFns-3bw9-U-e.js → refResolveFns-BbRLD8LA.js} +6 -6
  63. package/dist/{refResolveFns-BxmgIhQM.cjs → refResolveFns-CVDLwh12.cjs} +6 -6
  64. package/dist/result.cjs +1 -1
  65. package/dist/result.js +1 -1
  66. package/dist/rolldown-runtime-DakpK96I.cjs +43 -0
  67. package/dist/shapeFns-BTFx-os7.js +43 -0
  68. package/dist/shapeFns-D_5TgiUi.cjs +84 -0
  69. package/dist/shapeRef.cjs +1 -1
  70. package/dist/shapeRef.js +1 -1
  71. package/dist/{shapeTypes-Bpsu5KJO.cjs → shapeTypes-CkcIL7zv.cjs} +1 -222
  72. package/dist/{shapeTypes-CnKFSfDT.js → shapeTypes-t49f64Dx.js} +2 -139
  73. package/dist/sketching/drawing.d.ts +9 -1
  74. package/dist/sketching.cjs +3 -3
  75. package/dist/sketching.js +3 -3
  76. package/dist/{solidBuilders-I8_V8qqU.js → solidBuilders-DTgqQC3W.js} +310 -8
  77. package/dist/{solidBuilders-Bp7lQW62.cjs → solidBuilders-IiIzjKAr.cjs} +401 -15
  78. package/dist/{surfaceBuilders-D8_08oOR.cjs → surfaceBuilders-Biqx51el.cjs} +6 -5
  79. package/dist/{surfaceBuilders-BNR7yMQO.js → surfaceBuilders-BryY-i0F.js} +4 -3
  80. package/dist/text.cjs +2 -2
  81. package/dist/text.js +2 -2
  82. package/dist/{textBlueprints-B5zcLGvJ.cjs → textBlueprints-BY0FEg59.cjs} +138 -51
  83. package/dist/{textBlueprints-igbNvKcd.js → textBlueprints-ZzYg3XTS.js} +116 -11
  84. package/dist/{textMetrics-CJvtpbc3.js → textMetrics-Diakbtem.js} +2 -2
  85. package/dist/{textMetrics-08fF0QNf.cjs → textMetrics-f5yXR4OG.cjs} +2 -2
  86. package/dist/{threadFns-CqSMNyTZ.js → threadFns-BOtXTHZ9.js} +8 -8
  87. package/dist/{threadFns-Co6vWEWx.cjs → threadFns-DRrk9Qod.cjs} +8 -8
  88. package/dist/topology.cjs +9 -9
  89. package/dist/topology.js +9 -9
  90. package/dist/{topologyQueryFns-C3fhJndG.cjs → topologyQueryFns-Bia7o8l_.cjs} +97 -6
  91. package/dist/{topologyQueryFns-DNqT88yx.js → topologyQueryFns-BkQ6Q7gN.js} +93 -2
  92. package/dist/validityTypes-DiTgeCD9.js +129 -0
  93. package/dist/validityTypes-ZGMVlv7b.cjs +200 -0
  94. package/dist/vectors.cjs +1 -1
  95. package/dist/vectors.js +1 -1
  96. package/package.json +8 -8
  97. package/dist/primitiveFns-CRy_CUVg.cjs +0 -492
  98. package/dist/primitiveFns-DCIH-SBm.js +0 -331
  99. package/dist/shapeFns-BrHFNLMA.js +0 -771
  100. package/dist/shapeFns-qm9VRo4i.cjs +0 -962
@@ -0,0 +1,226 @@
1
+ const require_shapeTypes = require("./shapeTypes-CkcIL7zv.cjs");
2
+ const require_topologyQueryFns = require("./topologyQueryFns-Bia7o8l_.cjs");
3
+ const require_constants = require("./constants-BOVyEYGH.cjs");
4
+ //#region src/topology/metadata/originTrackingFns.ts
5
+ /**
6
+ * Face origin tracking — tag faces with integer origins and propagate
7
+ * them through kernel operations via ShapeEvolution records.
8
+ */
9
+ /**
10
+ * Tag all faces of a shape with an opaque integer origin.
11
+ * Consumers assign meaning (e.g., source line number).
12
+ */
13
+ function setShapeOrigin(shape, origin) {
14
+ const cache = require_topologyQueryFns.getOrCreateCache(shape);
15
+ const map = /* @__PURE__ */ new Map();
16
+ for (const hash of require_topologyQueryFns.subShapeHashes(shape, "face")) map.set(hash, origin);
17
+ cache.faceOrigins = map;
18
+ }
19
+ /**
20
+ * Get the face origin map for a shape (faceHash → originTag).
21
+ * Returns undefined if no origins have been set or propagated.
22
+ */
23
+ function getFaceOrigins(shape) {
24
+ return require_topologyQueryFns.getCacheEntry(shape)?.faceOrigins;
25
+ }
26
+ /**
27
+ * Propagate face origins using a kernel-provided ShapeEvolution record.
28
+ */
29
+ function propagateOriginsFromEvolution(evolution, inputs, result) {
30
+ const inputOrigins = /* @__PURE__ */ new Map();
31
+ for (const input of inputs) {
32
+ const origins = getFaceOrigins(input);
33
+ if (!origins) continue;
34
+ for (const [hash, origin] of origins) inputOrigins.set(hash, origin);
35
+ }
36
+ if (inputOrigins.size === 0) return;
37
+ const resultMap = /* @__PURE__ */ new Map();
38
+ for (const [hash, origin] of inputOrigins) {
39
+ if (evolution.deleted.has(hash)) continue;
40
+ const modifiedHashes = evolution.modified.get(hash);
41
+ if (modifiedHashes && modifiedHashes.length > 0) for (const modHash of modifiedHashes) resultMap.set(modHash, origin);
42
+ else resultMap.set(hash, origin);
43
+ const generatedHashes = evolution.generated.get(hash);
44
+ if (generatedHashes) {
45
+ for (const genHash of generatedHashes) if (!resultMap.has(genHash)) resultMap.set(genHash, origin);
46
+ }
47
+ }
48
+ if (resultMap.size > 0) {
49
+ const cache = require_topologyQueryFns.getOrCreateCache(result);
50
+ cache.faceOrigins = resultMap;
51
+ }
52
+ }
53
+ /** Max 3D centroid separation (mm²) for a "near" match — the general case. */
54
+ var MAX_MATCH_DIST_SQ = 100;
55
+ /** Min |outNormal·inNormal| for two faces to count as sharing a plane's orientation. */
56
+ var COPLANAR_NORMAL_MIN = .985;
57
+ /**
58
+ * Max squared perpendicular offset (mm²) from an input face's plane for the
59
+ * output face to count as *coplanar* with it — i.e. a piece the boolean sliced
60
+ * off that same planar surface. 0.1mm² tolerates kernel/mesh float noise while
61
+ * still separating floors that sit even a fraction of a mm apart in depth.
62
+ */
63
+ var COPLANAR_OFFSET_SQ = .1;
64
+ /**
65
+ * Find the best origin match for a result face by comparing normals and centroids
66
+ * against input face signatures. Returns `undefined` if no good match exists.
67
+ *
68
+ * Two passes, near strictly preferred:
69
+ * 1. Near match — same-facing normal (signed dot ≥ 0.707) and centroids within
70
+ * {@link MAX_MATCH_DIST_SQ}. The general case for regenerated seam faces
71
+ * (feature tops, flush walls). Unchanged legacy behavior. If any near match
72
+ * exists it wins outright — the coplanar pass never runs — so a distant
73
+ * coplanar candidate can't outscore a valid near one.
74
+ * 2. Coplanar match (only when no near match, and only between PLANAR faces) —
75
+ * the output face lies on an input face's plane (parallel *or* antiparallel
76
+ * normal, tiny perpendicular offset) regardless of how far its centroid
77
+ * drifted in-plane. Two cases pass 1 misses:
78
+ * • A boolean that splits a large planar face — a wide cutout floor sliced
79
+ * by an overlapping deeper cutout — leaves pieces >10mm from the parent
80
+ * centroid (past pass 1's cutoff).
81
+ * • A cut flips the cavity face's normal versus the tool face it came from,
82
+ * so the floor is antiparallel to its origin's input face.
83
+ * Both left the surface tagless → body color in multi-color consumers
84
+ * (gridfinity GH #2443). The planar gate keeps a curved output face from
85
+ * inheriting an origin off an unrelated face that merely shares a sampled
86
+ * tangent plane; among coplanar candidates the nearest in-plane wins.
87
+ */
88
+ function findBestOriginMatch(outNormal, outCentroid, outPlanar, inputSigs) {
89
+ let bestNearScore = -Infinity;
90
+ let bestNear;
91
+ for (const inp of inputSigs) {
92
+ const dot = outNormal[0] * inp.normal[0] + outNormal[1] * inp.normal[1] + outNormal[2] * inp.normal[2];
93
+ if (dot < .707) continue;
94
+ const dx = outCentroid[0] - inp.centroid[0];
95
+ const dy = outCentroid[1] - inp.centroid[1];
96
+ const dz = outCentroid[2] - inp.centroid[2];
97
+ const distSq = dx * dx + dy * dy + dz * dz;
98
+ if (distSq > MAX_MATCH_DIST_SQ) continue;
99
+ const score = dot - distSq / MAX_MATCH_DIST_SQ;
100
+ if (score > bestNearScore) {
101
+ bestNearScore = score;
102
+ bestNear = inp.origin;
103
+ }
104
+ }
105
+ if (bestNear !== void 0) return bestNear;
106
+ if (!outPlanar) return void 0;
107
+ let bestInPlaneSq = Infinity;
108
+ let bestCoplanar;
109
+ for (const inp of inputSigs) {
110
+ if (!inp.planar) continue;
111
+ const dot = outNormal[0] * inp.normal[0] + outNormal[1] * inp.normal[1] + outNormal[2] * inp.normal[2];
112
+ if (Math.abs(dot) < COPLANAR_NORMAL_MIN) continue;
113
+ const dx = outCentroid[0] - inp.centroid[0];
114
+ const dy = outCentroid[1] - inp.centroid[1];
115
+ const dz = outCentroid[2] - inp.centroid[2];
116
+ const perp = dx * inp.normal[0] + dy * inp.normal[1] + dz * inp.normal[2];
117
+ if (perp * perp > COPLANAR_OFFSET_SQ) continue;
118
+ const inPlaneSq = Math.max(0, dx * dx + dy * dy + dz * dz - perp * perp);
119
+ if (inPlaneSq < bestInPlaneSq) {
120
+ bestInPlaneSq = inPlaneSq;
121
+ bestCoplanar = inp.origin;
122
+ }
123
+ }
124
+ return bestCoplanar;
125
+ }
126
+ /**
127
+ * Fallback origin propagation when no kernel op object is available
128
+ * (native `fuseAll` / `cutAll`, which expose no ShapeEvolution record).
129
+ *
130
+ * Matches result faces to input faces by hash code first. Faces that pass
131
+ * through the boolean unchanged keep their hash and recover their origin
132
+ * directly. Faces the boolean *regenerates* (split, merged, or re-created at
133
+ * the intersection) get a fresh hash that matches no input — these fall back
134
+ * to geometric matching (normal + centroid) against the input face
135
+ * signatures.
136
+ *
137
+ * The geometric pass runs for every unmatched face, not only when the hash
138
+ * pass found nothing. A partial hash match is the common case for additive
139
+ * features (pass-through side walls match by hash; the surfaces where the
140
+ * tool meets the body — feature tops, flush walls — are regenerated and need
141
+ * the geometric pass). Gating the fallback on "zero hash matches" left those
142
+ * regenerated faces with no origin, so they fell back to 0 (body) at mesh
143
+ * time — the multi-color export bug where a scoop/label/lip top printed in
144
+ * the body color. Matching against the full signature set (body origin 0
145
+ * included) keeps body faces body and feature faces feature.
146
+ */
147
+ function propagateOriginsByHash(inputs, result) {
148
+ const lookup = /* @__PURE__ */ new Map();
149
+ for (const input of inputs) {
150
+ const origins = getFaceOrigins(input);
151
+ if (!origins) continue;
152
+ for (const [hash, origin] of origins) lookup.set(hash, origin);
153
+ }
154
+ if (lookup.size === 0) return;
155
+ const kernel = require_shapeTypes.getKernel();
156
+ const resultMap = /* @__PURE__ */ new Map();
157
+ const resultFaces = require_topologyQueryFns.getFaces(result);
158
+ const unmatched = [];
159
+ for (const f of resultFaces) {
160
+ const hash = kernel.hashCode(f.wrapped, require_constants.HASH_CODE_MAX);
161
+ const origin = lookup.get(hash);
162
+ if (origin !== void 0) resultMap.set(hash, origin);
163
+ else unmatched.push(f);
164
+ }
165
+ if (unmatched.length > 0) {
166
+ const inputSigs = [];
167
+ for (const input of inputs) {
168
+ const origins = getFaceOrigins(input);
169
+ if (!origins) continue;
170
+ for (const f of require_topologyQueryFns.getFaces(input)) {
171
+ const hash = kernel.hashCode(f.wrapped, require_constants.HASH_CODE_MAX);
172
+ const origin = origins.get(hash);
173
+ if (origin === void 0) continue;
174
+ try {
175
+ const bounds = kernel.uvBounds(f.wrapped);
176
+ const normal = kernel.surfaceNormal(f.wrapped, .5 * (bounds.uMin + bounds.uMax), .5 * (bounds.vMin + bounds.vMax));
177
+ const centroid = kernel.surfaceCenterOfMass(f.wrapped);
178
+ const planar = kernel.surfaceType(f.wrapped) === "plane";
179
+ inputSigs.push({
180
+ origin,
181
+ normal,
182
+ centroid,
183
+ planar
184
+ });
185
+ } catch {}
186
+ }
187
+ }
188
+ if (inputSigs.length > 0) for (const f of unmatched) {
189
+ const hash = kernel.hashCode(f.wrapped, require_constants.HASH_CODE_MAX);
190
+ try {
191
+ const outBounds = kernel.uvBounds(f.wrapped);
192
+ const bestOrigin = findBestOriginMatch(kernel.surfaceNormal(f.wrapped, .5 * (outBounds.uMin + outBounds.uMax), .5 * (outBounds.vMin + outBounds.vMax)), kernel.surfaceCenterOfMass(f.wrapped), kernel.surfaceType(f.wrapped) === "plane", inputSigs);
193
+ if (bestOrigin !== void 0) resultMap.set(hash, bestOrigin);
194
+ } catch {}
195
+ }
196
+ }
197
+ if (resultMap.size > 0) {
198
+ const cache = require_topologyQueryFns.getOrCreateCache(result);
199
+ cache.faceOrigins = resultMap;
200
+ }
201
+ }
202
+ //#endregion
203
+ Object.defineProperty(exports, "getFaceOrigins", {
204
+ enumerable: true,
205
+ get: function() {
206
+ return getFaceOrigins;
207
+ }
208
+ });
209
+ Object.defineProperty(exports, "propagateOriginsByHash", {
210
+ enumerable: true,
211
+ get: function() {
212
+ return propagateOriginsByHash;
213
+ }
214
+ });
215
+ Object.defineProperty(exports, "propagateOriginsFromEvolution", {
216
+ enumerable: true,
217
+ get: function() {
218
+ return propagateOriginsFromEvolution;
219
+ }
220
+ });
221
+ Object.defineProperty(exports, "setShapeOrigin", {
222
+ enumerable: true,
223
+ get: function() {
224
+ return setShapeOrigin;
225
+ }
226
+ });
@@ -1,4 +1,4 @@
1
- import { I as unwrap, O as ok, d as validationError, v as err } from "./errors-B3CDG537.js";
1
+ import { E as ok, P as unwrap, d as validationError, g as err } from "./errors-MHLiNE-C.js";
2
2
  import { t as DEG2RAD } from "./constants-ITRzCnCp.js";
3
3
  import { r as toVec3 } from "./types-D24Y27N0.js";
4
4
  import { d as vecNormalize, h as vecScale, m as vecRotate, r as vecCross, s as vecIsZero, t as vecAdd } from "./vecOps-SKPRvPH-.js";
@@ -1,4 +1,4 @@
1
- const require_errors = require("./errors-CJU8CHng.cjs");
1
+ const require_errors = require("./errors-RHkKO5bZ.cjs");
2
2
  const require_constants = require("./constants-BOVyEYGH.cjs");
3
3
  const require_types = require("./types-KjA8tY4Y.cjs");
4
4
  const require_vecOps = require("./vecOps-CCnJt-yH.cjs");