brepjs-sheetmetal 0.3.1 → 0.4.0
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/brepjs-sheetmetal.cjs +25 -50
- package/dist/brepjs-sheetmetal.js +25 -50
- package/package.json +4 -4
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
let brepjs = require("brepjs");
|
|
3
|
-
|
|
3
|
+
// src/materials.ts
|
|
4
4
|
var DEFAULT_K_FACTOR = .44;
|
|
5
5
|
function gauge(name, thickness, kFactor = DEFAULT_K_FACTOR) {
|
|
6
6
|
return {
|
|
@@ -38,8 +38,7 @@ var MATERIALS = {
|
|
|
38
38
|
function getMaterial(name) {
|
|
39
39
|
return MATERIALS[name];
|
|
40
40
|
}
|
|
41
|
-
|
|
42
|
-
//#region src/bendTableFns.ts
|
|
41
|
+
// src/bendTableFns.ts
|
|
43
42
|
var DEG_TO_RAD = Math.PI / 180;
|
|
44
43
|
var registry = /* @__PURE__ */ new Map();
|
|
45
44
|
/**
|
|
@@ -378,8 +377,7 @@ function ensureStarterTables() {
|
|
|
378
377
|
});
|
|
379
378
|
}
|
|
380
379
|
}
|
|
381
|
-
|
|
382
|
-
//#region src/allowanceFns.ts
|
|
380
|
+
// src/allowanceFns.ts
|
|
383
381
|
function validateRule(rule) {
|
|
384
382
|
if (!Number.isFinite(rule.innerRadius) || rule.innerRadius < 0) return (0, brepjs.err)((0, brepjs.validationError)("INVALID_RADIUS", `innerRadius must be a finite, non-negative number, got ${rule.innerRadius}`));
|
|
385
383
|
if (!Number.isFinite(rule.kFactor) || rule.kFactor < 0 || rule.kFactor > 1) return (0, brepjs.err)((0, brepjs.validationError)("INVALID_K_FACTOR", `kFactor must be in [0, 1], got ${rule.kFactor}`));
|
|
@@ -413,8 +411,7 @@ function neutralRadius(thickness, rule) {
|
|
|
413
411
|
if (!ruleCheck.ok) return ruleCheck;
|
|
414
412
|
return (0, brepjs.ok)(rule.innerRadius + rule.kFactor * thickness);
|
|
415
413
|
}
|
|
416
|
-
|
|
417
|
-
//#region src/featureTreeFns.ts
|
|
414
|
+
// src/featureTreeFns.ts
|
|
418
415
|
var ROOT_FLAT_ID = "root";
|
|
419
416
|
/**
|
|
420
417
|
* Build the feature graph for an authored part. Each flange contributes a flat
|
|
@@ -559,8 +556,7 @@ function featureTree(part, rootId = ROOT_FLAT_ID) {
|
|
|
559
556
|
if (!graph.ok) return graph;
|
|
560
557
|
return buildFeatureTree(graph.value, rootId);
|
|
561
558
|
}
|
|
562
|
-
|
|
563
|
-
//#region src/internal.ts
|
|
559
|
+
// src/internal.ts
|
|
564
560
|
/**
|
|
565
561
|
* OCCT boolean fuse returns a compound wrapping the unioned solid. Extract the
|
|
566
562
|
* single solid so a part's cached shape is a true `Solid` (clean STEP/GLB
|
|
@@ -583,8 +579,7 @@ function sideFromAxisDir(axisDir) {
|
|
|
583
579
|
if (Math.abs(axisDir[1]) > .5) return "xmax";
|
|
584
580
|
if (Math.abs(axisDir[0]) > .5) return "ymax";
|
|
585
581
|
}
|
|
586
|
-
|
|
587
|
-
//#region src/unfoldFns.ts
|
|
582
|
+
// src/unfoldFns.ts
|
|
588
583
|
/**
|
|
589
584
|
* Tree-driven analytic unfold of an arbitrary straight-bend part into its flat
|
|
590
585
|
* pattern. Walks the feature tree in BFS order placing every flat in the flat
|
|
@@ -1291,8 +1286,7 @@ function reportFromLayout(layout) {
|
|
|
1291
1286
|
totalFlatSize: [maxX - minX, maxY - minY]
|
|
1292
1287
|
};
|
|
1293
1288
|
}
|
|
1294
|
-
|
|
1295
|
-
//#region src/foreignUnfoldFns.ts
|
|
1289
|
+
// src/foreignUnfoldFns.ts
|
|
1296
1290
|
/** Default neutral-axis K-factor for a purely geometric unfold (mid-surface). */
|
|
1297
1291
|
var DEFAULT_FOREIGN_K = .5;
|
|
1298
1292
|
/** Relative tolerance for the cylinder-fit residual (fraction of the radius). */
|
|
@@ -2181,8 +2175,7 @@ function bendDirection(bend, parent) {
|
|
|
2181
2175
|
function faceNormal(face) {
|
|
2182
2176
|
return (0, brepjs.vecNormalize)((0, brepjs.normalAt)(face, (0, brepjs.faceCenter)(face)));
|
|
2183
2177
|
}
|
|
2184
|
-
|
|
2185
|
-
//#region src/authorFns.ts
|
|
2178
|
+
// src/authorFns.ts
|
|
2186
2179
|
/**
|
|
2187
2180
|
* Stable edge reference for flange attachment. The base flat is `face-0`; every
|
|
2188
2181
|
* flange face is `face-<n+1>` in authoring order. The leading edge of a flat is
|
|
@@ -2799,8 +2792,7 @@ function buildFlangeFlat(axisOrigin, thetaDeg, width, thickness, length, directi
|
|
|
2799
2792
|
]
|
|
2800
2793
|
});
|
|
2801
2794
|
}
|
|
2802
|
-
|
|
2803
|
-
//#region src/reliefFns.ts
|
|
2795
|
+
// src/reliefFns.ts
|
|
2804
2796
|
var EPS$6 = 1e-6;
|
|
2805
2797
|
var Z_AXIS$1 = [
|
|
2806
2798
|
0,
|
|
@@ -3164,8 +3156,7 @@ function toPt2$1(v) {
|
|
|
3164
3156
|
function dist2(a, b) {
|
|
3165
3157
|
return Math.hypot(a[0] - b[0], a[1] - b[1]);
|
|
3166
3158
|
}
|
|
3167
|
-
|
|
3168
|
-
//#region src/cutoutFns.ts
|
|
3159
|
+
// src/cutoutFns.ts
|
|
3169
3160
|
var EPS$5 = 1e-6;
|
|
3170
3161
|
/** A hair of over-cut so the tool pokes through both faces cleanly. */
|
|
3171
3162
|
var HAIR$1 = .05;
|
|
@@ -3393,8 +3384,7 @@ function polygonArea(loop) {
|
|
|
3393
3384
|
}
|
|
3394
3385
|
return Math.abs(sum) / 2;
|
|
3395
3386
|
}
|
|
3396
|
-
|
|
3397
|
-
//#region src/tabFns.ts
|
|
3387
|
+
// src/tabFns.ts
|
|
3398
3388
|
var EPS$4 = 1e-6;
|
|
3399
3389
|
/**
|
|
3400
3390
|
* Fuse a rectangular tab onto a named flat region's edge — additive material (the
|
|
@@ -3536,8 +3526,7 @@ function devRect(local, dev) {
|
|
|
3536
3526
|
y1
|
|
3537
3527
|
];
|
|
3538
3528
|
}
|
|
3539
|
-
|
|
3540
|
-
//#region src/formFns.ts
|
|
3529
|
+
// src/formFns.ts
|
|
3541
3530
|
var EPS$3 = 1e-6;
|
|
3542
3531
|
var HAIR = .05;
|
|
3543
3532
|
var CIRCLE_SEGMENTS = 48;
|
|
@@ -3838,8 +3827,7 @@ function circleLocal(c, r) {
|
|
|
3838
3827
|
}
|
|
3839
3828
|
return pts;
|
|
3840
3829
|
}
|
|
3841
|
-
|
|
3842
|
-
//#region src/validateFns.ts
|
|
3830
|
+
// src/validateFns.ts
|
|
3843
3831
|
var OVERLAP_TOL = 1e-6;
|
|
3844
3832
|
/**
|
|
3845
3833
|
* Manufacturability checks for an authored sheet-metal part. Returns a list of
|
|
@@ -4021,8 +4009,7 @@ function pairKey(a, b) {
|
|
|
4021
4009
|
function boundsOverlap(a, b) {
|
|
4022
4010
|
return a.xMin < b.xMax - OVERLAP_TOL && b.xMin < a.xMax - OVERLAP_TOL && a.yMin < b.yMax - OVERLAP_TOL && b.yMin < a.yMax - OVERLAP_TOL && a.zMin < b.zMax - OVERLAP_TOL && b.zMin < a.zMax - OVERLAP_TOL;
|
|
4023
4011
|
}
|
|
4024
|
-
|
|
4025
|
-
//#region src/foldFns.ts
|
|
4012
|
+
// src/foldFns.ts
|
|
4026
4013
|
/**
|
|
4027
4014
|
* Fold a flat pattern up into a 3D part. Each {@link FoldRegion} folds about its
|
|
4028
4015
|
* fold line off its parent region, exactly inverting {@link unfold}: folding by an
|
|
@@ -4680,8 +4667,7 @@ function uniqueSorted(values) {
|
|
|
4680
4667
|
}
|
|
4681
4668
|
return out;
|
|
4682
4669
|
}
|
|
4683
|
-
|
|
4684
|
-
//#region src/miterFns.ts
|
|
4670
|
+
// src/miterFns.ts
|
|
4685
4671
|
/**
|
|
4686
4672
|
* General miter primitive: cut a sheet-metal part by a plane, removing the
|
|
4687
4673
|
* material on the `+normal` side. The tool is a half-space block sized to the
|
|
@@ -4803,8 +4789,7 @@ function alignZTo(shape, target) {
|
|
|
4803
4789
|
axis
|
|
4804
4790
|
});
|
|
4805
4791
|
}
|
|
4806
|
-
|
|
4807
|
-
//#region src/contourFlangeFns.ts
|
|
4792
|
+
// src/contourFlangeFns.ts
|
|
4808
4793
|
/**
|
|
4809
4794
|
* Author a contour flange: an OPEN 2D profile (alternating line/arc segments) swept
|
|
4810
4795
|
* along one straight edge of the base flat. Each arc is a cylindrical bend, each
|
|
@@ -5273,8 +5258,7 @@ function matrixToAxisAngle(m) {
|
|
|
5273
5258
|
angleDeg
|
|
5274
5259
|
};
|
|
5275
5260
|
}
|
|
5276
|
-
|
|
5277
|
-
//#region src/loftedFlangeFns.ts
|
|
5261
|
+
// src/loftedFlangeFns.ts
|
|
5278
5262
|
/**
|
|
5279
5263
|
* Relative out-of-plane tolerance for the per-quad developability test: a quad is
|
|
5280
5264
|
* twisted (non-developable) when its far corner sits off the diagonal-triangle plane
|
|
@@ -5586,8 +5570,7 @@ function closedLoopWire(loop) {
|
|
|
5586
5570
|
}
|
|
5587
5571
|
return (0, brepjs.wireLoop)(edges);
|
|
5588
5572
|
}
|
|
5589
|
-
|
|
5590
|
-
//#region src/hemFns.ts
|
|
5573
|
+
// src/hemFns.ts
|
|
5591
5574
|
/**
|
|
5592
5575
|
* A small clearance baked into a CLOSED hem's curl radius. A true closed hem folds
|
|
5593
5576
|
* the return flat against the parent with zero gap; modelling that exactly makes the
|
|
@@ -5780,8 +5763,7 @@ function splitAngle(totalDeg) {
|
|
|
5780
5763
|
const per = totalDeg / n;
|
|
5781
5764
|
return Array.from({ length: n }, () => per);
|
|
5782
5765
|
}
|
|
5783
|
-
|
|
5784
|
-
//#region src/jogFns.ts
|
|
5766
|
+
// src/jogFns.ts
|
|
5785
5767
|
/**
|
|
5786
5768
|
* Author a jog (joggle): two opposite bends (`+θ` then `−θ`) that step a flat by
|
|
5787
5769
|
* `offsetHeight` perpendicular to its plane, then continue parallel past the step.
|
|
@@ -5940,8 +5922,7 @@ function jogId(spec) {
|
|
|
5940
5922
|
function resolveRegion(region) {
|
|
5941
5923
|
return region === "base" || region === "face-0" ? ROOT_FLAT_ID : region;
|
|
5942
5924
|
}
|
|
5943
|
-
|
|
5944
|
-
//#region src/dxfFns.ts
|
|
5925
|
+
// src/dxfFns.ts
|
|
5945
5926
|
var DEFAULT_TEXT_HEIGHT = 2.5;
|
|
5946
5927
|
var LAYER_OUTLINE = "OUTLINE";
|
|
5947
5928
|
var LAYER_BEND_UP = "BEND_UP";
|
|
@@ -6150,8 +6131,7 @@ function pathPoints(wire) {
|
|
|
6150
6131
|
function toPt2(v) {
|
|
6151
6132
|
return [v[0], v[1]];
|
|
6152
6133
|
}
|
|
6153
|
-
|
|
6154
|
-
//#region src/polygonFns.ts
|
|
6134
|
+
// src/polygonFns.ts
|
|
6155
6135
|
/**
|
|
6156
6136
|
* 2D simple-polygon geometry for true-shape (no-fit-polygon) nesting: an ordered
|
|
6157
6137
|
* vertex loop plus the overlap predicate that is the correctness backbone of the
|
|
@@ -6394,8 +6374,7 @@ function pointSegmentDistance(p, a, b) {
|
|
|
6394
6374
|
const dy = p[1] - (a[1] + t * vy);
|
|
6395
6375
|
return Math.hypot(dx, dy);
|
|
6396
6376
|
}
|
|
6397
|
-
|
|
6398
|
-
//#region src/nestFns.ts
|
|
6377
|
+
// src/nestFns.ts
|
|
6399
6378
|
var EPS = 1e-9;
|
|
6400
6379
|
/**
|
|
6401
6380
|
* Bounding-box nest: arrange developed flat patterns onto stock sheets to reduce
|
|
@@ -6861,8 +6840,7 @@ function nestToDXF$1(result, patterns, sheetIndex, options) {
|
|
|
6861
6840
|
}
|
|
6862
6841
|
return multiPatternToDXF(placed, options ?? {});
|
|
6863
6842
|
}
|
|
6864
|
-
|
|
6865
|
-
//#region src/reportFns.ts
|
|
6843
|
+
// src/reportFns.ts
|
|
6866
6844
|
/**
|
|
6867
6845
|
* Build the bend-table JSON report directly from an authored part. Walks the
|
|
6868
6846
|
* same tree layout the unfold consumes so the per-bend values and the total flat
|
|
@@ -6905,8 +6883,7 @@ function reportFromUnfold(result) {
|
|
|
6905
6883
|
function reportToJSON(report) {
|
|
6906
6884
|
return JSON.stringify(report, null, 2);
|
|
6907
6885
|
}
|
|
6908
|
-
|
|
6909
|
-
//#region src/api.ts
|
|
6886
|
+
// src/api.ts
|
|
6910
6887
|
/** Author a straight-bend part: a base flat plus folded-up flanges. */
|
|
6911
6888
|
function author(spec) {
|
|
6912
6889
|
return authorPart(spec);
|
|
@@ -7068,8 +7045,7 @@ function bendTable(id) {
|
|
|
7068
7045
|
function resolveAllowance(rule, angleDeg, thickness, onWarning) {
|
|
7069
7046
|
return resolveBendAllowance(rule, angleDeg, thickness, onWarning);
|
|
7070
7047
|
}
|
|
7071
|
-
|
|
7072
|
-
//#region src/facade.ts
|
|
7048
|
+
// src/facade.ts
|
|
7073
7049
|
/** Thrown by the fluent facade when an underlying `Result<T>` is an `Err`. */
|
|
7074
7050
|
var SheetMetalError = class extends Error {
|
|
7075
7051
|
code;
|
|
@@ -7339,7 +7315,6 @@ function foldFlat(input) {
|
|
|
7339
7315
|
function fromSolid(solid, opts) {
|
|
7340
7316
|
return new ForeignSolidHandle(solid, opts);
|
|
7341
7317
|
}
|
|
7342
|
-
//#endregion
|
|
7343
7318
|
exports.ALUMINUM_GAUGES = ALUMINUM_GAUGES;
|
|
7344
7319
|
exports.DEFAULT_K_FACTOR = DEFAULT_K_FACTOR;
|
|
7345
7320
|
exports.ForeignSolidHandle = ForeignSolidHandle;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { box, curveEndPoint, curveStartPoint, cut, cylinder, err, extrude, face, faceCenter, fuse, getBounds, getEdges, getFaces, getSolids, getSurfaceType, intersect, isErr, isOk, isPlanarWire, isSolid, isValid, line, measureArea, measureVolume, normalAt, ok, pointOnSurface, rotate, sharedEdges, translate, validationError, vecAdd, vecCross, vecDot, vecLength, vecNormalize, vecScale, vecSub, wire, wireLoop } from "brepjs";
|
|
2
|
-
|
|
2
|
+
// src/materials.ts
|
|
3
3
|
var DEFAULT_K_FACTOR = .44;
|
|
4
4
|
function gauge(name, thickness, kFactor = DEFAULT_K_FACTOR) {
|
|
5
5
|
return {
|
|
@@ -37,8 +37,7 @@ var MATERIALS = {
|
|
|
37
37
|
function getMaterial(name) {
|
|
38
38
|
return MATERIALS[name];
|
|
39
39
|
}
|
|
40
|
-
|
|
41
|
-
//#region src/bendTableFns.ts
|
|
40
|
+
// src/bendTableFns.ts
|
|
42
41
|
var DEG_TO_RAD = Math.PI / 180;
|
|
43
42
|
var registry = /* @__PURE__ */ new Map();
|
|
44
43
|
/**
|
|
@@ -377,8 +376,7 @@ function ensureStarterTables() {
|
|
|
377
376
|
});
|
|
378
377
|
}
|
|
379
378
|
}
|
|
380
|
-
|
|
381
|
-
//#region src/allowanceFns.ts
|
|
379
|
+
// src/allowanceFns.ts
|
|
382
380
|
function validateRule(rule) {
|
|
383
381
|
if (!Number.isFinite(rule.innerRadius) || rule.innerRadius < 0) return err(validationError("INVALID_RADIUS", `innerRadius must be a finite, non-negative number, got ${rule.innerRadius}`));
|
|
384
382
|
if (!Number.isFinite(rule.kFactor) || rule.kFactor < 0 || rule.kFactor > 1) return err(validationError("INVALID_K_FACTOR", `kFactor must be in [0, 1], got ${rule.kFactor}`));
|
|
@@ -412,8 +410,7 @@ function neutralRadius(thickness, rule) {
|
|
|
412
410
|
if (!ruleCheck.ok) return ruleCheck;
|
|
413
411
|
return ok(rule.innerRadius + rule.kFactor * thickness);
|
|
414
412
|
}
|
|
415
|
-
|
|
416
|
-
//#region src/featureTreeFns.ts
|
|
413
|
+
// src/featureTreeFns.ts
|
|
417
414
|
var ROOT_FLAT_ID = "root";
|
|
418
415
|
/**
|
|
419
416
|
* Build the feature graph for an authored part. Each flange contributes a flat
|
|
@@ -558,8 +555,7 @@ function featureTree(part, rootId = ROOT_FLAT_ID) {
|
|
|
558
555
|
if (!graph.ok) return graph;
|
|
559
556
|
return buildFeatureTree(graph.value, rootId);
|
|
560
557
|
}
|
|
561
|
-
|
|
562
|
-
//#region src/internal.ts
|
|
558
|
+
// src/internal.ts
|
|
563
559
|
/**
|
|
564
560
|
* OCCT boolean fuse returns a compound wrapping the unioned solid. Extract the
|
|
565
561
|
* single solid so a part's cached shape is a true `Solid` (clean STEP/GLB
|
|
@@ -582,8 +578,7 @@ function sideFromAxisDir(axisDir) {
|
|
|
582
578
|
if (Math.abs(axisDir[1]) > .5) return "xmax";
|
|
583
579
|
if (Math.abs(axisDir[0]) > .5) return "ymax";
|
|
584
580
|
}
|
|
585
|
-
|
|
586
|
-
//#region src/unfoldFns.ts
|
|
581
|
+
// src/unfoldFns.ts
|
|
587
582
|
/**
|
|
588
583
|
* Tree-driven analytic unfold of an arbitrary straight-bend part into its flat
|
|
589
584
|
* pattern. Walks the feature tree in BFS order placing every flat in the flat
|
|
@@ -1290,8 +1285,7 @@ function reportFromLayout(layout) {
|
|
|
1290
1285
|
totalFlatSize: [maxX - minX, maxY - minY]
|
|
1291
1286
|
};
|
|
1292
1287
|
}
|
|
1293
|
-
|
|
1294
|
-
//#region src/foreignUnfoldFns.ts
|
|
1288
|
+
// src/foreignUnfoldFns.ts
|
|
1295
1289
|
/** Default neutral-axis K-factor for a purely geometric unfold (mid-surface). */
|
|
1296
1290
|
var DEFAULT_FOREIGN_K = .5;
|
|
1297
1291
|
/** Relative tolerance for the cylinder-fit residual (fraction of the radius). */
|
|
@@ -2180,8 +2174,7 @@ function bendDirection(bend, parent) {
|
|
|
2180
2174
|
function faceNormal(face) {
|
|
2181
2175
|
return vecNormalize(normalAt(face, faceCenter(face)));
|
|
2182
2176
|
}
|
|
2183
|
-
|
|
2184
|
-
//#region src/authorFns.ts
|
|
2177
|
+
// src/authorFns.ts
|
|
2185
2178
|
/**
|
|
2186
2179
|
* Stable edge reference for flange attachment. The base flat is `face-0`; every
|
|
2187
2180
|
* flange face is `face-<n+1>` in authoring order. The leading edge of a flat is
|
|
@@ -2798,8 +2791,7 @@ function buildFlangeFlat(axisOrigin, thetaDeg, width, thickness, length, directi
|
|
|
2798
2791
|
]
|
|
2799
2792
|
});
|
|
2800
2793
|
}
|
|
2801
|
-
|
|
2802
|
-
//#region src/reliefFns.ts
|
|
2794
|
+
// src/reliefFns.ts
|
|
2803
2795
|
var EPS$6 = 1e-6;
|
|
2804
2796
|
var Z_AXIS$1 = [
|
|
2805
2797
|
0,
|
|
@@ -3163,8 +3155,7 @@ function toPt2$1(v) {
|
|
|
3163
3155
|
function dist2(a, b) {
|
|
3164
3156
|
return Math.hypot(a[0] - b[0], a[1] - b[1]);
|
|
3165
3157
|
}
|
|
3166
|
-
|
|
3167
|
-
//#region src/cutoutFns.ts
|
|
3158
|
+
// src/cutoutFns.ts
|
|
3168
3159
|
var EPS$5 = 1e-6;
|
|
3169
3160
|
/** A hair of over-cut so the tool pokes through both faces cleanly. */
|
|
3170
3161
|
var HAIR$1 = .05;
|
|
@@ -3392,8 +3383,7 @@ function polygonArea(loop) {
|
|
|
3392
3383
|
}
|
|
3393
3384
|
return Math.abs(sum) / 2;
|
|
3394
3385
|
}
|
|
3395
|
-
|
|
3396
|
-
//#region src/tabFns.ts
|
|
3386
|
+
// src/tabFns.ts
|
|
3397
3387
|
var EPS$4 = 1e-6;
|
|
3398
3388
|
/**
|
|
3399
3389
|
* Fuse a rectangular tab onto a named flat region's edge — additive material (the
|
|
@@ -3535,8 +3525,7 @@ function devRect(local, dev) {
|
|
|
3535
3525
|
y1
|
|
3536
3526
|
];
|
|
3537
3527
|
}
|
|
3538
|
-
|
|
3539
|
-
//#region src/formFns.ts
|
|
3528
|
+
// src/formFns.ts
|
|
3540
3529
|
var EPS$3 = 1e-6;
|
|
3541
3530
|
var HAIR = .05;
|
|
3542
3531
|
var CIRCLE_SEGMENTS = 48;
|
|
@@ -3837,8 +3826,7 @@ function circleLocal(c, r) {
|
|
|
3837
3826
|
}
|
|
3838
3827
|
return pts;
|
|
3839
3828
|
}
|
|
3840
|
-
|
|
3841
|
-
//#region src/validateFns.ts
|
|
3829
|
+
// src/validateFns.ts
|
|
3842
3830
|
var OVERLAP_TOL = 1e-6;
|
|
3843
3831
|
/**
|
|
3844
3832
|
* Manufacturability checks for an authored sheet-metal part. Returns a list of
|
|
@@ -4020,8 +4008,7 @@ function pairKey(a, b) {
|
|
|
4020
4008
|
function boundsOverlap(a, b) {
|
|
4021
4009
|
return a.xMin < b.xMax - OVERLAP_TOL && b.xMin < a.xMax - OVERLAP_TOL && a.yMin < b.yMax - OVERLAP_TOL && b.yMin < a.yMax - OVERLAP_TOL && a.zMin < b.zMax - OVERLAP_TOL && b.zMin < a.zMax - OVERLAP_TOL;
|
|
4022
4010
|
}
|
|
4023
|
-
|
|
4024
|
-
//#region src/foldFns.ts
|
|
4011
|
+
// src/foldFns.ts
|
|
4025
4012
|
/**
|
|
4026
4013
|
* Fold a flat pattern up into a 3D part. Each {@link FoldRegion} folds about its
|
|
4027
4014
|
* fold line off its parent region, exactly inverting {@link unfold}: folding by an
|
|
@@ -4679,8 +4666,7 @@ function uniqueSorted(values) {
|
|
|
4679
4666
|
}
|
|
4680
4667
|
return out;
|
|
4681
4668
|
}
|
|
4682
|
-
|
|
4683
|
-
//#region src/miterFns.ts
|
|
4669
|
+
// src/miterFns.ts
|
|
4684
4670
|
/**
|
|
4685
4671
|
* General miter primitive: cut a sheet-metal part by a plane, removing the
|
|
4686
4672
|
* material on the `+normal` side. The tool is a half-space block sized to the
|
|
@@ -4802,8 +4788,7 @@ function alignZTo(shape, target) {
|
|
|
4802
4788
|
axis
|
|
4803
4789
|
});
|
|
4804
4790
|
}
|
|
4805
|
-
|
|
4806
|
-
//#region src/contourFlangeFns.ts
|
|
4791
|
+
// src/contourFlangeFns.ts
|
|
4807
4792
|
/**
|
|
4808
4793
|
* Author a contour flange: an OPEN 2D profile (alternating line/arc segments) swept
|
|
4809
4794
|
* along one straight edge of the base flat. Each arc is a cylindrical bend, each
|
|
@@ -5272,8 +5257,7 @@ function matrixToAxisAngle(m) {
|
|
|
5272
5257
|
angleDeg
|
|
5273
5258
|
};
|
|
5274
5259
|
}
|
|
5275
|
-
|
|
5276
|
-
//#region src/loftedFlangeFns.ts
|
|
5260
|
+
// src/loftedFlangeFns.ts
|
|
5277
5261
|
/**
|
|
5278
5262
|
* Relative out-of-plane tolerance for the per-quad developability test: a quad is
|
|
5279
5263
|
* twisted (non-developable) when its far corner sits off the diagonal-triangle plane
|
|
@@ -5585,8 +5569,7 @@ function closedLoopWire(loop) {
|
|
|
5585
5569
|
}
|
|
5586
5570
|
return wireLoop(edges);
|
|
5587
5571
|
}
|
|
5588
|
-
|
|
5589
|
-
//#region src/hemFns.ts
|
|
5572
|
+
// src/hemFns.ts
|
|
5590
5573
|
/**
|
|
5591
5574
|
* A small clearance baked into a CLOSED hem's curl radius. A true closed hem folds
|
|
5592
5575
|
* the return flat against the parent with zero gap; modelling that exactly makes the
|
|
@@ -5779,8 +5762,7 @@ function splitAngle(totalDeg) {
|
|
|
5779
5762
|
const per = totalDeg / n;
|
|
5780
5763
|
return Array.from({ length: n }, () => per);
|
|
5781
5764
|
}
|
|
5782
|
-
|
|
5783
|
-
//#region src/jogFns.ts
|
|
5765
|
+
// src/jogFns.ts
|
|
5784
5766
|
/**
|
|
5785
5767
|
* Author a jog (joggle): two opposite bends (`+θ` then `−θ`) that step a flat by
|
|
5786
5768
|
* `offsetHeight` perpendicular to its plane, then continue parallel past the step.
|
|
@@ -5939,8 +5921,7 @@ function jogId(spec) {
|
|
|
5939
5921
|
function resolveRegion(region) {
|
|
5940
5922
|
return region === "base" || region === "face-0" ? ROOT_FLAT_ID : region;
|
|
5941
5923
|
}
|
|
5942
|
-
|
|
5943
|
-
//#region src/dxfFns.ts
|
|
5924
|
+
// src/dxfFns.ts
|
|
5944
5925
|
var DEFAULT_TEXT_HEIGHT = 2.5;
|
|
5945
5926
|
var LAYER_OUTLINE = "OUTLINE";
|
|
5946
5927
|
var LAYER_BEND_UP = "BEND_UP";
|
|
@@ -6149,8 +6130,7 @@ function pathPoints(wire) {
|
|
|
6149
6130
|
function toPt2(v) {
|
|
6150
6131
|
return [v[0], v[1]];
|
|
6151
6132
|
}
|
|
6152
|
-
|
|
6153
|
-
//#region src/polygonFns.ts
|
|
6133
|
+
// src/polygonFns.ts
|
|
6154
6134
|
/**
|
|
6155
6135
|
* 2D simple-polygon geometry for true-shape (no-fit-polygon) nesting: an ordered
|
|
6156
6136
|
* vertex loop plus the overlap predicate that is the correctness backbone of the
|
|
@@ -6393,8 +6373,7 @@ function pointSegmentDistance(p, a, b) {
|
|
|
6393
6373
|
const dy = p[1] - (a[1] + t * vy);
|
|
6394
6374
|
return Math.hypot(dx, dy);
|
|
6395
6375
|
}
|
|
6396
|
-
|
|
6397
|
-
//#region src/nestFns.ts
|
|
6376
|
+
// src/nestFns.ts
|
|
6398
6377
|
var EPS = 1e-9;
|
|
6399
6378
|
/**
|
|
6400
6379
|
* Bounding-box nest: arrange developed flat patterns onto stock sheets to reduce
|
|
@@ -6860,8 +6839,7 @@ function nestToDXF$1(result, patterns, sheetIndex, options) {
|
|
|
6860
6839
|
}
|
|
6861
6840
|
return multiPatternToDXF(placed, options ?? {});
|
|
6862
6841
|
}
|
|
6863
|
-
|
|
6864
|
-
//#region src/reportFns.ts
|
|
6842
|
+
// src/reportFns.ts
|
|
6865
6843
|
/**
|
|
6866
6844
|
* Build the bend-table JSON report directly from an authored part. Walks the
|
|
6867
6845
|
* same tree layout the unfold consumes so the per-bend values and the total flat
|
|
@@ -6904,8 +6882,7 @@ function reportFromUnfold(result) {
|
|
|
6904
6882
|
function reportToJSON(report) {
|
|
6905
6883
|
return JSON.stringify(report, null, 2);
|
|
6906
6884
|
}
|
|
6907
|
-
|
|
6908
|
-
//#region src/api.ts
|
|
6885
|
+
// src/api.ts
|
|
6909
6886
|
/** Author a straight-bend part: a base flat plus folded-up flanges. */
|
|
6910
6887
|
function author(spec) {
|
|
6911
6888
|
return authorPart(spec);
|
|
@@ -7067,8 +7044,7 @@ function bendTable(id) {
|
|
|
7067
7044
|
function resolveAllowance(rule, angleDeg, thickness, onWarning) {
|
|
7068
7045
|
return resolveBendAllowance(rule, angleDeg, thickness, onWarning);
|
|
7069
7046
|
}
|
|
7070
|
-
|
|
7071
|
-
//#region src/facade.ts
|
|
7047
|
+
// src/facade.ts
|
|
7072
7048
|
/** Thrown by the fluent facade when an underlying `Result<T>` is an `Err`. */
|
|
7073
7049
|
var SheetMetalError = class extends Error {
|
|
7074
7050
|
code;
|
|
@@ -7338,5 +7314,4 @@ function foldFlat(input) {
|
|
|
7338
7314
|
function fromSolid(solid, opts) {
|
|
7339
7315
|
return new ForeignSolidHandle(solid, opts);
|
|
7340
7316
|
}
|
|
7341
|
-
//#endregion
|
|
7342
7317
|
export { ALUMINUM_GAUGES, DEFAULT_K_FACTOR, ForeignSolidHandle, MATERIALS, ROOT_FLAT_ID, STEEL_GAUGES, SheetMetalBuilder, SheetMetalError, SheetMetalPartHandle, addBendRelief, addBendTable, addCutout, addForm, addHole, addPolygonCutout, addSlot, addTab, allowance, author, authorContourFlange, authorLoftedFlange, authorPart, autoBendReliefs, autoMiterCorner, autoReliefs, baseEdgeRef, bendAllowance, bendRelief, bendTable, buildFeatureGraph, buildFeatureTree, buildReport, contourFlange, cornerRelief, developed, developedLength, emboss, featureTree, fitCylinder, flatPatternToDXF, flatPatternToPolylines, fold, foldFlat, fold$1 as foldPart, foldWithWarnings, fromPart, fromSolid, getBendTable, getMaterial, hem, jog, loftedFlange, louver, miter, miterCorner, miterCut, multiPatternToDXF, nest, nestToDXF, neutralRadius, partToFlatInput, patternBbox, patternToFlatInput, pointInPolygon, polygonBounds, polygonsOverlap, polygonsOverlapWithClearance, registerBendTable, relieveCorner, report, reportFrom, reportFromUnfold, reportJSON, reportToJSON, resolveAllowance, resolveBendAllowance, segmentsIntersect, sheetMetal, signedArea, tabAndSlot, toDXF, transformPolygon, unfold, unfoldForeignSolid, unfold$1 as unfoldPart, unfoldSolid, validate, validatePart, wireToPolygon };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "brepjs-sheetmetal",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Sheet-metal CAD domain for brepjs — flange authoring, auto-miter, fold/unfold flat patterns",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"sheet-metal",
|
|
@@ -53,13 +53,13 @@
|
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
55
|
"@eslint/js": "*",
|
|
56
|
-
"@types/node": "26.
|
|
56
|
+
"@types/node": "26.6.5",
|
|
57
57
|
"eslint": "*",
|
|
58
|
-
"tsx": "4.23.
|
|
58
|
+
"tsx": "4.23.15",
|
|
59
59
|
"typescript": "*",
|
|
60
60
|
"typescript-eslint": "*",
|
|
61
61
|
"vite": "^8.0.0",
|
|
62
62
|
"vite-plugin-dts": "^5.0.0",
|
|
63
|
-
"vitest": "^
|
|
63
|
+
"vitest": "^5.0.0"
|
|
64
64
|
}
|
|
65
65
|
}
|