brepjs 18.82.4 → 18.82.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.
@@ -0,0 +1,300 @@
1
+ import { Z as getKernel, c as createSolid, x as isClosedWire } from "./shapeTypes-D4Evnmz_.js";
2
+ import { A as ok, b as err, d as validationError, v as andThen } from "./errors-DNWJsfVU.js";
3
+ import { t as DEG2RAD } from "./constants-ITRzCnCp.js";
4
+ import { h as translate } from "./shapeFns-B6UAiYAx.js";
5
+ import { _ as makeThreePointArc, a as makeNonPlanarFace, c as makeBSplineApproximation, d as makeCircle, f as makeEllipse, g as makeTangentArc, h as makeLine, i as makeNewFaceWithinFace, m as makeHelix, o as makePolygon, p as makeEllipseArc, r as makeFace, s as assembleWire, t as addHolesInFace, u as makeBezierCurve } from "./surfaceBuilders-CLMyFimy.js";
6
+ import { a as makeOffset, c as makeTorus, i as makeEllipsoid, l as makeVertex, n as makeCone, o as makeSolid, r as makeCylinder, s as makeSphere, t as makeCompound, u as weldShellsAndFaces } from "./solidBuilders-QUpJdbiK.js";
7
+ //#region src/topology/primitiveFns.ts
8
+ /**
9
+ * Create a box with the given dimensions.
10
+ *
11
+ * @param width - Size along X.
12
+ * @param depth - Size along Y.
13
+ * @param height - Size along Z.
14
+ */
15
+ function box(width, depth, height, options) {
16
+ const solid = createSolid(getKernel().makeBox(width, depth, height));
17
+ const center = options?.at ?? (options?.centered ? [
18
+ 0,
19
+ 0,
20
+ 0
21
+ ] : void 0);
22
+ if (center) return translate(solid, [
23
+ center[0] - width / 2,
24
+ center[1] - depth / 2,
25
+ center[2] - height / 2
26
+ ]);
27
+ return solid;
28
+ }
29
+ /**
30
+ * Create a cylinder with the given radius and height.
31
+ */
32
+ function cylinder(radius, height, options) {
33
+ const at = options?.at ?? [
34
+ 0,
35
+ 0,
36
+ 0
37
+ ];
38
+ const axis = options?.axis ?? [
39
+ 0,
40
+ 0,
41
+ 1
42
+ ];
43
+ let solid = makeCylinder(radius, height, at, axis);
44
+ if (options?.centered) {
45
+ const halfShift = [
46
+ -axis[0] * height * .5,
47
+ -axis[1] * height * .5,
48
+ -axis[2] * height * .5
49
+ ];
50
+ solid = translate(solid, halfShift);
51
+ }
52
+ return solid;
53
+ }
54
+ /**
55
+ * Create a sphere with the given radius.
56
+ */
57
+ function sphere(radius, options) {
58
+ let solid = makeSphere(radius);
59
+ if (options?.at) solid = translate(solid, options.at);
60
+ return solid;
61
+ }
62
+ /**
63
+ * Create a cone (or frustum) with the given radii and height.
64
+ *
65
+ * @param bottomRadius - Radius at the base.
66
+ * @param topRadius - Radius at the top (0 for a full cone).
67
+ * @param height - Height of the cone.
68
+ */
69
+ function cone(bottomRadius, topRadius, height, options) {
70
+ const at = options?.at ?? [
71
+ 0,
72
+ 0,
73
+ 0
74
+ ];
75
+ const axis = options?.axis ?? [
76
+ 0,
77
+ 0,
78
+ 1
79
+ ];
80
+ let solid = makeCone(bottomRadius, topRadius, height, at, axis);
81
+ if (options?.centered) {
82
+ const halfShift = [
83
+ -axis[0] * height * .5,
84
+ -axis[1] * height * .5,
85
+ -axis[2] * height * .5
86
+ ];
87
+ solid = translate(solid, halfShift);
88
+ }
89
+ return solid;
90
+ }
91
+ /**
92
+ * Create a torus with the given major and minor radii.
93
+ */
94
+ function torus(majorRadius, minorRadius, options) {
95
+ return makeTorus(majorRadius, minorRadius, options?.at ?? [
96
+ 0,
97
+ 0,
98
+ 0
99
+ ], options?.axis ?? [
100
+ 0,
101
+ 0,
102
+ 1
103
+ ]);
104
+ }
105
+ /**
106
+ * Create an ellipsoid with the given axis half-lengths.
107
+ *
108
+ * @param rx - Half-length along X.
109
+ * @param ry - Half-length along Y.
110
+ * @param rz - Half-length along Z.
111
+ */
112
+ function ellipsoid(rx, ry, rz, options) {
113
+ let solid = makeEllipsoid(rx, ry, rz);
114
+ if (options?.at) solid = translate(solid, options.at);
115
+ return solid;
116
+ }
117
+ /** Create a straight edge between two 3D points. */
118
+ function line(from, to) {
119
+ return makeLine(from, to);
120
+ }
121
+ /** Create a circular edge with the given radius. */
122
+ function circle(radius, options) {
123
+ const axisDir = options?.axis ?? [
124
+ 0,
125
+ 0,
126
+ 1
127
+ ];
128
+ return makeCircle(radius, options?.at ?? [
129
+ 0,
130
+ 0,
131
+ 0
132
+ ], axisDir);
133
+ }
134
+ /**
135
+ * Create an elliptical edge.
136
+ *
137
+ * @returns An error if `minorRadius` exceeds `majorRadius`.
138
+ */
139
+ function ellipse(majorRadius, minorRadius, options) {
140
+ const axisDir = options?.axis ?? [
141
+ 0,
142
+ 0,
143
+ 1
144
+ ];
145
+ return makeEllipse(majorRadius, minorRadius, options?.at ?? [
146
+ 0,
147
+ 0,
148
+ 0
149
+ ], axisDir, options?.xDir);
150
+ }
151
+ /**
152
+ * Create a helical wire.
153
+ *
154
+ * @param pitch - Vertical distance per full turn.
155
+ * @param height - Total height.
156
+ * @param radius - Helix radius.
157
+ */
158
+ function helix(pitch, height, radius, options) {
159
+ return makeHelix(pitch, height, radius, options?.at ?? [
160
+ 0,
161
+ 0,
162
+ 0
163
+ ], options?.axis ?? [
164
+ 0,
165
+ 0,
166
+ 1
167
+ ], options?.lefthand ?? false);
168
+ }
169
+ /** Create a circular arc edge passing through three points. */
170
+ function threePointArc(p1, p2, p3) {
171
+ return makeThreePointArc(p1, p2, p3);
172
+ }
173
+ /**
174
+ * Create an elliptical arc edge between two angles.
175
+ *
176
+ * All angles are in **degrees** (unlike the legacy `makeEllipseArc` which used radians).
177
+ *
178
+ * @param startAngle - Start angle in degrees.
179
+ * @param endAngle - End angle in degrees.
180
+ */
181
+ function ellipseArc(majorRadius, minorRadius, startAngle, endAngle, options) {
182
+ const axisDir = options?.axis ?? [
183
+ 0,
184
+ 0,
185
+ 1
186
+ ];
187
+ return makeEllipseArc(majorRadius, minorRadius, startAngle * DEG2RAD, endAngle * DEG2RAD, options?.at ?? [
188
+ 0,
189
+ 0,
190
+ 0
191
+ ], axisDir, options?.xDir);
192
+ }
193
+ /**
194
+ * Create a B-spline edge that approximates a set of 3D points.
195
+ *
196
+ * @returns An error if the approximation algorithm fails.
197
+ */
198
+ function bsplineApprox(points, config) {
199
+ return makeBSplineApproximation(points, config);
200
+ }
201
+ /**
202
+ * Create a Bezier curve edge from control points.
203
+ *
204
+ * @param points - Two or more control points.
205
+ */
206
+ function bezier(points) {
207
+ return makeBezierCurve(points);
208
+ }
209
+ /**
210
+ * Create a circular arc edge tangent to a direction at the start point.
211
+ */
212
+ function tangentArc(startPoint, startTgt, endPoint) {
213
+ return makeTangentArc(startPoint, startTgt, endPoint);
214
+ }
215
+ /**
216
+ * Assemble edges and/or wires into a single connected wire.
217
+ */
218
+ function wire(listOfEdges) {
219
+ return assembleWire(listOfEdges);
220
+ }
221
+ /**
222
+ * Assemble edges into a wire and verify it forms a closed loop.
223
+ *
224
+ * Combines {@link wire} + the `closedWire` smart constructor in a single step.
225
+ * Returns an error if the edges cannot be assembled or the wire is not closed.
226
+ *
227
+ * @example
228
+ * ```ts
229
+ * const cw = unwrap(wireLoop([e1, e2, e3, e4]));
230
+ * const f = unwrap(face(cw)); // ClosedWire accepted directly
231
+ * ```
232
+ */
233
+ function wireLoop(listOfEdges) {
234
+ return andThen(assembleWire(listOfEdges), (w) => {
235
+ if (isClosedWire(w)) return ok(w);
236
+ return err(validationError("WIRE_NOT_CLOSED", "Assembled wire is not closed: start and end points do not coincide"));
237
+ });
238
+ }
239
+ /**
240
+ * Create a planar face from a closed wire, optionally with holes.
241
+ * The resulting face is always oriented (consistent normal direction).
242
+ */
243
+ function face(w, holes) {
244
+ return makeFace(w, holes);
245
+ }
246
+ /**
247
+ * Create a non-planar face from a wire using surface filling.
248
+ * The resulting face is always oriented.
249
+ */
250
+ function filledFace(w) {
251
+ return makeNonPlanarFace(w);
252
+ }
253
+ /**
254
+ * Create a face bounded by a wire on an existing face's surface.
255
+ * The resulting face inherits orientation from the origin face.
256
+ */
257
+ function subFace(originFace, w) {
258
+ return makeNewFaceWithinFace(originFace, w);
259
+ }
260
+ /**
261
+ * Create a polygonal face from three or more coplanar points.
262
+ * The resulting face is always oriented.
263
+ */
264
+ function polygon(points) {
265
+ return makePolygon(points);
266
+ }
267
+ /** Create a vertex at a 3D point. */
268
+ function vertex(point) {
269
+ return makeVertex(point);
270
+ }
271
+ /**
272
+ * Build a compound from multiple shapes.
273
+ */
274
+ function compound(shapeArray) {
275
+ return makeCompound(shapeArray);
276
+ }
277
+ /**
278
+ * Weld faces and shells into a single solid.
279
+ * The resulting solid is always validated.
280
+ */
281
+ function solid(facesOrShells) {
282
+ return makeSolid(facesOrShells);
283
+ }
284
+ /**
285
+ * Create an offset shape from a face.
286
+ */
287
+ function offsetFace(f, distance, tolerance) {
288
+ return makeOffset(f, distance, tolerance);
289
+ }
290
+ /**
291
+ * Weld faces and shells into a single shell.
292
+ */
293
+ function sewShells(facesOrShells, ignoreType) {
294
+ return weldShellsAndFaces(facesOrShells, ignoreType);
295
+ }
296
+ function addHoles(f, holes) {
297
+ return addHolesInFace(f, holes);
298
+ }
299
+ //#endregion
300
+ export { threePointArc as C, wireLoop as D, wire as E, tangentArc as S, vertex as T, polygon as _, circle as a, sphere as b, cylinder as c, ellipsoid as d, face as f, offsetFace as g, line as h, bsplineApprox as i, ellipse as l, helix as m, bezier as n, compound as o, filledFace as p, box as r, cone as s, addHoles as t, ellipseArc as u, sewShells as v, torus as w, subFace as x, solid as y };
@@ -1,7 +1,7 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_textBlueprints = require("./textBlueprints-BjSwFtO2.cjs");
2
+ const require_textBlueprints = require("./textBlueprints-D4pLmVno.cjs");
3
3
  const require_blueprintSketcher = require("./blueprintSketcher-CFa32JZU.cjs");
