brepjs 20.12.4 → 20.12.5
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.
- package/dist/2d.cjs +6 -6
- package/dist/2d.js +6 -6
- package/dist/{adjacencyFns-54UTqtan.js → adjacencyFns-B2Po1gPs.js} +3 -3
- package/dist/{adjacencyFns-C_Vb1AeW.cjs → adjacencyFns-Cho9v3Q3.cjs} +3 -3
- package/dist/{blueprint-D0VEeTzJ.cjs → blueprint-ERmwk6zG.cjs} +5 -5
- package/dist/{blueprint-DFpjcrlm.js → blueprint-Zmt5-07y.js} +5 -5
- package/dist/{blueprintFns-Douf5ZdX.cjs → blueprintFns-B_sxtIo7.cjs} +2 -2
- package/dist/{blueprintFns-Dye1jezD.js → blueprintFns-Dtm-XukP.js} +2 -2
- package/dist/{blueprintSketcher-W9yON-UC.cjs → blueprintSketcher-CZyokLGJ.cjs} +3 -3
- package/dist/{blueprintSketcher-Cr0Lr1Dq.js → blueprintSketcher-CwTAtrkY.js} +3 -3
- package/dist/{boolean2D-C9VghXHG.cjs → boolean2D-CRuNKgXs.cjs} +4 -4
- package/dist/{boolean2D-CCV3R6lN.js → boolean2D-yUpS8onH.js} +4 -4
- package/dist/brepjs.cjs +128 -100
- package/dist/brepjs.js +128 -100
- package/dist/{cameraFns-x3L6dtA8.cjs → cameraFns-DB1IyMmS.cjs} +3 -3
- package/dist/{cameraFns-DZOI_ewG.js → cameraFns-DRok4UxZ.js} +3 -3
- package/dist/core.cjs +2 -2
- package/dist/core.js +2 -2
- package/dist/{cornerFinder-BY10jciz.js → cornerFinder-D5qnDbtZ.js} +1 -1
- package/dist/{cornerFinder-B8PqO4um.cjs → cornerFinder-DfYBHHZG.cjs} +1 -1
- package/dist/{curveFns-B4308HNM.js → curveFns-BGPSFUWB.js} +1 -1
- package/dist/{curveFns-8lUhNquZ.cjs → curveFns-BKT4Sg8q.cjs} +1 -1
- package/dist/{drawFns-C7zAvera.cjs → drawFns-D8e5RiRe.cjs} +23 -15
- package/dist/{drawFns-DjnU3fEd.js → drawFns-aGufr-pr.js} +23 -15
- package/dist/{faceFns-BjmlYcc9.cjs → faceFns-Cx7cwUMx.cjs} +2 -2
- package/dist/{faceFns-7eHqNM0P.js → faceFns-lE2OvBfq.js} +2 -2
- package/dist/{healingFns-BW7mZ_SW.js → healingFns-B94zSk1-.js} +5 -5
- package/dist/{healingFns-CYLIcIWv.cjs → healingFns-CcgyrL6h.cjs} +5 -5
- package/dist/{helpers-De0Z_6iV.cjs → helpers-C4f2MV-r.cjs} +14 -10
- package/dist/{helpers-BQ6XMFcm.js → helpers-CNgipe6l.js} +14 -10
- package/dist/{importFns-3IMBHQrQ.cjs → importFns-fIdcaMqt.cjs} +2 -2
- package/dist/{importFns-BCL4-H8e.js → importFns-gB1X3ti2.js} +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/io.cjs +2 -2
- package/dist/io.js +2 -2
- package/dist/kernel/occtWasm/constructionOps.d.ts +1 -1
- package/dist/kernel/occtWasm/occtWasmAdapter.cjs +1 -1
- package/dist/kernel/occtWasm/occtWasmAdapter.d.ts +1 -1
- package/dist/kernel/occtWasm/occtWasmAdapter.js +1 -1
- package/dist/kernel/occtWasm/occtWasmTypes.d.ts +5 -0
- package/dist/{loftFns-DlG5oR0X.cjs → loftFns-AHaYxJyS.cjs} +17 -2
- package/dist/{loftFns-H4ZOpRAk.js → loftFns-mbyBvJ8Y.js} +17 -2
- package/dist/{measureFns-1IfNe629.js → measureFns-C94G0fH8.js} +102 -35
- package/dist/{measureFns-Ce01LVwq.cjs → measureFns-CuabRDRL.cjs} +102 -35
- package/dist/measurement/measureFns.d.ts +3 -2
- package/dist/measurement.cjs +2 -2
- package/dist/measurement.js +2 -2
- package/dist/{meshFns-nEvfwNRF.cjs → meshFns-GXF5gPZL.cjs} +3 -3
- package/dist/{meshFns-DaRZxa7B.js → meshFns-jarDZKw1.js} +3 -3
- package/dist/{occtWasmAdapter-CRd9RFEu.cjs → occtWasmAdapter-DeoeK2iJ.cjs} +7 -4
- package/dist/{occtWasmAdapter-ipKUdNLN.js → occtWasmAdapter-DlNmVNUn.js} +7 -4
- package/dist/operations/patternFns.d.ts +6 -1
- package/dist/operations.cjs +2 -2
- package/dist/operations.js +2 -2
- package/dist/{originTrackingFns-zrksCJTa.js → originTrackingFns-BxeUD2NM.js} +2 -2
- package/dist/{originTrackingFns-9gyCMFFQ.cjs → originTrackingFns-C-yuMV3m.cjs} +2 -2
- package/dist/{primitiveFns-BRXZ7jnP.cjs → primitiveFns-BVAkYHVf.cjs} +7 -14
- package/dist/{primitiveFns-ClQP6zMQ.js → primitiveFns-CualoFAk.js} +7 -14
- package/dist/{principalBoxFns-tIv-crMB.cjs → principalBoxFns-DHh5_HCw.cjs} +3 -3
- package/dist/{principalBoxFns-DsfWOoXg.js → principalBoxFns-DtI7tVuS.js} +3 -3
- package/dist/projection.cjs +1 -1
- package/dist/projection.js +1 -1
- package/dist/query/finderCore.d.ts +7 -7
- package/dist/query.cjs +2 -2
- package/dist/query.js +2 -2
- package/dist/{refResolveFns-BG3JGs--.js → refResolveFns--SRyN2qa.js} +6 -6
- package/dist/{refResolveFns-BZdUlv9f.cjs → refResolveFns-CaAw-ya3.cjs} +6 -6
- package/dist/{shapeFns-BCgegapL.js → shapeFns-CdrDroOM.js} +2 -2
- package/dist/{shapeFns-BbXqiNqY.cjs → shapeFns-CwjjUOr0.cjs} +2 -2
- package/dist/shapeRef.cjs +1 -1
- package/dist/shapeRef.js +1 -1
- package/dist/{shapeTypes-DJT3SnGK.cjs → shapeTypes-D938X2mg.cjs} +1 -1
- package/dist/{shapeTypes-DAz6aAnJ.js → shapeTypes-PNVEv6ga.js} +1 -1
- package/dist/sketching/sketches.d.ts +2 -0
- package/dist/sketching.cjs +3 -3
- package/dist/sketching.js +3 -3
- package/dist/{solidBuilders-BWbqhbyv.cjs → solidBuilders-CAkBQKWb.cjs} +5 -5
- package/dist/{solidBuilders-8xytLt8-.js → solidBuilders-Hft8Cr6a.js} +5 -5
- package/dist/{surfaceBuilders-CwG_RPdZ.cjs → surfaceBuilders-BKCiVf7T.cjs} +3 -3
- package/dist/{surfaceBuilders-BO96DMCH.js → surfaceBuilders-CrO_BBKM.js} +3 -3
- package/dist/text.cjs +2 -2
- package/dist/text.js +2 -2
- package/dist/{textBlueprints-Dhe8_Uvc.js → textBlueprints-B8q2a-nN.js} +19 -11
- package/dist/{textBlueprints-DHfYmLtP.cjs → textBlueprints-C9HeYc5a.cjs} +19 -11
- package/dist/{textMetrics-CwYDH9js.cjs → textMetrics-1fhCSAGF.cjs} +1 -1
- package/dist/{textMetrics-Bbf-Dllw.js → textMetrics-DJfTSy6w.js} +1 -1
- package/dist/{threadFns-B23RqugN.cjs → threadFns-CVIEbOW3.cjs} +37 -29
- package/dist/{threadFns-Cn7_bmux.js → threadFns-f2KwibLR.js} +36 -28
- package/dist/topology/apiTypes.d.ts +13 -7
- package/dist/topology.cjs +9 -9
- package/dist/topology.d.ts +1 -1
- package/dist/topology.js +9 -9
- package/dist/{topologyQueryFns-xh11vEQw.cjs → topologyQueryFns-4WYqtSFF.cjs} +1 -1
- package/dist/{topologyQueryFns-BfYdGOJc.js → topologyQueryFns-BZUY10TD.js} +1 -1
- package/dist/{validityTypes-BfOuvfyp.js → validityTypes-DAXIqwZM.js} +1 -1
- package/dist/{validityTypes-CXkecqMw.cjs → validityTypes-tWSx_zAH.cjs} +1 -1
- package/package.json +2 -1
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
const require_rolldown_runtime = require("./rolldown-runtime-BW-eSwOZ.cjs");
|
|
2
|
-
const require_shapeTypes = require("./shapeTypes-
|
|
2
|
+
const require_shapeTypes = require("./shapeTypes-D938X2mg.cjs");
|
|
3
3
|
const require_bug = require("./bug-CBcpIPuf.cjs");
|
|
4
4
|
const require_errors = require("./errors-O_blYTWT.cjs");
|
|
5
5
|
const require_constants = require("./constants-oee0S_x6.cjs");
|
|
6
6
|
const require_types = require("./types-CjF9Rofr.cjs");
|
|
7
7
|
const require_vecOps = require("./vecOps-CrGEPPQM.cjs");
|
|
8
8
|
const require_planeOps = require("./planeOps-DZfLToKZ.cjs");
|
|
9
|
-
const require_faceFns = require("./faceFns-
|
|
10
|
-
const require_solidBuilders = require("./solidBuilders-
|
|
9
|
+
const require_faceFns = require("./faceFns-Cx7cwUMx.cjs");
|
|
10
|
+
const require_solidBuilders = require("./solidBuilders-CAkBQKWb.cjs");
|
|
11
11
|
const require_faceRoleFns = require("./faceRoleFns-Db5bYj4Q.cjs");
|
|
12
|
-
const require_curveFns = require("./curveFns-
|
|
12
|
+
const require_curveFns = require("./curveFns-BKT4Sg8q.cjs");
|
|
13
13
|
const require_arrayAccess = require("./arrayAccess-DpJYARwv.cjs");
|
|
14
|
-
const require_surfaceBuilders = require("./surfaceBuilders-
|
|
15
|
-
const require_blueprintSketcher = require("./blueprintSketcher-
|
|
16
|
-
const require_loftFns = require("./loftFns-
|
|
14
|
+
const require_surfaceBuilders = require("./surfaceBuilders-BKCiVf7T.cjs");
|
|
15
|
+
const require_blueprintSketcher = require("./blueprintSketcher-CZyokLGJ.cjs");
|
|
16
|
+
const require_loftFns = require("./loftFns-AHaYxJyS.cjs");
|
|
17
17
|
let opentype_js = require("opentype.js");
|
|
18
18
|
opentype_js = require_rolldown_runtime.__toESM(opentype_js, 1);
|
|
19
19
|
// src/topology/shapeRef/extrudeRoleFns.ts
|
|
@@ -486,9 +486,13 @@ function sketchSweep(sketch, sketchOnPlane, sweepConfig = {}) {
|
|
|
486
486
|
...sweepConfig
|
|
487
487
|
};
|
|
488
488
|
if (sketch.baseFace) config.support = sketch.baseFace.wrapped;
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
489
|
+
try {
|
|
490
|
+
const shape = require_errors.unwrap(require_loftFns.sweep(profile.wire, sketch.wire, config));
|
|
491
|
+
sketch.delete();
|
|
492
|
+
return shape;
|
|
493
|
+
} finally {
|
|
494
|
+
profile.delete();
|
|
495
|
+
}
|
|
492
496
|
}
|
|
493
497
|
/**
|
|
494
498
|
* Loft between this sketch and one or more other sketches.
|
|
@@ -763,6 +767,10 @@ var Sketches = class {
|
|
|
763
767
|
if (!(only instanceof Sketch)) require_bug.bug(`Sketches.${op}`, `${op} is only supported on single-wire profiles.`);
|
|
764
768
|
return only;
|
|
765
769
|
}
|
|
770
|
+
/** Release the kernel resources of every contained sketch. */
|
|
771
|
+
delete() {
|
|
772
|
+
for (const s of this.sketches) s.delete();
|
|
773
|
+
}
|
|
766
774
|
/** Build a face from the sole contained profile (see {@link Sketches.faces}). */
|
|
767
775
|
face() {
|
|
768
776
|
if (this.sketches.length !== 1) require_bug.bug("Sketches.face", "Multiple profiles — use faces() to combine them.");
|
|
@@ -930,7 +938,7 @@ function textBlueprints(text, { startX = 0, startY = 0, fontSize = 16, fontFamil
|
|
|
930
938
|
let font = getFont(fontFamily);
|
|
931
939
|
if (!font) font = getFont();
|
|
932
940
|
if (!font) require_bug.bug("text", "No fonts loaded. Call loadFont() before using text functions.");
|
|
933
|
-
const writtenText = font.getPath(text,
|
|
941
|
+
const writtenText = font.getPath(text, startX, -startY, fontSize);
|
|
934
942
|
const blueprints = Array.from(sketchFontCommands(writtenText.commands));
|
|
935
943
|
return require_blueprintSketcher.organiseBlueprints(blueprints).mirror([0, 0]);
|
|
936
944
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const require_errors = require("./errors-O_blYTWT.cjs");
|
|
2
|
-
const require_textBlueprints = require("./textBlueprints-
|
|
2
|
+
const require_textBlueprints = require("./textBlueprints-C9HeYc5a.cjs");
|
|
3
3
|
// src/text/sketchText.ts
|
|
4
4
|
/**
|
|
5
5
|
* Render text as 3D sketch outlines on a plane.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { E as ok, d as validationError, g as err, t as BrepErrorCode } from "./errors-BTccWbtE.js";
|
|
2
|
-
import { _ as wrapSketchData, a as Sketches, n as getFont, t as textBlueprints, y as CompoundSketch } from "./textBlueprints-
|
|
2
|
+
import { _ as wrapSketchData, a as Sketches, n as getFont, t as textBlueprints, y as CompoundSketch } from "./textBlueprints-B8q2a-nN.js";
|
|
3
3
|
// src/text/sketchText.ts
|
|
4
4
|
/**
|
|
5
5
|
* Render text as 3D sketch outlines on a plane.
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
const require_shapeTypes = require("./shapeTypes-
|
|
1
|
+
const require_shapeTypes = require("./shapeTypes-D938X2mg.cjs");
|
|
2
2
|
const require_errors = require("./errors-O_blYTWT.cjs");
|
|
3
3
|
const require_vecOps = require("./vecOps-CrGEPPQM.cjs");
|
|
4
|
-
const require_faceFns = require("./faceFns-
|
|
5
|
-
const require_solidBuilders = require("./solidBuilders-
|
|
6
|
-
const require_primitiveFns = require("./primitiveFns-
|
|
7
|
-
const require_shapeFns = require("./shapeFns-
|
|
8
|
-
const require_loftFns = require("./loftFns-
|
|
9
|
-
const require_refResolveFns = require("./refResolveFns-
|
|
4
|
+
const require_faceFns = require("./faceFns-Cx7cwUMx.cjs");
|
|
5
|
+
const require_solidBuilders = require("./solidBuilders-CAkBQKWb.cjs");
|
|
6
|
+
const require_primitiveFns = require("./primitiveFns-BVAkYHVf.cjs");
|
|
7
|
+
const require_shapeFns = require("./shapeFns-CwjjUOr0.cjs");
|
|
8
|
+
const require_loftFns = require("./loftFns-AHaYxJyS.cjs");
|
|
9
|
+
const require_refResolveFns = require("./refResolveFns-CaAw-ya3.cjs");
|
|
10
10
|
// src/utils/uuid.ts
|
|
11
11
|
/** Generate a v4-style UUID string using `crypto.getRandomValues`. */
|
|
12
12
|
function uuidv() {
|
|
@@ -147,7 +147,7 @@ function quatMultiply(a, b) {
|
|
|
147
147
|
*/
|
|
148
148
|
function linearPattern(shape, direction, count, spacing, options) {
|
|
149
149
|
if (count < 1) return require_errors.err(require_errors.validationError("PATTERN_INVALID_COUNT", "Pattern count must be at least 1"));
|
|
150
|
-
if (count === 1) return
|
|
150
|
+
if (count === 1) return require_shapeFns.clone(shape);
|
|
151
151
|
if (require_vecOps.vecIsZero(direction)) return require_errors.err(require_errors.validationError("PATTERN_ZERO_DIRECTION", "Pattern direction cannot be zero"));
|
|
152
152
|
const dir = require_vecOps.vecNormalize(direction);
|
|
153
153
|
const copies = require_shapeTypes.getKernel().linearPattern(shape.wrapped, [...dir], spacing, count).map((s) => require_shapeTypes.castResultShape(s));
|
|
@@ -163,10 +163,15 @@ function linearPattern(shape, direction, count, spacing, options) {
|
|
|
163
163
|
/**
|
|
164
164
|
* Create a circular pattern of a shape around an axis.
|
|
165
165
|
*
|
|
166
|
+
* A full turn (`fullAngle` of ±360) spaces the copies `fullAngle / count`
|
|
167
|
+
* apart, so the last copy does not land on the first. Any other angle is an
|
|
168
|
+
* open arc: the first copy stays in place, the last lands at `fullAngle`, and
|
|
169
|
+
* they are spaced `fullAngle / (count - 1)` apart.
|
|
170
|
+
*
|
|
166
171
|
* @param shape - The shape to replicate
|
|
167
172
|
* @param axis - Rotation axis direction
|
|
168
173
|
* @param count - Total number of copies (including the original)
|
|
169
|
-
* @param fullAngle -
|
|
174
|
+
* @param fullAngle - Angle in degrees the copies span (default: 360)
|
|
170
175
|
* @param center - Center point of rotation (default: [0,0,0])
|
|
171
176
|
* @param options - Boolean options for the fuse operation
|
|
172
177
|
* @returns Fused shape of all copies
|
|
@@ -177,9 +182,9 @@ function circularPattern(shape, axis, count, fullAngle = 360, center = [
|
|
|
177
182
|
0
|
|
178
183
|
], options) {
|
|
179
184
|
if (count < 1) return require_errors.err(require_errors.validationError("PATTERN_INVALID_COUNT", "Pattern count must be at least 1"));
|
|
180
|
-
if (count === 1) return
|
|
185
|
+
if (count === 1) return require_shapeFns.clone(shape);
|
|
181
186
|
if (require_vecOps.vecIsZero(axis)) return require_errors.err(require_errors.validationError("PATTERN_ZERO_AXIS", "Pattern axis cannot be zero"));
|
|
182
|
-
const angleStep = fullAngle / count;
|
|
187
|
+
const angleStep = fullAngle / (Math.abs(Math.abs(fullAngle) - 360) < 1e-9 ? count : count - 1);
|
|
183
188
|
const copies = require_shapeTypes.getKernel().circularPattern(shape.wrapped, [...center], [...axis], angleStep, count).map((s) => require_shapeTypes.castResultShape(s));
|
|
184
189
|
try {
|
|
185
190
|
return require_solidBuilders.fuseAll(copies, {
|
|
@@ -204,24 +209,27 @@ function circularPattern(shape, axis, count, fullAngle = 360, center = [
|
|
|
204
209
|
* @returns Compound shape containing all copies, or fused result
|
|
205
210
|
*/
|
|
206
211
|
function gridPattern(shape, directionX, directionY, countX, countY, spacingX, spacingY, options) {
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
const
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
212
|
+
try {
|
|
213
|
+
var _usingCtx$2 = require_shapeTypes._usingCtx();
|
|
214
|
+
if (countX < 1 || countY < 1) return require_errors.err(require_errors.validationError("PATTERN_INVALID_COUNT", "Grid pattern counts must be at least 1"));
|
|
215
|
+
if (countX === 1 && countY === 1) return require_shapeFns.clone(shape);
|
|
216
|
+
if (require_vecOps.vecIsZero(directionX)) return require_errors.err(require_errors.validationError("PATTERN_ZERO_DIRECTION", "Grid directionX cannot be zero"));
|
|
217
|
+
if (require_vecOps.vecIsZero(directionY)) return require_errors.err(require_errors.validationError("PATTERN_ZERO_DIRECTION", "Grid directionY cannot be zero"));
|
|
218
|
+
const kernel = require_shapeTypes.getKernel();
|
|
219
|
+
const dirX = require_vecOps.vecNormalize(directionX);
|
|
220
|
+
const dirY = require_vecOps.vecNormalize(directionY);
|
|
221
|
+
if (typeof kernel.gridPattern === "function") {
|
|
222
|
+
const compound = kernel.gridPattern(shape.wrapped, [...dirX], [...dirY], spacingX, spacingY, countX, countY);
|
|
223
|
+
return require_errors.ok(require_shapeTypes.castResultShape(compound));
|
|
224
|
+
}
|
|
225
|
+
const rowResult = linearPattern(shape, directionX, countX, spacingX, options);
|
|
226
|
+
if (!rowResult.ok) return rowResult;
|
|
227
|
+
return linearPattern(_usingCtx$2.u(rowResult.value), directionY, countY, spacingY, options);
|
|
228
|
+
} catch (_) {
|
|
229
|
+
_usingCtx$2.e = _;
|
|
230
|
+
} finally {
|
|
231
|
+
_usingCtx$2.d();
|
|
232
|
+
}
|
|
225
233
|
}
|
|
226
234
|
// src/operations/exporterFns.ts
|
|
227
235
|
/**
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { F as createKernelHandle, G as _usingCtx, N as DisposalScope, n as castResultShape, q as getKernel, x as isShape3D } from "./shapeTypes-
|
|
1
|
+
import { F as createKernelHandle, G as _usingCtx, N as DisposalScope, n as castResultShape, q as getKernel, x as isShape3D } from "./shapeTypes-PNVEv6ga.js";
|
|
2
2
|
import { E as ok, d as validationError, g as err, n as computationError, r as ioError, t as BrepErrorCode, x as isOk } from "./errors-BTccWbtE.js";
|
|
3
3
|
import { d as vecNormalize, s as vecIsZero } from "./vecOps-S-m9H_fe.js";
|
|
4
|
-
import { b as fromBREP } from "./faceFns-
|
|
5
|
-
import { h as fuseAll } from "./solidBuilders-
|
|
6
|
-
import { E as wire, h as line } from "./primitiveFns-
|
|
7
|
-
import { s as toBREP } from "./shapeFns-
|
|
8
|
-
import { t as loft } from "./loftFns-
|
|
9
|
-
import { c as resolveRefParams } from "./refResolveFns
|
|
4
|
+
import { b as fromBREP } from "./faceFns-lE2OvBfq.js";
|
|
5
|
+
import { h as fuseAll } from "./solidBuilders-Hft8Cr6a.js";
|
|
6
|
+
import { E as wire, h as line } from "./primitiveFns-CualoFAk.js";
|
|
7
|
+
import { s as toBREP, t as clone } from "./shapeFns-CdrDroOM.js";
|
|
8
|
+
import { t as loft } from "./loftFns-mbyBvJ8Y.js";
|
|
9
|
+
import { c as resolveRefParams } from "./refResolveFns--SRyN2qa.js";
|
|
10
10
|
// src/utils/uuid.ts
|
|
11
11
|
/** Generate a v4-style UUID string using `crypto.getRandomValues`. */
|
|
12
12
|
function uuidv() {
|
|
@@ -147,7 +147,7 @@ function quatMultiply(a, b) {
|
|
|
147
147
|
*/
|
|
148
148
|
function linearPattern(shape, direction, count, spacing, options) {
|
|
149
149
|
if (count < 1) return err(validationError("PATTERN_INVALID_COUNT", "Pattern count must be at least 1"));
|
|
150
|
-
if (count === 1) return
|
|
150
|
+
if (count === 1) return clone(shape);
|
|
151
151
|
if (vecIsZero(direction)) return err(validationError("PATTERN_ZERO_DIRECTION", "Pattern direction cannot be zero"));
|
|
152
152
|
const dir = vecNormalize(direction);
|
|
153
153
|
const copies = getKernel().linearPattern(shape.wrapped, [...dir], spacing, count).map((s) => castResultShape(s));
|
|
@@ -163,10 +163,15 @@ function linearPattern(shape, direction, count, spacing, options) {
|
|
|
163
163
|
/**
|
|
164
164
|
* Create a circular pattern of a shape around an axis.
|
|
165
165
|
*
|
|
166
|
+
* A full turn (`fullAngle` of ±360) spaces the copies `fullAngle / count`
|
|
167
|
+
* apart, so the last copy does not land on the first. Any other angle is an
|
|
168
|
+
* open arc: the first copy stays in place, the last lands at `fullAngle`, and
|
|
169
|
+
* they are spaced `fullAngle / (count - 1)` apart.
|
|
170
|
+
*
|
|
166
171
|
* @param shape - The shape to replicate
|
|
167
172
|
* @param axis - Rotation axis direction
|
|
168
173
|
* @param count - Total number of copies (including the original)
|
|
169
|
-
* @param fullAngle -
|
|
174
|
+
* @param fullAngle - Angle in degrees the copies span (default: 360)
|
|
170
175
|
* @param center - Center point of rotation (default: [0,0,0])
|
|
171
176
|
* @param options - Boolean options for the fuse operation
|
|
172
177
|
* @returns Fused shape of all copies
|
|
@@ -177,9 +182,9 @@ function circularPattern(shape, axis, count, fullAngle = 360, center = [
|
|
|
177
182
|
0
|
|
178
183
|
], options) {
|
|
179
184
|
if (count < 1) return err(validationError("PATTERN_INVALID_COUNT", "Pattern count must be at least 1"));
|
|
180
|
-
if (count === 1) return
|
|
185
|
+
if (count === 1) return clone(shape);
|
|
181
186
|
if (vecIsZero(axis)) return err(validationError("PATTERN_ZERO_AXIS", "Pattern axis cannot be zero"));
|
|
182
|
-
const angleStep = fullAngle / count;
|
|
187
|
+
const angleStep = fullAngle / (Math.abs(Math.abs(fullAngle) - 360) < 1e-9 ? count : count - 1);
|
|
183
188
|
const copies = getKernel().circularPattern(shape.wrapped, [...center], [...axis], angleStep, count).map((s) => castResultShape(s));
|
|
184
189
|
try {
|
|
185
190
|
return fuseAll(copies, {
|
|
@@ -204,24 +209,27 @@ function circularPattern(shape, axis, count, fullAngle = 360, center = [
|
|
|
204
209
|
* @returns Compound shape containing all copies, or fused result
|
|
205
210
|
*/
|
|
206
211
|
function gridPattern(shape, directionX, directionY, countX, countY, spacingX, spacingY, options) {
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
const
|
|
216
|
-
|
|
212
|
+
try {
|
|
213
|
+
var _usingCtx$2 = _usingCtx();
|
|
214
|
+
if (countX < 1 || countY < 1) return err(validationError("PATTERN_INVALID_COUNT", "Grid pattern counts must be at least 1"));
|
|
215
|
+
if (countX === 1 && countY === 1) return clone(shape);
|
|
216
|
+
if (vecIsZero(directionX)) return err(validationError("PATTERN_ZERO_DIRECTION", "Grid directionX cannot be zero"));
|
|
217
|
+
if (vecIsZero(directionY)) return err(validationError("PATTERN_ZERO_DIRECTION", "Grid directionY cannot be zero"));
|
|
218
|
+
const kernel = getKernel();
|
|
219
|
+
const dirX = vecNormalize(directionX);
|
|
220
|
+
const dirY = vecNormalize(directionY);
|
|
221
|
+
if (typeof kernel.gridPattern === "function") {
|
|
222
|
+
const compound = kernel.gridPattern(shape.wrapped, [...dirX], [...dirY], spacingX, spacingY, countX, countY);
|
|
223
|
+
return ok(castResultShape(compound));
|
|
224
|
+
}
|
|
225
|
+
const rowResult = linearPattern(shape, directionX, countX, spacingX, options);
|
|
226
|
+
if (!rowResult.ok) return rowResult;
|
|
227
|
+
return linearPattern(_usingCtx$2.u(rowResult.value), directionY, countY, spacingY, options);
|
|
228
|
+
} catch (_) {
|
|
229
|
+
_usingCtx$2.e = _;
|
|
230
|
+
} finally {
|
|
231
|
+
_usingCtx$2.d();
|
|
217
232
|
}
|
|
218
|
-
const rowResult = linearPattern(shape, directionX, countX, spacingX, options);
|
|
219
|
-
if (!rowResult.ok) return rowResult;
|
|
220
|
-
const row = rowResult.value;
|
|
221
|
-
const out = linearPattern(row, directionY, countY, spacingY, options);
|
|
222
|
-
const passthrough = out.ok && out.value === row;
|
|
223
|
-
if (row !== shape && !passthrough) row[Symbol.dispose]();
|
|
224
|
-
return out;
|
|
225
233
|
}
|
|
226
234
|
// src/operations/exporterFns.ts
|
|
227
235
|
/**
|
|
@@ -2,13 +2,14 @@ import { Vec2, Vec3 } from '../core/types.js';
|
|
|
2
2
|
import { AnyShape, Dimension, Edge, Face, Wire, Shape3D } from '../core/shapeTypes.js';
|
|
3
3
|
import { EdgeFinderFn, FaceFinderFn, ShapeFinder } from '../query/finderFns.js';
|
|
4
4
|
/**
|
|
5
|
-
* Structural type matching a Drawing
|
|
6
|
-
* Used in place of importing the actual
|
|
7
|
-
* Layer 2 → Layer 3 boundary violations.
|
|
5
|
+
* Structural type matching a Drawing: it sketches onto a plane as something
|
|
6
|
+
* that builds a face (holes included). Used in place of importing the actual
|
|
7
|
+
* Drawing class to avoid Layer 2 → Layer 3 boundary violations.
|
|
8
8
|
*/
|
|
9
9
|
export interface DrawingLike {
|
|
10
|
-
sketchOnPlane(plane:
|
|
11
|
-
|
|
10
|
+
sketchOnPlane(plane: 'XY'): {
|
|
11
|
+
face(): Face;
|
|
12
|
+
delete?(): void;
|
|
12
13
|
};
|
|
13
14
|
}
|
|
14
15
|
type FinderFor<T extends AnyShape<Dimension>> = T extends Edge ? EdgeFinderFn : T extends Face ? FaceFinderFn : ShapeFinder<T>;
|
|
@@ -66,7 +67,12 @@ export interface DrillOptions {
|
|
|
66
67
|
}
|
|
67
68
|
/** Options for the pocket() compound operation. */
|
|
68
69
|
export interface PocketOptions {
|
|
69
|
-
/**
|
|
70
|
+
/**
|
|
71
|
+
* 2D profile to cut into the face, drawn in XY with its origin at the face
|
|
72
|
+
* centre. On faces parallel to XY it keeps the world X and Y axes; on any
|
|
73
|
+
* other face its Y axis runs up the face and its X axis points right as seen
|
|
74
|
+
* from outside.
|
|
75
|
+
*/
|
|
70
76
|
profile: DrawingLike | Wire;
|
|
71
77
|
/** Which face to pocket. Default: top face. */
|
|
72
78
|
face?: Face | FinderFn<Face>;
|
|
@@ -75,7 +81,7 @@ export interface PocketOptions {
|
|
|
75
81
|
}
|
|
76
82
|
/** Options for the boss() compound operation. */
|
|
77
83
|
export interface BossOptions {
|
|
78
|
-
/** 2D profile
|
|
84
|
+
/** 2D profile to extrude from the face, placed as for {@link PocketOptions.profile}. */
|
|
79
85
|
profile: DrawingLike | Wire;
|
|
80
86
|
/** Which face to add onto. Default: top face. */
|
|
81
87
|
face?: Face | FinderFn<Face>;
|
package/dist/topology.cjs
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_topologyQueryFns = require("./topologyQueryFns-
|
|
3
|
-
const require_faceFns = require("./faceFns-
|
|
4
|
-
const require_solidBuilders = require("./solidBuilders-
|
|
5
|
-
const require_primitiveFns = require("./primitiveFns-
|
|
6
|
-
const require_shapeFns = require("./shapeFns-
|
|
7
|
-
const require_curveFns = require("./curveFns-
|
|
8
|
-
const require_meshFns = require("./meshFns-
|
|
9
|
-
const require_healingFns = require("./healingFns-
|
|
10
|
-
const require_adjacencyFns = require("./adjacencyFns-
|
|
2
|
+
const require_topologyQueryFns = require("./topologyQueryFns-4WYqtSFF.cjs");
|
|
3
|
+
const require_faceFns = require("./faceFns-Cx7cwUMx.cjs");
|
|
4
|
+
const require_solidBuilders = require("./solidBuilders-CAkBQKWb.cjs");
|
|
5
|
+
const require_primitiveFns = require("./primitiveFns-BVAkYHVf.cjs");
|
|
6
|
+
const require_shapeFns = require("./shapeFns-CwjjUOr0.cjs");
|
|
7
|
+
const require_curveFns = require("./curveFns-BKT4Sg8q.cjs");
|
|
8
|
+
const require_meshFns = require("./meshFns-GXF5gPZL.cjs");
|
|
9
|
+
const require_healingFns = require("./healingFns-CcgyrL6h.cjs");
|
|
10
|
+
const require_adjacencyFns = require("./adjacencyFns-Cho9v3Q3.cjs");
|
|
11
11
|
exports.addHoles = require_primitiveFns.addHoles;
|
|
12
12
|
exports.adjacentFaces = require_adjacencyFns.adjacentFaces;
|
|
13
13
|
exports.approximateCurve = require_curveFns.approximateCurve;
|
package/dist/topology.d.ts
CHANGED
|
@@ -17,7 +17,7 @@ export { chamferDistAngle as chamferDistAngleShape } from './topology/chamferAng
|
|
|
17
17
|
export { variableFillet, type VariableFilletRadius } from './topology/modifierFns.js';
|
|
18
18
|
export { getCurveType, curveStartPoint, curveEndPoint, curvePointAt, curveTangentAt, curveAxis, curveLength, curveIsClosed, curveIsPeriodic, curvePeriod, getOrientation, flipOrientation, offsetWire2D, interpolateCurve, approximateCurve, type InterpolateCurveOptions, type ApproximateCurveOptions, } from './topology/curveFns.js';
|
|
19
19
|
export { getNurbsCurveData, getNurbsSurfaceData } from './topology/nurbsFns.js';
|
|
20
|
-
export { getSurfaceType, faceGeomType, faceOrientation, flipFaceOrientation, uvBounds, pointOnSurface, uvCoordinates, normalAt, faceCenter, faceAxis, classifyPointOnFace, outerWire, innerWires, projectPointOnFace, type UVBounds, type PointProjectionResult, } from './topology/faceFns.js';
|
|
20
|
+
export { getSurfaceType, faceGeomType, faceOrientation, flipFaceOrientation, uvBounds, pointOnSurface, uvCoordinates, normalAt, faceCenter, faceAxis, classifyPointOnFace, outerWire, innerWires, projectPointOnFace, type SurfaceType, type UVBounds, type PointProjectionResult, } from './topology/faceFns.js';
|
|
21
21
|
export { facesOfEdge, edgesOfFace, wiresOfFace, verticesOfEdge, adjacentFaces, sharedEdges, } from './topology/adjacencyFns.js';
|
|
22
22
|
export { exportSTEP, exportSTL, exportIGES, type ShapeMesh, type EdgeMesh, type MeshOptions, } from './topology/meshFns.js';
|
|
23
23
|
export { clearMeshCache, createMeshCache, type MeshCacheContext } from './topology/meshCache.js';
|
package/dist/topology.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { _ as iterFaces, b as iterVertices, c as getFaces, f as getVertices, g as iterEdges, m as invalidateShapeCache, n as getBounds, p as getWires, s as getEdges, w as vertexPosition, x as iterWires } from "./topologyQueryFns-
|
|
2
|
-
import { C as shapeType, S as iterTopo, _ as cast, a as faceOrientation, b as fromBREP, c as innerWires, d as pointOnSurface, f as projectPointOnFace, g as asTopo, h as uvCoordinates, i as faceGeomType, l as normalAt, m as uvBounds, n as faceAxis, o as flipFaceOrientation, r as faceCenter, s as getSurfaceType, t as classifyPointOnFace, u as outerWire, x as isCompSolid, y as downcast } from "./faceFns-
|
|
3
|
-
import { h as fuseAll, p as cutAll } from "./solidBuilders-
|
|
4
|
-
import { C as threePointArc, D as wireLoop, E as wire, S as tangentArc, T as vertex, _ as polygon, a as circle, b as sphere, c as cylinder, d as ellipsoid, f as face, g as offsetFace, h as line, i as bsplineApprox, l as ellipse, m as helix, n as bezier, o as compound, p as filledFace, r as box, s as cone, t as addHoles, u as ellipseArc, v as sewShells, w as torus, x as subFace, y as solid } from "./primitiveFns-
|
|
5
|
-
import { a as isSameShape, i as isEqualShape, n as getHashCode } from "./shapeFns-
|
|
6
|
-
import { a as curveIsPeriodic, c as curvePointAt, d as flipOrientation, f as getCurveType, h as offsetWire2D, i as curveIsClosed, l as curveStartPoint, m as interpolateCurve, n as curveAxis, o as curveLength, p as getOrientation, r as curveEndPoint, s as curvePeriod, t as approximateCurve, u as curveTangentAt } from "./curveFns-
|
|
7
|
-
import { d as clearMeshCache, f as createMeshCache, n as exportSTEP, r as exportSTL, t as exportIGES } from "./meshFns-
|
|
8
|
-
import { A as variableFillet, F as toLineGeometryData, M as toGroupedBufferGeometryData, S as chamferDistAngle, _ as checkBoolean, a as healFace, b as getNurbsCurveData, d as chamferWithEvolution, f as cutWithEvolution, g as shellWithEvolution, h as intersectWithEvolution, j as toBufferGeometryData, l as solidFromShell, m as fuseWithEvolution, n as fixSelfIntersection, o as healSolid, p as filletWithEvolution, r as fixShape, s as healWire, t as autoHeal, u as positionOnCurve, v as cutAllBisect, x as getNurbsSurfaceData, y as fuseAllBisect } from "./healingFns-
|
|
9
|
-
import { i as facesOfEdge, l as wiresOfFace, n as adjacentFaces, o as sharedEdges, r as edgesOfFace, s as verticesOfEdge } from "./adjacencyFns-
|
|
1
|
+
import { _ as iterFaces, b as iterVertices, c as getFaces, f as getVertices, g as iterEdges, m as invalidateShapeCache, n as getBounds, p as getWires, s as getEdges, w as vertexPosition, x as iterWires } from "./topologyQueryFns-BZUY10TD.js";
|
|
2
|
+
import { C as shapeType, S as iterTopo, _ as cast, a as faceOrientation, b as fromBREP, c as innerWires, d as pointOnSurface, f as projectPointOnFace, g as asTopo, h as uvCoordinates, i as faceGeomType, l as normalAt, m as uvBounds, n as faceAxis, o as flipFaceOrientation, r as faceCenter, s as getSurfaceType, t as classifyPointOnFace, u as outerWire, x as isCompSolid, y as downcast } from "./faceFns-lE2OvBfq.js";
|
|
3
|
+
import { h as fuseAll, p as cutAll } from "./solidBuilders-Hft8Cr6a.js";
|
|
4
|
+
import { C as threePointArc, D as wireLoop, E as wire, S as tangentArc, T as vertex, _ as polygon, a as circle, b as sphere, c as cylinder, d as ellipsoid, f as face, g as offsetFace, h as line, i as bsplineApprox, l as ellipse, m as helix, n as bezier, o as compound, p as filledFace, r as box, s as cone, t as addHoles, u as ellipseArc, v as sewShells, w as torus, x as subFace, y as solid } from "./primitiveFns-CualoFAk.js";
|
|
5
|
+
import { a as isSameShape, i as isEqualShape, n as getHashCode } from "./shapeFns-CdrDroOM.js";
|
|
6
|
+
import { a as curveIsPeriodic, c as curvePointAt, d as flipOrientation, f as getCurveType, h as offsetWire2D, i as curveIsClosed, l as curveStartPoint, m as interpolateCurve, n as curveAxis, o as curveLength, p as getOrientation, r as curveEndPoint, s as curvePeriod, t as approximateCurve, u as curveTangentAt } from "./curveFns-BGPSFUWB.js";
|
|
7
|
+
import { d as clearMeshCache, f as createMeshCache, n as exportSTEP, r as exportSTL, t as exportIGES } from "./meshFns-jarDZKw1.js";
|
|
8
|
+
import { A as variableFillet, F as toLineGeometryData, M as toGroupedBufferGeometryData, S as chamferDistAngle, _ as checkBoolean, a as healFace, b as getNurbsCurveData, d as chamferWithEvolution, f as cutWithEvolution, g as shellWithEvolution, h as intersectWithEvolution, j as toBufferGeometryData, l as solidFromShell, m as fuseWithEvolution, n as fixSelfIntersection, o as healSolid, p as filletWithEvolution, r as fixShape, s as healWire, t as autoHeal, u as positionOnCurve, v as cutAllBisect, x as getNurbsSurfaceData, y as fuseAllBisect } from "./healingFns-B94zSk1-.js";
|
|
9
|
+
import { i as facesOfEdge, l as wiresOfFace, n as adjacentFaces, o as sharedEdges, r as edgesOfFace, s as verticesOfEdge } from "./adjacencyFns-B2Po1gPs.js";
|
|
10
10
|
export { addHoles, adjacentFaces, approximateCurve, asTopo, autoHeal, bezier, box, bsplineApprox, cast, chamferDistAngle as chamferDistAngleShape, chamferWithEvolution, checkBoolean, circle, classifyPointOnFace, clearMeshCache, compound, cone, createMeshCache, curveAxis, curveEndPoint, curveIsClosed, curveIsPeriodic, curveLength, curvePeriod, curvePointAt, curveStartPoint, curveTangentAt, cutAll, cutAllBisect, cutWithEvolution, cylinder, fromBREP as deserializeShape, downcast, edgesOfFace, ellipse, ellipseArc, ellipsoid, exportIGES, exportSTEP, exportSTL, face, faceAxis, faceCenter, faceGeomType, faceOrientation, facesOfEdge, filledFace, filletWithEvolution, fixSelfIntersection, fixShape, flipFaceOrientation, flipOrientation, fuseAll, fuseAllBisect, fuseWithEvolution, getBounds, getCurveType, getEdges, getFaces, getHashCode, getNurbsCurveData, getNurbsSurfaceData, getOrientation, getSurfaceType, getVertices, getWires, healFace, healSolid, healWire, helix, innerWires, interpolateCurve, intersectWithEvolution, invalidateShapeCache, isCompSolid, isEqualShape, isSameShape, iterEdges, iterFaces, iterTopo, iterVertices, iterWires, line, normalAt, offsetFace, offsetWire2D, outerWire, pointOnSurface, polygon, positionOnCurve, projectPointOnFace, sewShells, shapeType, sharedEdges, shellWithEvolution, solid, solidFromShell, sphere, subFace, tangentArc, threePointArc, toBufferGeometryData, toGroupedBufferGeometryData, toLineGeometryData, torus, uvBounds, uvCoordinates, variableFillet, vertex, vertexPosition, verticesOfEdge, wire, wireLoop, wiresOfFace };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const require_shapeTypes = require("./shapeTypes-
|
|
1
|
+
const require_shapeTypes = require("./shapeTypes-D938X2mg.cjs");
|
|
2
2
|
const require_errors = require("./errors-O_blYTWT.cjs");
|
|
3
3
|
const require_constants = require("./constants-oee0S_x6.cjs");
|
|
4
4
|
// src/core/kernelErrorTranslation.ts
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { G as _usingCtx, N as DisposalScope, O as getOrQueryType, n as castResultShape, q as getKernel, r as castResultShapeWithKnownType } from "./shapeTypes-
|
|
1
|
+
import { G as _usingCtx, N as DisposalScope, O as getOrQueryType, n as castResultShape, q as getKernel, r as castResultShapeWithKnownType } from "./shapeTypes-PNVEv6ga.js";
|
|
2
2
|
import { E as ok, g as err } from "./errors-BTccWbtE.js";
|
|
3
3
|
import { n as HASH_CODE_MAX } from "./constants-iraOnb2p.js";
|
|
4
4
|
// src/core/kernelErrorTranslation.ts
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "brepjs",
|
|
3
|
-
"version": "20.12.
|
|
3
|
+
"version": "20.12.5",
|
|
4
4
|
"description": "Exact B-Rep CAD in TypeScript on OpenCascade WebAssembly, with a pluggable geometry kernel",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cad",
|
|
@@ -223,6 +223,7 @@
|
|
|
223
223
|
"prepublishOnly": "npm run build",
|
|
224
224
|
"prepack": "bash scripts/validate-pack.sh",
|
|
225
225
|
"typecheck": "tsgo --noEmit",
|
|
226
|
+
"typecheck:tests": "tsgo --noEmit -p tsconfig.typecheck-tests.json",
|
|
226
227
|
"typecheck:tsc": "tsc --noEmit",
|
|
227
228
|
"lint": "eslint src/",
|
|
228
229
|
"lint:fix": "eslint src/ --fix",
|