brepjs 8.0.1 → 8.0.3
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/blueprints/booleanHelpers.d.ts +32 -0
- package/dist/2d/blueprints/booleanHelpers.d.ts.map +1 -0
- package/dist/2d/blueprints/booleanOperations.d.ts +5 -3
- package/dist/2d/blueprints/booleanOperations.d.ts.map +1 -1
- package/dist/2d/blueprints/intersectionSegments.d.ts +12 -0
- package/dist/2d/blueprints/intersectionSegments.d.ts.map +1 -0
- package/dist/2d/blueprints/segmentAssembly.d.ts +31 -0
- package/dist/2d/blueprints/segmentAssembly.d.ts.map +1 -0
- package/dist/2d.cjs +2 -2
- package/dist/2d.js +8 -8
- package/dist/{Blueprint-D3JfGJTz.js → Blueprint-DnAO3gr5.js} +116 -30
- package/dist/{Blueprint-CVctc41Z.cjs → Blueprint-FxmMji4s.cjs} +110 -24
- package/dist/{boolean2D-hOw5Qay5.js → boolean2D-BnZKKBWU.js} +391 -310
- package/dist/{boolean2D-BdZATaHs.cjs → boolean2D-BrjHZfWn.cjs} +426 -345
- package/dist/{booleanFns-CqehfzcK.js → booleanFns-Ct3wDnhc.js} +14 -18
- package/dist/{booleanFns-BBSVKhL2.cjs → booleanFns-ND7sZvhu.cjs} +12 -16
- package/dist/brepjs.cjs +171 -101
- package/dist/brepjs.js +315 -244
- package/dist/{cast-DQaUibmm.js → cast-BEg1mN7n.js} +2 -2
- package/dist/{cast-DkB0GKmQ.cjs → cast-CqDc8oFW.cjs} +2 -2
- package/dist/core/disposal.d.ts +1 -1
- package/dist/core/disposal.d.ts.map +1 -1
- package/dist/core.cjs +3 -3
- package/dist/core.js +3 -3
- package/dist/cornerFinder-89obDwGi.js +59 -0
- package/dist/cornerFinder-BKsCkrXd.cjs +58 -0
- package/dist/curveBuilders-BjtdNw1B.cjs +196 -0
- package/dist/curveBuilders-U26XDfxg.js +197 -0
- package/dist/curveFns-BoG_iA07.cjs +375 -0
- package/dist/curveFns-Cg99XKe2.js +376 -0
- package/dist/{drawFns-CUyx50gi.cjs → drawFns-C-MCkYj6.cjs} +60 -62
- package/dist/{drawFns-921SkhDL.js → drawFns-DJV-nOox.js} +12 -14
- package/dist/{faceFns-DHu-2JpA.js → faceFns-CyokaCDr.js} +3 -3
- package/dist/{faceFns-BwK7FP7N.cjs → faceFns-DcSCjDG0.cjs} +3 -3
- package/dist/helpers--iZxPeJg.cjs +203 -0
- package/dist/helpers-CRx_ks-u.js +204 -0
- package/dist/io.cjs +4 -4
- package/dist/io.js +4 -4
- package/dist/kernel/curveOps.d.ts.map +1 -1
- package/dist/kernel/meshOps.d.ts.map +1 -1
- package/dist/kernel/modifierOps.d.ts.map +1 -1
- package/dist/kernel/occtAdapter.d.ts +1 -0
- package/dist/kernel/occtAdapter.d.ts.map +1 -1
- package/dist/kernel/sweepOps.d.ts +8 -0
- package/dist/kernel/sweepOps.d.ts.map +1 -1
- package/dist/kernel/types.d.ts +1 -0
- package/dist/kernel/types.d.ts.map +1 -1
- package/dist/loft-8asn63t4.cjs +372 -0
- package/dist/loft-jIkZRqHm.js +373 -0
- package/dist/{measurement-C5JGCuUP.js → measurement-DWv8kK6J.js} +3 -3
- package/dist/{measurement-fxm_pW7x.cjs → measurement-lRLwaoqD.cjs} +3 -3
- package/dist/measurement.cjs +1 -1
- package/dist/measurement.js +1 -1
- package/dist/{meshFns-BhrZGi6w.cjs → meshFns-DWuLC3fk.cjs} +29 -9
- package/dist/{meshFns-AqAjTTVl.js → meshFns-DgAIL1B-.js} +29 -9
- package/dist/{occtBoundary-du8_ex-p.cjs → occtBoundary-DHtzU4tz.cjs} +93 -61
- package/dist/{occtBoundary-CwegMzqc.js → occtBoundary-DYsksDtE.js} +98 -66
- package/dist/operations/extrude.d.ts.map +1 -1
- package/dist/operations/extrudeFns.d.ts.map +1 -1
- package/dist/operations/extrudeUtils.d.ts +17 -0
- package/dist/operations/extrudeUtils.d.ts.map +1 -1
- package/dist/operations/patternFns.d.ts.map +1 -1
- package/dist/{operations-C1rWoba2.js → operations-B8FHVC22.js} +54 -9
- package/dist/{operations-BP1wVDw0.cjs → operations-CCFPvtd-.cjs} +54 -9
- package/dist/operations.cjs +2 -2
- package/dist/operations.js +4 -4
- package/dist/query/cornerFinder.d.ts +48 -0
- package/dist/query/cornerFinder.d.ts.map +1 -0
- package/dist/query/directionUtils.d.ts +6 -0
- package/dist/query/directionUtils.d.ts.map +1 -0
- package/dist/query/edgeFinder.d.ts +15 -0
- package/dist/query/edgeFinder.d.ts.map +1 -0
- package/dist/query/faceFinder.d.ts +15 -0
- package/dist/query/faceFinder.d.ts.map +1 -0
- package/dist/query/finderCore.d.ts +35 -0
- package/dist/query/finderCore.d.ts.map +1 -0
- package/dist/query/finderFns.d.ts +21 -106
- package/dist/query/finderFns.d.ts.map +1 -1
- package/dist/query/shapeDistanceFilter.d.ts +11 -0
- package/dist/query/shapeDistanceFilter.d.ts.map +1 -0
- package/dist/query/vertexFinder.d.ts +16 -0
- package/dist/query/vertexFinder.d.ts.map +1 -0
- package/dist/query/wireFinder.d.ts +10 -0
- package/dist/query/wireFinder.d.ts.map +1 -0
- package/dist/query.cjs +42 -5
- package/dist/query.js +40 -2
- package/dist/{shapeTypes-DKhwEnUM.cjs → shapeTypes-b_lhwQB7.cjs} +24 -20
- package/dist/{shapeTypes-BlSElW8z.js → shapeTypes-i7VwMRwc.js} +32 -28
- package/dist/sketching/Sketcher.d.ts.map +1 -1
- package/dist/sketching/Sketcher2d.d.ts +12 -4
- package/dist/sketching/Sketcher2d.d.ts.map +1 -1
- package/dist/sketching/ellipseUtils.d.ts +29 -0
- package/dist/sketching/ellipseUtils.d.ts.map +1 -0
- package/dist/sketching.cjs +2 -2
- package/dist/sketching.js +2 -2
- package/dist/topology/booleanFns.d.ts.map +1 -1
- package/dist/topology/curveBuilders.d.ts +75 -0
- package/dist/topology/curveBuilders.d.ts.map +1 -0
- package/dist/topology/curveFns.d.ts.map +1 -1
- package/dist/topology/meshFns.d.ts.map +1 -1
- package/dist/topology/primitiveFns.d.ts.map +1 -1
- package/dist/topology/shapeFns.d.ts.map +1 -1
- package/dist/topology/shapeHelpers.d.ts +6 -173
- package/dist/topology/shapeHelpers.d.ts.map +1 -1
- package/dist/topology/shapeUtils.d.ts +13 -0
- package/dist/topology/shapeUtils.d.ts.map +1 -0
- package/dist/topology/solidBuilders.d.ts +70 -0
- package/dist/topology/solidBuilders.d.ts.map +1 -0
- package/dist/topology/surfaceBuilders.d.ts +35 -0
- package/dist/topology/surfaceBuilders.d.ts.map +1 -0
- package/dist/topology/wrapperFns.d.ts +1 -0
- package/dist/topology/wrapperFns.d.ts.map +1 -1
- package/dist/{topology-tFzqSrGH.js → topology-Bh-aPIxA.js} +7 -8
- package/dist/{topology-CIooytHH.cjs → topology-ByOn_z3E.cjs} +12 -13
- package/dist/topology.cjs +33 -34
- package/dist/topology.js +54 -55
- package/dist/{vectors-CBuaMeZv.js → vectors-DWLjb9-P.js} +1 -1
- package/dist/{vectors-ChWEZPwy.cjs → vectors-aQBZK0Sb.cjs} +1 -1
- package/dist/vectors.cjs +2 -2
- package/dist/vectors.js +2 -2
- package/package.json +1 -1
- package/dist/curveFns-BilyYL_s.cjs +0 -190
- package/dist/curveFns-CdVE4da7.js +0 -191
- package/dist/loft-BzWFokmC.cjs +0 -178
- package/dist/loft-CtG5nMq5.js +0 -179
- package/dist/query-V6nV-VfL.js +0 -396
- package/dist/query-hMSmOWJP.cjs +0 -395
- package/dist/shapeFns-BrF97sKt.js +0 -204
- package/dist/shapeFns-BvOndshS.cjs +0 -203
- package/dist/shapeHelpers-B2SXz1p4.cjs +0 -488
- package/dist/shapeHelpers-BcoZf2N9.js +0 -489
|
@@ -0,0 +1,373 @@
|
|
|
1
|
+
import { g as getKernel, b as toOcPnt, m as makeOcAx2, e as makeOcAx1, a as toVec3 } from "./occtBoundary-DYsksDtE.js";
|
|
2
|
+
import { D as DEG2RAD, v as vecAdd, g as vecLength } from "./vecOps-ZDdZWbwT.js";
|
|
3
|
+
import { c as cast, d as downcast, a as isShape3D$1, b as isWire } from "./cast-BEg1mN7n.js";
|
|
4
|
+
import { e as err, x as validationError, l as ok, u as unwrap, p as typeCastError, a as andThen, o as occtError } from "./errors-wGhcJMpB.js";
|
|
5
|
+
import { p as gcWithScope, j as isShell, q as createCompound, r as createVertex, s as createSolid, h as isShape3D, k as isSolid, t as localGC } from "./shapeTypes-i7VwMRwc.js";
|
|
6
|
+
import { m as makeLine, a as assembleWire, b as makeHelix } from "./curveBuilders-U26XDfxg.js";
|
|
7
|
+
function buildLawFromProfile(extrusionLength, { profile, endFactor = 1 }) {
|
|
8
|
+
const oc = getKernel().oc;
|
|
9
|
+
const r = gcWithScope();
|
|
10
|
+
let law;
|
|
11
|
+
if (profile === "s-curve") {
|
|
12
|
+
law = r(new oc.Law_S());
|
|
13
|
+
law.Set_1(0, 1, extrusionLength, endFactor);
|
|
14
|
+
} else if (profile === "linear") {
|
|
15
|
+
law = r(new oc.Law_Linear());
|
|
16
|
+
law.Set(0, 1, extrusionLength, endFactor);
|
|
17
|
+
} else {
|
|
18
|
+
return err(
|
|
19
|
+
validationError("UNSUPPORTED_PROFILE", `Unsupported extrusion profile: ${String(profile)}`)
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
return ok(law.Trim(0, extrusionLength, 1e-6));
|
|
23
|
+
}
|
|
24
|
+
function weldShapes(facesOrShells) {
|
|
25
|
+
const sewn = getKernel().sew(facesOrShells.map((s) => s.wrapped));
|
|
26
|
+
return unwrap(cast(unwrap(downcast(sewn))));
|
|
27
|
+
}
|
|
28
|
+
function weldShellsAndFaces(facesOrShells, ignoreType = false) {
|
|
29
|
+
const shell = weldShapes(facesOrShells);
|
|
30
|
+
if (!ignoreType && !isShell(shell))
|
|
31
|
+
return err(typeCastError("WELD_NOT_SHELL", "Could not make a shell from faces and shells"));
|
|
32
|
+
return ok(shell);
|
|
33
|
+
}
|
|
34
|
+
function makeCylinder(radius, height, location = [0, 0, 0], direction = [0, 0, 1]) {
|
|
35
|
+
const oc = getKernel().oc;
|
|
36
|
+
const r = gcWithScope();
|
|
37
|
+
const axis = r(makeOcAx2(location, direction));
|
|
38
|
+
const cylinder = r(new oc.BRepPrimAPI_MakeCylinder_3(axis, radius, height));
|
|
39
|
+
return createSolid(cylinder.Shape());
|
|
40
|
+
}
|
|
41
|
+
function makeSphere(radius) {
|
|
42
|
+
const oc = getKernel().oc;
|
|
43
|
+
const r = gcWithScope();
|
|
44
|
+
const sphereMaker = r(new oc.BRepPrimAPI_MakeSphere_1(radius));
|
|
45
|
+
return createSolid(sphereMaker.Shape());
|
|
46
|
+
}
|
|
47
|
+
function makeCone(radius1, radius2, height, location = [0, 0, 0], direction = [0, 0, 1]) {
|
|
48
|
+
const oc = getKernel().oc;
|
|
49
|
+
const r = gcWithScope();
|
|
50
|
+
const axis = r(makeOcAx2(location, direction));
|
|
51
|
+
const coneMaker = r(new oc.BRepPrimAPI_MakeCone_3(axis, radius1, radius2, height));
|
|
52
|
+
return createSolid(coneMaker.Shape());
|
|
53
|
+
}
|
|
54
|
+
function makeTorus(majorRadius, minorRadius, location = [0, 0, 0], direction = [0, 0, 1]) {
|
|
55
|
+
const oc = getKernel().oc;
|
|
56
|
+
const r = gcWithScope();
|
|
57
|
+
const axis = r(makeOcAx2(location, direction));
|
|
58
|
+
const torusMaker = r(new oc.BRepPrimAPI_MakeTorus_5(axis, majorRadius, minorRadius));
|
|
59
|
+
return createSolid(torusMaker.Shape());
|
|
60
|
+
}
|
|
61
|
+
function makeEllipsoidTransform(x, y, z) {
|
|
62
|
+
const oc = getKernel().oc;
|
|
63
|
+
const r = gcWithScope();
|
|
64
|
+
const xyRatio = Math.sqrt(x * y / z);
|
|
65
|
+
const xzRatio = x / xyRatio;
|
|
66
|
+
const yzRatio = y / xyRatio;
|
|
67
|
+
const ax1 = r(makeOcAx1([0, 0, 0], [0, 1, 0]));
|
|
68
|
+
const ax2 = r(makeOcAx1([0, 0, 0], [0, 0, 1]));
|
|
69
|
+
const ax3 = r(makeOcAx1([0, 0, 0], [1, 0, 0]));
|
|
70
|
+
const transform = new oc.gp_GTrsf_1();
|
|
71
|
+
transform.SetAffinity_1(ax1, xzRatio);
|
|
72
|
+
const xy = r(new oc.gp_GTrsf_1());
|
|
73
|
+
xy.SetAffinity_1(ax2, xyRatio);
|
|
74
|
+
const yz = r(new oc.gp_GTrsf_1());
|
|
75
|
+
yz.SetAffinity_1(ax3, yzRatio);
|
|
76
|
+
transform.Multiply(xy);
|
|
77
|
+
transform.Multiply(yz);
|
|
78
|
+
return {
|
|
79
|
+
transform,
|
|
80
|
+
applyToPoint(p) {
|
|
81
|
+
const r2 = gcWithScope();
|
|
82
|
+
const coords = r2(p.XYZ());
|
|
83
|
+
transform.Transforms_1(coords);
|
|
84
|
+
return new oc.gp_Pnt_2(coords);
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
function convertToJSArray(arrayOfPoints) {
|
|
89
|
+
const newArray = [];
|
|
90
|
+
for (let row = arrayOfPoints.LowerRow(); row <= arrayOfPoints.UpperRow(); row++) {
|
|
91
|
+
const rowArr = [];
|
|
92
|
+
newArray.push(rowArr);
|
|
93
|
+
for (let c = arrayOfPoints.LowerCol(); c <= arrayOfPoints.UpperCol(); c++) {
|
|
94
|
+
const pnt = arrayOfPoints.Value(row, c);
|
|
95
|
+
rowArr.push(pnt);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
return newArray;
|
|
99
|
+
}
|
|
100
|
+
function makeEllipsoid(aLength, bLength, cLength) {
|
|
101
|
+
const oc = getKernel().oc;
|
|
102
|
+
const r = gcWithScope();
|
|
103
|
+
const sphere = r(new oc.gp_Sphere_1());
|
|
104
|
+
sphere.SetRadius(1);
|
|
105
|
+
const sphericalSurface = r(new oc.Geom_SphericalSurface_2(sphere));
|
|
106
|
+
const baseSurface = oc.GeomConvert.SurfaceToBSplineSurface(sphericalSurface.UReversed()).get();
|
|
107
|
+
try {
|
|
108
|
+
const poles = convertToJSArray(baseSurface.Poles_2());
|
|
109
|
+
const ellipsoidTrsf = makeEllipsoidTransform(aLength, bLength, cLength);
|
|
110
|
+
poles.forEach((columns, rowIdx) => {
|
|
111
|
+
columns.forEach((value, colIdx) => {
|
|
112
|
+
const newPoint = ellipsoidTrsf.applyToPoint(value);
|
|
113
|
+
baseSurface.SetPole_1(rowIdx + 1, colIdx + 1, newPoint);
|
|
114
|
+
newPoint.delete();
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
ellipsoidTrsf.transform.delete();
|
|
118
|
+
const shell = unwrap(
|
|
119
|
+
cast(r(new oc.BRepBuilderAPI_MakeShell_2(baseSurface.UReversed(), false)).Shell())
|
|
120
|
+
);
|
|
121
|
+
return unwrap(makeSolid([shell]));
|
|
122
|
+
} finally {
|
|
123
|
+
baseSurface.delete();
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
function makeVertex(point) {
|
|
127
|
+
const oc = getKernel().oc;
|
|
128
|
+
const r = gcWithScope();
|
|
129
|
+
const pnt = r(toOcPnt(point));
|
|
130
|
+
const vertexMaker = r(new oc.BRepBuilderAPI_MakeVertex(pnt));
|
|
131
|
+
return createVertex(vertexMaker.Vertex());
|
|
132
|
+
}
|
|
133
|
+
function makeOffset(face, offset, tolerance = 1e-6) {
|
|
134
|
+
const oc = getKernel().oc;
|
|
135
|
+
const progress = new oc.Message_ProgressRange_1();
|
|
136
|
+
const offsetBuilder = new oc.BRepOffsetAPI_MakeOffsetShape();
|
|
137
|
+
try {
|
|
138
|
+
offsetBuilder.PerformByJoin(
|
|
139
|
+
face.wrapped,
|
|
140
|
+
offset,
|
|
141
|
+
tolerance,
|
|
142
|
+
oc.BRepOffset_Mode.BRepOffset_Skin,
|
|
143
|
+
false,
|
|
144
|
+
false,
|
|
145
|
+
oc.GeomAbs_JoinType.GeomAbs_Arc,
|
|
146
|
+
false,
|
|
147
|
+
progress
|
|
148
|
+
);
|
|
149
|
+
return andThen(
|
|
150
|
+
downcast(offsetBuilder.Shape()),
|
|
151
|
+
(downcasted) => andThen(cast(downcasted), (newShape) => {
|
|
152
|
+
if (!isShape3D(newShape))
|
|
153
|
+
return err(typeCastError("OFFSET_NOT_3D", "Could not offset to a 3d shape"));
|
|
154
|
+
return ok(newShape);
|
|
155
|
+
})
|
|
156
|
+
);
|
|
157
|
+
} finally {
|
|
158
|
+
offsetBuilder.delete();
|
|
159
|
+
progress.delete();
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
function makeCompound(shapeArray) {
|
|
163
|
+
const oc = getKernel().oc;
|
|
164
|
+
const builder = new oc.TopoDS_Builder();
|
|
165
|
+
const compound = new oc.TopoDS_Compound();
|
|
166
|
+
builder.MakeCompound(compound);
|
|
167
|
+
for (const s of shapeArray) {
|
|
168
|
+
builder.Add(compound, s.wrapped);
|
|
169
|
+
}
|
|
170
|
+
builder.delete();
|
|
171
|
+
return createCompound(compound);
|
|
172
|
+
}
|
|
173
|
+
function makeSolid(facesOrShells) {
|
|
174
|
+
const r = gcWithScope();
|
|
175
|
+
const oc = getKernel().oc;
|
|
176
|
+
const shell = weldShapes(facesOrShells);
|
|
177
|
+
return andThen(cast(r(new oc.ShapeFix_Solid_1()).SolidFromShell(shell.wrapped)), (solid) => {
|
|
178
|
+
if (!isSolid(solid))
|
|
179
|
+
return err(typeCastError("SOLID_BUILD_FAILED", "Could not make a solid of faces and shells"));
|
|
180
|
+
return ok(solid);
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
const basicFaceExtrusion = (face, extrusionVec) => {
|
|
184
|
+
const oc = getKernel().oc;
|
|
185
|
+
const [r, gc] = localGC();
|
|
186
|
+
const vec = toVec3(extrusionVec);
|
|
187
|
+
const ocVec = r(new oc.gp_Vec_4(vec[0], vec[1], vec[2]));
|
|
188
|
+
const solidBuilder = r(new oc.BRepPrimAPI_MakePrism_1(face.wrapped, ocVec, false, true));
|
|
189
|
+
const solid = createSolid(unwrap(downcast(solidBuilder.Shape())));
|
|
190
|
+
gc();
|
|
191
|
+
return solid;
|
|
192
|
+
};
|
|
193
|
+
const revolution = (face, center = [0, 0, 0], direction = [0, 0, 1], angle = 360) => {
|
|
194
|
+
const oc = getKernel().oc;
|
|
195
|
+
const [r, gc] = localGC();
|
|
196
|
+
const centerVec = toVec3(center);
|
|
197
|
+
const directionVec = toVec3(direction);
|
|
198
|
+
const ax = r(makeOcAx1(centerVec, directionVec));
|
|
199
|
+
const revolBuilder = r(new oc.BRepPrimAPI_MakeRevol_1(face.wrapped, ax, angle * DEG2RAD, false));
|
|
200
|
+
const result = andThen(cast(revolBuilder.Shape()), (shape) => {
|
|
201
|
+
if (!isShape3D$1(shape))
|
|
202
|
+
return err(typeCastError("REVOLUTION_NOT_3D", "Revolution did not produce a 3D shape"));
|
|
203
|
+
return ok(shape);
|
|
204
|
+
});
|
|
205
|
+
gc();
|
|
206
|
+
return result;
|
|
207
|
+
};
|
|
208
|
+
function genericSweep(wire, spine, {
|
|
209
|
+
frenet = false,
|
|
210
|
+
auxiliarySpine,
|
|
211
|
+
law = null,
|
|
212
|
+
transitionMode = "right",
|
|
213
|
+
withContact,
|
|
214
|
+
support,
|
|
215
|
+
forceProfileSpineOthogonality,
|
|
216
|
+
mode: sweepMode,
|
|
217
|
+
tolerance,
|
|
218
|
+
boundTolerance,
|
|
219
|
+
angularTolerance,
|
|
220
|
+
maxDegree,
|
|
221
|
+
maxSegments
|
|
222
|
+
} = {}, shellMode = false) {
|
|
223
|
+
if (sweepMode === "simple" && !shellMode) {
|
|
224
|
+
const kernel = getKernel();
|
|
225
|
+
const resultOc = kernel.simplePipe(wire.wrapped, spine.wrapped);
|
|
226
|
+
const result = andThen(cast(resultOc), (shape2) => {
|
|
227
|
+
if (!isShape3D$1(shape2))
|
|
228
|
+
return err(typeCastError("SWEEP_NOT_3D", "Simple pipe did not produce a 3D shape"));
|
|
229
|
+
return ok(shape2);
|
|
230
|
+
});
|
|
231
|
+
return result;
|
|
232
|
+
}
|
|
233
|
+
const oc = getKernel().oc;
|
|
234
|
+
const [r, gc] = localGC();
|
|
235
|
+
const withCorrection = transitionMode === "round" ? true : !!forceProfileSpineOthogonality;
|
|
236
|
+
const sweepBuilder = r(new oc.BRepOffsetAPI_MakePipeShell(spine.wrapped));
|
|
237
|
+
if (tolerance !== void 0) {
|
|
238
|
+
sweepBuilder.SetTolerance(tolerance, boundTolerance ?? tolerance, angularTolerance ?? 1e-7);
|
|
239
|
+
}
|
|
240
|
+
if (maxDegree !== void 0) {
|
|
241
|
+
sweepBuilder.SetMaxDegree(maxDegree);
|
|
242
|
+
}
|
|
243
|
+
if (maxSegments !== void 0) {
|
|
244
|
+
sweepBuilder.SetMaxSegments(maxSegments);
|
|
245
|
+
}
|
|
246
|
+
{
|
|
247
|
+
const mode = {
|
|
248
|
+
transformed: oc.BRepBuilderAPI_TransitionMode.BRepBuilderAPI_Transformed,
|
|
249
|
+
round: oc.BRepBuilderAPI_TransitionMode.BRepBuilderAPI_RoundCorner,
|
|
250
|
+
right: oc.BRepBuilderAPI_TransitionMode.BRepBuilderAPI_RightCorner
|
|
251
|
+
}[transitionMode];
|
|
252
|
+
if (mode) sweepBuilder.SetTransitionMode(mode);
|
|
253
|
+
}
|
|
254
|
+
if (support) {
|
|
255
|
+
sweepBuilder.SetMode_4(support);
|
|
256
|
+
} else if (frenet) {
|
|
257
|
+
sweepBuilder.SetMode_1(frenet);
|
|
258
|
+
}
|
|
259
|
+
if (auxiliarySpine) {
|
|
260
|
+
sweepBuilder.SetMode_5(
|
|
261
|
+
auxiliarySpine.wrapped,
|
|
262
|
+
false,
|
|
263
|
+
oc.BRepFill_TypeOfContact.BRepFill_NoContact
|
|
264
|
+
);
|
|
265
|
+
}
|
|
266
|
+
if (!law) sweepBuilder.Add_1(wire.wrapped, !!withContact, withCorrection);
|
|
267
|
+
else sweepBuilder.SetLaw_1(wire.wrapped, law, !!withContact, withCorrection);
|
|
268
|
+
const progress = r(new oc.Message_ProgressRange_1());
|
|
269
|
+
sweepBuilder.Build(progress);
|
|
270
|
+
if (!sweepBuilder.IsDone()) {
|
|
271
|
+
gc();
|
|
272
|
+
return err(occtError("SWEEP_FAILED", "Sweep operation failed"));
|
|
273
|
+
}
|
|
274
|
+
if (!shellMode) {
|
|
275
|
+
sweepBuilder.MakeSolid();
|
|
276
|
+
}
|
|
277
|
+
const shape = unwrap(cast(sweepBuilder.Shape()));
|
|
278
|
+
if (!isShape3D$1(shape)) {
|
|
279
|
+
gc();
|
|
280
|
+
return err(typeCastError("SWEEP_NOT_3D", "Sweep did not produce a 3D shape"));
|
|
281
|
+
}
|
|
282
|
+
if (shellMode) {
|
|
283
|
+
const startWire = unwrap(cast(sweepBuilder.FirstShape()));
|
|
284
|
+
const endWire = unwrap(cast(sweepBuilder.LastShape()));
|
|
285
|
+
if (!isWire(startWire)) {
|
|
286
|
+
gc();
|
|
287
|
+
return err(typeCastError("SWEEP_START_NOT_WIRE", "Sweep did not produce a start Wire"));
|
|
288
|
+
}
|
|
289
|
+
if (!isWire(endWire)) {
|
|
290
|
+
gc();
|
|
291
|
+
return err(typeCastError("SWEEP_END_NOT_WIRE", "Sweep did not produce an end Wire"));
|
|
292
|
+
}
|
|
293
|
+
gc();
|
|
294
|
+
return ok([shape, startWire, endWire]);
|
|
295
|
+
}
|
|
296
|
+
gc();
|
|
297
|
+
return ok(shape);
|
|
298
|
+
}
|
|
299
|
+
function complexExtrude(wire, center, normal, profileShape, shellMode = false) {
|
|
300
|
+
const [r, gc] = localGC();
|
|
301
|
+
const centerVec = toVec3(center);
|
|
302
|
+
const normalVec = toVec3(normal);
|
|
303
|
+
const endVec = vecAdd(centerVec, normalVec);
|
|
304
|
+
const mainSpineEdge = r(makeLine(centerVec, endVec));
|
|
305
|
+
const spine = r(unwrap(assembleWire([mainSpineEdge])));
|
|
306
|
+
const law = profileShape ? r(unwrap(buildLawFromProfile(vecLength(normalVec), profileShape))) : null;
|
|
307
|
+
const result = shellMode ? genericSweep(wire, spine, { law }, shellMode) : genericSweep(wire, spine, { law }, shellMode);
|
|
308
|
+
gc();
|
|
309
|
+
return result;
|
|
310
|
+
}
|
|
311
|
+
function twistExtrude(wire, angleDegrees, center, normal, profileShape, shellMode = false) {
|
|
312
|
+
const [r, gc] = localGC();
|
|
313
|
+
const centerVec = toVec3(center);
|
|
314
|
+
const normalVec = toVec3(normal);
|
|
315
|
+
const endVec = vecAdd(centerVec, normalVec);
|
|
316
|
+
const mainSpineEdge = r(makeLine(centerVec, endVec));
|
|
317
|
+
const spine = r(unwrap(assembleWire([mainSpineEdge])));
|
|
318
|
+
const extrusionLength = vecLength(normalVec);
|
|
319
|
+
const pitch = 360 / angleDegrees * extrusionLength;
|
|
320
|
+
const radius = 1;
|
|
321
|
+
const auxiliarySpine = r(makeHelix(pitch, extrusionLength, radius, centerVec, normalVec));
|
|
322
|
+
const law = profileShape ? r(unwrap(buildLawFromProfile(extrusionLength, profileShape))) : null;
|
|
323
|
+
const result = shellMode ? genericSweep(wire, spine, { auxiliarySpine, law }, shellMode) : genericSweep(wire, spine, { auxiliarySpine, law }, shellMode);
|
|
324
|
+
gc();
|
|
325
|
+
return result;
|
|
326
|
+
}
|
|
327
|
+
const loft = (wires, { ruled = true, startPoint, endPoint } = {}, returnShell = false) => {
|
|
328
|
+
if (wires.length === 0 && !startPoint && !endPoint) {
|
|
329
|
+
return err(validationError("LOFT_EMPTY", "Loft requires at least one wire or start/end point"));
|
|
330
|
+
}
|
|
331
|
+
const oc = getKernel().oc;
|
|
332
|
+
const [r, gc] = localGC();
|
|
333
|
+
const loftBuilder = r(new oc.BRepOffsetAPI_ThruSections(!returnShell, ruled, 1e-6));
|
|
334
|
+
if (startPoint) {
|
|
335
|
+
loftBuilder.AddVertex(r(makeVertex(toVec3(startPoint))).wrapped);
|
|
336
|
+
}
|
|
337
|
+
wires.forEach((w) => loftBuilder.AddWire(w.wrapped));
|
|
338
|
+
if (endPoint) {
|
|
339
|
+
loftBuilder.AddVertex(r(makeVertex(toVec3(endPoint))).wrapped);
|
|
340
|
+
}
|
|
341
|
+
const progress = r(new oc.Message_ProgressRange_1());
|
|
342
|
+
loftBuilder.Build(progress);
|
|
343
|
+
if (!loftBuilder.IsDone()) {
|
|
344
|
+
gc();
|
|
345
|
+
return err(occtError("LOFT_FAILED", "Loft operation failed"));
|
|
346
|
+
}
|
|
347
|
+
const result = andThen(cast(loftBuilder.Shape()), (shape) => {
|
|
348
|
+
if (!isShape3D$1(shape))
|
|
349
|
+
return err(typeCastError("LOFT_NOT_3D", "Loft did not produce a 3D shape"));
|
|
350
|
+
return ok(shape);
|
|
351
|
+
});
|
|
352
|
+
gc();
|
|
353
|
+
return result;
|
|
354
|
+
};
|
|
355
|
+
export {
|
|
356
|
+
makeCone as a,
|
|
357
|
+
makeCylinder as b,
|
|
358
|
+
makeEllipsoid as c,
|
|
359
|
+
makeOffset as d,
|
|
360
|
+
makeSolid as e,
|
|
361
|
+
makeSphere as f,
|
|
362
|
+
makeTorus as g,
|
|
363
|
+
makeVertex as h,
|
|
364
|
+
basicFaceExtrusion as i,
|
|
365
|
+
genericSweep as j,
|
|
366
|
+
complexExtrude as k,
|
|
367
|
+
loft as l,
|
|
368
|
+
makeCompound as m,
|
|
369
|
+
buildLawFromProfile as n,
|
|
370
|
+
revolution as r,
|
|
371
|
+
twistExtrude as t,
|
|
372
|
+
weldShellsAndFaces as w
|
|
373
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { g as getKernel, s as surfaceCurvature } from "./occtBoundary-
|
|
2
|
-
import {
|
|
3
|
-
import { u as uvBounds } from "./faceFns-
|
|
1
|
+
import { g as getKernel, s as surfaceCurvature } from "./occtBoundary-DYsksDtE.js";
|
|
2
|
+
import { p as gcWithScope } from "./shapeTypes-i7VwMRwc.js";
|
|
3
|
+
import { u as uvBounds } from "./faceFns-CyokaCDr.js";
|
|
4
4
|
function assertShapeNotNull(shape, fn) {
|
|
5
5
|
if (shape.wrapped.IsNull()) {
|
|
6
6
|
throw new Error(`${fn}: shape is a null shape`);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
const occtBoundary = require("./occtBoundary-
|
|
3
|
-
const shapeTypes = require("./shapeTypes-
|
|
4
|
-
const faceFns = require("./faceFns-
|
|
2
|
+
const occtBoundary = require("./occtBoundary-DHtzU4tz.cjs");
|
|
3
|
+
const shapeTypes = require("./shapeTypes-b_lhwQB7.cjs");
|
|
4
|
+
const faceFns = require("./faceFns-DcSCjDG0.cjs");
|
|
5
5
|
function assertShapeNotNull(shape, fn) {
|
|
6
6
|
if (shape.wrapped.IsNull()) {
|
|
7
7
|
throw new Error(`${fn}: shape is a null shape`);
|
package/dist/measurement.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const measurement = require("./measurement-
|
|
3
|
+
const measurement = require("./measurement-lRLwaoqD.cjs");
|
|
4
4
|
exports.createDistanceQuery = measurement.createDistanceQuery;
|
|
5
5
|
exports.measureArea = measurement.measureArea;
|
|
6
6
|
exports.measureDistance = measurement.measureDistance;
|
package/dist/measurement.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
const occtBoundary = require("./occtBoundary-
|
|
2
|
+
const occtBoundary = require("./occtBoundary-DHtzU4tz.cjs");
|
|
3
3
|
const errors = require("./errors-DK1VAdP4.cjs");
|
|
4
4
|
function buildMeshCacheKey(tolerance, angularTolerance, skipNormals) {
|
|
5
5
|
return `${tolerance}:${angularTolerance}:${skipNormals}`;
|
|
@@ -71,6 +71,24 @@ function createMeshCache() {
|
|
|
71
71
|
}
|
|
72
72
|
};
|
|
73
73
|
}
|
|
74
|
+
function shapeHasTriangulation(oc, shape) {
|
|
75
|
+
const explorer = new oc.TopExp_Explorer_2(
|
|
76
|
+
shape,
|
|
77
|
+
oc.TopAbs_ShapeEnum.TopAbs_FACE,
|
|
78
|
+
oc.TopAbs_ShapeEnum.TopAbs_SHAPE
|
|
79
|
+
);
|
|
80
|
+
let hasTri = false;
|
|
81
|
+
if (explorer.More()) {
|
|
82
|
+
const face = oc.TopoDS.Face_1(explorer.Current());
|
|
83
|
+
const loc = new oc.TopLoc_Location_1();
|
|
84
|
+
const tri = oc.BRep_Tool.Triangulation(face, loc, 0);
|
|
85
|
+
hasTri = !tri.IsNull();
|
|
86
|
+
loc.delete();
|
|
87
|
+
tri.delete();
|
|
88
|
+
}
|
|
89
|
+
explorer.delete();
|
|
90
|
+
return hasTri;
|
|
91
|
+
}
|
|
74
92
|
function mesh(shape, {
|
|
75
93
|
tolerance = 1e-3,
|
|
76
94
|
angularTolerance = 0.1,
|
|
@@ -159,14 +177,16 @@ function exportSTL(shape, {
|
|
|
159
177
|
binary = false
|
|
160
178
|
} = {}) {
|
|
161
179
|
const oc = occtBoundary.getKernel().oc;
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
180
|
+
if (!shapeHasTriangulation(oc, shape.wrapped)) {
|
|
181
|
+
const mesher = new oc.BRepMesh_IncrementalMesh_2(
|
|
182
|
+
shape.wrapped,
|
|
183
|
+
tolerance,
|
|
184
|
+
false,
|
|
185
|
+
angularTolerance,
|
|
186
|
+
false
|
|
187
|
+
);
|
|
188
|
+
mesher.delete();
|
|
189
|
+
}
|
|
170
190
|
const filename = occtBoundary.uniqueIOFilename("_blob", "stl");
|
|
171
191
|
const done = oc.StlAPI.Write(shape.wrapped, filename, !binary);
|
|
172
192
|
if (done) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { g as getKernel, u as uniqueIOFilename } from "./occtBoundary-
|
|
1
|
+
import { g as getKernel, u as uniqueIOFilename } from "./occtBoundary-DYsksDtE.js";
|
|
2
2
|
import { l as ok, e as err, i as ioError } from "./errors-wGhcJMpB.js";
|
|
3
3
|
function buildMeshCacheKey(tolerance, angularTolerance, skipNormals) {
|
|
4
4
|
return `${tolerance}:${angularTolerance}:${skipNormals}`;
|
|
@@ -70,6 +70,24 @@ function createMeshCache() {
|
|
|
70
70
|
}
|
|
71
71
|
};
|
|
72
72
|
}
|
|
73
|
+
function shapeHasTriangulation(oc, shape) {
|
|
74
|
+
const explorer = new oc.TopExp_Explorer_2(
|
|
75
|
+
shape,
|
|
76
|
+
oc.TopAbs_ShapeEnum.TopAbs_FACE,
|
|
77
|
+
oc.TopAbs_ShapeEnum.TopAbs_SHAPE
|
|
78
|
+
);
|
|
79
|
+
let hasTri = false;
|
|
80
|
+
if (explorer.More()) {
|
|
81
|
+
const face = oc.TopoDS.Face_1(explorer.Current());
|
|
82
|
+
const loc = new oc.TopLoc_Location_1();
|
|
83
|
+
const tri = oc.BRep_Tool.Triangulation(face, loc, 0);
|
|
84
|
+
hasTri = !tri.IsNull();
|
|
85
|
+
loc.delete();
|
|
86
|
+
tri.delete();
|
|
87
|
+
}
|
|
88
|
+
explorer.delete();
|
|
89
|
+
return hasTri;
|
|
90
|
+
}
|
|
73
91
|
function mesh(shape, {
|
|
74
92
|
tolerance = 1e-3,
|
|
75
93
|
angularTolerance = 0.1,
|
|
@@ -158,14 +176,16 @@ function exportSTL(shape, {
|
|
|
158
176
|
binary = false
|
|
159
177
|
} = {}) {
|
|
160
178
|
const oc = getKernel().oc;
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
179
|
+
if (!shapeHasTriangulation(oc, shape.wrapped)) {
|
|
180
|
+
const mesher = new oc.BRepMesh_IncrementalMesh_2(
|
|
181
|
+
shape.wrapped,
|
|
182
|
+
tolerance,
|
|
183
|
+
false,
|
|
184
|
+
angularTolerance,
|
|
185
|
+
false
|
|
186
|
+
);
|
|
187
|
+
mesher.delete();
|
|
188
|
+
}
|
|
169
189
|
const filename = uniqueIOFilename("_blob", "stl");
|
|
170
190
|
const done = oc.StlAPI.Write(shape.wrapped, filename, !binary);
|
|
171
191
|
if (done) {
|