@snaptrude/plugin-core 0.9.13 → 0.9.14-networks-20260930.1
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/CHANGELOG.md +39 -0
- package/dist/api/core/geom/create/index.d.ts +935 -100
- package/dist/api/core/geom/create/index.d.ts.map +1 -1
- package/dist/api/core/geom/query/brep.d.ts +59 -2
- package/dist/api/core/geom/query/brep.d.ts.map +1 -1
- package/dist/api/core/geom/query/curve.d.ts +59 -35
- package/dist/api/core/geom/query/curve.d.ts.map +1 -1
- package/dist/api/core/geom/query/edge.d.ts +2 -2
- package/dist/api/core/geom/query/face.d.ts +105 -0
- package/dist/api/core/geom/query/face.d.ts.map +1 -1
- package/dist/api/core/geom/update/contour.d.ts +2 -0
- package/dist/api/core/geom/update/contour.d.ts.map +1 -1
- package/dist/api/core/geom/update/curve.d.ts +5 -5
- package/dist/api/core/geom/update/profile.d.ts +3 -1
- package/dist/api/core/geom/update/profile.d.ts.map +1 -1
- package/dist/api/core/handles/index.d.ts +4 -2
- package/dist/api/core/handles/index.d.ts.map +1 -1
- package/dist/api/design/create/grids.d.ts +1 -1
- package/dist/api/design/family.d.ts +67 -10
- package/dist/api/design/family.d.ts.map +1 -1
- package/dist/api/design/index.d.ts +6 -0
- package/dist/api/design/index.d.ts.map +1 -1
- package/dist/api/design/networks.d.ts +530 -0
- package/dist/api/design/networks.d.ts.map +1 -0
- package/dist/api/design/query/geometry/index.d.ts +33 -5
- package/dist/api/design/query/geometry/index.d.ts.map +1 -1
- package/dist/api/design/query/grids.d.ts +3 -3
- package/dist/api/design/query/index.d.ts +47 -0
- package/dist/api/design/query/index.d.ts.map +1 -1
- package/dist/api/design/query/spaces.d.ts +5 -5
- package/dist/api/design/update/index.d.ts +99 -0
- package/dist/api/design/update/index.d.ts.map +1 -1
- package/dist/api/entity/referenceLine.d.ts +1 -1
- package/dist/api/entity/space.d.ts +4 -4
- package/dist/api/entity/story.d.ts +4 -4
- package/dist/api/presentation/aiInspiration.d.ts +5 -5
- package/dist/api/program/site.d.ts +4 -4
- package/dist/api/program/spreadsheet.d.ts +4 -4
- package/dist/handles.d.ts +13 -3
- package/dist/handles.d.ts.map +1 -1
- package/dist/index.cjs +3623 -2949
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3561 -2949
- package/dist/index.js.map +1 -1
- package/dist/massParameters.d.ts +287 -0
- package/dist/massParameters.d.ts.map +1 -0
- package/dist/massParameters.ops.d.ts +138 -0
- package/dist/massParameters.ops.d.ts.map +1 -0
- package/package.json +2 -1
- package/scripts/check-dist-fresh.mjs +22 -0
- package/src/api/core/geom/create/index.ts +1030 -101
- package/src/api/core/geom/query/brep.ts +60 -2
- package/src/api/core/geom/query/curve.ts +26 -2
- package/src/api/core/geom/query/edge.ts +2 -2
- package/src/api/core/geom/query/face.ts +109 -4
- package/src/api/core/geom/update/contour.ts +2 -0
- package/src/api/core/geom/update/profile.ts +2 -0
- package/src/api/core/handles/index.ts +3 -2
- package/src/api/design/family.ts +68 -10
- package/src/api/design/index.ts +7 -0
- package/src/api/design/networks.ts +315 -0
- package/src/api/design/query/geometry/index.ts +35 -4
- package/src/api/design/query/index.ts +50 -0
- package/src/api/design/update/index.ts +106 -0
- package/src/handles.ts +18 -3
- package/src/index.ts +2 -0
- package/src/massParameters.ops.ts +246 -0
- package/src/massParameters.ts +427 -0
- package/test/massParameters.test.mjs +952 -0
- package/api-manifest.json +0 -8371
|
@@ -1,15 +1,46 @@
|
|
|
1
1
|
import * as z from "zod"
|
|
2
2
|
import { PluginApiReturn } from "../../../../types"
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
MAX_SPLINE_THROUGH_POINTS,
|
|
5
|
+
MAX_SPLINE_POLES,
|
|
6
|
+
MAX_PATH_CURVES,
|
|
7
|
+
MAX_TWIST_LEVELS,
|
|
8
|
+
MAX_FILLET_LAW_SAMPLES,
|
|
9
|
+
} from "../../../../massParameters"
|
|
10
|
+
import type { SweepAlongCurveRecordOptions } from "../../../../massParameters"
|
|
11
|
+
import { Vec3Handle, LineHandle, ArcHandle, SplineHandle, CircleHandle, CurveHandle, ProfileHandle, ContourHandle, BrepHandle, FaceHandle, EdgeHandle, Vec3Components } from "../../../../handles"
|
|
12
|
+
|
|
13
|
+
/** Maximum boundary items one patch may span. */
|
|
14
|
+
export const MAX_PATCH_BOUNDARY_CURVES = 16
|
|
15
|
+
/** Maximum interior points one patch may be pulled through. */
|
|
16
|
+
export const MAX_PATCH_INTERIOR_POINTS = 64
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* An edge named together with the solid it belongs to — an edge handle cannot
|
|
20
|
+
* name its own solid, and one patch may meet two solids. `face` is the adjacent
|
|
21
|
+
* face a tangent patch continues: REQUIRED under `continuity: "tangent"`
|
|
22
|
+
* (a solid edge has two faces — the wall or the top of a rim — and only the
|
|
23
|
+
* caller knows which), ignored otherwise. Owner LAST, like every read that
|
|
24
|
+
* takes `(face, brep)`.
|
|
25
|
+
*/
|
|
26
|
+
export type OwnedEdge = { edge: EdgeHandle; brep: BrepHandle; face?: FaceHandle }
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* The trailing bag of {@linkcode PluginGeomCreateApi.brepFromSweepAlongCurve}:
|
|
30
|
+
* the recorded switches plus `rail`, a live curve handle that never enters a
|
|
31
|
+
* record (a record is pure JSON, and a dead handle would not regenerate).
|
|
32
|
+
*/
|
|
33
|
+
export type SweepAlongCurveOptions = SweepAlongCurveRecordOptions & { rail?: CurveHandle }
|
|
4
34
|
|
|
5
35
|
/**
|
|
6
36
|
* Curve creation — construct new geometric curves from point handles (all-handle
|
|
7
37
|
* model, §11).
|
|
8
38
|
*
|
|
9
39
|
* Each method takes point handles ({@linkcode Vec3Handle}) and returns an opaque
|
|
10
|
-
* curve handle ({@linkcode LineHandle}
|
|
11
|
-
* query, update, or entity-creation
|
|
12
|
-
* via the
|
|
40
|
+
* curve handle ({@linkcode LineHandle}, {@linkcode ArcHandle}, or
|
|
41
|
+
* {@linkcode SplineHandle}) that you pass to query, update, or entity-creation
|
|
42
|
+
* methods. Read geometry back as plain values via the
|
|
43
|
+
* `snaptrude.core.geom.query.*` methods.
|
|
13
44
|
*
|
|
14
45
|
* Accessed via `snaptrude.core.geom.create`.
|
|
15
46
|
*/
|
|
@@ -83,6 +114,97 @@ export abstract class PluginGeomCreateApi {
|
|
|
83
114
|
radius: number,
|
|
84
115
|
): PluginApiReturn<CircleHandle>
|
|
85
116
|
|
|
117
|
+
/**
|
|
118
|
+
* Create an open NURBS curve passing exactly THROUGH each point, in order
|
|
119
|
+
* (centripetal Catmull-Rom fit → clamped cubic B-spline; C1-smooth, no cusps
|
|
120
|
+
* on uneven spacing). Host API call — returns a handle. The points are
|
|
121
|
+
* interpolated, NOT control points. For a CLOSED smooth loop use
|
|
122
|
+
* {@linkcode PluginGeomCreateApi.profileFromSplinePoints} — closed splines
|
|
123
|
+
* exist only as profiles, never as a single curve handle.
|
|
124
|
+
*
|
|
125
|
+
* Pure host-side math — the geometry kernel is not loaded. The result is a
|
|
126
|
+
* {@linkcode CurveHandle}: pass it to `profileFromCurves` alongside lines and
|
|
127
|
+
* arcs, or read it back via `core.geom.query.curve.*`.
|
|
128
|
+
*
|
|
129
|
+
* @param points 3..256 ordered through-points; consecutive points must be distinct
|
|
130
|
+
* @returns The new open curve as a {@linkcode SplineHandle}
|
|
131
|
+
* @throws VALIDATION if fewer than 3 points (2 points are a straight line —
|
|
132
|
+
* use {@linkcode PluginGeomCreateApi.line}), more than 256 points, or two
|
|
133
|
+
* consecutive points coincide
|
|
134
|
+
*
|
|
135
|
+
* @examplePrompt Draw a smooth curve through these points
|
|
136
|
+
* @examplePrompt Make a wavy edge that passes through A, B, C and D
|
|
137
|
+
* @examplePrompt Freeform curved wall path through these clicks
|
|
138
|
+
*
|
|
139
|
+
* # Example
|
|
140
|
+
* ```ts
|
|
141
|
+
* const spline = await snaptrude.core.geom.create.splineFromPoints([p0, p1, p2, p3])
|
|
142
|
+
* // Mixed profile: smooth top, straight closing base
|
|
143
|
+
* const base = await snaptrude.core.geom.create.line(p3, p0)
|
|
144
|
+
* const profile = await snaptrude.core.geom.create.profileFromCurves([spline, base])
|
|
145
|
+
* ```
|
|
146
|
+
*/
|
|
147
|
+
public abstract splineFromPoints(points: Vec3Handle[]): PluginApiReturn<SplineHandle>
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Create an open NURBS curve DEFINED BY control points — the curve is pulled
|
|
151
|
+
* TOWARD the interior points, not through them; it starts at the first point
|
|
152
|
+
* and ends at the last. Knots are computed for you (clamped, uniform) —
|
|
153
|
+
* there is no knot-vector argument. For a curve that must pass THROUGH given
|
|
154
|
+
* points use {@linkcode PluginGeomCreateApi.splineFromPoints}.
|
|
155
|
+
*
|
|
156
|
+
* A curve made here records as `splinePoles` in a mass recipe and is
|
|
157
|
+
* re-minted verbatim on edit — so an agent that read a `splinePoles` curve
|
|
158
|
+
* back off a mass can move its poles and rebuild the mass with
|
|
159
|
+
* `design.update.parameters`. Pure host-side math — the geometry kernel is
|
|
160
|
+
* not loaded, and nothing is created in the scene. An edge's control points
|
|
161
|
+
* rebuild the same curve here only when its knots are clamped uniform.
|
|
162
|
+
*
|
|
163
|
+
* @param controlPoints 3..512 control points ({@linkcode Vec3Handle}s), in order
|
|
164
|
+
* @param options.degree 2 or 3; default `min(3, controlPoints.length - 1)`
|
|
165
|
+
* @returns The new open curve as a {@linkcode SplineHandle}
|
|
166
|
+
* @throws VALIDATION when fewer than `degree + 1` points are given, two
|
|
167
|
+
* consecutive points coincide, or `degree` is not 2 or 3
|
|
168
|
+
*
|
|
169
|
+
* @examplePrompt Draw a smooth curve controlled by these four points
|
|
170
|
+
*
|
|
171
|
+
* # Example
|
|
172
|
+
* ```ts
|
|
173
|
+
* const curve = await snaptrude.core.geom.create.splineFromControlPoints([p0, p1, p2, p3])
|
|
174
|
+
* // Quadratic instead of the default cubic
|
|
175
|
+
* const tighter = await snaptrude.core.geom.create.splineFromControlPoints(
|
|
176
|
+
* [p0, p1, p2, p3],
|
|
177
|
+
* { degree: 2 },
|
|
178
|
+
* )
|
|
179
|
+
* ```
|
|
180
|
+
*/
|
|
181
|
+
public abstract splineFromControlPoints(
|
|
182
|
+
controlPoints: Vec3Handle[],
|
|
183
|
+
options?: { degree?: number },
|
|
184
|
+
): PluginApiReturn<SplineHandle>
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* Drops a curve onto a face along the face's normal and returns the curves it
|
|
188
|
+
* lands on — one per connected run, empty when the curve misses the face
|
|
189
|
+
* entirely. Host API call — returns new curve handles; the inputs are
|
|
190
|
+
* read-only. No lengths are involved: the result is a curve in the same
|
|
191
|
+
* internal length units as its inputs.
|
|
192
|
+
*
|
|
193
|
+
* @param curve The curve to project
|
|
194
|
+
* @param face The face to project onto
|
|
195
|
+
* @param faceBrep The solid `face` belongs to — a face handle cannot name its
|
|
196
|
+
* own solid
|
|
197
|
+
* @returns The projected curves as {@linkcode CurveHandle}`[]`
|
|
198
|
+
* @throws VALIDATION if `face` is not a face of `faceBrep`, or the curve's
|
|
199
|
+
* midpoint lies on the face's surface (there is no drop direction there)
|
|
200
|
+
* @throws OPERATION_FAILED if the kernel could not project the curve
|
|
201
|
+
*/
|
|
202
|
+
public abstract curvesFromProjection(
|
|
203
|
+
curve: CurveHandle,
|
|
204
|
+
face: FaceHandle,
|
|
205
|
+
faceBrep: BrepHandle,
|
|
206
|
+
): PluginApiReturn<CurveHandle[]>
|
|
207
|
+
|
|
86
208
|
/**
|
|
87
209
|
* Create a closed profile from an ordered list of point handles connected by
|
|
88
210
|
* line segments (last auto-connected to first). Host API call — returns a handle.
|
|
@@ -117,8 +239,42 @@ export abstract class PluginGeomCreateApi {
|
|
|
117
239
|
public abstract profileFromCurves(curves: CurveHandle[]): PluginApiReturn<ProfileHandle>
|
|
118
240
|
|
|
119
241
|
/**
|
|
120
|
-
* Create
|
|
121
|
-
*
|
|
242
|
+
* Create a CLOSED smooth profile passing through each point, in order, with
|
|
243
|
+
* the loop closed smoothly back from the last point to the first (do NOT
|
|
244
|
+
* repeat the first point). Host API call — returns a handle. This is the
|
|
245
|
+
* closed counterpart of {@linkcode PluginGeomCreateApi.splineFromPoints} and
|
|
246
|
+
* the one-call route from points to an extrudable outline: wrap in
|
|
247
|
+
* `contourFromProfile` and extrude/loft/sweep as usual.
|
|
248
|
+
*
|
|
249
|
+
* The whole loop is smooth — this call takes no mixed straight/spline input.
|
|
250
|
+
* For a profile that is part curve and part straight, build the pieces with
|
|
251
|
+
* `splineFromPoints` + `line` and join them with
|
|
252
|
+
* {@linkcode PluginGeomCreateApi.profileFromCurves}.
|
|
253
|
+
*
|
|
254
|
+
* @param points 3..256 ordered through-points of the loop (first point NOT repeated)
|
|
255
|
+
* @returns The new closed profile as a {@linkcode ProfileHandle}
|
|
256
|
+
* @throws VALIDATION if fewer than 3 points, more than 256 points,
|
|
257
|
+
* consecutive points coincide (including last→first), or the loop
|
|
258
|
+
* self-intersects
|
|
259
|
+
*
|
|
260
|
+
* @examplePrompt Make a blob-shaped floor plate through these points
|
|
261
|
+
* @examplePrompt Organic curved outline through these corners
|
|
262
|
+
* @examplePrompt Freeform podium profile
|
|
263
|
+
*
|
|
264
|
+
* # Example
|
|
265
|
+
* ```ts
|
|
266
|
+
* const profile = await snaptrude.core.geom.create.profileFromSplinePoints([p0, p1, p2, p3, p4])
|
|
267
|
+
* const contour = await snaptrude.core.geom.create.contourFromProfile(profile)
|
|
268
|
+
* const brep = await snaptrude.core.geom.create.brepFromExtrusion(contour, { x: 0, y: 1, z: 0 }, 3)
|
|
269
|
+
* const podium = await snaptrude.design.create.massFromBrep(brep, "Podium")
|
|
270
|
+
* ```
|
|
271
|
+
*/
|
|
272
|
+
public abstract profileFromSplinePoints(points: Vec3Handle[]): PluginApiReturn<ProfileHandle>
|
|
273
|
+
|
|
274
|
+
/**
|
|
275
|
+
* Create an axis-aligned **rectangle** profile in the XZ plane,
|
|
276
|
+
* `width` × `depth`, centred at `center` (defaults to the origin). Host API
|
|
277
|
+
* call — returns a handle.
|
|
122
278
|
*
|
|
123
279
|
* Pair with `design.create.space` / `design.create.spaces` to author a rectangular
|
|
124
280
|
* (box) space — there is no dedicated rectangular-space creator; build the profile
|
|
@@ -237,15 +393,34 @@ export abstract class PluginGeomCreateApi {
|
|
|
237
393
|
*
|
|
238
394
|
* @param contour The cross-section to extrude (outer profile + optional holes)
|
|
239
395
|
* @param direction Extrusion direction as plain `{x, y, z}` components (non-zero, normalised by the host)
|
|
240
|
-
* @param amount Extrusion distance (non-zero; negative extrudes opposite to `direction`)
|
|
396
|
+
* @param amount Extrusion distance in internal length units (non-zero; negative extrudes opposite to `direction`)
|
|
397
|
+
* @param options Optional twist and taper, both about `direction` through the
|
|
398
|
+
* base contour's centroid. `twistInDegrees` — total rotation base → top in
|
|
399
|
+
* DEGREES (an angle: never scaled by the project's length unit), positive
|
|
400
|
+
* turning the top CLOCKWISE seen from the far end of `direction` looking
|
|
401
|
+
* back at the base — for the usual upward extrusion, the plan view;
|
|
402
|
+
* `topScale` — the top outline's scale, a ratio (1 = no taper); `levels` —
|
|
403
|
+
* how many sections to build through, a count (2..64; each step may turn
|
|
404
|
+
* at most 22.5°). Leave `levels` out
|
|
405
|
+
* and the host resolves one and writes it into the record, so the mass
|
|
406
|
+
* regenerates identically ever after. An extrusion without twist or
|
|
407
|
+
* taper (no `options`, or zero twist and a `topScale` of 1) is
|
|
408
|
+
* built exactly as before these options existed.
|
|
241
409
|
* @returns The new solid as a {@linkcode BrepHandle}
|
|
242
410
|
* @throws if the extrusion is degenerate (zero amount, zero direction, or a
|
|
243
|
-
* direction lying in the contour
|
|
244
|
-
* into a valid solid
|
|
411
|
+
* direction lying in the plane of the contour) or the contour cannot be
|
|
412
|
+
* extruded into a valid solid
|
|
413
|
+
* @throws VALIDATION if `twistInDegrees` is not finite or turns more than
|
|
414
|
+
* 1440°, `topScale` is not a positive finite ratio, `levels` is outside
|
|
415
|
+
* 2..64 or too few for the twist (more than 22.5° per step), a twist is
|
|
416
|
+
* asked of a `direction` that is not the contour's normal, the contour has
|
|
417
|
+
* holes under a twist or taper, or a scaled section self-intersects
|
|
245
418
|
*
|
|
246
419
|
* @examplePrompt Extrude this profile 3 metres up
|
|
247
420
|
* @examplePrompt Make a solid by extruding this outline
|
|
248
421
|
* @examplePrompt Create a cylinder from a circle profile
|
|
422
|
+
* @examplePrompt Extrude this floor plate 40m up with a 90 degree twist
|
|
423
|
+
* @examplePrompt Taper this tower to 60 percent of its footprint at the top
|
|
249
424
|
*
|
|
250
425
|
* # Example
|
|
251
426
|
* ```ts
|
|
@@ -259,6 +434,81 @@ export abstract class PluginGeomCreateApi {
|
|
|
259
434
|
contour: ContourHandle,
|
|
260
435
|
direction: Vec3Components,
|
|
261
436
|
amount: number,
|
|
437
|
+
options?: { twistInDegrees?: number; topScale?: number; levels?: number },
|
|
438
|
+
): PluginApiReturn<BrepHandle>
|
|
439
|
+
|
|
440
|
+
/**
|
|
441
|
+
* Stretches a surface across a closed loop of boundary curves and thickens it
|
|
442
|
+
* into a SOLID in one call — a roof over four curves, a canopy between two
|
|
443
|
+
* rails, a blend across a gap. `thickness` is in internal length units and is
|
|
444
|
+
* required: only solids reach the canvas, and there is no separate surface
|
|
445
|
+
* object to keep. Pass edges as `{ edge, brep, face }` with
|
|
446
|
+
* `continuity: "tangent"` to leave the named face smoothly. The result carries
|
|
447
|
+
* NO recipe (`design.query.getParameters` returns `null`) — label it when you
|
|
448
|
+
* commit it, because the label is all the provenance there is.
|
|
449
|
+
*
|
|
450
|
+
* Runs on the OpenCascade kernel (the first kernel call loads a wasm of tens
|
|
451
|
+
* of MB — expect a pause of seconds).
|
|
452
|
+
*
|
|
453
|
+
* @param boundary 3..16 items forming ONE closed loop (ends meeting within
|
|
454
|
+
* tolerance): a curve, or an edge named WITH the solid it belongs to
|
|
455
|
+
* ({@linkcode OwnedEdge}) — an edge handle cannot name its own solid, and
|
|
456
|
+
* one patch may meet two solids. Read scene breps with
|
|
457
|
+
* `design.query.geometry.getBrep(x, { frame: "world" })` so every item is in
|
|
458
|
+
* one frame.
|
|
459
|
+
* @param thickness Solid thickness in internal length units (> 0)
|
|
460
|
+
* @param options `interiorPoints` pull the surface through them (≤ 64, plain
|
|
461
|
+
* `{x, y, z}` in the same frame as the boundary). `continuity` —
|
|
462
|
+
* `"position"` (default) or `"tangent"`: every boundary item must then be an
|
|
463
|
+
* edge item that also names the `face` to continue (a solid edge has two
|
|
464
|
+
* faces — the wall or the top of a rim). `side` — `"below"` (default) or
|
|
465
|
+
* `"above"`: which side of the boundary the solid grows to.
|
|
466
|
+
* @returns The thickened patch as a new {@linkcode BrepHandle}
|
|
467
|
+
* @throws VALIDATION if the boundary is not one closed loop (the message names
|
|
468
|
+
* the gap and its size), a count cap is exceeded, `thickness` is not
|
|
469
|
+
* positive, `continuity: "tangent"` is used with a curve item or with an
|
|
470
|
+
* edge item that names no `face` (the message names the edge's two candidate
|
|
471
|
+
* faces), or a `face` is not adjacent to its `edge`
|
|
472
|
+
* @throws OPERATION_FAILED if the kernel could not fill the boundary, the
|
|
473
|
+
* filled surface misses its own boundary by more than 0.254 mm (the message
|
|
474
|
+
* carries the measured gap), or the thicken produced no solid
|
|
475
|
+
*
|
|
476
|
+
* @examplePrompt Patch a roof over these four boundary curves, 250 mm thick
|
|
477
|
+
* @examplePrompt Span a canopy between these two curved rails, 300 mm thick
|
|
478
|
+
*
|
|
479
|
+
* # Example
|
|
480
|
+
* ```ts
|
|
481
|
+
* // A roof over four curves
|
|
482
|
+
* const roof = await snaptrude.core.geom.create.brepFromPatch(
|
|
483
|
+
* [curveA, curveB, curveC, curveD],
|
|
484
|
+
* 0.984, // 250 mm
|
|
485
|
+
* )
|
|
486
|
+
* const mass = await snaptrude.design.create.massFromBrep(roof, "Roof patch")
|
|
487
|
+
* ```
|
|
488
|
+
*
|
|
489
|
+
* ```ts
|
|
490
|
+
* // A canopy between two towers' rims, leaving every wall it meets smoothly:
|
|
491
|
+
* // with `continuity: "tangent"` EVERY item is an edge naming its face.
|
|
492
|
+
* const canopy = await snaptrude.core.geom.create.brepFromPatch(
|
|
493
|
+
* [
|
|
494
|
+
* { edge: rimA, brep: towerA, face: wallA },
|
|
495
|
+
* { edge: sideA, brep: towerA, face: endA },
|
|
496
|
+
* { edge: rimB, brep: towerB, face: wallB },
|
|
497
|
+
* { edge: sideB, brep: towerB, face: endB },
|
|
498
|
+
* ],
|
|
499
|
+
* 1.181, // 300 mm
|
|
500
|
+
* { continuity: "tangent" },
|
|
501
|
+
* )
|
|
502
|
+
* ```
|
|
503
|
+
*/
|
|
504
|
+
public abstract brepFromPatch(
|
|
505
|
+
boundary: (CurveHandle | OwnedEdge)[],
|
|
506
|
+
thickness: number,
|
|
507
|
+
options?: {
|
|
508
|
+
interiorPoints?: Vec3Components[]
|
|
509
|
+
continuity?: "position" | "tangent"
|
|
510
|
+
side?: "below" | "above"
|
|
511
|
+
},
|
|
262
512
|
): PluginApiReturn<BrepHandle>
|
|
263
513
|
|
|
264
514
|
/**
|
|
@@ -274,8 +524,8 @@ export abstract class PluginGeomCreateApi {
|
|
|
274
524
|
* unchanged. A pair whose side faces would be non-planar under every
|
|
275
525
|
* correspondence still builds for hole-free straight-edged pairs — planar
|
|
276
526
|
* side quads stay quads and warped ones split into planar triangles (the
|
|
277
|
-
* triangulated
|
|
278
|
-
* auto-matching that would pair an arc with a straight edge. Matching hole
|
|
527
|
+
* triangulated fallback); arc-bearing or holed twisted pairs are rejected, as
|
|
528
|
+
* is auto-matching that would pair an arc with a straight edge. Matching hole
|
|
279
529
|
* counts are allowed in the two-section form. With intermediates the loft
|
|
280
530
|
* is a chain of ruled segments folded into one solid: sections must be
|
|
281
531
|
* planar and hole-free, ordered bottom → intermediates → top. The contours
|
|
@@ -289,7 +539,9 @@ export abstract class PluginGeomCreateApi {
|
|
|
289
539
|
* bottom — sections are auto-matched)
|
|
290
540
|
* @param intermediateContours Optional in-between cross-sections, ordered
|
|
291
541
|
* bottom to top (hole-free; edge counts may differ — every section is
|
|
292
|
-
* normalized to the largest)
|
|
542
|
+
* normalized to the largest). Any count is accepted; a loft of more
|
|
543
|
+
* than 32 sections counting the bottom and the top still builds but
|
|
544
|
+
* carries no parameter record (records are capped, calls are not)
|
|
293
545
|
* @param options Optional behavior switches. `compatibility` — `"auto"`
|
|
294
546
|
* (default) inserts vertices to match differing edge counts; `"strict"`
|
|
295
547
|
* skips normalization and throws VALIDATION when outer edge counts (or,
|
|
@@ -297,9 +549,13 @@ export abstract class PluginGeomCreateApi {
|
|
|
297
549
|
* `"auto"` (default) searches seam rotations on straight-edge sections to
|
|
298
550
|
* avoid a twist; `"authored"` keeps the authored start-vertex
|
|
299
551
|
* correspondence unchanged (a twisted correspondence then builds through
|
|
300
|
-
* the triangulated
|
|
552
|
+
* the triangulated fallback for hole-free straight-edged pairs).
|
|
301
553
|
* `{ compatibility: "strict", seamAlignment: "authored" }` reproduces
|
|
302
|
-
* pre-0.9.4 lofting exactly.
|
|
554
|
+
* pre-0.9.4 lofting exactly. `smoothing` — `"ruled"` (default) keeps the
|
|
555
|
+
* straight-sided behaviour described above; `"smooth"` lofts every
|
|
556
|
+
* section in ONE kernel pass, so the sides curve continuously through the
|
|
557
|
+
* intermediates instead of creasing at each one (a vase, a curved tower —
|
|
558
|
+
* the sections must still be planar and hole-free).
|
|
303
559
|
* @returns The new solid as a {@linkcode BrepHandle}
|
|
304
560
|
* @throws VALIDATION if the contours are coincident, their hole counts
|
|
305
561
|
* differ, any section has holes when intermediates are present
|
|
@@ -321,6 +577,7 @@ export abstract class PluginGeomCreateApi {
|
|
|
321
577
|
* @examplePrompt Loft these outlines even though their corners don't line up
|
|
322
578
|
* @examplePrompt Loft these outlines exactly as authored, corner to corner
|
|
323
579
|
* @examplePrompt Fail the loft if my sections don't have matching edge counts
|
|
580
|
+
* @examplePrompt Loft these three outlines with smoothly curving sides
|
|
324
581
|
*
|
|
325
582
|
* # Example
|
|
326
583
|
* ```ts
|
|
@@ -338,7 +595,11 @@ export abstract class PluginGeomCreateApi {
|
|
|
338
595
|
bottomContour: ContourHandle,
|
|
339
596
|
topContour: ContourHandle,
|
|
340
597
|
intermediateContours?: ContourHandle[],
|
|
341
|
-
options?: {
|
|
598
|
+
options?: {
|
|
599
|
+
compatibility?: "strict" | "auto"
|
|
600
|
+
seamAlignment?: "authored" | "auto"
|
|
601
|
+
smoothing?: "ruled" | "smooth"
|
|
602
|
+
},
|
|
342
603
|
): PluginApiReturn<BrepHandle>
|
|
343
604
|
|
|
344
605
|
/**
|
|
@@ -474,44 +735,95 @@ export abstract class PluginGeomCreateApi {
|
|
|
474
735
|
public abstract brepFromIntersection(a: BrepHandle, b: BrepHandle): PluginApiReturn<BrepHandle>
|
|
475
736
|
|
|
476
737
|
/**
|
|
477
|
-
* Rounds the given
|
|
478
|
-
*
|
|
479
|
-
*
|
|
480
|
-
*
|
|
481
|
-
*
|
|
482
|
-
*
|
|
483
|
-
*
|
|
484
|
-
*
|
|
738
|
+
* Rounds the given edges of a solid with a constant radius. Host API call —
|
|
739
|
+
* returns a new {@linkcode BrepHandle}; the input brep is read-only.
|
|
740
|
+
*
|
|
741
|
+
* Works on curved solids: edges may be straight, circular or spline, and
|
|
742
|
+
* adjacent edges (corner blends) are allowed. To pick a **rim** — the circle
|
|
743
|
+
* where a cylinder meets a flat cap — walk the edges and keep the ones whose
|
|
744
|
+
* two faces are a `cylinder` and a `plane`:
|
|
745
|
+
* `core.geom.query.brep.listEdges(brep)` → per edge
|
|
746
|
+
* `core.geom.query.edge.listFaces(edge)` → `core.geom.query.face.getSurfaceKind`
|
|
747
|
+
* on both faces. (`core.geom.query.brep.listEdgesBetween` takes two VERTEX
|
|
748
|
+
* indices — it is NOT a face-pair lookup.) For one cap's rim only, the
|
|
749
|
+
* shorter walk is: find the cap (call `getSurfaceKind` on each face from
|
|
750
|
+
* `brep.listFaces`), then `core.geom.query.face.listEdges(capFace)`.
|
|
751
|
+
*
|
|
752
|
+
* When the input brep carries a creation recipe, the result carries it too,
|
|
753
|
+
* with this operation appended to `operations`; `design.create.massFromBrep`
|
|
754
|
+
* then keeps the mass editable through `design.update.parameters`.
|
|
755
|
+
*
|
|
756
|
+
* Runs on the OpenCascade kernel (the first kernel call loads a wasm of tens
|
|
757
|
+
* of MB — expect a pause of seconds).
|
|
485
758
|
*
|
|
486
759
|
* Inspect the result via `core.geom.query.brep.*`, or commit it to the scene
|
|
487
760
|
* with `design.create.massFromBrep`.
|
|
488
761
|
*
|
|
489
762
|
* @param brep The solid whose edges to round
|
|
490
|
-
* @param edges The
|
|
491
|
-
*
|
|
763
|
+
* @param edges The edges to fillet (one or more, all on `brep`, no
|
|
764
|
+
* duplicates; more than 64 still fillets but the result carries no
|
|
765
|
+
* parameter record)
|
|
766
|
+
* @param radius Fillet radius in internal length units (positive, finite) —
|
|
767
|
+
* the radius at the START of the blend with `endRadius`; unused with
|
|
768
|
+
* `radii` (the table is the whole law — pass its first row's radius)
|
|
769
|
+
* @param options Optional VARIABLE blend, in one of two forms, each naming
|
|
770
|
+
* exactly ONE edge: the law belongs to the whole tangent chain that edge
|
|
771
|
+
* lies on, and it is measured from that edge's start. `endRadius` —
|
|
772
|
+
* the radius at the far end, in internal length units, interpolated
|
|
773
|
+
* linearly along the chain; on a closed rim it must equal `radius` (0 and
|
|
774
|
+
* 1 are the same point) — use `radii` there. `radii` — a sampled law instead:
|
|
775
|
+
* `position` is normalised ARC LENGTH along the chain (a ratio 0..1, never
|
|
776
|
+
* converted), `radius` is internal length units; 2..32 rows with strictly
|
|
777
|
+
* increasing `position`; before the first row and after the last the
|
|
778
|
+
* radius is held constant. On a closed rim 0 and 1 are the same point, so
|
|
779
|
+
* give them the same radius and put the variation in the interior rows. The two
|
|
780
|
+
* forms are mutually exclusive; without either, the fillet has one constant
|
|
781
|
+
* radius.
|
|
492
782
|
* @returns The filleted solid as a new {@linkcode BrepHandle}
|
|
493
|
-
* @throws VALIDATION if `edges` is empty, `radius` is
|
|
494
|
-
* number, an edge is not on `brep`, an edge
|
|
495
|
-
*
|
|
496
|
-
*
|
|
497
|
-
*
|
|
498
|
-
*
|
|
499
|
-
*
|
|
500
|
-
*
|
|
783
|
+
* @throws VALIDATION if `edges` is empty or holds a duplicate, `radius` is
|
|
784
|
+
* not a positive finite number, an edge is not on `brep`, or an edge has no
|
|
785
|
+
* crease to round — it is a seam of a closed face, or it lies between two
|
|
786
|
+
* patches of one smooth surface; for a variable blend, if `endRadius` and
|
|
787
|
+
* `radii` are both given, more than one edge is passed, a `radii` table is
|
|
788
|
+
* outside 2..32 rows or its positions do not strictly increase within
|
|
789
|
+
* 0..1, or the law's two ends differ on a closed rim (an `endRadius`
|
|
790
|
+
* other than `radius`, or a `radii` table whose first and last radii
|
|
791
|
+
* differ)
|
|
792
|
+
* @throws PRECONDITION_FAILED if an edge could not be located on the kernel
|
|
793
|
+
* solid after healing (select a different edge, or fillet before the
|
|
794
|
+
* operation that curved the solid), or the kernel could not blend the edge
|
|
795
|
+
* named in the message (reduce the radius or drop that edge)
|
|
796
|
+
* @throws OPERATION_FAILED if the kernel or the translation fails, or the
|
|
797
|
+
* result is non-manifold, splits into several solids, or contains a surface
|
|
798
|
+
* Snaptrude cannot represent
|
|
799
|
+
*
|
|
800
|
+
* @examplePrompt Round the rim of the column with 200 mm
|
|
801
|
+
* @examplePrompt Soften where the dome meets the wall
|
|
501
802
|
* @examplePrompt Fillet the corners of the podium with a 0.5m radius
|
|
502
803
|
* @examplePrompt Soften the vertical edges of this tower
|
|
804
|
+
* @examplePrompt Blend this edge from 200mm at one end to 600mm at the other
|
|
805
|
+
* @examplePrompt Round this rim wider at the back than at the front
|
|
503
806
|
*
|
|
504
807
|
* # Example
|
|
505
808
|
* ```ts
|
|
506
|
-
*
|
|
507
|
-
* const edges = await snaptrude.core.geom.query.brep.listEdges(
|
|
508
|
-
* const
|
|
809
|
+
* // Rim = every edge between the cylinder side and a plane cap
|
|
810
|
+
* const edges = await snaptrude.core.geom.query.brep.listEdges(column)
|
|
811
|
+
* const rim = []
|
|
812
|
+
* for (const edge of edges) {
|
|
813
|
+
* const faces = await snaptrude.core.geom.query.edge.listFaces(edge)
|
|
814
|
+
* const kinds = await Promise.all(
|
|
815
|
+
* faces.map((f) => snaptrude.core.geom.query.face.getSurfaceKind(f)),
|
|
816
|
+
* )
|
|
817
|
+
* if (kinds.includes("cylinder") && kinds.includes("plane")) rim.push(edge)
|
|
818
|
+
* }
|
|
819
|
+
* const rounded = await snaptrude.core.geom.create.brepFromFillet(column, rim, 0.787) // 200 mm
|
|
509
820
|
* ```
|
|
510
821
|
*/
|
|
511
822
|
public abstract brepFromFillet(
|
|
512
823
|
brep: BrepHandle,
|
|
513
824
|
edges: EdgeHandle[],
|
|
514
825
|
radius: number,
|
|
826
|
+
options?: { endRadius?: number; radii?: { position: number; radius: number }[] },
|
|
515
827
|
): PluginApiReturn<BrepHandle>
|
|
516
828
|
|
|
517
829
|
/**
|
|
@@ -519,6 +831,14 @@ export abstract class PluginGeomCreateApi {
|
|
|
519
831
|
* moves faces outward, negative moves them inward. Host API call — returns
|
|
520
832
|
* a new {@linkcode BrepHandle}; the input brep is read-only.
|
|
521
833
|
*
|
|
834
|
+
* Works on curved solids: a sphere offsets to a sphere, a torus to a torus,
|
|
835
|
+
* a cylinder to a cylinder. There is nothing to select — the whole solid is
|
|
836
|
+
* offset.
|
|
837
|
+
*
|
|
838
|
+
* When the input brep carries a creation recipe, the result carries it too,
|
|
839
|
+
* with this operation appended to `operations`; `design.create.massFromBrep`
|
|
840
|
+
* then keeps the mass editable through `design.update.parameters`.
|
|
841
|
+
*
|
|
522
842
|
* Runs on the OpenCascade kernel (the first kernel call loads a wasm of
|
|
523
843
|
* tens of MB — expect a pause of seconds).
|
|
524
844
|
*
|
|
@@ -530,9 +850,15 @@ export abstract class PluginGeomCreateApi {
|
|
|
530
850
|
* @returns The offset solid as a new {@linkcode BrepHandle}
|
|
531
851
|
* @throws VALIDATION if `distance` is not finite, is too small to offset
|
|
532
852
|
* anything, or an inward distance consumes the solid entirely
|
|
533
|
-
* @throws OPERATION_FAILED if the kernel
|
|
534
|
-
* result
|
|
535
|
-
*
|
|
853
|
+
* @throws OPERATION_FAILED if the kernel or the translation fails, or the
|
|
854
|
+
* result is non-manifold, splits into several solids, or contains a surface
|
|
855
|
+
* Snaptrude cannot represent (an offset free-form NURBS surface may have no
|
|
856
|
+
* exact representation — the model is left unchanged). A distance too
|
|
857
|
+
* large for the solid is reported here, with a hint asking for a smaller
|
|
858
|
+
* one. There is no per-face refusal: the whole call fails, and the error
|
|
859
|
+
* names no face
|
|
860
|
+
*
|
|
861
|
+
* @examplePrompt Thicken the torus ring by 100 mm
|
|
536
862
|
* @examplePrompt Grow this solid by 0.5m in every direction
|
|
537
863
|
* @examplePrompt Shrink this mass by 200mm
|
|
538
864
|
* @examplePrompt Offset the building envelope outward by 1m
|
|
@@ -551,6 +877,18 @@ export abstract class PluginGeomCreateApi {
|
|
|
551
877
|
* input brep is read-only. The outer surface is kept and the walls grow
|
|
552
878
|
* inward.
|
|
553
879
|
*
|
|
880
|
+
* Works on curved solids: the open faces may be spherical, cylindrical,
|
|
881
|
+
* conical, toroidal or free-form patches, not only flat ones. To open the
|
|
882
|
+
* flat base of a dome, check every face first —
|
|
883
|
+
* `core.geom.query.brep.listFaces` then
|
|
884
|
+
* `core.geom.query.face.getSurfaceKind` on each — and keep the `"plane"`
|
|
885
|
+
* one. A closed curved surface is stored as several patches (a sphere as
|
|
886
|
+
* lunes), so opening "the sphere" may mean passing several faces.
|
|
887
|
+
*
|
|
888
|
+
* When the input brep carries a creation recipe, the result carries it too,
|
|
889
|
+
* with this operation appended to `operations`; `design.create.massFromBrep`
|
|
890
|
+
* then keeps the mass editable through `design.update.parameters`.
|
|
891
|
+
*
|
|
554
892
|
* Runs on the OpenCascade kernel (the first kernel call loads a wasm of
|
|
555
893
|
* tens of MB — expect a pause of seconds).
|
|
556
894
|
*
|
|
@@ -558,24 +896,36 @@ export abstract class PluginGeomCreateApi {
|
|
|
558
896
|
* with `design.create.massFromBrep`.
|
|
559
897
|
*
|
|
560
898
|
* @param brep The solid to hollow
|
|
561
|
-
* @param openFaces The faces to remove as openings (
|
|
899
|
+
* @param openFaces The faces to remove as openings (one or more, all on
|
|
900
|
+
* `brep`, no duplicates; more than 32 still shells but the result carries
|
|
901
|
+
* no parameter record)
|
|
562
902
|
* @param thickness Wall thickness (positive, finite, smaller than half the solid's smallest span)
|
|
563
903
|
* @returns The hollowed solid as a new {@linkcode BrepHandle}
|
|
564
|
-
* @throws VALIDATION if `openFaces` is empty, a face is
|
|
565
|
-
* `thickness` is not a positive finite number, or the
|
|
566
|
-
* large (it must be smaller than half the solid's smallest
|
|
567
|
-
*
|
|
568
|
-
*
|
|
569
|
-
*
|
|
904
|
+
* @throws VALIDATION if `openFaces` is empty or holds a duplicate, a face is
|
|
905
|
+
* not on `brep`, `thickness` is not a positive finite number, or the
|
|
906
|
+
* thickness is too large (it must be smaller than half the solid's smallest
|
|
907
|
+
* span)
|
|
908
|
+
* @throws OPERATION_FAILED if the kernel or the translation fails, or the
|
|
909
|
+
* result is non-manifold, splits into several solids, or contains a surface
|
|
910
|
+
* Snaptrude cannot represent. A thickness too large for the solid is
|
|
911
|
+
* reported here, with a hint asking for one below half the smallest span.
|
|
912
|
+
* There is no per-face refusal: the whole call fails, and the error
|
|
913
|
+
* names no face
|
|
914
|
+
*
|
|
915
|
+
* @examplePrompt Hollow the dome into a 300 mm shell, open at the base
|
|
570
916
|
* @examplePrompt Hollow this mass into 200mm walls
|
|
571
917
|
* @examplePrompt Shell this form with the top face open
|
|
572
918
|
* @examplePrompt Turn this solid tower into a tube open at both ends
|
|
573
919
|
*
|
|
574
920
|
* # Example
|
|
575
921
|
* ```ts
|
|
576
|
-
*
|
|
577
|
-
* const faces = await snaptrude.core.geom.query.brep.listFaces(
|
|
578
|
-
* const
|
|
922
|
+
* // Open the dome at its flat base: the one face whose surface is a plane
|
|
923
|
+
* const faces = await snaptrude.core.geom.query.brep.listFaces(dome)
|
|
924
|
+
* const base = []
|
|
925
|
+
* for (const face of faces) {
|
|
926
|
+
* if ((await snaptrude.core.geom.query.face.getSurfaceKind(face)) === "plane") base.push(face)
|
|
927
|
+
* }
|
|
928
|
+
* const hollow = await snaptrude.core.geom.create.brepFromShell(dome, base, 1.181) // 300 mm
|
|
579
929
|
* ```
|
|
580
930
|
*/
|
|
581
931
|
public abstract brepFromShell(
|
|
@@ -625,28 +975,89 @@ export abstract class PluginGeomCreateApi {
|
|
|
625
975
|
): PluginApiReturn<BrepHandle[]>
|
|
626
976
|
|
|
627
977
|
/**
|
|
628
|
-
*
|
|
629
|
-
*
|
|
630
|
-
*
|
|
978
|
+
* Cuts a solid with a FACE of another solid — the curved twin of
|
|
979
|
+
* {@linkcode PluginGeomCreateApi.brepsFromSplit}, which cuts with a plane.
|
|
980
|
+
* Host API call — returns new {@linkcode BrepHandle}s; both inputs are
|
|
981
|
+
* read-only. BOTH breps must be in the same frame: read scene masses with
|
|
982
|
+
* `design.query.geometry.getBrep(x, { frame: "world" })` (the default is each
|
|
983
|
+
* mass's own local frame, and two masses have two). The pieces come back in
|
|
984
|
+
* DESCENDING volume order; pick the one you want with
|
|
985
|
+
* `core.geom.query.brep.getCentroid` or `getVolume` and commit it. A piece
|
|
986
|
+
* carries no recipe — label it.
|
|
987
|
+
*
|
|
988
|
+
* Runs on the OpenCascade kernel (the first kernel call loads a wasm of tens
|
|
989
|
+
* of MB — expect a pause of seconds).
|
|
990
|
+
*
|
|
991
|
+
* @param brep The solid to cut
|
|
992
|
+
* @param toolFace The cutting face, read-only
|
|
993
|
+
* @param toolBrep The solid `toolFace` belongs to — a face handle cannot name
|
|
994
|
+
* its own solid
|
|
995
|
+
* @returns The resulting pieces as {@linkcode BrepHandle}`[]`, largest first
|
|
996
|
+
* @throws VALIDATION if `toolFace` is not a face of `toolBrep`, `toolBrep` IS
|
|
997
|
+
* `brep`, or the cut produced a single part — the surface does not pass all
|
|
998
|
+
* the way through (extend it past the mass on every side, and check both
|
|
999
|
+
* breps were read in the same frame)
|
|
1000
|
+
* @throws OPERATION_FAILED if the kernel could not split the solid
|
|
1001
|
+
*
|
|
1002
|
+
* @examplePrompt Cut this mass with the curved roof surface and keep the lower part
|
|
631
1003
|
*
|
|
632
|
-
*
|
|
633
|
-
*
|
|
634
|
-
*
|
|
1004
|
+
* # Example
|
|
1005
|
+
* ```ts
|
|
1006
|
+
* const target = await snaptrude.design.query.geometry.getBrep(tower, { frame: "world" })
|
|
1007
|
+
* const tool = await snaptrude.design.query.geometry.getBrep(roof, { frame: "world" })
|
|
1008
|
+
* const [toolFace] = await snaptrude.core.geom.query.brep.listFaces(tool)
|
|
1009
|
+
* const pieces = await snaptrude.core.geom.create.brepsFromSplitByFace(target, toolFace, tool)
|
|
1010
|
+
* ```
|
|
1011
|
+
*/
|
|
1012
|
+
public abstract brepsFromSplitByFace(
|
|
1013
|
+
brep: BrepHandle,
|
|
1014
|
+
toolFace: FaceHandle,
|
|
1015
|
+
toolBrep: BrepHandle,
|
|
1016
|
+
): PluginApiReturn<BrepHandle[]>
|
|
1017
|
+
|
|
1018
|
+
/**
|
|
1019
|
+
* Bevels the given edges of a solid with a symmetric planar cut. Host API
|
|
1020
|
+
* call — returns a new {@linkcode BrepHandle}; the input brep is read-only.
|
|
1021
|
+
*
|
|
1022
|
+
* Works on curved solids: edges may be straight, circular or spline, and
|
|
1023
|
+
* adjacent edges are allowed. Pick edges the same way as for
|
|
1024
|
+
* {@linkcode PluginGeomCreateApi.brepFromFillet} — `brep.listEdges`, then
|
|
1025
|
+
* `core.geom.query.edge.listFaces` and `core.geom.query.face.getSurfaceKind`
|
|
1026
|
+
* on both faces of each edge. (`core.geom.query.brep.listEdgesBetween` takes
|
|
1027
|
+
* two VERTEX indices — it is NOT a face-pair lookup.) Chamfering a cylinder's
|
|
1028
|
+
* rim yields a cone patch where a fillet would yield a torus patch.
|
|
1029
|
+
*
|
|
1030
|
+
* When the input brep carries a creation recipe, the result carries it too,
|
|
1031
|
+
* with this operation appended to `operations`; `design.create.massFromBrep`
|
|
1032
|
+
* then keeps the mass editable through `design.update.parameters`.
|
|
1033
|
+
*
|
|
1034
|
+
* Runs on the OpenCascade kernel (the first kernel call loads a wasm of tens
|
|
1035
|
+
* of MB — expect a pause of seconds).
|
|
635
1036
|
*
|
|
636
1037
|
* Inspect the result via `core.geom.query.brep.*`, or commit it to the scene
|
|
637
1038
|
* with `design.create.massFromBrep`.
|
|
638
1039
|
*
|
|
639
1040
|
* @param brep The solid whose edges to bevel
|
|
640
|
-
* @param edges The
|
|
1041
|
+
* @param edges The edges to chamfer (one or more, all on `brep`, no
|
|
1042
|
+
* duplicates; more than 64 still chamfers but the result carries no
|
|
1043
|
+
* parameter record)
|
|
641
1044
|
* @param distance Chamfer distance from the edge on each adjacent face (positive, finite)
|
|
642
1045
|
* @returns The chamfered solid as a new {@linkcode BrepHandle}
|
|
643
|
-
* @throws VALIDATION if `edges` is empty, `distance` is
|
|
644
|
-
* finite number, an edge is not on `brep`, an edge
|
|
645
|
-
*
|
|
646
|
-
*
|
|
647
|
-
* @throws
|
|
648
|
-
*
|
|
649
|
-
*
|
|
1046
|
+
* @throws VALIDATION if `edges` is empty or holds a duplicate, `distance` is
|
|
1047
|
+
* not a positive finite number, an edge is not on `brep`, or an edge has no
|
|
1048
|
+
* crease to cut — it is a seam of a closed face, or it lies between two
|
|
1049
|
+
* patches of one smooth surface
|
|
1050
|
+
* @throws PRECONDITION_FAILED if an edge could not be located on the kernel
|
|
1051
|
+
* solid after healing (select a different edge, or chamfer before the
|
|
1052
|
+
* operation that curved the solid)
|
|
1053
|
+
* @throws OPERATION_FAILED if the kernel or the translation fails, or the
|
|
1054
|
+
* result is non-manifold, splits into several solids, or contains a surface
|
|
1055
|
+
* Snaptrude cannot represent. A distance larger than an adjacent face
|
|
1056
|
+
* is reported here, with a hint asking for a smaller one. Unlike
|
|
1057
|
+
* {@linkcode PluginGeomCreateApi.brepFromFillet}, the kernel does not say
|
|
1058
|
+
* which edge failed a chamfer, so the error names no edge
|
|
1059
|
+
*
|
|
1060
|
+
* @examplePrompt Chamfer the top edge of the cylinder
|
|
650
1061
|
* @examplePrompt Bevel these edges by 100mm
|
|
651
1062
|
* @examplePrompt Chamfer the top edges of the plinth
|
|
652
1063
|
* @examplePrompt Cut a 45-degree flat along the corners of this mass
|
|
@@ -682,11 +1093,16 @@ export abstract class PluginGeomCreateApi {
|
|
|
682
1093
|
* tapering across a bend or along an arc edge would create faces Snaptrude
|
|
683
1094
|
* cannot represent and throws (sweep each straight run separately and union
|
|
684
1095
|
* the results instead). An optional `transition` picks the corner
|
|
685
|
-
* treatment: `"miter"` (default) is
|
|
1096
|
+
* treatment: `"miter"` (default) is a sharp mitred bend; `"round"`
|
|
1097
|
+
* carries the section around each turning corner on a tangent circular arc,
|
|
1098
|
+
* so the corner patch is a real curved surface (geometrically cylindrical;
|
|
1099
|
+
* `getSurfaceKind` reports it as `"spline"`) rather than a
|
|
1100
|
+
* flat cut (open paths only — `"round"` on a closed ring path is refused);
|
|
686
1101
|
* `{ bevel: b }` chamfers each turning corner by cutting `b` back along
|
|
687
1102
|
* both adjacent legs (works on open and closed paths — each leg must be
|
|
688
|
-
* long enough for its cuts). On a corner-less path `transition` has no
|
|
689
|
-
* varying
|
|
1103
|
+
* long enough for its cuts). On a corner-less path `transition` has no
|
|
1104
|
+
* effect, and a varying scale only accepts straight paths, so it never meets
|
|
1105
|
+
* a corner.
|
|
690
1106
|
*
|
|
691
1107
|
* Open paths run on the OpenCascade kernel (the first kernel call loads a
|
|
692
1108
|
* wasm of tens of MB — expect a pause of seconds); closed paths are
|
|
@@ -696,19 +1112,22 @@ export abstract class PluginGeomCreateApi {
|
|
|
696
1112
|
* with `design.create.massFromBrep`.
|
|
697
1113
|
*
|
|
698
1114
|
* @param profile The cross-section to sweep (hole-free contour)
|
|
699
|
-
* @param path The polyline path as plain `{x, y, z}` points (
|
|
700
|
-
* first point as the last to close the path into a ring
|
|
1115
|
+
* @param path The polyline path as plain `{x, y, z}` points (2 or more;
|
|
1116
|
+
* repeat the first point as the last to close the path into a ring; more
|
|
1117
|
+
* than 512 points still sweeps but the result carries no parameter record)
|
|
701
1118
|
* @param options Optional scale law and corner transition. Scale law:
|
|
702
1119
|
* `startScale`/`endScale` (linear taper by arc length) or `scales` (one
|
|
703
1120
|
* factor per path point; mutually exclusive with
|
|
704
1121
|
* `startScale`/`endScale`); every factor must be finite and within
|
|
705
|
-
* 1e-3..1e3. `transition`: `"miter"` (default, sharp corners)
|
|
706
|
-
* `
|
|
707
|
-
*
|
|
1122
|
+
* 1e-3..1e3. `transition`: `"miter"` (default, sharp corners),
|
|
1123
|
+
* `"round"` (arc-carried corners — curved corner patches; open paths
|
|
1124
|
+
* only) or `{ bevel: b }` (chamfered corners, `b` finite within
|
|
1125
|
+
* 1e-3..1e3; open and closed paths)
|
|
708
1126
|
* @returns The swept solid as a new {@linkcode BrepHandle}
|
|
709
1127
|
* @throws VALIDATION if the profile has holes, the path has fewer than 2
|
|
710
|
-
* points, consecutive path points coincide, a
|
|
711
|
-
* or the profile plane contains the first
|
|
1128
|
+
* points, consecutive path points coincide, a
|
|
1129
|
+
* coordinate is not finite, or the profile plane contains the first
|
|
1130
|
+
* path segment's direction
|
|
712
1131
|
* (degenerate sweep); for closed paths, if the ring has fewer than 3
|
|
713
1132
|
* distinct corners, the path is non-planar, a corner doubles back, the
|
|
714
1133
|
* profile has an arc edge, or the profile is too large for a mitred
|
|
@@ -716,11 +1135,14 @@ export abstract class PluginGeomCreateApi {
|
|
|
716
1135
|
* is combined with `startScale`/`endScale`, `scales` does not match the
|
|
717
1136
|
* path length, or a varying scale is used on a bent or closed path or
|
|
718
1137
|
* with an arc-edged profile; for `{ bevel }`, if a leg is too short for
|
|
719
|
-
* the cuts its
|
|
720
|
-
* back so its
|
|
1138
|
+
* the cuts its bevelled corners take from it or a corner nearly doubles
|
|
1139
|
+
* back so its bevel collapses (the errors name the corner)
|
|
1140
|
+
* @throws PRECONDITION_FAILED if `transition` is `"round"` and the path is
|
|
1141
|
+
* closed — round corners work on open paths only; use `"miter"` or
|
|
1142
|
+
* `{ bevel }` on a ring
|
|
721
1143
|
* @throws OPERATION_FAILED if the kernel cannot sweep the profile into a
|
|
722
|
-
* valid solid
|
|
723
|
-
*
|
|
1144
|
+
* valid solid — including a `"round"` corner whose arc does not fit its
|
|
1145
|
+
* legs, which is not pre-checked and so is not named per corner
|
|
724
1146
|
*
|
|
725
1147
|
* @examplePrompt Sweep this profile along the corridor path
|
|
726
1148
|
* @examplePrompt Extrude the railing section along this route
|
|
@@ -729,6 +1151,7 @@ export abstract class PluginGeomCreateApi {
|
|
|
729
1151
|
* @examplePrompt Taper this duct from 1x1 to 2x2 along its run
|
|
730
1152
|
* @examplePrompt Sweep a column section that narrows toward the top
|
|
731
1153
|
* @examplePrompt Chamfer the corners of this swept frame by 200mm
|
|
1154
|
+
* @examplePrompt Sweep this handrail with rounded corners at the bends
|
|
732
1155
|
*
|
|
733
1156
|
* # Example
|
|
734
1157
|
* ```ts
|
|
@@ -767,17 +1190,76 @@ export abstract class PluginGeomCreateApi {
|
|
|
767
1190
|
startScale?: number
|
|
768
1191
|
endScale?: number
|
|
769
1192
|
scales?: number[]
|
|
770
|
-
transition?: "miter" | { bevel: number }
|
|
1193
|
+
transition?: "miter" | "round" | { bevel: number }
|
|
771
1194
|
},
|
|
772
1195
|
): PluginApiReturn<BrepHandle>
|
|
773
1196
|
|
|
1197
|
+
/**
|
|
1198
|
+
* Sweeps a cross-section along a SMOOTH path — splines, arcs and lines chained
|
|
1199
|
+
* end to end — with control of how the profile turns.
|
|
1200
|
+
* {@linkcode PluginGeomCreateApi.brepFromSweep} takes a polyline path; this
|
|
1201
|
+
* takes curves. Host API call — returns a new {@linkcode BrepHandle}; the
|
|
1202
|
+
* inputs are read-only. Records as `sweepAlongCurve`, so the orientation stays
|
|
1203
|
+
* editable through `design.update.parameters`. The properties panel shows it
|
|
1204
|
+
* read-only, because it is a text value, not a number. A railed sweep records
|
|
1205
|
+
* nothing (`getParameters` answers `null`).
|
|
1206
|
+
*
|
|
1207
|
+
* Runs on the OpenCascade kernel (the first kernel call loads a wasm of tens
|
|
1208
|
+
* of MB — expect a pause of seconds).
|
|
1209
|
+
*
|
|
1210
|
+
* @param profile Hole-free cross-section contour; placed at the first curve's start
|
|
1211
|
+
* @param path 1..64 curves, ordered, meeting end to end within tolerance
|
|
1212
|
+
* @param options `orientation` — `"upright"` (default) keeps the profile's up
|
|
1213
|
+
* aligned with world up (ducts, handrails, ribbons that must not roll);
|
|
1214
|
+
* `"frenet"` lets it roll with the path's curvature; `"fixed"` carries the
|
|
1215
|
+
* authored frame along unchanged, which is a pure translation — use it to
|
|
1216
|
+
* bend a footprint along an arc. `rail` is a second guide curve.
|
|
1217
|
+
* @returns The swept solid as a new {@linkcode BrepHandle}
|
|
1218
|
+
* @throws VALIDATION if the path curves are not connected, the path is closed,
|
|
1219
|
+
* the profile has holes, the first tangent lies in the profile plane, the
|
|
1220
|
+
* path runs vertically under `"upright"` (that frame is undefined there —
|
|
1221
|
+
* the message names the run and points at `"frenet"`), the path turns
|
|
1222
|
+
* parallel to the profile under `"fixed"`, `rail` is closed, or `rail` and
|
|
1223
|
+
* `orientation` are both given
|
|
1224
|
+
* @throws OPERATION_FAILED if the kernel could not sweep the profile — a
|
|
1225
|
+
* self-intersection on a tight bend
|
|
1226
|
+
*
|
|
1227
|
+
* @examplePrompt Sweep a 600x400 duct along this curved route and keep it upright
|
|
1228
|
+
* @examplePrompt Run this handrail along the curved stair edge
|
|
1229
|
+
* @examplePrompt Bend this footprint along the arc
|
|
1230
|
+
*
|
|
1231
|
+
* # Example
|
|
1232
|
+
* ```ts
|
|
1233
|
+
* const route = await snaptrude.core.geom.create.splineFromPoints(points)
|
|
1234
|
+
* const duct = await snaptrude.core.geom.create.brepFromSweepAlongCurve(profile, [route], {
|
|
1235
|
+
* orientation: "upright",
|
|
1236
|
+
* })
|
|
1237
|
+
* ```
|
|
1238
|
+
*/
|
|
1239
|
+
public abstract brepFromSweepAlongCurve(
|
|
1240
|
+
profile: ContourHandle,
|
|
1241
|
+
path: CurveHandle[],
|
|
1242
|
+
options?: SweepAlongCurveOptions,
|
|
1243
|
+
): PluginApiReturn<BrepHandle>
|
|
1244
|
+
|
|
774
1245
|
/**
|
|
775
1246
|
* Revolves a planar profile about an axis to make a solid of revolution — a
|
|
776
1247
|
* full turn by default. Host API call — returns a new
|
|
777
1248
|
* {@linkcode BrepHandle}; the input contour is read-only. Holes in the
|
|
778
|
-
* profile are allowed
|
|
779
|
-
*
|
|
780
|
-
*
|
|
1249
|
+
* profile are allowed, and segments may run at any angle to the axis: an
|
|
1250
|
+
* inclined segment revolves into a cone, an arc into a sphere or torus
|
|
1251
|
+
* section. This is the general route to domes, vases, columns and rotundas.
|
|
1252
|
+
*
|
|
1253
|
+
* Two rules bind the axis to the profile. First, the axis line must lie IN
|
|
1254
|
+
* the profile's plane or run parallel to it — a revolution turns a planar
|
|
1255
|
+
* section about a line drawn in that same plane; a parallel axis offset out
|
|
1256
|
+
* of the plane is judged by its projection into the plane (the result is a
|
|
1257
|
+
* hollow ring). A skew axis is refused: move the axis into the profile's
|
|
1258
|
+
* plane. Second, within that plane the whole profile stays on ONE side of
|
|
1259
|
+
* the axis.
|
|
1260
|
+
* Vertices and whole segments may lie ON the axis — that is how a dome's
|
|
1261
|
+
* pole and a cylinder's inner edge are authored — but no part of the profile
|
|
1262
|
+
* may cross to the other side, which would sweep a self-intersecting solid.
|
|
781
1263
|
*
|
|
782
1264
|
* Runs on the OpenCascade kernel (the first kernel call loads a wasm of
|
|
783
1265
|
* tens of MB — expect a pause of seconds).
|
|
@@ -791,19 +1273,25 @@ export abstract class PluginGeomCreateApi {
|
|
|
791
1273
|
* @param angleInDegrees Optional revolution angle in degrees (0 < angle ≤ 360; default 360)
|
|
792
1274
|
* @returns The revolved solid as a new {@linkcode BrepHandle}
|
|
793
1275
|
* @throws VALIDATION if `axisDirection` is zero-length, `angleInDegrees` is
|
|
794
|
-
* not in (0, 360],
|
|
795
|
-
*
|
|
796
|
-
*
|
|
797
|
-
*
|
|
798
|
-
*
|
|
1276
|
+
* not in (0, 360], a coordinate is not finite, or the profile crosses the
|
|
1277
|
+
* axis (the message names the offending segment — keep the whole profile
|
|
1278
|
+
* on one side; points may touch the axis but not cross it)
|
|
1279
|
+
* @throws PRECONDITION_FAILED if the axis is skew to the profile's plane
|
|
1280
|
+
* (neither in it nor parallel to it; the message asks you to move the axis
|
|
1281
|
+
* into the plane of the profile)
|
|
1282
|
+
* @throws OPERATION_FAILED if the kernel cannot revolve the profile into a
|
|
1283
|
+
* valid solid
|
|
799
1284
|
*
|
|
800
1285
|
* @examplePrompt Create a dome from this section
|
|
801
1286
|
* @examplePrompt Revolve this profile 360 degrees around the vertical axis
|
|
802
1287
|
* @examplePrompt Build a rotunda by revolving this wall section
|
|
1288
|
+
* @examplePrompt Make a dome by revolving a quarter-circle about the vertical axis
|
|
1289
|
+
* @examplePrompt Turn this curved outline into a vase
|
|
803
1290
|
*
|
|
804
1291
|
* # Example
|
|
805
1292
|
* ```ts
|
|
806
|
-
* // A cylinder: revolve a 2m-wide, 3m-tall rectangle about the Y axis at
|
|
1293
|
+
* // A cylinder: revolve a 2m-wide, 3m-tall rectangle about the Y axis at
|
|
1294
|
+
* // its edge — the left edge sits ON the axis, which is legal.
|
|
807
1295
|
* const rect = await snaptrude.core.geom.create.profileFromLinePoints([
|
|
808
1296
|
* await snaptrude.core.math.vec3.new(0, 0, 0),
|
|
809
1297
|
* await snaptrude.core.math.vec3.new(2, 0, 0),
|
|
@@ -824,6 +1312,159 @@ export abstract class PluginGeomCreateApi {
|
|
|
824
1312
|
axisDirection: Vec3Components,
|
|
825
1313
|
angleInDegrees?: number,
|
|
826
1314
|
): PluginApiReturn<BrepHandle>
|
|
1315
|
+
|
|
1316
|
+
/**
|
|
1317
|
+
* Create a solid **sphere** B-rep (boundary representation: the solid's
|
|
1318
|
+
* exact faces, edges and vertices) from a centre and radius. Host API call
|
|
1319
|
+
* — returns a {@linkcode BrepHandle}; commit it to the scene with
|
|
1320
|
+
* `design.create.massFromBrep`. The result carries an exact spherical
|
|
1321
|
+
* surface (not a faceted approximation) and a creation recipe — read the
|
|
1322
|
+
* committed mass's parameters back with `design.query.getParameters` and edit
|
|
1323
|
+
* them with `design.update.parameters`.
|
|
1324
|
+
*
|
|
1325
|
+
* Runs on the OpenCascade kernel (the first kernel call loads a wasm of tens
|
|
1326
|
+
* of MB — expect a pause of seconds).
|
|
1327
|
+
*
|
|
1328
|
+
* @param centre Sphere centre as plain `{x, y, z}` components (internal length units)
|
|
1329
|
+
* @param radius Sphere radius (> 0, internal length units)
|
|
1330
|
+
* @returns The new solid as a {@linkcode BrepHandle}
|
|
1331
|
+
* @throws VALIDATION if `radius` is not a positive finite number or a
|
|
1332
|
+
* coordinate is not finite
|
|
1333
|
+
*
|
|
1334
|
+
* @examplePrompt Create a sphere of radius 5 at the origin
|
|
1335
|
+
* @examplePrompt Add a 3m ball on top of the tower
|
|
1336
|
+
*
|
|
1337
|
+
* # Example
|
|
1338
|
+
* ```ts
|
|
1339
|
+
* const brep = await snaptrude.core.geom.create.brepFromSphere({ x: 0, y: 5, z: 0 }, 5)
|
|
1340
|
+
* const mass = await snaptrude.design.create.massFromBrep(brep, "Sphere")
|
|
1341
|
+
* ```
|
|
1342
|
+
*/
|
|
1343
|
+
public abstract brepFromSphere(
|
|
1344
|
+
centre: Vec3Components,
|
|
1345
|
+
radius: number,
|
|
1346
|
+
): PluginApiReturn<BrepHandle>
|
|
1347
|
+
|
|
1348
|
+
/**
|
|
1349
|
+
* Create a solid **cylinder** B-rep from its bottom-cap centre, axis
|
|
1350
|
+
* direction, radius and height. Host API call — returns a
|
|
1351
|
+
* {@linkcode BrepHandle}; commit with `design.create.massFromBrep`. The
|
|
1352
|
+
* bottom cap sits AT `base` and the solid extends `height` along `axis` —
|
|
1353
|
+
* place `base` on the floor and use axis `{x: 0, y: 1, z: 0}` for an upright
|
|
1354
|
+
* column. Carries a creation recipe (radius, height), editable through
|
|
1355
|
+
* `design.update.parameters`.
|
|
1356
|
+
*
|
|
1357
|
+
* Runs on the OpenCascade kernel (the first kernel call loads a wasm of tens
|
|
1358
|
+
* of MB — expect a pause of seconds).
|
|
1359
|
+
*
|
|
1360
|
+
* @param base Centre of the bottom cap as plain `{x, y, z}` components
|
|
1361
|
+
* @param axis Axis direction as plain `{x, y, z}` components (non-zero, normalised by the host)
|
|
1362
|
+
* @param radius Cylinder radius (> 0)
|
|
1363
|
+
* @param height Cylinder height along `axis` (> 0)
|
|
1364
|
+
* @returns The new solid as a {@linkcode BrepHandle}
|
|
1365
|
+
* @throws VALIDATION if `radius`/`height` are not positive finite numbers or
|
|
1366
|
+
* `axis` is zero-length
|
|
1367
|
+
*
|
|
1368
|
+
* @examplePrompt Create a cylinder 2m across and 4m tall
|
|
1369
|
+
* @examplePrompt Add a circular column here
|
|
1370
|
+
*
|
|
1371
|
+
* # Example
|
|
1372
|
+
* ```ts
|
|
1373
|
+
* const brep = await snaptrude.core.geom.create.brepFromCylinder(
|
|
1374
|
+
* { x: 0, y: 0, z: 0 },
|
|
1375
|
+
* { x: 0, y: 1, z: 0 },
|
|
1376
|
+
* 1,
|
|
1377
|
+
* 4,
|
|
1378
|
+
* )
|
|
1379
|
+
* const column = await snaptrude.design.create.massFromBrep(brep, "Column")
|
|
1380
|
+
* ```
|
|
1381
|
+
*/
|
|
1382
|
+
public abstract brepFromCylinder(
|
|
1383
|
+
base: Vec3Components,
|
|
1384
|
+
axis: Vec3Components,
|
|
1385
|
+
radius: number,
|
|
1386
|
+
height: number,
|
|
1387
|
+
): PluginApiReturn<BrepHandle>
|
|
1388
|
+
|
|
1389
|
+
/**
|
|
1390
|
+
* Create a solid **cone or frustum** B-rep: bottom-cap centre, axis, base
|
|
1391
|
+
* radius, height, and an optional top radius (default 0 — a full cone to a
|
|
1392
|
+
* point; > 0 — a frustum / tapered column). Host API call — returns a
|
|
1393
|
+
* {@linkcode BrepHandle}; commit with `design.create.massFromBrep`. Carries
|
|
1394
|
+
* a creation recipe (radii + height), editable through `design.update.parameters`.
|
|
1395
|
+
*
|
|
1396
|
+
* Runs on the OpenCascade kernel (the first kernel call loads a wasm of tens
|
|
1397
|
+
* of MB — expect a pause of seconds).
|
|
1398
|
+
*
|
|
1399
|
+
* @param base Centre of the bottom cap as plain `{x, y, z}` components
|
|
1400
|
+
* @param axis Axis direction as plain `{x, y, z}` components (non-zero, normalised by the host)
|
|
1401
|
+
* @param baseRadius Radius at the base (> 0)
|
|
1402
|
+
* @param height Height along `axis` (> 0)
|
|
1403
|
+
* @param topRadius Optional radius at the top (≥ 0, ≠ `baseRadius`; default 0 = apex)
|
|
1404
|
+
* @returns The new solid as a {@linkcode BrepHandle}
|
|
1405
|
+
* @throws VALIDATION if radii/height are invalid, `topRadius === baseRadius`
|
|
1406
|
+
* (that is a cylinder — use {@linkcode PluginGeomCreateApi.brepFromCylinder}),
|
|
1407
|
+
* or `axis` is zero-length
|
|
1408
|
+
*
|
|
1409
|
+
* @examplePrompt Create a cone roof 4m wide and 3m tall
|
|
1410
|
+
* @examplePrompt Make a tapered column narrowing from 1m to 0.6m
|
|
1411
|
+
*
|
|
1412
|
+
* # Example
|
|
1413
|
+
* ```ts
|
|
1414
|
+
* const roof = await snaptrude.core.geom.create.brepFromCone(
|
|
1415
|
+
* { x: 0, y: 9, z: 0 },
|
|
1416
|
+
* { x: 0, y: 1, z: 0 },
|
|
1417
|
+
* 2,
|
|
1418
|
+
* 3,
|
|
1419
|
+
* )
|
|
1420
|
+
* ```
|
|
1421
|
+
*/
|
|
1422
|
+
public abstract brepFromCone(
|
|
1423
|
+
base: Vec3Components,
|
|
1424
|
+
axis: Vec3Components,
|
|
1425
|
+
baseRadius: number,
|
|
1426
|
+
height: number,
|
|
1427
|
+
topRadius?: number,
|
|
1428
|
+
): PluginApiReturn<BrepHandle>
|
|
1429
|
+
|
|
1430
|
+
/**
|
|
1431
|
+
* Create a solid **torus** (ring / donut) B-rep from its centre, plane
|
|
1432
|
+
* normal, ring radius and tube radius. Host API call — returns a
|
|
1433
|
+
* {@linkcode BrepHandle}; commit with `design.create.massFromBrep`.
|
|
1434
|
+
* `majorRadius` is centre-to-tube-centre; `minorRadius` is the tube's own
|
|
1435
|
+
* radius and must be strictly smaller. Carries a creation recipe, editable
|
|
1436
|
+
* through `design.update.parameters`.
|
|
1437
|
+
*
|
|
1438
|
+
* Runs on the OpenCascade kernel (the first kernel call loads a wasm of tens
|
|
1439
|
+
* of MB — expect a pause of seconds).
|
|
1440
|
+
*
|
|
1441
|
+
* @param centre Torus centre as plain `{x, y, z}` components
|
|
1442
|
+
* @param axis Plane normal of the ring as plain `{x, y, z}` components (non-zero)
|
|
1443
|
+
* @param majorRadius Ring radius, centre to tube centre (> 0)
|
|
1444
|
+
* @param minorRadius Tube radius (> 0 and < `majorRadius` — a self-intersecting torus is rejected)
|
|
1445
|
+
* @returns The new solid as a {@linkcode BrepHandle}
|
|
1446
|
+
* @throws VALIDATION if a radius is invalid, `minorRadius >= majorRadius`,
|
|
1447
|
+
* or `axis` is zero-length
|
|
1448
|
+
*
|
|
1449
|
+
* @examplePrompt Create a donut-shaped ring 10m across with a 1m tube
|
|
1450
|
+
* @examplePrompt Add a torus canopy around the tower
|
|
1451
|
+
*
|
|
1452
|
+
* # Example
|
|
1453
|
+
* ```ts
|
|
1454
|
+
* const ring = await snaptrude.core.geom.create.brepFromTorus(
|
|
1455
|
+
* { x: 0, y: 6, z: 0 },
|
|
1456
|
+
* { x: 0, y: 1, z: 0 },
|
|
1457
|
+
* 5,
|
|
1458
|
+
* 1,
|
|
1459
|
+
* )
|
|
1460
|
+
* ```
|
|
1461
|
+
*/
|
|
1462
|
+
public abstract brepFromTorus(
|
|
1463
|
+
centre: Vec3Components,
|
|
1464
|
+
axis: Vec3Components,
|
|
1465
|
+
majorRadius: number,
|
|
1466
|
+
minorRadius: number,
|
|
1467
|
+
): PluginApiReturn<BrepHandle>
|
|
827
1468
|
}
|
|
828
1469
|
|
|
829
1470
|
/**
|
|
@@ -877,6 +1518,38 @@ export const PluginGeomCreateCircleArgs = z.object({
|
|
|
877
1518
|
|
|
878
1519
|
export type PluginGeomCreateCircleArgs = z.infer<typeof PluginGeomCreateCircleArgs>
|
|
879
1520
|
|
|
1521
|
+
/**
|
|
1522
|
+
* Arguments for {@linkcode PluginGeomCreateApi.splineFromPoints}.
|
|
1523
|
+
*
|
|
1524
|
+
* | Property | Type | Description |
|
|
1525
|
+
* |---|---|---|
|
|
1526
|
+
* | `points` | {@linkcode Vec3Handle}`[]` | 3..256 ordered through-points of the curve |
|
|
1527
|
+
*/
|
|
1528
|
+
export const PluginGeomCreateSplineFromPointsArgs = z.object({
|
|
1529
|
+
points: z.array(Vec3Handle).min(3).max(MAX_SPLINE_THROUGH_POINTS),
|
|
1530
|
+
})
|
|
1531
|
+
|
|
1532
|
+
export type PluginGeomCreateSplineFromPointsArgs = z.infer<
|
|
1533
|
+
typeof PluginGeomCreateSplineFromPointsArgs
|
|
1534
|
+
>
|
|
1535
|
+
|
|
1536
|
+
/**
|
|
1537
|
+
* Arguments for {@linkcode PluginGeomCreateApi.splineFromControlPoints}.
|
|
1538
|
+
*
|
|
1539
|
+
* | Property | Type | Description |
|
|
1540
|
+
* |---|---|---|
|
|
1541
|
+
* | `controlPoints` | {@linkcode Vec3Handle}`[]` | 3..512 control points of the curve, in order |
|
|
1542
|
+
* | `options` | `object`? | `degree`: 2 or 3 (default `min(3, controlPoints.length - 1)`) |
|
|
1543
|
+
*/
|
|
1544
|
+
export const PluginGeomCreateSplineFromControlPointsArgs = z.object({
|
|
1545
|
+
controlPoints: z.array(Vec3Handle).min(3).max(MAX_SPLINE_POLES),
|
|
1546
|
+
options: z.object({ degree: z.number().int().min(2).max(3).optional() }).optional(),
|
|
1547
|
+
})
|
|
1548
|
+
|
|
1549
|
+
export type PluginGeomCreateSplineFromControlPointsArgs = z.infer<
|
|
1550
|
+
typeof PluginGeomCreateSplineFromControlPointsArgs
|
|
1551
|
+
>
|
|
1552
|
+
|
|
880
1553
|
/**
|
|
881
1554
|
* Arguments for {@linkcode PluginGeomCreateApi.profileFromLinePoints}.
|
|
882
1555
|
*
|
|
@@ -907,6 +1580,21 @@ export type PluginGeomCreateProfileFromCurvesArgs = z.infer<
|
|
|
907
1580
|
typeof PluginGeomCreateProfileFromCurvesArgs
|
|
908
1581
|
>
|
|
909
1582
|
|
|
1583
|
+
/**
|
|
1584
|
+
* Arguments for {@linkcode PluginGeomCreateApi.profileFromSplinePoints}.
|
|
1585
|
+
*
|
|
1586
|
+
* | Property | Type | Description |
|
|
1587
|
+
* |---|---|---|
|
|
1588
|
+
* | `points` | {@linkcode Vec3Handle}`[]` | 3..256 ordered through-points of the closed loop (first point NOT repeated) |
|
|
1589
|
+
*/
|
|
1590
|
+
export const PluginGeomCreateProfileFromSplinePointsArgs = z.object({
|
|
1591
|
+
points: z.array(Vec3Handle).min(3).max(MAX_SPLINE_THROUGH_POINTS),
|
|
1592
|
+
})
|
|
1593
|
+
|
|
1594
|
+
export type PluginGeomCreateProfileFromSplinePointsArgs = z.infer<
|
|
1595
|
+
typeof PluginGeomCreateProfileFromSplinePointsArgs
|
|
1596
|
+
>
|
|
1597
|
+
|
|
910
1598
|
/**
|
|
911
1599
|
* Arguments for {@linkcode PluginGeomCreateApi.contourFromProfile}.
|
|
912
1600
|
*
|
|
@@ -962,6 +1650,7 @@ export type PluginGeomCreateBrepFromFacesArgs = z.infer<
|
|
|
962
1650
|
* | `contour` | {@linkcode ContourHandle} | The cross-section to extrude |
|
|
963
1651
|
* | `direction` | {@linkcode Vec3Components} | Extrusion direction (non-zero, finite components) |
|
|
964
1652
|
* | `amount` | `number` | Extrusion distance (finite, non-zero) |
|
|
1653
|
+
* | `options` | `object`? | Optional twist and taper: `twistInDegrees` (an angle, finite), `topScale` (a ratio, finite and positive) and `levels` (a count, 2..64) |
|
|
965
1654
|
*/
|
|
966
1655
|
export const PluginGeomCreateBrepFromExtrusionArgs = z.object({
|
|
967
1656
|
contour: ContourHandle,
|
|
@@ -974,6 +1663,13 @@ export const PluginGeomCreateBrepFromExtrusionArgs = z.object({
|
|
|
974
1663
|
.number()
|
|
975
1664
|
.finite()
|
|
976
1665
|
.refine((value) => value !== 0, { message: "amount must be non-zero" }),
|
|
1666
|
+
options: z
|
|
1667
|
+
.object({
|
|
1668
|
+
twistInDegrees: z.number().finite().optional(),
|
|
1669
|
+
topScale: z.number().finite().positive().optional(),
|
|
1670
|
+
levels: z.number().int().min(2).max(MAX_TWIST_LEVELS).optional(),
|
|
1671
|
+
})
|
|
1672
|
+
.optional(),
|
|
977
1673
|
})
|
|
978
1674
|
|
|
979
1675
|
export type PluginGeomCreateBrepFromExtrusionArgs = z.infer<
|
|
@@ -987,8 +1683,8 @@ export type PluginGeomCreateBrepFromExtrusionArgs = z.infer<
|
|
|
987
1683
|
* |---|---|---|
|
|
988
1684
|
* | `bottomContour` | {@linkcode ContourHandle} | The bottom cross-section |
|
|
989
1685
|
* | `topContour` | {@linkcode ContourHandle} | The top cross-section |
|
|
990
|
-
* | `intermediateContours` | {@linkcode ContourHandle}`[]`? | Optional in-between cross-sections, ordered bottom to top |
|
|
991
|
-
* | `options` | `object`? | Optional behavior switches: `compatibility` (`"strict"` throws on mismatched edge counts instead of auto-matching; default `"auto"`)
|
|
1686
|
+
* | `intermediateContours` | {@linkcode ContourHandle}`[]`? | Optional in-between cross-sections, ordered bottom to top (any count; more than 32 sections in all builds but carries no parameter record) |
|
|
1687
|
+
* | `options` | `object`? | Optional behavior switches: `compatibility` (`"strict"` throws on mismatched edge counts instead of auto-matching; default `"auto"`), `seamAlignment` (`"authored"` keeps the authored correspondence instead of searching seam rotations; default `"auto"`) and `smoothing` (`"smooth"` lofts every section in one pass, so the sides curve through the intermediates; default `"ruled"`) |
|
|
992
1688
|
*/
|
|
993
1689
|
export const PluginGeomCreateBrepFromLoftArgs = z.object({
|
|
994
1690
|
bottomContour: ContourHandle,
|
|
@@ -998,6 +1694,7 @@ export const PluginGeomCreateBrepFromLoftArgs = z.object({
|
|
|
998
1694
|
.object({
|
|
999
1695
|
compatibility: z.enum(["strict", "auto"]).optional(),
|
|
1000
1696
|
seamAlignment: z.enum(["authored", "auto"]).optional(),
|
|
1697
|
+
smoothing: z.enum(["ruled", "smooth"]).optional(),
|
|
1001
1698
|
})
|
|
1002
1699
|
.optional(),
|
|
1003
1700
|
})
|
|
@@ -1050,16 +1747,99 @@ const FiniteVec3Components = z.object({
|
|
|
1050
1747
|
* | Property | Type | Description |
|
|
1051
1748
|
* |---|---|---|
|
|
1052
1749
|
* | `brep` | {@linkcode BrepHandle} | The solid whose edges to round |
|
|
1053
|
-
* | `edges` | {@linkcode EdgeHandle}`[]` | The
|
|
1054
|
-
* | `radius` | `number` | Fillet radius (positive, finite) |
|
|
1750
|
+
* | `edges` | {@linkcode EdgeHandle}`[]` | The edges to fillet (one or more; more than 64 builds but carries no parameter record) |
|
|
1751
|
+
* | `radius` | `number` | Fillet radius (positive, finite); the start radius with `endRadius`, unused with `radii` |
|
|
1752
|
+
* | `options` | `object`? | Optional variable blend: `endRadius` (positive, finite) or `radii` (2..32 rows of `{ position, radius }`, `position` a ratio 0..1 strictly increasing). Mutually exclusive, and either one takes exactly ONE edge |
|
|
1055
1753
|
*/
|
|
1056
|
-
export const PluginGeomCreateBrepFromFilletArgs = z
|
|
1754
|
+
export const PluginGeomCreateBrepFromFilletArgs = z
|
|
1755
|
+
.object({
|
|
1756
|
+
brep: BrepHandle,
|
|
1757
|
+
edges: z.array(EdgeHandle).min(1),
|
|
1758
|
+
radius: z.number().finite().positive(),
|
|
1759
|
+
options: z
|
|
1760
|
+
.object({
|
|
1761
|
+
endRadius: z.number().finite().positive().optional(),
|
|
1762
|
+
radii: z
|
|
1763
|
+
.array(
|
|
1764
|
+
z.object({
|
|
1765
|
+
position: z.number().finite().min(0).max(1),
|
|
1766
|
+
radius: z.number().finite().positive(),
|
|
1767
|
+
}),
|
|
1768
|
+
)
|
|
1769
|
+
.min(2)
|
|
1770
|
+
.max(MAX_FILLET_LAW_SAMPLES)
|
|
1771
|
+
.optional(),
|
|
1772
|
+
})
|
|
1773
|
+
.optional(),
|
|
1774
|
+
})
|
|
1775
|
+
.superRefine((a, ctx) => {
|
|
1776
|
+
const { endRadius, radii } = a.options ?? {}
|
|
1777
|
+
if (endRadius === undefined && radii === undefined) return
|
|
1778
|
+
if (endRadius !== undefined && radii !== undefined) {
|
|
1779
|
+
ctx.addIssue({ code: "custom", message: "endRadius is mutually exclusive with radii" })
|
|
1780
|
+
}
|
|
1781
|
+
// The law belongs to the blend contour the one edge lies on, and `position`
|
|
1782
|
+
// is measured from that edge's start: a second edge would have no origin.
|
|
1783
|
+
if (a.edges.length !== 1) {
|
|
1784
|
+
ctx.addIssue({
|
|
1785
|
+
code: "custom",
|
|
1786
|
+
message: "a variable fillet takes exactly one edge — the blend contour it runs along",
|
|
1787
|
+
})
|
|
1788
|
+
}
|
|
1789
|
+
if (radii?.some((row, i) => i > 0 && row.position <= radii[i - 1].position)) {
|
|
1790
|
+
ctx.addIssue({ code: "custom", message: "radii positions must strictly increase" })
|
|
1791
|
+
}
|
|
1792
|
+
})
|
|
1793
|
+
|
|
1794
|
+
export type PluginGeomCreateBrepFromFilletArgs = z.infer<typeof PluginGeomCreateBrepFromFilletArgs>
|
|
1795
|
+
|
|
1796
|
+
/** An edge with the solid it belongs to. See {@linkcode OwnedEdge}. */
|
|
1797
|
+
export const OwnedEdge = z.object({
|
|
1798
|
+
edge: EdgeHandle,
|
|
1057
1799
|
brep: BrepHandle,
|
|
1058
|
-
|
|
1059
|
-
radius: z.number().finite().positive(),
|
|
1800
|
+
face: FaceHandle.optional(),
|
|
1060
1801
|
})
|
|
1061
1802
|
|
|
1062
|
-
|
|
1803
|
+
/**
|
|
1804
|
+
* Arguments for {@linkcode PluginGeomCreateApi.brepFromPatch}.
|
|
1805
|
+
*
|
|
1806
|
+
* | Property | Type | Description |
|
|
1807
|
+
* |---|---|---|
|
|
1808
|
+
* | `boundary` | ({@linkcode CurveHandle} \| {@linkcode OwnedEdge})`[]` | 3..16 items forming one closed loop |
|
|
1809
|
+
* | `thickness` | `number` | Solid thickness in internal length units (positive, finite) |
|
|
1810
|
+
* | `options` | `object`? | `interiorPoints` (≤ 64 plain `{x, y, z}` the surface is pulled through), `continuity` (`"position"` default, or `"tangent"` — every item must then be an edge item naming its `face`), `side` (`"below"` default, or `"above"`) |
|
|
1811
|
+
*/
|
|
1812
|
+
export const PluginGeomCreateBrepFromPatchArgs = z
|
|
1813
|
+
.object({
|
|
1814
|
+
boundary: z
|
|
1815
|
+
.array(z.union([CurveHandle, OwnedEdge]))
|
|
1816
|
+
.min(3)
|
|
1817
|
+
.max(MAX_PATCH_BOUNDARY_CURVES),
|
|
1818
|
+
thickness: z.number().finite().positive(),
|
|
1819
|
+
options: z
|
|
1820
|
+
.object({
|
|
1821
|
+
interiorPoints: z.array(FiniteVec3Components).max(MAX_PATCH_INTERIOR_POINTS).optional(),
|
|
1822
|
+
continuity: z.enum(["position", "tangent"]).optional(),
|
|
1823
|
+
side: z.enum(["below", "above"]).optional(),
|
|
1824
|
+
})
|
|
1825
|
+
.optional(),
|
|
1826
|
+
})
|
|
1827
|
+
.superRefine((a, ctx) => {
|
|
1828
|
+
if (a.options?.continuity !== "tangent") return
|
|
1829
|
+
// The kernel's filling call (`Add_2`) follows exactly ONE support face per
|
|
1830
|
+
// edge, but a solid edge touches two faces. So a tangent patch must say
|
|
1831
|
+
// which face to follow, for every item, and this is checked before the host
|
|
1832
|
+
// runs.
|
|
1833
|
+
if (a.boundary.some((item) => !("edge" in item) || item.face === undefined)) {
|
|
1834
|
+
ctx.addIssue({
|
|
1835
|
+
code: "custom",
|
|
1836
|
+
message:
|
|
1837
|
+
'continuity: "tangent" needs every boundary item to be an edge with its brep and the face to continue',
|
|
1838
|
+
})
|
|
1839
|
+
}
|
|
1840
|
+
})
|
|
1841
|
+
|
|
1842
|
+
export type PluginGeomCreateBrepFromPatchArgs = z.infer<typeof PluginGeomCreateBrepFromPatchArgs>
|
|
1063
1843
|
|
|
1064
1844
|
/**
|
|
1065
1845
|
* Arguments for {@linkcode PluginGeomCreateApi.brepFromOffset}.
|
|
@@ -1085,7 +1865,7 @@ export type PluginGeomCreateBrepFromOffsetArgs = z.infer<typeof PluginGeomCreate
|
|
|
1085
1865
|
* | Property | Type | Description |
|
|
1086
1866
|
* |---|---|---|
|
|
1087
1867
|
* | `brep` | {@linkcode BrepHandle} | The solid to hollow |
|
|
1088
|
-
* | `openFaces` | {@linkcode FaceHandle}`[]` | The faces to remove as openings (
|
|
1868
|
+
* | `openFaces` | {@linkcode FaceHandle}`[]` | The faces to remove as openings (one or more; more than 32 builds but carries no parameter record) |
|
|
1089
1869
|
* | `thickness` | `number` | Wall thickness (positive, finite) |
|
|
1090
1870
|
*/
|
|
1091
1871
|
export const PluginGeomCreateBrepFromShellArgs = z.object({
|
|
@@ -1113,13 +1893,51 @@ export const PluginGeomCreateBrepsFromSplitArgs = z.object({
|
|
|
1113
1893
|
|
|
1114
1894
|
export type PluginGeomCreateBrepsFromSplitArgs = z.infer<typeof PluginGeomCreateBrepsFromSplitArgs>
|
|
1115
1895
|
|
|
1896
|
+
/**
|
|
1897
|
+
* Arguments for {@linkcode PluginGeomCreateApi.brepsFromSplitByFace}.
|
|
1898
|
+
*
|
|
1899
|
+
* | Property | Type | Description |
|
|
1900
|
+
* |---|---|---|
|
|
1901
|
+
* | `brep` | {@linkcode BrepHandle} | The solid to cut |
|
|
1902
|
+
* | `toolFace` | {@linkcode FaceHandle} | The cutting face (read-only) |
|
|
1903
|
+
* | `toolBrep` | {@linkcode BrepHandle} | The solid `toolFace` belongs to (owner last) |
|
|
1904
|
+
*/
|
|
1905
|
+
export const PluginGeomCreateBrepsFromSplitByFaceArgs = z.object({
|
|
1906
|
+
brep: BrepHandle,
|
|
1907
|
+
toolFace: FaceHandle,
|
|
1908
|
+
toolBrep: BrepHandle,
|
|
1909
|
+
})
|
|
1910
|
+
|
|
1911
|
+
export type PluginGeomCreateBrepsFromSplitByFaceArgs = z.infer<
|
|
1912
|
+
typeof PluginGeomCreateBrepsFromSplitByFaceArgs
|
|
1913
|
+
>
|
|
1914
|
+
|
|
1915
|
+
/**
|
|
1916
|
+
* Arguments for {@linkcode PluginGeomCreateApi.curvesFromProjection}.
|
|
1917
|
+
*
|
|
1918
|
+
* | Property | Type | Description |
|
|
1919
|
+
* |---|---|---|
|
|
1920
|
+
* | `curve` | {@linkcode CurveHandle} | The curve to project |
|
|
1921
|
+
* | `face` | {@linkcode FaceHandle} | The face to project onto |
|
|
1922
|
+
* | `faceBrep` | {@linkcode BrepHandle} | The solid `face` belongs to (owner last) |
|
|
1923
|
+
*/
|
|
1924
|
+
export const PluginGeomCreateCurvesFromProjectionArgs = z.object({
|
|
1925
|
+
curve: CurveHandle,
|
|
1926
|
+
face: FaceHandle,
|
|
1927
|
+
faceBrep: BrepHandle,
|
|
1928
|
+
})
|
|
1929
|
+
|
|
1930
|
+
export type PluginGeomCreateCurvesFromProjectionArgs = z.infer<
|
|
1931
|
+
typeof PluginGeomCreateCurvesFromProjectionArgs
|
|
1932
|
+
>
|
|
1933
|
+
|
|
1116
1934
|
/**
|
|
1117
1935
|
* Arguments for {@linkcode PluginGeomCreateApi.brepFromChamfer}.
|
|
1118
1936
|
*
|
|
1119
1937
|
* | Property | Type | Description |
|
|
1120
1938
|
* |---|---|---|
|
|
1121
1939
|
* | `brep` | {@linkcode BrepHandle} | The solid whose edges to bevel |
|
|
1122
|
-
* | `edges` | {@linkcode EdgeHandle}`[]` | The
|
|
1940
|
+
* | `edges` | {@linkcode EdgeHandle}`[]` | The edges to chamfer (one or more; more than 64 builds but carries no parameter record) |
|
|
1123
1941
|
* | `distance` | `number` | Chamfer distance from the edge on each adjacent face (positive, finite) |
|
|
1124
1942
|
*/
|
|
1125
1943
|
export const PluginGeomCreateBrepFromChamferArgs = z.object({
|
|
@@ -1142,8 +1960,8 @@ const SweepScaleFactor = z.number().finite().min(1e-3).max(1e3)
|
|
|
1142
1960
|
* | Property | Type | Description |
|
|
1143
1961
|
* |---|---|---|
|
|
1144
1962
|
* | `profile` | {@linkcode ContourHandle} | The cross-section to sweep (hole-free) |
|
|
1145
|
-
* | `path` | {@linkcode Vec3Components}`[]` | The polyline path (
|
|
1146
|
-
* | `options` | `object`? | Optional scale law: `startScale`/`endScale` (linear taper by arc length) or per-point `scales` (mutually exclusive; factors finite, 1e-3..1e3; `scales.length` must equal `path.length`). Optional corner `transition`: `"miter"` (default) or `{ bevel }` (chamfered corners; finite, 1e-3..1e3) |
|
|
1963
|
+
* | `path` | {@linkcode Vec3Components}`[]` | The polyline path (2 or more points, finite components — more than 512 builds but carries no parameter record; repeating the first point as the last closes it into a ring — closed paths must be flat and straight-segmented and take a straight-edged profile) |
|
|
1964
|
+
* | `options` | `object`? | Optional scale law: `startScale`/`endScale` (linear taper by arc length) or per-point `scales` (mutually exclusive; factors finite, 1e-3..1e3; `scales.length` must equal `path.length`). Optional corner `transition`: `"miter"` (default), `"round"` (arc-carried corners) or `{ bevel }` (chamfered corners; finite, 1e-3..1e3) |
|
|
1147
1965
|
*/
|
|
1148
1966
|
export const PluginGeomCreateBrepFromSweepArgs = z
|
|
1149
1967
|
.object({
|
|
@@ -1157,6 +1975,7 @@ export const PluginGeomCreateBrepFromSweepArgs = z
|
|
|
1157
1975
|
transition: z
|
|
1158
1976
|
.union([
|
|
1159
1977
|
z.literal("miter"),
|
|
1978
|
+
z.literal("round"),
|
|
1160
1979
|
z.object({ bevel: z.number().finite().min(1e-3).max(1e3) }),
|
|
1161
1980
|
])
|
|
1162
1981
|
.optional(),
|
|
@@ -1182,14 +2001,38 @@ export const PluginGeomCreateBrepFromSweepArgs = z
|
|
|
1182
2001
|
|
|
1183
2002
|
export type PluginGeomCreateBrepFromSweepArgs = z.infer<typeof PluginGeomCreateBrepFromSweepArgs>
|
|
1184
2003
|
|
|
2004
|
+
/**
|
|
2005
|
+
* Arguments for {@linkcode PluginGeomCreateApi.brepFromSweepAlongCurve}.
|
|
2006
|
+
*
|
|
2007
|
+
* | Property | Type | Description |
|
|
2008
|
+
* |---|---|---|
|
|
2009
|
+
* | `profile` | {@linkcode ContourHandle} | The cross-section to sweep (hole-free) |
|
|
2010
|
+
* | `path` | {@linkcode CurveHandle}`[]` | 1..64 curves, ordered, meeting end to end |
|
|
2011
|
+
* | `options` | `object`? | `orientation` — `"upright"` (default), `"frenet"` or `"fixed"`; `rail` — a second guide {@linkcode CurveHandle} |
|
|
2012
|
+
*/
|
|
2013
|
+
export const PluginGeomCreateBrepFromSweepAlongCurveArgs = z.object({
|
|
2014
|
+
profile: ContourHandle,
|
|
2015
|
+
path: z.array(CurveHandle).min(1).max(MAX_PATH_CURVES),
|
|
2016
|
+
options: z
|
|
2017
|
+
.object({
|
|
2018
|
+
orientation: z.enum(["frenet", "fixed", "upright"]).optional(),
|
|
2019
|
+
rail: CurveHandle.optional(),
|
|
2020
|
+
})
|
|
2021
|
+
.optional(),
|
|
2022
|
+
})
|
|
2023
|
+
|
|
2024
|
+
export type PluginGeomCreateBrepFromSweepAlongCurveArgs = z.infer<
|
|
2025
|
+
typeof PluginGeomCreateBrepFromSweepAlongCurveArgs
|
|
2026
|
+
>
|
|
2027
|
+
|
|
1185
2028
|
/**
|
|
1186
2029
|
* Arguments for {@linkcode PluginGeomCreateApi.brepFromRevolution}.
|
|
1187
2030
|
*
|
|
1188
2031
|
* | Property | Type | Description |
|
|
1189
2032
|
* |---|---|---|
|
|
1190
2033
|
* | `profile` | {@linkcode ContourHandle} | The cross-section to revolve (holes allowed) |
|
|
1191
|
-
* | `axisOrigin` | {@linkcode Vec3Components} | A point on the revolution axis (finite components) |
|
|
1192
|
-
* | `axisDirection` | {@linkcode Vec3Components} | The axis direction (non-zero, finite components) |
|
|
2034
|
+
* | `axisOrigin` | {@linkcode Vec3Components} | A point on the revolution axis (finite components; the axis must lie in the plane of the profile) |
|
|
2035
|
+
* | `axisDirection` | {@linkcode Vec3Components} | The axis direction (non-zero, finite components; the axis must lie in the plane of the profile) |
|
|
1193
2036
|
* | `angleInDegrees` | `number`? | Revolution angle in degrees (0 < angle ≤ 360; default 360) |
|
|
1194
2037
|
*/
|
|
1195
2038
|
export const PluginGeomCreateBrepFromRevolutionArgs = z.object({
|
|
@@ -1202,3 +2045,89 @@ export const PluginGeomCreateBrepFromRevolutionArgs = z.object({
|
|
|
1202
2045
|
export type PluginGeomCreateBrepFromRevolutionArgs = z.infer<
|
|
1203
2046
|
typeof PluginGeomCreateBrepFromRevolutionArgs
|
|
1204
2047
|
>
|
|
2048
|
+
|
|
2049
|
+
/**
|
|
2050
|
+
* Arguments for {@linkcode PluginGeomCreateApi.brepFromSphere}.
|
|
2051
|
+
*
|
|
2052
|
+
* | Property | Type | Description |
|
|
2053
|
+
* |---|---|---|
|
|
2054
|
+
* | `centre` | {@linkcode Vec3Components} | Sphere centre (finite components) |
|
|
2055
|
+
* | `radius` | `number` | Sphere radius (finite; positivity is checked host-side so the error names the parameter) |
|
|
2056
|
+
*/
|
|
2057
|
+
export const PluginGeomCreateBrepFromSphereArgs = z.object({
|
|
2058
|
+
centre: FiniteVec3Components,
|
|
2059
|
+
radius: z.number().finite(),
|
|
2060
|
+
})
|
|
2061
|
+
|
|
2062
|
+
export type PluginGeomCreateBrepFromSphereArgs = z.infer<
|
|
2063
|
+
typeof PluginGeomCreateBrepFromSphereArgs
|
|
2064
|
+
>
|
|
2065
|
+
|
|
2066
|
+
/**
|
|
2067
|
+
* Arguments for {@linkcode PluginGeomCreateApi.brepFromCylinder}.
|
|
2068
|
+
*
|
|
2069
|
+
* | Property | Type | Description |
|
|
2070
|
+
* |---|---|---|
|
|
2071
|
+
* | `base` | {@linkcode Vec3Components} | Centre of the bottom cap (finite components) |
|
|
2072
|
+
* | `axis` | {@linkcode Vec3Components} | Axis direction (non-zero, finite components) |
|
|
2073
|
+
* | `radius` | `number` | Cylinder radius (finite, positive) |
|
|
2074
|
+
* | `height` | `number` | Height along `axis` (finite, positive) |
|
|
2075
|
+
*/
|
|
2076
|
+
export const PluginGeomCreateBrepFromCylinderArgs = z.object({
|
|
2077
|
+
base: FiniteVec3Components,
|
|
2078
|
+
axis: FiniteVec3Components,
|
|
2079
|
+
radius: z.number().finite(),
|
|
2080
|
+
height: z.number().finite(),
|
|
2081
|
+
})
|
|
2082
|
+
|
|
2083
|
+
export type PluginGeomCreateBrepFromCylinderArgs = z.infer<
|
|
2084
|
+
typeof PluginGeomCreateBrepFromCylinderArgs
|
|
2085
|
+
>
|
|
2086
|
+
|
|
2087
|
+
/**
|
|
2088
|
+
* Arguments for {@linkcode PluginGeomCreateApi.brepFromCone}.
|
|
2089
|
+
*
|
|
2090
|
+
* | Property | Type | Description |
|
|
2091
|
+
* |---|---|---|
|
|
2092
|
+
* | `base` | {@linkcode Vec3Components} | Centre of the bottom cap (finite components) |
|
|
2093
|
+
* | `axis` | {@linkcode Vec3Components} | Axis direction (non-zero, finite components) |
|
|
2094
|
+
* | `baseRadius` | `number` | Radius at the base (finite, positive) |
|
|
2095
|
+
* | `height` | `number` | Height along `axis` (finite, positive) |
|
|
2096
|
+
* | `topRadius` | `number`? | Radius at the top (finite, ≥ 0, ≠ `baseRadius`; default 0 = apex) |
|
|
2097
|
+
*/
|
|
2098
|
+
export const PluginGeomCreateBrepFromConeArgs = z
|
|
2099
|
+
.object({
|
|
2100
|
+
base: FiniteVec3Components,
|
|
2101
|
+
axis: FiniteVec3Components,
|
|
2102
|
+
baseRadius: z.number().finite(),
|
|
2103
|
+
height: z.number().finite(),
|
|
2104
|
+
topRadius: z.number().finite().optional(),
|
|
2105
|
+
})
|
|
2106
|
+
.refine((a) => (a.topRadius ?? 0) !== a.baseRadius, {
|
|
2107
|
+
message: "topRadius must differ from baseRadius — equal radii are a cylinder",
|
|
2108
|
+
})
|
|
2109
|
+
|
|
2110
|
+
export type PluginGeomCreateBrepFromConeArgs = z.infer<typeof PluginGeomCreateBrepFromConeArgs>
|
|
2111
|
+
|
|
2112
|
+
/**
|
|
2113
|
+
* Arguments for {@linkcode PluginGeomCreateApi.brepFromTorus}.
|
|
2114
|
+
*
|
|
2115
|
+
* | Property | Type | Description |
|
|
2116
|
+
* |---|---|---|
|
|
2117
|
+
* | `centre` | {@linkcode Vec3Components} | Torus centre (finite components) |
|
|
2118
|
+
* | `axis` | {@linkcode Vec3Components} | Plane normal of the ring (non-zero, finite components) |
|
|
2119
|
+
* | `majorRadius` | `number` | Ring radius, centre to tube centre (finite, positive) |
|
|
2120
|
+
* | `minorRadius` | `number` | Tube radius (finite, positive, strictly less than `majorRadius`) |
|
|
2121
|
+
*/
|
|
2122
|
+
export const PluginGeomCreateBrepFromTorusArgs = z
|
|
2123
|
+
.object({
|
|
2124
|
+
centre: FiniteVec3Components,
|
|
2125
|
+
axis: FiniteVec3Components,
|
|
2126
|
+
majorRadius: z.number().finite(),
|
|
2127
|
+
minorRadius: z.number().finite(),
|
|
2128
|
+
})
|
|
2129
|
+
.refine((a) => a.minorRadius < a.majorRadius, {
|
|
2130
|
+
message: "minorRadius must be smaller than majorRadius — the torus would self-intersect",
|
|
2131
|
+
})
|
|
2132
|
+
|
|
2133
|
+
export type PluginGeomCreateBrepFromTorusArgs = z.infer<typeof PluginGeomCreateBrepFromTorusArgs>
|