4
- const require_drawFns = require("./drawFns-CmSMHb12.cjs");
4
+ const require_drawFns = require("./drawFns-DK3DGHku.cjs");
5
5
  //#region src/sketching.ts
6
6
  /**
7
7
  * brepjs/sketching — Sketcher, Drawing, and sketch-to-shape operations.
package/dist/sketching.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { n as BaseSketcher2d, t as BlueprintSketcher } from "./blueprintSketcher-CIydRzRr.js";
2
- import { A as sketchEllipse, C as DrawingPen, D as makeBaseBox, E as deserializeDrawing, F as sketchRectangle, I as sketchRoundedRectangle, L as FaceSketcher, M as sketchHelix, N as sketchParametricFunction, O as polysideInnerRadius, P as sketchPolysides, R as Sketcher, S as drawText, T as Drawing, _ as drawPolysides, a as drawingIntersect, b as drawSingleCircle, c as rotateDrawing, d as drawFaceOutline, f as drawProjection, g as drawPointsInterpolation, h as drawParametricFunction, i as drawingFuse, j as sketchFaceOffset, k as sketchCircle, l as scaleDrawing, m as drawEllipse, n as drawingCut, o as drawingToSketchOnPlane, p as drawCircle, r as drawingFillet, s as mirrorDrawing, t as drawingChamfer, u as translateDrawing, v as drawRectangle, w as draw, x as drawSingleEllipse, y as drawRoundedRectangle } from "./drawFns-DrlxFhe4.js";
3
- import { a as Sketch, c as compoundSketchLoft, d as sketchFace, f as sketchLoft, h as sketchWires, i as Sketches, l as compoundSketchRevolve, m as sketchSweep, o as compoundSketchExtrude, p as sketchRevolve, s as compoundSketchFace, u as sketchExtrude, v as CompoundSketch } from "./textBlueprints-BJ22J1c2.js";
2
+ import { A as sketchEllipse, C as DrawingPen, D as makeBaseBox, E as deserializeDrawing, F as sketchRectangle, I as sketchRoundedRectangle, L as FaceSketcher, M as sketchHelix, N as sketchParametricFunction, O as polysideInnerRadius, P as sketchPolysides, R as Sketcher, S as drawText, T as Drawing, _ as drawPolysides, a as drawingIntersect, b as drawSingleCircle, c as rotateDrawing, d as drawFaceOutline, f as drawProjection, g as drawPointsInterpolation, h as drawParametricFunction, i as drawingFuse, j as sketchFaceOffset, k as sketchCircle, l as scaleDrawing, m as drawEllipse, n as drawingCut, o as drawingToSketchOnPlane, p as drawCircle, r as drawingFillet, s as mirrorDrawing, t as drawingChamfer, u as translateDrawing, v as drawRectangle, w as draw, x as drawSingleEllipse, y as drawRoundedRectangle } from "./drawFns-C5Mdr0iH.js";
3
+ import { a as Sketch, c as compoundSketchLoft, d as sketchFace, f as sketchLoft, h as sketchWires, i as Sketches, l as compoundSketchRevolve, m as sketchSweep, o as compoundSketchExtrude, p as sketchRevolve, s as compoundSketchFace, u as sketchExtrude, v as CompoundSketch } from "./textBlueprints-f8cgx9vi.js";
4
4
  //#region src/sketching.ts
5
5
  /**
6
6
  * brepjs/sketching — Sketcher, Drawing, and sketch-to-shape operations.