brepjs 8.4.0 → 8.7.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.
- package/dist/2d.cjs +2 -2
- package/dist/2d.js +13 -13
- package/dist/{Blueprint-zgFe_5Qj.cjs → Blueprint-BcbOBF-9.cjs} +11 -99
- package/dist/{Blueprint-Bp45tnh0.js → Blueprint-Cmh8lKc4.js} +29 -117
- package/dist/{boolean2D-CfEbRMPF.cjs → boolean2D-CqacqjME.cjs} +24 -25
- package/dist/{boolean2D-DN6ETTCq.js → boolean2D-D94Axs3i.js} +23 -24
- package/dist/{booleanFns-C-M6qqvB.js → booleanFns-DdjtpcM6.js} +306 -12
- package/dist/{booleanFns-5dDG0jpA.cjs → booleanFns-NtKxkiXn.cjs} +299 -5
- package/dist/brepjs.cjs +1619 -71
- package/dist/brepjs.js +1880 -333
- package/dist/core/errors.d.ts +18 -0
- package/dist/core/errors.d.ts.map +1 -1
- package/dist/core.cjs +4 -4
- package/dist/core.js +4 -4
- package/dist/{cornerFinder-CC_MunIh.js → cornerFinder-BBOYfsXl.js} +1 -1
- package/dist/{cornerFinder-BQ-_VJx0.cjs → cornerFinder-Bqy8Lw2p.cjs} +1 -1
- package/dist/{curveFns-ZuQUBZvd.js → curveFns-B85Glnfo.js} +19 -17
- package/dist/{curveFns-VMxgfkqw.cjs → curveFns-BXCbASW-.cjs} +6 -4
- package/dist/{drawFns-BbhX1IUq.js → drawFns-B-gJ2WUc.js} +47 -21
- package/dist/{drawFns-CKaHgGSK.cjs → drawFns-CAmFEqd1.cjs} +63 -37
- package/dist/{errors-CSYOlCCR.js → errors-Coh_5_19.js} +26 -1
- package/dist/{errors-D13q2HCk.cjs → errors-eRQu29oc.cjs} +26 -1
- package/dist/{faceFns-CfJIbHY3.js → faceFns-CltrEfOo.js} +109 -12
- package/dist/{faceFns-es3GENII.cjs → faceFns-DcndPHWm.cjs} +103 -6
- package/dist/{helpers-C0q_FVxq.cjs → helpers-CC21GeAr.cjs} +8 -9
- package/dist/{helpers-CmVkMubc.js → helpers-SksQIreB.js} +16 -17
- package/dist/index.d.ts +18 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/io/dxfImportFns.d.ts +17 -0
- package/dist/io/dxfImportFns.d.ts.map +1 -0
- package/dist/io/objImportFns.d.ts +19 -0
- package/dist/io/objImportFns.d.ts.map +1 -0
- package/dist/io/threemfImportFns.d.ts +19 -0
- package/dist/io/threemfImportFns.d.ts.map +1 -0
- package/dist/io.cjs +5 -5
- package/dist/io.js +5 -5
- package/dist/kernel/hullOps.d.ts +1 -0
- package/dist/kernel/hullOps.d.ts.map +1 -1
- package/dist/kernel/occtAdapter.d.ts +5 -0
- package/dist/kernel/occtAdapter.d.ts.map +1 -1
- package/dist/kernel/solverAdapter.d.ts +39 -0
- package/dist/kernel/solverAdapter.d.ts.map +1 -0
- package/dist/kernel/types.d.ts +5 -0
- package/dist/kernel/types.d.ts.map +1 -1
- package/dist/{loft-B-UCPW9P.cjs → loft-BcyyvWCj.cjs} +28 -28
- package/dist/{loft-oJq2OD3A.js → loft-CJMPx1NQ.js} +16 -16
- package/dist/{measurement-Cf_SoIiR.js → measurement-ByOztLxb.js} +3 -3
- package/dist/{measurement-CYmT-C77.cjs → measurement-DU3ry-0Q.cjs} +3 -3
- package/dist/measurement.cjs +1 -1
- package/dist/measurement.js +1 -1
- package/dist/{meshFns-CqNwW0PO.js → meshFns-D2gLyLFt.js} +3 -3
- package/dist/{meshFns-DDC_2U81.cjs → meshFns-DawUwI3W.cjs} +3 -3
- package/dist/{occtBoundary-D_gjqgzo.js → occtBoundary-CWzWqBCm.js} +17 -5
- package/dist/{occtBoundary-CocN2VKx.cjs → occtBoundary-DH2VO-rq.cjs} +12 -0
- package/dist/operations/assemblyFns.d.ts +1 -0
- package/dist/operations/assemblyFns.d.ts.map +1 -1
- package/dist/operations/guidedSweepFns.d.ts +25 -0
- package/dist/operations/guidedSweepFns.d.ts.map +1 -0
- package/dist/operations/mateFns.d.ts +50 -0
- package/dist/operations/mateFns.d.ts.map +1 -0
- package/dist/operations/multiSweepFns.d.ts +32 -0
- package/dist/operations/multiSweepFns.d.ts.map +1 -0
- package/dist/operations/roofFns.d.ts +16 -0
- package/dist/operations/roofFns.d.ts.map +1 -0
- package/dist/operations/straightSkeleton.d.ts +28 -0
- package/dist/operations/straightSkeleton.d.ts.map +1 -0
- package/dist/{operations-BQeW_DSM.cjs → operations-CdELWxgv.cjs} +7 -7
- package/dist/{operations-6hdpuYmY.js → operations-DiXo_4t9.js} +15 -15
- package/dist/operations.cjs +2 -2
- package/dist/operations.js +13 -13
- package/dist/query.cjs +5 -5
- package/dist/query.js +7 -7
- package/dist/result.cjs +1 -1
- package/dist/result.js +1 -1
- package/dist/{shapeFns-B0zSdO9c.cjs → shapeFns-3RYtsUVY.cjs} +54 -21
- package/dist/{shapeFns-k1YHFwmB.js → shapeFns-4ioRrhih.js} +52 -19
- package/dist/{shapeTypes-BxVxLdiD.cjs → shapeTypes-CMjrTv36.cjs} +1 -1
- package/dist/{shapeTypes-c-_pgYCx.js → shapeTypes-D0vfRxWb.js} +13 -13
- package/dist/sketching.cjs +2 -2
- package/dist/sketching.js +2 -2
- package/dist/{curveBuilders-BREwqvuc.js → surfaceBuilders-B7Jxob8g.js} +106 -13
- package/dist/{curveBuilders-BkEJ-RVn.cjs → surfaceBuilders-Xx9DRRxs.cjs} +96 -3
- package/dist/text/textBlueprints.d.ts +38 -0
- package/dist/text/textBlueprints.d.ts.map +1 -1
- package/dist/topology/api.d.ts +5 -0
- package/dist/topology/api.d.ts.map +1 -1
- package/dist/topology/booleanFns.d.ts +10 -1
- package/dist/topology/booleanFns.d.ts.map +1 -1
- package/dist/topology/colorFns.d.ts +38 -0
- package/dist/topology/colorFns.d.ts.map +1 -0
- package/dist/topology/curveFns.d.ts +1 -1
- package/dist/topology/curveFns.d.ts.map +1 -1
- package/dist/topology/faceTagFns.d.ts +44 -0
- package/dist/topology/faceTagFns.d.ts.map +1 -0
- package/dist/topology/modifierFns.d.ts.map +1 -1
- package/dist/topology/polyhedronFns.d.ts +8 -0
- package/dist/topology/polyhedronFns.d.ts.map +1 -0
- package/dist/topology/shapeFns.d.ts +4 -0
- package/dist/topology/shapeFns.d.ts.map +1 -1
- package/dist/topology/surfaceBuilders.d.ts +7 -0
- package/dist/topology/surfaceBuilders.d.ts.map +1 -1
- package/dist/topology/surfaceFns.d.ts +38 -0
- package/dist/topology/surfaceFns.d.ts.map +1 -0
- package/dist/{topology-CycEc6Oe.cjs → topology-D-nGjCzV.cjs} +19 -20
- package/dist/{topology-tMKHJgw2.js → topology-DRP9zreU.js} +8 -9
- package/dist/topology.cjs +13 -14
- package/dist/topology.js +51 -52
- package/dist/{vectors-DE0XriuQ.js → vectors-CZV4ZrTz.js} +2 -2
- package/dist/{vectors-DVmHF4zt.cjs → vectors-DwFeX0Ja.cjs} +2 -2
- package/dist/vectors.cjs +2 -2
- package/dist/vectors.js +2 -2
- package/package.json +4 -3
- package/dist/cast-CPNOTNFm.cjs +0 -102
- package/dist/cast-Cerqtxtb.js +0 -103
package/dist/2d.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const Blueprint = require("./Blueprint-
|
|
4
|
-
const boolean2D = require("./boolean2D-
|
|
3
|
+
const Blueprint = require("./Blueprint-BcbOBF-9.cjs");
|
|
4
|
+
const boolean2D = require("./boolean2D-CqacqjME.cjs");
|
|
5
5
|
function reverseCurve(curve) {
|
|
6
6
|
const cloned = curve.clone();
|
|
7
7
|
cloned.reverse();
|
package/dist/2d.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { B as Blueprint } from "./Blueprint-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { B as Blueprint } from "./Blueprint-Cmh8lKc4.js";
|
|
2
|
+
import { d, C, r } from "./Blueprint-Cmh8lKc4.js";
|
|
3
|
+
import { e, C as C2, f, l, g, n, k, q, o, p, r as r2 } from "./boolean2D-D94Axs3i.js";
|
|
4
4
|
function reverseCurve(curve) {
|
|
5
5
|
const cloned = curve.clone();
|
|
6
6
|
cloned.reverse();
|
|
@@ -68,11 +68,11 @@ function sketch2DOnFace(bp, face, scaleMode) {
|
|
|
68
68
|
}
|
|
69
69
|
export {
|
|
70
70
|
Blueprint,
|
|
71
|
-
|
|
72
|
-
|
|
71
|
+
e as Blueprints,
|
|
72
|
+
d as BoundingBox2d,
|
|
73
73
|
C2 as CompoundBlueprint,
|
|
74
74
|
C as Curve2D,
|
|
75
|
-
|
|
75
|
+
r as axis2d,
|
|
76
76
|
createBlueprint,
|
|
77
77
|
curve2dBoundingBox,
|
|
78
78
|
curve2dDistanceFrom,
|
|
@@ -82,21 +82,21 @@ export {
|
|
|
82
82
|
curve2dParameter,
|
|
83
83
|
curve2dSplitAt,
|
|
84
84
|
curve2dTangentAt,
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
85
|
+
f as cut2D,
|
|
86
|
+
l as cutBlueprints,
|
|
87
|
+
g as fuse2D,
|
|
88
|
+
n as fuseBlueprints,
|
|
89
89
|
getBounds2D,
|
|
90
90
|
getOrientation2D,
|
|
91
|
-
|
|
92
|
-
|
|
91
|
+
k as intersect2D,
|
|
92
|
+
q as intersectBlueprints,
|
|
93
93
|
isInside2D,
|
|
94
94
|
mirror2D,
|
|
95
95
|
o as organiseBlueprints,
|
|
96
96
|
p as polysidesBlueprint,
|
|
97
97
|
reverseCurve,
|
|
98
98
|
rotate2D,
|
|
99
|
-
|
|
99
|
+
r2 as roundedRectangleBlueprint,
|
|
100
100
|
scale2D,
|
|
101
101
|
sketch2DOnFace,
|
|
102
102
|
sketch2DOnPlane,
|
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
const vectors = require("./vectors-
|
|
3
|
-
const occtBoundary = require("./occtBoundary-
|
|
4
|
-
const shapeTypes = require("./shapeTypes-
|
|
5
|
-
const faceFns = require("./faceFns-
|
|
6
|
-
const curveFns = require("./curveFns-
|
|
7
|
-
const errors = require("./errors-
|
|
8
|
-
const
|
|
9
|
-
const
|
|
2
|
+
const vectors = require("./vectors-DwFeX0Ja.cjs");
|
|
3
|
+
const occtBoundary = require("./occtBoundary-DH2VO-rq.cjs");
|
|
4
|
+
const shapeTypes = require("./shapeTypes-CMjrTv36.cjs");
|
|
5
|
+
const faceFns = require("./faceFns-DcndPHWm.cjs");
|
|
6
|
+
const curveFns = require("./curveFns-BXCbASW-.cjs");
|
|
7
|
+
const errors = require("./errors-eRQu29oc.cjs");
|
|
8
|
+
const surfaceBuilders = require("./surfaceBuilders-Xx9DRRxs.cjs");
|
|
9
|
+
const helpers = require("./helpers-CC21GeAr.cjs");
|
|
10
10
|
const vecOps = require("./vecOps-CjRL1jau.cjs");
|
|
11
|
-
const shapeFns = require("./shapeFns-B0zSdO9c.cjs");
|
|
12
|
-
const curveBuilders = require("./curveBuilders-BkEJ-RVn.cjs");
|
|
13
11
|
const result = require("./result.cjs");
|
|
14
12
|
function makePlane(plane, origin) {
|
|
15
13
|
if (plane && typeof plane !== "string") {
|
|
@@ -46,86 +44,6 @@ function mirror(shape, inputPlane, origin) {
|
|
|
46
44
|
gc();
|
|
47
45
|
return newShape;
|
|
48
46
|
}
|
|
49
|
-
function range(len) {
|
|
50
|
-
return Array.from(Array(len).keys());
|
|
51
|
-
}
|
|
52
|
-
function zip(arrays) {
|
|
53
|
-
const minLength = Math.min(...arrays.map((arr) => arr.length));
|
|
54
|
-
return range(minLength).map((i) => arrays.map((arr) => arr[i]));
|
|
55
|
-
}
|
|
56
|
-
function makeFace(wire, holes) {
|
|
57
|
-
const oc = occtBoundary.getKernel().oc;
|
|
58
|
-
const faceBuilder = new oc.BRepBuilderAPI_MakeFace_15(wire.wrapped, false);
|
|
59
|
-
holes?.forEach((hole) => {
|
|
60
|
-
faceBuilder.Add(hole.wrapped);
|
|
61
|
-
});
|
|
62
|
-
if (!faceBuilder.IsDone()) {
|
|
63
|
-
faceBuilder.delete();
|
|
64
|
-
return errors.err(
|
|
65
|
-
errors.occtError("FACE_BUILD_FAILED", "Failed to build the face. Your wire might be non planar.")
|
|
66
|
-
);
|
|
67
|
-
}
|
|
68
|
-
const face = faceBuilder.Face();
|
|
69
|
-
faceBuilder.delete();
|
|
70
|
-
return errors.ok(shapeTypes.createFace(face));
|
|
71
|
-
}
|
|
72
|
-
function makeNewFaceWithinFace(originFace, wire) {
|
|
73
|
-
const oc = occtBoundary.getKernel().oc;
|
|
74
|
-
const [r, gc] = shapeTypes.localGC();
|
|
75
|
-
const surface = r(oc.BRep_Tool.Surface_2(originFace.wrapped));
|
|
76
|
-
const faceBuilder = r(new oc.BRepBuilderAPI_MakeFace_21(surface, wire.wrapped, true));
|
|
77
|
-
const face = faceBuilder.Face();
|
|
78
|
-
gc();
|
|
79
|
-
return shapeTypes.createFace(face);
|
|
80
|
-
}
|
|
81
|
-
function makeNonPlanarFace(wire) {
|
|
82
|
-
const oc = occtBoundary.getKernel().oc;
|
|
83
|
-
const [r, gc] = shapeTypes.localGC();
|
|
84
|
-
const faceBuilder = r(
|
|
85
|
-
new oc.BRepOffsetAPI_MakeFilling(3, 15, 2, false, 1e-5, 1e-4, 0.01, 0.1, 8, 9)
|
|
86
|
-
);
|
|
87
|
-
shapeFns.getEdges(wire).forEach((edge) => {
|
|
88
|
-
faceBuilder.Add_1(
|
|
89
|
-
edge.wrapped,
|
|
90
|
-
oc.GeomAbs_Shape.GeomAbs_C0,
|
|
91
|
-
true
|
|
92
|
-
);
|
|
93
|
-
});
|
|
94
|
-
const progress = r(new oc.Message_ProgressRange_1());
|
|
95
|
-
faceBuilder.Build(progress);
|
|
96
|
-
return errors.andThen(cast.cast(faceBuilder.Shape()), (newFace) => {
|
|
97
|
-
gc();
|
|
98
|
-
if (!shapeTypes.isFace(newFace)) {
|
|
99
|
-
return errors.err(errors.occtError("FACE_BUILD_FAILED", "Failed to create a face"));
|
|
100
|
-
}
|
|
101
|
-
return errors.ok(newFace);
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
function addHolesInFace(face, holes) {
|
|
105
|
-
const oc = occtBoundary.getKernel().oc;
|
|
106
|
-
const [r, gc] = shapeTypes.localGC();
|
|
107
|
-
const faceMaker = r(new oc.BRepBuilderAPI_MakeFace_2(face.wrapped));
|
|
108
|
-
holes.forEach((wire) => {
|
|
109
|
-
faceMaker.Add(wire.wrapped);
|
|
110
|
-
});
|
|
111
|
-
const builtFace = r(faceMaker.Face());
|
|
112
|
-
const fixer = r(new oc.ShapeFix_Face_2(builtFace));
|
|
113
|
-
fixer.FixOrientation_1();
|
|
114
|
-
const newFace = fixer.Face();
|
|
115
|
-
gc();
|
|
116
|
-
return shapeTypes.createFace(newFace);
|
|
117
|
-
}
|
|
118
|
-
function makePolygon(points) {
|
|
119
|
-
if (points.length < 3)
|
|
120
|
-
return errors.err(
|
|
121
|
-
errors.validationError("POLYGON_MIN_POINTS", "You need at least 3 points to make a polygon")
|
|
122
|
-
);
|
|
123
|
-
const edges = zip([points, [...points.slice(1), points[0]]]).map(
|
|
124
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- zip returns untyped pairs
|
|
125
|
-
([p1, p2]) => curveBuilders.makeLine(p1, p2)
|
|
126
|
-
);
|
|
127
|
-
return errors.andThen(curveBuilders.assembleWire(edges), (wire) => makeFace(wire));
|
|
128
|
-
}
|
|
129
47
|
function isPoint2D(point) {
|
|
130
48
|
return Array.isArray(point) && point.length === 2 && typeof point[0] === "number" && typeof point[1] === "number";
|
|
131
49
|
}
|
|
@@ -493,7 +411,7 @@ class Curve2D {
|
|
|
493
411
|
)
|
|
494
412
|
parameters = parameters.slice(0, -1);
|
|
495
413
|
if (!parameters.length) return [this];
|
|
496
|
-
return zip([
|
|
414
|
+
return surfaceBuilders.zip([
|
|
497
415
|
[firstParam, ...parameters],
|
|
498
416
|
[...parameters, lastParam]
|
|
499
417
|
]).map(([first, last]) => {
|
|
@@ -1105,7 +1023,7 @@ class Blueprint {
|
|
|
1105
1023
|
const originPoint = origin || [...faceFns.faceCenter(face)];
|
|
1106
1024
|
const originVec3 = occtBoundary.toVec3(originPoint);
|
|
1107
1025
|
const sketch = this.translate(faceFns.uvCoordinates(face, originVec3)).sketchOnFace(face, "original");
|
|
1108
|
-
return errors.unwrap(makeFace(sketch.wire));
|
|
1026
|
+
return errors.unwrap(surfaceBuilders.makeFace(sketch.wire));
|
|
1109
1027
|
}
|
|
1110
1028
|
/**
|
|
1111
1029
|
* Cut a prism-shaped hole through a solid along a face using this blueprint.
|
|
@@ -1142,7 +1060,7 @@ class Blueprint {
|
|
|
1142
1060
|
} else {
|
|
1143
1061
|
maker.PerformThruAll();
|
|
1144
1062
|
}
|
|
1145
|
-
return errors.unwrap(
|
|
1063
|
+
return errors.unwrap(faceFns.cast(maker.Shape()));
|
|
1146
1064
|
}
|
|
1147
1065
|
/** Convert the blueprint to an SVG path `d` attribute string. */
|
|
1148
1066
|
toSVGPathD() {
|
|
@@ -1245,7 +1163,6 @@ class Blueprint {
|
|
|
1245
1163
|
exports.Blueprint = Blueprint;
|
|
1246
1164
|
exports.BoundingBox2d = BoundingBox2d;
|
|
1247
1165
|
exports.Curve2D = Curve2D;
|
|
1248
|
-
exports.addHolesInFace = addHolesInFace;
|
|
1249
1166
|
exports.approximateAsBSpline = approximateAsBSpline;
|
|
1250
1167
|
exports.approximateAsSvgCompatibleCurve = approximateAsSvgCompatibleCurve;
|
|
1251
1168
|
exports.asSVG = asSVG;
|
|
@@ -1262,12 +1179,7 @@ exports.make2dInerpolatedBSplineCurve = make2dInerpolatedBSplineCurve;
|
|
|
1262
1179
|
exports.make2dSegmentCurve = make2dSegmentCurve;
|
|
1263
1180
|
exports.make2dTangentArc = make2dTangentArc;
|
|
1264
1181
|
exports.make2dThreePointArc = make2dThreePointArc;
|
|
1265
|
-
exports.makeFace = makeFace;
|
|
1266
|
-
exports.makeNewFaceWithinFace = makeNewFaceWithinFace;
|
|
1267
|
-
exports.makeNonPlanarFace = makeNonPlanarFace;
|
|
1268
1182
|
exports.makePlane = makePlane;
|
|
1269
|
-
exports.makePolygon = makePolygon;
|
|
1270
1183
|
exports.mirror = mirror;
|
|
1271
1184
|
exports.removeDuplicatePoints = removeDuplicatePoints;
|
|
1272
1185
|
exports.viewbox = viewbox;
|
|
1273
|
-
exports.zip = zip;
|
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
import { r as resolvePlane } from "./vectors-
|
|
2
|
-
import { g as getKernel, a as toVec3,
|
|
3
|
-
import {
|
|
4
|
-
import { u as uvBounds,
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { c as
|
|
1
|
+
import { r as resolvePlane } from "./vectors-CZV4ZrTz.js";
|
|
2
|
+
import { g as getKernel, a as toVec3, c as makeOcAx2 } from "./occtBoundary-CWzWqBCm.js";
|
|
3
|
+
import { r as localGC, v as registerForCleanup, x as unregisterFromCleanup, n as gcWithScope, p as createEdge, o as createWire } from "./shapeTypes-D0vfRxWb.js";
|
|
4
|
+
import { u as uvBounds, f as faceGeomType, e as faceCenter, h as uvCoordinates, c as cast } from "./faceFns-CltrEfOo.js";
|
|
5
|
+
import { f as findCurveType, g as getOrientation } from "./curveFns-B85Glnfo.js";
|
|
6
|
+
import { u as unwrap, l as ok, e as err, b as computationError, x as validationError } from "./errors-Coh_5_19.js";
|
|
7
|
+
import { z as zip, m as makeFace } from "./surfaceBuilders-B7Jxob8g.js";
|
|
8
|
+
import { d as distance2d, s as samePoint, b as scalarMultiply2d, c as add2d, n as normalize2d, e as subtract2d, g as getSingleFace } from "./helpers-SksQIreB.js";
|
|
9
9
|
import { R as RAD2DEG, D as DEG2RAD } from "./vecOps-ZDdZWbwT.js";
|
|
10
|
-
import { e as getEdges } from "./shapeFns-k1YHFwmB.js";
|
|
11
|
-
import { m as makeLine, a as assembleWire$1 } from "./curveBuilders-BREwqvuc.js";
|
|
12
10
|
import { bug } from "./result.js";
|
|
13
11
|
function makePlane(plane, origin) {
|
|
14
12
|
if (plane && typeof plane !== "string") {
|
|
@@ -45,86 +43,6 @@ function mirror(shape, inputPlane, origin) {
|
|
|
45
43
|
gc();
|
|
46
44
|
return newShape;
|
|
47
45
|
}
|
|
48
|
-
function range(len) {
|
|
49
|
-
return Array.from(Array(len).keys());
|
|
50
|
-
}
|
|
51
|
-
function zip(arrays) {
|
|
52
|
-
const minLength = Math.min(...arrays.map((arr) => arr.length));
|
|
53
|
-
return range(minLength).map((i) => arrays.map((arr) => arr[i]));
|
|
54
|
-
}
|
|
55
|
-
function makeFace(wire, holes) {
|
|
56
|
-
const oc = getKernel().oc;
|
|
57
|
-
const faceBuilder = new oc.BRepBuilderAPI_MakeFace_15(wire.wrapped, false);
|
|
58
|
-
holes?.forEach((hole) => {
|
|
59
|
-
faceBuilder.Add(hole.wrapped);
|
|
60
|
-
});
|
|
61
|
-
if (!faceBuilder.IsDone()) {
|
|
62
|
-
faceBuilder.delete();
|
|
63
|
-
return err(
|
|
64
|
-
occtError("FACE_BUILD_FAILED", "Failed to build the face. Your wire might be non planar.")
|
|
65
|
-
);
|
|
66
|
-
}
|
|
67
|
-
const face = faceBuilder.Face();
|
|
68
|
-
faceBuilder.delete();
|
|
69
|
-
return ok(createFace(face));
|
|
70
|
-
}
|
|
71
|
-
function makeNewFaceWithinFace(originFace, wire) {
|
|
72
|
-
const oc = getKernel().oc;
|
|
73
|
-
const [r, gc] = localGC();
|
|
74
|
-
const surface = r(oc.BRep_Tool.Surface_2(originFace.wrapped));
|
|
75
|
-
const faceBuilder = r(new oc.BRepBuilderAPI_MakeFace_21(surface, wire.wrapped, true));
|
|
76
|
-
const face = faceBuilder.Face();
|
|
77
|
-
gc();
|
|
78
|
-
return createFace(face);
|
|
79
|
-
}
|
|
80
|
-
function makeNonPlanarFace(wire) {
|
|
81
|
-
const oc = getKernel().oc;
|
|
82
|
-
const [r, gc] = localGC();
|
|
83
|
-
const faceBuilder = r(
|
|
84
|
-
new oc.BRepOffsetAPI_MakeFilling(3, 15, 2, false, 1e-5, 1e-4, 0.01, 0.1, 8, 9)
|
|
85
|
-
);
|
|
86
|
-
getEdges(wire).forEach((edge) => {
|
|
87
|
-
faceBuilder.Add_1(
|
|
88
|
-
edge.wrapped,
|
|
89
|
-
oc.GeomAbs_Shape.GeomAbs_C0,
|
|
90
|
-
true
|
|
91
|
-
);
|
|
92
|
-
});
|
|
93
|
-
const progress = r(new oc.Message_ProgressRange_1());
|
|
94
|
-
faceBuilder.Build(progress);
|
|
95
|
-
return andThen(cast(faceBuilder.Shape()), (newFace) => {
|
|
96
|
-
gc();
|
|
97
|
-
if (!isFace(newFace)) {
|
|
98
|
-
return err(occtError("FACE_BUILD_FAILED", "Failed to create a face"));
|
|
99
|
-
}
|
|
100
|
-
return ok(newFace);
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
function addHolesInFace(face, holes) {
|
|
104
|
-
const oc = getKernel().oc;
|
|
105
|
-
const [r, gc] = localGC();
|
|
106
|
-
const faceMaker = r(new oc.BRepBuilderAPI_MakeFace_2(face.wrapped));
|
|
107
|
-
holes.forEach((wire) => {
|
|
108
|
-
faceMaker.Add(wire.wrapped);
|
|
109
|
-
});
|
|
110
|
-
const builtFace = r(faceMaker.Face());
|
|
111
|
-
const fixer = r(new oc.ShapeFix_Face_2(builtFace));
|
|
112
|
-
fixer.FixOrientation_1();
|
|
113
|
-
const newFace = fixer.Face();
|
|
114
|
-
gc();
|
|
115
|
-
return createFace(newFace);
|
|
116
|
-
}
|
|
117
|
-
function makePolygon(points) {
|
|
118
|
-
if (points.length < 3)
|
|
119
|
-
return err(
|
|
120
|
-
validationError("POLYGON_MIN_POINTS", "You need at least 3 points to make a polygon")
|
|
121
|
-
);
|
|
122
|
-
const edges = zip([points, [...points.slice(1), points[0]]]).map(
|
|
123
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- zip returns untyped pairs
|
|
124
|
-
([p1, p2]) => makeLine(p1, p2)
|
|
125
|
-
);
|
|
126
|
-
return andThen(assembleWire$1(edges), (wire) => makeFace(wire));
|
|
127
|
-
}
|
|
128
46
|
function isPoint2D(point) {
|
|
129
47
|
return Array.isArray(point) && point.length === 2 && typeof point[0] === "number" && typeof point[1] === "number";
|
|
130
48
|
}
|
|
@@ -1242,33 +1160,27 @@ class Blueprint {
|
|
|
1242
1160
|
}
|
|
1243
1161
|
}
|
|
1244
1162
|
export {
|
|
1245
|
-
removeDuplicatePoints as A,
|
|
1246
1163
|
Blueprint as B,
|
|
1247
1164
|
Curve2D as C,
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
viewbox as v,
|
|
1270
|
-
make2dEllipseArc as w,
|
|
1271
|
-
make2dTangentArc as x,
|
|
1272
|
-
make2dBezierCurve as y,
|
|
1273
|
-
zip as z
|
|
1165
|
+
make2dSegmentCurve as a,
|
|
1166
|
+
make2dArcFromCenter as b,
|
|
1167
|
+
approximateAsSvgCompatibleCurve as c,
|
|
1168
|
+
BoundingBox2d as d,
|
|
1169
|
+
edgeToCurve as e,
|
|
1170
|
+
make2dInerpolatedBSplineCurve as f,
|
|
1171
|
+
make2dCircle as g,
|
|
1172
|
+
make2dEllipse as h,
|
|
1173
|
+
deserializeCurve2D as i,
|
|
1174
|
+
approximateAsBSpline as j,
|
|
1175
|
+
isPoint2D as k,
|
|
1176
|
+
make2dThreePointArc as l,
|
|
1177
|
+
mirror as m,
|
|
1178
|
+
asSVG as n,
|
|
1179
|
+
make2dEllipseArc as o,
|
|
1180
|
+
make2dTangentArc as p,
|
|
1181
|
+
make2dBezierCurve as q,
|
|
1182
|
+
axis2d as r,
|
|
1183
|
+
removeDuplicatePoints as s,
|
|
1184
|
+
makePlane as t,
|
|
1185
|
+
viewbox as v
|
|
1274
1186
|
};
|
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
const vectors = require("./vectors-
|
|
3
|
-
const errors = require("./errors-
|
|
4
|
-
const
|
|
5
|
-
const occtBoundary = require("./occtBoundary-
|
|
2
|
+
const vectors = require("./vectors-DwFeX0Ja.cjs");
|
|
3
|
+
const errors = require("./errors-eRQu29oc.cjs");
|
|
4
|
+
const faceFns = require("./faceFns-DcndPHWm.cjs");
|
|
5
|
+
const occtBoundary = require("./occtBoundary-DH2VO-rq.cjs");
|
|
6
6
|
const vecOps = require("./vecOps-CjRL1jau.cjs");
|
|
7
|
-
const loft = require("./loft-
|
|
8
|
-
const shapeTypes = require("./shapeTypes-
|
|
9
|
-
const curveFns = require("./curveFns-
|
|
10
|
-
const
|
|
11
|
-
const faceFns = require("./faceFns-es3GENII.cjs");
|
|
7
|
+
const loft = require("./loft-BcyyvWCj.cjs");
|
|
8
|
+
const shapeTypes = require("./shapeTypes-CMjrTv36.cjs");
|
|
9
|
+
const curveFns = require("./curveFns-BXCbASW-.cjs");
|
|
10
|
+
const surfaceBuilders = require("./surfaceBuilders-Xx9DRRxs.cjs");
|
|
12
11
|
const result = require("./result.cjs");
|
|
13
|
-
const helpers = require("./helpers-
|
|
14
|
-
const
|
|
12
|
+
const helpers = require("./helpers-CC21GeAr.cjs");
|
|
13
|
+
const Blueprint = require("./Blueprint-BcbOBF-9.cjs");
|
|
15
14
|
function* pointsIteration(intersector) {
|
|
16
15
|
const nPoints = intersector.NbPoints();
|
|
17
16
|
if (!nPoints) return;
|
|
@@ -959,7 +958,7 @@ class Sketch {
|
|
|
959
958
|
}
|
|
960
959
|
set baseFace(newFace) {
|
|
961
960
|
if (this._baseFace) this._baseFace.delete();
|
|
962
|
-
this._baseFace = newFace ? shapeTypes.createFace(errors.unwrap(
|
|
961
|
+
this._baseFace = newFace ? shapeTypes.createFace(errors.unwrap(faceFns.downcast(newFace.wrapped))) : newFace;
|
|
963
962
|
}
|
|
964
963
|
/** Release all OCCT resources held by this sketch. */
|
|
965
964
|
delete() {
|
|
@@ -968,11 +967,11 @@ class Sketch {
|
|
|
968
967
|
}
|
|
969
968
|
/** Create an independent deep copy of this sketch. */
|
|
970
969
|
clone() {
|
|
971
|
-
const sketch = new Sketch(shapeTypes.createWire(errors.unwrap(
|
|
970
|
+
const sketch = new Sketch(shapeTypes.createWire(errors.unwrap(faceFns.downcast(this.wire.wrapped))), {
|
|
972
971
|
defaultOrigin: this.defaultOrigin,
|
|
973
972
|
defaultDirection: this.defaultDirection
|
|
974
973
|
});
|
|
975
|
-
if (this.baseFace) sketch.baseFace = shapeTypes.createFace(errors.unwrap(
|
|
974
|
+
if (this.baseFace) sketch.baseFace = shapeTypes.createFace(errors.unwrap(faceFns.downcast(this.baseFace.wrapped)));
|
|
976
975
|
return sketch;
|
|
977
976
|
}
|
|
978
977
|
/** Get the 3D origin used as default for extrusion and revolution. */
|
|
@@ -997,15 +996,15 @@ class Sketch {
|
|
|
997
996
|
face() {
|
|
998
997
|
let face;
|
|
999
998
|
if (!this.baseFace) {
|
|
1000
|
-
face = errors.unwrap(
|
|
999
|
+
face = errors.unwrap(surfaceBuilders.makeFace(this.wire));
|
|
1001
1000
|
} else {
|
|
1002
|
-
face =
|
|
1001
|
+
face = surfaceBuilders.makeNewFaceWithinFace(this.baseFace, this.wire);
|
|
1003
1002
|
}
|
|
1004
1003
|
return face;
|
|
1005
1004
|
}
|
|
1006
1005
|
/** Return a clone of the underlying wire. */
|
|
1007
1006
|
wires() {
|
|
1008
|
-
return shapeTypes.createWire(errors.unwrap(
|
|
1007
|
+
return shapeTypes.createWire(errors.unwrap(faceFns.downcast(this.wire.wrapped)));
|
|
1009
1008
|
}
|
|
1010
1009
|
/** Alias for {@link Sketch.face}. */
|
|
1011
1010
|
faces() {
|
|
@@ -1016,7 +1015,7 @@ class Sketch {
|
|
|
1016
1015
|
* (defaults to the sketch origin)
|
|
1017
1016
|
*/
|
|
1018
1017
|
revolve(revolutionAxis, { origin } = {}) {
|
|
1019
|
-
const face = errors.unwrap(
|
|
1018
|
+
const face = errors.unwrap(surfaceBuilders.makeFace(this.wire));
|
|
1020
1019
|
const solid = errors.unwrap(loft.revolution(face, origin || this.defaultOrigin, revolutionAxis));
|
|
1021
1020
|
face.delete();
|
|
1022
1021
|
this.delete();
|
|
@@ -1058,7 +1057,7 @@ class Sketch {
|
|
|
1058
1057
|
this.delete();
|
|
1059
1058
|
return solid2;
|
|
1060
1059
|
}
|
|
1061
|
-
const face = errors.unwrap(
|
|
1060
|
+
const face = errors.unwrap(surfaceBuilders.makeFace(this.wire));
|
|
1062
1061
|
const solid = loft.basicFaceExtrusion(face, [...extrusionVec]);
|
|
1063
1062
|
gc();
|
|
1064
1063
|
this.delete();
|
|
@@ -1631,7 +1630,7 @@ class FaceSketcher extends BaseSketcher2d {
|
|
|
1631
1630
|
_bounds;
|
|
1632
1631
|
constructor(face, origin = [0, 0]) {
|
|
1633
1632
|
super(origin);
|
|
1634
|
-
this.face = shapeTypes.createFace(errors.unwrap(
|
|
1633
|
+
this.face = shapeTypes.createFace(errors.unwrap(faceFns.downcast(face.wrapped)));
|
|
1635
1634
|
this._bounds = faceFns.uvBounds(face);
|
|
1636
1635
|
}
|
|
1637
1636
|
_convertToUV([x, y]) {
|
|
@@ -1656,7 +1655,7 @@ class FaceSketcher extends BaseSketcher2d {
|
|
|
1656
1655
|
const edges = this.pendingCurves.map((curve) => {
|
|
1657
1656
|
return r(shapeTypes.createEdge(r(new oc.BRepBuilderAPI_MakeEdge_30(curve.wrapped, geomSurf)).Edge()));
|
|
1658
1657
|
});
|
|
1659
|
-
const wire = errors.unwrap(
|
|
1658
|
+
const wire = errors.unwrap(surfaceBuilders.assembleWire(edges));
|
|
1660
1659
|
oc.BRepLib.BuildCurves3d_2(wire.wrapped);
|
|
1661
1660
|
gc();
|
|
1662
1661
|
return wire;
|
|
@@ -1942,7 +1941,7 @@ function findAllIntersections(first, second) {
|
|
|
1942
1941
|
};
|
|
1943
1942
|
}
|
|
1944
1943
|
function splitCurvesAtIntersections(curves, curvePoints) {
|
|
1945
|
-
return
|
|
1944
|
+
return surfaceBuilders.zip([curves, curvePoints]).flatMap(
|
|
1946
1945
|
([curve, intersections]) => {
|
|
1947
1946
|
if (intersections.length === 0) return [curve];
|
|
1948
1947
|
return curve.splitAt(intersections, helpers.PRECISION_INTERSECTION / 100);
|
|
@@ -1994,7 +1993,7 @@ function blueprintsIntersectionSegments(first, second) {
|
|
|
1994
1993
|
secondIntersectedSegments = reverseSegments(secondIntersectedSegments);
|
|
1995
1994
|
}
|
|
1996
1995
|
}
|
|
1997
|
-
return
|
|
1996
|
+
return surfaceBuilders.zip([firstIntersectedSegments, secondIntersectedSegments]).map(
|
|
1998
1997
|
([first2, second2]) => {
|
|
1999
1998
|
if (first2 === void 0 || second2 === void 0) {
|
|
2000
1999
|
result.bug("blueprintsIntersectionSegments", "Mismatched segment counts between blueprints");
|
|
@@ -2012,12 +2011,12 @@ function splitPaths(curves) {
|
|
|
2012
2011
|
const startPoints = curves.map((c) => c.firstPoint);
|
|
2013
2012
|
const shiftedEndPoints = curves.map((c) => c.lastPoint);
|
|
2014
2013
|
const endPoints = shiftedEndPoints.slice(-1).concat(shiftedEndPoints.slice(0, -1));
|
|
2015
|
-
const discontinuities =
|
|
2014
|
+
const discontinuities = surfaceBuilders.zip([startPoints, endPoints]).map(([startPoint, endPoint], index) => {
|
|
2016
2015
|
if (startPoint === void 0 || endPoint === void 0) return null;
|
|
2017
2016
|
return samePoint(startPoint, endPoint) ? null : index;
|
|
2018
2017
|
}).filter((f) => f !== null);
|
|
2019
2018
|
if (discontinuities.length === 0) return [curves];
|
|
2020
|
-
const paths =
|
|
2019
|
+
const paths = surfaceBuilders.zip([discontinuities.slice(0, -1), discontinuities.slice(1)]).map(
|
|
2021
2020
|
([start, end]) => curves.slice(start, end)
|
|
2022
2021
|
);
|
|
2023
2022
|
let lastPath = curves.slice(discontinuities[discontinuities.length - 1]);
|
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
import { a as createPlane } from "./vectors-
|
|
2
|
-
import { l as ok, e as err, b as computationError, u as unwrap, g as isOk } from "./errors-
|
|
3
|
-
import { d as downcast } from "./
|
|
4
|
-
import { g as getKernel, a as toVec3 } from "./occtBoundary-
|
|
1
|
+
import { a as createPlane } from "./vectors-CZV4ZrTz.js";
|
|
2
|
+
import { l as ok, e as err, b as computationError, u as unwrap, g as isOk } from "./errors-Coh_5_19.js";
|
|
3
|
+
import { d as downcast, u as uvBounds, p as pointOnSurface, n as normalAt } from "./faceFns-CltrEfOo.js";
|
|
4
|
+
import { g as getKernel, a as toVec3 } from "./occtBoundary-CWzWqBCm.js";
|
|
5
5
|
import { n as vecScale, j as vecNormalize, b as vecCross, D as DEG2RAD, R as RAD2DEG } from "./vecOps-ZDdZWbwT.js";
|
|
6
|
-
import { r as revolution,
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import { u as uvBounds, p as pointOnSurface, n as normalAt } from "./faceFns-CfJIbHY3.js";
|
|
6
|
+
import { r as revolution, c as complexExtrude, t as twistExtrude, b as basicFaceExtrusion, g as genericSweep, l as loft } from "./loft-CJMPx1NQ.js";
|
|
7
|
+
import { n as gcWithScope, q as createFace, o as createWire, r as localGC, p as createEdge } from "./shapeTypes-D0vfRxWb.js";
|
|
8
|
+
import { d as curveStartPoint, c as curveTangentAt, e as curveIsClosed } from "./curveFns-B85Glnfo.js";
|
|
9
|
+
import { m as makeFace, l as makeNewFaceWithinFace, b as assembleWire, z as zip } from "./surfaceBuilders-B7Jxob8g.js";
|
|
11
10
|
import { bug } from "./result.js";
|
|
12
|
-
import { s as samePoint$1, n as normalize2d,
|
|
13
|
-
import { a as
|
|
11
|
+
import { s as samePoint$1, n as normalize2d, e as subtract2d, c as add2d, i as crossProduct2d, b as scalarMultiply2d, f as polarToCartesian, r as rotate2d, j as cartesianToPolar, d as distance2d, p as polarAngle2d, k as PRECISION_INTERSECTION } from "./helpers-SksQIreB.js";
|
|
12
|
+
import { C as Curve2D, a as make2dSegmentCurve, j as approximateAsBSpline, b as make2dArcFromCenter, k as isPoint2D, g as make2dCircle, l as make2dThreePointArc, d as BoundingBox2d, v as viewbox, n as asSVG, B as Blueprint, o as make2dEllipseArc, p as make2dTangentArc, q as make2dBezierCurve, r as axis2d, s as removeDuplicatePoints } from "./Blueprint-Cmh8lKc4.js";
|
|
14
13
|
function* pointsIteration(intersector) {
|
|
15
14
|
const nPoints = intersector.NbPoints();
|
|
16
15
|
if (!nPoints) return;
|
|
@@ -2441,21 +2440,21 @@ export {
|
|
|
2441
2440
|
FaceSketcher as F,
|
|
2442
2441
|
Sketch as S,
|
|
2443
2442
|
BlueprintSketcher as a,
|
|
2444
|
-
|
|
2445
|
-
|
|
2446
|
-
|
|
2447
|
-
|
|
2448
|
-
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
|
|
2454
|
-
|
|
2443
|
+
Flatbush as b,
|
|
2444
|
+
convertSvgEllipseParams as c,
|
|
2445
|
+
defaultsSplineOptions as d,
|
|
2446
|
+
Blueprints as e,
|
|
2447
|
+
cut2D as f,
|
|
2448
|
+
fuse2D as g,
|
|
2449
|
+
filletCurves as h,
|
|
2450
|
+
intersectCurves as i,
|
|
2451
|
+
chamferCurves as j,
|
|
2452
|
+
intersect2D as k,
|
|
2453
|
+
cutBlueprints as l,
|
|
2455
2454
|
make2dOffset as m,
|
|
2456
|
-
|
|
2455
|
+
fuseBlueprints as n,
|
|
2457
2456
|
organiseBlueprints as o,
|
|
2458
2457
|
polysidesBlueprint as p,
|
|
2459
|
-
|
|
2458
|
+
intersectBlueprints as q,
|
|
2460
2459
|
roundedRectangleBlueprint as r
|
|
2461
2460
|
};
|